// Numbas version: exam_results_page_options {"name": "Sets: Set logic", "extensions": ["geogebra"], "custom_part_types": [{"source": {"pk": 2, "author": {"name": "Christian Lawson-Perfect", "pk": 7}, "edit_page": "/part_type/2/edit"}, "name": "List of numbers", "short_name": "list-of-numbers", "description": "

The answer is a comma-separated list of numbers.

\n

The list is marked correct if each number occurs the same number of times as in the expected answer, and no extra numbers are present.

\n

You can optionally treat the answer as a set, so the number of occurrences doesn't matter, only whether each number is included or not.

", "help_url": "", "input_widget": "string", "input_options": {"correctAnswer": "join(\n if(settings[\"correctAnswerFractions\"],\n map(let([a,b],rational_approximation(x), string(a/b)),x,settings[\"correctAnswer\"])\n ,\n settings[\"correctAnswer\"]\n ),\n settings[\"separator\"] + \" \"\n)", "hint": {"static": false, "value": "if(settings[\"show_input_hint\"],\n \"Enter a list of numbers separated by {settings['separator']}.\",\n \"\"\n)"}, "allowEmpty": {"static": true, "value": true}}, "can_be_gap": true, "can_be_step": true, "marking_script": "bits:\nlet(b,filter(x<>\"\",x,split(studentAnswer,settings[\"separator\"])),\n if(isSet,list(set(b)),b)\n)\n\nexpected_numbers:\nlet(l,settings[\"correctAnswer\"] as \"list\",\n if(isSet,list(set(l)),l)\n)\n\nvalid_numbers:\nif(all(map(not isnan(x),x,interpreted_answer)),\n true,\n let(index,filter(isnan(interpreted_answer[x]),x,0..len(interpreted_answer)-1)[0], wrong, bits[index],\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": "let(b,filter(x<>\"\",x,split(studentAnswer,settings[\"separator\"])),\n if(isSet,list(set(b)),b)\n)"}, {"name": "expected_numbers", "description": "", "definition": "let(l,settings[\"correctAnswer\"] as \"list\",\n if(isSet,list(set(l)),l)\n)"}, {"name": "valid_numbers", "description": "

Is every number in the student's list valid?

", "definition": "if(all(map(not isnan(x),x,interpreted_answer)),\n true,\n let(index,filter(isnan(interpreted_answer[x]),x,0..len(interpreted_answer)-1)[0], wrong, bits[index],\n warn(wrong+\" is not a valid number\");\n fail(wrong+\" is not a valid number.\")\n )\n )"}, {"name": "is_sorted", "description": "

Are the student's answers in ascending order?

", "definition": "assert(sort(interpreted_answer)=interpreted_answer,\n multiply_credit(0.5,\"Not in order\")\n )"}, {"name": "included", "description": "

Is each number in the expected answer present in the student's list the correct number of times?

", "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": "all(included)"}, {"name": "no_extras", "description": "

True if the student's list doesn't contain any numbers that aren't in the expected answer.

", "definition": "if(all(map(x in expected_numbers, x, interpreted_answer)),\n true\n ,\n incorrect(\"Your answer contains \"+extra_numbers[0]+\" but should not.\");\n false\n )"}, {"name": "interpreted_answer", "description": "A value representing the student's answer to this part.", "definition": "if(lower(studentAnswer) in [\"empty\",\"\u2205\"],[],\n map(\n if(settings[\"allowFractions\"],parsenumber_or_fraction(x,notationStyles), parsenumber(x,notationStyles))\n ,x\n ,bits\n )\n)"}, {"name": "mark", "description": "This is the main marking note. It should award credit and provide feedback based on the student's answer.", "definition": "if(studentanswer=\"\",fail(\"You have not entered an answer\"),false);\napply(valid_numbers);\napply(included);\napply(no_extras);\ncorrectif(all_included and no_extras)"}, {"name": "notationStyles", "description": "", "definition": "[\"en\"]"}, {"name": "isSet", "description": "

Should the answer be considered as a set, so the number of times an element occurs doesn't matter?

", "definition": "settings[\"isSet\"]"}, {"name": "extra_numbers", "description": "

Numbers included in the student's answer that are not in the expected list.

", "definition": "filter(not (x in expected_numbers),x,interpreted_answer)"}], "settings": [{"name": "correctAnswer", "label": "Correct answer", "help_url": "", "hint": "The list of numbers that the student should enter. The order does not matter.", "input_type": "code", "default_value": "", "evaluate": true}, {"name": "allowFractions", "label": "Allow the student to enter fractions?", "help_url": "", "hint": "", "input_type": "checkbox", "default_value": false}, {"name": "correctAnswerFractions", "label": "Display the correct answers as fractions?", "help_url": "", "hint": "", "input_type": "checkbox", "default_value": false}, {"name": "isSet", "label": "Is the answer a set?", "help_url": "", "hint": "If ticked, the number of times an element occurs doesn't matter, only whether it's included at all.", "input_type": "checkbox", "default_value": false}, {"name": "show_input_hint", "label": "Show the input hint?", "help_url": "", "hint": "", "input_type": "checkbox", "default_value": true}, {"name": "separator", "label": "Separator", "help_url": "", "hint": "The substring that should separate items in the student's list", "input_type": "string", "default_value": ",", "subvars": false}], "public_availability": "always", "published": true, "extensions": []}], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Sets: Set logic", "tags": [], "metadata": {"description": "

Tests knowledge of union, intersection, subset, strict subset & element of

", "licence": "None specified"}, "statement": "

Given that

\n

$\\var{n[0]} =\\var{Awrite}$ 

\n

and

\n

$\\var{n[1]} = \\var{Bwrite}$ 

", "advice": "

part a)

\n

$\\var{n[0]} \\cap \\var{n[1]}$ is read as 'the intersection of $\\var{n[0]}$ and $\\var{n[1]}$', which means 'the values that occur in both $\\var{n[0]}$ and $\\var{n[1]}$'.

\n

part b)

\n

$\\var{n[0]} \\cup \\var{n[1]}$ is read as 'the union of $\\var{n[0]}$ and $\\var{n[1]}$', which means 'the values that occur in either $\\var{n[0]}$ or $\\var{n[1]}$ or both'.

\n

part c)

\n

This question checks your understanding on the notation:

\n\n

", "rulesets": {}, "extensions": ["geogebra"], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"A": {"name": "A", "group": "Ungrouped variables", "definition": "distinct(sort(repeat(random(1..5),length[0])))", "description": "", "templateType": "anything", "can_override": false}, "B": {"name": "B", "group": "Ungrouped variables", "definition": "distinct(sort(repeat(random(1..5),length[1])))", "description": "", "templateType": "anything", "can_override": false}, "justA": {"name": "justA", "group": "Ungrouped variables", "definition": "A except B", "description": "", "templateType": "anything", "can_override": false}, "justB": {"name": "justB", "group": "Ungrouped variables", "definition": "B except A\n", "description": "", "templateType": "anything", "can_override": false}, "AnB": {"name": "AnB", "group": "Ungrouped variables", "definition": "sort(AuB except justA except justB)\n", "description": "", "templateType": "anything", "can_override": false}, "AuB": {"name": "AuB", "group": "Ungrouped variables", "definition": "distinct(sort((A+B)))", "description": "", "templateType": "anything", "can_override": false}, "n": {"name": "n", "group": "Ungrouped variables", "definition": "random(['A','B'],['B','A'],['P','Q'],['Q','P'],['R','S'],['S', 'T'],['U','V'],['V','U'])", "description": "", "templateType": "anything", "can_override": false}, "AWrite": {"name": "AWrite", "group": "Ungrouped variables", "definition": "render(safe(\"{a}\"), [\"a\": A])", "description": "", "templateType": "anything", "can_override": false}, "length": {"name": "length", "group": "Ungrouped variables", "definition": "[random(2..5), random(2..5)]", "description": "", "templateType": "anything", "can_override": false}, "Bwrite": {"name": "Bwrite", "group": "Ungrouped variables", "definition": "render(safe(\"{a}\"), [\"a\": B])", "description": "", "templateType": "anything", "can_override": false}, "notAnB": {"name": "notAnB", "group": "Ungrouped variables", "definition": "sort(B except A)", "description": "", "templateType": "anything", "can_override": false}, "trueorfalse": {"name": "trueorfalse", "group": "Ungrouped variables", "definition": "[t1, t2, t3, t4, t5,t6] ", "description": "", "templateType": "anything", "can_override": false}, "trueorfalseans": {"name": "trueorfalseans", "group": "Ungrouped variables", "definition": "[if(len(set(A)-set(B))=0,if(len(set(B)-set(A))>0,1,0),0),\n if(len(set(A)-set(B))=0,1,0),\n if(len(set(A)-set(B))=0,0,1),\n if(len(set(A)-set(B))=0,if(len(set(B)-set(A))=0,1,0),1),\n if(len(set(B)-set(A[0])) = len(set(B)),0,1),\n if(len(set(A)-set(B[1])) = len(set(A)),1,0)\n ]", "description": "", "templateType": "anything", "can_override": false}, "t1": {"name": "t1", "group": "Ungrouped variables", "definition": "\"

$\\\\var{n[0]} \\\\subset \\\\var{n[1]}$

\"", "description": "", "templateType": "long string", "can_override": false}, "t2": {"name": "t2", "group": "Ungrouped variables", "definition": "\"

$\\\\var{n[0]} \\\\subseteq \\\\var{n[1]}$

\"", "description": "", "templateType": "long string", "can_override": false}, "t3": {"name": "t3", "group": "Ungrouped variables", "definition": "\"

$\\\\var{n[0]} \\\\not \\\\subseteq \\\\var{n[1]}$

\"", "description": "", "templateType": "long string", "can_override": false}, "t4": {"name": "t4", "group": "Ungrouped variables", "definition": "\"

$\\\\var{n[0]} \\\\not \\\\subset \\\\var{n[1]}$

\"", "description": "", "templateType": "long string", "can_override": false}, "t5": {"name": "t5", "group": "Ungrouped variables", "definition": "\"

$\\\\var{A[0]} \\\\in \\\\var{n[1]}$

\"", "description": "", "templateType": "long string", "can_override": false}, "t6": {"name": "t6", "group": "Ungrouped variables", "definition": "\"

$\\\\var{B[1]} \\\\notin \\\\var{n[0]}$

\"", "description": "", "templateType": "long string", "can_override": false}}, "variablesTest": {"condition": "length(A)>1 AND length(B)>1 AND length(AnB)>0", "maxRuns": "7"}, "ungrouped_variables": ["length", "A", "B", "justA", "justB", "AnB", "AuB", "n", "AWrite", "Bwrite", "notAnB", "trueorfalse", "trueorfalseans", "t1", "t2", "t3", "t4", "t5", "t6"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "list-of-numbers", "useCustomName": false, "customName": "", "marks": "1", "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Find the set $\\var{n[0]} \\cap \\var{n[1]}$

", "settings": {"correctAnswer": "AnB", "allowFractions": false, "correctAnswerFractions": false, "isSet": false, "show_input_hint": true, "separator": ","}}, {"type": "list-of-numbers", "useCustomName": false, "customName": "", "marks": 1, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Find the set $\\var{n[0]} \\cup \\var{n[1]}$

", "settings": {"correctAnswer": "AuB", "allowFractions": false, "correctAnswerFractions": false, "isSet": true, "show_input_hint": true, "separator": ","}}, {"type": "m_n_2", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

Select all statements that are true

", "minMarks": 0, "maxMarks": "1", "shuffleChoices": true, "displayType": "checkbox", "displayColumns": 0, "minAnswers": 0, "maxAnswers": 0, "warningType": "none", "showCellAnswerState": true, "markingMethod": "all-or-nothing", "choices": "trueorfalse", "matrix": "trueorfalseans"}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "contributors": [{"name": "Ruth Hand", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3228/"}]}]}], "contributors": [{"name": "Ruth Hand", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3228/"}]}