File tree Expand file tree Collapse file tree
contentcuration/contentcuration Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2250,11 +2250,13 @@ def mark_complete(self): # noqa C901
22502250 | (
22512251 # A non-blank question
22522252 ~ Q (question = "" )
2253- # Non-blank answers
2254- & ~ Q (answers = "[]" )
2255- # With either an input question or one answer marked as correct
2253+ # Non-blank answers, unless it is a free response question
2254+ # (which is allowed to have no answers)
2255+ & (~ Q (answers = "[]" ) | Q (type = exercises .FREE_RESPONSE ))
2256+ # With either an input or free response question or one answer marked as correct
22562257 & (
22572258 Q (type = exercises .INPUT_QUESTION )
2259+ | Q (type = exercises .FREE_RESPONSE )
22582260 | Q (answers__iregex = r'"correct":\s*true' )
22592261 )
22602262 )
Original file line number Diff line number Diff line change @@ -1223,6 +1223,29 @@ def test_create_exercise_invalid_assessment_item_no_answers(self):
12231223 new_obj .mark_complete ()
12241224 self .assertFalse (new_obj .complete )
12251225
1226+ def test_create_exercise_valid_assessment_item_free_response_no_answers (self ):
1227+ licenses = list (
1228+ License .objects .filter (
1229+ copyright_holder_required = False , is_custom = False
1230+ ).values_list ("pk" , flat = True )
1231+ )
1232+ channel = testdata .channel ()
1233+ new_obj = ContentNode (
1234+ title = "yes" ,
1235+ kind_id = content_kinds .EXERCISE ,
1236+ parent = channel .main_tree ,
1237+ license_id = licenses [0 ],
1238+ extra_fields = self .new_extra_fields ,
1239+ )
1240+ new_obj .save ()
1241+ AssessmentItem .objects .create (
1242+ contentnode = new_obj ,
1243+ question = "This is a question" ,
1244+ type = exercises .FREE_RESPONSE ,
1245+ )
1246+ new_obj .mark_complete ()
1247+ self .assertTrue (new_obj .complete )
1248+
12261249 def test_create_exercise_invalid_assessment_item_no_correct_answers (self ):
12271250 licenses = list (
12281251 License .objects .filter (
You can’t perform that action at this time.
0 commit comments