{ "source": { "author": { "name": "Christian Lawson-Perfect" } }, "name": "List of codewords", "short_name": "list-of-codewords", "description": "

The student must enter the given list of codewords.

", "help_url": "", "input_widget": "string", "input_options": { "correctAnswer": "join(map(string(x),x,settings[\"correctAnswer\"]),\", \")", "hint": { "static": true, "value": "Enter a list of codewords, separated by commas." }, "allowEmpty": { "static": true, "value": false } }, "can_be_gap": true, "can_be_step": true, "marking_script": "mark:\napply(is_list_of_codewords);\napply(student_codewords);\napply(is_correct_list) \n\ninterpreted_answer:\nstudent_codewords\n\nfield_size:\nfield_size(correct_answer[0])\n\ncorrect_answer:\nsettings[\"correctAnswer\"]\n\nstudent_codewords:\ntry(\n map(codeword(x,field_size),x,filter(x<>\"\",x,split_regex(studentAnswer,\"\\\\s*,\\\\s*\"))),\n msg,\n fail(msg)\n)\n\nis_list_of_codewords:\nif(len(match_regex(\"\\\\s*\\\\d+(\\\\s*,\\\\s*\\\\d+)*\\\\s*(,\\\\s*)?$\",studentAnswer))>0,\n true\n,\n fail(\"Your answer is not a list of codewords.\");\n false\n)\n\nis_correct_list:\ncorrectif(code(student_codewords)=code(correct_answer))", "marking_notes": [ { "name": "mark", "description": "This is the main marking note. It should award credit and provide feedback based on the student's answer.", "definition": "apply(is_list_of_codewords);\napply(student_codewords);\napply(is_correct_list) " }, { "name": "interpreted_answer", "description": "A value representing the student's answer to this part.", "definition": "student_codewords" }, { "name": "field_size", "description": "", "definition": "field_size(correct_answer[0])" }, { "name": "correct_answer", "description": "", "definition": "settings[\"correctAnswer\"]" }, { "name": "student_codewords", "description": "", "definition": "try(\n map(codeword(x,field_size),x,filter(x<>\"\",x,split_regex(studentAnswer,\"\\\\s*,\\\\s*\"))),\n msg,\n fail(msg)\n)" }, { "name": "is_list_of_codewords", "description": "", "definition": "if(len(match_regex(\"\\\\s*\\\\d+(\\\\s*,\\\\s*\\\\d+)*\\\\s*(,\\\\s*)?$\",studentAnswer))>0,\n true\n,\n fail(\"Your answer is not a list of codewords.\");\n false\n)" }, { "name": "is_correct_list", "description": "", "definition": "correctif(code(student_codewords)=code(correct_answer))" } ], "settings": [ { "name": "correctAnswer", "label": "Correct answer", "help_url": "", "hint": "A list containing all the codewords that the student must enter.", "input_type": "code", "default_value": "", "evaluate": true } ], "public_availability": "always", "published": true, "extensions": [ "codewords" ] }