Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix publish regression and prevent superfluous data export #4158

Merged
merged 2 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions contentcuration/contentcuration/tests/test_exportchannel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import absolute_import

import json
import os
import random
import string
Expand Down Expand Up @@ -302,8 +301,8 @@ def test_channel_icon_encoding(self):
def test_assessment_metadata(self):
for i, exercise in enumerate(kolibri_models.ContentNode.objects.filter(kind="exercise")):
asm = exercise.assessmentmetadata.first()
self.assertTrue(isinstance(json.loads(asm.assessment_item_ids), list))
mastery = json.loads(asm.mastery_model)
self.assertTrue(isinstance(asm.assessment_item_ids, list))
mastery = asm.mastery_model
self.assertTrue(isinstance(mastery, dict))
self.assertEqual(mastery["type"], exercises.DO_ALL if i == 0 else exercises.M_OF_N)
self.assertEqual(mastery["m"], 3 if i == 0 else 1)
Expand Down Expand Up @@ -398,6 +397,12 @@ def test_publish_no_modify_exercise_extra_fields(self):
"n": 2,
"mastery_model": exercises.M_OF_N,
})
published_exercise = kolibri_models.ContentNode.objects.get(title="Mastery test")
self.assertEqual(published_exercise.options["completion_criteria"]["threshold"], {
"m": 1,
"n": 2,
"mastery_model": exercises.M_OF_N,
})

def test_publish_no_modify_legacy_exercise_extra_fields(self):
current_exercise = cc.ContentNode.objects.get(title="Legacy Mastery test")
Expand Down
7 changes: 4 additions & 3 deletions contentcuration/contentcuration/utils/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import uuid
import zipfile
from builtins import str
from copy import deepcopy
from itertools import chain

from django.conf import settings
Expand Down Expand Up @@ -494,7 +495,7 @@ def process_assessment_metadata(ccnode, kolibrinode):
randomize = extra_fields.get('randomize') if extra_fields.get('randomize') is not None else True
assessment_item_ids = [a.assessment_id for a in assessment_items]

exercise_data = extra_fields.get('options').get('completion_criteria').get('threshold')
exercise_data = deepcopy(extra_fields.get('options').get('completion_criteria').get('threshold'))

exercise_data_type = exercise_data.get('mastery_model', "")

Expand Down Expand Up @@ -526,9 +527,9 @@ def process_assessment_metadata(ccnode, kolibrinode):
kolibrimodels.AssessmentMetaData.objects.create(
id=uuid.uuid4(),
contentnode=kolibrinode,
assessment_item_ids=json.dumps(assessment_item_ids),
assessment_item_ids=assessment_item_ids,
number_of_assessments=assessment_items.count(),
mastery_model=json.dumps(mastery_model),
mastery_model=mastery_model,
randomize=randomize,
is_manipulable=ccnode.kind_id == content_kinds.EXERCISE,
)
Expand Down