This repository was archived by the owner on Jun 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +24
-3
lines changed
Expand file tree Collapse file tree 1 file changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -1441,9 +1441,30 @@ def createquestion():
14411441 htmlsrc = request .vars ["htmlsrc" ],
14421442 )
14431443
1444- db .assignment_questions .insert (
1445- assignment_id = assignmentid , question_id = newqID , timed = timed , points = points
1446- )
1444+ if request .vars ["template" ] == "datafile" :
1445+ # datafiles are not questions, but we would like instructors to be able
1446+ # to add their own datafiles for projects or exercises. So we store
1447+ # the datafile contents in the database instead of adding a question
1448+ # to the assignment.
1449+ divid = request .vars ["name" ].strip ()
1450+ q = request .vars ["question" ].lstrip ()
1451+ q = q .split ("\n " )
1452+ first_blank = q .index ("" )
1453+ q = "\n " .join ([x .lstrip () for x in q [first_blank + 1 :]])
1454+ db .source_code .update_or_insert (
1455+ (db .source_code .acid == divid )
1456+ & (db .source_code .course_id == base_course ),
1457+ main_code = q ,
1458+ course_id = base_course ,
1459+ acid = divid ,
1460+ )
1461+ else :
1462+ db .assignment_questions .insert (
1463+ assignment_id = assignmentid ,
1464+ question_id = newqID ,
1465+ timed = timed ,
1466+ points = points ,
1467+ )
14471468
14481469 returndict = {request .vars ["name" ]: newqID , "timed" : timed , "points" : points }
14491470
You can’t perform that action at this time.
0 commit comments