diff --git a/dist/exercises.json b/dist/exercises.json index f64ba4e..d0048f8 100644 --- a/dist/exercises.json +++ b/dist/exercises.json @@ -1 +1 @@ -{"testing_off_licence":{"30":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Fix the errors and warnings to complete the code?
  • \n\n\n","initial":"/*globals INPUT OUTPUT openWebOffLicence */\nfunction getValidInteger(AGE)\n{\n if(/[0-9]+/.test(AGE)) {\n return parseInt(AGE, 10);\n }\n OUTPUT(\"warning\", \"Not a Valid Number\");\n return false;\n}\n\nfunction isValidAge(AGE)\n{ \n if(AGE <= 2 || AGE >= 150) {\n OUTPUT(\"warning\", \"Not a Valid Age\");\n return false;\n } else if(AGE < 18) {\n OUTPUT(\"warning\", \"Not Old enough to drink\");\n return false;\n }\n return true;\n}\n\nfunction main() {\n var AGE = getValidInteger(INPUT(\"age\"));\n if (AGE !== false) {\n if (isValidAge(AGE)) {\n openWebOffLicence();\n }\n }\n}\n","initial-v1":"/*globals INPUT OUTPUT openWebOffLicence */\nfunction isAgeValid(AGE)\n{\n console.log(\"AGE\", AGE);\n if(typeof AGE !== \"number\") {\n return {valid:false, warning:\"Not a Valid Number\"};\n }\n if(AGE <= 2 || AGE >= 150) {\n return {valid:false, warning:\"Not a Valid Age\"};\n }\n if(AGE < 18) {\n return {valid:false, warning:\"Not Old enough to drink\"};\n }\n return {valid:true, warning:\"\"};\n}\n\nfunction main() {\n var AGE = INPUT(\"age\");\n if (isAgeValid(AGE)) {\n openWebOffLicence();\n }\n}\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/debuged/","display":{"en-GB":"debuged"}},"label":"Debug"}},"35":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Check out what happens to the \"Air Temperature\", is that what we want?
  • \n\n\n","initial":"/*globals INPUT OUTPUT openWebOffLicence */\nfunction getValidInteger(AGE)\n{\n if(/[0-9]+/.test(AGE)) {\n return parseInt(AGE, 10);\n }\n OUTPUT(\"warning\", \"Not a Valid Number\");\n return false;\n}\n\nfunction isValidAge(AGE)\n{ \n if(AGE <= 2 || AGE >= 150) {\n OUTPUT(\"warning\", \"Not a Valid Age\");\n return false;\n } else if(AGE < 18) {\n OUTPUT(\"warning\", \"Not Old enough to drink\");\n return false;\n }\n return true;\n}\n\nfunction main() {\n var AGE = getValidInteger(INPUT(\"age\"));\n if (AGE !== false) {\n if (isValidAge(AGE)) {\n openWebOffLicence();\n }\n }\n}\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"tests":"\nfunction testIsAgeValid(number, bExpectValid, sReg) {\n var bValid = isValidAge(number);\n if( bExpectValid !== bValid) {\n return false;\n }\n \n var sWarning = $(\"#warning\").html();\n var regexObj = new RegExp(sReg, \"i\");\n var bRegResult = regexObj.test(sWarning);\n return bRegResult;\n}\n\nassert( testIsAgeValid(2, false, \"Not a Valid Age\"), '2 is \"Not a Valid Age\"', \"logic\");\nassert( testIsAgeValid(3, false, \"Not old enough to drink\"), '3 is \"Not old enough to drink\"', \"logic\");\nassert( testIsAgeValid(17, false, \"Not old enough to drink\"), '17 is \"Not old enough to drink\"', \"logic\");\nassert( testIsAgeValid(18, true, \"\"), '18 is valid', \"logic\");\nassert( testIsAgeValid(149, true, \"\"), '149 is valid', \"logic\");\nassert( testIsAgeValid(150, false, \"Not a Valid Age\"), '150 is \"Not a Valid Age\"', \"logic\");\nassert( testIsAgeValid(999999, false, \"Not a Valid Age\"), '999999999 is \"Not a Valid Age\"', \"logic\");\nassert( getValidInteger(\"ten\") === false, '\"ten\" is \"Not a Valid Number\"', \"logic\");\nassert( getValidInteger(10) === 10, '10 is \"A Valid Number\"', \"logic\");\n\n\n\n","simulation":"\n\n
    \n\n\n
    \n
    Warnings :
    \n
    \n","info":{"name":"Age Validation","tags":["selection","if","else"],"default":false,"objects":["http://utc-sheffield.github.io/tincan_curriculum/OCR_GCSE_Computing_2012/#2-1-7-Q"],"towards":[]},"context":"function INPUT(ControlName) {\n var ele = $(\"#\" + ControlName);\n if(ele.prop(\"tagName\") === \"SPAN\") {\n return ele.html();\n } else {\n return ele.val();\n }\n}\n\nfunction OUTPUT(Out, Val) {\n if(typeof Val === \"undefined\") {\n $(\"#output\").append(\"
    \" + Out + \"
    \");\n } else {\n var ele = $(\"#\" + Out);\n if(ele.prop(\"tagName\") === \"SPAN\") {\n ele.html(Val);\n } else {\n ele.val(Val);\n }\n }\n}\n\nfunction GET(ControlName) {\n return INPUT(ControlName);\n}\n\n\nfunction openWebOffLicence() {\n OUTPUT(\"Welcome to the Web Off Licence\");\n}\n\n//CODE//\n\n\n//TESTS//\n\nfunction run() {\n $(\"#output\").html(\"\");\n main();\n}\n\n$(\"#start\").click(run);\nmain();\n\n"},"student_array":{"30":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Fix the errors and warnings to complete the code?
  • \n\n\n","initial":"var students = [\"John\", \"Paul\", \"George\", \"Ringo\"];\n\n\nassert(students[0] === \"\", \"Index 0 is 'John'\", \"\");\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/debuged/","display":{"en-GB":"debuged"}},"label":"Debug"}},"35":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Check out what happens to the \"Air Temperature\", is that what we want?
  • \n\n\n","initial":"function calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) {\n if(AirTemp < MinTemp) {\n Status = \"ON\";\n } else {\n if(AirTemp < MinTemp) {\n Status = \"OFF\";\n }\n }\n return Status;\n}\n\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"40":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Check out what happens to the \"Air Temperature\", is that what we want?
  • \n\n\n","initial":"function calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) {\n if(AirTemp < MinTemp) {\n Status = \"ON\";\n } else {\n //Your code should go here\n }\n return Status;\n}\n\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/thinking/developed/","display":{"en-GB":"developed"}},"label":"Develop"}},"45":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Write the function body so that Status = \"ON\" or \"OFF\" when the boiler needs to turn On or Off
  • \n\n\n","initial":"function calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) {\n //Your code should go here\n \n return Status;\n}\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/thinking/designed/","display":{"en-GB":"designed"}},"label":"Design"}},"tests":"assert( true === true, 'Test description.', \"logic\");\n\n\n\n","simulation":"\n\n
    \n
    \n","info":{"name":"Student Array","tags":["array"],"default":true,"objects":["http://utc-sheffield.github.io/tincan_curriculum/OCR_GCSE_Computing_2012/#2-1-7-O"],"towards":[]},"context":"\nfunction INPUT(ControlName) {\n return $(\"#\" + ControlName).val();\n \n}\n\nfunction OUTPUT(Out, Val) {\n if(typeof Val === \"undefined\")\n {\n $(\"#output\").append(\"
    \" + Out + \"
    \");\n }\n else\n {\n $(\"#\" + Out).val(Val);\n }\n}\n\nfunction GET(ControlName) {\n return $(\"#\" + ControlName).val();\n}\n\n//var MinTemp = INPUT(\"mintemp\");\n\n\nfunction main(){\n//CODE//\n}\n\n//TESTS//\n\n\nfunction run() {\n stop();\n $(\"#output\").html(\"\");\n main();\n}\n\n\n$(\"#start\").click(run);\n//$(\"#stop\").click(stop);\nmain();\n\n"},"shopping_list":{"30":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Fix the errors and warnings to complete the code?
  • \n\n\n","initial":"var students = [\"John\", \"Paul\", \"George\", \"Ringo\"];\n\n\nassert(students[0] === \"\", \"Index 0 is 'John'\", \"\");\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/debuged/","display":{"en-GB":"debuged"}},"label":"Debug"}},"35":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Check out what happens to the \"Air Temperature\", is that what we want?
  • \n\n\n","initial":"function calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) {\n if(AirTemp < MinTemp) {\n Status = \"ON\";\n } else {\n if(AirTemp < MinTemp) {\n Status = \"OFF\";\n }\n }\n return Status;\n}\n\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"40":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Check out what happens to the \"Air Temperature\", is that what we want?
  • \n\n\n","initial":"function calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) {\n if(AirTemp < MinTemp) {\n Status = \"ON\";\n } else {\n //Your code should go here\n }\n return Status;\n}\n\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/thinking/developed/","display":{"en-GB":"developed"}},"label":"Develop"}},"45":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Write the function body so that Status = \"ON\" or \"OFF\" when the boiler needs to turn On or Off
  • \n\n\n","initial":"function calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) {\n //Your code should go here\n \n return Status;\n}\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/thinking/designed/","display":{"en-GB":"designed"}},"label":"Design"}},"tests":"assert( true === true, 'Test description.', \"logic\");\n\n\n\n","simulation":"\n\n
    \n
    \n","info":{"name":"Shopping List","tags":["array"],"default":false,"objects":["http://utc-sheffield.github.io/tincan_curriculum/OCR_GCSE_Computing_2012/#2-1-7-O"],"towards":[]},"context":"\nfunction INPUT(ControlName) {\n return $(\"#\" + ControlName).val();\n \n}\n\nfunction OUTPUT(Out, Val) {\n if(typeof Val === \"undefined\")\n {\n $(\"#output\").append(\"
    \" + Out + \"
    \");\n }\n else\n {\n $(\"#\" + Out).val(Val);\n }\n}\n\nfunction GET(ControlName) {\n return $(\"#\" + ControlName).val();\n}\n\n//var MinTemp = INPUT(\"mintemp\");\n\n\nfunction main(){\n//CODE//\n}\n\n//TESTS//\n\n\nfunction run() {\n stop();\n $(\"#output\").html(\"\");\n main();\n}\n\n\n$(\"#start\").click(run);\n//$(\"#stop\").click(stop);\nmain();\n\n"},"homophones":{"30":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Fix the errors and warnings to complete the code?
  • \n\n\n","initial":"var aHomophones = [\"'ere\", \"ade\", \"aid\", \"aide\", \"air\", \"allowed\", \"aloud\", \"bare\", \"bare\", \"bear\", \"blew\", \"blue\", \"disc\", \"disk\", \"eyre\", \"fain\", \"fair\", \"fane\", \"fare\", \"fayre\", \"feign\", \"for\", \"fore\", \"four\", \"grate\", \"great\", \"heir\", \"miner\", \"minor\", \"moor\", \"more\", \"pair\", \"pare\", \"pear\", \"sign\", \"sine\", \"syne\", \"tare\", \"tear\", \"their\", \"there\", \"they’re\", \"wailer\", \"waler\", \"wear\", \"weather\", \"whaler\", \"where\", \"whether\", \"which\", \"witch\"];\n\nfunction findHomophones(aWords){\n var aHomophoneList = [];\n for(var i = 0; i < aWords.length; i++) {\n var sWord = aWords[i];\n if(isHomophone(sWord)) //if(aHomophones.indexOf(sWord) >= 0)\n {\n aHomophoneList.push(sWord); \n }\n }\n return aHomophoneList;\n}\n \nfunction isHomophone(sWord){\n return aHomophones.indexOf(sWord) >= 0;\n}\n\nfunction findHomophones2(aWords){\n return aWords.filter(isHomophone);\n}\n\n\nfunction highlight() {\n var sText = $(\"#text\").html().trim([\" \", \"\\n\"]); \n var aWords = sText.toLowerCase().split(/\\W/);\n \n var aFoundWords = findHomophones(aWords);\n console.log(aFoundWords);\n for(var i = 0; i < aFoundWords.length; i++) {\n var sWord = aFoundWords[i];\n //var sPattern = new RegExp(\"\\W\"+sWord+\"\\W\"\n sText = sText.replace(sWord, ''+sWord+'');\n }\n $(\"#text\").html(sText);\n}\n\n\n$(\"#start\").click(highlight);\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/debuged/","display":{"en-GB":"debuged"}},"label":"Debug"}},"35":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Check out what happens to the \"Air Temperature\", is that what we want?
  • \n\n\n","initial":"var aHomophones = [\"ade\", \"aid\", \"aide\", \"air\", \"allowed\", \"aloud\", \"bare\", \"bear\", \"blew\", \"blue\", \"disc\", \"disk\", \"eyre\", \"fain\", \"fair\", \"fane\", \"fare\", \"fayre\", \"feign\", \"for\", \"fore\", \"four\", \"grate\", \"great\", \"heir\", \"miner\", \"minor\", \"moor\", \"more\", \"pair\", \"pare\", \"pear\", \"sign\", \"sine\", \"syne\", \"tare\", \"tear\", \"their\", \"there\", \"they’re\", \"wailer\", \"waler\", \"wear\", \"weather\", \"whaler\", \"where\", \"whether\", \"which\", \"witch\"];\n\nfunction findHomophones(aWords){\n var aHomophoneList = [];\n for(var i = 0; i < aWords.length; i++) {\n var sWord = aWords[i];\n if(isHomophone(sWord))\n {\n aHomophoneList.push(sWord); \n }\n }\n return aHomophoneList;\n}\n \nfunction isHomophone(sWord){\n return aHomophones.indexOf(sWord) >= 0;\n}\n\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"40":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Check out what happens to the \"Air Temperature\", is that what we want?
  • \n\n\n","initial":"function calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) {\n if(AirTemp < MinTemp) {\n Status = \"ON\";\n } else {\n //Your code should go here\n }\n return Status;\n}\n\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/thinking/developed/","display":{"en-GB":"developed"}},"label":"Develop"}},"45":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Write the function body so that Status = \"ON\" or \"OFF\" when the boiler needs to turn On or Off
  • \n\n\n","initial":"function calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) {\n //Your code should go here\n \n return Status;\n}\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/thinking/designed/","display":{"en-GB":"designed"}},"label":"Design"}},"tests":"assert( true === true, 'Test description.', \"logic\");\n\n\n\n","simulation":"\n
    The weather is fair with crisp blue sky.
    \nI shall wear my scarf out there.
    \n\n\n\n
    \n
    \n","info":{"name":"Homophones","tags":["array"],"default":false,"objects":["http://utc-sheffield.github.io/tincan_curriculum/OCR_GCSE_Computing_2012/#2-1-7-O"],"towards":[]},"context":"\nfunction INPUT(ControlName) {\n return $(\"#\" + ControlName).val();\n \n}\n\nfunction OUTPUT(Out, Val) {\n if(typeof Val === \"undefined\")\n {\n $(\"#output\").append(\"
    \" + Out + \"
    \");\n }\n else\n {\n $(\"#\" + Out).val(Val);\n }\n}\n\nfunction GET(ControlName) {\n return $(\"#\" + ControlName).val();\n}\n\n//var MinTemp = INPUT(\"mintemp\");\n\n\n//CODE//\n\n\n//TESTS//\n\n\nfunction findHomophones2(aWords){\n return aWords.filter(isHomophone);\n}\n\n\nfunction main() {\n var sText = $(\"#text\").html().trim([\" \",\"\\n\"]); \n var aWords = sText.split(/\\W/);\n \n var aFoundWords = findHomophones(aWords);\n\n for(var i = 0; i < aFoundWords.length; i++) {\n var sWord = aFoundWords[i];\n //var sPattern = new RegExp(\"\\W\"+sWord+\"\\W\"\n sText = sText.replace(sWord, ''+sWord+'');\n }\n $(\"#text\").html(sText);\n}\n\nfunction run() {\n stop();\n $(\"#output\").html(\"\");\n main();\n}\n\n\n$(\"#start\").click(run);\n//$(\"#stop\").click(stop);\n//main();\n\n"},"central_heating":{"30":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Fix the errors and warnings to complete the code?
  • \n\n\n","initial":"function calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) {\n if(AirTemp < MinTemp) {\n Status = \"ON\";\n } else \n if(AirTemp > MaxTemp); {\n Status = \"OFF\";\n }\n }\n return Stratus;\n}\n\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/debuged/","display":{"en-GB":"debuged"}},"label":"Debug"}},"35":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Check out what happens to the \"Air Temperature\", is that what we want?
  • \n\n\n","initial":"function calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) {\n if(AirTemp < MinTemp) {\n Status = \"ON\";\n } else {\n if(AirTemp < MinTemp) {\n Status = \"OFF\";\n }\n }\n return Status;\n}\n\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"40":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Check out what happens to the \"Air Temperature\", is that what we want?
  • \n\n\n","initial":"function calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) {\n if(AirTemp < MinTemp) {\n Status = \"ON\";\n } else {\n //Your code should go here\n }\n return Status;\n}\n\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/thinking/developed/","display":{"en-GB":"developed"}},"label":"Develop"}},"45":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Write the function body so that Status = \"ON\" or \"OFF\" when the boiler needs to turn On or Off
  • \n\n\n","initial":"function calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) {\n //Your code should go here\n \n return Status;\n}\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/thinking/designed/","display":{"en-GB":"designed"}},"label":"Design"}},"tests":"assert( calcBoilerStatus(19, 22, 18, \"OFF\") == \"ON\", 'Boiler should turn ON when too cold.', \"logic\");\n\nassert( calcBoilerStatus(19, 22, 23, \"ON\") == \"OFF\", 'Boiler should turn OFF when too hot.', \"logic\");\n\nassert( calcBoilerStatus(19, 22, 20, \"ON\") == \"ON\", 'Boiler should stay ON when temp is OK.', \"logic\");\n\nassert( calcBoilerStatus(19, 22, 20, \"OFF\") == \"OFF\", 'Boiler should stay OFF when temp is OK.', \"logic\");\n\n","simulation":"\n\n\n
    \n\n\n
    \n\n\n
    \n\n\n
    \n\nOFF\n
    \n","info":{"name":"Central Heating","tags":["selection","if","else"],"default":true,"objects":["http://utc-sheffield.github.io/tincan_curriculum/OCR_GCSE_Computing_2012/#2-1-7-H"],"towards":[]},"context":"\nfunction INPUT(ControlName) {\n return $(\"#\" + ControlName).val();\n \n}\n\nfunction OUTPUT(Out, Val) {\n if(typeof Val === \"undefined\")\n {\n $(\"#output\").append(\"
    \" + Out + \"
    \");\n }\n else\n {\n $(\"#\" + Out).val(Val);\n }\n}\n\n\nfunction GET(ControlName) {\n return $(\"#\" + ControlName).val();\n}\n\n$(\"#airtemp\").val(26);\n$(\"#boiler\").val(\"OFF\");\nvar MinTemp = INPUT(\"mintemp\");\nvar MaxTemp = INPUT(\"maxtemp\");\nvar AirTemp = GET(\"airtemp\");\nvar Boiler = GET(\"boiler\");\n\n\n//CODE//\n\n\n\nfunction loop() {\n MinTemp = INPUT(\"mintemp\");\n MaxTemp = INPUT(\"maxtemp\");\n AirTemp = GET(\"airtemp\");\n OldStatus = GET(\"boiler\");\n Boiler = calcBoilerStatus(MinTemp, MaxTemp, AirTemp, OldStatus);\n OUTPUT(\"boiler\", Boiler);\n}\n\n\n\nfunction stop(){\n window.clearInterval(intervalID);\n}\n\n\nfunction _loop(){\n loop();\n\n if (Boiler === \"ON\")\n {\n AirTemp ++;\n $(\"#airtemp\").val( AirTemp);\n }\n else\n {\n if( AirTemp > -5)\n {\n AirTemp --;\n $(\"#airtemp\").val( AirTemp );\n }\n else\n {\n OUTPUT(\"You are frozen solid!!!\");\n stop();\n }\n }\n if( AirTemp >= 50)\n {\n OUTPUT(\"House on Fire!!!\");\n stop();\n }\n}\n\nfunction main(){\n intervalID = window.setInterval(_loop, 1000);\n}\n\nfunction run() {\n stop();\n $(\"#output\").html(\"\");\n main();\n}\n\n//TESTS//\n\n$(\"#start\").click(run);\n$(\"#stop\").click(stop);\nmain();\n\n"},"caesar_search":{"30":{"task":"
  • Cracking the Caesar Cypher in code
  • \n
  • Fix the PlainTextContainsWords function
  • \n
  • Fix the MakeCaesarCypherAlphabet function
  • \n
  • Fix the FindNextPossibleSetting function
  • \n
  • Add words to PlainTextContainsWords until FindNextPossibleSetting finds the setting to decrypt \"VDTZHTBVQRDUQTRFJKHVQVDVCOQYEHIVI\"
  • \n
  • Use the \"Start search for Setting\" to decrypt \"VDTZHTBVQRDUQTRFJKHVQVDVCOQYEHIVI\"
  • \n","initial":"/*global PlainTextAlphabet Decrypt */ //The PlainTextAlphabet and Decrypt functions are already written \n\n//Checks whether the PlainText we have produced contains common words \n//Returns true if found false if not\nfunction PlainTextContainsWords(PlainText) {\n var Words = [\"THE\", \"at\", \"CANON\"]; //Common word list (add more)\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions\n var Pattern = Words.join(\"|\"); // \"THE|at|CANON\"\n var PatternMatcher = new RegExp(Pattern); //Makes a Pattern Matcher using the Pattern \n MatchFound = PatternMatcher.test(PlainText); //true if the plain text contains a match\n return MatchFound;\n\n\n//Returns the CypherAlphabet (the outer ring) for the given Setting\nvar MakeCaesarCypherAlphabet = function(Setting) {\n Setting = Setting % PlainTextAlphabet.length; // Make it so Setting can't ever point outside our Alphabet by using % (remainders)\n var Start = PlainTextAlphabet.slice(0 Setting); //Get first Setting Letters of Our Alphabet\n var End = PlainTextAlphabet.slice(Setting); // Get the rest of the end of Alphabet\n var CypherAlphabet = End + Start; //New Alphabet is the End then the Start\n return CypherAlphabet;\n};\n\n//Trys to find a Setting which Decrypts the CypherText into PlainText which passes PlainTextContainsWordsing\n//Returns the Setting number if successful and false if it couldn't find anything\nfunction FindNextPossibleSetting(StartSetting, CypherText) {\n var Setting = StartSetting; //Set the first Setting to check to StartSetting (so the continue button works and we can check out different possiblities)\n while(Setting <= PlainTextAlphabet.length) { //Go until run out of possible Settings\n var SettingAlphabet = MakeCaesarCypherAlphabet(Setting); //Get the CypherAlphabet for our current attempted setting\n var PlainText = Decrypt(PlainTextAlphabet, SettingAlphabet, CypherText); //Try Decrypting the CypherText\n var SomeWordsMatch = PlainTextContainsWords(PlainText); //Does the PlainText have reconginable words in it\n if(SomeWordsMatch) {\n return Setting; //Found a match, send the Setting back to process\n )\n Setting ++; // Not found so increase the setting by 1\n }\n return false; //If we got all the way to the end of the possible Setting send back false;\n}\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"35":{"task":"
  • Cracking the Caesar Cypher in code
  • \n
  • Fix the PlainTextContainsWords function
  • \n
  • Fix the MakeCaesarCypherAlphabet function
  • \n
  • Fix the FindNextPossibleSetting function
  • \n
  • Add words to PlainTextContainsWords until FindNextPossibleSetting finds the setting to decrypt \"VDTZHTBVQRDUQTRFJKHVQVDVCOQYEHIVI\"
  • \n
  • Use the \"Start search for Setting\" to decrypt \"VDTZHTBVQRDUQTRFJKHVQVDVCOQYEHIVI\"
  • \n","initial":"/*global PlainTextAlphabet Decrypt */ //The PlainTextAlphabet and Decrypt functions are already written \n\n//Checks whether the PlainText we have produced contains common words \n//Returns true if found false if not\nfunction PlainTextContainsWords(PlainText) {\n var Words = [\"THE\", \"at\", \"CANON\"]; //Common word list (add more)\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions\n var Pattern = Words.join(\"|\"); // \"THE|at|CANON\"\n var PatternMatcher = new RegExp(Pattern); //Makes a Pattern Matcher using the Pattern \n var MatchFound = PatternMatcher.test(PlainText); //true if the plain text contains a match\n return MatchFound;\n}\n\n//Returns the CypherAlphabet (the outer ring) for the given Setting\nvar MakeCaesarCypherAlphabet = function(Setting) {\n Setting = Setting % PlainTextAlphabet.length; // Make it so Setting can't ever point outside our Alphabet by using % (remainders)\n var Start = PlainTextAlphabet.slice(0, Setting); //Get first Setting Letters of Our Alphabet\n var End = PlainTextAlphabet.slice(Setting); // Get the rest of the end of Alphabet\n var CypherAlphabet = End + End; //New Alphabet is the End then the Start\n return CypherAlphabet;\n};\n\n//Trys to find a Setting which Decrypts the CypherText into PlainText which passes PlainTextContainsWordsing\n//Returns the Setting number if successful and false if it couldn't find anything\nfunction FindNextPossibleSetting(StartSetting, CypherText) {\n var Setting = StartSetting; //Set the first Setting to check to StartSetting (so the continue button works and we can check out different possiblities)\n while(Setting <= PlainTextAlphabet.length) { //Go until run out of possible Settings\n var SettingAlphabet = MakeCaesarCypherAlphabet(Setting); //Get the CypherAlphabet for our current attempted setting\n var PlainText = Decrypt(PlainTextAlphabet, SettingAlphabet, CypherText); //Try Decrypting the CypherText\n var SomeWordsMatch = PlainTextContainsWords(PlainText); //Does the PlainText have reconginable words in it\n if(SomeWordsMatch) {\n return Setting; //Found a match, send the Setting back to process\n }\n Setting ++; // Not found so increase the setting by 1\n }\n return \"None Found\"; //If we got all the way to the end of the possible Setting send back false;\n}\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"40":{"task":"
  • Cracking the Caesar Cypher in code
  • \n
  • Fix the PlainTextContainsWords function
  • \n
  • Fix the MakeCaesarCypherAlphabet function
  • \n
  • Fix the FindNextPossibleSetting function
  • \n
  • Add words to PlainTextContainsWords until FindNextPossibleSetting finds the setting to decrypt \"VDTZHTBVQRDUQTRFJKHVQVDVCOQYEHIVI\"
  • \n
  • Use the \"Start search for Setting\" to decrypt \"VDTZHTBVQRDUQTRFJKHVQVDVCOQYEHIVI\"
  • \n","initial":"/*global PlainTextAlphabet Decrypt */ //The PlainTextAlphabet and Decrypt functions are already written \n\n//Checks whether the PlainText we have produced contains common words \n//Returns true if found false if not\nfunction PlainTextContainsWords(PlainText) {\n var Words = [\"THE\", \"at\", \"CANON\"]; //Common word list (add more)\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions\n var Pattern = Words.join(\"|\"); // \"THE|at|CANON\"\n var PatternMatcher = new RegExp(Pattern); //Makes a Pattern Matcher using the Pattern \n var MatchFound = PatternMatcher.test(PlainText); //true if the plain text contains a match\n return MatchFound;\n}\n\n//Returns the CypherAlphabet (the outer ring) for the given Setting\nvar MakeCaesarCypherAlphabet = function(Setting) {\n Setting = Setting % PlainTextAlphabet.length; // Make it so Setting can't ever point outside our Alphabet by using % (remainders)\n var Start = PlainTextAlphabet.slice(0, Setting); //Get first Setting Letters of Our Alphabet\n var End = PlainTextAlphabet.slice(Setting); // Get the rest of the end of Alphabet\n //CypherAlphabet = the End then the Start\n return CypherAlphabet;\n};\n\n//Trys to find a Setting which Decrypts the CypherText into PlainText which passes PlainTextContainsWordsing\n//Returns the Setting number if successful and false if it couldn't find anything\nfunction FindNextPossibleSetting(StartSetting, CypherText) {\n //Set the first Setting to check to StartSetting (so the continue button works and we can check out different possiblities)\n while(Setting <= PlainTextAlphabet.length) { //Go until run out of possible Setting values\n //Make Caesar Cypher Alphabet for our current attempted setting\n var PlainText = Decrypt(PlainTextAlphabet, SettingAlphabet, CypherText); //Try Decrypting the CypherText\n var SomeWordsMatch = PlainTextContainsWords(PlainText); //Does the PlainText have reconginable words in it\n if(SomeWordsMatch) {\n return Setting; //Found a match, send the Setting back to process\n }\n // Not found so increase Setting by 1\n }\n return false; //If we got all the way to the end of the possible Setting send back false;\n}\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"45":{"task":"
  • Cracking the Caesar Cypher in code
  • \n
  • Fix the PlainTextContainsWords function
  • \n
  • Fix the MakeCaesarCypherAlphabet function
  • \n
  • Fix the FindNextPossibleSetting function
  • \n
  • Add words to PlainTextContainsWords until FindNextPossibleSetting finds the setting to decrypt \"VDTZHTBVQRDUQTRFJKHVQVDVCOQYEHIVI\"
  • \n
  • Use the \"Start search for Setting\" to decrypt \"VDTZHTBVQRDUQTRFJKHVQVDVCOQYEHIVI\"
  • \n","initial":"/*global PlainTextAlphabet Decrypt */ //The PlainTextAlphabet and Decrypt functions are already written \n\n//Checks whether the PlainText we have produced contains common words \n//Returns true if found false if not\nfunction PlainTextContainsWords(PlainText) {\n var Words = [\"THE\", \"at\", \"CANON\"]; //Common word list (add more)\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions\n var Pattern = Words.join(\"|\"); // \"THE|at|CANON\"\n var PatternMatcher = new RegExp(Pattern); //Makes a Pattern Matcher using the Pattern \n var MatchFound = PatternMatcher.test(PlainText); //true if the plain text contains a match\n //must return MatchFound \n}\n\n//Returns the CypherAlphabet (the outer ring) for the given Setting\nvar MakeCaesarCypherAlphabet = function(Setting) {\n Setting = Setting % PlainTextAlphabet.length; // Make it so Setting can't ever point outside our Alphabet by using % (remainders)\n var Start = .slice(0, Setting); //Get first Setting Letters of Our PlainTextAlphabet\n var End = .slice(Setting); // Get the rest of the end of PlainTextAlphabet\n var CypherAlphabet = ; //New CypherAlphabet is the End (Setting characters ) then the Start \n //must return CypherAlphabet \n};\n\n//Trys to find a Setting which Decrypts the CypherText into PlainText which passes PlainTextContainsWordsing\n//Returns the Setting number if successful and false if it couldn't find anything\nfunction FindNextPossibleSetting(StartSetting, CypherText) {\n var Setting = StartSetting; //Set the first Setting to check to StartSetting (so the continue button works and we can check out different possiblities)\n while(Setting <= PlainTextAlphabet.length) { //Go until run out of possible Settings\n //MakeCaesarCypherAlphabet for our current attempted Setting\n var PlainText = Decrypt(PlainTextAlphabet, SettingAlphabet, CypherText); //Try Decrypting the CypherText\n //Does the PlainText have reconginable words in it\n if(SomeWordsMatch) {\n return Setting; //Found a match, send the Setting back to process\n }\n Setting ++; // Not found so increase the setting by 1\n }\n return false; //If we got all the way to the end of the possible Setting send back false;\n}\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"50":{"task":"
  • Cracking the Caesar Cypher in code
  • \n
  • Write the PlainTextContainsWords function
  • \n
  • Write the MakeCaesarCypherAlphabet function
  • \n
  • Write the FindNextPossibleSetting function
  • \n
  • Add words to PlainTextContainsWords until FindNextPossibleSetting finds the setting to decrypt \"VDTZHTBVQRDUQTRFJKHVQVDVCOQYEHIVI\"
  • \n
  • Use the \"Start search for Setting\" to decrypt \"VDTZHTBVQRDUQTRFJKHVQVDVCOQYEHIVI\"
  • \n","initial":"/*global PlainTextAlphabet Decrypt */ //The PlainTextAlphabet and Decrypt functions are already written \n\n//Checks whether the PlainText we have produced contains common words \n//Returns true if found false if not\nfunction PlainTextContainsWords(PlainText) {\n\n\n}\n\n//Returns the CypherAlphabet (the outer ring) for the given Setting\nvar MakeCaesarCypherAlphabet = function(Setting) {\n //PlainTextAlphabet is the normal Alphabet ABCD....\n\n\n};\n\n//Trys to find a Setting which Decrypts the CypherText into PlainText which passes PlainTextContainsWordsing\n//Returns the Setting number if successful and false if it couldn't find anything\nfunction FindNextPossibleSetting(StartSetting, CypherText) {\n //PlainTextAlphabet is the normal Alphabet ABCD....\n\n // You will want to use the following functions :-\n // Decrypt(PlainTextAlphabet, SettingAlphabet, CypherText);\n // PlainTextContainsWords(PlainText); //Does the PlainText have reconginable words in it\n \n}\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"tests":"assert( PlainTextContainsWords(\"ATTACK AT DAWN\"), 'PlainTextContainsWords: Should find a word on its list in \"ATTACK AT DAWN\"', \"data\");\n\nassert( PlainTextContainsWords(\"TBRFMDHXCBOHTGH\") == false, 'PlainTextContainsWords: Should not find a word on its list in \"TBRFMDHXCBOHTGH\"', \"data\");\n\nassert( MakeCaesarCypherAlphabet(15) == \"PQRSTUVWXYZ_ABCDEFGHIJKLMNO\",\n 'MakeCaesarCypherAlphabet: CypherAlphabet for setting 15 should be \"PQRSTUVWXYZ_ABCDEFGHIJKLMNO\"', \"logic\");\n\nassert( FindNextPossibleSetting(0, \"PHHPRZOPHOSPKB\") == 15, 'FindNextPossibleSetting: Should find possible Setting of 15 with Cypher Text of \"PHHPRZOPHOSPKB\"', \"logic\");\n\nassert( FindNextPossibleSetting(0, \"VDTZHTBVQRDUQTRFJKHVQVDVCOQYEHIVI\") == 17, \n 'FindNextPossibleSetting: Should find Setting to Decrypt \"VDTZHTBVQRDUQTRFJKHVQVDVCOQYEHIVI\"', \"logic\");\n\n","simulation":"\n\n

    Current Cypher Table

    \n\n \n \n
    Plain Text Alphabet
    ABCDEFGHIJKLMNOPQRSTUVWXYZ_
    Cypher Alphabet
    ABCDEFGHIJKLMNOPQRSTUVWXYZ_
    \n\n\n\n\n

    Messages

    \n\n \n \n \n \n \n \n \n \n \n \n
    Plain Text Message
    Cypher Text Message
    \n\n \n\n

    \n","info":{"name":"Caesar Setting Search","tags":["array","encryption"],"default":false,"objects":["http://utc-sheffield.github.io/tincan_curriculum/GCSE_Computing_Theme/Cypher"],"towards":[]},"context":"$(\"#matchesfound\").hide();\n \nvar autoAction = function() {\n getDecrypted();\n};\n\nvar PlainTextAlphabet = $(\"#alphabet\").text();\n\nvar makeCaesarCypher = function() {\n var iCaesarSetting = $(\"#caesar_setting\").val();\n //console.log(\"iCaesarSetting =\", iCaesarSetting);\n var sCypherAlphabet = MakeCaesarCypherAlphabet(iCaesarSetting);\n //console.log(\"sCypherAlphabet =\", sCypherAlphabet);\n $(\"#cypheralphabet\").text(sCypherAlphabet);\n autoAction();\n};\n \nvar Encrypt = function(Alphabet, SubstitutionAlphabet, PlainText) {\n var OutputText = \"\"; //We start with no letters in our output\n \n //The variable i will go up from 0 (pointing to the first letter)\n //until i = the length of our plain text (pointing to the last letter in our plain text)\n for(var i = 0 ; i < PlainText.length; i++) { \n var PlainTextLetter = PlainText[i]; //The letter we want to Encypher this time\n var Position = Alphabet.search(PlainTextLetter); //Finds what position our Letter is in our Alphabet\n if(Position === -1) { //If we didn't find the letter in our Alphabet\n Position = Alphabet.search(\"_\"); //Find \"_\" instead\n }\n var CypherLetter = SubstitutionAlphabet[Position]; //Look up that position in our Substitution Alphabet\n OutputText += CypherLetter; //Add our Cypher Letter to the OutputText\n }\n return OutputText; //Send it back\n};\n\nvar Decrypt = function(Alphabet, SubstitutionAlphabet, CypherText) {\n var OutputText = \"\"; //We start with no letters in our output\n \n //The variable i will go up from 0 (pointing to the first letter)\n //until i = the length of our cypher text (pointing to the last letter in our cypher text)\n for(var i = 0 ; i < CypherText.length; i++) { \n var CypherTextLetter = CypherText[i]; //The letter we want to Encypher this time\n var Position = SubstitutionAlphabet.search(CypherTextLetter); //Finds what position our Letter is in our SubstitutionAlphabet\n var PlainTextLetter = Alphabet[Position]; //Look up that position in our Plain text Alphabet\n OutputText += PlainTextLetter; //Add our Plain Text Letter to the OutputText\n }\n return OutputText; //Send it back\n};\n\n \nvar getEncrypted = function() {\n var sIn = $(\"#plaintext\").val();\n var sAlphabet = $(\"#alphabet\").text(); \n var sCypher = $(\"#cypheralphabet\").text();\n var sCypherText = \"\";\n if(sAlphabet.length !== sCypher.length)\n {\n sCypherText = \"Cypher Too Short\";\n } else {\n sCypherText = Encrypt(sAlphabet, sCypher, sIn);\n }\n $(\"#cyphertext\").val(sCypherText); \n //console.log(\"getEncrypted sCypherText =\", sCypherText);\n};\n\nvar getDecrypted = function() {\n var sAlphabet = $(\"#alphabet\").text(); \n var sIn = $(\"#cyphertext\").val();\n var sCypher = $(\"#cypheralphabet\").text();\n var sPlainText = Decrypt(sAlphabet, sCypher, sIn);\n //console.log(\"sPlainText =\", sPlainText);\n $(\"#plaintext\").val(sPlainText);\n //testPlainText();\n};\n\n\n\nvar testPlainText = function () {\n var sPlainText = $(\"#plaintext\").val();\n \n if(PlainTextContainsWords(sPlainText)) {\n $(\"#matchesfound\").show();\n return true;\n } else {\n $(\"#matchesfound\").hide();\n return false;\n } \n};\n\n$(\"#caesar_setting\").on(\"input\", makeCaesarCypher);\n\n//$(\"#plaintext\").on(\"input\", getEncrypted);\n$(\"#cyphertext\").on(\"input\", getDecrypted);\n\n$(\"#cypheralphabet\").on(\"input\", autoAction);\n\n$(\".encrypt\").click(getEncrypted);\n$(\".decrypt\").click(getDecrypted);\n\n\n//CODE// \n\n\nfunction search(){\n var iSetting = FindNextPossibleSetting($(\"#caesar_setting\").val(), $(\"#cyphertext\").val());\n if(iSetting === false) {\n $(\"#searchresult\").text(\"Search found no matching words\");\n } else {\n $(\"#caesar_setting\").val(iSetting);\n makeCaesarCypher();\n $(\"#searchresult\").text(\"Words found with Setting of \"+iSetting );\n }\n}\n\nfunction search_start(){\n $(\"#caesar_setting\").val(0);\n makeCaesarCypher();\n search();\n}\n\n$(\"#search\").click(search_start);\n$(\"#continue_search\").click(search);\n\nmakeCaesarCypher();\n\n//TESTS//\n\n \n"},"caesar":{"30":{"task":"
  • Read the Encrypt Function to see how it works.
  • \n
  • Fix the Decrypt function - use the tests to see if it works.
  • \n
  • Using Setting 13 Decrypt \"NFFNPXMSDAZMFURM_ADFU\"
  • \n
  • Work out what \"JMEQSRJJRBZEDIQEWQYEHIVQJEQJYVQDEHJY\" means
  • \n\n","initial":"var Encrypt = function(Alphabet, SubstitutionAlphabet, PlainText) {\n var OutputText = \"\"; //We start with no letters in our output\n \n //The variable i will go up from 0 (pointing to the first letter)\n //until i = the length of our plain text (pointing to the last letter in our plain text)\n for(var i = 0 ; i < PlainText.length; i++) { \n var PlainTextLetter = PlainText[i]; //The letter we want to Encypher this time\n var Position = Alphabet.search(PlainTextLetter); //Finds what position our Letter is in our Alphabet\n if(Position === -1) { //If we didn't find the letter in our Alphabet\n Position = Alphabet.search(\"_\"); //Find \"_\" instead\n }\n var CypherLetter = SubstitutionAlphabet[Position]; //Look up that position in our Substitution Alphabet\n OutputText += CypherLetter; //Add our Cypher Letter to the OutputText\n }\n return OutputText; //Send it back\n};\n\nvar Decrypt = function(Alphabet, SubstitutionAlphabet, CypherText) {\n var OutputText = \"\"; //We start with no letters in our output\n \n //The variable i will go up from 0 (pointing to the first letter)\n //until i = the length of our cypher text (pointing to the last letter in our cypher text)\n for(var i = 0 ; i < CypherText.length; i++) { \n var CypherTextLetter = CypherText[i; //The letter we want to Encypher this time\n var Position = SubstitutionAlphabet.search(CypherTextLetter); //Finds what position our Letter is in our SubstitutionAlphabet\n var PlainTextLetter = Alphabet[Position]; //Look up that position in our Plain text Alphabet\n OutputText += PlainTextLetter; //Add our Plain Text Letter to the OutputText\n }\n return OutputText; //Send it back\n\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"35":{"task":"
  • Read the Encrypt Function to see how it works.
  • \n
  • Fix the Decrypt function - use the tests to see if it works.
  • \n
  • Using Setting 13 Decrypt \"NFFNPXMSDAZMFURM_ADFU\"
  • \n
  • Work out what \"JMEQSRJJRBZEDIQEWQYEHIVQJEQJYVQDEHJY\" means
  • \n\n","initial":"var Encrypt = function(Alphabet, SubstitutionAlphabet, PlainText) {\n var OutputText = \"\"; //We start with no letters in our output\n \n //The variable i will go up from 0 (pointing to the first letter)\n //until i = the length of our plain text (pointing to the last letter in our plain text)\n for(var i = 0 ; i < PlainText.length; i++) { \n var PlainTextLetter = PlainText[i]; //The letter we want to Encypher this time\n var Position = Alphabet.search(PlainTextLetter); //Finds what position our Letter is in our Alphabet\n if(Position === -1) { //If we didn't find the letter in our Alphabet\n Position = Alphabet.search(\"_\"); //Find \"_\" instead\n }\n var CypherLetter = SubstitutionAlphabet[Position]; //Look up that position in our Substitution Alphabet\n OutputText += CypherLetter; //Add our Cypher Letter to the OutputText\n }\n return OutputText; //Send it back\n};\n\nvar Decrypt = function(Alphabet, SubstitutionAlphabet, CypherText) {\n var OutputText = \"\"; //We start with no letters in our output\n \n //The variable i will go up from 0 (pointing to the first letter)\n //until i = the length of our cypher text (pointing to the last letter in our cypher text)\n for(var i = 0 ; i < CypherText.length; i++) { \n var CypherTextLetter = CypherText[j]; //The letter we want to Encypher this time\n var Position = SubstitutionAlphabet.search(CypherTextLetter); //Finds what position our Letter is in our SubstitutionAlphabet\n var PlainTextLetter = SubstitutionAlphabet[Position]; //Look up that position in our Plain text Alphabet\n OutputText += PlainTextLetter; //Add our Plain Text Letter to the OutputText\n }\n return OutputText; //Send it back\n};\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"40":{"task":"
  • Read the Encrypt Function to see how it works.
  • \n
  • Fix the Decrypt function - use the tests to see if it works.
  • \n
  • Using Setting 13 Decrypt \"NFFNPXMSDAZMFURM_ADFU\"
  • \n
  • Work out what \"JMEQSRJJRBZEDIQEWQYEHIVQJEQJYVQDEHJY\" means
  • \n\n","initial":"var Encrypt = function(Alphabet, SubstitutionAlphabet, PlainText) {\n var OutputText = \"\"; //We start with no letters in our output\n \n //The variable i will go up from 0 (pointing to the first letter)\n //until i = the length of our plain text (pointing to the last letter in our plain text)\n for(var i = 0 ; i < PlainText.length; i++) { \n var PlainTextLetter = PlainText[i]; //The letter we want to Encypher this time\n var Position = Alphabet.search(PlainTextLetter); //Finds what position our Letter is in our Alphabet\n if(Position === -1) { //If we didn't find the letter in our Alphabet\n Position = Alphabet.search(\"_\"); //Find \"_\" instead\n }\n var CypherLetter = SubstitutionAlphabet[Position]; //Look up that position in our Substitution Alphabet\n OutputText += CypherLetter; //Add our Cypher Letter to the OutputText\n }\n return OutputText; //Send it back\n};\n\nvar Decrypt = function(Alphabet, SubstitutionAlphabet, CypherText) {\n var OutputText = \"\"; //We start with no letters in our output\n for(var i = 0 ; i < CypherText.length; i++) { \n //The letter we want to Encypher this time\n var Position = SubstitutionAlphabet.search(CypherTextLetter); //Finds what position our Letter is in our SubstitutionAlphabet\n //Look up that position in our Plain text Alphabet\n OutputText += PlainTextLetter; //Add our Plain Text Letter to the OutputText\n }\n return OutputText; //Send it back\n};\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"45":{"task":"
  • Read the Encrypt Function to see how it works.
  • \n
  • Write the Decrypt function - use the tests to see if it works.
  • \n
  • Using Setting 13 Decrypt \"NFFNPXMSDAZMFURM_ADFU\"
  • \n
  • Work out what \"JMEQSRJJRBZEDIQEWQYEHIVQJEQJYVQDEHJY\" means
  • \n\n","initial":"var Encrypt = function(Alphabet, SubstitutionAlphabet, PlainText) {\n var OutputText = \"\"; //We start with no letters in our output\n \n //The variable i will go up from 0 (pointing to the first letter)\n //until i = the length of our plain text (pointing to the last letter in our plain text)\n for(var i = 0 ; i < PlainText.length; i++) { \n var PlainTextLetter = PlainText[i]; //The letter we want to Encypher this time\n var Position = Alphabet.search(PlainTextLetter); //Finds what position our Letter is in our Alphabet\n if(Position === -1) { //If we didn't find the letter in our Alphabet\n Position = Alphabet.search(\"_\"); //Find \"_\" instead\n }\n var CypherLetter = SubstitutionAlphabet[Position]; //Look up that position in our Substitution Alphabet\n OutputText += CypherLetter; //Add our Cypher Letter to the OutputText\n }\n return OutputText; //Send it back\n};\n\nvar Decrypt = function(Alphabet, SubstitutionAlphabet, CypherText) {\n var OutputText = \"\"; //We start with no letters in our output\n \n \n \n return OutputText; //Send it back\n};\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"tests":"assert( Encrypt(\"ABCDEFGHIJKLMNOPQRSTUVWXYZ_\", \"KLMNOPQRSTUVWXYZ_ABCDEFGHIJ\", \"ENCRYPTION_TEST\") == \"OXMAHZCSYXJCOBC\", 'Should encrypt \"ENCRYPTION_TEST\" with setting=10 to \"OXMAHZCSYXJCOBC\"', \"logic\");\n\nassert( Encrypt(\"ABCDEFGHIJKLMNOPQRSTUVWXYZ_\", \"PQRSTUVWXYZ_ABCDEFGHIJKLMNO\", \"ENCRYPTION_TEST\") == \"TBRFMDHXCBOHTGH\", 'Should encrypt \"ENCRYPTION_TEST\" with setting=15 to \"TBRFMDHXCBOHTGH\"', \"logic\");\n\nassert( Decrypt(\"ABCDEFGHIJKLMNOPQRSTUVWXYZ_\", \"KLMNOPQRSTUVWXYZ_ABCDEFGHIJ\", \"OXMAHZCSYXJCOBC\") == \"ENCRYPTION_TEST\", 'Should decrypt \"OXMAHZCSYXJCOBC\" with setting=10 to \"ENCRYPTION_TEST\"', \"logic\");\n\nassert( Decrypt(\"ABCDEFGHIJKLMNOPQRSTUVWXYZ_\", \"PQRSTUVWXYZ_ABCDEFGHIJKLMNO\", \"TBRFMDHXCBOHTGH\") == \"ENCRYPTION_TEST\", 'Should decrypt \"TBRFMDHXCBOHTGH\" with setting=15 to \"ENCRYPTION_TEST\"', \"logic\");\n\n","simulation":"\n\n

    Current Cypher Table

    \n\n \n \n
    Plain Text Alphabet
    ABCDEFGHIJKLMNOPQRSTUVWXYZ_
    Cypher Alphabet
    ABCDEFGHIJKLMNOPQRSTUVWXYZ_
    \n

    Make new Caesar Cypher

    \n\n
    \n\n\n\n

    Messages

    \n\n \n \n \n \n \n \n \n \n \n \n
    Plain Text Message
    Cypher Text
    \n\n","info":{"name":"Caesar Cypher","tags":["array","encryption"],"default":true,"objects":["http://utc-sheffield.github.io/tincan_curriculum/GCSE_Computing_Theme/Cypher"],"towards":[]},"context":"$(\"#matchesfound\").hide();\n\n//CODE// \n\nvar getEncrypted = function() {\n var sIn = $(\"#plaintext\").val();\n var sAlphabet = $(\"#alphabet\").text(); \n var sCypher = $(\"#cypheralphabet\").text();\n var sCypherText = \"\";\n if(sAlphabet.length !== sCypher.length)\n {\n sCypherText = \"Cypher Too Short\";\n } else {\n sCypherText = Encrypt(sAlphabet, sCypher, sIn);\n }\n $(\"#cyphertext\").val(sCypherText); \n};\n\nvar getDecrypted = function() {\n var sAlphabet = $(\"#alphabet\").text(); \n var sIn = $(\"#cyphertext\").val();\n var sCypher = $(\"#cypheralphabet\").text();\n var sPlainText = Decrypt(sAlphabet, sCypher, sIn);\n $(\"#plaintext\").val(sPlainText);\n};\n\nvar autoAction = function() {\n var sMode = $(\"#mode\").val();\n if(sMode === \"Encrypt\") {\n getEncrypted();\n } else if(sMode === \"Decrypt\") {\n getDecrypted();\n }\n};\n\nvar makeCaesarCypher = function() {\n var sAlphabet = $(\"#alphabet\").text();\n var iCaesarSetting = $(\"#caesar_setting\").val() % sAlphabet.length;\n var sStart = sAlphabet.slice(0, iCaesarSetting);\n var sEnd = sAlphabet.slice(iCaesarSetting);\n var sNew = sEnd + sStart;\n $(\"#cypheralphabet\").text(sNew);\n autoAction();\n};\n \n$(\"#caesar_setting\").on(\"input\", makeCaesarCypher);\n\n$(\"#plaintext\").on(\"input\", getEncrypted);\n$(\"#cyphertext\").on(\"input\", getDecrypted);\n\n$(\"#cypheralphabet\").on(\"input\", autoAction);\n\n$(\".encrypt\").click(getEncrypted);\n$(\".decrypt\").click(getDecrypted);\n\nmakeCaesarCypher();\n \n//TESTS//\n\n"}} \ No newline at end of file +{"testing_off_licence":{"30":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Fix the errors and warnings to complete the code?
  • \n\n\n","initial":"/*globals INPUT OUTPUT openWebOffLicence */\nfunction getValidInteger(AGE)\n{\n if(/[0-9]+/.test(AGE)) {\n return parseInt(AGE, 10);\n }\n OUTPUT(\"warning\", \"Not a Valid Number\");\n return false;\n}\n\nfunction isValidAge(AGE)\n{ \n if(AGE <= 2 || AGE >= 150) {\n OUTPUT(\"warning\", \"Not a Valid Age\");\n return false;\n } else if(AGE < 18) {\n OUTPUT(\"warning\", \"Not Old enough to drink\");\n return false;\n }\n return true;\n}\n\nfunction main() {\n var AGE = getValidInteger(INPUT(\"age\"));\n if (AGE !== false) {\n if (isValidAge(AGE)) {\n openWebOffLicence();\n }\n }\n}\n","initial-v1":"/*globals INPUT OUTPUT openWebOffLicence */\nfunction isAgeValid(AGE)\n{\n console.log(\"AGE\", AGE);\n if(typeof AGE !== \"number\") {\n return {valid:false, warning:\"Not a Valid Number\"};\n }\n if(AGE <= 2 || AGE >= 150) {\n return {valid:false, warning:\"Not a Valid Age\"};\n }\n if(AGE < 18) {\n return {valid:false, warning:\"Not Old enough to drink\"};\n }\n return {valid:true, warning:\"\"};\n}\n\nfunction main() {\n var AGE = INPUT(\"age\");\n if (isAgeValid(AGE)) {\n openWebOffLicence();\n }\n}\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/debuged/","display":{"en-GB":"debuged"}},"label":"Debug"}},"35":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Check out what happens to the \"Air Temperature\", is that what we want?
  • \n\n\n","initial":"/*globals INPUT OUTPUT openWebOffLicence */\nfunction getValidInteger(AGE)\n{\n if(/[0-9]+/.test(AGE)) {\n return parseInt(AGE, 10);\n }\n OUTPUT(\"warning\", \"Not a Valid Number\");\n return false;\n}\n\nfunction isValidAge(AGE)\n{ \n if(AGE <= 2 || AGE >= 150) {\n OUTPUT(\"warning\", \"Not a Valid Age\");\n return false;\n } else if(AGE < 18) {\n OUTPUT(\"warning\", \"Not Old enough to drink\");\n return false;\n }\n return true;\n}\n\nfunction main() {\n var AGE = getValidInteger(INPUT(\"age\"));\n if (AGE !== false) {\n if (isValidAge(AGE)) {\n openWebOffLicence();\n }\n }\n}\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"tests":"\nfunction testIsAgeValid(number, bExpectValid, sReg) {\n var bValid = isValidAge(number);\n if( bExpectValid !== bValid) {\n return false;\n }\n \n var sWarning = $(\"#warning\").html();\n var regexObj = new RegExp(sReg, \"i\");\n var bRegResult = regexObj.test(sWarning);\n return bRegResult;\n}\n\nassert( testIsAgeValid(2, false, \"Not a Valid Age\"), '2 is \"Not a Valid Age\"', \"logic\");\nassert( testIsAgeValid(3, false, \"Not old enough to drink\"), '3 is \"Not old enough to drink\"', \"logic\");\nassert( testIsAgeValid(17, false, \"Not old enough to drink\"), '17 is \"Not old enough to drink\"', \"logic\");\nassert( testIsAgeValid(18, true, \"\"), '18 is valid', \"logic\");\nassert( testIsAgeValid(149, true, \"\"), '149 is valid', \"logic\");\nassert( testIsAgeValid(150, false, \"Not a Valid Age\"), '150 is \"Not a Valid Age\"', \"logic\");\nassert( testIsAgeValid(999999, false, \"Not a Valid Age\"), '999999999 is \"Not a Valid Age\"', \"logic\");\nassert( getValidInteger(\"ten\") === false, '\"ten\" is \"Not a Valid Number\"', \"logic\");\nassert( getValidInteger(10) === 10, '10 is \"A Valid Number\"', \"logic\");\n\n\n\n","simulation":"\n\n
    \n\n\n
    \n
    Warnings :
    \n
    \n","info":{"name":"Age Validation","tags":["selection","if","else"],"default":false,"objects":["http://utc-sheffield.github.io/tincan_curriculum/OCR_GCSE_Computing_2012/#2-1-7-Q"],"towards":[]},"context":"function INPUT(ControlName) {\n var ele = $(\"#\" + ControlName);\n if(ele.prop(\"tagName\") === \"SPAN\") {\n return ele.html();\n } else {\n return ele.val();\n }\n}\n\nfunction OUTPUT(Out, Val) {\n if(typeof Val === \"undefined\") {\n $(\"#output\").append(\"
    \" + Out + \"
    \");\n } else {\n var ele = $(\"#\" + Out);\n if(ele.prop(\"tagName\") === \"SPAN\") {\n ele.html(Val);\n } else {\n ele.val(Val);\n }\n }\n}\n\nfunction GET(ControlName) {\n return INPUT(ControlName);\n}\n\n\nfunction openWebOffLicence() {\n OUTPUT(\"Welcome to the Web Off Licence\");\n}\n\n//CODE//\n\n\n//TESTS//\n\nfunction run() {\n $(\"#output\").html(\"\");\n main();\n}\n\n$(\"#start\").click(run);\nmain();\n\n"},"student_array":{"30":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Fix the errors and warnings to complete the code?
  • \n\n\n","initial":"var students = [\"John\", \"Paul\", \"George\", \"Ringo\"];\n\n\nassert(students[0] === \"\", \"Index 0 is 'John'\", \"\");\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/debuged/","display":{"en-GB":"debuged"}},"label":"Debug"}},"35":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Check out what happens to the \"Air Temperature\", is that what we want?
  • \n\n\n","initial":"function calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) {\n if(AirTemp < MinTemp) {\n Status = \"ON\";\n } else {\n if(AirTemp < MinTemp) {\n Status = \"OFF\";\n }\n }\n return Status;\n}\n\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"40":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Check out what happens to the \"Air Temperature\", is that what we want?
  • \n\n\n","initial":"function calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) {\n if(AirTemp < MinTemp) {\n Status = \"ON\";\n } else {\n //Your code should go here\n }\n return Status;\n}\n\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/thinking/developed/","display":{"en-GB":"developed"}},"label":"Develop"}},"45":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Write the function body so that Status = \"ON\" or \"OFF\" when the boiler needs to turn On or Off
  • \n\n\n","initial":"function calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) {\n //Your code should go here\n \n return Status;\n}\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/thinking/designed/","display":{"en-GB":"designed"}},"label":"Design"}},"tests":"assert( true === true, 'Test description.', \"logic\");\n\n\n\n","simulation":"\n\n
    \n
    \n","info":{"name":"Student Array","tags":["array"],"default":true,"objects":["http://utc-sheffield.github.io/tincan_curriculum/OCR_GCSE_Computing_2012/#2-1-7-O"],"towards":[]},"context":"\nfunction INPUT(ControlName) {\n return $(\"#\" + ControlName).val();\n \n}\n\nfunction OUTPUT(Out, Val) {\n if(typeof Val === \"undefined\")\n {\n $(\"#output\").append(\"
    \" + Out + \"
    \");\n }\n else\n {\n $(\"#\" + Out).val(Val);\n }\n}\n\nfunction GET(ControlName) {\n return $(\"#\" + ControlName).val();\n}\n\n//var MinTemp = INPUT(\"mintemp\");\n\n\nfunction main(){\n//CODE//\n}\n\n//TESTS//\n\n\nfunction run() {\n stop();\n $(\"#output\").html(\"\");\n main();\n}\n\n\n$(\"#start\").click(run);\n//$(\"#stop\").click(stop);\nmain();\n\n"},"shopping_list":{"30":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Fix the errors and warnings to complete the code?
  • \n\n\n","initial":"var students = [\"John\", \"Paul\", \"George\", \"Ringo\"];\n\n\nassert(students[0] === \"\", \"Index 0 is 'John'\", \"\");\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/debuged/","display":{"en-GB":"debuged"}},"label":"Debug"}},"35":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Check out what happens to the \"Air Temperature\", is that what we want?
  • \n\n\n","initial":"function calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) {\n if(AirTemp < MinTemp) {\n Status = \"ON\";\n } else {\n if(AirTemp < MinTemp) {\n Status = \"OFF\";\n }\n }\n return Status;\n}\n\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"40":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Check out what happens to the \"Air Temperature\", is that what we want?
  • \n\n\n","initial":"function calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) {\n if(AirTemp < MinTemp) {\n Status = \"ON\";\n } else {\n //Your code should go here\n }\n return Status;\n}\n\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/thinking/developed/","display":{"en-GB":"developed"}},"label":"Develop"}},"45":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Write the function body so that Status = \"ON\" or \"OFF\" when the boiler needs to turn On or Off
  • \n\n\n","initial":"function calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) {\n //Your code should go here\n \n return Status;\n}\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/thinking/designed/","display":{"en-GB":"designed"}},"label":"Design"}},"tests":"assert( true === true, 'Test description.', \"logic\");\n\n\n\n","simulation":"\n\n
    \n
    \n","info":{"name":"Shopping List","tags":["array"],"default":false,"objects":["http://utc-sheffield.github.io/tincan_curriculum/OCR_GCSE_Computing_2012/#2-1-7-O"],"towards":[]},"context":"\nfunction INPUT(ControlName) {\n return $(\"#\" + ControlName).val();\n \n}\n\nfunction OUTPUT(Out, Val) {\n if(typeof Val === \"undefined\")\n {\n $(\"#output\").append(\"
    \" + Out + \"
    \");\n }\n else\n {\n $(\"#\" + Out).val(Val);\n }\n}\n\nfunction GET(ControlName) {\n return $(\"#\" + ControlName).val();\n}\n\n//var MinTemp = INPUT(\"mintemp\");\n\n\nfunction main(){\n//CODE//\n}\n\n//TESTS//\n\n\nfunction run() {\n stop();\n $(\"#output\").html(\"\");\n main();\n}\n\n\n$(\"#start\").click(run);\n//$(\"#stop\").click(stop);\nmain();\n\n"},"homophones":{"30":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Fix the errors and warnings to complete the code?
  • \n\n\n","initial":"var aHomophones = [\"'ere\", \"ade\", \"aid\", \"aide\", \"air\", \"allowed\", \"aloud\", \"bare\", \"bare\", \"bear\", \"blew\", \"blue\", \"disc\", \"disk\", \"eyre\", \"fain\", \"fair\", \"fane\", \"fare\", \"fayre\", \"feign\", \"for\", \"fore\", \"four\", \"grate\", \"great\", \"heir\", \"miner\", \"minor\", \"moor\", \"more\", \"pair\", \"pare\", \"pear\", \"sign\", \"sine\", \"syne\", \"tare\", \"tear\", \"their\", \"there\", \"they’re\", \"wailer\", \"waler\", \"wear\", \"weather\", \"whaler\", \"where\", \"whether\", \"which\", \"witch\"];\n\nfunction findHomophones(aWords){\n var aHomophoneList = [];\n for(var i = 0; i < aWords.length; i++) {\n var sWord = aWords[i];\n if(isHomophone(sWord)) //if(aHomophones.indexOf(sWord) >= 0)\n {\n aHomophoneList.push(sWord); \n }\n }\n return aHomophoneList;\n}\n \nfunction isHomophone(sWord){\n return aHomophones.indexOf(sWord) >= 0;\n}\n\nfunction findHomophones2(aWords){\n return aWords.filter(isHomophone);\n}\n\n\nfunction highlight() {\n var sText = $(\"#text\").html().trim([\" \", \"\\n\"]); \n var aWords = sText.toLowerCase().split(/\\W/);\n \n var aFoundWords = findHomophones(aWords);\n console.log(aFoundWords);\n for(var i = 0; i < aFoundWords.length; i++) {\n var sWord = aFoundWords[i];\n //var sPattern = new RegExp(\"\\W\"+sWord+\"\\W\"\n sText = sText.replace(sWord, ''+sWord+'');\n }\n $(\"#text\").html(sText);\n}\n\n\n$(\"#start\").click(highlight);\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/debuged/","display":{"en-GB":"debuged"}},"label":"Debug"}},"35":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Check out what happens to the \"Air Temperature\", is that what we want?
  • \n\n\n","initial":"var aHomophones = [\"ade\", \"aid\", \"aide\", \"air\", \"allowed\", \"aloud\", \"bare\", \"bear\", \"blew\", \"blue\", \"disc\", \"disk\", \"eyre\", \"fain\", \"fair\", \"fane\", \"fare\", \"fayre\", \"feign\", \"for\", \"fore\", \"four\", \"grate\", \"great\", \"heir\", \"miner\", \"minor\", \"moor\", \"more\", \"pair\", \"pare\", \"pear\", \"sign\", \"sine\", \"syne\", \"tare\", \"tear\", \"their\", \"there\", \"they’re\", \"wailer\", \"waler\", \"wear\", \"weather\", \"whaler\", \"where\", \"whether\", \"which\", \"witch\"];\n\nfunction findHomophones(aWords){\n var aHomophoneList = [];\n for(var i = 0; i < aWords.length; i++) {\n var sWord = aWords[i];\n if(isHomophone(sWord))\n {\n aHomophoneList.push(sWord); \n }\n }\n return aHomophoneList;\n}\n \nfunction isHomophone(sWord){\n return aHomophones.indexOf(sWord) >= 0;\n}\n\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"40":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Check out what happens to the \"Air Temperature\", is that what we want?
  • \n\n\n","initial":"function calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) {\n if(AirTemp < MinTemp) {\n Status = \"ON\";\n } else {\n //Your code should go here\n }\n return Status;\n}\n\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/thinking/developed/","display":{"en-GB":"developed"}},"label":"Develop"}},"45":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Write the function body so that Status = \"ON\" or \"OFF\" when the boiler needs to turn On or Off
  • \n\n\n","initial":"function calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) {\n //Your code should go here\n \n return Status;\n}\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/thinking/designed/","display":{"en-GB":"designed"}},"label":"Design"}},"tests":"assert( true === true, 'Test description.', \"logic\");\n\n\n\n","simulation":"\n
    The weather is fair with crisp blue sky.
    \nI shall wear my scarf out there.
    \n\n\n\n
    \n
    \n","info":{"name":"Homophones","tags":["array"],"default":false,"objects":["http://utc-sheffield.github.io/tincan_curriculum/OCR_GCSE_Computing_2012/#2-1-7-O"],"towards":[]},"context":"\nfunction INPUT(ControlName) {\n return $(\"#\" + ControlName).val();\n \n}\n\nfunction OUTPUT(Out, Val) {\n if(typeof Val === \"undefined\")\n {\n $(\"#output\").append(\"
    \" + Out + \"
    \");\n }\n else\n {\n $(\"#\" + Out).val(Val);\n }\n}\n\nfunction GET(ControlName) {\n return $(\"#\" + ControlName).val();\n}\n\n//var MinTemp = INPUT(\"mintemp\");\n\n\n//CODE//\n\n\n//TESTS//\n\n\nfunction findHomophones2(aWords){\n return aWords.filter(isHomophone);\n}\n\n\nfunction main() {\n var sText = $(\"#text\").html().trim([\" \",\"\\n\"]); \n var aWords = sText.split(/\\W/);\n \n var aFoundWords = findHomophones(aWords);\n\n for(var i = 0; i < aFoundWords.length; i++) {\n var sWord = aFoundWords[i];\n //var sPattern = new RegExp(\"\\W\"+sWord+\"\\W\"\n sText = sText.replace(sWord, ''+sWord+'');\n }\n $(\"#text\").html(sText);\n}\n\nfunction run() {\n stop();\n $(\"#output\").html(\"\");\n main();\n}\n\n\n$(\"#start\").click(run);\n//$(\"#stop\").click(stop);\n//main();\n\n"},"central_heating":{"30":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Fix the errors and warnings to complete the code?
  • \n\n\n","initial_py":"def calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) :\n if(AirTemp < MinTemp) :\n Status = \"ON\"\n else : \n if(AirTemp > MaxTemp) :\n Status = \"OFF\"\n return Stratus","initial":"function calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) {\n if(AirTemp < MinTemp) {\n Status = \"ON\";\n } else \n if(AirTemp > MaxTemp); {\n Status = \"OFF\";\n }\n }\n return Stratus;\n}\n\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/debuged/","display":{"en-GB":"debuged"}},"label":"Debug"}},"35":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Check out what happens to the \"Air Temperature\", is that what we want?
  • \n\n\n","initial_py":"def calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) :\n if(AirTemp < MinTemp) :\n Status = \"ON\"\n else : \n if(AirTemp < MinTemp) :\n Status = \"OFF\"\nreturn Status\n\n","initial":"function calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) {\n if(AirTemp < MinTemp) {\n Status = \"ON\";\n } else {\n if(AirTemp < MinTemp) {\n Status = \"OFF\";\n }\n }\n return Status;\n}\n\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"40":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Check out what happens to the \"Air Temperature\", is that what we want?
  • \n\n\n","initial_py":"def calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) :\n if(AirTemp < MinTemp) :\n Status = \"ON\"\n else :\n #Your code should go here\n \n return Status\n","initial":"function calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) {\n if(AirTemp < MinTemp) {\n Status = \"ON\";\n } else {\n //Your code should go here\n }\n return Status;\n}\n\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/thinking/developed/","display":{"en-GB":"developed"}},"label":"Develop"}},"45":{"task":"
  • This is code for Simulated Central Heating system
  • \n
  • In this simulation 1 second = 10 mins of real time
  • \n
  • Write the function body so that Status = \"ON\" or \"OFF\" when the boiler needs to turn On or Off
  • \n\n\n","initial_py":"def calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) :\n #Your code should go here\n \n return Status\n","initial":"function calcBoilerStatus(MinTemp, MaxTemp, AirTemp, Status) {\n //Your code should go here\n \n return Status;\n}\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/thinking/designed/","display":{"en-GB":"designed"}},"label":"Design"}},"tests":"GCSEtest({\n \"text\":'Boiler should turn ON when too cold.',\n \"func\": calcBoilerStatus,\n \"type\":\"logic\",\n \"input_type\":\"valid\",\n \"inputs\":[19, 22, 18, \"OFF\"],\n \"expected\":\"ON\",\n \"task\":1\n})\n\nGCSEtest({\n \"text\":'Boiler should turn OFF when too hot.',\n \"func\": calcBoilerStatus,\n \"type\":\"logic\",\n \"input_type\":\"valid\",\n \"inputs\":[19, 22, 23, \"ON\"],\n \"expected\":\"OFF\",\n \"task\":2\n})\n\nGCSEtest({\n \"text\":'Boiler should stay ON when temp is OK.',\n \"func\": calcBoilerStatus,\n \"type\":\"logic\",\n \"input_type\":\"valid\",\n \"inputs\":[19, 22, 20, \"ON\"],\n \"expected\":\"ON\",\n \"task\":3\n})\n\nGCSEtest({\n \"text\":'Boiler should stay OFF when temp is OK.',\n \"func\": calcBoilerStatus,\n \"type\":\"logic\",\n \"input_type\":\"valid\",\n \"inputs\":[19, 22, 20, \"OFF\"],\n \"expected\":\"OFF\",\n \"task\":4\n})\n","simulation":"\n\n\n
    \n\n\n
    \n\n\n
    \n\n\n
    \n\nOFF\n
    \n","info":{"name":"Central Heating","tags":["selection","if","else"],"default":true,"objects":["http://utc-sheffield.github.io/tincan_curriculum/OCR_GCSE_Computing_2012/#2-1-7-H"],"towards":[]},"context_py":"\nfunction INPUT(ControlName) {\n return $(\"#\" + ControlName).val();\n \n}\n\nfunction OUTPUT(Out, Val) {\n if(typeof Val === \"undefined\")\n {\n $(\"#output\").append(\"
    \" + Out + \"
    \");\n }\n else\n {\n $(\"#\" + Out).val(Val);\n }\n}\n\n\nfunction GET(ControlName) {\n return $(\"#\" + ControlName).val();\n}\n\n$(\"#airtemp\").val(26);\n$(\"#boiler\").val(\"OFF\");\nvar MinTemp = INPUT(\"mintemp\");\nvar MaxTemp = INPUT(\"maxtemp\");\nvar AirTemp = GET(\"airtemp\");\nvar Boiler = GET(\"boiler\");\n\n\n//CODE//\n\n\n\nfunction loop() {\n MinTemp = INPUT(\"mintemp\");\n MaxTemp = INPUT(\"maxtemp\");\n AirTemp = GET(\"airtemp\");\n OldStatus = GET(\"boiler\");\n Boiler = calcBoilerStatus(MinTemp, MaxTemp, AirTemp, OldStatus);\n OUTPUT(\"boiler\", Boiler);\n}\n\n\n\nfunction stop(){\n window.clearInterval(intervalID);\n}\n\n\nfunction _loop(){\n loop();\n\n if (Boiler === \"ON\")\n {\n AirTemp ++;\n $(\"#airtemp\").val( AirTemp);\n }\n else\n {\n if( AirTemp > -5)\n {\n AirTemp --;\n $(\"#airtemp\").val( AirTemp );\n }\n else\n {\n OUTPUT(\"You are frozen solid!!!\");\n stop();\n }\n }\n if( AirTemp >= 50)\n {\n OUTPUT(\"House on Fire!!!\");\n stop();\n }\n}\n\nfunction main(){\n intervalID = window.setInterval(_loop, 1000);\n}\n\nfunction run() {\n stop();\n $(\"#output\").html(\"\");\n main();\n}\n\n//TESTS//\n\n$(\"#start\").click(run);\n$(\"#stop\").click(stop);\nmain();\n\n","context":"\nfunction INPUT(ControlName) {\n return $(\"#\" + ControlName).val();\n \n}\n\nfunction OUTPUT(Out, Val) {\n if(typeof Val === \"undefined\")\n {\n $(\"#output\").append(\"
    \" + Out + \"
    \");\n }\n else\n {\n $(\"#\" + Out).val(Val);\n }\n}\n\n\nfunction GET(ControlName) {\n return $(\"#\" + ControlName).val();\n}\n\n$(\"#airtemp\").val(26);\n$(\"#boiler\").val(\"OFF\");\nvar MinTemp = INPUT(\"mintemp\");\nvar MaxTemp = INPUT(\"maxtemp\");\nvar AirTemp = GET(\"airtemp\");\nvar Boiler = GET(\"boiler\");\n\n\n//CODE//\n\n\n\nfunction loop() {\n MinTemp = INPUT(\"mintemp\");\n MaxTemp = INPUT(\"maxtemp\");\n AirTemp = GET(\"airtemp\");\n OldStatus = GET(\"boiler\");\n Boiler = calcBoilerStatus(MinTemp, MaxTemp, AirTemp, OldStatus);\n OUTPUT(\"boiler\", Boiler);\n}\n\n\n\nfunction stop(){\n window.clearInterval(intervalID);\n}\n\n\nfunction _loop(){\n loop();\n\n if (Boiler === \"ON\")\n {\n AirTemp ++;\n $(\"#airtemp\").val( AirTemp);\n }\n else\n {\n if( AirTemp > -5)\n {\n AirTemp --;\n $(\"#airtemp\").val( AirTemp );\n }\n else\n {\n OUTPUT(\"You are frozen solid!!!\");\n stop();\n }\n }\n if( AirTemp >= 50)\n {\n OUTPUT(\"House on Fire!!!\");\n stop();\n }\n}\n\nfunction main(){\n intervalID = window.setInterval(_loop, 1000);\n}\n\nfunction run() {\n stop();\n $(\"#output\").html(\"\");\n main();\n}\n\n//TESTS//\n\n$(\"#start\").click(run);\n$(\"#stop\").click(stop);\nmain();\n\n"},"caesar_search":{"30":{"task":"
  • Cracking the Caesar Cypher in code
  • \n
  • Fix the PlainTextContainsWords function
  • \n
  • Fix the MakeCaesarCypherAlphabet function
  • \n
  • Fix the FindNextPossibleSetting function
  • \n
  • Add words to PlainTextContainsWords until FindNextPossibleSetting finds the setting to decrypt \"VDTZHTBVQRDUQTRFJKHVQVDVCOQYEHIVI\"
  • \n
  • Use the \"Start search for Setting\" to decrypt \"VDTZHTBVQRDUQTRFJKHVQVDVCOQYEHIVI\"
  • \n","initial":"/*global PlainTextAlphabet Decrypt */ //The PlainTextAlphabet and Decrypt functions are already written \n\n//Checks whether the PlainText we have produced contains common words \n//Returns true if found false if not\nfunction PlainTextContainsWords(PlainText) {\n var Words = [\"THE\", \"at\", \"CANON\"]; //Common word list (add more)\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions\n var Pattern = Words.join(\"|\"); // \"THE|at|CANON\"\n var PatternMatcher = new RegExp(Pattern); //Makes a Pattern Matcher using the Pattern \n MatchFound = PatternMatcher.test(PlainText); //true if the plain text contains a match\n return MatchFound;\n\n\n//Returns the CypherAlphabet (the outer ring) for the given Setting\nvar MakeCaesarCypherAlphabet = function(Setting) {\n Setting = Setting % PlainTextAlphabet.length; // Make it so Setting can't ever point outside our Alphabet by using % (remainders)\n var Start = PlainTextAlphabet.slice(0 Setting); //Get first Setting Letters of Our Alphabet\n var End = PlainTextAlphabet.slice(Setting); // Get the rest of the end of Alphabet\n var CypherAlphabet = End + Start; //New Alphabet is the End then the Start\n return CypherAlphabet;\n};\n\n//Trys to find a Setting which Decrypts the CypherText into PlainText which passes PlainTextContainsWordsing\n//Returns the Setting number if successful and false if it couldn't find anything\nfunction FindNextPossibleSetting(StartSetting, CypherText) {\n var Setting = StartSetting; //Set the first Setting to check to StartSetting (so the continue button works and we can check out different possiblities)\n while(Setting <= PlainTextAlphabet.length) { //Go until run out of possible Settings\n var SettingAlphabet = MakeCaesarCypherAlphabet(Setting); //Get the CypherAlphabet for our current attempted setting\n var PlainText = Decrypt(PlainTextAlphabet, SettingAlphabet, CypherText); //Try Decrypting the CypherText\n var SomeWordsMatch = PlainTextContainsWords(PlainText); //Does the PlainText have reconginable words in it\n if(SomeWordsMatch) {\n return Setting; //Found a match, send the Setting back to process\n )\n Setting ++; // Not found so increase the setting by 1\n }\n return false; //If we got all the way to the end of the possible Setting send back false;\n}\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"35":{"task":"
  • Cracking the Caesar Cypher in code
  • \n
  • Fix the PlainTextContainsWords function
  • \n
  • Fix the MakeCaesarCypherAlphabet function
  • \n
  • Fix the FindNextPossibleSetting function
  • \n
  • Add words to PlainTextContainsWords until FindNextPossibleSetting finds the setting to decrypt \"VDTZHTBVQRDUQTRFJKHVQVDVCOQYEHIVI\"
  • \n
  • Use the \"Start search for Setting\" to decrypt \"VDTZHTBVQRDUQTRFJKHVQVDVCOQYEHIVI\"
  • \n","initial":"/*global PlainTextAlphabet Decrypt */ //The PlainTextAlphabet and Decrypt functions are already written \n\n//Checks whether the PlainText we have produced contains common words \n//Returns true if found false if not\nfunction PlainTextContainsWords(PlainText) {\n var Words = [\"THE\", \"at\", \"CANON\"]; //Common word list (add more)\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions\n var Pattern = Words.join(\"|\"); // \"THE|at|CANON\"\n var PatternMatcher = new RegExp(Pattern); //Makes a Pattern Matcher using the Pattern \n var MatchFound = PatternMatcher.test(PlainText); //true if the plain text contains a match\n return MatchFound;\n}\n\n//Returns the CypherAlphabet (the outer ring) for the given Setting\nvar MakeCaesarCypherAlphabet = function(Setting) {\n Setting = Setting % PlainTextAlphabet.length; // Make it so Setting can't ever point outside our Alphabet by using % (remainders)\n var Start = PlainTextAlphabet.slice(0, Setting); //Get first Setting Letters of Our Alphabet\n var End = PlainTextAlphabet.slice(Setting); // Get the rest of the end of Alphabet\n var CypherAlphabet = End + End; //New Alphabet is the End then the Start\n return CypherAlphabet;\n};\n\n//Trys to find a Setting which Decrypts the CypherText into PlainText which passes PlainTextContainsWordsing\n//Returns the Setting number if successful and false if it couldn't find anything\nfunction FindNextPossibleSetting(StartSetting, CypherText) {\n var Setting = StartSetting; //Set the first Setting to check to StartSetting (so the continue button works and we can check out different possiblities)\n while(Setting <= PlainTextAlphabet.length) { //Go until run out of possible Settings\n var SettingAlphabet = MakeCaesarCypherAlphabet(Setting); //Get the CypherAlphabet for our current attempted setting\n var PlainText = Decrypt(PlainTextAlphabet, SettingAlphabet, CypherText); //Try Decrypting the CypherText\n var SomeWordsMatch = PlainTextContainsWords(PlainText); //Does the PlainText have reconginable words in it\n if(SomeWordsMatch) {\n return Setting; //Found a match, send the Setting back to process\n }\n Setting ++; // Not found so increase the setting by 1\n }\n return \"None Found\"; //If we got all the way to the end of the possible Setting send back false;\n}\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"40":{"task":"
  • Cracking the Caesar Cypher in code
  • \n
  • Fix the PlainTextContainsWords function
  • \n
  • Fix the MakeCaesarCypherAlphabet function
  • \n
  • Fix the FindNextPossibleSetting function
  • \n
  • Add words to PlainTextContainsWords until FindNextPossibleSetting finds the setting to decrypt \"VDTZHTBVQRDUQTRFJKHVQVDVCOQYEHIVI\"
  • \n
  • Use the \"Start search for Setting\" to decrypt \"VDTZHTBVQRDUQTRFJKHVQVDVCOQYEHIVI\"
  • \n","initial":"/*global PlainTextAlphabet Decrypt */ //The PlainTextAlphabet and Decrypt functions are already written \n\n//Checks whether the PlainText we have produced contains common words \n//Returns true if found false if not\nfunction PlainTextContainsWords(PlainText) {\n var Words = [\"THE\", \"at\", \"CANON\"]; //Common word list (add more)\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions\n var Pattern = Words.join(\"|\"); // \"THE|at|CANON\"\n var PatternMatcher = new RegExp(Pattern); //Makes a Pattern Matcher using the Pattern \n var MatchFound = PatternMatcher.test(PlainText); //true if the plain text contains a match\n return MatchFound;\n}\n\n//Returns the CypherAlphabet (the outer ring) for the given Setting\nvar MakeCaesarCypherAlphabet = function(Setting) {\n Setting = Setting % PlainTextAlphabet.length; // Make it so Setting can't ever point outside our Alphabet by using % (remainders)\n var Start = PlainTextAlphabet.slice(0, Setting); //Get first Setting Letters of Our Alphabet\n var End = PlainTextAlphabet.slice(Setting); // Get the rest of the end of Alphabet\n //CypherAlphabet = the End then the Start\n return CypherAlphabet;\n};\n\n//Trys to find a Setting which Decrypts the CypherText into PlainText which passes PlainTextContainsWordsing\n//Returns the Setting number if successful and false if it couldn't find anything\nfunction FindNextPossibleSetting(StartSetting, CypherText) {\n //Set the first Setting to check to StartSetting (so the continue button works and we can check out different possiblities)\n while(Setting <= PlainTextAlphabet.length) { //Go until run out of possible Setting values\n //Make Caesar Cypher Alphabet for our current attempted setting\n var PlainText = Decrypt(PlainTextAlphabet, SettingAlphabet, CypherText); //Try Decrypting the CypherText\n var SomeWordsMatch = PlainTextContainsWords(PlainText); //Does the PlainText have reconginable words in it\n if(SomeWordsMatch) {\n return Setting; //Found a match, send the Setting back to process\n }\n // Not found so increase Setting by 1\n Setting ++;\n }\n return false; //If we got all the way to the end of the possible Setting send back false;\n}\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"45":{"task":"
  • Cracking the Caesar Cypher in code
  • \n
  • Fix the PlainTextContainsWords function
  • \n
  • Fix the MakeCaesarCypherAlphabet function
  • \n
  • Fix the FindNextPossibleSetting function
  • \n
  • Add words to PlainTextContainsWords until FindNextPossibleSetting finds the setting to decrypt \"VDTZHTBVQRDUQTRFJKHVQVDVCOQYEHIVI\"
  • \n
  • Use the \"Start search for Setting\" to decrypt \"VDTZHTBVQRDUQTRFJKHVQVDVCOQYEHIVI\"
  • \n","initial":"/*global PlainTextAlphabet Decrypt */ //The PlainTextAlphabet and Decrypt functions are already written \n\n//Checks whether the PlainText we have produced contains common words \n//Returns true if found false if not\nfunction PlainTextContainsWords(PlainText) {\n var Words = [\"THE\", \"at\", \"CANON\"]; //Common word list (add more)\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions\n var Pattern = Words.join(\"|\"); // \"THE|at|CANON\"\n var PatternMatcher = new RegExp(Pattern); //Makes a Pattern Matcher using the Pattern \n var MatchFound = PatternMatcher.test(PlainText); //true if the plain text contains a match\n //must return MatchFound \n}\n\n//Returns the CypherAlphabet (the outer ring) for the given Setting\nvar MakeCaesarCypherAlphabet = function(Setting) {\n Setting = Setting % PlainTextAlphabet.length; // Make it so Setting can't ever point outside our Alphabet by using % (remainders)\n var Start = .slice(0, Setting); //Get first Setting Letters of Our PlainTextAlphabet\n var End = .slice(Setting); // Get the rest of the end of PlainTextAlphabet\n var CypherAlphabet = ; //New CypherAlphabet is the End (Setting characters ) then the Start \n //must return CypherAlphabet \n};\n\n//Trys to find a Setting which Decrypts the CypherText into PlainText which passes PlainTextContainsWordsing\n//Returns the Setting number if successful and false if it couldn't find anything\nfunction FindNextPossibleSetting(StartSetting, CypherText) {\n var Setting = StartSetting; //Set the first Setting to check to StartSetting (so the continue button works and we can check out different possiblities)\n while(Setting <= PlainTextAlphabet.length) { //Go until run out of possible Settings\n //MakeCaesarCypherAlphabet for our current attempted Setting\n var PlainText = Decrypt(PlainTextAlphabet, SettingAlphabet, CypherText); //Try Decrypting the CypherText\n //Does the PlainText have reconginable words in it\n if(SomeWordsMatch) {\n return Setting; //Found a match, send the Setting back to process\n }\n Setting ++; // Not found so increase the setting by 1\n }\n return false; //If we got all the way to the end of the possible Setting send back false;\n}\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"50":{"task":"
  • Cracking the Caesar Cypher in code
  • \n
  • Write the PlainTextContainsWords function
  • \n
  • Write the MakeCaesarCypherAlphabet function
  • \n
  • Write the FindNextPossibleSetting function
  • \n
  • Add words to PlainTextContainsWords until FindNextPossibleSetting finds the setting to decrypt \"VDTZHTBVQRDUQTRFJKHVQVDVCOQYEHIVI\"
  • \n
  • Use the \"Start search for Setting\" to decrypt \"VDTZHTBVQRDUQTRFJKHVQVDVCOQYEHIVI\"
  • \n","initial":"/*global PlainTextAlphabet Decrypt */ //The PlainTextAlphabet and Decrypt functions are already written \n\n//Checks whether the PlainText we have produced contains common words \n//Returns true if found false if not\nfunction PlainTextContainsWords(PlainText) {\n\n\n}\n\n//Returns the CypherAlphabet (the outer ring) for the given Setting\nvar MakeCaesarCypherAlphabet = function(Setting) {\n //PlainTextAlphabet is the normal Alphabet ABCD....\n\n\n};\n\n//Trys to find a Setting which Decrypts the CypherText into PlainText which passes PlainTextContainsWordsing\n//Returns the Setting number if successful and false if it couldn't find anything\nfunction FindNextPossibleSetting(StartSetting, CypherText) {\n //PlainTextAlphabet is the normal Alphabet ABCD....\n\n // You will want to use the following functions :-\n // Decrypt(PlainTextAlphabet, SettingAlphabet, CypherText);\n // PlainTextContainsWords(PlainText); //Does the PlainText have reconginable words in it\n \n}\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"tests":"assert( PlainTextContainsWords(\"ATTACK AT DAWN\"), 'PlainTextContainsWords: Should find a word on its list in \"ATTACK AT DAWN\"', \"data\");\n\nassert( PlainTextContainsWords(\"TBRFMDHXCBOHTGH\") == false, 'PlainTextContainsWords: Should not find a word on its list in \"TBRFMDHXCBOHTGH\"', \"data\");\n\nassert( MakeCaesarCypherAlphabet(15) == \"PQRSTUVWXYZ_ABCDEFGHIJKLMNO\",\n 'MakeCaesarCypherAlphabet: CypherAlphabet for setting 15 should be \"PQRSTUVWXYZ_ABCDEFGHIJKLMNO\"', \"logic\");\n\nassert( FindNextPossibleSetting(0, \"PHHPRZOPHOSPKB\") == 15, 'FindNextPossibleSetting: Should find possible Setting of 15 with Cypher Text of \"PHHPRZOPHOSPKB\"', \"logic\");\n\nassert( FindNextPossibleSetting(0, \"VDTZHTBVQRDUQTRFJKHVQVDVCOQYEHIVI\") == 17, \n 'FindNextPossibleSetting: Should find Setting to Decrypt \"VDTZHTBVQRDUQTRFJKHVQVDVCOQYEHIVI\"', \"logic\");\n\n","simulation":"\n\n

    Current Cypher Table

    \n\n \n \n
    Plain Text Alphabet
    ABCDEFGHIJKLMNOPQRSTUVWXYZ_
    Cypher Alphabet
    ABCDEFGHIJKLMNOPQRSTUVWXYZ_
    \n\n\n\n\n

    Messages

    \n\n \n \n \n \n \n \n \n \n \n \n
    Plain Text Message
    Cypher Text Message
    \n\n \n\n

    \n","info":{"name":"Caesar Setting Search","tags":["array","encryption"],"default":false,"objects":["http://utc-sheffield.github.io/tincan_curriculum/GCSE_Computing_Theme/Cypher"],"towards":[]},"context":"$(\"#matchesfound\").hide();\n \nvar autoAction = function() {\n getDecrypted();\n};\n\nvar PlainTextAlphabet = $(\"#alphabet\").text();\n\nvar makeCaesarCypher = function() {\n var iCaesarSetting = $(\"#caesar_setting\").val();\n //console.log(\"iCaesarSetting =\", iCaesarSetting);\n var sCypherAlphabet = MakeCaesarCypherAlphabet(iCaesarSetting);\n //console.log(\"sCypherAlphabet =\", sCypherAlphabet);\n $(\"#cypheralphabet\").text(sCypherAlphabet);\n autoAction();\n};\n \nvar Encrypt = function(Alphabet, SubstitutionAlphabet, PlainText) {\n var OutputText = \"\"; //We start with no letters in our output\n \n //The variable i will go up from 0 (pointing to the first letter)\n //until i = the length of our plain text (pointing to the last letter in our plain text)\n for(var i = 0 ; i < PlainText.length; i++) { \n var PlainTextLetter = PlainText[i]; //The letter we want to Encypher this time\n var Position = Alphabet.search(PlainTextLetter); //Finds what position our Letter is in our Alphabet\n if(Position === -1) { //If we didn't find the letter in our Alphabet\n Position = Alphabet.search(\"_\"); //Find \"_\" instead\n }\n var CypherLetter = SubstitutionAlphabet[Position]; //Look up that position in our Substitution Alphabet\n OutputText += CypherLetter; //Add our Cypher Letter to the OutputText\n }\n return OutputText; //Send it back\n};\n\nvar Decrypt = function(Alphabet, SubstitutionAlphabet, CypherText) {\n var OutputText = \"\"; //We start with no letters in our output\n \n //The variable i will go up from 0 (pointing to the first letter)\n //until i = the length of our cypher text (pointing to the last letter in our cypher text)\n for(var i = 0 ; i < CypherText.length; i++) { \n var CypherTextLetter = CypherText[i]; //The letter we want to Encypher this time\n var Position = SubstitutionAlphabet.search(CypherTextLetter); //Finds what position our Letter is in our SubstitutionAlphabet\n var PlainTextLetter = Alphabet[Position]; //Look up that position in our Plain text Alphabet\n OutputText += PlainTextLetter; //Add our Plain Text Letter to the OutputText\n }\n return OutputText; //Send it back\n};\n\n \nvar getEncrypted = function() {\n var sIn = $(\"#plaintext\").val();\n var sAlphabet = $(\"#alphabet\").text(); \n var sCypher = $(\"#cypheralphabet\").text();\n var sCypherText = \"\";\n if(sAlphabet.length !== sCypher.length)\n {\n sCypherText = \"Cypher Too Short\";\n } else {\n sCypherText = Encrypt(sAlphabet, sCypher, sIn);\n }\n $(\"#cyphertext\").val(sCypherText); \n //console.log(\"getEncrypted sCypherText =\", sCypherText);\n};\n\nvar getDecrypted = function() {\n var sAlphabet = $(\"#alphabet\").text(); \n var sIn = $(\"#cyphertext\").val();\n var sCypher = $(\"#cypheralphabet\").text();\n var sPlainText = Decrypt(sAlphabet, sCypher, sIn);\n //console.log(\"sPlainText =\", sPlainText);\n $(\"#plaintext\").val(sPlainText);\n //testPlainText();\n};\n\n\n\nvar testPlainText = function () {\n var sPlainText = $(\"#plaintext\").val();\n \n if(PlainTextContainsWords(sPlainText)) {\n $(\"#matchesfound\").show();\n return true;\n } else {\n $(\"#matchesfound\").hide();\n return false;\n } \n};\n\n$(\"#caesar_setting\").on(\"input\", makeCaesarCypher);\n\n//$(\"#plaintext\").on(\"input\", getEncrypted);\n$(\"#cyphertext\").on(\"input\", getDecrypted);\n\n$(\"#cypheralphabet\").on(\"input\", autoAction);\n\n$(\".encrypt\").click(getEncrypted);\n$(\".decrypt\").click(getDecrypted);\n\n\n//CODE// \n\n\nfunction search(){\n var iSetting = FindNextPossibleSetting($(\"#caesar_setting\").val(), $(\"#cyphertext\").val());\n if(iSetting === false) {\n $(\"#searchresult\").text(\"Search found no matching words\");\n } else {\n $(\"#caesar_setting\").val(iSetting);\n makeCaesarCypher();\n $(\"#searchresult\").text(\"Words found with Setting of \"+iSetting );\n }\n}\n\nfunction search_start(){\n $(\"#caesar_setting\").val(0);\n makeCaesarCypher();\n search();\n}\n\n$(\"#search\").click(search_start);\n$(\"#continue_search\").click(search);\n\nmakeCaesarCypher();\n\n//TESTS//\n\n \n"},"caesar":{"30":{"task":"
  • Read the Encrypt Function to see how it works.
  • \n
  • Fix the Decrypt function - use the tests to see if it works.
  • \n
  • Using Setting 13 Decrypt \"NFFNPXMSDAZMFURM_ADFU\"
  • \n
  • Work out what \"JMEQSRJJRBZEDIQEWQYEHIVQJEQJYVQDEHJY\" means
  • \n\n","initial":"var Encrypt = function(Alphabet, SubstitutionAlphabet, PlainText) {\n var OutputText = \"\"; //We start with no letters in our output\n \n //The variable i will go up from 0 (pointing to the first letter)\n //until i = the length of our plain text (pointing to the last letter in our plain text)\n for(var i = 0 ; i < PlainText.length; i++) { \n var PlainTextLetter = PlainText[i]; //The letter we want to Encypher this time\n var Position = Alphabet.search(PlainTextLetter); //Finds what position our Letter is in our Alphabet\n if(Position === -1) { //If we didn't find the letter in our Alphabet\n Position = Alphabet.search(\"_\"); //Find \"_\" instead\n }\n var CypherLetter = SubstitutionAlphabet[Position]; //Look up that position in our Substitution Alphabet\n OutputText += CypherLetter; //Add our Cypher Letter to the OutputText\n }\n return OutputText; //Send it back\n};\n\nvar Decrypt = function(Alphabet, SubstitutionAlphabet, CypherText) {\n var OutputText = \"\"; //We start with no letters in our output\n \n //The variable i will go up from 0 (pointing to the first letter)\n //until i = the length of our cypher text (pointing to the last letter in our cypher text)\n for(var i = 0 ; i < CypherText.length; i++) { \n var CypherTextLetter = CypherText[i; //The letter we want to Encypher this time\n var Position = SubstitutionAlphabet.search(CypherTextLetter); //Finds what position our Letter is in our SubstitutionAlphabet\n var PlainTextLetter = Alphabet[Position]; //Look up that position in our Plain text Alphabet\n OutputText += PlainTextLetter; //Add our Plain Text Letter to the OutputText\n }\n return OutputText; //Send it back\n\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"35":{"task":"
  • Read the Encrypt Function to see how it works.
  • \n
  • Fix the Decrypt function - use the tests to see if it works.
  • \n
  • Using Setting 13 Decrypt \"NFFNPXMSDAZMFURM_ADFU\"
  • \n
  • Work out what \"JMEQSRJJRBZEDIQEWQYEHIVQJEQJYVQDEHJY\" means
  • \n\n","initial":"var Encrypt = function(Alphabet, SubstitutionAlphabet, PlainText) {\n var OutputText = \"\"; //We start with no letters in our output\n \n //The variable i will go up from 0 (pointing to the first letter)\n //until i = the length of our plain text (pointing to the last letter in our plain text)\n for(var i = 0 ; i < PlainText.length; i++) { \n var PlainTextLetter = PlainText[i]; //The letter we want to Encypher this time\n var Position = Alphabet.search(PlainTextLetter); //Finds what position our Letter is in our Alphabet\n if(Position === -1) { //If we didn't find the letter in our Alphabet\n Position = Alphabet.search(\"_\"); //Find \"_\" instead\n }\n var CypherLetter = SubstitutionAlphabet[Position]; //Look up that position in our Substitution Alphabet\n OutputText += CypherLetter; //Add our Cypher Letter to the OutputText\n }\n return OutputText; //Send it back\n};\n\nvar Decrypt = function(Alphabet, SubstitutionAlphabet, CypherText) {\n var OutputText = \"\"; //We start with no letters in our output\n \n //The variable i will go up from 0 (pointing to the first letter)\n //until i = the length of our cypher text (pointing to the last letter in our cypher text)\n for(var i = 0 ; i < CypherText.length; i++) { \n var CypherTextLetter = CypherText[j]; //The letter we want to Encypher this time\n var Position = SubstitutionAlphabet.search(CypherTextLetter); //Finds what position our Letter is in our SubstitutionAlphabet\n var PlainTextLetter = SubstitutionAlphabet[Position]; //Look up that position in our Plain text Alphabet\n OutputText += PlainTextLetter; //Add our Plain Text Letter to the OutputText\n }\n return OutputText; //Send it back\n};\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"40":{"task":"
  • Read the Encrypt Function to see how it works.
  • \n
  • Fix the Decrypt function - use the tests to see if it works.
  • \n
  • Using Setting 13 Decrypt \"NFFNPXMSDAZMFURM_ADFU\"
  • \n
  • Work out what \"JMEQSRJJRBZEDIQEWQYEHIVQJEQJYVQDEHJY\" means
  • \n\n","initial":"var Encrypt = function(Alphabet, SubstitutionAlphabet, PlainText) {\n var OutputText = \"\"; //We start with no letters in our output\n \n //The variable i will go up from 0 (pointing to the first letter)\n //until i = the length of our plain text (pointing to the last letter in our plain text)\n for(var i = 0 ; i < PlainText.length; i++) { \n var PlainTextLetter = PlainText[i]; //The letter we want to Encypher this time\n var Position = Alphabet.search(PlainTextLetter); //Finds what position our Letter is in our Alphabet\n if(Position === -1) { //If we didn't find the letter in our Alphabet\n Position = Alphabet.search(\"_\"); //Find \"_\" instead\n }\n var CypherLetter = SubstitutionAlphabet[Position]; //Look up that position in our Substitution Alphabet\n OutputText += CypherLetter; //Add our Cypher Letter to the OutputText\n }\n return OutputText; //Send it back\n};\n\nvar Decrypt = function(Alphabet, SubstitutionAlphabet, CypherText) {\n var OutputText = \"\"; //We start with no letters in our output\n for(var i = 0 ; i < CypherText.length; i++) { \n //The letter we want to Encypher this time\n var Position = SubstitutionAlphabet.search(CypherTextLetter); //Finds what position our Letter is in our SubstitutionAlphabet\n //Look up that position in our Plain text Alphabet\n OutputText += PlainTextLetter; //Add our Plain Text Letter to the OutputText\n }\n return OutputText; //Send it back\n};\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"45":{"task":"
  • Read the Encrypt Function to see how it works.
  • \n
  • Write the Decrypt function - use the tests to see if it works.
  • \n
  • Using Setting 13 Decrypt \"NFFNPXMSDAZMFURM_ADFU\"
  • \n
  • Work out what \"JMEQSRJJRBZEDIQEWQYEHIVQJEQJYVQDEHJY\" means
  • \n\n","initial":"var Encrypt = function(Alphabet, SubstitutionAlphabet, PlainText) {\n var OutputText = \"\"; //We start with no letters in our output\n \n //The variable i will go up from 0 (pointing to the first letter)\n //until i = the length of our plain text (pointing to the last letter in our plain text)\n for(var i = 0 ; i < PlainText.length; i++) { \n var PlainTextLetter = PlainText[i]; //The letter we want to Encypher this time\n var Position = Alphabet.search(PlainTextLetter); //Finds what position our Letter is in our Alphabet\n if(Position === -1) { //If we didn't find the letter in our Alphabet\n Position = Alphabet.search(\"_\"); //Find \"_\" instead\n }\n var CypherLetter = SubstitutionAlphabet[Position]; //Look up that position in our Substitution Alphabet\n OutputText += CypherLetter; //Add our Cypher Letter to the OutputText\n }\n return OutputText; //Send it back\n};\n\nvar Decrypt = function(Alphabet, SubstitutionAlphabet, CypherText) {\n var OutputText = \"\"; //We start with no letters in our output\n \n \n \n return OutputText; //Send it back\n};\n\n","info":{"verb":{"id":"http://utc-sheffield.github.io/taxonomy/doing/completed/","display":{"en-GB":"completed"}},"label":"Complete"}},"tests":"assert( Encrypt(\"ABCDEFGHIJKLMNOPQRSTUVWXYZ_\", \"KLMNOPQRSTUVWXYZ_ABCDEFGHIJ\", \"ENCRYPTION_TEST\") == \"OXMAHZCSYXJCOBC\", 'Should encrypt \"ENCRYPTION_TEST\" with setting=10 to \"OXMAHZCSYXJCOBC\"', \"logic\");\n\nassert( Encrypt(\"ABCDEFGHIJKLMNOPQRSTUVWXYZ_\", \"PQRSTUVWXYZ_ABCDEFGHIJKLMNO\", \"ENCRYPTION_TEST\") == \"TBRFMDHXCBOHTGH\", 'Should encrypt \"ENCRYPTION_TEST\" with setting=15 to \"TBRFMDHXCBOHTGH\"', \"logic\");\n\nassert( Decrypt(\"ABCDEFGHIJKLMNOPQRSTUVWXYZ_\", \"KLMNOPQRSTUVWXYZ_ABCDEFGHIJ\", \"OXMAHZCSYXJCOBC\") == \"ENCRYPTION_TEST\", 'Should decrypt \"OXMAHZCSYXJCOBC\" with setting=10 to \"ENCRYPTION_TEST\"', \"logic\");\n\nassert( Decrypt(\"ABCDEFGHIJKLMNOPQRSTUVWXYZ_\", \"PQRSTUVWXYZ_ABCDEFGHIJKLMNO\", \"TBRFMDHXCBOHTGH\") == \"ENCRYPTION_TEST\", 'Should decrypt \"TBRFMDHXCBOHTGH\" with setting=15 to \"ENCRYPTION_TEST\"', \"logic\");\n\n","simulation":"\n\n

    Current Cypher Table

    \n\n \n \n
    Plain Text Alphabet
    ABCDEFGHIJKLMNOPQRSTUVWXYZ_
    Cypher Alphabet
    ABCDEFGHIJKLMNOPQRSTUVWXYZ_
    \n

    Make new Caesar Cypher

    \n\n
    \n\n\n\n

    Messages

    \n\n \n \n \n \n \n \n \n \n \n \n
    Plain Text Message
    Cypher Text
    \n\n","info":{"name":"Caesar Cypher","tags":["array","encryption"],"default":true,"objects":["http://utc-sheffield.github.io/tincan_curriculum/GCSE_Computing_Theme/Cypher"],"towards":[]},"context":"$(\"#matchesfound\").hide();\n\n//CODE// \n\nvar getEncrypted = function() {\n var sIn = $(\"#plaintext\").val();\n var sAlphabet = $(\"#alphabet\").text(); \n var sCypher = $(\"#cypheralphabet\").text();\n var sCypherText = \"\";\n if(sAlphabet.length !== sCypher.length)\n {\n sCypherText = \"Cypher Too Short\";\n } else {\n sCypherText = Encrypt(sAlphabet, sCypher, sIn);\n }\n $(\"#cyphertext\").val(sCypherText); \n};\n\nvar getDecrypted = function() {\n var sAlphabet = $(\"#alphabet\").text(); \n var sIn = $(\"#cyphertext\").val();\n var sCypher = $(\"#cypheralphabet\").text();\n var sPlainText = Decrypt(sAlphabet, sCypher, sIn);\n $(\"#plaintext\").val(sPlainText);\n};\n\nvar autoAction = function() {\n var sMode = $(\"#mode\").val();\n if(sMode === \"Encrypt\") {\n getEncrypted();\n } else if(sMode === \"Decrypt\") {\n getDecrypted();\n }\n};\n\nvar makeCaesarCypher = function() {\n var sAlphabet = $(\"#alphabet\").text();\n var iCaesarSetting = $(\"#caesar_setting\").val() % sAlphabet.length;\n var sStart = sAlphabet.slice(0, iCaesarSetting);\n var sEnd = sAlphabet.slice(iCaesarSetting);\n var sNew = sEnd + sStart;\n $(\"#cypheralphabet\").text(sNew);\n autoAction();\n};\n \n$(\"#caesar_setting\").on(\"input\", makeCaesarCypher);\n\n$(\"#plaintext\").on(\"input\", getEncrypted);\n$(\"#cyphertext\").on(\"input\", getDecrypted);\n\n$(\"#cypheralphabet\").on(\"input\", autoAction);\n\n$(\".encrypt\").click(getEncrypted);\n$(\".decrypt\").click(getDecrypted);\n\nmakeCaesarCypher();\n \n//TESTS//\n\n"}} \ No newline at end of file diff --git a/exercises/central_heating/tests.js b/exercises/central_heating/tests.js index d1bb645..9777009 100644 --- a/exercises/central_heating/tests.js +++ b/exercises/central_heating/tests.js @@ -1,8 +1,39 @@ -assert( calcBoilerStatus(19, 22, 18, "OFF") == "ON", 'Boiler should turn ON when too cold.', "logic"); +GCSEtest({ + "text":'Boiler should turn ON when too cold.', + "func": calcBoilerStatus, + "type":"logic", + "input_type":"valid", + "inputs":[19, 22, 18, "OFF"], + "expected":"ON", + "task":1 +}) -assert( calcBoilerStatus(19, 22, 23, "ON") == "OFF", 'Boiler should turn OFF when too hot.', "logic"); +GCSEtest({ + "text":'Boiler should turn OFF when too hot.', + "func": calcBoilerStatus, + "type":"logic", + "input_type":"valid", + "inputs":[19, 22, 23, "ON"], + "expected":"OFF", + "task":2 +}) -assert( calcBoilerStatus(19, 22, 20, "ON") == "ON", 'Boiler should stay ON when temp is OK.', "logic"); - -assert( calcBoilerStatus(19, 22, 20, "OFF") == "OFF", 'Boiler should stay OFF when temp is OK.', "logic"); +GCSEtest({ + "text":'Boiler should stay ON when temp is OK.', + "func": calcBoilerStatus, + "type":"logic", + "input_type":"valid", + "inputs":[19, 22, 20, "ON"], + "expected":"ON", + "task":3 +}) +GCSEtest({ + "text":'Boiler should stay OFF when temp is OK.', + "func": calcBoilerStatus, + "type":"logic", + "input_type":"valid", + "inputs":[19, 22, 20, "OFF"], + "expected":"OFF", + "task":4 +}) diff --git a/index.html b/index.html index ba31cee..97f81a9 100644 --- a/index.html +++ b/index.html @@ -52,6 +52,8 @@

    Result

    Test Results

    + +

    diff --git a/js/executer.js b/js/executer.js index 89280dc..49b20c9 100644 --- a/js/executer.js +++ b/js/executer.js @@ -55,6 +55,31 @@ var Executer = function (sTestScript, sContextScript){ if(this.bTest) { script += "var assert = function(outcome, description, type ) {aTests.push({text:description,type:type,label:outcome?'Pass':'Fail',pass:outcome, row: false, col: false});};"; + script += "var GCSEtest = function(options){"; + script += "var actual = options.func.apply(null, options.inputs);"; + script += "var outcome = (actual == options.expected);"; + script += "var result = new Object(options);"; + script += "result.actual = actual;"; + script += "result.label = outcome?'Pass':'Fail';"; + script += "result.pass = outcome;"; + script += "result.row = false; "; + script += "result.col = false;"; + script += "aTests.push(result);"; + script += "};"; + /* + var GCSEtest = function(options){ + var actual = options.func.apply(null, options.inputs); + var outcome = (actual == options.expected); + var result = new Object(options); + result.actual = actual; + result.label = outcome?'Pass':'Fail'; + result.pass = outcome; + result.row = false; + result.col = false; + aTests.push(result); + }; + */ + } script += this.sContextScript.replace("//CODE//", this.sCode); @@ -67,6 +92,25 @@ var Executer = function (sTestScript, sContextScript){ }; + + this.getExecutionPython = function() { + var script = "aTests = [];"; + + if(this.bTest) { + script += "def assert(outcome, description, type ) {aTests.push({text:description,type:type,label:outcome?'Pass':'Fail',pass:outcome, row: false, col: false});};"; + + } + script += this.sContextScript.replace("##CODE##", this.sCode); + + if(this.bTest) { + // TODO : if()//TESTS// not in script add it at end + script = script.replace("##TESTS##", this.sTestScript); + } + script += "\n\nreturn aTests"; + return script; + + }; + this.execute = function(){ window.clearInterval(intervalID); this.calcAnnoErrors(); @@ -109,22 +153,59 @@ var Executer = function (sTestScript, sContextScript){ this.resultsToHTML = function(){ if(this.aTests.length) { + $("#testtable").html("TestFunctionInput TypeInputsExpectedActualOutcome"); this.aTests.forEach(function(oMess, iKey) { - var li = document.createElement('li'); - li.className = oMess.label.toLowerCase(); - - var sText = oMess.text; - - if(oMess.row !== false) { - $(li).click(function(){ - editor.gotoLine(oMess.row + 1); - }); - sText = "Line "+(oMess.row+1)+" : "+sText; - } - - li.appendChild( document.createTextNode( sText ) ); - var eOut = $("#testoutput"); - eOut.append(li); + if(oMess.input_type){ + var tr = document.createElement('tr'); + tr.className = oMess.label.toLowerCase(); + //var aNum = document.createElement('td'); + + var eTest = document.createElement('td'); + eTest.appendChild( document.createTextNode( oMess.text ) ); + + tr.appendChild(eTest) + var eFunc = document.createElement('td'); + eFunc.appendChild( document.createTextNode( oMess.func.name ) ); + tr.appendChild(eFunc) + + var eIT = document.createElement('td'); + eIT.appendChild( document.createTextNode( oMess.input_type ) ); + tr.appendChild(eIT) + + var eInputs = document.createElement('td'); + eInputs.appendChild( document.createTextNode( oMess.inputs.join(", ") ) ); + tr.appendChild(eInputs) + + var eExpected = document.createElement('td'); + eExpected.appendChild( document.createTextNode( oMess.expected ) ); + tr.appendChild(eExpected) + + var eActual = document.createElement('td'); + eActual.appendChild( document.createTextNode( oMess.actual ) ); + tr.appendChild(eActual) + + var eOutcome = document.createElement('td'); + eOutcome.appendChild( document.createTextNode( oMess.label ) ); + tr.appendChild(eOutcome) + + var eOut = $("#testtable"); + eOut.append(tr); + }else{ + var li = document.createElement('li'); + li.className = oMess.label.toLowerCase(); + + var sText = oMess.text; + + if(oMess.row !== false) { + $(li).click(function(){ + editor.gotoLine(oMess.row + 1); + }); + sText = "Line "+(oMess.row+1)+" : "+sText; + } + li.appendChild( document.createTextNode( sText ) ); + var eOut = $("#testoutput"); + eOut.append(li); + } }); } }; diff --git a/js/exercise.js b/js/exercise.js index fc70e8f..9d7eea0 100644 --- a/js/exercise.js +++ b/js/exercise.js @@ -50,6 +50,7 @@ var Exercise = function (aData, sExercise){ this.resetGUI =function () { $("#output").html(""); $("#testoutput").html(""); + $("#testtable").html(""); $("#result").html(""); $("#simulation").html(this.aData.simulation); $("title").text("Active Javascript : " + this.aData.info.name);