// Numbas version: exam_results_page_options {"name": "Testing JSXGraph for a Hasse diagram", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"ungrouped_variables": ["a", "b"], "functions": {"createNetwork": {"parameters": [], "language": "javascript", "type": "html", "definition": "// This function creates the board and sets it up, then returns an\n// HTML div tag containing the board.\n \n// The line is described by the equation \n// y = a*x + b\n\n// This function takes as its parameters the coefficients a and b,\n// and the coordinates (x2,y2) of a point on the line.\n\n// First, make the JSXGraph board.\n// The function provided by the JSXGraph extension wraps the board up in \n// a div tag so that it's easier to embed in the page.\nvar div = Numbas.extensions.jsxgraph.makeBoard('300px','400px',\n{boundingBox: [0,4.5,1,0.5],\n axis: false,\n showNavigation: false,\n grid: false\n});\n\n\n// div.board is the object created by JSXGraph, which you use to \n// manipulate elements\n\nvar redColor='#ff0000';\nvar blueColor='#0000ff';\nvar grayColor='#9b9b9b';\n\nvar PointStyle={face:'o', size:4, fixed:false,label:{fontSize:20}};\nvar LineStyle={fixed:true,straightFirst:false,straightLast:false,strokeWidth:2,dash:0,strokeColor:blueColor};\n\n\nquestion.parts[0].trueEdges=new Set([\"{1,2,4,5}gt{1,2,4}\", \"{1,2,3,5}gt{1,2}\", \"{1,2,3,5}gt{3}\", \"{1,3,4}gt{3,4}\", \"{1,3,4}gt{1}\", \"{1,2,4}gt{1,2}\", \"{1,2}gt{1}\", \"{1,2}gt{2}\", \"{3,4}gt{3}\"]);\n\nquestion.parts[0].allEdges = new Set([\"{1,2,4,5}gt{1,2,4}\", \"{1,2,4,5}gt{1,2}\", \"{1,2,4,5}gt{1}\", \"{1,2,4,5}gt{2}\", \"{1,2,3,5}gt{1,2}\", \"{1,2,3,5}gt{1}\", \"{1,2,3,5}gt{2}\", \"{1,2,3,5}gt{3}\", \"{1,3,4}gt{3,4}\", \"{1,3,4}gt{1}\", \"{1,3,4}gt{3}\", \"{1,2,4}gt{1,2}\", \"{1,2,4}gt{1}\", \"{1,2,4}gt{2}\", \"{1,2}gt{1}\", \"{1,2}gt{2}\", \"{3,4}gt{3}\"]);\n\nquestion.parts[0].removableEdges = new Set([\"{1,2,4,5}gt{1,2}\", \"{1,2,4,5}gt{1}\", \"{1,2,4,5}gt{2}\", \"{1,2,4,5}gt{1}\", \"{1,2,4,5}gt{2}\", \"{1,2,3,5}gt{1}\", \"{1,2,3,5}gt{2}\", \"{1,3,4}gt{3}\", \"{1,2,4}gt{1}\", \"{1,2,4}gt{2}\"]);\n\nquestion.parts[0].constructedEdges=new Set();\n\nvar lineDict={};\n\nvar point0selected=false\nvar point0\n\n\nfunction changePointStyle(){\n if(this.selected==true){\n this.selected=false;\n this.setAttribute({fillColor:redColor,strokeColor:redColor});\n \n point0selected=false\n \n } else {\n this.selected=true ;\n this.setAttribute({fillColor:blueColor,strokeColor:blueColor});\n \n if(point0selected==false){\n point0selected=true\n point0=this\n } else {\n if(point0.Y()>this.Y()){\n lineName=point0.name+\"gt\"+this.name;\n } else if (point0.Y()15){\n this.selected=false;\n this.setAttribute({fillColor:redColor,strokeColor:redColor}); \n if (point0selected==true){\n point0selected=false\n }\n }\n this.dragged=0;\n}\n\nvar board = div.board; \n\nvar PointInfoArray=[[[ 0.33, 4.00],\"{1,2,4,5}\"]\n ,[[ 0.66, 4.00],\"{1,2,3,5}\"]\n \n ,[[ 0.25, 3.00],\"{1,2,4}\" ]\n ,[[ 0.75, 3.00],\"{1,3,4}\" ]\n \n ,[[ 0.60, 2.00],\"{1,2}\" ]\n ,[[ 0.30, 2.00],\"{3,4}\" ]\n \n ,[[ 0.75, 1.00],\"{1}\" ]\n ,[[ 0.50, 1.00],\"{2}\" ]\n ,[[ 0.25, 1.00],\"{3}\" ]];\n\nPointArray=[];\nfor (i=0;iClick on the vertices and make a Hasse Diagram. Clicking on two vertices will create/destroy an edge. To unselect a vertex, click on it again.

