{ "source": { "author": { "name": "Christian Lawson-Perfect" } }, "name": "Write a permutation in cycle notation", "short_name": "write-a-permutation-in-cycle-notation", "description": "
The student must write a permutation in cycle notation. You can optionally require the cycles to be disjoint and/or all of length 2.
", "help_url": "", "input_widget": "string", "input_options": { "correctAnswer": "let(ans,\n if(settings[\"must_be_transpositions\"],\n as_transpositions(settings[\"correct_answer\"]),\n show(settings[\"correct_answer\"])\n ),\n if(ans=\"\",settings[\"identity_name\"],ans)\n)", "hint": { "static": false, "value": "if(settings[\"show_hint\"],\n if(settings[\"must_be_disjoint\"],\n if(settings[\"must_be_transpositions\"],\n \"Write a permutation in cycle notation as a product of disjoint transpositions.\",\n \"Write a permutation in cycle notation as a product of disjoint cycles.\"\n ),\n if(settings[\"must_be_transpositions\"],\n \"Write a permutation in cycle notation as a product of transpositions.\",\n \"Write a permutation in cycle notation.\"\n )\n ),\n \"\"\n)" }, "allowEmpty": { "static": true, "value": false } }, "can_be_gap": true, "can_be_step": true, "marking_script": "mark:\napply(student_permutation);\napply(is_correct);\napply(is_disjoint);\napply(is_transpositions)\n\ninterpreted_answer:\nstudent_permutation\n\nis_correct:\ncorrectif(student_permutation=settings[\"correct_answer\"])\n\nis_disjoint:\nif(is_disjoint(studentAnswer),\n true\n,\n assert(not settings[\"must_be_disjoint\"],\n set_credit(0,\"You have not written your answer as a product of disjoint cycles.\"),\n );\n false\n)\n\nstudent_permutation:\ntry(\n if(studentAnswer=settings[\"identity_name\"],\n permutation(\"\"), \n permutation(studentAnswer)\n ),\n message,\n warn(\"Your answer is not valid cycle notation: \"+message);\n fail(\"Your answer is not valid cycle notation: \"+message)\n)\n\nis_transpositions:\nif(is_transpositions(studentAnswer),\n true\n,\n assert(not settings[\"must_be_transpositions\"],\n set_credit(0,\"You have not written your answer as a product of transpositions.\")\n );\n false\n)", "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(student_permutation);\napply(is_correct);\napply(is_disjoint);\napply(is_transpositions)" }, { "name": "interpreted_answer", "description": "A value representing the student's answer to this part.", "definition": "student_permutation" }, { "name": "is_correct", "description": "", "definition": "correctif(student_permutation=settings[\"correct_answer\"])" }, { "name": "is_disjoint", "description": "", "definition": "if(is_disjoint(studentAnswer),\n true\n,\n assert(not settings[\"must_be_disjoint\"],\n set_credit(0,\"You have not written your answer as a product of disjoint cycles.\"),\n );\n false\n)" }, { "name": "student_permutation", "description": "", "definition": "try(\n if(studentAnswer=settings[\"identity_name\"],\n permutation(\"\"), \n permutation(studentAnswer)\n ),\n message,\n warn(\"Your answer is not valid cycle notation: \"+message);\n fail(\"Your answer is not valid cycle notation: \"+message)\n)" }, { "name": "is_transpositions", "description": "", "definition": "if(is_transpositions(studentAnswer),\n true\n,\n assert(not settings[\"must_be_transpositions\"],\n set_credit(0,\"You have not written your answer as a product of transpositions.\")\n );\n false\n)" } ], "settings": [ { "name": "correct_answer", "label": "Correct answer", "help_url": "", "hint": "", "input_type": "code", "default_value": "", "evaluate": true }, { "name": "show_hint", "label": "Show answer input hint?", "help_url": "", "hint": "", "input_type": "checkbox", "default_value": true }, { "name": "must_be_disjoint", "label": "Must the cycles be disjoint?", "help_url": "", "hint": "", "input_type": "checkbox", "default_value": false }, { "name": "must_be_transpositions", "label": "Must the cycles be transpositions?", "help_url": "", "hint": "", "input_type": "checkbox", "default_value": false }, { "name": "identity_name", "label": "Name of the identity permutation", "help_url": "", "hint": "The student should write this string for the identity permutation.", "input_type": "string", "default_value": "e", "subvars": true } ], "public_availability": "always", "published": true, "extensions": [ "permutations" ] }