Skip to content

Commit

Permalink
feat: add randomize_choices to MultiChoiceQuestion widget
Browse files Browse the repository at this point in the history
  • Loading branch information
AmooHashem committed Nov 2, 2024
1 parent fe141ca commit ded8f9e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
18 changes: 18 additions & 0 deletions apps/fsm/migrations/0222_multichoiceproblem_randomize_choices.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.1.3 on 2024-11-02 00:12

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('fsm', '0221_audio_autoplay'),
]

operations = [
migrations.AddField(
model_name='multichoiceproblem',
name='randomize_choices',
field=models.BooleanField(default=False, help_text='If enabled, the choices will be presented in random order'),
),
]
4 changes: 4 additions & 0 deletions apps/fsm/models/question_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ class MultiChoiceProblem(Problem):
max_selections = models.IntegerField(
validators=[MinValueValidator(0)], default=1)
lock_after_answer = models.BooleanField(default=False)
randomize_choices = models.BooleanField(
default=False,
help_text="If enabled, the choices will be presented in random order"
)

def clone(self, paper):
cloned_widget = clone_widget(self, paper)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ class MultiChoiceProblemSerializer(QuestionWidgetSerializer):
class Meta(QuestionWidgetSerializer.Meta):
model = MultiChoiceProblem
fields = QuestionWidgetSerializer.Meta.fields + \
['min_selections', 'max_selections', 'lock_after_answer', 'choices']
['min_selections', 'max_selections',
'lock_after_answer', 'randomize_choices', 'choices']

def create(self, validated_data):
choices_data = validated_data.pop('choices')
Expand Down

0 comments on commit ded8f9e

Please sign in to comment.