", "metadata": {"description": "", "licence": "None specified"}, "tags": [], "variable_groups": [], "parts": [{"scripts": {"mark": {"order": "instead", "script": "var totalTrue=this.trueEdges.size;\nconsole.log(this.trueEdges);\n\nvar goodSet = new Set([...this.constructedEdges].filter(x => this.trueEdges.has(x))); \n\nvar fractionOfTrue=Math.round(100*goodSet.size/totalTrue)/100;\nvar runningGrade=fractionOfTrue;\n\nif (fractionOfTrue==0){\n var ratioPhrase=\"none\"\n} else if (fractionOfTrue<0.3){\n var ratioPhrase=\"a few\"\n} else if (fractionOfTrue<0.6){\n var ratioPhrase=\"some\"\n} else if (fractionOfTrue<0.9){\n var ratioPhrase=\"many\"\n} else if (fractionOfTrue<1){\n var ratioPhrase=\"almost all\"\n} else {\n var ratioPhrase=\"all\"\n}\nthis.setCredit(runningGrade,\"You have created \"+ratioPhrase+\" of the correct edges.\");\n\nif (fractionOfTrue<1){\n var missingSet = new Set([...this.trueEdges].filter(x => !this.constructedEdges.has(x))); \n // Just double checking there really is a missing element\n if (missingSet.size>0) {\n this.setCredit(runningGrade,\"You are missing some vital edges, for example from \"+missingSet.values().next()['value'].replace(\"gt\", \" to \")+\".\");\n }\n}\n\nvar badSet = new Set([...this.constructedEdges].filter(x => !this.allEdges.has(x))); \nvar badReduction=0;\n\nfor (let item of badSet) {\n console.log(item);\n runningGrade=Math.max(runningGrade-0.25,0);\n this.setCredit(runningGrade,\"You have edges that are do not represent a partial order, \"+item.replace(\"gt\", \" is connected to \")+\".\")\n};\n\nvar preredundantSet = new Set([...this.constructedEdges].filter(x => this.allEdges.has(x))); \nconsole.log(\"prered\");\nconsole.log(preredundantSet);\n\nvar redundantSet = new Set([...preredundantSet].filter(x => !this.trueEdges.has(x))); \n\nfor (let item of redundantSet) {\n console.log(item);\n runningGrade=Math.max(runningGrade-0.125,0);\n\n this.setCredit(runningGrade,\"The edge from \"+item.replace(\"gt\", \" to \")+\" can be reduced.\");\n};"}, "validate": {"order": "instead", "script": "return true"}}, "showCorrectAnswer": true, "type": "extension", "marks": "4", "showFeedbackIcon": true, "variableReplacementStrategy": "originalfirst", "prompt": "

{createNetwork()}

\n

Create a Hasse diagram for the subsets about under the poset relation $\\subseteq$.

", "variableReplacements": []}], "variablesTest": {"condition": "a<>b", "maxRuns": 100}, "type": "question", "contributors": [{"name": "Joshua Capel", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1479/"}]}]}], "contributors": [{"name": "Joshua Capel", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1479/"}]}