{ "source": { "author": { "name": "Michael Hoffmann" } }, "name": "Michael's copy of List of numbers", "short_name": "michael-s-copy-of-list-of-numbers", "description": "
The answer is a comma-separated list of numbers.
\nThe list is marked correct if each number occurs the same number of times as in the expected answer, and no extra numbers are present.
", "help_url": "", "input_widget": "string", "input_options": { "allowEmpty": { "static": true, "value": false }, "correctAnswer": "join(settings[\"correctAnswer\"],\",\")", "hint": { "static": true, "value": "Enter a list of numbers separated by commas." } }, "can_be_gap": true, "can_be_step": true, "marking_script": "bits:\nfilter(x<>\"\",x,split(studentAnswer,\",\"))\n\nexpected_numbers:\nsettings[\"correctAnswer\"]\n\ninterpreted_answer:\nmap(parsenumber(x,\"en\"),x,bits)\n\nvalid_numbers:\nif(all(map(not isnan(parsenumber(x,\"en\")),x,bits)),\n true,\n let(wrong,filter(isnan(parsenumber(x,\"en\")),x,bits)[0],\n warn(wrong+\" is not a valid number\");\n fail(wrong+\" is not a valid number.\")\n )\n )\n\nis_sorted:\nassert(sort(interpreted_answer)=interpreted_answer,\n multiply_credit(0.5,\"Not in order\")\n )\n\nincluded:\nmap(\n let(\n num_student,len(filter(x=y,y,interpreted_answer)),\n num_expected,len(filter(x=y,y,expected_numbers)),\n switch(\n num_student=num_expected,\n true,\n num_studentThe separate items in the student's answer
" }, { "definition": "settings[\"correctAnswer\"]", "name": "expected_numbers", "description": "" }, { "definition": "map(parsenumber(x,\"en\"),x,bits)", "name": "interpreted_answer", "description": "A value representing the student's answer to this part." }, { "definition": "if(all(map(not isnan(parsenumber(x,\"en\")),x,bits)),\n true,\n let(wrong,filter(isnan(parsenumber(x,\"en\")),x,bits)[0],\n warn(wrong+\" is not a valid number\");\n fail(wrong+\" is not a valid number.\")\n )\n )", "name": "valid_numbers", "description": "Is every number in the student's list valid?
" }, { "definition": "assert(sort(interpreted_answer)=interpreted_answer,\n multiply_credit(0.5,\"Not in order\")\n )", "name": "is_sorted", "description": "Are the student's answers in ascending order?
" }, { "definition": "map(\n let(\n num_student,len(filter(x=y,y,interpreted_answer)),\n num_expected,len(filter(x=y,y,expected_numbers)),\n switch(\n num_student=num_expected,\n true,\n num_studentHas every number been included the right number of times?
" }, { "definition": "if(all(map(x in expected_numbers, x, interpreted_answer)),\n true\n ,\n incorrect(filter(not (x in expected_numbers),x,interpreted_answer)[0]+\" is not in the list.\");\n false\n )", "name": "no_extras", "description": "True if the student's list doesn't contain any numbers that aren't in the expected answer.
" }, { "definition": "if(studentanswer=\"\",fail(\"You have not entered an answer\"),false);\n apply(valid_numbers);\n apply(included);\n apply(no_extras);\n if(all_included and no_extras,\n correct()\n ,\n incorrect()\n )", "name": "mark", "description": "This is the main marking note. It should award credit and provide feedback based on the student's answer." } ], "settings": [ { "evaluate": true, "input_type": "code", "hint": "The list of numbers that the student should enter. The order does not matter.", "default_value": "", "label": "Correct answer", "name": "correctAnswer", "help_url": "" } ], "public_availability": "always", "published": true, "extensions": [] }