author
int64
658
755k
date
stringlengths
19
19
timezone
int64
-46,800
43.2k
hash
stringlengths
40
40
message
stringlengths
5
490
mods
list
language
stringclasses
20 values
license
stringclasses
3 values
repo
stringlengths
5
68
original_message
stringlengths
12
491
701,848
22.07.2020 09:35:37
-43,200
fae6bb735a9032bf1f5c109e87d1e722e1d1db13
Updates to the editor information panel Remove link to unplugged lesson Remove learning outcomes Remove link to solution in hints Make the h1 challenge headings a smaller font size Remove 'Requirement' heading
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/scss/programming-editor.scss", "new_path": "csunplugged/static/scss/programming-editor.scss", "diff": "@@ -94,10 +94,14 @@ body {\nwidth: 100%;\nborder: 1px solid grey;\nborder-radius: 15px;\n+\n+ h1 {\n+ font-size: 2.0rem;\n+ }\n}\n// Removing the testing examples section from content (temporary).\n- #testing-examples, #testing-examples + p, #testing-examples + p + table {\n+ #testing-examples, #testing-examples + p, #testing-examples + p + table, #requirement {\ndisplay: none;\n}\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "{% endif %}\n{% endblock page_heading %}\n- {% if lessons %}\n- <div class=\"alert alert-info\" role=\"alert\">\n- <p>{% trans \"This programming challenge is linked to the following unplugged lessons:\" %}</p>\n-\n- <ul class=\"mb-0\">\n- {% for lesson in lessons %}\n- <li>\n- <a href=\"{% url 'topics:lesson' topic.slug lesson.unit_plan.slug lesson.slug %}\">\n- {% blocktrans with set_num=lesson.challenge_set_number chal_num=lesson.challenge_number name=lesson.name trimmed %}\n- {{ name }}\n- {% endblocktrans %}\n- ({% for age_group in lesson.age_group.all %}{% blocktrans with lower=age_group.ages.lower upper=age_group.ages.upper trimmed %}{{ lower }} to {{ upper }}{% endblocktrans %}{% if not forloop.last %}, {% endif %}{% endfor %})\n- </a>\n- {% if not lesson.translation_available %}\n- {% include 'generic/not-available-badge.html' %}\n- {% endif %}\n- </li>\n- {% endfor %}\n- </ul>\n- </div>\n- {% endif %}\n-\n-\n{% render_html_field programming_challenge.content %}\n- {% comment %} Learning Outcomes {% endcomment %}\n- {% if learning_outcomes %}\n- <details class=\"panel-learning-outcomes\">\n- <summary>\n- <strong>{% trans \"Learning outcomes\" %}</strong>\n- <img class=\"inline-image\" src=\"{% static 'img/general/outcomes.png' %}\">\n- </summary>\n- <div class=\"boxed-text-content\">\n- <p>{% trans \"Students will be able to:\" %}</p>\n- <ul>\n- {% for learning_outcome in learning_outcomes %}\n- <li>\n- {{ learning_outcome.text }}<br>\n- {% for area in learning_outcome.curriculum_areas.all %}\n- {% include \"topics/curriculum-area-badge.html\" %}\n- {% endfor %}\n- </li>\n- {% endfor %}\n- </ul>\n- </div>\n- </details>\n- {% endif %}\n-\n{% comment %} Challenge Hints {% endcomment %}\n{% for implementation in implementations %}\n{% if implementation.language.name == \"Python\" and implementation.hints %}\n<div class=\"boxed-text-content\">\n{% render_html_field implementation.hints %}\n- <p class=\"text-center\">\n- {% comment %} Link to old solution - in topics section {% endcomment %}\n- <a href=\"{% url 'topics:programming_challenge_solution' topic.slug programming_challenge.slug implementation.language.slug %}\">\n- {% blocktrans trimmed %}\n- Show {{ implementation.language.name }} solution\n- {% endblocktrans %}\n- </a>\n- </p>\n</div>\n</details>\n{% endif %}\n" } ]
Python
MIT License
uccser/cs-unplugged
Updates to the editor information panel - Remove link to unplugged lesson - Remove learning outcomes - Remove link to solution in hints - Make the h1 challenge headings a smaller font size - Remove 'Requirement' heading
701,848
22.07.2020 09:35:45
-43,200
6d647cd2df69cfc67fed3f475a75139e1209c075
Remove redundant 'Plugging it in' breadcrumb
[ { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/index.html", "new_path": "csunplugged/templates/plugging_it_in/index.html", "diff": "{% trans \"Plugging It In\" %}\n{% endblock title %}\n-{% block breadcrumbs %}\n- {% breadcrumb \"Plugging it in\" \"plugging-it-in:index\" %}\n-{% endblock breadcrumbs %}\n-\n{% block page_heading %}\n<h1>{% trans \"Plugging It In\" %}</h1>\n{% endblock page_heading %}\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/lesson.html", "new_path": "csunplugged/templates/plugging_it_in/lesson.html", "diff": "{% endblock title %}\n{% block breadcrumbs %}\n- {% breadcrumb \"Plugging It In\" \"plugging_it_in:index\" %}\n{% breadcrumb topic.name \"plugging_it_in:topic\" topic.slug %}\n{% breadcrumb lesson.name \"plugging_it_in:lesson\" topic.slug lesson.slug %}\n{% endblock breadcrumbs %}\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/topic.html", "new_path": "csunplugged/templates/plugging_it_in/topic.html", "diff": "{% endblock title %}\n{% block breadcrumbs %}\n- {% breadcrumb \"Plugging It In\" \"plugging_it_in:index\" %}\n{% breadcrumb topic.name \"topics:topic\" topic.slug %}\n{% endblock breadcrumbs %}\n" } ]
Python
MIT License
uccser/cs-unplugged
Remove redundant 'Plugging it in' breadcrumb
701,848
22.07.2020 10:21:59
-43,200
6471fc4c4e3bf41ff0d7f06a654b30504c33d7ff
Add unit tests for pii topic view
[ { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/tests/plugging_it_in/views/test_topic_view.py", "diff": "+from http import HTTPStatus\n+from django.urls import reverse\n+from tests.BaseTestWithDB import BaseTestWithDB\n+from tests.topics.TopicsTestDataGenerator import TopicsTestDataGenerator\n+\n+\n+class TopicViewTest(BaseTestWithDB):\n+\n+ def __init__(self, *args, **kwargs):\n+ super().__init__(*args, **kwargs)\n+ self.language = \"en\"\n+ self.test_data = TopicsTestDataGenerator()\n+\n+ def test_pii_topic_view_with_valid_slug(self):\n+ topic = self.test_data.create_topic(1)\n+ self.test_data.create_unit_plan(topic, 1)\n+ kwargs = {\n+ \"topic_slug\": topic.slug\n+ }\n+ url = reverse(\"plugging_it_in:topic\", kwargs=kwargs)\n+ response = self.client.get(url)\n+ self.assertEqual(HTTPStatus.OK, response.status_code)\n+\n+ def test_pii_topic_view_with_invalid_slug(self):\n+ topic = self.test_data.create_topic(1)\n+ self.test_data.create_unit_plan(topic, 1)\n+ kwargs = {\n+ \"topic_slug\": \"wrong_slug\",\n+ }\n+ url = reverse(\"plugging_it_in:topic\", kwargs=kwargs)\n+ response = self.client.get(url)\n+ self.assertEqual(HTTPStatus.NOT_FOUND, response.status_code)\n+\n+ def test_pii_topic_view_topic_context(self):\n+ topic = self.test_data.create_topic(1)\n+ self.test_data.create_unit_plan(topic, 1)\n+ kwargs = {\n+ \"topic_slug\": topic.slug\n+ }\n+ url = reverse(\"plugging_it_in:topic\", kwargs=kwargs)\n+ response = self.client.get(url)\n+ self.assertEqual(\n+ response.context[\"topic\"],\n+ topic\n+ )\n+\n+ def test_pii_topic_view_lessons_context_with_programming_challenge(self):\n+ topic = self.test_data.create_topic(1)\n+ unit_plan = self.test_data.create_unit_plan(topic, 1)\n+ age_group_1 = self.test_data.create_age_group(5, 7)\n+ lesson = self.test_data.create_lesson(\n+ topic,\n+ unit_plan,\n+ 1,\n+ age_group_1\n+ )\n+\n+ difficulty = self.test_data.create_difficulty_level(1)\n+ challenge = self.test_data.create_programming_challenge(topic, 1, difficulty)\n+ self.test_data.add_challenge_lesson_relationship(\n+ challenge,\n+ lesson,\n+ 1,\n+ 1\n+ )\n+\n+ kwargs = {\n+ \"topic_slug\": topic.slug\n+ }\n+ url = reverse(\"plugging_it_in:topic\", kwargs=kwargs)\n+ response = self.client.get(url)\n+ self.assertEqual(\n+ len(response.context[\"grouped_lessons\"]),\n+ 1\n+ )\n+ grouped_lessons = response.context[\"grouped_lessons\"]\n+ for (age_group, lessons) in grouped_lessons.items():\n+ self.assertEqual(repr(age_group), \"<AgeGroup: NumericRange(5, 7, '[)')>\")\n+ self.assertEqual(\n+ lessons,\n+ [lesson]\n+ )\n+\n+ def test_pii_topic_view_lessons_context_without_programming_challenge(self):\n+ topic = self.test_data.create_topic(1)\n+ unit_plan = self.test_data.create_unit_plan(topic, 1)\n+ age_group_1 = self.test_data.create_age_group(5, 7)\n+ self.test_data.create_lesson(\n+ topic,\n+ unit_plan,\n+ 1,\n+ age_group_1\n+ )\n+\n+ kwargs = {\n+ \"topic_slug\": topic.slug\n+ }\n+ url = reverse(\"plugging_it_in:topic\", kwargs=kwargs)\n+ response = self.client.get(url)\n+ self.assertEqual(\n+ len(response.context[\"grouped_lessons\"]),\n+ 0\n+ )\n+\n+ def test_pii_topic_view_templates(self):\n+ topic = self.test_data.create_topic(1)\n+ self.test_data.create_unit_plan(topic, 1)\n+ kwargs = {\n+ \"topic_slug\": topic.slug\n+ }\n+ url = reverse(\"plugging_it_in:topic\", kwargs=kwargs)\n+ response = self.client.get(url)\n+ template_found = False\n+ for template in response.templates:\n+ if template.name == \"plugging_it_in/topic.html\":\n+ template_found = True\n+ self.assertTrue(template_found)\n" } ]
Python
MIT License
uccser/cs-unplugged
Add unit tests for pii topic view
701,848
22.07.2020 20:08:48
-43,200
7ea336df73fd0790021cca2ed48ca666c522fb72
Modify editor top header to be full width
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/scss/programming-editor.scss", "new_path": "csunplugged/static/scss/programming-editor.scss", "diff": "@@ -15,6 +15,14 @@ body {\nwidth: 100%;\n}\n+.navbar-student {\n+ .container {\n+ max-width: 100%;\n+ padding-left: 20px !important;\n+ padding-right: 20px !important;\n+ }\n+}\n+\n.programming__options {\nheight: 7%;\nbackground-color: #28368f;\n" } ]
Python
MIT License
uccser/cs-unplugged
Modify editor top header to be full width
701,848
22.07.2020 21:10:46
-43,200
64c2e023adf28b409b54185d3223061b6af72a02
Simplifying the bottom nav bar Remove lesson name Remove hamburger menu (and font awesome icons) Remove challenge name Progress label is made larger with more information and option to open the challenge navigation
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/editor-options-menu.js", "new_path": "csunplugged/static/js/editor-options-menu.js", "diff": "@@ -61,7 +61,8 @@ function setupLessonNav() {\nconst isCurrentChallengeIndex = (element) => element.slug == current_challenge_slug;\ncurrentChallengeIndex = programming_exercises.findIndex(isCurrentChallengeIndex);\n- document.getElementById(\"challenge_progression_text\").innerHTML = currentChallengeIndex+1 + \"/\" + programming_exercises.length;\n+ const progressionText = `Question <strong>${currentChallengeIndex+1}</strong> of <strong>${programming_exercises.length}</strong>`;\n+ document.getElementById(\"challenge_progression_text\").innerHTML = progressionText;\nsetPreviousChallenge(currentChallengeIndex)\nsetNextChallenge(currentChallengeIndex)\n}\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/static/scss/programming-editor.scss", "new_path": "csunplugged/static/scss/programming-editor.scss", "diff": "@@ -34,6 +34,18 @@ body {\nborder-radius: 20px;\n}\n+ .progression-info {\n+ text-align: center;\n+\n+ #challenge_progression_text {\n+ font-size: 20px;\n+ }\n+\n+ #lessons_nav_toggle:hover {\n+ cursor: pointer;\n+ }\n+ }\n+\n.prev {\nborder: 2px solid white;\ncolor: white;\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/core.html", "new_path": "csunplugged/templates/core.html", "diff": "<link rel=\"apple-touch-icon\" sizes=\"180x180\" href=\"{% static 'img/apple-touch-icon.png' %}\">\n<link rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"{% static 'img/favicon-32x32.png' %}\">\n<link rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"{% static 'img/favicon-16x16.png' %}\">\n- <link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css\">\n<link rel=\"manifest\" href=\"{% static 'img/manifest.json' %}\">\n<link rel=\"mask-icon\" href=\"{% static 'img/safari-pinned-tab.svg' %}\" color=\"#ce2326\">\n<link rel=\"shortcut icon\" href=\"{% static 'img/favicon.ico' %}\">\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "{% endif %}\n</div>\n-<div class=\"col-12 row programming__options d-flex justify-content-between align-items-center\">\n- <div class=\"col-4 lesson-nav d-flex justify-content-start align-items-center\">\n- <button id=\"lessons_nav_toggle\" class=\"btn\"><i class=\"fa fa-bars\"></i></button>\n- <p>{{programming_challenge.name}}</p>\n- </div>\n-\n- <div class=\"col-4 progression-options d-flex justify-content-around align-items-center\">\n+<div class=\"col-12 row programming__options d-flex justify-content-center align-items-center\">\n+ <div class=\"col-12 progression-options d-flex justify-content-between align-items-center\">\n<a id='prev_challenge_button'>\n<button class=\"btn prev\">Previous Challenge</button>\n</a>\n+ <div class=\"progression-info\">\n<p id=\"challenge_progression_text\"></p>\n+ <p id=\"lessons_nav_toggle\">(Click here to select a challenge)</p>\n+ </div>\n<a id='next_challenge_button'>\n<button class=\"btn next\">Next Challenge</button>\n</a>\n</div>\n-\n- <a class=\"col-4 d-flex justify-content-end lesson-link\" href=\"{% url \"plugging_it_in:lesson\" topic.slug lesson.slug %}\">\n- <p >{{lesson.name}}</p>\n- </a>\n</div>\n{% endblock body_container %}\n" } ]
Python
MIT License
uccser/cs-unplugged
Simplifying the bottom nav bar - Remove lesson name - Remove hamburger menu (and font awesome icons) - Remove challenge name - Progress label is made larger with more information and option to open the challenge navigation
701,848
23.07.2020 16:49:04
-43,200
4224a52e76247b7f73e4d33dcb5c1f92a2b41da2
Add headings to the editor and output blocks.
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/scss/programming-editor.scss", "new_path": "csunplugged/static/scss/programming-editor.scss", "diff": "@@ -142,12 +142,21 @@ body {\n}\n}\n+.pii-block-heading {\n+ color: #292b2c;\n+ font-size: 1.1em;\n+ font-weight: bolder;\n+ font-family: \"Noto Sans\", sans-serif;\n+ margin: 0px;\n+ height: 5%;\n+}\n+\n.programming__editor {\nheight: 100%;\npadding: 20px 10px;\n.CodeMirror {\n- height: 93%;\n+ height: 88%;\nmargin: 0px;\nborder: 1px solid grey;\nborder-radius: 15px;\n@@ -190,6 +199,13 @@ body {\n}\n}\n+.programming__results {\n+ .results-table {\n+ max-height: 95%;\n+ overflow-y: auto;\n+ }\n+}\n+\n// Side Drawer\n.sidenav {\nheight: 100%;\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "</div>\n</div>\n<div class=\"col-12 col-md-4 programming__editor\">\n- <textarea id=\"codemirror_editor\"># Start Coding Here.</textarea>\n+ <p class='pii-block-heading'>Enter your code in the editor below</p>\n+ <textarea id=\"codemirror_editor\"></textarea>\n<div class=\"programming__submit d-flex justify-content-between align-items-center\">\n<div class=\"programming__submit_options d-flex justify-content-start\">\n<button class=\"editor_button\" id=\"editor_run_button\" >CHECK</button>\n</div>\n<div class=\"col-12 col-md-4 programming__results\">\n+ <p class='pii-block-heading'>Your results will be displayed here</p>\n{% include \"plugging_it_in/results-table.html\" %}\n</div>\n{% endif %}\n" } ]
Python
MIT License
uccser/cs-unplugged
Add headings to the editor and output blocks.
701,848
23.07.2020 19:18:21
-43,200
d2c923b9680fed8be095738e3bbab2a78cb487f8
Update editor button style Make button text lowercase Make download button an outline style Equal sizes for both buttons
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/scss/programming-editor.scss", "new_path": "csunplugged/static/scss/programming-editor.scss", "diff": "@@ -184,11 +184,19 @@ body {\nmargin: 0px 10px;\nborder-radius: 20px;\ntransition: ease-in;\n+ min-width: 100px;\n}\n- .editor_button:hover {\n+ .editor_button:hover, #download_button:hover {\ncursor: pointer;\nbackground-color: #1b7bffff;\n+ color: white;\n+ }\n+\n+ #download_button {\n+ border: 2px solid #1b7bffff;\n+ color: #1b7bffff;\n+ background-color: transparent;\n}\n#editor_run_button:disabled {\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "<textarea id=\"codemirror_editor\"></textarea>\n<div class=\"programming__submit d-flex justify-content-between align-items-center\">\n<div class=\"programming__submit_options d-flex justify-content-start\">\n- <button class=\"editor_button\" id=\"editor_run_button\" >CHECK</button>\n- <button class=\"editor_button\" id=\"download_button\" >DOWNLOAD</button>\n+ <button class=\"editor_button\" id=\"editor_run_button\" >Check</button>\n+ <button class=\"editor_button\" id=\"download_button\" >Download</button>\n</div>\n<div class=\"code_running_spinner spinner-grow\" role=\"status\">\n<span class=\"sr-only\">Loading...</span>\n" } ]
Python
MIT License
uccser/cs-unplugged
Update editor button style - Make button text lowercase - Make download button an outline style - Equal sizes for both buttons
701,848
23.07.2020 20:11:22
-43,200
12cdb42d77531af18d5d6d7d56a6d6b7d372d9d0
Sidedrawer update Link to unplugged lesson (jump to unplugged) Link to plugging it in lesson Link to plugging it in topic Keep top header visible when sidebar open Switch around the topic and lesson display at the top of the side drawer
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/editor-options-menu.js", "new_path": "csunplugged/static/js/editor-options-menu.js", "diff": "*/\nfunction openNav() {\ndocument.getElementById(\"my_sidenav\").style.width = \"800px\";\n- document.getElementById(\"sidebar_overlay\").style.zIndex = \"1031\";\n+ document.getElementById(\"sidebar_overlay\").style.zIndex = \"1029\";\ndocument.getElementById(\"sidebar_overlay\").style.opacity = \"0.6\";\n}\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/static/scss/programming-editor.scss", "new_path": "csunplugged/static/scss/programming-editor.scss", "diff": "@@ -25,7 +25,7 @@ body {\n.programming__options {\nheight: 7%;\n- background-color: #28368f;\n+ background-color: $student-colour;\ncolor: white;\nmargin-left: 0px;\n@@ -52,12 +52,12 @@ body {\n}\n.prev:hover {\n- color: #28368f;\n+ color: $student-colour;\nbackground-color: white;\n}\n.next {\n- color: #28368f;\n+ color: $student-colour;\nbackground-color: #ffea00;\n}\n}\n@@ -216,12 +216,13 @@ body {\n// Side Drawer\n.sidenav {\n- height: 100%;\nwidth: 0;\nposition: fixed;\n- z-index: 1032;\n+ z-index: 1031;\ntop: 0;\nleft: 0;\n+ margin-top: 50px;\n+ height: calc( 100vh - 50px );\nbackground-color: white;\noverflow-x: hidden;\ntransition: 0.5s;\n@@ -232,9 +233,8 @@ body {\n.sidebar-headings {\npadding: 20px 0px;\nbackground-color: rgb(248, 249, 250);\n- }\n- h5 {\n+ h5, p {\nmargin-bottom: 0px;\n}\n@@ -242,6 +242,15 @@ body {\npadding-left: 20px;\n}\n+ h2:hover, h5:hover, p:hover {\n+ opacity: 0.8;\n+ }\n+ }\n+\n+ p {\n+ padding-left: 20px;\n+ }\n+\na:hover {\ntext-decoration: none;\n}\n@@ -259,6 +268,15 @@ body {\n.challenges-list {\npadding: 0px;\n+\n+ .badge {\n+ margin-right: 10px;\n+ min-width: 40px;\n+\n+ h5 {\n+ color: white;\n+ margin-bottom: 0px;\n+ }\n}\n.current-exercise {\n@@ -269,6 +287,7 @@ body {\nbackground-color: #e9f1fc;\n}\n}\n+}\n.sidenav li {\npadding: 12px 8px 12px 20px;\n@@ -304,7 +323,7 @@ body {\nz-index: 0;\ntop: 0;\nleft: 0;\n- background-color: #111;\n+ background-color: #0f173aff;\nopacity: 0;\noverflow-x: hidden;\ntransition: opacity 0.5s;\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "<a href=\"javascript:void(0)\" class=\"closebtn\" id=\"close_nav_button\">&times;</a>\n<div class='sidebar-headings'>\n- <h2 class='lesson-heading'>{{lesson.name}}</h2>\n+ <a href=\"{% url \"plugging_it_in:topic\" topic.slug %}\">\n<h5 class='topic-subheading'>{{topic.name}}</h5>\n+ </a>\n+ <a href=\"{% url \"plugging_it_in:lesson\" topic.slug lesson.slug %}\">\n+ <h2 class='lesson-heading'>{{lesson.name}}</h2>\n+ </a>\n+ <a href=\"{% url 'topics:lesson' topic.slug lesson.unit_plan.slug lesson.slug %}\">\n+ <p>Jump to the CS Unplugged Lesson</p>\n+ </a>\n</div>\n<hr>\n<ol class='challenges-list'>\n{% for programming_challenge_item in programming_challenges %}\n<a href=\"{% url 'plugging_it_in:programming_challenge' topic.slug lesson.slug programming_challenge_item.slug %}\">\n- <li class=\"{% if programming_challenge.slug == programming_challenge_item.slug %}current-exercise{% endif %}\">{{ programming_challenge_item.challenge_set_number }}.{{ programming_challenge_item.challenge_number }} {{ programming_challenge_item.name }}</li>\n+ <li class=\"{% if programming_challenge.slug == programming_challenge_item.slug %}current-exercise{% endif %}\">\n+ <span class=\"badge badge-primary\">\n+ <h5>{{ programming_challenge_item.challenge_set_number }}.{{ programming_challenge_item.challenge_number }}</h5>\n+ </span>\n+ {{ programming_challenge_item.name }}\n+ </li>\n</a>\n{% endfor %}\n</ol>\n" } ]
Python
MIT License
uccser/cs-unplugged
Sidedrawer update -Link to unplugged lesson (jump to unplugged) -Link to plugging it in lesson -Link to plugging it in topic -Keep top header visible when sidebar open -Switch around the topic and lesson display at the top of the side drawer
701,848
23.07.2020 20:29:28
-43,200
489f9170b78c5f8bcc42b047572a412624b896b7
Filter exercises by language on editor screen
[ { "change_type": "MODIFY", "old_path": "csunplugged/plugging_it_in/views.py", "new_path": "csunplugged/plugging_it_in/views.py", "diff": "@@ -147,9 +147,9 @@ class ProgrammingChallengeView(generic.DetailView):\nfor lesson in lessons:\nif lesson.slug == self.kwargs.get(\"lesson_slug\", None):\ncontext[\"lesson\"] = lesson\n- context[\"programming_challenges\"] = lesson.retrieve_related_programming_challenges()\n+ context[\"programming_challenges\"] = lesson.retrieve_related_programming_challenges(\"Python\")\ncontext[\"programming_exercises_json\"] = json.dumps(\n- list(lesson.retrieve_related_programming_challenges().values()))\n+ list(lesson.retrieve_related_programming_challenges(\"Python\").values()))\n# Getting the related lessons - there may be multiple\ncontext[\"lessons\"] = self.object.lessons.all()\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/models.py", "new_path": "csunplugged/topics/models.py", "diff": "@@ -388,7 +388,7 @@ class Lesson(TranslatableModel):\n\"\"\"\nreturn bool(self.programming_challenges.all())\n- def retrieve_related_programming_challenges(self):\n+ def retrieve_related_programming_challenges(self, language_filter=\"all\"):\n\"\"\"Retrieve the lesson's programming challenges and update numbers.\nReturns:\n@@ -399,6 +399,10 @@ class Lesson(TranslatableModel):\n\"challenge_number\",\n\"name\",\n)\n+\n+ if language_filter != \"all\":\n+ programming_challenges = programming_challenges.filter(implementations__language__name=language_filter)\n+\nfor programming_challenge in programming_challenges:\nchallenge_numbers = ProgrammingChallengeNumber.objects.get(\nlesson=self,\n" } ]
Python
MIT License
uccser/cs-unplugged
Filter exercises by language on editor screen
701,848
23.07.2020 20:48:01
-43,200
fa4c925338d5c447b688b0a118c8e31970cd7256
Update programming challenge languages query to return objects
[ { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/lessons-table.html", "new_path": "csunplugged/templates/plugging_it_in/lessons-table.html", "diff": "</a>\n</td>\n<td class=\"text-center\" style=\"width:20%\">\n- {% for language_icon in lesson.challenge_language_icons %}\n- <img src=\"{% get_static_prefix %}{{ language_icon.implementations__language__icon }}\" class=\"inline-image-small\" />\n+ {% for language in lesson.challenge_languages %}\n+ <img src=\"{% get_static_prefix %}{{ language.icon }}\" class=\"inline-image-small\" />\n{% endfor %}\n</td>\n</tr>\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/models.py", "new_path": "csunplugged/topics/models.py", "diff": "@@ -412,13 +412,13 @@ class Lesson(TranslatableModel):\nprogramming_challenge.challenge_number = challenge_numbers.challenge_number\nreturn programming_challenges\n- def challenge_language_icons(self):\n- \"\"\"Retrieve the lesson's programming challenge language icons.\n+ def challenge_languages(self):\n+ \"\"\"Retrieve the lesson's programming challenge languages.\nReturns:\n- QuerySet of language icons for this lesson.\n+ QuerySet of languages for this lesson.\n\"\"\"\n- return self.programming_challenges.all().values('implementations__language__icon').distinct()\n+ return ProgrammingChallengeLanguage.objects.filter(implementations__challenge__lessons=self).distinct()\ndef get_absolute_url(self):\n\"\"\"Return the canonical URL for a lesson.\n" } ]
Python
MIT License
uccser/cs-unplugged
Update programming challenge languages query to return objects
701,848
23.07.2020 22:06:14
-43,200
ff24e3961749603945456147f2860a129f8da1aa
Add language tabs for lesson challenges
[ { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/lesson.html", "new_path": "csunplugged/templates/plugging_it_in/lesson.html", "diff": "{% block content %}\n{% if programming_challenges %}\n- {% include \"plugging_it_in/programming-challenges-table.html\" %}\n+ <nav>\n+ <div class=\"nav nav-tabs mt-2\" id=\"nav-tab\" role=\"tablist\">\n+ {% for language in lesson.challenge_languages %}\n+ <a class=\"nav-item nav-link {% if forloop.first %}active{% endif %}\" id=\"{{language.name}}\" data-toggle=\"tab\" href=\"#nav-{{language.name}}\" role=\"tab\" aria-controls=\"{{language.name}}\" aria-selected=\"false\">\n+ {{language.name}}\n+ <img src=\"{% get_static_prefix %}{{ language.icon }}\" class=\"inline-image-small pl-1\" />\n+ </a>\n+ {% endfor %}\n+ </div>\n+ </nav>\n+ <div class=\"tab-content\" id=\"nav-tabContent\">\n+ {% for language in lesson.challenge_languages %}\n+ <div class=\"tab-pane fade {% if forloop.first %}show active{% endif %}\" id=\"nav-{{language.name}}\" role=\"tabpanel\" aria-labelledby=\"{{language.name}}\">\n+ {% include \"plugging_it_in/programming-challenges-table.html\" with language=language.name %}\n+ </div>\n+ {% endfor %}\n+ </div>\n{% else %}\n<p>{% blocktrans trimmed %}No programming challenges for {{ topic }}.{% endblocktrans %}</p>\n{% endif %}\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenges-table.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenges-table.html", "diff": "{% load i18n %}\n-<table class=\"table table-responsive table-center-vertical\">\n+<div class='table-responsive'>\n+<table class=\"table table-center-vertical\">\n<thead class=\"thead-default\">\n<tr>\n<th class=\"text-center\">{% trans \"Number\" %}</th>\n<th>{% trans \"Name\" %}</th>\n<th class=\"text-center\">{% trans \"Challenge Level\" %}</th>\n- <th class=\"text-center\">{% trans \"Languages\" %}</th>\n</tr>\n</thead>\n<tbody>\n{% for programming_challenge in programming_challenges %}\n+ {% for implementation in programming_challenge.ordered_implementations %}\n+ {% if implementation.language.name == language %}\n<tr class=\"align-middle{% if not programming_challenge.translation_available %} table-active{% endif %}\">\n<td class=\"text-center\">\n{{ programming_challenge.challenge_set_number }}.{{ programming_challenge.challenge_number }}\n{% include \"generic/not-available-badge.html\" %}\n<br>\n{% endif %}\n+ {% if language == \"Python\"%}\n<a href=\"{% url 'plugging_it_in:programming_challenge' topic.slug lesson.slug programming_challenge.slug %}\">\n- <strong>\n- {{ programming_challenge.name }}\n- </strong>\n+ <strong>{{ programming_challenge.name }}</strong>\n+ </a>\n+ {% else %}\n+ {% comment %} Links back to the old unplugged challenge {% endcomment %}\n+ <a href=\"{% url 'topics:programming_challenge' topic.slug programming_challenge.slug %}\">\n+ <strong>{{ programming_challenge.name }}</strong>\n</a>\n+ {% endif %}\n</td>\n<td class=\"text-center\">\n{% include \"topics/programming-difficulty-badge.html\" %}\n</td>\n- <td class=\"text-center\">\n- {% for implementation in programming_challenge.ordered_implementations %}\n- <img src=\"{% get_static_prefix %}{{ implementation.language.icon }}\" class=\"inline-image-small\" />\n- {% endfor %}\n- </td>\n</tr>\n+ {% endif %}\n+ {% endfor %}\n{% endfor %}\n</tbody>\n</table>\n+</div>\n" } ]
Python
MIT License
uccser/cs-unplugged
Add language tabs for lesson challenges
701,848
25.07.2020 09:27:50
-43,200
f1b1e488aebae2a60ad159cad87152735147dbe8
Add extra unit plan view test for cover all conditional cases for grouped lessons
[ { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/views/test_unit_plan_view.py", "new_path": "csunplugged/tests/topics/views/test_unit_plan_view.py", "diff": "@@ -140,6 +140,51 @@ class UnitPlanViewTest(BaseTestWithDB):\n)\ni += 1\n+ def test_unit_plan_view_lessons_with_programming_exercises(self):\n+ topic = self.test_data.create_topic(1)\n+ unit_plan = self.test_data.create_unit_plan(topic, 1)\n+ age_group_1 = self.test_data.create_age_group(5, 7)\n+ lesson1 = self.test_data.create_lesson(\n+ topic,\n+ unit_plan,\n+ 1,\n+ age_group_1\n+ )\n+ lesson2 = self.test_data.create_lesson(\n+ topic,\n+ unit_plan,\n+ 2,\n+ age_group_1\n+ )\n+\n+ # This covers the false true senario in the retrieve_related_programming_challenges method\n+ difficulty = self.test_data.create_difficulty_level(1)\n+ challenge = self.test_data.create_programming_challenge(topic, 1, difficulty)\n+ self.test_data.add_challenge_lesson_relationship(\n+ challenge,\n+ lesson1,\n+ 1,\n+ 1\n+ )\n+\n+ kwargs = {\n+ \"topic_slug\": topic.slug,\n+ \"unit_plan_slug\": unit_plan.slug,\n+ }\n+ url = reverse(\"topics:unit_plan\", kwargs=kwargs)\n+ response = self.client.get(url)\n+ self.assertEqual(\n+ len(response.context[\"grouped_lessons\"]),\n+ 1\n+ )\n+ grouped_lessons = response.context[\"grouped_lessons\"]\n+ for (age_group, lessons) in grouped_lessons.items():\n+ self.assertEqual(repr(age_group), \"<AgeGroup: NumericRange(5, 7, '[)')>\")\n+ self.assertEqual(\n+ lessons,\n+ [lesson1, lesson2]\n+ )\n+\ndef test_unit_plan_view_templates(self):\ntopic = self.test_data.create_topic(1)\nunit_plan = self.test_data.create_unit_plan(topic, 1)\n" } ]
Python
MIT License
uccser/cs-unplugged
Add extra unit plan view test for cover all conditional cases for grouped lessons
701,848
25.07.2020 11:06:24
-43,200
a2c8d3d9ffe153b7b42fc92dd2c56da48d06ac75
Add init files to the plugging it in test package.
[ { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/tests/plugging_it_in/__init__.py", "diff": "+\"\"\"Module for tests of the plugging it in application.\"\"\"\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/tests/plugging_it_in/views/__init__.py", "diff": "+\"\"\"Module for tests of the views in the plugging it in application.\"\"\"\n" } ]
Python
MIT License
uccser/cs-unplugged
Add init files to the plugging it in test package.
701,848
25.07.2020 12:07:09
-43,200
5970ae8a5c19c251f7e73ac460be263f606516f8
Add addtional tests to the lessons model test_get_filtered_programming_exercises_by_lanaguge test_get_programming_exercises_without_filter test_get_available_languages
[ { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/models/test_lesson.py", "new_path": "csunplugged/tests/topics/models/test_lesson.py", "diff": "@@ -46,3 +46,126 @@ class LessonModelTest(BaseTestWithDB):\nlesson.get_absolute_url(),\n\"/en/topics/topic-1/unit-plan-1/lesson-1/\"\n)\n+\n+ def test_get_filtered_programming_exercises_by_lanaguge(self):\n+ topic = self.test_data.create_topic(1)\n+ unit_plan = self.test_data.create_unit_plan(topic, 1)\n+ age_group_1 = self.test_data.create_age_group(5, 7)\n+ lesson = self.test_data.create_lesson(\n+ topic,\n+ unit_plan,\n+ 1,\n+ age_group_1\n+ )\n+ self.assertEqual(lesson.MODEL_NAME, \"Lesson\")\n+\n+ difficulty = self.test_data.create_difficulty_level(1)\n+ language1 = self.test_data.create_programming_language(1)\n+ challenge = self.test_data.create_programming_challenge(topic, 1, difficulty)\n+\n+ self.test_data.add_challenge_lesson_relationship(\n+ challenge,\n+ lesson,\n+ 1,\n+ 1\n+ )\n+\n+ # Create an implementation which has a language called \"Language 1\"\n+ self.test_data.create_programming_challenge_implementation(\n+ topic=topic,\n+ language=language1,\n+ challenge=challenge\n+ )\n+\n+ filtered_challenges = lesson.retrieve_related_programming_challenges(\"Language 2\")\n+\n+ # No challenges should be returned as there are none that have implemenations with language \"Language 2\"\n+ self.assertEqual(len(filtered_challenges), 0)\n+\n+ def test_get_programming_exercises_without_filter(self):\n+ topic = self.test_data.create_topic(1)\n+ unit_plan = self.test_data.create_unit_plan(topic, 1)\n+ age_group_1 = self.test_data.create_age_group(5, 7)\n+ lesson = self.test_data.create_lesson(\n+ topic,\n+ unit_plan,\n+ 1,\n+ age_group_1\n+ )\n+ self.assertEqual(lesson.MODEL_NAME, \"Lesson\")\n+\n+ difficulty = self.test_data.create_difficulty_level(1)\n+ language1 = self.test_data.create_programming_language(1)\n+ challenge = self.test_data.create_programming_challenge(topic, 1, difficulty)\n+\n+ self.test_data.add_challenge_lesson_relationship(\n+ challenge,\n+ lesson,\n+ 1,\n+ 1\n+ )\n+\n+ # Create an implementation which has a language called \"Language 1\"\n+ self.test_data.create_programming_challenge_implementation(\n+ topic=topic,\n+ language=language1,\n+ challenge=challenge\n+ )\n+\n+ non_filtered_challenges = lesson.retrieve_related_programming_challenges()\n+\n+ # One challenge should be returned in the non filtered set\n+ self.assertQuerysetEqual(non_filtered_challenges, [str(challenge.__repr__())])\n+\n+ def test_get_available_languages(self):\n+ topic = self.test_data.create_topic(1)\n+ unit_plan = self.test_data.create_unit_plan(topic, 1)\n+ age_group_1 = self.test_data.create_age_group(5, 7)\n+ lesson = self.test_data.create_lesson(\n+ topic,\n+ unit_plan,\n+ 1,\n+ age_group_1\n+ )\n+ self.assertEqual(lesson.MODEL_NAME, \"Lesson\")\n+\n+ difficulty = self.test_data.create_difficulty_level(1)\n+ language1 = self.test_data.create_programming_language(1)\n+ challenge1 = self.test_data.create_programming_challenge(topic, 1, difficulty)\n+ challenge2 = self.test_data.create_programming_challenge(topic, 1, difficulty)\n+\n+ self.test_data.add_challenge_lesson_relationship(\n+ challenge1,\n+ lesson,\n+ 1,\n+ 1\n+ )\n+\n+ self.test_data.add_challenge_lesson_relationship(\n+ challenge2,\n+ lesson,\n+ 2,\n+ 1\n+ )\n+\n+ # Create an implementation which has a language called \"Language 1\"\n+ self.test_data.create_programming_challenge_implementation(\n+ topic=topic,\n+ language=language1,\n+ challenge=challenge1\n+ )\n+\n+ # Create an implementation which has a language called \"Language 1\"\n+ self.test_data.create_programming_challenge_implementation(\n+ topic=topic,\n+ language=language1,\n+ challenge=challenge2\n+ )\n+\n+ available_languages = lesson.challenge_languages()\n+\n+ # One distinct language should be returned\n+ self.assertQuerysetEqual(\n+ available_languages,\n+ [str(language1.__repr__())]\n+ )\n" } ]
Python
MIT License
uccser/cs-unplugged
Add addtional tests to the lessons model - test_get_filtered_programming_exercises_by_lanaguge - test_get_programming_exercises_without_filter - test_get_available_languages
701,848
25.07.2020 17:31:24
-43,200
26b99b162fff0d649ed2f2e36f7569ada284b3d5
Remove redundant editor context
[ { "change_type": "MODIFY", "old_path": "csunplugged/plugging_it_in/views.py", "new_path": "csunplugged/plugging_it_in/views.py", "diff": "@@ -151,17 +151,6 @@ class ProgrammingChallengeView(generic.DetailView):\ncontext[\"programming_exercises_json\"] = json.dumps(\nlist(lesson.retrieve_related_programming_challenges(\"Python\").values()))\n- # Getting the related lessons - there may be multiple\n- context[\"lessons\"] = self.object.lessons.all()\n- for lesson in context[\"lessons\"]:\n- challenge_numbers = ProgrammingChallengeNumber.objects.get(\n- lesson=lesson,\n- programming_challenge=self.object\n- )\n- lesson.challenge_set_number = challenge_numbers.challenge_set_number\n- lesson.challenge_number = challenge_numbers.challenge_number\n-\n- context[\"learning_outcomes\"] = self.object.learning_outcomes(manager=\"translated_objects\").order_by(\"text\")\ncontext[\"implementations\"] = self.object.ordered_implementations()\ncontext[\"test_cases_json\"] = json.dumps(list(self.object.related_test_cases().values()))\ncontext[\"test_cases\"] = self.object.related_test_cases().values()\n" } ]
Python
MIT License
uccser/cs-unplugged
Remove redundant editor context
701,848
30.07.2020 11:31:57
-43,200
8f0e5de835e5c07a0cb3c77ceaeacf7b03ce1756
Editor button UI adjustments Changed the outline to the be the same colour as the check button Added a border to the check button so both buttons are the same size
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/scss/programming-editor.scss", "new_path": "csunplugged/static/scss/programming-editor.scss", "diff": "@@ -183,6 +183,7 @@ body {\n.editor_button {\nborder: none;\nbackground-color: #5a9fffff;\n+ border: 2px solid #5a9fffff;\ncolor: white;\nheight: 80%;\npadding: 0px 20px;\n@@ -195,12 +196,13 @@ body {\n.editor_button:hover, #download_button:hover {\ncursor: pointer;\nbackground-color: #1b7bffff;\n+ border: 2px solid #1b7bffff;\ncolor: white;\n}\n#download_button {\n- border: 2px solid #1b7bffff;\n- color: #1b7bffff;\n+ border: 2px solid #5a9fffff;\n+ color: #5a9fffff;\nbackground-color: transparent;\n}\n" } ]
Python
MIT License
uccser/cs-unplugged
Editor button UI adjustments - Changed the outline to the be the same colour as the check button - Added a border to the check button so both buttons are the same size
701,848
30.07.2020 11:37:20
-43,200
eefa3af2ea27e7942293dd27a01c76e30a2aaad0
Lesson challenges tabs adjustments Disabled Scratch tab Reordered tabs alphabetically by name so Python appears as the first tab
[ { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/lesson.html", "new_path": "csunplugged/templates/plugging_it_in/lesson.html", "diff": "<nav>\n<div class=\"nav nav-tabs mt-2\" id=\"nav-tab\" role=\"tablist\">\n{% for language in lesson.challenge_languages %}\n- <a class=\"nav-item nav-link {% if forloop.first %}active{% endif %}\" id=\"{{language.name}}\" data-toggle=\"tab\" href=\"#nav-{{language.name}}\" role=\"tab\" aria-controls=\"{{language.name}}\" aria-selected=\"false\">\n+ <a class=\"nav-item nav-link {% if forloop.first %}active{% endif %} {% if language.name == \"Scratch\" %}disabled{% endif %}\" id=\"{{language.name}}\" data-toggle=\"tab\" href=\"#nav-{{language.name}}\" role=\"tab\" aria-controls=\"{{language.name}}\" aria-selected=\"false\">\n{{language.name}}\n<img src=\"{% get_static_prefix %}{{ language.icon }}\" class=\"inline-image-small pl-1\" />\n</a>\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/models.py", "new_path": "csunplugged/topics/models.py", "diff": "@@ -418,7 +418,11 @@ class Lesson(TranslatableModel):\nReturns:\nQuerySet of languages for this lesson.\n\"\"\"\n- return ProgrammingChallengeLanguage.objects.filter(implementations__challenge__lessons=self).distinct()\n+ return ProgrammingChallengeLanguage.objects \\\n+ .filter(implementations__challenge__lessons=self) \\\n+ .distinct() \\\n+ .order_by('name') \\\n+\ndef get_absolute_url(self):\n\"\"\"Return the canonical URL for a lesson.\n" } ]
Python
MIT License
uccser/cs-unplugged
Lesson challenges tabs adjustments - Disabled Scratch tab - Reordered tabs alphabetically by name so Python appears as the first tab
701,848
30.07.2020 11:53:14
-43,200
608538826e1826d6705f62e94ee27e9e8e0fb83e
Fix plugging-it-in URL bug
[ { "change_type": "MODIFY", "old_path": "csunplugged/config/urls.py", "new_path": "csunplugged/config/urls.py", "diff": "@@ -25,9 +25,9 @@ urlpatterns += [\n]\nif not env(\"DEPLOYMENT\", default=None) == \"prod\":\n- urlpatterns += [\n+ urlpatterns += i18n_patterns(\npath('plugging-it-in/', include('plugging_it_in.urls', namespace='plugging_it_in')),\n- ]\n+ )\nif settings.DEBUG: # pragma: no cover\nimport debug_toolbar\n" } ]
Python
MIT License
uccser/cs-unplugged
Fix plugging-it-in URL bug
701,848
04.08.2020 20:20:25
-43,200
2a377a2ee1933e43bd41b507b2d86b903fa2a667
Renaming various plugging it in views
[ { "change_type": "MODIFY", "old_path": "csunplugged/plugging_it_in/urls.py", "new_path": "csunplugged/plugging_it_in/urls.py", "diff": "@@ -14,12 +14,12 @@ urlpatterns = [\n),\nurl(\nr\"^(?P<topic_slug>[-\\w]+)/$\",\n- views.TopicView.as_view(),\n+ views.LessonsView.as_view(),\nname=\"topic\"\n),\nurl(\nr\"^(?P<topic_slug>[-\\w]+)/(?P<lesson_slug>[-\\w]+)/$\",\n- views.LessonView.as_view(),\n+ views.ProgrammingChallengeListView.as_view(),\nname=\"lesson\"\n),\nurl(\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/plugging_it_in/views.py", "new_path": "csunplugged/plugging_it_in/views.py", "diff": "@@ -54,7 +54,7 @@ class IndexView(generic.ListView):\nreturn context\n-class TopicView(generic.DetailView):\n+class LessonsView(generic.DetailView):\n\"\"\"View of lessons with programming exercises for a particular topic.\"\"\"\nmodel = UnitPlan\n@@ -63,10 +63,10 @@ class TopicView(generic.DetailView):\ncontext_object_name = \"topic\"\ndef get_object(self, **kwargs):\n- \"\"\"Retrieve object for the unit plan view.\n+ \"\"\"Retrieve object for the lessons view.\nReturns:\n- UnitPlan object, or raises 404 error if not found.\n+ UnitPlan object with lessons, or raises 404 error if not found.\n\"\"\"\nreturn get_object_or_404(\nself.model.objects.select_related(),\n@@ -80,7 +80,7 @@ class TopicView(generic.DetailView):\nDictionary of context data.\n\"\"\"\n# Call the base implementation first to get a context\n- context = super(TopicView, self).get_context_data(**kwargs)\n+ context = super(LessonsView, self).get_context_data(**kwargs)\n# Loading object under consistent context names for breadcrumbs\ncontext[\"topic\"] = self.object.topic\n# Add all the connected lessons\n@@ -88,21 +88,21 @@ class TopicView(generic.DetailView):\nreturn context\n-class LessonView(generic.DetailView):\n- \"\"\"View for a specific lesson.\"\"\"\n+class ProgrammingChallengeListView(generic.DetailView):\n+ \"\"\"View showing all the programming exercises for a specific lesson.\"\"\"\nmodel = Lesson\ntemplate_name = \"plugging_it_in/lesson.html\"\nslug_url_kwarg = \"lesson_slug\"\ndef get_context_data(self, **kwargs):\n- \"\"\"Provide the context data for the topic view.\n+ \"\"\"Provide the context data for the programming challenge list view.\nReturns:\nDictionary of context data.\n\"\"\"\n# Call the base implementation first to get a context\n- context = super(LessonView, self).get_context_data(**kwargs)\n+ context = super(ProgrammingChallengeListView, self).get_context_data(**kwargs)\ncontext[\"topic\"] = self.object.topic\n" }, { "change_type": "RENAME", "old_path": "csunplugged/tests/plugging_it_in/views/test_topic_view.py", "new_path": "csunplugged/tests/plugging_it_in/views/test_lessons_view.py", "diff": "@@ -4,7 +4,7 @@ from tests.BaseTestWithDB import BaseTestWithDB\nfrom tests.topics.TopicsTestDataGenerator import TopicsTestDataGenerator\n-class TopicViewTest(BaseTestWithDB):\n+class LessonsViewTest(BaseTestWithDB):\ndef __init__(self, *args, **kwargs):\nsuper().__init__(*args, **kwargs)\n" } ]
Python
MIT License
uccser/cs-unplugged
Renaming various plugging it in views
701,848
05.08.2020 11:26:25
-43,200
6707152b3c882aae6cd60734bfcdd7495fdc4c54
Various review fixes Adding translation Adding an extra line to the end of some js files Fixing some comments FIxing indentation Adding in breakpoint mixin to editor styles
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "@@ -80,7 +80,7 @@ function updateResultsTable(results) {\n/**\n* Downloads text to a file.\n* @param {String} filename The filename of the file to be downloaded.\n- * @param {string} text The text content of the file to be downloaded.\n+ * @param {String} text The text content of the file to be downloaded.\n*/\nfunction download(filename, text) {\nvar element = document.createElement('a');\n@@ -96,7 +96,7 @@ function download(filename, text) {\n}\n/**\n- * Downloads the editor code to a file called code.py.\n+ * Downloads the editor code to a file called <current_challenge_slug>.py.\n*/\nfunction downloadCode() {\ndownload(current_challenge_slug + \".py\", myCodeMirror.getValue());\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/static/js/test-code.js", "new_path": "csunplugged/static/js/test-code.js", "diff": "@@ -80,7 +80,7 @@ async function run_testcase(\ntestcaseResult.userOutput = userResult.stdout;\n}\n} else if (userResult.outcome == 11) {\n- // Outcome 11: Compiler Error\n+ // Outcome 11: Compiler Error from Jobe (this has been changed to Syntax Error for plugging it in)\ntestcaseResult.status = \"Syntax Error\";\ntestcaseResult.userOutput = userResult.cmpinfo;\n} else if (userResult.outcome == 13) {\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/static/scss/programming-editor.scss", "new_path": "csunplugged/static/scss/programming-editor.scss", "diff": "@import \"node_modules/codemirror/lib/codemirror\";\n+@import \"node_modules/bootstrap/scss/functions\";\n+@import \"node_modules/bootstrap/scss/variables\";\n+@import \"node_modules/bootstrap/scss/mixins\";\n$student-colour: #3044b3;\n$student-colour-light: #5a9fffff;;\n@@ -227,7 +230,7 @@ body {\n}\n// For small devices\n-@media (max-width: 768px) {\n+@include media-breakpoint-down(sm) {\n.programming__results, .programming__editor, .programming__info-area {\npadding: 20px !important;\n}\n@@ -335,10 +338,6 @@ body {\nz-index: 1004;\n}\n-@media screen and (max-height: 450px) {\n- .sidenav {padding-top: 15px;}\n- .sidenav a {font-size: 18px;}\n-}\n#sidebar_overlay {\nheight: 100%;\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/lesson.html", "new_path": "csunplugged/templates/plugging_it_in/lesson.html", "diff": "{% load django_bootstrap_breadcrumbs %}\n{% block title %}\n- {{ topic.name }} Programming Exercises\n+ {% blocktrans with name=topic.name %}{{ name }} Programming Exercises{% endblocktrans %}\n{% endblock title %}\n{% block breadcrumbs %}\n{% endblock breadcrumbs %}\n{% block page_heading %}\n- <h1 id=\"{{ lesson.slug }}\">{{ lesson.name }} programming exercises</h1>\n+ <h1 id=\"{{ lesson.slug }}\">{% blocktrans with name=lesson.name %}{{ name }} programming exercises{% endblocktrans %}</h1>\n{% endblock page_heading %}\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "<div class=\"row programming__challenge-screen\">\n-\n<div id=\"my_sidenav\" class=\"sidenav\">\n<a href=\"javascript:void(0)\" class=\"closebtn\" id=\"close_nav_button\">&times;</a>\n<h2 class='lesson-heading'>{{lesson.name}}</h2>\n</a>\n<a href=\"{% url 'topics:lesson' topic.slug lesson.unit_plan.slug lesson.slug %}\">\n- <p>Jump to the CS Unplugged Lesson</p>\n+ <p>{% trans \"Jump to the CS Unplugged Lesson\" %}</p>\n</a>\n</div>\n<hr>\n- <p class='challenges-heading'>Challenges</p>\n+ <p class='challenges-heading'>{% trans \"Challenges\" %}</p>\n<ol class='challenges-list'>\n{% for programming_challenge_item in programming_challenges %}\n<a href=\"{% url 'plugging_it_in:programming_challenge' topic.slug lesson.slug programming_challenge_item.slug %}\">\n" } ]
Python
MIT License
uccser/cs-unplugged
Various review fixes - Adding translation - Adding an extra line to the end of some js files - Fixing some comments - FIxing indentation - Adding in breakpoint mixin to editor styles
701,848
03.08.2020 19:12:47
-43,200
0ad861976366ac1b83e5ac579debfd44da4cf4fe
Add code attempt persistance using sessions.
[ { "change_type": "MODIFY", "old_path": "csunplugged/plugging_it_in/urls.py", "new_path": "csunplugged/plugging_it_in/urls.py", "diff": "@@ -32,4 +32,9 @@ urlpatterns = [\nviews.JobeProxyView.as_view(),\nname=\"jobe_proxy\"\n),\n+ url(\n+ r\"^save_attempt$\",\n+ views.SaveAttemptView.as_view(),\n+ name=\"save_attempt\"\n+ ),\n]\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/plugging_it_in/views.py", "new_path": "csunplugged/plugging_it_in/views.py", "diff": "@@ -154,6 +154,8 @@ class ProgrammingChallengeView(generic.DetailView):\ncontext[\"test_cases_json\"] = json.dumps(list(self.object.related_test_cases().values()))\ncontext[\"test_cases\"] = self.object.related_test_cases().values()\ncontext[\"jobe_proxy_url\"] = reverse('plugging_it_in:jobe_proxy')\n+ context[\"saved_attempts\"] = self.request.session.get('saved_attempts', {})\n+\nreturn context\n@@ -180,3 +182,17 @@ class JobeProxyView(View):\nresponse = requests.post(settings.JOBE_SERVER_URL + \"/jobe/index.php/restapi/runs/\",\ndata=body, headers=headers)\nreturn HttpResponse(response.text)\n+\n+\n+class SaveAttemptView(View):\n+ \"\"\"View to save the users challenge attempt.\"\"\"\n+\n+ def post(self, request):\n+ \"\"\"Save the users attempt to a Django session.\"\"\"\n+ body_unicode = request.body.decode('utf-8')\n+ body = json.loads(body_unicode)\n+\n+ request.session['saved_attempts'] = request.session.get('saved_attempts', {})\n+ request.session['saved_attempts'][body[\"challenge\"]] = body[\"attempt\"]\n+\n+ return HttpResponse(\"Saved the attempt.\")\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "@@ -26,6 +26,9 @@ let myCodeMirror = CodeMirror.fromTextArea(myTextarea, {\n}\n});\n+// Set the editor to show the saved attempt if it exists\n+myCodeMirror.getDoc().setValue(saved_attempts[current_challenge_slug] ? saved_attempts[current_challenge_slug] : \"\");\n+\n/**\n* Retrieves code from the code mirror editor, runs all the test cases then updates the results table.\n* Disables the \"CHECK\" button and shows a loading spinner while request is being processed.\n@@ -38,6 +41,11 @@ function sendCodeToJobe() {\n$(\"#editor_run_button\").prop(\"disabled\", true);\n$(\".code_running_spinner\").css(\"display\", \"inline-block\");\n+ // Saved the users code\n+ let raw_code = myCodeMirror.getValue();\n+ save_code(raw_code)\n+\n+ // Run the test_cases\ncode_tester.run_all_testcases(code, test_cases).then(result => {\nupdateResultsTable(result);\n$(\"#editor_run_button\").prop(\"disabled\", false);\n@@ -45,6 +53,29 @@ function sendCodeToJobe() {\n});\n}\n+/**\n+ * Creates a request to save the users code in a django session.\n+ * @param {String} raw_code The users raw code attempt\n+ */\n+async function save_code(raw_code) {\n+ // Sets the saved attempt\n+ let data = {\n+ \"challenge\": current_challenge_slug,\n+ \"attempt\": raw_code\n+ }\n+\n+ // Saves the code in the django session\n+ fetch(save_attempt_url, {\n+ method: \"POST\",\n+ headers: {\n+ \"Content-type\": \"application/json; charset=utf-8\",\n+ Accept: \"application/json\",\n+ \"X-CSRFToken\": csrf_token\n+ },\n+ body: JSON.stringify(data)\n+ });\n+}\n+\n/**\n* Updates the results table given some test case results.\n* @param {Array} results An array of test case results.\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "let lesson_url = \"{% url 'plugging_it_in:lesson' topic.slug lesson.slug %}\";\nlet csrf_token = '{{ csrf_token }}';\nlet jobe_proxy_url = '{{ jobe_proxy_url }}';\n+ let save_attempt_url = \"{% url 'plugging_it_in:save_attempt' %}\"\n+ let saved_attempts = {{ saved_attempts|safe }}\n</script>\n<script src=\"{% static 'js/jobe-editor.js' %}\"></script>\n" } ]
Python
MIT License
uccser/cs-unplugged
Add code attempt persistance using sessions.
701,848
03.08.2020 21:16:42
-43,200
81e616e41518631368ff7e282c889415b9d68631
Add code attempt status and display in side drawer.
[ { "change_type": "MODIFY", "old_path": "csunplugged/config/settings/base.py", "new_path": "csunplugged/config/settings/base.py", "diff": "@@ -229,6 +229,7 @@ TEMPLATES = [\n\"render_html_field\": \"config.templatetags.render_html_field\",\n\"translate_url\": \"config.templatetags.translate_url\",\n\"query_replace\": \"config.templatetags.query_replace\",\n+ 'custom_tags':'config.templatetags.custom_tags'\n},\n},\n},\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/config/templatetags/custom_tags.py", "diff": "+from django.template.defaulttags import register\n+\n+@register.filter\n+def get_item(dictionary, key):\n+ return dictionary.get(key)\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/plugging_it_in/views.py", "new_path": "csunplugged/plugging_it_in/views.py", "diff": "@@ -193,6 +193,9 @@ class SaveAttemptView(View):\nbody = json.loads(body_unicode)\nrequest.session['saved_attempts'] = request.session.get('saved_attempts', {})\n- request.session['saved_attempts'][body[\"challenge\"]] = body[\"attempt\"]\n+ request.session['saved_attempts'][body[\"challenge\"]] = {\n+ \"status\": body[\"status\"],\n+ \"code\": body[\"attempt\"]\n+ }\nreturn HttpResponse(\"Saved the attempt.\")\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/static/js/editor-options-menu.js", "new_path": "csunplugged/static/js/editor-options-menu.js", "diff": "@@ -11,7 +11,7 @@ function openNav() {\n}\n/**\n- * Closes the challenge naviation drawer.\n+ * Closes the challenge navigation drawer.\n*/\nfunction closeNav() {\ndocument.getElementById(\"my_sidenav\").style.width = \"0\";\n@@ -20,15 +20,11 @@ function closeNav() {\n}\n// Setting up event listener for opening the navigation bar.\n-let lessonsNavToggle = document.getElementById(\"lessons_nav_toggle\");\n-lessonsNavToggle.addEventListener(\"click\", openNav);\n+$(\"#lessons_nav_toggle\").click(openNav);\n// Setting up event listener for closing the navigation drawer.\n-let closeLessonsNav = document.getElementById(\"sidebar_overlay\");\n-closeLessonsNav.addEventListener(\"click\", closeNav);\n-\n-let closeLessonsNavButton = document.getElementById(\"close_nav_button\");\n-closeLessonsNavButton.addEventListener(\"click\", closeNav);\n+$(\"#sidebar_overlay\").click(closeNav);\n+$(\"#close_nav_button\").click(closeNav);\n/**\n* Sets the link to the next challenge if it is not the last challenge.\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "// Scripts used to manage the UI functionality for the programming challenge editor screen.\nconst code_tester = require(\"./test-code.js\");\n+\nvar CodeMirror = require(\"codemirror\");\nrequire(\"codemirror/mode/python/python.js\");\n@@ -27,7 +28,7 @@ let myCodeMirror = CodeMirror.fromTextArea(myTextarea, {\n});\n// Set the editor to show the saved attempt if it exists\n-myCodeMirror.getDoc().setValue(saved_attempts[current_challenge_slug] ? saved_attempts[current_challenge_slug] : \"\");\n+myCodeMirror.getDoc().setValue(saved_attempts[current_challenge_slug] ? saved_attempts[current_challenge_slug][\"code\"] : \"\");\n/**\n* Retrieves code from the code mirror editor, runs all the test cases then updates the results table.\n@@ -41,27 +42,44 @@ function sendCodeToJobe() {\n$(\"#editor_run_button\").prop(\"disabled\", true);\n$(\".code_running_spinner\").css(\"display\", \"inline-block\");\n- // Saved the users code\n- let raw_code = myCodeMirror.getValue();\n- save_code(raw_code)\n-\n// Run the test_cases\ncode_tester.run_all_testcases(code, test_cases).then(result => {\nupdateResultsTable(result);\n+\n+ // Saving the users code\n+ save_code(allCorrect(result) ? \"passed\" : \"failed\")\n+\n$(\"#editor_run_button\").prop(\"disabled\", false);\n$(\".code_running_spinner\").css(\"display\", \"none\");\n});\n}\n+/**\n+ * Returns if the user has passed all test cases.\n+ * @param {Array} results An array of the test case results\n+ * @return {Array} If all the test cases passed returns \"Passed\", otherwise \"Failed\"\n+ */\n+function allCorrect(results) {\n+ for (result of results) {\n+ if (result.status != \"Passed\") {\n+ return false\n+ }\n+ }\n+ return true\n+}\n+\n/**\n* Creates a request to save the users code in a django session.\n- * @param {String} raw_code The users raw code attempt\n+ * @param {String} status If the user has Started, Passed or Failed the challenge.\n*/\n-async function save_code(raw_code) {\n+async function save_code(status=\"started\") {\n+ let raw_code = myCodeMirror.getValue();\n+\n// Sets the saved attempt\nlet data = {\n\"challenge\": current_challenge_slug,\n- \"attempt\": raw_code\n+ \"attempt\": raw_code,\n+ \"status\": status\n}\n// Saves the code in the django session\n@@ -134,9 +152,7 @@ function downloadCode() {\n}\n// Setting up event listener for the check button to run the code.\n-let submitButton = document.getElementById(\"editor_run_button\");\n-submitButton.addEventListener(\"click\", sendCodeToJobe);\n+$(\"#editor_run_button\").click(sendCodeToJobe);\n// Setting up event listener for the download button.\n-let downloadButton = document.getElementById(\"download_button\");\n-downloadButton.addEventListener(\"click\", downloadCode);\n+$(\"#download_button\").click(downloadCode);\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "{% load i18n %}\n{% load static %}\n{% load render_html_field %}\n+{% load custom_tags %}\n{% load django_bootstrap_breadcrumbs %}\n{% block title %}\n{% for programming_challenge_item in programming_challenges %}\n<a href=\"{% url 'plugging_it_in:programming_challenge' topic.slug lesson.slug programming_challenge_item.slug %}\">\n<li class=\"{% if programming_challenge.slug == programming_challenge_item.slug %}current-exercise{% endif %}\">\n- <span class=\"badge badge-primary\">\n+ <span class=\"badge\n+ {% if programming_challenge_item.slug in saved_attempts %}\n+ {% if saved_attempts|get_item:programming_challenge_item.slug|get_item:\"status\" == \"failed\" %}\n+ badge-danger\n+ {% elif saved_attempts|get_item:programming_challenge_item.slug|get_item:\"status\" == \"passed\" %}\n+ badge-success\n+ {% endif %}\n+ {% else %}\n+ badge-secondary\n+ {% endif %}\">\n<h5>{{ programming_challenge_item.challenge_set_number }}.{{ programming_challenge_item.challenge_number }}</h5>\n</span>\n{{ programming_challenge_item.name }}\n" } ]
Python
MIT License
uccser/cs-unplugged
Add code attempt status and display in side drawer.
701,848
03.08.2020 21:52:44
-43,200
e691445ce6cb58c849828fecabc6f2901fbe6d19
Add started code attempt status and saving on next, prev and nav open.
[ { "change_type": "MODIFY", "old_path": "csunplugged/plugging_it_in/views.py", "new_path": "csunplugged/plugging_it_in/views.py", "diff": "@@ -193,9 +193,13 @@ class SaveAttemptView(View):\nbody = json.loads(body_unicode)\nrequest.session['saved_attempts'] = request.session.get('saved_attempts', {})\n+\n+ # To stop a \"passed\" or \"failed\" status being overridden by \"started\"\n+ if not (body[\"status\"] == \"started\" and request.session.get('saved_attempts', {}).get(body[\"challenge\"], \"\") in {'passed', 'failed'}) and body[\"attempt\"] != \"\":\nrequest.session['saved_attempts'][body[\"challenge\"]] = {\n\"status\": body[\"status\"],\n\"code\": body[\"attempt\"]\n}\n-\nreturn HttpResponse(\"Saved the attempt.\")\n+ else:\n+ return HttpResponse(\"Response does not need to be saved.\")\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "@@ -156,3 +156,8 @@ $(\"#editor_run_button\").click(sendCodeToJobe);\n// Setting up event listener for the download button.\n$(\"#download_button\").click(downloadCode);\n+\n+// Save code when the user navigates using the next or prev buttons or opening nav\n+$(\"#prev_challenge_button\").on(\"click\", () => save_code());\n+$(\"#next_challenge_button\").on(\"click\", () => save_code());\n+$(\"#lessons_nav_toggle\").on(\"click\", () => save_code());\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "badge-danger\n{% elif saved_attempts|get_item:programming_challenge_item.slug|get_item:\"status\" == \"passed\" %}\nbadge-success\n+ {% elif saved_attempts|get_item:programming_challenge_item.slug|get_item:\"status\" == \"started\" %}\n+ badge-warning\n{% endif %}\n{% else %}\nbadge-secondary\n" } ]
Python
MIT License
uccser/cs-unplugged
Add started code attempt status and saving on next, prev and nav open.
701,848
05.08.2020 19:12:18
-43,200
d23c1f69080d299ce466df02a91d9078278f4efe
Adding status badges to the nav bar
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/scss/programming-editor.scss", "new_path": "csunplugged/static/scss/programming-editor.scss", "diff": "@@ -351,3 +351,40 @@ body {\noverflow-x: hidden;\ntransition: opacity 0.5s;\n}\n+\n+.nav-row-info {\n+ padding: 0px;\n+ padding-left: 30px;\n+\n+ p {\n+ margin-bottom: 0px;\n+ padding-left: 0px;\n+ }\n+}\n+\n+// Status badges\n+.status-badge {\n+ border: 1px solid #343a40;\n+ color: #343a40;\n+ border-radius: 5px;\n+ font-size: 10px;\n+ padding: 0px 5px !important;\n+ margin: 0px;\n+}\n+\n+.status-badge-correct {\n+ border-color: #279f2d;\n+ background-color: #279f2d;\n+ color: white;\n+}\n+\n+.status-badge-incorrect {\n+ border-color: #cc0423;\n+ background-color: #cc0423;\n+ color: white;\n+}\n+\n+.status-badge-started {\n+ background-color: #ffc107;\n+ border-color: #ffc107;\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "<ol class='challenges-list'>\n{% for programming_challenge_item in programming_challenges %}\n<a href=\"{% url 'plugging_it_in:programming_challenge' topic.slug lesson.slug programming_challenge_item.slug %}\">\n- <li class=\"{% if programming_challenge.slug == programming_challenge_item.slug %}current-exercise{% endif %}\">\n- <span class=\"badge\n+ <li class=\"{% if programming_challenge.slug == programming_challenge_item.slug %}current-exercise{% endif %} row\">\n+ <div class='row'>\n+ <div class='nav-row-info col-10 d-flex'>\n+ <div class=\"d-flex align-items-center\">\n+ <span class=\"badge badge-primary\">\n+ <h5>{{ programming_challenge_item.challenge_set_number }}.{{ programming_challenge_item.challenge_number }}</h5>\n+ </span>\n+ </div>\n+ <p>{{ programming_challenge_item.name }}</p>\n+ </div>\n+\n+ <div class='col-2 d-flex align-items-center justify-content-center'>\n{% if programming_challenge_item.slug in saved_attempts %}\n{% if saved_attempts|get_item:programming_challenge_item.slug|get_item:\"status\" == \"failed\" %}\n- badge-danger\n+ <p class=\"status-badge status-badge-incorrect\">Incorrect</p>\n{% elif saved_attempts|get_item:programming_challenge_item.slug|get_item:\"status\" == \"passed\" %}\n- badge-success\n+ <p class=\"status-badge status-badge-correct\">Correct</p>\n{% elif saved_attempts|get_item:programming_challenge_item.slug|get_item:\"status\" == \"started\" %}\n- badge-warning\n+ <p class=\"status-badge status-badge-started\">Started</p>\n{% endif %}\n{% else %}\n- badge-secondary\n- {% endif %}\">\n- <h5>{{ programming_challenge_item.challenge_set_number }}.{{ programming_challenge_item.challenge_number }}</h5>\n- </span>\n- {{ programming_challenge_item.name }}\n+ <p class=\"status-badge\">Not started</p>\n+ {% endif %}\n+ </div>\n+ </div>\n</li>\n</a>\n{% endfor %}\n" } ]
Python
MIT License
uccser/cs-unplugged
Adding status badges to the nav bar
701,848
05.08.2020 20:21:32
-43,200
9690d52d14cdf21f8b5100122237786fefc29948
Fix attempt not saving when page reloads too fast. Importing editor-options-menu js into the jobe editor file
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/editor-options-menu.js", "new_path": "csunplugged/static/js/editor-options-menu.js", "diff": "@@ -19,35 +19,40 @@ function closeNav() {\ndocument.getElementById(\"sidebar_overlay\").style.opacity = \"0\";\n}\n-// Setting up event listener for opening the navigation bar.\n-$(\"#lessons_nav_toggle\").click(openNav);\n-\n-// Setting up event listener for closing the navigation drawer.\n-$(\"#sidebar_overlay\").click(closeNav);\n-$(\"#close_nav_button\").click(closeNav);\n+/**\n+ * Gets the index of the current challenge.\n+ */\n+function getCurrentIndex() {\n+ const isCurrentChallengeIndex = (element) => element.slug == current_challenge_slug;\n+ return programming_exercises.findIndex(isCurrentChallengeIndex);\n+}\n/**\n- * Sets the link to the next challenge if it is not the last challenge.\n- * @param {Number} index The index of the current challenge\n+ * Gets the link to the next challenge if it is not the last challenge.\n*/\n-function setNextChallenge(index) {\n+function getNextChallengeURL() {\n+ const index = getCurrentIndex();\n+\nif (index !== programming_exercises.length-1) {\nconst nextLesson = programming_exercises[index+1];\n- const nextLessonUrl = lesson_url + nextLesson.slug;\n- $(\"#next_challenge_button\").attr(\"href\", nextLessonUrl);\n+ return nextLessonUrl = lesson_url + nextLesson.slug;\n}\n+\n+ return '#'\n}\n/**\n* Sets the link to the previous challenge if it is not the first challenge.\n- * @param {Number} index The index of the current challenge\n*/\n-function setPreviousChallenge(index) {\n+function getPreviousChallengeURL() {\n+ const index = getCurrentIndex()\n+\nif (index !== 0) {\nconst prevLesson = programming_exercises[index-1];\n- const prevLessonUrl = lesson_url + prevLesson.slug;\n- $(\"#prev_challenge_button\").attr(\"href\", prevLessonUrl);\n+ return prevLessonUrl = lesson_url + prevLesson.slug;\n}\n+\n+ return \"#\"\n}\n/**\n@@ -55,18 +60,22 @@ function setPreviousChallenge(index) {\n* Also sets the text to show lesson progression.\n*/\nfunction setupLessonNav() {\n- const isCurrentChallengeIndex = (element) => element.slug == current_challenge_slug;\n- currentChallengeIndex = programming_exercises.findIndex(isCurrentChallengeIndex);\n+ // Setting up event listener for opening the navigation bar.\n+ $(\"#lessons_nav_toggle\").click(openNav);\n- const progressionText = `Question <strong>${currentChallengeIndex+1}</strong> of <strong>${programming_exercises.length}</strong>`;\n- document.getElementById(\"challenge_progression_text\").innerHTML = progressionText;\n- setPreviousChallenge(currentChallengeIndex)\n- setNextChallenge(currentChallengeIndex)\n-}\n+ // Setting up event listener for closing the navigation drawer.\n+ $(\"#sidebar_overlay\").click(closeNav);\n+ $(\"#close_nav_button\").click(closeNav);\n-// Apply the navigation setup\n-setupLessonNav()\n+ // Sets the question progression text.\n+ const progressionText = `Question <strong>${getCurrentIndex()+1}</strong> of <strong>${programming_exercises.length}</strong>`;\n+ document.getElementById(\"challenge_progression_text\").innerHTML = progressionText;\n// Add testing examples info to the requirements block (temporary)\nconst static_requirement_info = \"Your program should display the outputs in the table (shown on the right) for the given inputs provided.\";\n$(\"#requirement + p\").append(`</br></br> <p>${static_requirement_info}</p>`);\n+}\n+\n+exports.setupLessonNav = setupLessonNav;\n+exports.getPreviousChallengeURL = getPreviousChallengeURL;\n+exports.getNextChallengeURL = getNextChallengeURL;\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "// Scripts used to manage the UI functionality for the programming challenge editor screen.\n-const code_tester = require(\"./test-code.js\");\n+const codeTester = require(\"./test-code.js\");\n+const editorUtils = require(\"./editor-options-menu.js\")\nvar CodeMirror = require(\"codemirror\");\nrequire(\"codemirror/mode/python/python.js\");\n@@ -43,7 +44,7 @@ function sendCodeToJobe() {\n$(\".code_running_spinner\").css(\"display\", \"inline-block\");\n// Run the test_cases\n- code_tester.run_all_testcases(code, test_cases).then(result => {\n+ codeTester.run_all_testcases(code, test_cases).then(result => {\nupdateResultsTable(result);\n// Saving the users code\n@@ -83,7 +84,7 @@ async function save_code(status=\"started\") {\n}\n// Saves the code in the django session\n- fetch(save_attempt_url, {\n+ let response = await fetch(save_attempt_url, {\nmethod: \"POST\",\nheaders: {\n\"Content-type\": \"application/json; charset=utf-8\",\n@@ -92,6 +93,8 @@ async function save_code(status=\"started\") {\n},\nbody: JSON.stringify(data)\n});\n+\n+ return response;\n}\n/**\n@@ -157,7 +160,11 @@ $(\"#editor_run_button\").click(sendCodeToJobe);\n// Setting up event listener for the download button.\n$(\"#download_button\").click(downloadCode);\n+// Apply the navigation setup\n+editorUtils.setupLessonNav()\n+\n// Save code when the user navigates using the next or prev buttons or opening nav\n-$(\"#prev_challenge_button\").on(\"click\", () => save_code());\n-$(\"#next_challenge_button\").on(\"click\", () => save_code());\n+// Manually navigating to the next page to ensure code is saved first before the page reloads.\n+$(\"#prev_challenge_button\").on(\"click\", () => save_code().then(() => window.location.href = editorUtils.getPreviousChallengeURL()));\n+$(\"#next_challenge_button\").on(\"click\", () => save_code().then(() => window.location.href = editorUtils.getNextChallengeURL()));\n$(\"#lessons_nav_toggle\").on(\"click\", () => save_code());\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "</script>\n<script src=\"{% static 'js/jobe-editor.js' %}\"></script>\n- <script src=\"{% static 'js/editor-options-menu.js' %}\"></script>\n{% endblock scripts %}\n" } ]
Python
MIT License
uccser/cs-unplugged
Fix attempt not saving when page reloads too fast. - Importing editor-options-menu js into the jobe editor file
701,848
06.08.2020 12:37:25
-43,200
c731a47e578073af1c54304f8b5ab8fab2ea3641
Fix style check issues
[ { "change_type": "MODIFY", "old_path": "csunplugged/config/templatetags/custom_tags.py", "new_path": "csunplugged/config/templatetags/custom_tags.py", "diff": "+\"\"\"Module for the custom dictionary look up template tag.\"\"\"\n+\nfrom django.template.defaulttags import register\n+\n@register.filter\ndef get_item(dictionary, key):\n+ \"\"\"Return the value in a dictionary given a key.\"\"\"\nreturn dictionary.get(key)\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/plugging_it_in/views.py", "new_path": "csunplugged/plugging_it_in/views.py", "diff": "@@ -195,7 +195,9 @@ class SaveAttemptView(View):\nrequest.session['saved_attempts'] = request.session.get('saved_attempts', {})\n# To stop a \"passed\" or \"failed\" status being overridden by \"started\"\n- if not (body[\"status\"] == \"started\" and request.session.get('saved_attempts', {}).get(body[\"challenge\"], \"\") in {'passed', 'failed'}) and body[\"attempt\"] != \"\":\n+ if (not (body[\"status\"] == \"started\"\n+ and request.session.get('saved_attempts', {}).get(body[\"challenge\"], \"\") in {'passed', 'failed'})\n+ and body[\"attempt\"] != \"\"):\nrequest.session['saved_attempts'][body[\"challenge\"]] = {\n\"status\": body[\"status\"],\n\"code\": body[\"attempt\"]\n" } ]
Python
MIT License
uccser/cs-unplugged
Fix style check issues
701,848
06.08.2020 16:58:02
-43,200
34ee3cae5b441012436a557c5cbcb5a48dce1b57
Enable Scratch tab and add a warning message for users.
[ { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/lesson.html", "new_path": "csunplugged/templates/plugging_it_in/lesson.html", "diff": "<nav>\n<div class=\"nav nav-tabs mt-2\" id=\"nav-tab\" role=\"tablist\">\n{% for language in lesson.challenge_languages %}\n- <a class=\"nav-item nav-link {% if forloop.first %}active{% endif %}{% if language.name == \"Scratch\" %}disabled{% endif %}\" id=\"{{language.name}}\" data-toggle=\"tab\" href=\"#nav-{{language.name}}\" role=\"tab\" aria-controls=\"{{language.name}}\" aria-selected=\"false\">\n+ <a class=\"nav-item nav-link {% if forloop.first %}active{% endif %}\" id=\"{{language.name}}\" data-toggle=\"tab\" href=\"#nav-{{language.name}}\" role=\"tab\" aria-controls=\"{{language.name}}\" aria-selected=\"false\">\n{{language.name}}\n<img src=\"{% get_static_prefix %}{{ language.icon }}\" class=\"inline-image-small pl-1\" />\n</a>\n<div class=\"tab-content\" id=\"nav-tabContent\">\n{% for language in lesson.challenge_languages %}\n<div class=\"tab-pane fade {% if forloop.first %}show active{% endif %}\" id=\"nav-{{language.name}}\" role=\"tabpanel\" aria-labelledby=\"{{language.name}}\">\n+ {% if language.name == \"Scratch\" %}\n+ <div class=\"alert alert-danger my-3\" role=\"alert\">\n+ Scratch challenges have not updated to our new plugging it in system. However, you can still access the old content using the links below.\n+ </div>\n+ {% endif %}\n{% include \"plugging_it_in/programming-challenges-table.html\" with language=language.name %}\n</div>\n{% endfor %}\n" } ]
Python
MIT License
uccser/cs-unplugged
Enable Scratch tab and add a warning message for users.
701,848
06.08.2020 17:24:58
-43,200
0e5ab9af3b7a456f79826c430bd4e9f054430206
Update Kidbots Q6.1 so test cases are consistent with the solution.
[ { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/kidbots/programming-challenges/modulo-add-video-timings/modulo-add-video-timings.md", "new_path": "csunplugged/topics/content/en/kidbots/programming-challenges/modulo-add-video-timings/modulo-add-video-timings.md", "diff": "Remix the program provided at [https://scratch.mit.edu/projects/165770195/](https://scratch.mit.edu/projects/165770195/).\nWrite a program that takes the durations of two video clips as the input (asks the user to enter the number of hours, minutes and seconds) and displays the total duration as the output.\n-For example, for planning the length of clips in a film or songs in a playlist we might need to add the length of the first clip which is 32 minutes, 21 seconds (0:32:21) to the length of another clip which is 33 minutes and 20 seconds.\n+For example, for planning the length of clips in a film or songs in a playlist we might need to add the length of the first clip which is 32 minutes, 21 seconds (0:32:21) to the length of another clip which is 33 minutes and 20 seconds. Each time input (hours, minutes and seconds) are entered each on a different line.\nThe output of your program should be 1 hour, 5 minutes and 41 seconds.\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/kidbots/programming-challenges/modulo-add-video-timings/test-cases/test-case-1-input.txt", "new_path": "csunplugged/topics/content/en/kidbots/programming-challenges/modulo-add-video-timings/test-cases/test-case-1-input.txt", "diff": "-0:32:21\n-0:33:20\n\\ No newline at end of file\n+0\n+32\n+21\n+0\n+33\n+20\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/kidbots/programming-challenges/modulo-add-video-timings/test-cases/test-case-1-output.txt", "new_path": "csunplugged/topics/content/en/kidbots/programming-challenges/modulo-add-video-timings/test-cases/test-case-1-output.txt", "diff": "-1:5:41\n\\ No newline at end of file\n+Total time: 1 hours, 5 minutes, and 41 seconds\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/kidbots/programming-challenges/modulo-add-video-timings/test-cases/test-case-2-input.txt", "new_path": "csunplugged/topics/content/en/kidbots/programming-challenges/modulo-add-video-timings/test-cases/test-case-2-input.txt", "diff": "-3:59:59\n-2:13:3\n\\ No newline at end of file\n+3\n+59\n+59\n+2\n+13\n+3\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/kidbots/programming-challenges/modulo-add-video-timings/test-cases/test-case-2-output.txt", "new_path": "csunplugged/topics/content/en/kidbots/programming-challenges/modulo-add-video-timings/test-cases/test-case-2-output.txt", "diff": "-6:13:2\n\\ No newline at end of file\n+Total time: 6 hours, 13 minutes, and 2 seconds\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/kidbots/programming-challenges/modulo-add-video-timings/test-cases/test-case-3-input.txt", "new_path": "csunplugged/topics/content/en/kidbots/programming-challenges/modulo-add-video-timings/test-cases/test-case-3-input.txt", "diff": "-4:59:59\n-2:59:59\n\\ No newline at end of file\n+4\n+59\n+59\n+2\n+59\n+59\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/kidbots/programming-challenges/modulo-add-video-timings/test-cases/test-case-3-output.txt", "new_path": "csunplugged/topics/content/en/kidbots/programming-challenges/modulo-add-video-timings/test-cases/test-case-3-output.txt", "diff": "-7:59:58\n\\ No newline at end of file\n+Total time: 7 hours, 59 minutes, and 58 seconds\n\\ No newline at end of file\n" } ]
Python
MIT License
uccser/cs-unplugged
Update Kidbots Q6.1 so test cases are consistent with the solution.
701,848
06.08.2020 18:16:36
-43,200
370ed9da015a04d00bd7776eef22ec236ba5690b
Update responsiveness for the bottom options bar.
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/scss/programming-editor.scss", "new_path": "csunplugged/static/scss/programming-editor.scss", "diff": "@@ -28,7 +28,6 @@ body {\n}\n.programming__options {\n- height: 70px;\nbackground-color: $student-colour;\ncolor: white;\nmargin-left: 0px;\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "{% endif %}\n</div>\n-<div class=\"col-12 row programming__options d-flex justify-content-center align-items-center\">\n- <div class=\"col-12 progression-options d-flex justify-content-between align-items-center\">\n+<div class=\"col-12 programming__options\">\n+ <div class=\"row progression-options\">\n+ <div class=\"col-sm-4 col-6 order-2 order-sm-1 d-flex align-items-center my-1\">\n<a id='prev_challenge_button'>\n<button class=\"btn prev\">Previous Challenge</button>\n</a>\n- <div class=\"progression-info\">\n+ </div>\n+ <div class=\"progression-info col-sm-4 col-12 order-1 order-sm-2 my-2\">\n<p id=\"challenge_progression_text\"></p>\n<p id=\"lessons_nav_toggle\">(Click here to select a challenge)</p>\n</div>\n+ <div class=\"col-sm-4 col-6 order-3 order-sm-3 d-flex justify-content-end align-items-center my-1\">\n<a id='next_challenge_button'>\n<button class=\"btn next\">Next Challenge</button>\n</a>\n</div>\n</div>\n+</div>\n{% endblock body_container %}\n" } ]
Python
MIT License
uccser/cs-unplugged
Update responsiveness for the bottom options bar.
701,848
06.08.2020 23:05:09
-43,200
af7c7696de981057866402f79bd27441f9d73bd5
Adding help pop ups for test case output status.
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "@@ -52,20 +52,25 @@ function sendCodeToJobe() {\nfunction updateResultsTable(results) {\nfor (result of results) {\n// Update status cell\n- let status_element = $(\"#test-case-\" + result.id + \"-status\");\n- status_element.text(result.status);\n+ $(`#test-case-${result.id}-status`).text(result.status);\n+\n+ // Update help modal\n+ $(`#test-case-${result.id}-help-title`).text(result.status)\n+ $(`#test-case-${result.id}-help`).text(result.helpInfo);\n+ $(`#test-case-${result.id}-help-icon`).show()\n// Update output cell\n- var output_element = $(\"#test-case-\" + result.id + \"-output\");\n- output_element.text(result.userOutput);\n+ $(`#test-case-${result.id}-output`).text(result.userOutput);\n// Update row colors\n- var row_element = $(\"#test-case-\" + result.id + \"-row\");\n+ var row_element = $(`#test-case-${result.id}-row`);\nif (result.status == \"Passed\") {\nrow_element.addClass(\"table-success\");\nrow_element.removeClass(\"table-danger\");\nrow_element.removeClass(\"table-warning\");\n- } else if (result.status == \"Compiler Error\") {\n+ $(`#test-case-${result.id}-help-icon`).hide()\n+\n+ } else if (result.status == \"Syntax Error\") {\nrow_element.addClass(\"table-warning\");\nrow_element.removeClass(\"table-danger\");\nrow_element.removeClass(\"table-success\");\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/static/scss/programming-editor.scss", "new_path": "csunplugged/static/scss/programming-editor.scss", "diff": "@@ -226,6 +226,15 @@ body {\nflex-shrink: 1;\noverflow-y: auto;\n}\n+\n+ .help-icon {\n+ height: 16px;\n+ width: 16px;\n+ color: white;\n+ background-color: #212529;\n+ border-radius: 8px;\n+ font-weight: bold;\n+ }\n}\n// For small devices\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/results-table.html", "new_path": "csunplugged/templates/plugging_it_in/results-table.html", "diff": "<td>\n<pre class=\"mb-0 test-case-output\" id=\"test-case-{{ test_case.id }}-output\"></pre>\n</td>\n- <td id=\"test-case-{{ test_case.id }}-status\">\n- <span class=\"text-muted\">\n+ <td>\n+ <span id=\"test-case-{{ test_case.id }}-status\">\nNot yet run\n</span>\n+ <a href=\"#\" id=\"test-case-{{ test_case.id }}-help-icon\" class=\"badge help-icon\" data-toggle=\"modal\" data-target=\"#modal-{{ test_case.id }}\" style=\"display:none\">\n+ ?\n+ </a>\n</td>\n</tr>\n+\n+ <!-- Modal -->\n+ <div class=\"modal fade\" id=\"modal-{{ test_case.id }}\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"exampleModalLabel\" aria-hidden=\"true\">\n+ <div class=\"modal-dialog\" role=\"document\">\n+ <div class=\"modal-content\">\n+ <div class=\"modal-header\">\n+ <h4 class=\"modal-title\" id=\"test-case-{{ test_case.id }}-help-title\"></h4>\n+ <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\">\n+ <span aria-hidden=\"true\">&times;</span>\n+ </button>\n+ </div>\n+ <div id=\"test-case-{{ test_case.id }}-help\" class=\"modal-body\"></div>\n+ </div>\n+ </div>\n+ </div>\n{% endfor %}\n</tbody>\n</table>\n" } ]
Python
MIT License
uccser/cs-unplugged
Adding help pop ups for test case output status.
701,848
06.08.2020 23:53:00
-43,200
e7fa732c6d4645e7387ef402ad430df677853a8c
Add static programming syntax hints Add highlight.js import for code highlighting
[ { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "<strong>{% trans \"Programming Reminders\" %}</strong>\n</summary>\n<div class=\"boxed-text-content\">\n- <p>[Some static content here]</p>\n+ {% include \"plugging_it_in/static-syntax-hints.html\" %}\n</div>\n</details>\n<script src=\"{% static 'js/jobe-editor.js' %}\"></script>\n<script src=\"{% static 'js/editor-options-menu.js' %}\"></script>\n+\n+ {% comment %} Add in highlight.js for code highlighting {% endcomment %}\n+ <link rel=\"stylesheet\" href=\"//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.2/styles/xcode.min.css\">\n+ <script src=\"//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.2/highlight.min.js\"></script>\n+ <script>hljs.initHighlightingOnLoad();</script>\n{% endblock scripts %}\n" } ]
Python
MIT License
uccser/cs-unplugged
Add static programming syntax hints - Add highlight.js import for code highlighting
701,848
25.07.2020 14:01:05
-43,200
a8609d1f1e74f31a06fa430dbe0762aa1de0b25b
Add collapsible learning outcomes to the topics programming challenges table.
[ { "change_type": "MODIFY", "old_path": "csunplugged/templates/topics/programming-challenges-table.html", "new_path": "csunplugged/templates/topics/programming-challenges-table.html", "diff": "</thead>\n<tbody>\n{% for programming_challenge in programming_challenges %}\n- <tr class=\"align-middle{% if not programming_challenge.translation_available %} table-active{% endif %}\">\n+ <tr class=\"align-middle{% if not programming_challenge.translation_available %} table-active{% endif %} clickable\" data-toggle=\"collapse\" data-target=\"#accordion-{{ programming_challenge.challenge_set_number }}{{ programming_challenge.challenge_number }}\">\n<td class=\"text-center\">\n{{ programming_challenge.challenge_set_number }}.{{ programming_challenge.challenge_number }}\n</td>\n{% endfor %}\n</td>\n</tr>\n+ <tr>\n+ <td class=\"p-0\"></td>\n+ <td colspan=\"3\" class=\"p-0\">\n+ <div id=\"accordion-{{ programming_challenge.challenge_set_number }}{{ programming_challenge.challenge_number }}\" style=\"padding: 0.75rem\" class=\"collapse\">\n+ {% if programming_challenge.get_learning_outcomes %}\n+ <strong>{% trans \"Learning outcomes\" %}</strong>\n+ <div class=\"boxed-text-content\">\n+ <p>{% trans \"Students will be able to:\" %}</p>\n+ <ul>\n+ {% for learning_outcome in programming_challenge.get_learning_outcomes %}\n+ <li>\n+ {{ learning_outcome.text }}<br>\n+ {% for area in learning_outcome.curriculum_areas.all %}\n+ {% include \"topics/curriculum-area-badge.html\" %}\n+ {% endfor %}\n+ </li>\n+ {% endfor %}\n+ </ul>\n+ </div>\n+ {% endif %}\n+ </div>\n+ </td>\n+ </tr>\n{% endfor %}\n</tbody>\n</table>\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/models.py", "new_path": "csunplugged/topics/models.py", "diff": "@@ -230,6 +230,9 @@ class ProgrammingChallenge(TranslatableModel):\n}\nreturn reverse(\"topics:programming_challenge\", kwargs=kwargs)\n+ def get_learning_outcomes(self):\n+ return self.learning_outcomes(manager=\"translated_objects\").order_by(\"text\")\n+\ndef ordered_implementations(self):\n\"\"\"Return an ordered QuerySet of implementations.\n" } ]
Python
MIT License
uccser/cs-unplugged
Add collapsible learning outcomes to the topics programming challenges table.
701,848
25.07.2020 15:29:06
-43,200
8607e371ac7ab52a9ee5321adda436a35609b2dc
Add solution links to the programming challenges table collapsible area.
[ { "change_type": "MODIFY", "old_path": "csunplugged/templates/topics/programming-challenges-table.html", "new_path": "csunplugged/templates/topics/programming-challenges-table.html", "diff": "</ul>\n</div>\n{% endif %}\n+\n+ {% if programming_challenge.ordered_implementations %}\n+ <strong>{% trans \"Challenge Solutions\" %}</strong>\n+ {% endif %}\n+ {% for implementation in programming_challenge.ordered_implementations %}\n+ </br>\n+ <a href=\"{% url 'topics:programming_challenge_solution' topic.slug programming_challenge.slug implementation.language.slug %}\">\n+ Show {{ implementation.language.name }} solution\n+ </a>\n+ {% endfor %}\n</div>\n</td>\n</tr>\n" } ]
Python
MIT License
uccser/cs-unplugged
Add solution links to the programming challenges table collapsible area.
701,848
25.07.2020 15:58:21
-43,200
5f29bbb2a00b45d86732fa89fe75f904cc7127f1
Adding docstring to the get_learning_outcomes method.
[ { "change_type": "MODIFY", "old_path": "csunplugged/topics/models.py", "new_path": "csunplugged/topics/models.py", "diff": "@@ -231,6 +231,11 @@ class ProgrammingChallenge(TranslatableModel):\nreturn reverse(\"topics:programming_challenge\", kwargs=kwargs)\ndef get_learning_outcomes(self):\n+ \"\"\"Return an ordered QuerySet of translated learning outcomes.\n+\n+ Returns:\n+ Ordered QuerySet.\n+ \"\"\"\nreturn self.learning_outcomes(manager=\"translated_objects\").order_by(\"text\")\ndef ordered_implementations(self):\n" } ]
Python
MIT License
uccser/cs-unplugged
Adding docstring to the get_learning_outcomes method.
701,848
04.08.2020 20:01:49
-43,200
751c1e009f84dbe3caeb290560107e137ea65a6c
Adjustments to the collapsable areas for the programming table Added a badge/button to toggle collapsable content Added a checkbox toggle showing/hiding all expandable content.
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/scss/website.scss", "new_path": "csunplugged/static/scss/website.scss", "diff": "@@ -844,3 +844,12 @@ button:hover .icon-search {\nmax-height: 60vh;\nobject-fit: contain;\n}\n+.badge-outline {\n+ color: #3366ff;\n+ background-color: transparent;\n+ border: 1px solid #3366ff;\n+}\n+.badge-outline:hover {\n+ color: white;\n+ background-color: #3366ff;\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/topics/programming-challenge-lesson-list.html", "new_path": "csunplugged/templates/topics/programming-challenge-lesson-list.html", "diff": "{% endif %}\n{% if programming_challenges %}\n+ <div class=\"custom-control custom-checkbox py-3\">\n+ <input type=\"checkbox\" class=\"custom-control-input\" id=\"show-all-checkbox\">\n+ <label class=\"custom-control-label\" for=\"show-all-checkbox\">Check to show all detailed content</label>\n+ </div>\n{% include \"topics/programming-challenges-table.html\" %}\n{% else %}\n<p>{% blocktrans trimmed %}No programming challenges for {{ topic }}.{% endblocktrans %}</p>\n{% endif %}\n{% endblock content %}\n+\n+{% block scripts %}\n+ <script type=\"text/javascript\">\n+ // This ensures all are closed and all are opened, otherwise wierd toggling behavior occurs.\n+ $(\"#show-all-checkbox\").change(function() {\n+ if (this.checked) {\n+ $('.acc-programming-challenge').collapse('show')\n+ } else {\n+ $('.acc-programming-challenge').collapse('hide')\n+ }\n+ });\n+ </script>\n+{% endblock scripts %}\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/topics/programming-challenges-table.html", "new_path": "csunplugged/templates/topics/programming-challenges-table.html", "diff": "</thead>\n<tbody>\n{% for programming_challenge in programming_challenges %}\n- <tr class=\"align-middle{% if not programming_challenge.translation_available %} table-active{% endif %} clickable\" data-toggle=\"collapse\" data-target=\"#accordion-{{ programming_challenge.challenge_set_number }}{{ programming_challenge.challenge_number }}\">\n+ <tr class=\"align-middle{% if not programming_challenge.translation_available %} table-active{% endif %}\">\n<td class=\"text-center\">\n+ <strong style=\"font-size: 20px\">\n{{ programming_challenge.challenge_set_number }}.{{ programming_challenge.challenge_number }}\n+ </strong>\n</td>\n<td>\n{% if not programming_challenge.translation_available %}\n{{ programming_challenge.name }}\n</strong>\n</a>\n+ <br>\n+ <a href=\"#\" class=\"badge badge-outline\" data-toggle=\"collapse\" data-target=\"#accordion-{{ programming_challenge.challenge_set_number }}{{ programming_challenge.challenge_number }}\">\n+ Show more details\n+ </a>\n</td>\n<td class=\"text-center\">\n{% include \"topics/programming-difficulty-badge.html\" %}\n<tr>\n<td class=\"p-0\"></td>\n<td colspan=\"3\" class=\"p-0\">\n- <div id=\"accordion-{{ programming_challenge.challenge_set_number }}{{ programming_challenge.challenge_number }}\" style=\"padding: 0.75rem\" class=\"collapse\">\n+ <div id=\"accordion-{{ programming_challenge.challenge_set_number }}{{ programming_challenge.challenge_number }}\" style=\"padding: 0.75rem\" class=\"collapse acc-programming-challenge\">\n{% if programming_challenge.get_learning_outcomes %}\n<strong>{% trans \"Learning outcomes\" %}</strong>\n<div class=\"boxed-text-content\">\n" } ]
Python
MIT License
uccser/cs-unplugged
Adjustments to the collapsable areas for the programming table - Added a badge/button to toggle collapsable content - Added a checkbox toggle showing/hiding all expandable content.
701,848
07.08.2020 16:01:13
-43,200
cc5d39ca60e33c6db4974671a965b1f7c15eaacb
Fix error server error when saving an attempt when opening the nav.
[ { "change_type": "MODIFY", "old_path": "csunplugged/plugging_it_in/views.py", "new_path": "csunplugged/plugging_it_in/views.py", "diff": "@@ -196,7 +196,7 @@ class SaveAttemptView(View):\n# To stop a \"passed\" or \"failed\" status being overridden by \"started\"\nif (not (body[\"status\"] == \"started\"\n- and request.session.get('saved_attempts', {}).get(body[\"challenge\"], \"\") in {'passed', 'failed'})\n+ and request.session.get('saved_attempts', {}).get(body[\"challenge\"], {}).get(\"status\", \"\") in {'passed', 'failed'})\nand body[\"attempt\"] != \"\"):\nrequest.session['saved_attempts'][body[\"challenge\"]] = {\n\"status\": body[\"status\"],\n" } ]
Python
MIT License
uccser/cs-unplugged
Fix error server error when saving an attempt when opening the nav.
701,848
07.08.2020 16:16:05
-43,200
fb5800067b8edd57ee38ff44430bae221f04565e
Add translations for challenge status
[ { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "<div class='col-2 d-flex align-items-center justify-content-center'>\n{% if programming_challenge_item.slug in saved_attempts %}\n{% if saved_attempts|get_item:programming_challenge_item.slug|get_item:\"status\" == \"failed\" %}\n- <p class=\"status-badge status-badge-incorrect\">Incorrect</p>\n+ <p class=\"status-badge bg-danger border-danger text-white\">{% trans \"Incorrect\" %}</p>\n{% elif saved_attempts|get_item:programming_challenge_item.slug|get_item:\"status\" == \"passed\" %}\n- <p class=\"status-badge status-badge-correct\">Correct</p>\n+ <p class=\"status-badge bg-success border-success text-white\">{% trans \"Correct\" %}</p>\n{% elif saved_attempts|get_item:programming_challenge_item.slug|get_item:\"status\" == \"started\" %}\n- <p class=\"status-badge status-badge-started\">Started</p>\n+ <p class=\"status-badge border-warning bg-warning\">{% trans \"Started\" %}</p>\n{% endif %}\n{% else %}\n- <p class=\"status-badge\">Not started</p>\n+ <p class=\"status-badge\">{% trans \"Not started\" %}</p>\n{% endif %}\n</div>\n</div>\n" } ]
Python
MIT License
uccser/cs-unplugged
Add translations for challenge status
701,848
07.08.2020 16:17:26
-43,200
a4cd00bce666e84a018357c8ed1a4066e1621bdc
Hide next/prev buttons if no challenge available
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/editor-options-menu.js", "new_path": "csunplugged/static/js/editor-options-menu.js", "diff": "@@ -74,6 +74,14 @@ function setupLessonNav() {\n// Add testing examples info to the requirements block (temporary)\nconst static_requirement_info = \"Your program should display the outputs in the table (shown on the right) for the given inputs provided.\";\n$(\"#requirement + p\").append(`</br></br> <p>${static_requirement_info}</p>`);\n+\n+ // Hides the next/prev challenge buttons if there is no challenge available in that direction.\n+ const index = getCurrentIndex();\n+ if (index === programming_exercises.length-1) {\n+ $(\"#next_challenge_button\").find('button').hide()\n+ } else if (index === 0) {\n+ $(\"#prev_challenge_button\").find('button').hide()\n+ }\n}\nexports.setupLessonNav = setupLessonNav;\n" } ]
Python
MIT License
uccser/cs-unplugged
Hide next/prev buttons if no challenge available
701,848
07.08.2020 16:44:00
-43,200
9c661c51b8f7e85dc1e9506bcee169b0bf4ec06f
Review fixes Updating translations Updating text when content is open Full width table New challenges-list css file
[ { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/static/scss/challenges-list.scss", "diff": "+.educators-programming-challenge-number {\n+ font-size: 1.2rem;\n+}\n+ .acc-programming-challenge {\n+ padding: 0.75rem;\n+}\n+.badge-outline {\n+ color: #3366ff;\n+ background-color: transparent;\n+ border: 1px solid #3366ff;\n+}\n+.badge-outline:hover {\n+ color: white;\n+ background-color: #3366ff;\n+ cursor: pointer;\n+}\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/static/scss/website.scss", "new_path": "csunplugged/static/scss/website.scss", "diff": "@@ -844,12 +844,3 @@ button:hover .icon-search {\nmax-height: 60vh;\nobject-fit: contain;\n}\n-.badge-outline {\n- color: #3366ff;\n- background-color: transparent;\n- border: 1px solid #3366ff;\n-}\n-.badge-outline:hover {\n- color: white;\n- background-color: #3366ff;\n-}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/topics/programming-challenge-lesson-list.html", "new_path": "csunplugged/templates/topics/programming-challenge-lesson-list.html", "diff": "{% if programming_challenges %}\n<div class=\"custom-control custom-checkbox py-3\">\n<input type=\"checkbox\" class=\"custom-control-input\" id=\"show-all-checkbox\">\n- <label class=\"custom-control-label\" for=\"show-all-checkbox\">Check to show all detailed content</label>\n+ <label class=\"custom-control-label\" for=\"show-all-checkbox\">{% trans \"Check to show all detailed content\" %}</label>\n</div>\n{% include \"topics/programming-challenges-table.html\" %}\n{% else %}\n$(\"#show-all-checkbox\").change(function() {\nif (this.checked) {\n$('.acc-programming-challenge').collapse('show')\n+ $(\".toggle-content\").text('Show less details');\n} else {\n$('.acc-programming-challenge').collapse('hide')\n+ $(\".toggle-content\").text('Show more details');\n}\n});\n</script>\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/topics/programming-challenges-table.html", "new_path": "csunplugged/templates/topics/programming-challenges-table.html", "diff": "{% load i18n %}\n-<table class=\"table table-responsive table-center-vertical\">\n+<div class=\"table-responsive\" >\n+ <table class=\"table table-center-vertical\">\n<thead class=\"thead-default\">\n<tr>\n<th class=\"text-center\">{% trans \"Number\" %}</th>\n{% for programming_challenge in programming_challenges %}\n<tr class=\"align-middle{% if not programming_challenge.translation_available %} table-active{% endif %}\">\n<td class=\"text-center\">\n- <strong style=\"font-size: 20px\">\n+ <strong class=\"educators-programming-challenge-number\">\n{{ programming_challenge.challenge_set_number }}.{{ programming_challenge.challenge_number }}\n</strong>\n</td>\n</strong>\n</a>\n<br>\n- <a href=\"#\" class=\"badge badge-outline\" data-toggle=\"collapse\" data-target=\"#accordion-{{ programming_challenge.challenge_set_number }}{{ programming_challenge.challenge_number }}\">\n- Show more details\n- </a>\n+ <span id=\"toggle-{{ programming_challenge.challenge_set_number }}{{ programming_challenge.challenge_number }}\" onclick=\"updateToggleButtonText({{ programming_challenge.challenge_set_number }}{{ programming_challenge.challenge_number }})\" class=\"badge badge-outline toggle-content collapsed\" data-toggle=\"collapse\" data-target=\"#accordion-{{ programming_challenge.challenge_set_number }}{{ programming_challenge.challenge_number }}\">\n+ {% trans \"Show more details\" %}\n+ </span>\n</td>\n<td class=\"text-center\">\n{% include \"topics/programming-difficulty-badge.html\" %}\n<tr>\n<td class=\"p-0\"></td>\n<td colspan=\"3\" class=\"p-0\">\n- <div id=\"accordion-{{ programming_challenge.challenge_set_number }}{{ programming_challenge.challenge_number }}\" style=\"padding: 0.75rem\" class=\"collapse acc-programming-challenge\">\n+ <div id=\"accordion-{{ programming_challenge.challenge_set_number }}{{ programming_challenge.challenge_number }}\" class=\"collapse acc-programming-challenge\">\n{% if programming_challenge.get_learning_outcomes %}\n<strong>{% trans \"Learning outcomes\" %}</strong>\n<div class=\"boxed-text-content\">\n{% for implementation in programming_challenge.ordered_implementations %}\n</br>\n<a href=\"{% url 'topics:programming_challenge_solution' topic.slug programming_challenge.slug implementation.language.slug %}\">\n- Show {{ implementation.language.name }} solution\n+ {% blocktrans with name=implementation.language.name %}Show {{ name }} solution{% endblocktrans %}\n</a>\n{% endfor %}\n</div>\n{% endfor %}\n</tbody>\n</table>\n+</div>\n+\n+{% block scripts %}\n+ <link rel=\"stylesheet\" href=\"{% static 'css/challenges-list.css' %}\" >\n+ <script type=\"text/javascript\">\n+ function updateToggleButtonText(challenge_num) {\n+ challengeContentToggleId = `#toggle-${challenge_num}`;\n+ if ($(challengeContentToggleId).hasClass('collapsed')) {\n+ $(challengeContentToggleId).text('Show less details');\n+ } else {\n+ $(challengeContentToggleId).text('Show more details');\n+ }\n+ }\n+ </script>\n+{% endblock scripts %}\n+\n" } ]
Python
MIT License
uccser/cs-unplugged
Review fixes - Updating translations - Updating text when content is open - Full width table - New challenges-list css file
701,848
07.08.2020 21:27:02
-43,200
f553ceae17b7da67dd5d127878265b56410cdd20
More review fixes Updated working for how to I teach unplugged Adding translations Adding a comment to syntax reminders Remove inline styles
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "@@ -57,7 +57,7 @@ function updateResultsTable(results) {\n// Update help modal\n$(`#test-case-${result.id}-help-title`).text(result.status)\n$(`#test-case-${result.id}-help`).text(result.helpInfo);\n- $(`#test-case-${result.id}-help-icon`).show()\n+ $(`#test-case-${result.id}-help-icon`).css('visibility','visible');\n// Update output cell\n$(`#test-case-${result.id}-output`).text(result.userOutput);\n@@ -68,7 +68,7 @@ function updateResultsTable(results) {\nrow_element.addClass(\"table-success\");\nrow_element.removeClass(\"table-danger\");\nrow_element.removeClass(\"table-warning\");\n- $(`#test-case-${result.id}-help-icon`).hide()\n+ $(`#test-case-${result.id}-help-icon`).css('visibility','hidden');\n} else if (result.status == \"Syntax Error\") {\nrow_element.addClass(\"table-warning\");\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/static/scss/programming-editor.scss", "new_path": "csunplugged/static/scss/programming-editor.scss", "diff": "@@ -234,6 +234,7 @@ body {\nbackground-color: #212529;\nborder-radius: 8px;\nfont-weight: bold;\n+ visibility: hidden;\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/lesson.html", "new_path": "csunplugged/templates/plugging_it_in/lesson.html", "diff": "<div class=\"tab-pane fade {% if forloop.first %}show active{% endif %}\" id=\"nav-{{language.name}}\" role=\"tabpanel\" aria-labelledby=\"{{language.name}}\">\n{% if language.name == \"Scratch\" %}\n<div class=\"alert alert-danger my-3\" role=\"alert\">\n- Scratch challenges have not updated to our new plugging it in system. However, you can still access the old content using the links below.\n+ {% trans \"Scratch challenges have not been updated to our new plugging it in system. However, you can still access the old content using the links below.\" %}\n</div>\n{% endif %}\n{% include \"plugging_it_in/programming-challenges-table.html\" with language=language.name %}\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "</div>\n</div>\n<div class=\"col-12 col-md-4 programming__editor\">\n- <p class='pii-block-heading'>Enter your code in the editor below</p>\n+ <p class='pii-block-heading'>{% trans \"Enter your code in the editor below\" %}</p>\n<textarea id=\"codemirror_editor\"></textarea>\n<div class=\"programming__submit d-flex justify-content-between align-items-center\">\n<div class=\"programming__submit_options d-flex justify-content-start\">\n- <button class=\"editor_button\" id=\"editor_run_button\" >Check</button>\n- <button class=\"editor_button\" id=\"download_button\" >Download</button>\n+ <button class=\"editor_button\" id=\"editor_run_button\" >{% trans \"Check\" %}</button>\n+ <button class=\"editor_button\" id=\"download_button\" >{% trans \"Download\" %}</button>\n</div>\n<div class=\"code_running_spinner spinner-grow\" role=\"status\">\n- <span class=\"sr-only\">Loading...</span>\n+ <span class=\"sr-only\"></span>\n</div>\n</div>\n</div>\n<div class=\"col-12 col-md-4 programming__results\">\n- <p class='pii-block-heading'>Your results will be displayed here</p>\n+ <p class='pii-block-heading'>{% trans \"Your results will be displayed here\" %}</p>\n{% include \"plugging_it_in/results-table.html\" %}\n</div>\n{% endif %}\n<div class=\"row progression-options\">\n<div class=\"col-sm-4 col-6 order-2 order-sm-1 d-flex align-items-center my-1\">\n<a id='prev_challenge_button'>\n- <button class=\"btn prev\">Previous Challenge</button>\n+ <button class=\"btn prev\">{% trans \"Previous Challenge\" %}</button>\n</a>\n</div>\n<div class=\"progression-info col-sm-4 col-12 order-1 order-sm-2 my-2\">\n<p id=\"challenge_progression_text\"></p>\n- <p id=\"lessons_nav_toggle\">(Click here to select a challenge)</p>\n+ <p id=\"lessons_nav_toggle\">({% trans \"Click here to select a challenge\" %})</p>\n</div>\n<div class=\"col-sm-4 col-6 order-3 order-sm-3 d-flex justify-content-end align-items-center my-1\">\n<a id='next_challenge_button'>\n- <button class=\"btn next\">Next Challenge</button>\n+ <button class=\"btn next\">{% trans \"Next Challenge\" %}</button>\n</a>\n</div>\n</div>\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/results-table.html", "new_path": "csunplugged/templates/plugging_it_in/results-table.html", "diff": "<span id=\"test-case-{{ test_case.id }}-status\">\nNot yet run\n</span>\n- <a href=\"#\" id=\"test-case-{{ test_case.id }}-help-icon\" class=\"badge help-icon\" data-toggle=\"modal\" data-target=\"#modal-{{ test_case.id }}\" style=\"display:none\">\n+ <a href=\"#\" id=\"test-case-{{ test_case.id }}-help-icon\" class=\"badge help-icon\" data-toggle=\"modal\" data-target=\"#modal-{{ test_case.id }}\">\n?\n</a>\n</td>\n" } ]
Python
MIT License
uccser/cs-unplugged
More review fixes - Updated working for how to I teach unplugged - Adding translations - Adding a comment to syntax reminders - Remove inline styles
701,848
07.08.2020 21:28:30
-43,200
e9eb9f5599b764d3243d3ff5ac2176cc42251421
Add in unit test for custom dictionary tag
[ { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/tests/general/templatetags/test_custom_tags.py", "diff": "+from django import template\n+from django.test import override_settings\n+\n+from tests.BaseTest import BaseTest\n+\n+AVAILABLE_LANGUAGES_EN = (\n+ (\"en\", \"English\"),\n+)\n+\n+\n+class CustomDictTagTest(BaseTest):\n+\n+ def render_template(self, string, context):\n+ context = template.Context(context)\n+ return template.Template(string).render(context)\n+\n+ @override_settings(LANGUAGES=AVAILABLE_LANGUAGES_EN)\n+ def test_get_dict_value(self):\n+ context = {\n+ \"a_dictionary\": {\"test_key\": \"test_value\"}\n+ }\n+ rendered = self.render_template(\"{% load custom_tags %}\"\n+ \"{% if a_dictionary|get_item:'test_key' == 'test_value' %}Hello{% endif %}\",\n+ context)\n+ self.assertEqual(\n+ \"Hello\",\n+ rendered\n+ )\n+\n+ @override_settings(LANGUAGES=AVAILABLE_LANGUAGES_EN)\n+ def test_get_nonexistant_dict_value(self):\n+ context = {\n+ \"a_dictionary\": {\"test_key\": \"test_value\"}\n+ }\n+ rendered = self.render_template(\"{% load custom_tags %}\"\n+ \"{% if a_dictionary|get_item:'bad_key' == 'test_value' %}Hello{% endif %}\",\n+ context)\n+ self.assertEqual(\n+ \"\",\n+ rendered\n+ )\n" } ]
Python
MIT License
uccser/cs-unplugged
Add in unit test for custom dictionary tag
701,848
07.08.2020 21:32:30
-43,200
4148f1f3578be8fb1140838799aaa8dc3c76ef9b
Removing duplicate queries in the editor view.
[ { "change_type": "MODIFY", "old_path": "csunplugged/plugging_it_in/views.py", "new_path": "csunplugged/plugging_it_in/views.py", "diff": "@@ -146,13 +146,15 @@ class ProgrammingChallengeView(generic.DetailView):\nfor lesson in lessons:\nif lesson.slug == self.kwargs.get(\"lesson_slug\", None):\ncontext[\"lesson\"] = lesson\n- context[\"programming_challenges\"] = lesson.retrieve_related_programming_challenges(\"Python\")\n- context[\"programming_exercises_json\"] = json.dumps(\n- list(lesson.retrieve_related_programming_challenges(\"Python\").values()))\n+ challlenges = lesson.retrieve_related_programming_challenges(\"Python\")\n+ context[\"programming_challenges\"] = challlenges\n+ context[\"programming_exercises_json\"] = json.dumps(list(challlenges.values()))\ncontext[\"implementations\"] = self.object.ordered_implementations()\n- context[\"test_cases_json\"] = json.dumps(list(self.object.related_test_cases().values()))\n- context[\"test_cases\"] = self.object.related_test_cases().values()\n+\n+ related_test_cases = self.object.related_test_cases().values()\n+ context[\"test_cases_json\"] = json.dumps(list(related_test_cases))\n+ context[\"test_cases\"] = related_test_cases\ncontext[\"jobe_proxy_url\"] = reverse('plugging_it_in:jobe_proxy')\nreturn context\n" } ]
Python
MIT License
uccser/cs-unplugged
Removing duplicate queries in the editor view.
701,848
08.08.2020 10:56:05
-43,200
5909a6bd4e82cc704348e56b82e3662238f5d4b1
Change Educators Guide to Educators' Guide
[ { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/about.html", "new_path": "csunplugged/templates/plugging_it_in/about.html", "diff": "{% load django_bootstrap_breadcrumbs %}\n{% block title %}\n- {% trans \"Educators Guide to Plugging It In\" %}\n+ {% trans \"Educators' Guide to Plugging It In\" %}\n{% endblock title %}\n{% block breadcrumbs %}\n- {% breadcrumb \"Educators Guide\" \"plugging_it_in:about\" %}\n+ {% breadcrumb \"Educators' Guide\" \"plugging_it_in:about\" %}\n{% endblock breadcrumbs %}\n{% block page_heading %}\n- <h1>{% trans \"Educators Guide to Plugging It In\" %}</h1>\n+ <h1>{% trans \"Educators' Guide to Plugging It In\" %}</h1>\n{% endblock page_heading %}\n{% block content %}\n" } ]
Python
MIT License
uccser/cs-unplugged
Change Educators Guide to Educators' Guide
701,848
08.08.2020 13:11:43
-43,200
a43e96c9543d285ff0e4cbf2292cf5375c438735
Navigate to language tab from index
[ { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/static/js/plugging-it-in-challenges.js", "diff": "+// Navigates to a specific tab when page loads based on the hash\n+// The hash does not match the exact id to prevent scrolling\n+$(document).ready(() => {\n+ let selectedTab = window.location.hash;\n+ if (selectedTab !== \"\") {\n+ $(`#${selectedTab.substring(1)}-tab`).tab('show');\n+ }\n+})\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/lesson.html", "new_path": "csunplugged/templates/plugging_it_in/lesson.html", "diff": "<nav>\n<div class=\"nav nav-tabs mt-2\" id=\"nav-tab\" role=\"tablist\">\n{% for language in lesson.challenge_languages %}\n- <a class=\"nav-item nav-link {% if forloop.first %}active{% endif %}\" id=\"{{language.name}}\" data-toggle=\"tab\" href=\"#nav-{{language.name}}\" role=\"tab\" aria-controls=\"{{language.name}}\" aria-selected=\"false\">\n+ <a class=\"nav-item nav-link {% if forloop.first %}active{% endif %}\" id=\"{{language.slug}}-tab\" data-toggle=\"tab\" data-target=\"#nav-{{language.slug}}\" role=\"tab\" aria-controls=\"{{language.slug}}\" aria-selected=\"false\">\n{{language.name}}\n<img src=\"{% get_static_prefix %}{{ language.icon }}\" class=\"inline-image-small pl-1\" />\n</a>\n</nav>\n<div class=\"tab-content\" id=\"nav-tabContent\">\n{% for language in lesson.challenge_languages %}\n- <div class=\"tab-pane fade {% if forloop.first %}show active{% endif %}\" id=\"nav-{{language.name}}\" role=\"tabpanel\" aria-labelledby=\"{{language.name}}\">\n- {% if language.name == \"Scratch\" %}\n+ <div class=\"tab-pane fade {% if forloop.first %}show active{% endif %}\" id=\"nav-{{language.slug}}\" role=\"tabpanel\" aria-labelledby=\"{{language.slug}}\">\n+ {% if language.slug == \"scratch\" %}\n<div class=\"alert alert-danger my-3\" role=\"alert\">\n{% trans \"Scratch challenges have not been updated to our new plugging it in system. However, you can still access the old content using the links below.\" %}\n</div>\n<p>{% blocktrans trimmed %}No programming challenges for {{ topic }}.{% endblocktrans %}</p>\n{% endif %}\n{% endblock content %}\n+\n+{% block scripts %}\n+ <script src=\"{% static 'js/plugging-it-in-challenges.js' %}\"></script>\n+{% endblock scripts %}\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/lessons-table.html", "new_path": "csunplugged/templates/plugging_it_in/lessons-table.html", "diff": "</div>\n<div class=\"col text-right\">\n{% for language in lesson.challenge_languages %}\n- <a class=\"btn btn-link my-2\" href=\"{% url 'plugging_it_in:lesson' topic.slug lesson.slug %}#nav-{{ language.slug }}\">\n+ <a class=\"btn btn-link my-2\" href=\"{% url 'plugging_it_in:lesson' topic.slug lesson.slug %}#{{ language.slug }}\">\n<img src=\"{% get_static_prefix %}{{ language.icon }}\" class=\"inline-image-small\" />\nView {{ language.name }} challenges\n</a>\n" } ]
Python
MIT License
uccser/cs-unplugged
Navigate to language tab from index
701,848
08.08.2020 14:09:24
-43,200
d11d928e9b38748534885060f62b4a956c9be4ba
Add unit test for new index page
[ { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/tests/plugging_it_in/views/test_index_view.py", "diff": "+from http import HTTPStatus\n+from django.urls import reverse\n+from tests.BaseTestWithDB import BaseTestWithDB\n+from tests.topics.TopicsTestDataGenerator import TopicsTestDataGenerator\n+\n+\n+class IndexViewTest(BaseTestWithDB):\n+\n+ def __init__(self, *args, **kwargs):\n+ super().__init__(*args, **kwargs)\n+ self.language = \"en\"\n+ self.test_data = TopicsTestDataGenerator()\n+\n+ def test_pii_index_view_with_valid_slug(self):\n+ topic = self.test_data.create_topic(1)\n+ self.test_data.create_unit_plan(topic, 1)\n+ url = reverse(\"plugging_it_in:index\")\n+ response = self.client.get(url)\n+ self.assertEqual(HTTPStatus.OK, response.status_code)\n+\n+ def test_pii_index_view_topics_context_without_programming_challenge(self):\n+ topic = self.test_data.create_topic(1)\n+ self.test_data.create_unit_plan(topic, 1)\n+ url = reverse(\"plugging_it_in:index\")\n+ response = self.client.get(url)\n+ self.assertEqual(\n+ response.context[\"programming_topics\"],\n+ []\n+ )\n+\n+ def test_pii_index_view_topics_context_with_programming_challenge(self):\n+ topic = self.test_data.create_topic(1)\n+ unit_plan = self.test_data.create_unit_plan(topic, 1)\n+ age_group_1 = self.test_data.create_age_group(5, 7)\n+ lesson = self.test_data.create_lesson(\n+ topic,\n+ unit_plan,\n+ 1,\n+ age_group_1\n+ )\n+ difficulty = self.test_data.create_difficulty_level(1)\n+ challenge = self.test_data.create_programming_challenge(topic, 1, difficulty)\n+ self.test_data.add_challenge_lesson_relationship(\n+ challenge,\n+ lesson,\n+ 1,\n+ 1\n+ )\n+\n+ url = reverse(\"plugging_it_in:index\")\n+ response = self.client.get(url)\n+ self.assertEqual(\n+ response.context[\"programming_topics\"],\n+ [topic]\n+ )\n+\n+ def test_pii_index_view_grouped_lessons_context_with_programming_challenges(self):\n+ topic = self.test_data.create_topic(1)\n+ unit_plan = self.test_data.create_unit_plan(topic, 1)\n+ age_group_1 = self.test_data.create_age_group(5, 7)\n+ lesson = self.test_data.create_lesson(\n+ topic,\n+ unit_plan,\n+ 1,\n+ age_group_1\n+ )\n+\n+ difficulty = self.test_data.create_difficulty_level(1)\n+ challenge = self.test_data.create_programming_challenge(topic, 1, difficulty)\n+ self.test_data.add_challenge_lesson_relationship(\n+ challenge,\n+ lesson,\n+ 1,\n+ 1\n+ )\n+\n+ url = reverse(\"plugging_it_in:index\")\n+ response = self.client.get(url)\n+ self.assertEqual(\n+ len(response.context[\"programming_topics\"][0].grouped_lessons),\n+ 1\n+ )\n+ grouped_lessons = response.context[\"programming_topics\"][0].grouped_lessons\n+ for (age_group, lessons) in grouped_lessons.items():\n+ self.assertEqual(repr(age_group), \"<AgeGroup: NumericRange(5, 7, '[)')>\")\n+ self.assertEqual(\n+ lessons,\n+ [lesson]\n+ )\n+\n+ def test_pii_index_view_grouped_lessons_context_with_lesson_without_programming_challenges(self):\n+ topic = self.test_data.create_topic(1)\n+ unit_plan = self.test_data.create_unit_plan(topic, 1)\n+ age_group_1 = self.test_data.create_age_group(5, 7)\n+ self.test_data.create_lesson(\n+ topic,\n+ unit_plan,\n+ 1,\n+ age_group_1\n+ )\n+\n+ lesson_with_programming_exercise = self.test_data.create_lesson(\n+ topic,\n+ unit_plan,\n+ 2,\n+ age_group_1\n+ )\n+\n+ difficulty = self.test_data.create_difficulty_level(1)\n+ challenge = self.test_data.create_programming_challenge(topic, 1, difficulty)\n+ self.test_data.add_challenge_lesson_relationship(\n+ challenge,\n+ lesson_with_programming_exercise,\n+ 1,\n+ 1\n+ )\n+\n+ url = reverse(\"plugging_it_in:index\")\n+ response = self.client.get(url)\n+\n+ # Should only return one of the lessons\n+ grouped_lessons = response.context[\"programming_topics\"][0].grouped_lessons\n+ self.assertEqual(\n+ len(grouped_lessons),\n+ 1\n+ )\n+\n+ for (age_group, lessons) in grouped_lessons.items():\n+ self.assertEqual(repr(age_group), \"<AgeGroup: NumericRange(5, 7, '[)')>\")\n+ self.assertEqual(\n+ lessons,\n+ [lesson_with_programming_exercise]\n+ )\n+\n+ def test_pii_index_view_templates(self):\n+ topic = self.test_data.create_topic(1)\n+ self.test_data.create_unit_plan(topic, 1)\n+\n+ url = reverse(\"plugging_it_in:index\")\n+ response = self.client.get(url)\n+ template_found = False\n+ for template in response.templates:\n+ if template.name == \"plugging_it_in/index.html\":\n+ template_found = True\n+ self.assertTrue(template_found)\n" } ]
Python
MIT License
uccser/cs-unplugged
Add unit test for new index page
701,848
08.08.2020 14:49:49
-43,200
0701c48dee7a0cbe03f640ff05e32e0a6786b126
Fix editor initial display issues
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/scss/programming-editor.scss", "new_path": "csunplugged/static/scss/programming-editor.scss", "diff": "@@ -19,6 +19,13 @@ body {\npadding-bottom: 70px;\n}\n+// Apply similar styles to the base text area while it loads\n+#codemirror_editor {\n+ height: 100%;\n+ border-radius: 15px;\n+ border: 1px solid grey;\n+}\n+\n.navbar-plugging-it-in {\n.container {\nmax-width: 100%;\n@@ -358,7 +365,7 @@ body {\nbackground-color: #0f173aff;\nopacity: 0;\noverflow-x: hidden;\n- transition: opacity 0.5s;\n+ // transition: opacity 0.5s;\n}\n.nav-row-info {\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "{{ programming_challenge.name }}\n{% endblock title %}\n+{% block css %}\n+ <link rel=\"stylesheet\" href=\"{% static 'css/programming-editor.css' %}\" >\n+{% endblock css %}\n+\n{% block body_container %}\n<div class=\"row programming__challenge-screen\">\n{% endblock body_container %}\n-{% block end_content %}\n- {% if programming_challenge.translation_available %}\n- {% if programming_challenge.extra_challenge %}\n- <h2>{% trans \"Extra Challenge\" %}</h2>\n- {% render_html_field programming_challenge.extra_challenge %}\n- {% endif %}\n- {% endif %}\n-{% endblock end_content %}\n-\n{% block scripts %}\n- <link rel=\"stylesheet\" href=\"{% static 'css/programming-editor.css' %}\" >\n-\n<script type=\"text/javascript\">\nlet current_challenge_slug = '{{ programming_challenge.slug }}';\nlet test_cases = {{ test_cases_json|safe }};\n" } ]
Python
MIT License
uccser/cs-unplugged
Fix editor initial display issues
701,848
08.08.2020 15:42:24
-43,200
208bf1431758605ad5e074046da549d32bc8be8f
Fix some performance issues related to challenge queries
[ { "change_type": "MODIFY", "old_path": "csunplugged/plugging_it_in/views.py", "new_path": "csunplugged/plugging_it_in/views.py", "diff": "@@ -84,7 +84,8 @@ class ProgrammingChallengeListView(generic.DetailView):\ncontext[\"lesson\"] = self.object\n# Add in a QuerySet of all the connected programming exercises for this topic\n- context[\"programming_challenges\"] = self.object.retrieve_related_programming_challenges()\n+ context[\"programming_challenges\"] = self.object.retrieve_related_programming_challenges(\n+ ).prefetch_related('implementations')\nreturn context\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenges-table.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenges-table.html", "diff": "</thead>\n<tbody>\n{% for programming_challenge in programming_challenges %}\n- {% for implementation in programming_challenge.ordered_implementations %}\n+ {% for implementation in programming_challenge.implementations.all %}\n{% if implementation.language.name == language %}\n<tr class=\"align-middle{% if not programming_challenge.translation_available %} table-active{% endif %}\">\n<td class=\"text-center\">\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/topics/programming-challenges-table.html", "new_path": "csunplugged/templates/topics/programming-challenges-table.html", "diff": "{% include \"topics/programming-difficulty-badge.html\" %}\n</td>\n<td class=\"text-center\">\n- {% for implementation in programming_challenge.ordered_implementations %}\n+ {% for implementation in programming_challenge.implementations.all %}\n<img src=\"{% get_static_prefix %}{{ implementation.language.icon }}\" class=\"inline-image-small\" />\n{% endfor %}\n</td>\n<td class=\"p-0\"></td>\n<td colspan=\"3\" class=\"p-0\">\n<div id=\"accordion-{{ programming_challenge.challenge_set_number }}{{ programming_challenge.challenge_number }}\" class=\"collapse acc-programming-challenge\">\n- {% if programming_challenge.get_learning_outcomes %}\n+ {% if programming_challenge.learning_outcomes %}\n<strong>{% trans \"Learning outcomes\" %}</strong>\n<div class=\"boxed-text-content\">\n<p>{% trans \"Students will be able to:\" %}</p>\n<ul>\n- {% for learning_outcome in programming_challenge.get_learning_outcomes %}\n+ {% for learning_outcome in programming_challenge.learning_outcomes.all %}\n<li>\n{{ learning_outcome.text }}<br>\n{% for area in learning_outcome.curriculum_areas.all %}\n</div>\n{% endif %}\n- {% if programming_challenge.ordered_implementations %}\n+ {% if programming_challenge.implementations %}\n<strong>{% trans \"Challenge Solutions\" %}</strong>\n{% endif %}\n- {% for implementation in programming_challenge.ordered_implementations %}\n+ {% for implementation in programming_challenge.implementations.all %}\n</br>\n<a href=\"{% url 'topics:programming_challenge_solution' topic.slug programming_challenge.slug implementation.language.slug %}\">\n{% blocktrans with name=implementation.language.name %}Show {{ name }} solution{% endblocktrans %}\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/views.py", "new_path": "csunplugged/topics/views.py", "diff": "@@ -228,7 +228,8 @@ class ProgrammingChallengeList(generic.base.TemplateView):\nslug=self.kwargs.get(\"lesson_slug\", None),\n)\ncontext[\"lesson\"] = lesson\n- context[\"programming_challenges\"] = lesson.retrieve_related_programming_challenges()\n+ context[\"programming_challenges\"] = lesson.retrieve_related_programming_challenges().prefetch_related(\n+ 'learning_outcomes', 'learning_outcomes__curriculum_areas', 'implementations')\ncontext[\"unit_plan\"] = lesson.unit_plan\ncontext[\"topic\"] = lesson.topic\nreturn context\n" } ]
Python
MIT License
uccser/cs-unplugged
Fix some performance issues related to challenge queries
701,848
08.08.2020 15:51:01
-43,200
864b04d4ee6d5fd89b0120ca647fda54194e8554
Update challenges list styles
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/scss/challenges-list.scss", "new_path": "csunplugged/static/scss/challenges-list.scss", "diff": "background-color: #3366ff;\ncursor: pointer;\n}\n+.nav-item:hover {\n+ cursor: pointer;\n+}\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenges-table.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenges-table.html", "diff": "{% load i18n %}\n+{% block css %}\n+ <link rel=\"stylesheet\" href=\"{% static 'css/challenges-list.css' %}\" >\n+{% endblock css %}\n+\n<div class='table-responsive'>\n<table class=\"table table-center-vertical\">\n<thead class=\"thead-default\">\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/topics/programming-challenges-table.html", "new_path": "csunplugged/templates/topics/programming-challenges-table.html", "diff": "{% load i18n %}\n+{% block css %}\n+ <link rel=\"stylesheet\" href=\"{% static 'css/challenges-list.css' %}\" >\n+{% endblock css %}\n+\n<div class=\"table-responsive\" >\n<table class=\"table table-center-vertical\">\n<thead class=\"thead-default\">\n</div>\n{% block scripts %}\n- <link rel=\"stylesheet\" href=\"{% static 'css/challenges-list.css' %}\" >\n<script type=\"text/javascript\">\nfunction updateToggleButtonText(challenge_num) {\nchallengeContentToggleId = `#toggle-${challenge_num}`;\n" } ]
Python
MIT License
uccser/cs-unplugged
Update challenges list styles
701,848
01.09.2020 17:26:39
-43,200
9aa8f47c1d35da9408e02c9a599aa4b08124392e
Change Q4.5 input to be on one line.
[ { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/binary-numbers/programming-challenges/count-bw-one-input-using-loop/test-cases/test-case-1-input.txt", "new_path": "csunplugged/topics/content/en/binary-numbers/programming-challenges/count-bw-one-input-using-loop/test-cases/test-case-1-input.txt", "diff": "-W\n-B\n-B\n\\ No newline at end of file\n+WBB\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/binary-numbers/programming-challenges/count-bw-one-input-using-loop/test-cases/test-case-4-input.txt", "new_path": "csunplugged/topics/content/en/binary-numbers/programming-challenges/count-bw-one-input-using-loop/test-cases/test-case-4-input.txt", "diff": "-W\n-W\n-W\n-W\n-W\n-W\n-W\n-W\n\\ No newline at end of file\n+WWWWWWWW\n\\ No newline at end of file\n" } ]
Python
MIT License
uccser/cs-unplugged
Change Q4.5 input to be on one line.
701,848
01.09.2020 19:15:11
-43,200
e25e651e7ae7b91c039faa1e6f9ab631f900f9fb
Updating expected output for Q7.1 to display 5 binary cards.
[ { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/binary-numbers/programming-challenges/binary-cards-representing-number/test-cases/test-case-1-output.txt", "new_path": "csunplugged/topics/content/en/binary-numbers/programming-challenges/binary-cards-representing-number/test-cases/test-case-1-output.txt", "diff": "-The binary representation for the number 11 is WBWW\n\\ No newline at end of file\n+The binary representation for the number 11 is BWBWW\n\\ No newline at end of file\n" } ]
Python
MIT License
uccser/cs-unplugged
Updating expected output for Q7.1 to display 5 binary cards.
701,848
14.09.2020 22:10:21
-43,200
ac8e013738fe68d62274be1dc462ceec560d737d
Add url unit tests for plugging it in
[ { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/tests/plugging_it_in/urls/__init__.py", "diff": "+\"\"\"Module for tests of the urls in the plugging it in application.\"\"\"\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/tests/plugging_it_in/urls/test_about.py", "diff": "+from http import HTTPStatus\n+from tests.BaseTestWithDB import BaseTestWithDB\n+from django.urls import reverse\n+\n+\n+class AboutURLTest(BaseTestWithDB):\n+\n+ def __init__(self, *args, **kwargs):\n+ super().__init__(*args, **kwargs)\n+ self.language = \"en\"\n+\n+ def test_valid_about(self):\n+ url = reverse(\"plugging_it_in:about\")\n+ self.assertEqual(url, \"/en/plugging-it-in/about/\")\n+\n+ response = self.client.get(url)\n+ self.assertEqual(HTTPStatus.OK, response.status_code)\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/tests/plugging_it_in/urls/test_index.py", "diff": "+from http import HTTPStatus\n+from tests.BaseTestWithDB import BaseTestWithDB\n+from django.urls import reverse\n+\n+\n+class IndexURLTest(BaseTestWithDB):\n+\n+ def __init__(self, *args, **kwargs):\n+ super().__init__(*args, **kwargs)\n+ self.language = \"en\"\n+\n+ def test_valid_index(self):\n+ url = reverse(\"plugging_it_in:index\")\n+ self.assertEqual(url, \"/en/plugging-it-in/\")\n+\n+ response = self.client.get(url)\n+ self.assertEqual(HTTPStatus.OK, response.status_code)\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/tests/plugging_it_in/urls/test_jobe_proxy.py", "diff": "+from tests.BaseTestWithDB import BaseTestWithDB\n+from django.urls import reverse\n+\n+\n+class JobeProxyURLTest(BaseTestWithDB):\n+\n+ def __init__(self, *args, **kwargs):\n+ super().__init__(*args, **kwargs)\n+ self.language = \"en\"\n+\n+ def test_valid_jobe_proxy(self):\n+ url = reverse(\"plugging_it_in:jobe_proxy\")\n+ self.assertEqual(url, \"/en/plugging-it-in/jobe_proxy\")\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/tests/plugging_it_in/urls/test_programming_challenge.py", "diff": "+from tests.BaseTestWithDB import BaseTestWithDB\n+from django.urls import reverse\n+\n+\n+class ProgrammingChallengeURLTest(BaseTestWithDB):\n+\n+ def __init__(self, *args, **kwargs):\n+ super().__init__(*args, **kwargs)\n+ self.language = \"en\"\n+\n+ def test_valid_programming_challenge(self):\n+ kwargs = {\n+ \"topic_slug\": \"binary-numbers\",\n+ \"lesson_slug\": \"lesson-1\",\n+ \"programming_challenge_slug\": \"challenge-1\",\n+ }\n+ url = reverse(\"plugging_it_in:programming_challenge\", kwargs=kwargs)\n+ self.assertEqual(url, \"/en/plugging-it-in/binary-numbers/lesson-1/challenge-1/\")\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/tests/plugging_it_in/urls/test_programming_challenge_list copy.py", "diff": "+from tests.BaseTestWithDB import BaseTestWithDB\n+from django.urls import reverse\n+\n+\n+class ProgrammingChallengeListURLTest(BaseTestWithDB):\n+\n+ def __init__(self, *args, **kwargs):\n+ super().__init__(*args, **kwargs)\n+ self.language = \"en\"\n+\n+ def test_valid_lesson_programming_challenge_list(self):\n+ kwargs = {\n+ \"topic_slug\": \"binary-numbers\",\n+ \"lesson_slug\": \"lesson-1\",\n+ }\n+ url = reverse(\"plugging_it_in:lesson\", kwargs=kwargs)\n+ self.assertEqual(url, \"/en/plugging-it-in/binary-numbers/lesson-1/\")\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/tests/plugging_it_in/urls/test_save_attempt.py", "diff": "+from tests.BaseTestWithDB import BaseTestWithDB\n+from django.urls import reverse\n+\n+\n+class SaveAttamptURLTest(BaseTestWithDB):\n+\n+ def __init__(self, *args, **kwargs):\n+ super().__init__(*args, **kwargs)\n+ self.language = \"en\"\n+\n+ def test_valid_jobe_proxy(self):\n+ url = reverse(\"plugging_it_in:save_attempt\")\n+ self.assertEqual(url, \"/en/plugging-it-in/save_attempt\")\n" } ]
Python
MIT License
uccser/cs-unplugged
Add url unit tests for plugging it in
701,848
14.09.2020 22:34:37
-43,200
2ebd8c3122fbeed90f445bc75a101d3e63d74845
Add plugging it in models tests
[ { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/tests/plugging_it_in/models/__init__.py", "diff": "+\"\"\"Module for tests of the models in the plugging it in application.\"\"\"\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/tests/plugging_it_in/models/test_testcase.py", "diff": "+from plugging_it_in.models import TestCase\n+\n+from tests.BaseTestWithDB import BaseTestWithDB\n+from tests.topics.TopicsTestDataGenerator import TopicsTestDataGenerator\n+\n+\n+class TestCaseModelTest(BaseTestWithDB):\n+\n+ def __init__(self, *args, **kwargs):\n+ super().__init__(*args, **kwargs)\n+ self.test_data = TopicsTestDataGenerator()\n+\n+ def create_testcase(self):\n+ topic = self.test_data.create_topic(1)\n+ difficulty = self.test_data.create_difficulty_level(1)\n+ challenge = self.test_data.create_programming_challenge(topic, 1, difficulty)\n+\n+ self.test_data.create_programming_challenge_test_case(1, challenge)\n+ self.test_case = TestCase.objects.get(id=1)\n+\n+ def test_testcase_verbose_model_name(self):\n+ self.create_testcase()\n+ verbose_name = self.test_case._meta.verbose_name\n+ self.assertEquals(verbose_name, \"Test Case\")\n" } ]
Python
MIT License
uccser/cs-unplugged
Add plugging it in models tests
701,848
14.09.2020 22:45:16
-43,200
25ba3579f13f9f4b93a086c3da1e96c2363c2663
Fixes to plugging it in views
[ { "change_type": "MODIFY", "old_path": "csunplugged/plugging_it_in/views.py", "new_path": "csunplugged/plugging_it_in/views.py", "diff": "\"\"\"Views for the plugging_it_in application.\"\"\"\nfrom django.http import HttpResponse\n+from django.http import Http404\nimport json\nimport requests\n@@ -68,7 +69,18 @@ class ProgrammingChallengeListView(generic.DetailView):\nmodel = Lesson\ntemplate_name = \"plugging_it_in/lesson.html\"\n- slug_url_kwarg = \"lesson_slug\"\n+\n+ def get_object(self, **kwargs):\n+ \"\"\"Retrieve object for the lesson view.\n+\n+ Returns:\n+ Lesson object, or raises 404 error if not found.\n+ \"\"\"\n+ return get_object_or_404(\n+ self.model.objects.select_related(),\n+ topic__slug=self.kwargs.get(\"topic_slug\", None),\n+ slug=self.kwargs.get(\"lesson_slug\", None),\n+ )\ndef get_context_data(self, **kwargs):\n\"\"\"Provide the context data for the programming challenge list view.\n@@ -119,13 +131,18 @@ class ProgrammingChallengeView(generic.DetailView):\ncontext[\"topic\"] = self.object.topic\nlessons = self.object.lessons.all()\n+ found = False\nfor lesson in lessons:\nif lesson.slug == self.kwargs.get(\"lesson_slug\", None):\n+ found = True\ncontext[\"lesson\"] = lesson\nchalllenges = lesson.retrieve_related_programming_challenges(\"Python\")\ncontext[\"programming_challenges\"] = challlenges\ncontext[\"programming_exercises_json\"] = json.dumps(list(challlenges.values()))\n+ if not found:\n+ raise Http404(\"Lesson does not exist\")\n+\ncontext[\"implementations\"] = self.object.ordered_implementations()\nrelated_test_cases = self.object.related_test_cases().values()\n" } ]
Python
MIT License
uccser/cs-unplugged
Fixes to plugging it in views
701,848
14.09.2020 22:45:47
-43,200
81a16ec0a7a75812c0b593debfebf08ddbf77e1b
Add unit tests for plugging it in views (unfinished)
[ { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/tests/plugging_it_in/views/test_about_view.py", "diff": "+from tests.BaseTestWithDB import BaseTestWithDB\n+from django.urls import reverse\n+from http import HTTPStatus\n+\n+\n+class AboutViewTest(BaseTestWithDB):\n+\n+ def __init__(self, *args, **kwargs):\n+ super().__init__(*args, **kwargs)\n+ self.language = \"en\"\n+\n+ def test_about_view(self):\n+ response = self.client.get(reverse(\"plugging_it_in:about\"))\n+ self.assertEqual(HTTPStatus.OK, response.status_code)\n+ self.assertContains(response, \"About\")\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/tests/plugging_it_in/views/test_jobe_proxy_view.py", "diff": "+from tests.BaseTestWithDB import BaseTestWithDB\n+from tests.topics.TopicsTestDataGenerator import TopicsTestDataGenerator\n+\n+# TODO: No idea how to test this one... more of an integration test really\n+class JobeProxyViewTest(BaseTestWithDB):\n+\n+ def __init__(self, *args, **kwargs):\n+ super().__init__(*args, **kwargs)\n+ self.language = \"en\"\n+ self.test_data = TopicsTestDataGenerator()\n+\n+ # TODO Finish tests...\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/tests/plugging_it_in/views/test_programming_challenge_list_view.py", "diff": "+from http import HTTPStatus\n+from django.urls import reverse\n+from tests.BaseTestWithDB import BaseTestWithDB\n+from tests.topics.TopicsTestDataGenerator import TopicsTestDataGenerator\n+\n+\n+class ProgrammingChallengeListViewTest(BaseTestWithDB):\n+\n+ def __init__(self, *args, **kwargs):\n+ super().__init__(*args, **kwargs)\n+ self.language = \"en\"\n+ self.test_data = TopicsTestDataGenerator()\n+\n+ def test_programming_challenge_list_with_valid_slugs(self):\n+ topic = self.test_data.create_topic(1)\n+ unit_plan = self.test_data.create_unit_plan(topic, 1)\n+ age_group_1 = self.test_data.create_age_group(5, 7)\n+ lesson = self.test_data.create_lesson(\n+ topic,\n+ unit_plan,\n+ 1,\n+ age_group_1\n+ )\n+ difficulty = self.test_data.create_difficulty_level(1)\n+ challenge1 = self.test_data.create_programming_challenge(topic, 1, difficulty)\n+ challenge2 = self.test_data.create_programming_challenge(topic, 2, difficulty)\n+ self.test_data.add_challenge_lesson_relationship(\n+ challenge1,\n+ lesson,\n+ 1,\n+ 1\n+ )\n+ self.test_data.add_challenge_lesson_relationship(\n+ challenge2,\n+ lesson,\n+ 1,\n+ 2\n+ )\n+ kwargs = {\n+ \"topic_slug\": topic.slug,\n+ \"lesson_slug\": lesson.slug,\n+ }\n+ url = reverse(\"plugging_it_in:lesson\", kwargs=kwargs)\n+ response = self.client.get(url)\n+ self.assertEqual(HTTPStatus.OK, response.status_code)\n+\n+ def test_programming_challenge_list_with_invalid_topic_slug(self):\n+ topic = self.test_data.create_topic(1)\n+ unit_plan = self.test_data.create_unit_plan(topic, 1)\n+ age_group_1 = self.test_data.create_age_group(5, 7)\n+ lesson = self.test_data.create_lesson(\n+ topic,\n+ unit_plan,\n+ 1,\n+ age_group_1\n+ )\n+ difficulty = self.test_data.create_difficulty_level(1)\n+ challenge1 = self.test_data.create_programming_challenge(topic, 1, difficulty)\n+ challenge2 = self.test_data.create_programming_challenge(topic, 2, difficulty)\n+ self.test_data.add_challenge_lesson_relationship(\n+ challenge1,\n+ lesson,\n+ 1,\n+ 1\n+ )\n+ self.test_data.add_challenge_lesson_relationship(\n+ challenge2,\n+ lesson,\n+ 1,\n+ 2\n+ )\n+ kwargs = {\n+ \"topic_slug\": \"wrong_slug\",\n+ \"lesson_slug\": lesson.slug,\n+ }\n+ url = reverse(\"plugging_it_in:lesson\", kwargs=kwargs)\n+ response = self.client.get(url)\n+ self.assertEqual(HTTPStatus.NOT_FOUND, response.status_code)\n+\n+ def test_programming_challenge_list_with_invalid_lesson_slug(self):\n+ topic = self.test_data.create_topic(1)\n+ unit_plan = self.test_data.create_unit_plan(topic, 1)\n+ age_group_1 = self.test_data.create_age_group(5, 7)\n+ lesson = self.test_data.create_lesson(\n+ topic,\n+ unit_plan,\n+ 1,\n+ age_group_1\n+ )\n+ difficulty = self.test_data.create_difficulty_level(1)\n+ challenge1 = self.test_data.create_programming_challenge(topic, 1, difficulty)\n+ challenge2 = self.test_data.create_programming_challenge(topic, 2, difficulty)\n+ self.test_data.add_challenge_lesson_relationship(\n+ challenge1,\n+ lesson,\n+ 1,\n+ 1\n+ )\n+ self.test_data.add_challenge_lesson_relationship(\n+ challenge2,\n+ lesson,\n+ 1,\n+ 2\n+ )\n+ kwargs = {\n+ \"topic_slug\": topic.slug,\n+ \"lesson_slug\": \"wrong_slug\",\n+ }\n+ url = reverse(\"plugging_it_in:lesson\", kwargs=kwargs)\n+ response = self.client.get(url)\n+ self.assertEqual(HTTPStatus.NOT_FOUND, response.status_code)\n+\n+ def test_programming_challenge_list_topic_context(self):\n+ topic = self.test_data.create_topic(1)\n+ unit_plan = self.test_data.create_unit_plan(topic, 1)\n+ age_group_1 = self.test_data.create_age_group(5, 7)\n+ lesson = self.test_data.create_lesson(\n+ topic,\n+ unit_plan,\n+ 1,\n+ age_group_1\n+ )\n+ difficulty = self.test_data.create_difficulty_level(1)\n+ challenge1 = self.test_data.create_programming_challenge(topic, 1, difficulty)\n+ challenge2 = self.test_data.create_programming_challenge(topic, 2, difficulty)\n+ self.test_data.add_challenge_lesson_relationship(\n+ challenge1,\n+ lesson,\n+ 1,\n+ 1\n+ )\n+ self.test_data.add_challenge_lesson_relationship(\n+ challenge2,\n+ lesson,\n+ 1,\n+ 2\n+ )\n+ kwargs = {\n+ \"topic_slug\": topic.slug,\n+ \"lesson_slug\": lesson.slug,\n+ }\n+ url = reverse(\"plugging_it_in:lesson\", kwargs=kwargs)\n+ response = self.client.get(url)\n+ self.assertEqual(\n+ response.context[\"topic\"],\n+ topic\n+ )\n+\n+ def test_programming_challenge_list_lesson_context(self):\n+ topic = self.test_data.create_topic(1)\n+ unit_plan = self.test_data.create_unit_plan(topic, 1)\n+ age_group_1 = self.test_data.create_age_group(5, 7)\n+ lesson = self.test_data.create_lesson(\n+ topic,\n+ unit_plan,\n+ 1,\n+ age_group_1\n+ )\n+ difficulty = self.test_data.create_difficulty_level(1)\n+ challenge1 = self.test_data.create_programming_challenge(topic, 1, difficulty)\n+ challenge2 = self.test_data.create_programming_challenge(topic, 2, difficulty)\n+ self.test_data.add_challenge_lesson_relationship(\n+ challenge1,\n+ lesson,\n+ 1,\n+ 1\n+ )\n+ self.test_data.add_challenge_lesson_relationship(\n+ challenge2,\n+ lesson,\n+ 1,\n+ 2\n+ )\n+ kwargs = {\n+ \"topic_slug\": topic.slug,\n+ \"lesson_slug\": lesson.slug,\n+ }\n+ url = reverse(\"plugging_it_in:lesson\", kwargs=kwargs)\n+ response = self.client.get(url)\n+ self.assertEqual(\n+ response.context[\"lesson\"],\n+ lesson\n+ )\n+\n+ def test_programming_challenge_list_challenges_context(self):\n+ topic = self.test_data.create_topic(1)\n+ unit_plan = self.test_data.create_unit_plan(topic, 1)\n+ age_group_1 = self.test_data.create_age_group(5, 7)\n+ lesson = self.test_data.create_lesson(\n+ topic,\n+ unit_plan,\n+ 1,\n+ age_group_1\n+ )\n+ difficulty = self.test_data.create_difficulty_level(1)\n+ challenge = self.test_data.create_programming_challenge(topic, 1, difficulty)\n+ self.test_data.add_challenge_lesson_relationship(\n+ challenge,\n+ lesson,\n+ 1,\n+ 1\n+ )\n+ kwargs = {\n+ \"topic_slug\": topic.slug,\n+ \"lesson_slug\": lesson.slug,\n+ }\n+ url = reverse(\"plugging_it_in:lesson\", kwargs=kwargs)\n+ response = self.client.get(url)\n+ self.assertQuerysetEqual(\n+ response.context[\"programming_challenges\"],\n+ [\n+ \"<ProgrammingChallenge: Challenge 1.1: 1>\",\n+ ]\n+ )\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/tests/plugging_it_in/views/test_programming_challenge_view.py", "diff": "+from http import HTTPStatus\n+from django.urls import reverse\n+from tests.BaseTestWithDB import BaseTestWithDB\n+from tests.topics.TopicsTestDataGenerator import TopicsTestDataGenerator\n+\n+from topics.models import (\n+ ProgrammingChallengeLanguage\n+)\n+\n+\n+class ProgrammingChallengeViewTest(BaseTestWithDB):\n+\n+ def __init__(self, *args, **kwargs):\n+ super().__init__(*args, **kwargs)\n+ self.language = \"en\"\n+ self.test_data = TopicsTestDataGenerator()\n+\n+ def create_challenge(self):\n+ self.topic = self.test_data.create_topic(1)\n+ self.unit_plan = self.test_data.create_unit_plan(self.topic, 1)\n+ self.age_group = self.test_data.create_age_group(5, 7)\n+ self.lesson = self.test_data.create_lesson(\n+ self.topic,\n+ self.unit_plan,\n+ 1,\n+ self.age_group\n+ )\n+ self.difficulty = self.test_data.create_difficulty_level(1)\n+ self.challenge = self.test_data.create_programming_challenge(self.topic, 1, self.difficulty)\n+ self.test_data.add_challenge_lesson_relationship(\n+ self.challenge,\n+ self.lesson,\n+ 1,\n+ 1\n+ )\n+\n+ def test_programming_challenge_view_with_valid_slugs(self):\n+ self.create_challenge()\n+ kwargs = {\n+ \"topic_slug\": self.topic.slug,\n+ \"lesson_slug\": self.lesson.slug,\n+ \"programming_challenge_slug\": self.challenge.slug,\n+ }\n+ url = reverse(\"plugging_it_in:programming_challenge\", kwargs=kwargs)\n+ response = self.client.get(url)\n+ self.assertEqual(HTTPStatus.OK, response.status_code)\n+\n+ def test_programming_challenge_view_with_invalid_topic_slug(self):\n+ self.create_challenge()\n+ kwargs = {\n+ \"topic_slug\": \"wrong_slug\",\n+ \"lesson_slug\": self.lesson.slug,\n+ \"programming_challenge_slug\": self.challenge.slug,\n+ }\n+ url = reverse(\"plugging_it_in:programming_challenge\", kwargs=kwargs)\n+ response = self.client.get(url)\n+ self.assertEqual(HTTPStatus.NOT_FOUND, response.status_code)\n+\n+ def test_programming_challenge_view_with_invalid_lesson_slug(self):\n+ self.create_challenge()\n+ kwargs = {\n+ \"topic_slug\": self.topic.slug,\n+ \"lesson_slug\": \"wrong_slug\",\n+ \"programming_challenge_slug\": self.challenge.slug,\n+ }\n+ url = reverse(\"plugging_it_in:programming_challenge\", kwargs=kwargs)\n+ response = self.client.get(url)\n+ self.assertEqual(HTTPStatus.NOT_FOUND, response.status_code)\n+\n+ def test_programming_challenge_view_with_invalid_challenge_slug(self):\n+ self.create_challenge()\n+ kwargs = {\n+ \"topic_slug\": self.topic.slug,\n+ \"lesson_slug\": self.lesson.slug,\n+ \"programming_challenge_slug\": \"wrong_slug\",\n+ }\n+ url = reverse(\"plugging_it_in:programming_challenge\", kwargs=kwargs)\n+ response = self.client.get(url)\n+ self.assertEqual(HTTPStatus.NOT_FOUND, response.status_code)\n+\n+ def test_programming_challenge_view_topic_context(self):\n+ self.create_challenge()\n+ kwargs = {\n+ \"topic_slug\": self.topic.slug,\n+ \"lesson_slug\": self.lesson.slug,\n+ \"programming_challenge_slug\": self.challenge.slug,\n+ }\n+ url = reverse(\"plugging_it_in:programming_challenge\", kwargs=kwargs)\n+ response = self.client.get(url)\n+ self.assertEqual(\n+ response.context[\"topic\"],\n+ self.topic\n+ )\n+\n+ def test_programming_challenge_view_lesson_context(self):\n+ self.create_challenge()\n+ lesson2 = self.test_data.create_lesson(\n+ self.topic,\n+ self.unit_plan,\n+ 2,\n+ self.age_group\n+ )\n+ self.test_data.add_challenge_lesson_relationship(\n+ self.challenge,\n+ lesson2,\n+ 1,\n+ 2\n+ )\n+ kwargs = {\n+ \"topic_slug\": self.topic.slug,\n+ \"lesson_slug\": self.lesson.slug,\n+ \"programming_challenge_slug\": self.challenge.slug,\n+ }\n+ url = reverse(\"plugging_it_in:programming_challenge\", kwargs=kwargs)\n+ response = self.client.get(url)\n+\n+ # It should only return the first lesson which corresponds with the slug\n+ self.assertEqual(\n+ response.context[\"lesson\"],\n+ self.lesson\n+ )\n+\n+ def test_programming_challenge_view_programming_challenges_context(self):\n+ self.create_challenge()\n+ challenge2 = self.test_data.create_programming_challenge(self.topic, 2, self.difficulty)\n+\n+ # Creating the programming challenge language for python manually\n+ python_language = ProgrammingChallengeLanguage(\n+ slug=\"python\",\n+ name=\"Python\",\n+ number=1,\n+ languages=[\"en\"],\n+ )\n+ python_language.save()\n+ other_language = self.test_data.create_programming_language(2)\n+\n+ self.test_data.add_challenge_lesson_relationship(\n+ challenge2,\n+ self.lesson,\n+ 1,\n+ 2\n+ )\n+\n+ # Add implementations\n+ self.test_data.create_programming_challenge_implementation(\n+ self.topic,\n+ python_language,\n+ self.challenge,\n+ )\n+ self.test_data.create_programming_challenge_implementation(\n+ self.topic,\n+ other_language,\n+ self.challenge,\n+ )\n+\n+ kwargs = {\n+ \"topic_slug\": self.topic.slug,\n+ \"lesson_slug\": self.lesson.slug,\n+ \"programming_challenge_slug\": self.challenge.slug,\n+ }\n+ url = reverse(\"plugging_it_in:programming_challenge\", kwargs=kwargs)\n+ response = self.client.get(url)\n+\n+ # Should only return the first challenge with the python language\n+ self.assertQuerysetEqual(\n+ response.context[\"programming_challenges\"],\n+ [\"<ProgrammingChallenge: Challenge 1.1: 1>\"]\n+ )\n+\n+ def test_programming_challenge_view_programming_challenges_json_context(self):\n+ self.create_challenge()\n+ challenge2 = self.test_data.create_programming_challenge(self.topic, 2, self.difficulty)\n+\n+ # Creating the programming challenge language for python manually\n+ python_language = ProgrammingChallengeLanguage(\n+ slug=\"python\",\n+ name=\"Python\",\n+ number=1,\n+ languages=[\"en\"],\n+ )\n+ python_language.save()\n+ other_language = self.test_data.create_programming_language(2)\n+\n+ self.test_data.add_challenge_lesson_relationship(\n+ challenge2,\n+ self.lesson,\n+ 1,\n+ 2\n+ )\n+ self.test_data.create_programming_challenge_implementation(\n+ self.topic,\n+ python_language,\n+ self.challenge,\n+ )\n+ self.test_data.create_programming_challenge_implementation(\n+ self.topic,\n+ other_language,\n+ challenge2,\n+ )\n+\n+ kwargs = {\n+ \"topic_slug\": self.topic.slug,\n+ \"lesson_slug\": self.lesson.slug,\n+ \"programming_challenge_slug\": self.challenge.slug,\n+ }\n+ url = reverse(\"plugging_it_in:programming_challenge\", kwargs=kwargs)\n+ response = self.client.get(url)\n+\n+ # TODO - assert the json context\n+ # Should only return the first challenge with the python language\n+ # Not sure how to assert this - the challenge object doesn't seem to become json easily\n+ # This is returned [{\"topic_id\": 15, \"id\": 18, \"slug\": \"cha[259 chars]1\"}]\n+ # If acheiving this statically is also difficult as finding the topic id...\n+ # self.assertEqual(\n+ # response.context[\"programming_exercises_json\"],\n+ # {\"slug\": self.challenge.slug,\n+ # \"difficulty_id\": self.difficulty.id,\n+ # \"languages\": [\"python\"]\n+ # }\n+ # )\n+\n+ def test_programming_challenge_view_test_cases_context(self):\n+ self.create_challenge()\n+ self.test_data.create_programming_challenge_test_case(\n+ 1,\n+ self.challenge\n+ )\n+ kwargs = {\n+ \"topic_slug\": self.topic.slug,\n+ \"lesson_slug\": self.lesson.slug,\n+ \"programming_challenge_slug\": self.challenge.slug,\n+ }\n+ url = reverse(\"plugging_it_in:programming_challenge\", kwargs=kwargs)\n+ response = self.client.get(url)\n+\n+ # TODO: this returns the test cases queryset values() - its in a weird semi json format...\n+ # Perhaps it can be done such that the testcases are returned and the values are only used when creating the json version\n+ # self.assertQuerysetEqual(\n+ # response.context[\"test_cases\"],\n+ # [\n+ # \"<TestCase: TestCase object (1)>\",\n+ # ]\n+ # )\n+\n+ def test_programming_challenge_view_test_cases_json_context(self):\n+ self.create_challenge()\n+ test_test_case = self.test_data.create_programming_challenge_test_case(\n+ 1,\n+ self.challenge\n+ )\n+ test_test_case.question_type = \"input\"\n+ test_test_case.expected_input = \"test_input\"\n+ test_test_case.expected_output = \"test_output\"\n+\n+ kwargs = {\n+ \"topic_slug\": self.topic.slug,\n+ \"lesson_slug\": self.lesson.slug,\n+ \"programming_challenge_slug\": self.challenge.slug,\n+ }\n+ url = reverse(\"plugging_it_in:programming_challenge\", kwargs=kwargs)\n+ response = self.client.get(url)\n+\n+ # TODO: the get related test cases uses select_related not sure if this is needed.\n+ # This will get rid of number and languages I'd imagine. Thinking a query will need to be made to get the challenge and test case ids.\n+ # self.assertQuerysetEqual(\n+ # response.context[\"test_cases_json\"],\n+ # [{\"id\": \"?\", \"languages\": [], \"number\": 1, \"test_input\": \"test_input\", \"expected_output\": \"test_output\", \"question_type\": \"input\", \"challenge_id\": \"?\"}]\n+ # )\n+\n+ def test_programming_challenge_view_jobe_proxy_url_context(self):\n+ self.create_challenge()\n+ kwargs = {\n+ \"topic_slug\": self.topic.slug,\n+ \"lesson_slug\": self.lesson.slug,\n+ \"programming_challenge_slug\": self.challenge.slug,\n+ }\n+ url = reverse(\"plugging_it_in:programming_challenge\", kwargs=kwargs)\n+ response = self.client.get(url)\n+ self.assertEqual(\n+ response.context[\"jobe_proxy_url\"],\n+ reverse('plugging_it_in:jobe_proxy')\n+ )\n+\n+ def test_programming_challenge_view_saved_attempts_context(self):\n+ self.create_challenge()\n+\n+ # Setting the session manually\n+ session = self.client.session\n+ session['saved_attempts'] = {\"test_session\": \"testing\"}\n+ session.save()\n+\n+ kwargs = {\n+ \"topic_slug\": self.topic.slug,\n+ \"lesson_slug\": self.lesson.slug,\n+ \"programming_challenge_slug\": self.challenge.slug,\n+ }\n+ url = reverse(\"plugging_it_in:programming_challenge\", kwargs=kwargs)\n+ response = self.client.get(url)\n+ self.assertEqual(\n+ response.context[\"saved_attempts\"],\n+ {\"test_session\": \"testing\"}\n+ )\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/tests/plugging_it_in/views/test_save_attempt_view.py", "diff": "+import json\n+\n+from http import HTTPStatus\n+from django.urls import reverse\n+from tests.BaseTestWithDB import BaseTestWithDB\n+from tests.topics.TopicsTestDataGenerator import TopicsTestDataGenerator\n+\n+\n+class SaveAttemptViewTest(BaseTestWithDB):\n+\n+ def __init__(self, *args, **kwargs):\n+ super().__init__(*args, **kwargs)\n+ self.language = \"en\"\n+ self.test_data = TopicsTestDataGenerator()\n+\n+ def test_save_new_attempt_response(self):\n+ new_attempt = {\n+ \"challenge\": \"test_challenge\",\n+ \"attempt\": \"print('Hello World')\",\n+ \"status\": \"passed\"\n+ }\n+\n+ url = reverse(\"plugging_it_in:save_attempt\")\n+ response = self.client.post(url, json.dumps(new_attempt), content_type='application/json')\n+\n+ self.assertEqual(\n+ response.content.decode(),\n+ \"Saved the attempt.\"\n+ )\n+\n+ def test_save_new_attempt_session(self):\n+ new_attempt = {\n+ \"challenge\": \"test_challenge\",\n+ \"attempt\": \"print('Hello World')\",\n+ \"status\": \"passed\"\n+ }\n+\n+ url = reverse(\"plugging_it_in:save_attempt\")\n+ self.client.post(url, json.dumps(new_attempt), content_type='application/json')\n+\n+ self.assertEqual(\n+ self.client.session['saved_attempts']['test_challenge'],\n+ {\n+ \"status\": \"passed\",\n+ \"code\": \"print('Hello World')\"\n+ }\n+ )\n+\n+ def test_save_empty_attempt_response(self):\n+ new_attempt = {\n+ \"challenge\": \"\",\n+ \"attempt\": \"\",\n+ \"status\": \"\"\n+ }\n+\n+ url = reverse(\"plugging_it_in:save_attempt\")\n+ response = self.client.post(url, json.dumps(new_attempt), content_type='application/json')\n+\n+ self.assertEqual(\n+ response.content.decode(),\n+ \"Response does not need to be saved.\"\n+ )\n+\n+ def test_save_empty_attempt_session(self):\n+ new_attempt = {\n+ \"challenge\": \"\",\n+ \"attempt\": \"\",\n+ \"status\": \"\"\n+ }\n+\n+ url = reverse(\"plugging_it_in:save_attempt\")\n+ self.client.post(url, json.dumps(new_attempt), content_type='application/json')\n+\n+ self.assertEqual(\n+ self.client.session['saved_attempts'],\n+ {}\n+ )\n+\n+ def test_save_started_attempt_response(self):\n+ new_attempt = {\n+ \"challenge\": \"test_challenge\",\n+ \"attempt\": \"print('Hello World')\",\n+ \"status\": \"started\"\n+ }\n+\n+ url = reverse(\"plugging_it_in:save_attempt\")\n+ response = self.client.post(url, json.dumps(new_attempt), content_type='application/json')\n+\n+ self.assertEqual(\n+ response.content.decode(),\n+ \"Saved the attempt.\"\n+ )\n+\n+ def test_save_started_attempt_session(self):\n+ new_attempt = {\n+ \"challenge\": \"test_challenge\",\n+ \"attempt\": \"print('Hello World')\",\n+ \"status\": \"started\"\n+ }\n+\n+ url = reverse(\"plugging_it_in:save_attempt\")\n+ self.client.post(url, json.dumps(new_attempt), content_type='application/json')\n+\n+ self.assertEqual(\n+ self.client.session['saved_attempts']['test_challenge'],\n+ {\n+ \"status\": \"started\",\n+ \"code\": \"print('Hello World')\"\n+ }\n+ )\n+\n+ def test_save_started_attempt_following_passed_attempt_response(self):\n+ first_attempt = {\n+ \"challenge\": \"test_challenge\",\n+ \"attempt\": \"print('Hello World')\",\n+ \"status\": \"passed\"\n+ }\n+\n+ second_attempt = {\n+ \"challenge\": \"test_challenge\",\n+ \"attempt\": \"print('Hello World')\",\n+ \"status\": \"started\"\n+ }\n+\n+ url = reverse(\"plugging_it_in:save_attempt\")\n+\n+ # First save is a passed attempt\n+ self.client.post(url, json.dumps(first_attempt), content_type='application/json')\n+\n+ # Second save is a started attempt\n+ response = self.client.post(url, json.dumps(second_attempt), content_type='application/json')\n+\n+ # The second attempt should not be saved as started since this overrides a passed attempt\n+ self.assertEqual(\n+ response.content.decode(),\n+ \"Response does not need to be saved.\"\n+ )\n+\n+ def test_save_started_attempt_following_passed_attempt_session(self):\n+ first_attempt = {\n+ \"challenge\": \"test_challenge\",\n+ \"attempt\": \"print('Hello World')\",\n+ \"status\": \"passed\"\n+ }\n+\n+ second_attempt = {\n+ \"challenge\": \"test_challenge\",\n+ \"attempt\": \"print('Hello World')\",\n+ \"status\": \"started\"\n+ }\n+\n+ url = reverse(\"plugging_it_in:save_attempt\")\n+\n+ # First save is a passed attempt\n+ self.client.post(url, json.dumps(first_attempt), content_type='application/json')\n+\n+ # Second save is a started attempt\n+ self.client.post(url, json.dumps(second_attempt), content_type='application/json')\n+\n+ # The first attempt should be retained since it has been checked\n+ self.assertEqual(\n+ self.client.session['saved_attempts']['test_challenge'],\n+ {\n+ \"status\": \"passed\",\n+ \"code\": \"print('Hello World')\"\n+ }\n+ )\n" } ]
Python
MIT License
uccser/cs-unplugged
Add unit tests for plugging it in views (unfinished)
701,848
15.09.2020 14:34:37
-43,200
7296cdaf0adb30100eb28646d7ff3e5631a5c6ed
Fix TestCase ID assertion Fixes: test_programming_challenge_related_test_cases
[ { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/models/test_programming_challenge.py", "new_path": "csunplugged/tests/topics/models/test_programming_challenge.py", "diff": "@@ -52,13 +52,13 @@ class ProgrammingChallengeModelTest(BaseTestWithDB):\ntopic = self.test_data.create_topic(1)\ndifficulty = self.test_data.create_difficulty_level(1)\nchallenge = self.test_data.create_programming_challenge(topic, 1, difficulty)\n- self.test_data.create_programming_challenge_test_case(\n+ test_case = self.test_data.create_programming_challenge_test_case(\n1,\nchallenge\n)\nself.assertQuerysetEqual(\nProgrammingChallenge.objects.get(slug=\"challenge-1\").related_test_cases(),\n[\n- \"<TestCase: TestCase object (1)>\",\n+ f\"<TestCase: TestCase object ({test_case.pk})>\",\n]\n)\n" } ]
Python
MIT License
uccser/cs-unplugged
Fix TestCase ID assertion Fixes: test_programming_challenge_related_test_cases
701,848
15.09.2020 19:33:25
-43,200
ba3abd56e60c49b47f3fec42ec3ae791369008e9
Fix plugging it in programming_challenge_view tests. Added in 3 commented out assertion statements for view contexts
[ { "change_type": "MODIFY", "old_path": "csunplugged/plugging_it_in/views.py", "new_path": "csunplugged/plugging_it_in/views.py", "diff": "@@ -145,8 +145,8 @@ class ProgrammingChallengeView(generic.DetailView):\ncontext[\"implementations\"] = self.object.ordered_implementations()\n- related_test_cases = self.object.related_test_cases().values()\n- context[\"test_cases_json\"] = json.dumps(list(related_test_cases))\n+ related_test_cases = self.object.related_test_cases()\n+ context[\"test_cases_json\"] = json.dumps(list(related_test_cases.values()))\ncontext[\"test_cases\"] = related_test_cases\ncontext[\"jobe_proxy_url\"] = reverse('plugging_it_in:jobe_proxy')\ncontext[\"saved_attempts\"] = self.request.session.get('saved_attempts', {})\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/tests/plugging_it_in/views/test_programming_challenge_view.py", "new_path": "csunplugged/tests/plugging_it_in/views/test_programming_challenge_view.py", "diff": "+import json\n+\nfrom http import HTTPStatus\nfrom django.urls import reverse\nfrom tests.BaseTestWithDB import BaseTestWithDB\n@@ -206,22 +208,14 @@ class ProgrammingChallengeViewTest(BaseTestWithDB):\nurl = reverse(\"plugging_it_in:programming_challenge\", kwargs=kwargs)\nresponse = self.client.get(url)\n- # TODO - assert the json context\n- # Should only return the first challenge with the python language\n- # Not sure how to assert this - the challenge object doesn't seem to become json easily\n- # This is returned [{\"topic_id\": 15, \"id\": 18, \"slug\": \"cha[259 chars]1\"}]\n- # If acheiving this statically is also difficult as finding the topic id...\n- # self.assertEqual(\n- # response.context[\"programming_exercises_json\"],\n- # {\"slug\": self.challenge.slug,\n- # \"difficulty_id\": self.difficulty.id,\n- # \"languages\": [\"python\"]\n- # }\n- # )\n+ self.assertEqual(\n+ response.context[\"programming_exercises_json\"],\n+ json.dumps(list(self.lesson.retrieve_related_programming_challenges(\"Python\").values()))\n+ )\ndef test_programming_challenge_view_test_cases_context(self):\nself.create_challenge()\n- self.test_data.create_programming_challenge_test_case(\n+ test_case = self.test_data.create_programming_challenge_test_case(\n1,\nself.challenge\n)\n@@ -233,14 +227,12 @@ class ProgrammingChallengeViewTest(BaseTestWithDB):\nurl = reverse(\"plugging_it_in:programming_challenge\", kwargs=kwargs)\nresponse = self.client.get(url)\n- # TODO: this returns the test cases queryset values() - its in a weird semi json format...\n- # Perhaps it can be done such that the testcases are returned and the values are only used when creating the json version\n- # self.assertQuerysetEqual(\n- # response.context[\"test_cases\"],\n- # [\n- # \"<TestCase: TestCase object (1)>\",\n- # ]\n- # )\n+ self.assertQuerysetEqual(\n+ response.context[\"test_cases\"],\n+ [\n+ f\"<TestCase: TestCase object ({test_case.pk})>\",\n+ ]\n+ )\ndef test_programming_challenge_view_test_cases_json_context(self):\nself.create_challenge()\n@@ -251,6 +243,7 @@ class ProgrammingChallengeViewTest(BaseTestWithDB):\ntest_test_case.question_type = \"input\"\ntest_test_case.expected_input = \"test_input\"\ntest_test_case.expected_output = \"test_output\"\n+ test_test_case.save()\nkwargs = {\n\"topic_slug\": self.topic.slug,\n@@ -260,12 +253,10 @@ class ProgrammingChallengeViewTest(BaseTestWithDB):\nurl = reverse(\"plugging_it_in:programming_challenge\", kwargs=kwargs)\nresponse = self.client.get(url)\n- # TODO: the get related test cases uses select_related not sure if this is needed.\n- # This will get rid of number and languages I'd imagine. Thinking a query will need to be made to get the challenge and test case ids.\n- # self.assertQuerysetEqual(\n- # response.context[\"test_cases_json\"],\n- # [{\"id\": \"?\", \"languages\": [], \"number\": 1, \"test_input\": \"test_input\", \"expected_output\": \"test_output\", \"question_type\": \"input\", \"challenge_id\": \"?\"}]\n- # )\n+ self.assertEqual(\n+ response.context[\"test_cases_json\"],\n+ json.dumps(list(self.challenge.related_test_cases().values()))\n+ )\ndef test_programming_challenge_view_jobe_proxy_url_context(self):\nself.create_challenge()\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/tests/plugging_it_in/views/test_save_attempt_view.py", "new_path": "csunplugged/tests/plugging_it_in/views/test_save_attempt_view.py", "diff": "import json\n-from http import HTTPStatus\nfrom django.urls import reverse\nfrom tests.BaseTestWithDB import BaseTestWithDB\nfrom tests.topics.TopicsTestDataGenerator import TopicsTestDataGenerator\n" } ]
Python
MIT License
uccser/cs-unplugged
Fix plugging it in programming_challenge_view tests. - Added in 3 commented out assertion statements for view contexts
701,848
16.09.2020 20:49:03
-43,200
fb856f6ad05dfb0778e9a9f1b614a0c96ea58b26
Add jobe proxy test for plugging it in
[ { "change_type": "MODIFY", "old_path": "csunplugged/tests/plugging_it_in/views/test_jobe_proxy_view.py", "new_path": "csunplugged/tests/plugging_it_in/views/test_jobe_proxy_view.py", "diff": "+import json\n+from unittest import mock\n+\n+from django.urls import reverse\nfrom tests.BaseTestWithDB import BaseTestWithDB\n-from tests.topics.TopicsTestDataGenerator import TopicsTestDataGenerator\n-# TODO: No idea how to test this one... more of an integration test really\n+\n+def mocked_requests_post(*args, **kwargs):\n+ class MockResponse:\n+ def __init__(self, text, status_code):\n+ self.text = text\n+ self.status_code = status_code\n+\n+ # Create mock JOBE server response when the api key is set to 'mockapikey'\n+ if args[0] == 'http://mockjobeserver/jobe/index.php/restapi/runs/' \\\n+ and 'X-API-KEY' in kwargs['headers'] \\\n+ and kwargs['headers']['X-API-KEY'] == 'mockapikey':\n+ return MockResponse('Hello World (with API key)', 200)\n+\n+ # Create a mock JOBE server response when no api key is set\n+ elif args[0] == 'http://mockjobeserver/jobe/index.php/restapi/runs/':\n+ return MockResponse('Hello World', 200)\n+\n+\nclass JobeProxyViewTest(BaseTestWithDB):\ndef __init__(self, *args, **kwargs):\nsuper().__init__(*args, **kwargs)\nself.language = \"en\"\n- self.test_data = TopicsTestDataGenerator()\n- # TODO Finish tests...\n+ def get_test_program_data(self, source_code):\n+ return {\n+ \"run_spec\": {\n+ \"language_id\": \"python3\",\n+ \"sourcefilename\": \"test_program\",\n+ \"sourcecode\": source_code,\n+ \"input\": \"input\"\n+ }\n+ }\n+\n+ @mock.patch('requests.post', side_effect=mocked_requests_post)\n+ def test_valid_jobe_proxy_call(self, mock_post):\n+ test_program_data = self.get_test_program_data(\"print('Hello World')\")\n+\n+ url = reverse(\"plugging_it_in:jobe_proxy\")\n+\n+ # Set the settings variable to call the mock JOBE server\n+ with self.settings(JOBE_SERVER_URL='http://mockjobeserver'):\n+ response = self.client.post(url, json.dumps(test_program_data), content_type='application/json')\n+\n+ # Assert that the function returns the correct response from the mock JOBE server.\n+ self.assertEqual(response.content.decode(), 'Hello World')\n+\n+ @mock.patch('requests.post', side_effect=mocked_requests_post)\n+ def test_valid_jobe_proxy_call_with_api_key(self, mock_post):\n+ test_program_data = self.get_test_program_data(\"print('Hello World') (with API key)\")\n+\n+ url = reverse(\"plugging_it_in:jobe_proxy\")\n+\n+ # Set the settings variable to call the mock JOBE server\n+ with self.settings(JOBE_SERVER_URL='http://mockjobeserver'), self.settings(JOBE_API_KEY='mockapikey'):\n+ response = self.client.post(url, json.dumps(test_program_data), content_type='application/json')\n+\n+ # Assert that the function returns the correct response from the mock JOBE server.\n+ self.assertEqual(response.content.decode(), 'Hello World (with API key)')\n" } ]
Python
MIT License
uccser/cs-unplugged
Add jobe proxy test for plugging it in
701,848
16.09.2020 21:28:04
-43,200
902e4ce0848cc2c3afa7192a85d413ed2919c798
Fix models unit test for plugging it in
[ { "change_type": "MODIFY", "old_path": "csunplugged/tests/plugging_it_in/models/test_testcase.py", "new_path": "csunplugged/tests/plugging_it_in/models/test_testcase.py", "diff": "-from plugging_it_in.models import TestCase\n-\nfrom tests.BaseTestWithDB import BaseTestWithDB\nfrom tests.topics.TopicsTestDataGenerator import TopicsTestDataGenerator\n@@ -15,8 +13,7 @@ class TestCaseModelTest(BaseTestWithDB):\ndifficulty = self.test_data.create_difficulty_level(1)\nchallenge = self.test_data.create_programming_challenge(topic, 1, difficulty)\n- self.test_data.create_programming_challenge_test_case(1, challenge)\n- self.test_case = TestCase.objects.get(id=1)\n+ self.test_case = self.test_data.create_programming_challenge_test_case(1, challenge)\ndef test_testcase_verbose_model_name(self):\nself.create_testcase()\n" } ]
Python
MIT License
uccser/cs-unplugged
Fix models unit test for plugging it in
701,848
21.09.2020 11:44:41
-43,200
1b2105b968b733c0cf0b69f457152766e043780c
Adjusting the lesson retrieval method in the ProgrammingChallengeView.
[ { "change_type": "MODIFY", "old_path": "csunplugged/plugging_it_in/views.py", "new_path": "csunplugged/plugging_it_in/views.py", "diff": "@@ -11,8 +11,10 @@ from django.views import generic\nfrom django.views import View\nfrom django.urls import reverse\nfrom django.conf import settings\n+from django.core.exceptions import ObjectDoesNotExist\nfrom utils.translated_first import translated_first\nfrom utils.group_lessons_by_age import group_lessons_by_age\n+\nfrom topics.models import (\nTopic,\nProgrammingChallenge,\n@@ -130,17 +132,15 @@ class ProgrammingChallengeView(generic.DetailView):\ncontext = super(ProgrammingChallengeView, self).get_context_data(**kwargs)\ncontext[\"topic\"] = self.object.topic\n- lessons = self.object.lessons.all()\n- found = False\n- for lesson in lessons:\n- if lesson.slug == self.kwargs.get(\"lesson_slug\", None):\n- found = True\n+\n+ try:\n+ lesson_slug = self.kwargs.get(\"lesson_slug\", None)\n+ lesson = Lesson.objects.get(slug=lesson_slug)\ncontext[\"lesson\"] = lesson\nchalllenges = lesson.retrieve_related_programming_challenges(\"Python\")\ncontext[\"programming_challenges\"] = challlenges\ncontext[\"programming_exercises_json\"] = json.dumps(list(challlenges.values()))\n-\n- if not found:\n+ except ObjectDoesNotExist:\nraise Http404(\"Lesson does not exist\")\ncontext[\"implementations\"] = self.object.ordered_implementations()\n" } ]
Python
MIT License
uccser/cs-unplugged
Adjusting the lesson retrieval method in the ProgrammingChallengeView.
701,849
21.10.2020 13:58:21
-46,800
f2c469b572e4806dace39192613448253c832ed2
use django docs method for csrf token
[ { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "{% endblock body_container %}\n{% block scripts %}\n+ {% csrf_token %}\n<script type=\"text/javascript\">\nlet current_challenge_slug = '{{ programming_challenge.slug }}';\nlet test_cases = {{ test_cases_json|safe }};\nlet programming_exercises = {{ programming_exercises_json|safe }};\nlet lesson_url = \"{% url 'plugging_it_in:lesson' topic.slug lesson.slug %}\";\n- let csrf_token = '{{ csrf_token }}';\n+ let csrf_token = jQuery(\"[name=csrfmiddlewaretoken]\").val();\nlet jobe_proxy_url = '{{ jobe_proxy_url }}';\nlet save_attempt_url = \"{% url 'plugging_it_in:save_attempt' %}\"\n</script>\n" } ]
Python
MIT License
uccser/cs-unplugged
use django docs method for csrf token
701,850
13.08.2021 14:11:36
-43,200
133e76349a199fab63a71e13b9a9c8cb28236417
Added an interactive Blockly editor. Can run blockly program in the browser (converted to JS firs), can send blockly program to the jobe server (converted to Python first). and can also download the python version of the blockly program. Have also added 'Recommended Blocks' if the Blockly editor is getting shown.
[ { "change_type": "MODIFY", "old_path": "csunplugged/package.json", "new_path": "csunplugged/package.json", "diff": "\"browserify\": \"17.0.0\",\n\"child_process\": \"1.0.2\",\n\"codemirror\": \"5.61.0\",\n+ \"blockly\": \"6.20210701.0\",\n\"cssnano\": \"4.1.10\",\n\"details-element-polyfill\": \"2.4.0\",\n\"fancy-log\": \"1.3.3\",\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/plugging_it_in/views.py", "new_path": "csunplugged/plugging_it_in/views.py", "diff": "@@ -134,10 +134,19 @@ class ProgrammingChallengeView(generic.DetailView):\ncontext[\"topic\"] = self.object.topic\ntry:\n+ programming_lang_slug = self.kwargs.get(\"programming_lang_slug\", None)\n+ context[\"programming_lang\"] = programming_lang_slug.lower() # make sure the /python or /block-based is lower case, because this will get checked in the programming.\n+\nlesson_slug = self.kwargs.get(\"lesson_slug\", None)\nlesson = Lesson.objects.get(slug=lesson_slug)\ncontext[\"lesson\"] = lesson\n+\n+ # Get Python challenges if programming_lang_slug == 'python' else get Block-based challanges\n+ if (programming_lang_slug == \"python\"):\nchalllenges = lesson.retrieve_related_programming_challenges(\"Python\")\n+ else:\n+ challlenges = lesson.retrieve_related_programming_challenges(\"Block-based\")\n+\ncontext[\"programming_challenges\"] = challlenges\ncontext[\"programming_exercises_json\"] = json.dumps(list(challlenges.values()))\nexcept ObjectDoesNotExist:\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/static/js/editor-options-menu.js", "new_path": "csunplugged/static/js/editor-options-menu.js", "diff": "@@ -31,11 +31,12 @@ function getCurrentIndex() {\n* Gets the link to the next challenge if it is not the last challenge.\n*/\nfunction getNextChallengeURL() {\n+ console.log(programming_exercises)\nconst index = getCurrentIndex();\nif (index !== programming_exercises.length-1) {\nconst nextLesson = programming_exercises[index+1];\n- return nextLessonUrl = lesson_url + nextLesson.slug;\n+ return nextLessonUrl = lesson_url + nextLesson.slug + \"/\" + programming_lang;\n}\nreturn '#'\n@@ -49,7 +50,7 @@ function getPreviousChallengeURL() {\nif (index !== 0) {\nconst prevLesson = programming_exercises[index-1];\n- return prevLessonUrl = lesson_url + prevLesson.slug;\n+ return prevLessonUrl = lesson_url + prevLesson.slug + \"/\" + programming_lang;\n}\nreturn \"#\"\n@@ -77,6 +78,8 @@ function setupLessonNav() {\n// Hides the next/prev challenge buttons if there is no challenge available in that direction.\nconst index = getCurrentIndex();\n+ console.log(\"INDEX\")\n+ console.log(index);\nif (index === programming_exercises.length-1) {\n$(\"#next_challenge_button\").find('button').hide()\n}\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "const codeTester = require(\"./test-code.js\");\nconst editorUtils = require(\"./editor-options-menu.js\")\n+// Python editor imports\nvar CodeMirror = require(\"codemirror\");\nrequire(\"codemirror/mode/python/python.js\");\n-// Set up code mirror editor\n+// Blockly editor imports\n+const Blockly = require('blockly/core');\n+require('blockly/blocks');\n+require('blockly/python');\n+require('blockly/javascript');\n+const En = require('blockly/msg/en');\n+Blockly.setLocale(En);\n+\n+// Has to be global as other functions are using these variables\n+let myCodeMirror;\n+let workspace;\n+// Set up code mirror or blockly editor depending what programming_lang is from URL (/python or /block-based)\n+if (programming_lang == \"python\") {\nlet myTextarea = document.getElementById(\"codemirror_editor\");\n-let myCodeMirror = CodeMirror.fromTextArea(myTextarea, {\n+ myCodeMirror = CodeMirror.fromTextArea(myTextarea, {\nmode: {\nname: \"python\",\nversion: 3,\n@@ -28,14 +41,58 @@ let myCodeMirror = CodeMirror.fromTextArea(myTextarea, {\n}\n});\n+} else {\n+ // Set up blockly editor\n+ document.addEventListener(\"DOMContentLoaded\", function () {\n+ const toolbox = document.getElementById('toolbox');\n+ /* Workspace configurations */\n+ const options = {\n+ toolbox : toolbox,\n+ collapse : true,\n+ comments : true,\n+ disable : true,\n+ maxBlocks : Infinity,\n+ trashcan : true,\n+ horizontalLayout : false,\n+ toolboxPosition : 'start',\n+ css : true,\n+ media : 'https://blockly-demo.appspot.com/static/media/',\n+ rtl : false,\n+ scrollbars : true,\n+ sounds : true,\n+ oneBasedIndex : true,\n+ zoom : {\n+ controls : true,\n+ wheel : true,\n+ startScale : 1,\n+ maxScale : 3,\n+ minScale : 0.3,\n+ scaleSpeed : 1.2\n+ }\n+ };\n+ /* Injects the blockly workspace */\n+ workspace = Blockly.inject('blocklyDiv', options);\n+ })\n+}\n+\n/**\n* Retrieves code from the code mirror editor, runs all the test cases then updates the results table.\n* Disables the \"CHECK\" button and shows a loading spinner while request is being processed.\n*/\nfunction sendCodeToJobe() {\n+ let code = '';\n+ if (programming_lang == 'python') {\n// Replaces all user input parameters to be blank so it matches the expected output\n// Takes into consideration cases input(\"thing)\"), input('thing)'), input(thing) and int(input(thing))\n- let code = myCodeMirror.getValue().replace(/(input\\(\"[^\"]+\"\\)|input\\('[^']+'\\)|input\\([^)]+\\))/mg, 'input()');\n+ code = myCodeMirror.getValue().replace(/(input\\(\"[^\"]+\"\\)|input\\('[^']+'\\)|input\\([^)]+\\))/mg, 'input()');\n+ } else {\n+ // converts Blockly-code to Python\n+ const lang = 'Python';\n+ code = Blockly[lang].workspaceToCode(workspace);\n+ }\n+\n+ console.log(\"SEND CODE TO JOBE\")\n+ console.log(code)\n$(\"#editor_run_button\").prop(\"disabled\", true);\n$(\".code_running_spinner\").css(\"display\", \"inline-block\");\n@@ -71,8 +128,14 @@ function allCorrect(results) {\n* @param {String} status If the user has Started, Passed or Failed the challenge.\n*/\nasync function save_code(status=\"started\") {\n- let raw_code = myCodeMirror.getValue();\n-\n+ let raw_code;\n+ if (programming_lang == \"python\") {\n+ raw_code = myCodeMirror.getValue();\n+ } else {\n+ raw_code = Blockly.Xml.workspaceToDom(Blockly.getMainWorkspace());\n+ }\n+ console.log(\"RAW CODE\")\n+ console.log(raw_code)\n// Sets the saved attempt\nlet data = {\n\"challenge\": current_challenge_slug,\n@@ -100,6 +163,7 @@ async function save_code(status=\"started\") {\n*/\nfunction updateResultsTable(results) {\nfor (result of results) {\n+ console.log(result)\n// Update status cell\n$(`#test-case-${result.id}-status`).text(result.status);\n@@ -153,15 +217,43 @@ function download(filename, text) {\n* Downloads the editor code to a file called <current_challenge_slug>.py.\n*/\nfunction downloadCode() {\n- download(current_challenge_slug + \".py\", myCodeMirror.getValue());\n+ let code;\n+ if (programming_lang == \"python\") {\n+ code = myCodeMirror.getValue()\n+ } else {\n+ const lang = 'Python'\n+ code = Blockly[lang].workspaceToCode(workspace);\n+ }\n+ download(current_challenge_slug + \".py\", code);\n+ }\n+\n+/**\n+ * Retrieves the code from the blockly editor, converts it to JavaScript, runs the code.\n+ */\n+function runCode() {\n+ // Convert blockly code to JavaScript\n+ const lang = 'JavaScript'\n+ const code = Blockly[lang].workspaceToCode(workspace);\n+\n+ console.log(code);\n+\n+ // Run JavaScript code\n+ try {\n+ eval(code);\n+ } catch (error) {\n+ console.log(error);\n+ }\n}\n// Setting up event listener for the check button to run the code.\n-$(\"#editor_run_button\").click(sendCodeToJobe);\n+$(\"#editor_check_button\").click(sendCodeToJobe);\n// Setting up event listener for the download button.\n$(\"#download_button\").click(downloadCode);\n+// Setting up event listener for the run button to run the code\n+$(\"#blockly_editor_run_program_button\").click(runCode);\n+\n// Apply the navigation setup\neditorUtils.setupLessonNav()\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "<p class='challenges-heading'>{% trans \"Challenges\" %}</p>\n<ol class='challenges-list'>\n{% for programming_challenge_item in programming_challenges %}\n- <a href=\"{% url 'plugging_it_in:programming_challenge' topic.slug lesson.slug programming_challenge_item.slug %}\">\n+ <a href=\"{% url 'plugging_it_in:programming_challenge' topic.slug lesson.slug programming_challenge_item.slug programming_lang %}\">\n<li class=\"{% if programming_challenge.slug == programming_challenge_item.slug %}current-exercise{% endif %} row\">\n<div class='row'>\n<div class='nav-row-info col-10 d-flex'>\n{% render_html_field programming_challenge.content %}\n- {% comment %} Challenge Hints {% endcomment %}\n{% for implementation in implementations %}\n- {% if implementation.language.name == \"Python\" and implementation.hints %}\n+ {% comment %} Displays the hints/programming reminders or recommended blocks accordingly to what programming_lang is (e.g., python or block-based) {% endcomment %}\n+ {% comment %} Challenge Hints {% endcomment %}\n+ {% if implementation.language.name == programming_lang|capfirst and implementation.hints %}\n<details>\n<summary>\n<strong>\n{% endif %}\n{% comment %} Programming syntax reminders {% endcomment %}\n- {% if implementation.language.name == \"Python\" and implementation.language.programming_reminders %}\n+ {% if implementation.language.name == programming_lang|capfirst and implementation.language.programming_reminders %}\n<details>\n<summary>\n<strong>{% trans \"Programming Reminders\" %}</strong>\n</div>\n</details>\n{% endif %}\n+\n+ {% comment %} Recommended blocks {% endcomment %}\n+ {% if implementation.language.name != 'Python' and implementation.language.name == programming_lang|capfirst and implementation.expected_result %}\n+ <details>\n+ <summary>\n+ <strong>{% trans \"Recommended Blocks\" %}</strong>\n+ </summary>\n+ <div class=\"boxed-text-content\">\n+ {% render_html_field implementation.expected_result %}\n+ </div>\n+ </details>\n+ {% endif %}\n{% endfor %}\n</div>\n</div>\n+\n+ {% comment %} Display the Python editor or the Blockly editor {% endcomment %}\n+ {% if programming_lang == 'python' %}\n<div class=\"col-12 col-md-4 programming__editor\">\n<p class='pii-block-heading'>{% trans \"Enter your code in the editor below\" %}</p>\n<textarea id=\"codemirror_editor\">{{ previous_submission|safe }}</textarea>\n<div class=\"programming__submit d-flex justify-content-between align-items-center\">\n<div class=\"programming__submit_options d-flex justify-content-start\">\n- <button class=\"editor_button\" id=\"editor_run_button\" >{% trans \"Check\" %}</button>\n+ <button class=\"editor_button\" id=\"editor_check_button\" >{% trans \"Check\" %}</button>\n<button class=\"editor_button\" id=\"download_button\" >{% trans \"Download\" %}</button>\n</div>\n<div class=\"code_running_spinner spinner-grow\" role=\"status\">\n<button id=\"introjs-walkthrough\" class=\"btn btn-outline-secondary btn-sm col-6 offset-6 my-2\">{% trans \"How does this page work?\" %}</button>\n</div>\n</div>\n+\n+ {% else %}\n+ <div class=\"col-12 col-md-5 programming__editor\">\n+ <p class='pii-block-heading'>{% trans \"Create your program in the editor below\" %}</p>\n+ <div id=\"blocklyDiv\" style=\"height: 100%; \"></div>\n+ <xml xmlns=\"https://developers.google.com/blockly/xml\" id=\"toolbox\" style=\"display: none\">\n+ <category name=\"Control\" colour=\"#a5745b\">\n+ <block type=\"controls_if\"></block>\n+ <block type=\"logic_compare\">\n+ <field name=\"OP\">EQ</field>\n+ </block>\n+ <block type=\"logic_operation\">\n+ <field name=\"OP\">AND</field>\n+ </block>\n+ <block type=\"logic_negate\"></block>\n+ <block type=\"logic_boolean\">\n+ <field name=\"BOOL\">TRUE</field>\n+ </block>\n+ <block type=\"logic_null\"></block>\n+ <block type=\"logic_ternary\"></block>\n+ <block type=\"controls_repeat_ext\">\n+ <value name=\"TIMES\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">10</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"controls_whileUntil\">\n+ <field name=\"MODE\">WHILE</field>\n+ </block>\n+ <block type=\"controls_for\">\n+ <field name=\"VAR\" id=\"syHPajql$jowW`$n$n=|\">i</field>\n+ <value name=\"FROM\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">1</field>\n+ </shadow>\n+ </value>\n+ <value name=\"TO\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">10</field>\n+ </shadow>\n+ </value>\n+ <value name=\"BY\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">1</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"controls_forEach\">\n+ <field name=\"VAR\" id=\"io+yhc[K+dO04I0!FEx;\">j</field>\n+ </block>\n+ <block type=\"controls_flow_statements\" disabled=\"true\">\n+ <field name=\"FLOW\">BREAK</field>\n+ </block>\n+ </category>\n+ <category name=\"Math\" colour=\"#5b67a5\">\n+ <block type=\"math_number\">\n+ <field name=\"NUM\">0</field>\n+ </block>\n+ <block type=\"math_arithmetic\">\n+ <field name=\"OP\">ADD</field>\n+ <value name=\"A\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">1</field>\n+ </shadow>\n+ </value>\n+ <value name=\"B\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">1</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"math_single\">\n+ <field name=\"OP\">ROOT</field>\n+ <value name=\"NUM\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">9</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"math_trig\">\n+ <field name=\"OP\">SIN</field>\n+ <value name=\"NUM\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">45</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"math_constant\">\n+ <field name=\"CONSTANT\">PI</field>\n+ </block>\n+ <block type=\"math_number_property\">\n+ <mutation divisor_input=\"false\"></mutation>\n+ <field name=\"PROPERTY\">EVEN</field>\n+ <value name=\"NUMBER_TO_CHECK\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">0</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"math_round\">\n+ <field name=\"OP\">ROUND</field>\n+ <value name=\"NUM\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">3.1</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"math_on_list\">\n+ <mutation op=\"SUM\"></mutation>\n+ <field name=\"OP\">SUM</field>\n+ </block>\n+ <block type=\"math_modulo\">\n+ <value name=\"DIVIDEND\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">64</field>\n+ </shadow>\n+ </value>\n+ <value name=\"DIVISOR\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">10</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"math_constrain\">\n+ <value name=\"VALUE\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">50</field>\n+ </shadow>\n+ </value>\n+ <value name=\"LOW\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">1</field>\n+ </shadow>\n+ </value>\n+ <value name=\"HIGH\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">100</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"math_random_int\">\n+ <value name=\"FROM\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">1</field>\n+ </shadow>\n+ </value>\n+ <value name=\"TO\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">100</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"math_random_float\"></block>\n+ </category>\n+ <category name=\"Text\" colour=\"#5ba58c\">\n+ <block type=\"text\">\n+ <field name=\"TEXT\"></field>\n+ </block>\n+ <block type=\"text_join\">\n+ <mutation items=\"2\"></mutation>\n+ </block>\n+ <block type=\"text_append\">\n+ <field name=\"VAR\" id=\":L5gSy]ul/r[,B_5!/t8\">item</field>\n+ <value name=\"TEXT\">\n+ <shadow type=\"text\">\n+ <field name=\"TEXT\"></field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"text_length\">\n+ <value name=\"VALUE\">\n+ <shadow type=\"text\">\n+ <field name=\"TEXT\">abc</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"text_isEmpty\">\n+ <value name=\"VALUE\">\n+ <shadow type=\"text\">\n+ <field name=\"TEXT\"></field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"text_indexOf\">\n+ <field name=\"END\">FIRST</field>\n+ <value name=\"VALUE\">\n+ <block type=\"variables_get\">\n+ <field name=\"VAR\" id=\"x,Zl7o=OyFqu`9w_v7A+\">text</field>\n+ </block>\n+ </value>\n+ <value name=\"FIND\">\n+ <shadow type=\"text\">\n+ <field name=\"TEXT\">abc</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"text_charAt\">\n+ <mutation at=\"true\"></mutation>\n+ <field name=\"WHERE\">FROM_START</field>\n+ <value name=\"VALUE\">\n+ <block type=\"variables_get\">\n+ <field name=\"VAR\" id=\"x,Zl7o=OyFqu`9w_v7A+\">text</field>\n+ </block>\n+ </value>\n+ </block>\n+ <block type=\"text_getSubstring\">\n+ <mutation at1=\"true\" at2=\"true\"></mutation>\n+ <field name=\"WHERE1\">FROM_START</field>\n+ <field name=\"WHERE2\">FROM_START</field>\n+ <value name=\"STRING\">\n+ <block type=\"variables_get\">\n+ <field name=\"VAR\" id=\"x,Zl7o=OyFqu`9w_v7A+\">text</field>\n+ </block>\n+ </value>\n+ </block>\n+ <block type=\"text_changeCase\">\n+ <field name=\"CASE\">UPPERCASE</field>\n+ <value name=\"TEXT\">\n+ <shadow type=\"text\">\n+ <field name=\"TEXT\">abc</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"text_trim\">\n+ <field name=\"MODE\">BOTH</field>\n+ <value name=\"TEXT\">\n+ <shadow type=\"text\">\n+ <field name=\"TEXT\">abc</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"text_print\">\n+ <value name=\"TEXT\">\n+ <shadow type=\"text\">\n+ <field name=\"TEXT\">abc</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"text_prompt_ext\">\n+ <mutation type=\"TEXT\"></mutation>\n+ <field name=\"TYPE\">TEXT</field>\n+ <value name=\"TEXT\">\n+ <shadow type=\"text\">\n+ <field name=\"TEXT\">abc</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ </category>\n+ <category name=\"Lists\" colour=\"#745ba5\">\n+ <block type=\"lists_create_with\">\n+ <mutation items=\"0\"></mutation>\n+ </block>\n+ <block type=\"lists_create_with\">\n+ <mutation items=\"3\"></mutation>\n+ </block>\n+ <block type=\"lists_repeat\">\n+ <value name=\"NUM\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">5</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"lists_length\"></block>\n+ <block type=\"lists_isEmpty\"></block>\n+ <block type=\"lists_indexOf\">\n+ <field name=\"END\">FIRST</field>\n+ <value name=\"VALUE\">\n+ <block type=\"variables_get\">\n+ <field name=\"VAR\" id=\"l?1Ne_YoM!bxpl#M5CKY\">list</field>\n+ </block>\n+ </value>\n+ </block>\n+ <block type=\"lists_getIndex\">\n+ <mutation statement=\"false\" at=\"true\"></mutation>\n+ <field name=\"MODE\">GET</field>\n+ <field name=\"WHERE\">FROM_START</field>\n+ <value name=\"VALUE\">\n+ <block type=\"variables_get\">\n+ <field name=\"VAR\" id=\"l?1Ne_YoM!bxpl#M5CKY\">list</field>\n+ </block>\n+ </value>\n+ </block>\n+ <block type=\"lists_setIndex\">\n+ <mutation at=\"true\"></mutation>\n+ <field name=\"MODE\">SET</field>\n+ <field name=\"WHERE\">FROM_START</field>\n+ <value name=\"LIST\">\n+ <block type=\"variables_get\">\n+ <field name=\"VAR\" id=\"l?1Ne_YoM!bxpl#M5CKY\">list</field>\n+ </block>\n+ </value>\n+ </block>\n+ <block type=\"lists_getSublist\">\n+ <mutation at1=\"true\" at2=\"true\"></mutation>\n+ <field name=\"WHERE1\">FROM_START</field>\n+ <field name=\"WHERE2\">FROM_START</field>\n+ <value name=\"LIST\">\n+ <block type=\"variables_get\">\n+ <field name=\"VAR\" id=\"l?1Ne_YoM!bxpl#M5CKY\">list</field>\n+ </block>\n+ </value>\n+ </block>\n+ <block type=\"lists_split\">\n+ <mutation mode=\"SPLIT\"></mutation>\n+ <field name=\"MODE\">SPLIT</field>\n+ <value name=\"DELIM\">\n+ <shadow type=\"text\">\n+ <field name=\"TEXT\">,</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"lists_sort\">\n+ <field name=\"TYPE\">NUMERIC</field>\n+ <field name=\"DIRECTION\">1</field>\n+ </block>\n+ </category>\n+ <sep></sep>\n+ <category name=\"Variables\" colour=\"#a55b80\" custom=\"VARIABLE\"></category>\n+ </xml>\n+ <div class=\"programming__submit d-flex justify-content-between align-items-center\">\n+ <div class=\"programming__submit_options d-flex justify-content-start\">\n+ <button class=\"editor_button\" id=\"blockly_editor_run_program_button\" >{% trans \"Run\" %}</button>\n+ <button class=\"editor_button\" id=\"editor_check_button\" >{% trans \"Check\" %}</button>\n+ <button class=\"editor_button\" id=\"download_button\" >{% trans \"Download\" %}</button>\n+ </div>\n+ <div class=\"code_running_spinner spinner-grow\" role=\"status\">\n+ <span class=\"sr-only\"></span>\n+ </div>\n+ </div>\n+ </div>\n+\n+ <div class=\"col-12 col-md-3 programming__results\">\n+ <p class=\"pii-block-heading d-inline\">{% trans \"Your results will be displayed here\" %}</p>\n+ {% include \"plugging_it_in/results-table.html\" %}\n+ <div id=\"walkthrough-btn-container\" class=\"row\">\n+ <button id=\"introjs-walkthrough\" class=\"btn btn-outline-secondary btn-sm col-6 offset-6 my-2\">{% trans \"How does this page work?\" %}</button>\n+ </div>\n+ </div>\n+ {% endif %}\n{% else %}\n<div class=\"col-md-6 offset-md-3 justify-content-center mt-3\">\n{% with model=programming_challenge parent=topic homepage='plugging_it_in:index' %}\nlet csrf_token = '{{ csrf_token }}';\nlet jobe_proxy_url = '{{ jobe_proxy_url }}';\nlet save_attempt_url = \"{% url 'plugging_it_in:save_attempt' %}\"\n+ let programming_lang = \"{{ programming_lang }}\"\n</script>\n<script src=\"{% static 'js/jobe-editor.js' %}\"></script>\n" } ]
Python
MIT License
uccser/cs-unplugged
Added an interactive Blockly editor. Can run blockly program in the browser (converted to JS firs), can send blockly program to the jobe server (converted to Python first). and can also download the python version of the blockly program. Have also added 'Recommended Blocks' if the Blockly editor is getting shown.
701,850
13.08.2021 16:08:30
-43,200
25e0e20d1ae0519085bce935f3050d64a3abd64e
Added saved functionality for Blockly coding attempt. Blockly attempt and Python attempt for the same question are also saved separately.
[ { "change_type": "MODIFY", "old_path": "csunplugged/plugging_it_in/views.py", "new_path": "csunplugged/plugging_it_in/views.py", "diff": "@@ -204,13 +204,15 @@ class SaveAttemptView(View):\nrequest.session['saved_attempts'] = request.session.get('saved_attempts', {})\n# To stop a \"passed\" or \"failed\" status being overridden by \"started\"\n+ # Saves the python attempt and blockly attempt in different places for the same question.\nif (not (body[\"status\"] == \"started\"\nand request.session.get('saved_attempts', {}).get(body[\"challenge\"], {}).get(\"status\", \"\")\nin {'passed', 'failed'})\nand body[\"attempt\"] != \"\"):\n- request.session['saved_attempts'][body[\"challenge\"]] = {\n+ request.session['saved_attempts'][body[\"challenge\"]][body[\"programming_language\"]] = {\n\"status\": body[\"status\"],\n- \"code\": body[\"attempt\"]\n+ \"code\": body[\"attempt\"],\n+ \"programming_language\": body[\"programming_language\"]\n}\nreturn HttpResponse(\"Saved the attempt.\")\nelse:\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "const codeTester = require(\"./test-code.js\");\nconst editorUtils = require(\"./editor-options-menu.js\")\n+const utils = require(\"./utils.js\")\n// Python editor imports\nvar CodeMirror = require(\"codemirror\");\n@@ -72,6 +73,16 @@ if (programming_lang == \"python\") {\n};\n/* Injects the blockly workspace */\nworkspace = Blockly.inject('blocklyDiv', options);\n+\n+ // Displays the user's previous submission\n+ if (previous_submission) {\n+ // Decodes the previous_submission which contains HTML entities. Outputs a string, and it converts it to XML\n+ console.log(\"PREVIOUS SUBMISSIONS\")\n+ console.log(previous_submission)\n+ const xml_node = Blockly.Xml.textToDom(utils.decodeHTMLEntities(previous_submission))\n+\n+ Blockly.Xml.domToWorkspace(xml_node, workspace);\n+ }\n})\n}\n@@ -102,7 +113,7 @@ function sendCodeToJobe() {\nupdateResultsTable(result);\n// Saving the users code\n- save_code(allCorrect(result) ? \"passed\" : \"failed\")\n+ console.log(save_code(allCorrect(result) ? \"passed\" : \"failed\"))\n$(\"#editor_run_button\").prop(\"disabled\", false);\n$(\".code_running_spinner\").css(\"display\", \"none\");\n@@ -132,7 +143,8 @@ async function save_code(status=\"started\") {\nif (programming_lang == \"python\") {\nraw_code = myCodeMirror.getValue();\n} else {\n- raw_code = Blockly.Xml.workspaceToDom(Blockly.getMainWorkspace());\n+ xml_code = Blockly.Xml.workspaceToDom(Blockly.getMainWorkspace());\n+ raw_code = Blockly.Xml.domToText(xml_code);\n}\nconsole.log(\"RAW CODE\")\nconsole.log(raw_code)\n@@ -140,7 +152,8 @@ async function save_code(status=\"started\") {\nlet data = {\n\"challenge\": current_challenge_slug,\n\"attempt\": raw_code,\n- \"status\": status\n+ \"status\": status,\n+ \"programming_language\": programming_lang\n}\n// Saves the code in the django session\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/static/js/utils.js", "diff": "+/**\n+* Takes an encoded HTML entitity and returns a decoded version of it.\n+* @param {string} str\n+* @returns decoded HTML entity\n+*/\n+function decodeHTMLEntities (str) {\n+ let element = document.createElement('div');\n+ if(str && typeof str === 'string') {\n+ // strip script/html tags\n+ str = str.replace(/<script[^>]*>([\\S\\s]*?)<\\/script>/gmi, '');\n+ str = str.replace(/<\\/?\\w(?:[^\"'>]|\"[^\"]*\"|'[^']*')*>/gmi, '');\n+ element.innerHTML = str;\n+ str = element.textContent;\n+ element.textContent = '';\n+ }\n+\n+ return str;\n+}\n+\n+exports.decodeHTMLEntities = decodeHTMLEntities;\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "let jobe_proxy_url = '{{ jobe_proxy_url }}';\nlet save_attempt_url = \"{% url 'plugging_it_in:save_attempt' %}\"\nlet programming_lang = \"{{ programming_lang }}\"\n+ let previous_submission = \"{{ previous_submission }}\"\n</script>\n<script src=\"{% static 'js/jobe-editor.js' %}\"></script>\n" } ]
Python
MIT License
uccser/cs-unplugged
Added saved functionality for Blockly coding attempt. Blockly attempt and Python attempt for the same question are also saved separately.
701,850
14.08.2021 17:47:22
-43,200
69d81d5fe9d6bfb3e2e8e473b80de3eecedaebc6
Fixed problem with code attempt not getting saved properly, and not being retrieved properly. Should be working now.
[ { "change_type": "MODIFY", "old_path": "csunplugged/plugging_it_in/views.py", "new_path": "csunplugged/plugging_it_in/views.py", "diff": "@@ -160,7 +160,8 @@ class ProgrammingChallengeView(generic.DetailView):\ncontext[\"jobe_proxy_url\"] = reverse('plugging_it_in:jobe_proxy')\ncontext[\"saved_attempts\"] = self.request.session.get('saved_attempts', {})\ntry:\n- context[\"previous_submission\"] = context[\"saved_attempts\"][self.object.slug]['code']\n+ # Retrieves either the python or blockly code for a specific question, depending what the value of context[\"programming_lang\"] is\n+ context[\"previous_submission\"] = context[\"saved_attempts\"][self.object.slug][context[\"programming_lang\"]]['code']\nexcept KeyError:\ncontext[\"previous_submission\"] = ''\n@@ -204,11 +205,11 @@ class SaveAttemptView(View):\nrequest.session['saved_attempts'] = request.session.get('saved_attempts', {})\n# To stop a \"passed\" or \"failed\" status being overridden by \"started\"\n- # Saves the python attempt and blockly attempt in different places for the same question.\nif (not (body[\"status\"] == \"started\"\nand request.session.get('saved_attempts', {}).get(body[\"challenge\"], {}).get(\"status\", \"\")\nin {'passed', 'failed'})\nand body[\"attempt\"] != \"\"):\n+ # Saves the python attempt and blockly attempt in different places for the same question.\nrequest.session['saved_attempts'][body[\"challenge\"]][body[\"programming_language\"]] = {\n\"status\": body[\"status\"],\n\"code\": body[\"attempt\"],\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "@@ -113,7 +113,7 @@ function sendCodeToJobe() {\nupdateResultsTable(result);\n// Saving the users code\n- console.log(save_code(allCorrect(result) ? \"passed\" : \"failed\"))\n+ save_code(allCorrect(result) ? \"passed\" : \"failed\")\n$(\"#editor_run_button\").prop(\"disabled\", false);\n$(\".code_running_spinner\").css(\"display\", \"none\");\n" } ]
Python
MIT License
uccser/cs-unplugged
Fixed problem with code attempt not getting saved properly, and not being retrieved properly. Should be working now.
701,850
15.08.2021 03:08:42
-43,200
550960a49ec7c8691c2ec72937b735ed4c4066ed
Started adding custom blocks. Firstly, added a custom modulo block to fix the default remainder block outputting a negative a number instead of a positive number. Added a multiplcation block.
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "@@ -16,6 +16,17 @@ require('blockly/javascript');\nconst En = require('blockly/msg/en');\nBlockly.setLocale(En);\n+// Change default text of default blocks\n+ const CustomEs = {\n+ TEXT_PRINT_TITLE: \"say %1\",\n+ TEXT_JOIN_TITLE_CREATEWITH: \"join\",\n+ TEXT_INDEXOF_TITLE: \"letter %1 %2 %3\",\n+ MATH_RANDOM_INT_TITLE: \"pick random %1 to %2\",\n+ CONTROLS_REPEAT_TITLE: \"repeat %1\",\n+ CONTROLS_FOR_INPUT_DO: \"\"\n+ }\n+ Blockly.setLocale(CustomEs);\n+\n// Has to be global as other functions are using these variables\nlet myCodeMirror;\nlet workspace;\n@@ -45,6 +56,89 @@ if (programming_lang == \"python\") {\n} else {\n// Set up blockly editor\ndocument.addEventListener(\"DOMContentLoaded\", function () {\n+ // Custom Blockly blocks to look and act like Scratch\n+ Blockly.defineBlocksWithJsonArray([\n+ // Custom multiply block\n+ {\n+ \"type\": \"custom_math_multiply\",\n+ \"message0\": \"%1 * %2 %3\",\n+ \"args0\": [\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"x\",\n+ \"check\": \"Number\"\n+ },\n+ {\n+ \"type\": \"input_dummy\"\n+ },\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"y\",\n+ \"check\": \"Number\"\n+ }\n+ ],\n+ \"inputsInline\": true,\n+ \"output\": \"Number\",\n+ \"colour\": 120,\n+ \"tooltip\": \"Return the product of the two numbers.\",\n+ \"helpUrl\": \"\"\n+ },\n+ // Custom modulo block\n+ {\n+ \"type\": \"custom_math_modulo\",\n+ \"message0\": \"%1 mod %2 %3\",\n+ \"args0\": [\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"a\",\n+ \"check\": \"Number\"\n+ },\n+ {\n+ \"type\": \"input_dummy\",\n+ \"align\": \"CENTRE\"\n+ },\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"n\",\n+ \"check\": \"Number\"\n+ }\n+ ],\n+ \"inputsInline\": true,\n+ \"output\": \"Number\",\n+ \"colour\": 230,\n+ \"tooltip\": \"Return the modulo of the two numbers.\",\n+ \"helpUrl\": \"\"\n+ }\n+ ]);\n+\n+ // Custom modulo block\n+ Blockly.JavaScript['custom_math_modulo'] = function(block) {\n+ var value_a = Blockly.JavaScript.valueToCode(block, 'a', Blockly.JavaScript.ORDER_MODULUS);\n+ var value_n = Blockly.JavaScript.valueToCode(block, 'n', Blockly.JavaScript.ORDER_MODULUS);\n+ var code = '(' + value_a + ' % ' + value_n + ' + ' + value_n + ')' + ' % ' + value_a;\n+ return [code, Blockly.JavaScript.ORDER_ADDITION];\n+ };\n+ Blockly.Python['custom_math_modulo'] = function(block) {\n+ var value_a = Blockly.Python.valueToCode(block, 'a', Blockly.Python.ORDER_ATOMIC);\n+ var value_n = Blockly.Python.valueToCode(block, 'n', Blockly.Python.ORDER_ATOMIC);\n+ var code = value_a + ' % ' + value_n;\n+ return [code, Blockly.Python.ORDER_NONE];\n+ };\n+\n+ // Custom multiply block\n+ Blockly.JavaScript['custom_math_multiply'] = function(block) {\n+ var value_x = Blockly.JavaScript.valueToCode(block, 'x', Blockly.JavaScript.ORDER_MULTIPLICATION);\n+ var value_y = Blockly.JavaScript.valueToCode(block, 'y', Blockly.JavaScript.ORDER_MULTIPLICATION);\n+ var code = value_x + ' * ' + value_y;\n+ return [code, Blockly.JavaScript.ORDER_NONE];\n+ };\n+ Blockly.Python['custom_math_multiply'] = function(block) {\n+ var value_x = Blockly.Python.valueToCode(block, 'x', Blockly.Python.ORDER_ATOMIC);\n+ var value_y = Blockly.Python.valueToCode(block, 'y', Blockly.Python.ORDER_ATOMIC);\n+ var code = value_x + ' * ' + value_y;\n+ return [code, Blockly.Python.ORDER_NONE];\n+ };\n+\nconst toolbox = document.getElementById('toolbox');\n/* Workspace configurations */\nconst options = {\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "<field name=\"BOOL\">TRUE</field>\n</block>\n<block type=\"logic_null\"></block>\n- <block type=\"logic_ternary\"></block>\n<block type=\"controls_repeat_ext\">\n<value name=\"TIMES\">\n<shadow type=\"math_number\">\n<field name=\"MODE\">WHILE</field>\n</block>\n<block type=\"controls_for\">\n- <field name=\"VAR\" id=\"syHPajql$jowW`$n$n=|\">i</field>\n+ <field name=\"VAR\" id=\"C~3vhn!z)$kFIgo1uY@@\">i</field>\n<value name=\"FROM\">\n<shadow type=\"math_number\">\n<field name=\"NUM\">1</field>\n</value>\n</block>\n<block type=\"controls_forEach\">\n- <field name=\"VAR\" id=\"io+yhc[K+dO04I0!FEx;\">j</field>\n+ <field name=\"VAR\" id=\"nl]?Fl371yL(iW8S]E47\">j</field>\n</block>\n<block type=\"controls_flow_statements\" disabled=\"true\">\n<field name=\"FLOW\">BREAK</field>\n</block>\n</category>\n- <category name=\"Math\" colour=\"#5b67a5\">\n+ <category name=\"Math\" colour=\"#5ba55b\">\n+ <block type=\"custom_math_multiply\">\n+ <value name=\"x\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">1</field>\n+ </shadow>\n+ </value>\n+ <value name=\"y\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">1</field>\n+ </shadow>\n+ </value>\n+ </block>\n<block type=\"math_number\">\n<field name=\"NUM\">0</field>\n</block>\n<mutation op=\"SUM\"></mutation>\n<field name=\"OP\">SUM</field>\n</block>\n+ <block type=\"custom_math_modulo\">\n+ <value name=\"a\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">-3</field>\n+ </shadow>\n+ </value>\n+ <value name=\"n\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">2</field>\n+ </shadow>\n+ </value>\n+ </block>\n<block type=\"math_modulo\">\n<value name=\"DIVIDEND\">\n<shadow type=\"math_number\">\n</block>\n<block type=\"math_random_float\"></block>\n</category>\n- <category name=\"Text\" colour=\"#5ba58c\">\n+ <category name=\"Text\" colour=\"#745ba5\">\n<block type=\"text\">\n<field name=\"TEXT\"></field>\n</block>\n<mutation items=\"2\"></mutation>\n</block>\n<block type=\"text_append\">\n- <field name=\"VAR\" id=\":L5gSy]ul/r[,B_5!/t8\">item</field>\n+ <field name=\"VAR\" id=\"ORK?8p5REPgQ?Er1F7.D\">item</field>\n<value name=\"TEXT\">\n<shadow type=\"text\">\n<field name=\"TEXT\"></field>\n<field name=\"END\">FIRST</field>\n<value name=\"VALUE\">\n<block type=\"variables_get\">\n- <field name=\"VAR\" id=\"x,Zl7o=OyFqu`9w_v7A+\">text</field>\n+ <field name=\"VAR\" id=\"x2O$~p~Zbcheb3G^q4Du\">text</field>\n</block>\n</value>\n<value name=\"FIND\">\n<field name=\"WHERE\">FROM_START</field>\n<value name=\"VALUE\">\n<block type=\"variables_get\">\n- <field name=\"VAR\" id=\"x,Zl7o=OyFqu`9w_v7A+\">text</field>\n+ <field name=\"VAR\" id=\"x2O$~p~Zbcheb3G^q4Du\">text</field>\n</block>\n</value>\n</block>\n<field name=\"WHERE2\">FROM_START</field>\n<value name=\"STRING\">\n<block type=\"variables_get\">\n- <field name=\"VAR\" id=\"x,Zl7o=OyFqu`9w_v7A+\">text</field>\n+ <field name=\"VAR\" id=\"x2O$~p~Zbcheb3G^q4Du\">text</field>\n</block>\n</value>\n</block>\n</value>\n</block>\n</category>\n- <category name=\"Lists\" colour=\"#745ba5\">\n+ <category name=\"Lists\" colour=\"#5b80a5\">\n<block type=\"lists_create_with\">\n<mutation items=\"0\"></mutation>\n</block>\n<field name=\"END\">FIRST</field>\n<value name=\"VALUE\">\n<block type=\"variables_get\">\n- <field name=\"VAR\" id=\"l?1Ne_YoM!bxpl#M5CKY\">list</field>\n+ <field name=\"VAR\" id=\".:#z/k2m@O`G%QxgNXPJ\">list</field>\n</block>\n</value>\n</block>\n<field name=\"WHERE\">FROM_START</field>\n<value name=\"VALUE\">\n<block type=\"variables_get\">\n- <field name=\"VAR\" id=\"l?1Ne_YoM!bxpl#M5CKY\">list</field>\n+ <field name=\"VAR\" id=\".:#z/k2m@O`G%QxgNXPJ\">list</field>\n</block>\n</value>\n</block>\n<field name=\"WHERE\">FROM_START</field>\n<value name=\"LIST\">\n<block type=\"variables_get\">\n- <field name=\"VAR\" id=\"l?1Ne_YoM!bxpl#M5CKY\">list</field>\n+ <field name=\"VAR\" id=\".:#z/k2m@O`G%QxgNXPJ\">list</field>\n</block>\n</value>\n</block>\n<field name=\"WHERE2\">FROM_START</field>\n<value name=\"LIST\">\n<block type=\"variables_get\">\n- <field name=\"VAR\" id=\"l?1Ne_YoM!bxpl#M5CKY\">list</field>\n+ <field name=\"VAR\" id=\".:#z/k2m@O`G%QxgNXPJ\">list</field>\n</block>\n</value>\n</block>\n" } ]
Python
MIT License
uccser/cs-unplugged
Started adding custom blocks. Firstly, added a custom modulo block to fix the default remainder block outputting a negative a number instead of a positive number. Added a multiplcation block.
701,850
15.08.2021 13:36:37
-43,200
4c195b4b9e2acf00499fd4acb630cdaab8cb4904
Changed Math category to Operators category, and created custom operators blocks similar to Scratch blocks.
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "@@ -58,9 +58,35 @@ if (programming_lang == \"python\") {\ndocument.addEventListener(\"DOMContentLoaded\", function () {\n// Custom Blockly blocks to look and act like Scratch\nBlockly.defineBlocksWithJsonArray([\n- // Custom multiply block\n+ // Operators modulo block\n{\n- \"type\": \"custom_math_multiply\",\n+ \"type\": \"operators_modulo\",\n+ \"message0\": \"%1 mod %2 %3\",\n+ \"args0\": [\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"a\",\n+ \"check\": \"Number\"\n+ },\n+ {\n+ \"type\": \"input_dummy\",\n+ \"align\": \"CENTRE\"\n+ },\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"n\",\n+ \"check\": \"Number\"\n+ }\n+ ],\n+ \"inputsInline\": true,\n+ \"output\": \"Number\",\n+ \"colour\": 120,\n+ \"tooltip\": \"Return the modulo of the two numbers.\",\n+ \"helpUrl\": \"\"\n+ },\n+ // Operators multiply block\n+ {\n+ \"type\": \"operators_multiply\",\n\"message0\": \"%1 * %2 %3\",\n\"args0\": [\n{\n@@ -83,62 +109,275 @@ if (programming_lang == \"python\") {\n\"tooltip\": \"Return the product of the two numbers.\",\n\"helpUrl\": \"\"\n},\n- // Custom modulo block\n+ ,\n+ // Operators divide block\n{\n- \"type\": \"custom_math_modulo\",\n- \"message0\": \"%1 mod %2 %3\",\n+ \"type\": \"operators_divide\",\n+ \"message0\": \"%1 / %2 %3\",\n\"args0\": [\n{\n\"type\": \"input_value\",\n- \"name\": \"a\",\n+ \"name\": \"x\",\n\"check\": \"Number\"\n},\n{\n- \"type\": \"input_dummy\",\n- \"align\": \"CENTRE\"\n+ \"type\": \"input_dummy\"\n},\n{\n\"type\": \"input_value\",\n- \"name\": \"n\",\n+ \"name\": \"y\",\n\"check\": \"Number\"\n}\n],\n\"inputsInline\": true,\n\"output\": \"Number\",\n- \"colour\": 230,\n- \"tooltip\": \"Return the modulo of the two numbers.\",\n+ \"colour\": 120,\n+ \"tooltip\": \"Return the quotient of the two numbers.\",\n+ \"helpUrl\": \"\"\n+ },\n+ // Operators add block\n+ {\n+ \"type\": \"operators_add\",\n+ \"message0\": \"%1 + %2 %3\",\n+ \"args0\": [\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"x\",\n+ \"check\": \"Number\"\n+ },\n+ {\n+ \"type\": \"input_dummy\"\n+ },\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"y\",\n+ \"check\": \"Number\"\n+ }\n+ ],\n+ \"inputsInline\": true,\n+ \"output\": \"Number\",\n+ \"colour\": 120,\n+ \"tooltip\": \"Return the sum of the two numbers.\",\n+ \"helpUrl\": \"\"\n+ },\n+ // Operators subtract block\n+ {\n+ \"type\": \"operators_subtract\",\n+ \"message0\": \"%1 - %2 %3\",\n+ \"args0\": [\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"x\",\n+ \"check\": \"Number\"\n+ },\n+ {\n+ \"type\": \"input_dummy\"\n+ },\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"y\",\n+ \"check\": \"Number\"\n+ }\n+ ],\n+ \"inputsInline\": true,\n+ \"output\": \"Number\",\n+ \"colour\": 120,\n+ \"tooltip\": \"Return the difference of the two numbers.\",\n+ \"helpUrl\": \"\"\n+ },\n+ // Operators join/concatenate string block\n+ {\n+ \"type\": \"operators_join_string\",\n+ \"message0\": \"join %1 %2 %3\",\n+ \"args0\": [\n+ {\n+ \"type\": \"input_dummy\"\n+ },\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"a\",\n+ \"check\": \"String\"\n+ },\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"b\",\n+ \"check\": \"String\"\n+ }\n+ ],\n+ \"inputsInline\": true,\n+ \"output\": \"String\",\n+ \"colour\": 120,\n+ \"tooltip\": \"Returns a combination of the two input strings added together.\",\n+ \"helpUrl\": \"\"\n+ },\n+ // Operators letter <num> of <string> block\n+ {\n+ \"type\": \"operators_letter_of\",\n+ \"message0\": \"letter %1 %2 of %3 %4\",\n+ \"args0\": [\n+ {\n+ \"type\": \"input_dummy\"\n+ },\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"index\",\n+ \"check\": \"Number\"\n+ },\n+ {\n+ \"type\": \"input_dummy\"\n+ },\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"word\",\n+ \"check\": \"String\"\n+ }\n+ ],\n+ \"output\": \"String\",\n+ \"colour\": 120,\n+ \"tooltip\": \"Returns the letter of the specified position. #1 is the first item.\",\n+ \"helpUrl\": \"\"\n+ },\n+ // Operators <string> contains <substring> block\n+ {\n+ \"type\": \"operators_string_contains\",\n+ \"message0\": \"%1 contains %2 %3 ?\",\n+ \"args0\": [\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"word\",\n+ \"check\": \"String\"\n+ },\n+ {\n+ \"type\": \"input_dummy\"\n+ },\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"subword\",\n+ \"check\": \"String\"\n+ }\n+ ],\n+ \"inputsInline\": true,\n+ \"output\": \"Boolean\",\n+ \"colour\": 120,\n+ \"tooltip\": \"Returns true if the second string is in the first string.\",\n\"helpUrl\": \"\"\n}\n]);\n- // Custom modulo block\n- Blockly.JavaScript['custom_math_modulo'] = function(block) {\n+ // Operators <string> contains <substring> block\n+ Blockly.JavaScript['operators_string_contains'] = function(block) {\n+ var value_word = Blockly.JavaScript.valueToCode(block, 'word', Blockly.JavaScript.ORDER_ATOMIC);\n+ var value_subword = Blockly.JavaScript.valueToCode(block, 'subword', Blockly.JavaScript.ORDER_ATOMIC);\n+ var code = value_word + \".includes(\" + value_subword + \")\";\n+ return [code, Blockly.JavaScript.ORDER_NONE];\n+ };\n+ Blockly.Python['operators_string_contains'] = function(block) {\n+ var value_word = Blockly.Python.valueToCode(block, 'word', Blockly.Python.ORDER_ATOMIC);\n+ var value_subword = Blockly.Python.valueToCode(block, 'subword', Blockly.Python.ORDER_ATOMIC);\n+ var code = value_subword + \" in \" + value_word;\n+ return [code, Blockly.Python.ORDER_NONE];\n+ };\n+\n+ // Operators letter <num> of <string> block\n+ Blockly.JavaScript['operators_letter_of'] = function(block) {\n+ var value_index = Blockly.JavaScript.valueToCode(block, 'index', Blockly.JavaScript.ORDER_ATOMIC) - 1; // subtract 1 since index starts from 0 in JS\n+ var value_word = Blockly.JavaScript.valueToCode(block, 'word', Blockly.JavaScript.ORDER_ATOMIC);\n+ var code = value_word + \".charAt(\" + value_index + \")\";\n+ return [code, Blockly.JavaScript.ORDER_NONE];\n+ };\n+ Blockly.Python['operators_letter_of'] = function(block) {\n+ var value_index = Blockly.Python.valueToCode(block, 'index', Blockly.Python.ORDER_ATOMIC) - 1; // subtract 1 since index starts from 0 in Python\n+ var value_word = Blockly.Python.valueToCode(block, 'word', Blockly.Python.ORDER_ATOMIC);\n+ var code = value_word + \"[\" + value_index + \"]\";\n+ return [code, Blockly.Python.ORDER_NONE];\n+ };\n+\n+ // Operators join/concatenate string block\n+ Blockly.JavaScript['operators_join_string'] = function(block) {\n+ var value_a = Blockly.JavaScript.valueToCode(block, 'a', Blockly.JavaScript.ORDER_ATOMIC);\n+ var value_b = Blockly.JavaScript.valueToCode(block, 'b', Blockly.JavaScript.ORDER_ATOMIC);\n+ var code = value_a + ' + ' + value_b;\n+ return [code, Blockly.JavaScript.ORDER_NONE];\n+ };\n+ Blockly.Python['operators_join_string'] = function(block) {\n+ var value_a = Blockly.Python.valueToCode(block, 'a', Blockly.Python.ORDER_ATOMIC);\n+ var value_b = Blockly.Python.valueToCode(block, 'b', Blockly.Python.ORDER_ATOMIC);\n+ var code = value_a + ' + ' + value_b;\n+ return [code, Blockly.Python.ORDER_NONE];\n+ };\n+\n+ // Operators modulo block\n+ Blockly.JavaScript['operators_modulo'] = function(block) {\nvar value_a = Blockly.JavaScript.valueToCode(block, 'a', Blockly.JavaScript.ORDER_MODULUS);\nvar value_n = Blockly.JavaScript.valueToCode(block, 'n', Blockly.JavaScript.ORDER_MODULUS);\nvar code = '(' + value_a + ' % ' + value_n + ' + ' + value_n + ')' + ' % ' + value_a;\nreturn [code, Blockly.JavaScript.ORDER_ADDITION];\n};\n- Blockly.Python['custom_math_modulo'] = function(block) {\n+ Blockly.Python['operators_modulo'] = function(block) {\nvar value_a = Blockly.Python.valueToCode(block, 'a', Blockly.Python.ORDER_ATOMIC);\nvar value_n = Blockly.Python.valueToCode(block, 'n', Blockly.Python.ORDER_ATOMIC);\nvar code = value_a + ' % ' + value_n;\nreturn [code, Blockly.Python.ORDER_NONE];\n};\n- // Custom multiply block\n- Blockly.JavaScript['custom_math_multiply'] = function(block) {\n+ // Operators multiply block\n+ Blockly.JavaScript['operators_multiply'] = function(block) {\nvar value_x = Blockly.JavaScript.valueToCode(block, 'x', Blockly.JavaScript.ORDER_MULTIPLICATION);\nvar value_y = Blockly.JavaScript.valueToCode(block, 'y', Blockly.JavaScript.ORDER_MULTIPLICATION);\nvar code = value_x + ' * ' + value_y;\nreturn [code, Blockly.JavaScript.ORDER_NONE];\n};\n- Blockly.Python['custom_math_multiply'] = function(block) {\n+ Blockly.Python['operators_multiply'] = function(block) {\nvar value_x = Blockly.Python.valueToCode(block, 'x', Blockly.Python.ORDER_ATOMIC);\nvar value_y = Blockly.Python.valueToCode(block, 'y', Blockly.Python.ORDER_ATOMIC);\nvar code = value_x + ' * ' + value_y;\nreturn [code, Blockly.Python.ORDER_NONE];\n};\n+ // Operators divide block\n+ Blockly.JavaScript['operators_divide'] = function(block) {\n+ var value_x = Blockly.JavaScript.valueToCode(block, 'x', Blockly.JavaScript.ORDER_ATOMIC);\n+ var value_y = Blockly.JavaScript.valueToCode(block, 'y', Blockly.JavaScript.ORDER_ATOMIC);\n+ var code = value_x + ' / ' + value_y;\n+ return [code, Blockly.JavaScript.ORDER_NONE];\n+ };\n+ Blockly.Python['operators_divide'] = function(block) {\n+ var value_x = Blockly.Python.valueToCode(block, 'x', Blockly.Python.ORDER_ATOMIC);\n+ var value_y = Blockly.Python.valueToCode(block, 'y', Blockly.Python.ORDER_ATOMIC);\n+ var code = value_x + ' / ' + value_y;\n+ return [code, Blockly.Python.ORDER_NONE];\n+ };\n+\n+ // Operators add block\n+ Blockly.JavaScript['operators_add'] = function(block) {\n+ var value_x = Blockly.JavaScript.valueToCode(block, 'x', Blockly.JavaScript.ORDER_ATOMIC);\n+ var value_y = Blockly.JavaScript.valueToCode(block, 'y', Blockly.JavaScript.ORDER_ATOMIC);\n+ var code = value_x + ' + ' + value_y;\n+ return [code, Blockly.JavaScript.ORDER_NONE];\n+ };\n+ Blockly.Python['operators_add'] = function(block) {\n+ var value_x = Blockly.Python.valueToCode(block, 'x', Blockly.Python.ORDER_ATOMIC);\n+ var value_y = Blockly.Python.valueToCode(block, 'y', Blockly.Python.ORDER_ATOMIC);\n+ var code = value_x + ' + ' + value_y;\n+ return [code, Blockly.Python.ORDER_NONE];\n+ };\n+\n+ // Operators subtract blocks\n+ Blockly.JavaScript['operators_subtract'] = function(block) {\n+ var value_x = Blockly.JavaScript.valueToCode(block, 'x', Blockly.JavaScript.ORDER_ATOMIC);\n+ var value_y = Blockly.JavaScript.valueToCode(block, 'y', Blockly.JavaScript.ORDER_ATOMIC);\n+ var code = value_x + ' - ' + value_y;\n+ return [code, Blockly.JavaScript.ORDER_NONE];\n+ };\n+ Blockly.Python['operators_subtract'] = function(block) {\n+ var value_x = Blockly.Python.valueToCode(block, 'x', Blockly.Python.ORDER_ATOMIC);\n+ var value_y = Blockly.Python.valueToCode(block, 'y', Blockly.Python.ORDER_ATOMIC);\n+ var code = value_x + ' - ' + value_y;\n+ return [code, Blockly.Python.ORDER_NONE];\n+ };\n+\n+\n+\nconst toolbox = document.getElementById('toolbox');\n/* Workspace configurations */\nconst options = {\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "<xml xmlns=\"https://developers.google.com/blockly/xml\" id=\"toolbox\" style=\"display: none\">\n<category name=\"Control\" colour=\"#a5745b\">\n<block type=\"controls_if\"></block>\n- <block type=\"logic_compare\">\n- <field name=\"OP\">EQ</field>\n- </block>\n- <block type=\"logic_operation\">\n- <field name=\"OP\">AND</field>\n- </block>\n- <block type=\"logic_negate\"></block>\n<block type=\"logic_boolean\">\n<field name=\"BOOL\">TRUE</field>\n</block>\n<block type=\"logic_null\"></block>\n- <block type=\"controls_repeat_ext\">\n- <value name=\"TIMES\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">10</field>\n- </shadow>\n- </value>\n- </block>\n+ <block type=\"controls_repeat_ext\"></block>\n<block type=\"controls_whileUntil\">\n<field name=\"MODE\">WHILE</field>\n</block>\n<field name=\"FLOW\">BREAK</field>\n</block>\n</category>\n- <category name=\"Math\" colour=\"#5ba55b\">\n- <block type=\"custom_math_multiply\">\n+ <category name=\"Operators\" colour=\"#5ba55b\">\n+ <block type=\"math_number\">\n+ <field name=\"NUM\">0</field>\n+ </block>\n+ <block type=\"operators_add\">\n<value name=\"x\">\n<shadow type=\"math_number\">\n<field name=\"NUM\">1</field>\n</shadow>\n</value>\n</block>\n- <block type=\"math_number\">\n- <field name=\"NUM\">0</field>\n+ <block type=\"operators_subtract\">\n+ <value name=\"x\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">1</field>\n+ </shadow>\n+ </value>\n+ <value name=\"y\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">1</field>\n+ </shadow>\n+ </value>\n</block>\n- <block type=\"math_arithmetic\">\n- <field name=\"OP\">ADD</field>\n- <value name=\"A\">\n+ <block type=\"operators_multiply\">\n+ <value name=\"x\">\n<shadow type=\"math_number\">\n<field name=\"NUM\">1</field>\n</shadow>\n</value>\n- <value name=\"B\">\n+ <value name=\"y\">\n<shadow type=\"math_number\">\n<field name=\"NUM\">1</field>\n</shadow>\n</value>\n</block>\n- <block type=\"math_single\">\n- <field name=\"OP\">ROOT</field>\n- <value name=\"NUM\">\n+ <block type=\"operators_divide\">\n+ <value name=\"x\">\n<shadow type=\"math_number\">\n- <field name=\"NUM\">9</field>\n+ <field name=\"NUM\">1</field>\n+ </shadow>\n+ </value>\n+ <value name=\"y\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">1</field>\n</shadow>\n</value>\n</block>\n- <block type=\"math_trig\">\n- <field name=\"OP\">SIN</field>\n- <value name=\"NUM\">\n+ <block type=\"math_random_int\">\n+ <value name=\"FROM\">\n<shadow type=\"math_number\">\n- <field name=\"NUM\">45</field>\n+ <field name=\"NUM\">1</field>\n+ </shadow>\n+ </value>\n+ <value name=\"TO\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">100</field>\n</shadow>\n</value>\n</block>\n- <block type=\"math_constant\">\n- <field name=\"CONSTANT\">PI</field>\n+ <block type=\"logic_compare\">\n+ <field name=\"OP\">EQ</field>\n</block>\n- <block type=\"math_number_property\">\n- <mutation divisor_input=\"false\"></mutation>\n- <field name=\"PROPERTY\">EVEN</field>\n- <value name=\"NUMBER_TO_CHECK\">\n+ <block type=\"logic_operation\">\n+ <field name=\"OP\">AND</field>\n+ </block>\n+ <block type=\"logic_negate\"></block>\n+ <block type=\"operators_join_string\">\n+ <value name=\"a\">\n+ <shadow type=\"text\">\n+ <field name=\"TEXT\">apple </field>\n+ </shadow>\n+ </value>\n+ <value name=\"b\">\n+ <shadow type=\"text\">\n+ <field name=\"TEXT\">banana</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"operators_letter_of\">\n+ <value name=\"index\">\n<shadow type=\"math_number\">\n- <field name=\"NUM\">0</field>\n+ <field name=\"NUM\">1</field>\n+ </shadow>\n+ </value>\n+ <value name=\"word\">\n+ <shadow type=\"text\">\n+ <field name=\"TEXT\">apple</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"text_length\">\n+ <value name=\"VALUE\">\n+ <shadow type=\"text\">\n+ <field name=\"TEXT\">abc</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"operators_string_contains\">\n+ <value name=\"word\">\n+ <shadow type=\"text\">\n+ <field name=\"TEXT\">apple</field>\n+ </shadow>\n+ </value>\n+ <value name=\"subword\">\n+ <shadow type=\"text\">\n+ <field name=\"TEXT\">a</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ </block>\n+ <block type=\"operators_modulo\">\n+ <value name=\"a\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">-3</field>\n+ </shadow>\n+ </value>\n+ <value name=\"n\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">2</field>\n</shadow>\n</value>\n</block>\n</shadow>\n</value>\n</block>\n- <block type=\"math_on_list\">\n- <mutation op=\"SUM\"></mutation>\n- <field name=\"OP\">SUM</field>\n+ <block type=\"math_single\">\n+ <field name=\"OP\">ROOT</field>\n+ <value name=\"NUM\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">9</field>\n+ </shadow>\n+ </value>\n</block>\n- <block type=\"custom_math_modulo\">\n- <value name=\"a\">\n+ <!-- <block type=\"math_arithmetic\">\n+ <field name=\"OP\">ADD</field>\n+ <value name=\"A\">\n<shadow type=\"math_number\">\n- <field name=\"NUM\">-3</field>\n+ <field name=\"NUM\">1</field>\n</shadow>\n</value>\n- <value name=\"n\">\n+ <value name=\"B\">\n<shadow type=\"math_number\">\n- <field name=\"NUM\">2</field>\n+ <field name=\"NUM\">1</field>\n+ </shadow>\n+ </value>\n+ </block> -->\n+ <block type=\"math_trig\">\n+ <field name=\"OP\">SIN</field>\n+ <value name=\"NUM\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">45</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <!-- <block type=\"math_number_property\">\n+ <mutation divisor_input=\"false\"></mutation>\n+ <field name=\"PROPERTY\">EVEN</field>\n+ <value name=\"NUMBER_TO_CHECK\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">0</field>\n</shadow>\n</value>\n</block>\n+ <block type=\"math_on_list\">\n+ <mutation op=\"SUM\"></mutation>\n+ <field name=\"OP\">SUM</field>\n+ </block>\n<block type=\"math_modulo\">\n<value name=\"DIVIDEND\">\n<shadow type=\"math_number\">\n</shadow>\n</value>\n</block>\n- <block type=\"math_random_int\">\n- <value name=\"FROM\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">1</field>\n- </shadow>\n- </value>\n- <value name=\"TO\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">100</field>\n- </shadow>\n- </value>\n- </block>\n- <block type=\"math_random_float\"></block>\n+ <block type=\"math_random_float\"></block> -->\n</category>\n<category name=\"Text\" colour=\"#745ba5\">\n<block type=\"text\">\n</shadow>\n</value>\n</block>\n- <block type=\"text_length\">\n- <value name=\"VALUE\">\n- <shadow type=\"text\">\n- <field name=\"TEXT\">abc</field>\n- </shadow>\n- </value>\n- </block>\n<block type=\"text_isEmpty\">\n<value name=\"VALUE\">\n<shadow type=\"text\">\n" } ]
Python
MIT License
uccser/cs-unplugged
Changed Math category to Operators category, and created custom operators blocks similar to Scratch blocks.
701,850
15.08.2021 14:28:21
-43,200
e69fd0d21de8aa164887f2891aae3760057a4955
Changed colours of categories, Controls and Operators, to look like Scratch
[ { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "<p class='pii-block-heading'>{% trans \"Create your program in the editor below\" %}</p>\n<div id=\"blocklyDiv\" style=\"height: 100%; \"></div>\n<xml xmlns=\"https://developers.google.com/blockly/xml\" id=\"toolbox\" style=\"display: none\">\n- <category name=\"Control\" colour=\"#a5745b\">\n+ <category name=\"Control\" colour=\"#ffab19\">\n<block type=\"controls_if\"></block>\n<block type=\"logic_boolean\">\n<field name=\"BOOL\">TRUE</field>\n<field name=\"FLOW\">BREAK</field>\n</block>\n</category>\n- <category name=\"Operators\" colour=\"#5ba55b\">\n+ <category name=\"Operators\" colour=\"#59c059\">\n<block type=\"math_number\">\n<field name=\"NUM\">0</field>\n</block>\n" } ]
Python
MIT License
uccser/cs-unplugged
Changed colours of categories, Controls and Operators, to look like Scratch
701,850
15.08.2021 14:36:48
-43,200
294f4c7418e9baa9e737a3fe3a18b6197ee3367c
Added more block categories similar to Scratch
[ { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "<p class='pii-block-heading'>{% trans \"Create your program in the editor below\" %}</p>\n<div id=\"blocklyDiv\" style=\"height: 100%; \"></div>\n<xml xmlns=\"https://developers.google.com/blockly/xml\" id=\"toolbox\" style=\"display: none\">\n+ <category name=\"Looks\" colour=\"#9966ff\">\n+\n+ </category>\n<category name=\"Control\" colour=\"#ffab19\">\n<block type=\"controls_if\"></block>\n<block type=\"logic_boolean\">\n<block type=\"controls_flow_statements\" disabled=\"true\">\n<field name=\"FLOW\">BREAK</field>\n</block>\n+ </category>\n+ <category name=\"Sensing\" colour=\"#4cc0e6\">\n+\n</category>\n<category name=\"Operators\" colour=\"#59c059\">\n<block type=\"math_number\">\n</block>\n</category>\n<sep></sep>\n- <category name=\"Variables\" colour=\"#a55b80\" custom=\"VARIABLE\"></category>\n+ <category name=\"Variables\" colour=\"#ff8d1a\" custom=\"VARIABLE\"></category>\n</xml>\n<div class=\"programming__submit d-flex justify-content-between align-items-center\">\n<div class=\"programming__submit_options d-flex justify-content-start\">\n" } ]
Python
MIT License
uccser/cs-unplugged
Added more block categories similar to Scratch
701,850
15.08.2021 14:54:57
-43,200
2e2aac1d27245bd12b2d1ec1eeff969e3e874a8c
Added the ask and wait block in the Sensing category
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "@@ -261,9 +261,45 @@ if (programming_lang == \"python\") {\n\"colour\": 120,\n\"tooltip\": \"Returns true if the second string is in the first string.\",\n\"helpUrl\": \"\"\n+ },\n+ // Sensing ask and wait block\n+ {\n+ \"type\": \"sensing_ask_and_wait\",\n+ \"message0\": \"ask %1 %2 and wait\",\n+ \"args0\": [\n+ {\n+ \"type\": \"input_dummy\"\n+ },\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"question\",\n+ \"check\": \"String\"\n+ }\n+ ],\n+ \"inputsInline\": true,\n+ \"output\": \"String\",\n+ \"colour\": 180,\n+ \"tooltip\": \"Ask user for some text.\",\n+ \"helpUrl\": \"\"\n}\n]);\n+ // Sensing ask and wait block\n+ Blockly.JavaScript['sensing_ask_and_wait'] = function(block) {\n+ var value_question = Blockly.JavaScript.valueToCode(block, 'question', Blockly.JavaScript.ORDER_ATOMIC);\n+ // TODO: Assemble JavaScript into code variable.\n+ var code = 'prompt(' + value_question + ')'\n+ // TODO: Change ORDER_NONE to the correct strength.\n+ return [code, Blockly.JavaScript.ORDER_NONE];\n+ };\n+ Blockly.Python['sensing_ask_and_wait'] = function(block) {\n+ var value_question = Blockly.Python.valueToCode(block, 'question', Blockly.Python.ORDER_ATOMIC);\n+ // TODO: Assemble Python into code variable.\n+ var code = 'input(' + value_question + ')';\n+ // TODO: Change ORDER_NONE to the correct strength.\n+ return [code, Blockly.Python.ORDER_NONE];\n+ };\n+\n// Operators <string> contains <substring> block\nBlockly.JavaScript['operators_string_contains'] = function(block) {\nvar value_word = Blockly.JavaScript.valueToCode(block, 'word', Blockly.JavaScript.ORDER_ATOMIC);\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "</block>\n</category>\n<category name=\"Sensing\" colour=\"#4cc0e6\">\n-\n+ <block type=\"sensing_ask_and_wait\">\n+ <value name=\"question\">\n+ <shadow type=\"text\">\n+ <field name=\"TEXT\">What is your name?</field>\n+ </shadow>\n+ </value>\n+ </block>\n</category>\n<category name=\"Operators\" colour=\"#59c059\">\n<block type=\"math_number\">\n" } ]
Python
MIT License
uccser/cs-unplugged
Added the ask and wait block in the Sensing category
701,850
15.08.2021 14:59:05
-43,200
ad287685ebc680a43b3299de4021b9d81884bb46
Moved the say/print block to the Looks category. This makes it similar to Scratch.
[ { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "<div id=\"blocklyDiv\" style=\"height: 100%; \"></div>\n<xml xmlns=\"https://developers.google.com/blockly/xml\" id=\"toolbox\" style=\"display: none\">\n<category name=\"Looks\" colour=\"#9966ff\">\n-\n+ <block type=\"text_print\">\n+ <value name=\"TEXT\">\n+ <shadow type=\"text\">\n+ <field name=\"TEXT\">abc</field>\n+ </shadow>\n+ </value>\n+ </block>\n</category>\n<category name=\"Control\" colour=\"#ffab19\">\n<block type=\"controls_if\"></block>\n</shadow>\n</value>\n</block>\n- <block type=\"text_print\">\n- <value name=\"TEXT\">\n- <shadow type=\"text\">\n- <field name=\"TEXT\">abc</field>\n- </shadow>\n- </value>\n- </block>\n<block type=\"text_prompt_ext\">\n<mutation type=\"TEXT\"></mutation>\n<field name=\"TYPE\">TEXT</field>\n" } ]
Python
MIT License
uccser/cs-unplugged
Moved the say/print block to the Looks category. This makes it similar to Scratch.
701,850
15.08.2021 15:16:11
-43,200
e98a8e41d9ce998336e968c7b330818b8f8b3fd0
Cleaned up the Control category, and removed unncessary blocks
[ { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "</block>\n</category>\n<category name=\"Control\" colour=\"#ffab19\">\n- <block type=\"controls_if\"></block>\n- <block type=\"logic_boolean\">\n- <field name=\"BOOL\">TRUE</field>\n- </block>\n- <block type=\"logic_null\"></block>\n- <block type=\"controls_repeat_ext\"></block>\n- <block type=\"controls_whileUntil\">\n- <field name=\"MODE\">WHILE</field>\n- </block>\n- <block type=\"controls_for\">\n- <field name=\"VAR\" id=\"C~3vhn!z)$kFIgo1uY@@\">i</field>\n- <value name=\"FROM\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">1</field>\n- </shadow>\n- </value>\n- <value name=\"TO\">\n+ <block type=\"controls_repeat_ext\">\n+ <value name=\"TIMES\">\n<shadow type=\"math_number\">\n<field name=\"NUM\">10</field>\n</shadow>\n</value>\n- <value name=\"BY\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">1</field>\n- </shadow>\n- </value>\n</block>\n- <block type=\"controls_forEach\">\n- <field name=\"VAR\" id=\"nl]?Fl371yL(iW8S]E47\">j</field>\n+ <!-- Forever loop? -->\n+ <!-- If then block? -->\n+ <!-- If then, else block? -->\n+ <block type=\"controls_if\"></block>\n+\n+ <block type=\"controls_whileUntil\">\n+ <field name=\"MODE\">WHILE</field>\n</block>\n+ <!-- Stop block? -->\n<block type=\"controls_flow_statements\" disabled=\"true\">\n<field name=\"FLOW\">BREAK</field>\n</block>\n" } ]
Python
MIT License
uccser/cs-unplugged
Cleaned up the Control category, and removed unncessary blocks
701,850
15.08.2021 15:31:59
-43,200
102e24d7b918e8c59beffb9d0d7d94a93f6cb827
Added the stop block, similar to a break in JavaScript or Python.
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "@@ -281,9 +281,30 @@ if (programming_lang == \"python\") {\n\"colour\": 180,\n\"tooltip\": \"Ask user for some text.\",\n\"helpUrl\": \"\"\n- }\n+ },\n+ // Controls stop block\n+ {\n+ \"type\": \"controls_stop\",\n+ \"message0\": \"stop\",\n+ \"previousStatement\": null,\n+ \"colour\": 15,\n+ \"tooltip\": \"Stops the containing loop.\",\n+ \"helpUrl\": \"\"\n+ },\n]);\n+ // Controls stop block\n+ Blockly.JavaScript['controls_stop'] = function(block) {\n+ // TODO: Assemble JavaScript into code variable.\n+ var code = 'break;\\n';\n+ return code;\n+ };\n+ Blockly.Python['controls_stop'] = function(block) {\n+ // TODO: Assemble Python into code variable.\n+ var code = 'break\\n';\n+ return code;\n+ };\n+\n// Sensing ask and wait block\nBlockly.JavaScript['sensing_ask_and_wait'] = function(block) {\nvar value_question = Blockly.JavaScript.valueToCode(block, 'question', Blockly.JavaScript.ORDER_ATOMIC);\n@@ -446,8 +467,6 @@ if (programming_lang == \"python\") {\n// Displays the user's previous submission\nif (previous_submission) {\n// Decodes the previous_submission which contains HTML entities. Outputs a string, and it converts it to XML\n- console.log(\"PREVIOUS SUBMISSIONS\")\n- console.log(previous_submission)\nconst xml_node = Blockly.Xml.textToDom(utils.decodeHTMLEntities(previous_submission))\nBlockly.Xml.domToWorkspace(xml_node, workspace);\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "<field name=\"MODE\">WHILE</field>\n</block>\n<!-- Stop block? -->\n- <block type=\"controls_flow_statements\" disabled=\"true\">\n- <field name=\"FLOW\">BREAK</field>\n- </block>\n+ <block type=\"controls_stop\"></block>\n</category>\n<category name=\"Sensing\" colour=\"#4cc0e6\">\n<block type=\"sensing_ask_and_wait\">\n" } ]
Python
MIT License
uccser/cs-unplugged
Added the stop block, similar to a break in JavaScript or Python.
701,850
15.08.2021 16:02:44
-43,200
3692eaf072c752f87558a59348ff9744971ec65c
Replaced the default and/or dropdown block, with separated 'and' & 'or' block. This is the same as the and/or blocks in Scratch.
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "@@ -262,6 +262,54 @@ if (programming_lang == \"python\") {\n\"tooltip\": \"Returns true if the second string is in the first string.\",\n\"helpUrl\": \"\"\n},\n+ // Operators logical AND block\n+ {\n+ \"type\": \"operators_and\",\n+ \"message0\": \"%1 and %2 %3\",\n+ \"args0\": [\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"a\",\n+ \"check\": \"Boolean\"\n+ },\n+ {\n+ \"type\": \"input_dummy\"\n+ },\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"b\",\n+ \"check\": \"Boolean\"\n+ }\n+ ],\n+ \"output\": \"Boolean\",\n+ \"colour\": 120,\n+ \"tooltip\": \"Returns true if both inputs are true.\",\n+ \"helpUrl\": \"\"\n+ },\n+ // Operators logical OR block\n+ {\n+ \"type\": \"operators_or\",\n+ \"message0\": \"%1 or %2 %3\",\n+ \"args0\": [\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"a\",\n+ \"check\": \"Boolean\"\n+ },\n+ {\n+ \"type\": \"input_dummy\"\n+ },\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"b\",\n+ \"check\": \"Boolean\"\n+ }\n+ ],\n+ \"output\": \"Boolean\",\n+ \"colour\": 120,\n+ \"tooltip\": \"Returns true if at least one of the inputs is true.\",\n+ \"helpUrl\": \"\"\n+ },\n// Sensing ask and wait block\n{\n\"type\": \"sensing_ask_and_wait\",\n@@ -293,6 +341,35 @@ if (programming_lang == \"python\") {\n},\n]);\n+ // Operators logical OR block\n+ Blockly.JavaScript['operators_or'] = function(block) {\n+ var value_a = Blockly.JavaScript.valueToCode(block, 'a', Blockly.JavaScript.ORDER_ATOMIC);\n+ var value_b = Blockly.JavaScript.valueToCode(block, 'b', Blockly.JavaScript.ORDER_ATOMIC);\n+ var code = value_a + ' || ' + value_b;\n+ return [code, Blockly.JavaScript.ORDER_NONE];\n+ };\n+ Blockly.Python['operators_or'] = function(block) {\n+ var value_a = Blockly.Python.valueToCode(block, 'a', Blockly.Python.ORDER_ATOMIC);\n+ var value_b = Blockly.Python.valueToCode(block, 'b', Blockly.Python.ORDER_ATOMIC);\n+ var code = value_a + ' or ' + value_b;\n+ return [code, Blockly.Python.ORDER_NONE];\n+ };\n+\n+\n+ // Operators logical AND block\n+ Blockly.JavaScript['operators_and'] = function(block) {\n+ var value_a = Blockly.JavaScript.valueToCode(block, 'a', Blockly.JavaScript.ORDER_ATOMIC);\n+ var value_b = Blockly.JavaScript.valueToCode(block, 'b', Blockly.JavaScript.ORDER_ATOMIC);\n+ var code = value_a + ' && ' + value_b;\n+ return [code, Blockly.JavaScript.ORDER_NONE];\n+ };\n+ Blockly.Python['operators_and'] = function(block) {\n+ var value_a = Blockly.Python.valueToCode(block, 'a', Blockly.Python.ORDER_ATOMIC);\n+ var value_b = Blockly.Python.valueToCode(block, 'b', Blockly.Python.ORDER_ATOMIC);\n+ var code = value_a + ' and ' + value_b;\n+ return [code, Blockly.Python.ORDER_NONE];\n+ };\n+\n// Controls stop block\nBlockly.JavaScript['controls_stop'] = function(block) {\n// TODO: Assemble JavaScript into code variable.\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "<block type=\"logic_compare\">\n<field name=\"OP\">EQ</field>\n</block>\n- <block type=\"logic_operation\">\n- <field name=\"OP\">AND</field>\n- </block>\n+ <block type=\"operators_and\"></block>\n+ <block type=\"operators_or\"></block>\n<block type=\"logic_negate\"></block>\n<block type=\"operators_join_string\">\n<value name=\"a\">\n" } ]
Python
MIT License
uccser/cs-unplugged
Replaced the default and/or dropdown block, with separated 'and' & 'or' block. This is the same as the and/or blocks in Scratch.
701,850
15.08.2021 16:38:54
-43,200
0b65ee368657ab08ed621c839fe4f0c254e24adf
Replaced the default Blockly dropdown round block, with new round block that is similar to the Scratch round block.
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "@@ -109,7 +109,6 @@ if (programming_lang == \"python\") {\n\"tooltip\": \"Return the product of the two numbers.\",\n\"helpUrl\": \"\"\n},\n- ,\n// Operators divide block\n{\n\"type\": \"operators_divide\",\n@@ -310,6 +309,26 @@ if (programming_lang == \"python\") {\n\"tooltip\": \"Returns true if at least one of the inputs is true.\",\n\"helpUrl\": \"\"\n},\n+ // Operators round up block\n+ {\n+ \"type\": \"operators_round\",\n+ \"message0\": \"round %1 %2\",\n+ \"args0\": [\n+ {\n+ \"type\": \"input_dummy\"\n+ },\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"a\",\n+ \"check\": \"Number\"\n+ }\n+ ],\n+ \"inputsInline\": true,\n+ \"output\": \"Number\",\n+ \"colour\": 120,\n+ \"tooltip\": \"Round a number up.\",\n+ \"helpUrl\": \"\"\n+ },\n// Sensing ask and wait block\n{\n\"type\": \"sensing_ask_and_wait\",\n@@ -341,6 +360,18 @@ if (programming_lang == \"python\") {\n},\n]);\n+ // Operators round up block\n+ Blockly.JavaScript['operators_round'] = function(block) {\n+ var value_a = Blockly.JavaScript.valueToCode(block, 'a', Blockly.JavaScript.ORDER_ATOMIC);\n+ var code = 'Math.round(' + value_a + ')';\n+ return [code, Blockly.JavaScript.ORDER_NONE];\n+ };\n+ Blockly.Python['operators_round'] = function(block) {\n+ var value_a = Blockly.Python.valueToCode(block, 'a', Blockly.Python.ORDER_ATOMIC);\n+ var code = 'round(' + value_a + ')';\n+ return [code, Blockly.Python.ORDER_NONE];\n+ };\n+\n// Operators logical OR block\nBlockly.JavaScript['operators_or'] = function(block) {\nvar value_a = Blockly.JavaScript.valueToCode(block, 'a', Blockly.JavaScript.ORDER_ATOMIC);\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "</shadow>\n</value>\n</block>\n- <block type=\"math_round\">\n- <field name=\"OP\">ROUND</field>\n- <value name=\"NUM\">\n+ <block type=\"operators_round\">\n+ <value name=\"a\">\n<shadow type=\"math_number\">\n- <field name=\"NUM\">3.1</field>\n+ <field name=\"NUM\">3.14</field>\n</shadow>\n</value>\n</block>\n" } ]
Python
MIT License
uccser/cs-unplugged
Replaced the default Blockly dropdown round block, with new round block that is similar to the Scratch round block.
701,850
15.08.2021 16:46:32
-43,200
8066aa67551d1adddbc4dc2dadee929a3caabe72
Removed the Blockly Text category
[ { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "</block>\n<block type=\"math_random_float\"></block> -->\n</category>\n- <category name=\"Text\" colour=\"#745ba5\">\n- <block type=\"text\">\n- <field name=\"TEXT\"></field>\n- </block>\n- <block type=\"text_join\">\n- <mutation items=\"2\"></mutation>\n- </block>\n- <block type=\"text_append\">\n- <field name=\"VAR\" id=\"ORK?8p5REPgQ?Er1F7.D\">item</field>\n- <value name=\"TEXT\">\n- <shadow type=\"text\">\n- <field name=\"TEXT\"></field>\n- </shadow>\n- </value>\n- </block>\n- <block type=\"text_isEmpty\">\n- <value name=\"VALUE\">\n- <shadow type=\"text\">\n- <field name=\"TEXT\"></field>\n- </shadow>\n- </value>\n- </block>\n- <block type=\"text_indexOf\">\n- <field name=\"END\">FIRST</field>\n- <value name=\"VALUE\">\n- <block type=\"variables_get\">\n- <field name=\"VAR\" id=\"x2O$~p~Zbcheb3G^q4Du\">text</field>\n- </block>\n- </value>\n- <value name=\"FIND\">\n- <shadow type=\"text\">\n- <field name=\"TEXT\">abc</field>\n- </shadow>\n- </value>\n- </block>\n- <block type=\"text_charAt\">\n- <mutation at=\"true\"></mutation>\n- <field name=\"WHERE\">FROM_START</field>\n- <value name=\"VALUE\">\n- <block type=\"variables_get\">\n- <field name=\"VAR\" id=\"x2O$~p~Zbcheb3G^q4Du\">text</field>\n- </block>\n- </value>\n- </block>\n- <block type=\"text_getSubstring\">\n- <mutation at1=\"true\" at2=\"true\"></mutation>\n- <field name=\"WHERE1\">FROM_START</field>\n- <field name=\"WHERE2\">FROM_START</field>\n- <value name=\"STRING\">\n- <block type=\"variables_get\">\n- <field name=\"VAR\" id=\"x2O$~p~Zbcheb3G^q4Du\">text</field>\n- </block>\n- </value>\n- </block>\n- <block type=\"text_changeCase\">\n- <field name=\"CASE\">UPPERCASE</field>\n- <value name=\"TEXT\">\n- <shadow type=\"text\">\n- <field name=\"TEXT\">abc</field>\n- </shadow>\n- </value>\n- </block>\n- <block type=\"text_trim\">\n- <field name=\"MODE\">BOTH</field>\n- <value name=\"TEXT\">\n- <shadow type=\"text\">\n- <field name=\"TEXT\">abc</field>\n- </shadow>\n- </value>\n- </block>\n- <block type=\"text_prompt_ext\">\n- <mutation type=\"TEXT\"></mutation>\n- <field name=\"TYPE\">TEXT</field>\n- <value name=\"TEXT\">\n- <shadow type=\"text\">\n- <field name=\"TEXT\">abc</field>\n- </shadow>\n- </value>\n- </block>\n- </category>\n<category name=\"Lists\" colour=\"#5b80a5\">\n<block type=\"lists_create_with\">\n<mutation items=\"0\"></mutation>\n" } ]
Python
MIT License
uccser/cs-unplugged
Removed the Blockly Text category
701,850
15.08.2021 16:51:22
-43,200
52e9ecdd89a0950282257a3b423e52cc2f9332f4
Removed the Blockly List category.
[ { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "</block>\n<block type=\"math_random_float\"></block> -->\n</category>\n- <category name=\"Lists\" colour=\"#5b80a5\">\n- <block type=\"lists_create_with\">\n- <mutation items=\"0\"></mutation>\n- </block>\n- <block type=\"lists_create_with\">\n- <mutation items=\"3\"></mutation>\n- </block>\n- <block type=\"lists_repeat\">\n- <value name=\"NUM\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">5</field>\n- </shadow>\n- </value>\n- </block>\n- <block type=\"lists_length\"></block>\n- <block type=\"lists_isEmpty\"></block>\n- <block type=\"lists_indexOf\">\n- <field name=\"END\">FIRST</field>\n- <value name=\"VALUE\">\n- <block type=\"variables_get\">\n- <field name=\"VAR\" id=\".:#z/k2m@O`G%QxgNXPJ\">list</field>\n- </block>\n- </value>\n- </block>\n- <block type=\"lists_getIndex\">\n- <mutation statement=\"false\" at=\"true\"></mutation>\n- <field name=\"MODE\">GET</field>\n- <field name=\"WHERE\">FROM_START</field>\n- <value name=\"VALUE\">\n- <block type=\"variables_get\">\n- <field name=\"VAR\" id=\".:#z/k2m@O`G%QxgNXPJ\">list</field>\n- </block>\n- </value>\n- </block>\n- <block type=\"lists_setIndex\">\n- <mutation at=\"true\"></mutation>\n- <field name=\"MODE\">SET</field>\n- <field name=\"WHERE\">FROM_START</field>\n- <value name=\"LIST\">\n- <block type=\"variables_get\">\n- <field name=\"VAR\" id=\".:#z/k2m@O`G%QxgNXPJ\">list</field>\n- </block>\n- </value>\n- </block>\n- <block type=\"lists_getSublist\">\n- <mutation at1=\"true\" at2=\"true\"></mutation>\n- <field name=\"WHERE1\">FROM_START</field>\n- <field name=\"WHERE2\">FROM_START</field>\n- <value name=\"LIST\">\n- <block type=\"variables_get\">\n- <field name=\"VAR\" id=\".:#z/k2m@O`G%QxgNXPJ\">list</field>\n- </block>\n- </value>\n- </block>\n- <block type=\"lists_split\">\n- <mutation mode=\"SPLIT\"></mutation>\n- <field name=\"MODE\">SPLIT</field>\n- <value name=\"DELIM\">\n- <shadow type=\"text\">\n- <field name=\"TEXT\">,</field>\n- </shadow>\n- </value>\n- </block>\n- <block type=\"lists_sort\">\n- <field name=\"TYPE\">NUMERIC</field>\n- <field name=\"DIRECTION\">1</field>\n- </block>\n- </category>\n- <sep></sep>\n<category name=\"Variables\" colour=\"#ff8d1a\" custom=\"VARIABLE\"></category>\n</xml>\n<div class=\"programming__submit d-flex justify-content-between align-items-center\">\n" } ]
Python
MIT License
uccser/cs-unplugged
Removed the Blockly List category.
701,850
15.08.2021 17:53:29
-43,200
fe95766452a2af6ba9aa7e93c5b34db1e7ab9697
Replaced the Blockly print block, with the custom say block
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "@@ -19,8 +19,6 @@ Blockly.setLocale(En);\n// Change default text of default blocks\nconst CustomEs = {\nTEXT_PRINT_TITLE: \"say %1\",\n- TEXT_JOIN_TITLE_CREATEWITH: \"join\",\n- TEXT_INDEXOF_TITLE: \"letter %1 %2 %3\",\nMATH_RANDOM_INT_TITLE: \"pick random %1 to %2\",\nCONTROLS_REPEAT_TITLE: \"repeat %1\",\nCONTROLS_FOR_INPUT_DO: \"\"\n@@ -58,6 +56,26 @@ if (programming_lang == \"python\") {\ndocument.addEventListener(\"DOMContentLoaded\", function () {\n// Custom Blockly blocks to look and act like Scratch\nBlockly.defineBlocksWithJsonArray([\n+ // Looks say block\n+ {\n+ \"type\": \"looks_say\",\n+ \"message0\": \"say %1 %2\",\n+ \"args0\": [\n+ {\n+ \"type\": \"input_dummy\"\n+ },\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"value\"\n+ }\n+ ],\n+ \"inputsInline\": true,\n+ \"previousStatement\": null,\n+ \"nextStatement\": null,\n+ \"colour\": 240,\n+ \"tooltip\": \"Say the specified text, number or other value.\",\n+ \"helpUrl\": \"\"\n+ },\n// Operators modulo block\n{\n\"type\": \"operators_modulo\",\n@@ -80,7 +98,7 @@ if (programming_lang == \"python\") {\n],\n\"inputsInline\": true,\n\"output\": \"Number\",\n- \"colour\": 120,\n+ \"colour\": '#7459c0',\n\"tooltip\": \"Return the modulo of the two numbers.\",\n\"helpUrl\": \"\"\n},\n@@ -360,6 +378,19 @@ if (programming_lang == \"python\") {\n},\n]);\n+ // Looks say block\n+ Blockly.JavaScript['looks_say'] = function(block) {\n+ var value_value = Blockly.JavaScript.valueToCode(block, 'value', Blockly.JavaScript.ORDER_ATOMIC);\n+ // TODO: Assemble JavaScript into code variable.\n+ var code = 'alert(' + value_value + ');\\n';\n+ return code;\n+ };\n+ Blockly.Python['looks_say'] = function(block) {\n+ var value_value = Blockly.Python.valueToCode(block, 'value', Blockly.Python.ORDER_ATOMIC);\n+ var code = 'print(' + value_value + ')\\n';\n+ return code;\n+ };\n+\n// Operators round up block\nBlockly.JavaScript['operators_round'] = function(block) {\nvar value_a = Blockly.JavaScript.valueToCode(block, 'a', Blockly.JavaScript.ORDER_ATOMIC);\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "<div id=\"blocklyDiv\" style=\"height: 100%; \"></div>\n<xml xmlns=\"https://developers.google.com/blockly/xml\" id=\"toolbox\" style=\"display: none\">\n<category name=\"Looks\" colour=\"#9966ff\">\n- <block type=\"text_print\">\n- <value name=\"TEXT\">\n+ <block type=\"looks_say\">\n+ <value name=\"value\">\n<shadow type=\"text\">\n<field name=\"TEXT\">abc</field>\n</shadow>\n<!-- Stop block? -->\n<block type=\"controls_stop\"></block>\n</category>\n- <category name=\"Sensing\" colour=\"#4cc0e6\">\n+ <category name=\"Sensing\" colour=\"#4cbfe6\">\n<block type=\"sensing_ask_and_wait\">\n<value name=\"question\">\n<shadow type=\"text\">\n</value>\n</block>\n</category>\n- <category name=\"Operators\" colour=\"#59c059\">\n+ <category name=\"Operators\" colour=\"#40bf4a\">\n<block type=\"math_number\">\n<field name=\"NUM\">0</field>\n</block>\n</block>\n<block type=\"math_random_float\"></block> -->\n</category>\n- <category name=\"Variables\" colour=\"#ff8d1a\" custom=\"VARIABLE\"></category>\n+ <category name=\"Variables\" colour=\"#ff8c1a\" custom=\"VARIABLE\"></category>\n</xml>\n<div class=\"programming__submit d-flex justify-content-between align-items-center\">\n<div class=\"programming__submit_options d-flex justify-content-start\">\n" } ]
Python
MIT License
uccser/cs-unplugged
Replaced the Blockly print block, with the custom say block
701,850
15.08.2021 19:41:31
-43,200
02771ee468e97fd8b0b559e45e4de99c370e2d50
Replaced the Blockly default 'if, do' block, with the Scratch 'if, then' block and 'if, then, else' block. Also fixed code generators, so that code is converted to Python/JS properly
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "@@ -367,6 +367,61 @@ if (programming_lang == \"python\") {\n\"tooltip\": \"Ask user for some text.\",\n\"helpUrl\": \"\"\n},\n+ // Controls if, then block\n+ {\n+ \"type\": \"controls_if_then\",\n+ \"message0\": \"if %1 then %2 %3\",\n+ \"args0\": [\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"condition\",\n+ \"check\": \"Boolean\"\n+ },\n+ {\n+ \"type\": \"input_dummy\"\n+ },\n+ {\n+ \"type\": \"input_statement\",\n+ \"name\": \"body\"\n+ }\n+ ],\n+ \"previousStatement\": null,\n+ \"nextStatement\": null,\n+ \"colour\": 30,\n+ \"tooltip\": \"\",\n+ \"helpUrl\": \"\"\n+ },\n+ // Controls, if, then, else block\n+ {\n+ \"type\": \"controls_if_then_else\",\n+ \"message0\": \"if %1 then %2 %3 else %4 %5\",\n+ \"args0\": [\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"condition\",\n+ \"check\": \"Boolean\"\n+ },\n+ {\n+ \"type\": \"input_dummy\"\n+ },\n+ {\n+ \"type\": \"input_statement\",\n+ \"name\": \"body_1\"\n+ },\n+ {\n+ \"type\": \"input_dummy\"\n+ },\n+ {\n+ \"type\": \"input_statement\",\n+ \"name\": \"body_2\"\n+ }\n+ ],\n+ \"previousStatement\": null,\n+ \"nextStatement\": null,\n+ \"colour\": 30,\n+ \"tooltip\": \"\",\n+ \"helpUrl\": \"\"\n+ },\n// Controls stop block\n{\n\"type\": \"controls_stop\",\n@@ -378,6 +433,50 @@ if (programming_lang == \"python\") {\n},\n]);\n+ // Controls, if, then, else block\n+ Blockly.JavaScript['controls_if_then_else'] = function(block) {\n+ var value_condition = Blockly.JavaScript.valueToCode(block, 'condition', Blockly.JavaScript.ORDER_ATOMIC) || 'false';\n+ var statements_body_1 = Blockly.JavaScript.statementToCode(block, 'body_1');\n+ var statements_body_2 = Blockly.JavaScript.statementToCode(block, 'body_2');\n+ var code = 'if (' + value_condition + ') {\\n' + statements_body_1 + '} else {\\n' + statements_body_2 + '}\\n';\n+ return code;\n+ };\n+ Blockly.Python['controls_if_then_else'] = function(block) {\n+ var value_condition = Blockly.Python.valueToCode(block, 'condition', Blockly.Python.ORDER_ATOMIC) || \"False\";\n+ var statements_body_1 = Blockly.Python.statementToCode(block, 'body_1');\n+ var statements_body_2 = Blockly.Python.statementToCode(block, 'body_2');\n+\n+ if (statements_body_1 === \"\") {\n+ statements_body_1 = ' pass\\n'; // 2 spaces for indentation in Python\n+ }\n+ if (statements_body_2 === \"\") {\n+ statements_body_2 = ' pass'; // 2 spaces for indentation in Python\n+ }\n+\n+ // TODO: Assemble Python into code variable.\n+ var code = 'if ' + value_condition + ':\\n' + statements_body_1 + 'else:\\n' + statements_body_2 + '\\n';\n+ return code;\n+ };\n+\n+ // Controls if, then block\n+ Blockly.JavaScript['controls_if_then'] = function(block) {\n+ var value_condition = Blockly.JavaScript.valueToCode(block, 'condition', Blockly.JavaScript.ORDER_ATOMIC) || 'false';\n+ var statements_body = Blockly.JavaScript.statementToCode(block, 'body');\n+ var code = 'if (' + value_condition + ') {\\n' + statements_body + '}\\n';\n+ return code;\n+ };\n+ Blockly.Python['controls_if_then'] = function(block) {\n+ var value_condition = Blockly.Python.valueToCode(block, 'condition', Blockly.Python.ORDER_ATOMIC) || \"False\";\n+ var statements_body = Blockly.Python.statementToCode(block, 'body');\n+\n+ if (statements_body === \"\") {\n+ statements_body = ' pass\\n';\n+ }\n+\n+ var code = 'if ' + value_condition + ':\\n' + statements_body + '\\n';\n+ return code;\n+ };\n+\n// Looks say block\nBlockly.JavaScript['looks_say'] = function(block) {\nvar value_value = Blockly.JavaScript.valueToCode(block, 'value', Blockly.JavaScript.ORDER_ATOMIC);\n@@ -405,14 +504,14 @@ if (programming_lang == \"python\") {\n// Operators logical OR block\nBlockly.JavaScript['operators_or'] = function(block) {\n- var value_a = Blockly.JavaScript.valueToCode(block, 'a', Blockly.JavaScript.ORDER_ATOMIC);\n- var value_b = Blockly.JavaScript.valueToCode(block, 'b', Blockly.JavaScript.ORDER_ATOMIC);\n+ var value_a = Blockly.JavaScript.valueToCode(block, 'a', Blockly.JavaScript.ORDER_LOGICAL_OR) || 'false';\n+ var value_b = Blockly.JavaScript.valueToCode(block, 'b', Blockly.JavaScript.ORDER_LOGICAL_OR) || 'false';\nvar code = value_a + ' || ' + value_b;\n- return [code, Blockly.JavaScript.ORDER_NONE];\n+ return [code, Blockly.JavaScript.ORDER_LOGICAL_OR];\n};\nBlockly.Python['operators_or'] = function(block) {\n- var value_a = Blockly.Python.valueToCode(block, 'a', Blockly.Python.ORDER_ATOMIC);\n- var value_b = Blockly.Python.valueToCode(block, 'b', Blockly.Python.ORDER_ATOMIC);\n+ var value_a = Blockly.Python.valueToCode(block, 'a', Blockly.Python.ORDER_ATOMIC) || 'False';\n+ var value_b = Blockly.Python.valueToCode(block, 'b', Blockly.Python.ORDER_ATOMIC) || 'False';\nvar code = value_a + ' or ' + value_b;\nreturn [code, Blockly.Python.ORDER_NONE];\n};\n@@ -420,14 +519,14 @@ if (programming_lang == \"python\") {\n// Operators logical AND block\nBlockly.JavaScript['operators_and'] = function(block) {\n- var value_a = Blockly.JavaScript.valueToCode(block, 'a', Blockly.JavaScript.ORDER_ATOMIC);\n- var value_b = Blockly.JavaScript.valueToCode(block, 'b', Blockly.JavaScript.ORDER_ATOMIC);\n+ var value_a = Blockly.JavaScript.valueToCode(block, 'a', Blockly.JavaScript.ORDER_ATOMIC) || 'false';\n+ var value_b = Blockly.JavaScript.valueToCode(block, 'b', Blockly.JavaScript.ORDER_ATOMIC) || 'false';\nvar code = value_a + ' && ' + value_b;\nreturn [code, Blockly.JavaScript.ORDER_NONE];\n};\nBlockly.Python['operators_and'] = function(block) {\n- var value_a = Blockly.Python.valueToCode(block, 'a', Blockly.Python.ORDER_ATOMIC);\n- var value_b = Blockly.Python.valueToCode(block, 'b', Blockly.Python.ORDER_ATOMIC);\n+ var value_a = Blockly.Python.valueToCode(block, 'a', Blockly.Python.ORDER_ATOMIC) || 'False';\n+ var value_b = Blockly.Python.valueToCode(block, 'b', Blockly.Python.ORDER_ATOMIC) || 'False';\nvar code = value_a + ' and ' + value_b;\nreturn [code, Blockly.Python.ORDER_NONE];\n};\n@@ -448,14 +547,14 @@ if (programming_lang == \"python\") {\nBlockly.JavaScript['sensing_ask_and_wait'] = function(block) {\nvar value_question = Blockly.JavaScript.valueToCode(block, 'question', Blockly.JavaScript.ORDER_ATOMIC);\n// TODO: Assemble JavaScript into code variable.\n- var code = 'prompt(' + value_question + ')'\n+ var code = 'prompt(' + value_question + ');\\n'\n// TODO: Change ORDER_NONE to the correct strength.\nreturn [code, Blockly.JavaScript.ORDER_NONE];\n};\nBlockly.Python['sensing_ask_and_wait'] = function(block) {\nvar value_question = Blockly.Python.valueToCode(block, 'question', Blockly.Python.ORDER_ATOMIC);\n// TODO: Assemble Python into code variable.\n- var code = 'input(' + value_question + ')';\n+ var code = 'input(' + value_question + ')\\n';\n// TODO: Change ORDER_NONE to the correct strength.\nreturn [code, Blockly.Python.ORDER_NONE];\n};\n@@ -673,8 +772,6 @@ async function save_code(status=\"started\") {\nxml_code = Blockly.Xml.workspaceToDom(Blockly.getMainWorkspace());\nraw_code = Blockly.Xml.domToText(xml_code);\n}\n- console.log(\"RAW CODE\")\n- console.log(raw_code)\n// Sets the saved attempt\nlet data = {\n\"challenge\": current_challenge_slug,\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "<!-- Forever loop? -->\n<!-- If then block? -->\n<!-- If then, else block? -->\n- <block type=\"controls_if\"></block>\n+ <block type=\"controls_if_then\"></block>\n+ <block type=\"controls_if_then_else\"></block>\n<block type=\"controls_whileUntil\">\n<field name=\"MODE\">WHILE</field>\n" } ]
Python
MIT License
uccser/cs-unplugged
Replaced the Blockly default 'if, do' block, with the Scratch 'if, then' block and 'if, then, else' block. Also fixed code generators, so that code is converted to Python/JS properly
701,850
15.08.2021 20:32:18
-43,200
38a921e043d8f007263cee3b2fabd948b562a8b3
Replaced the default Blockly repeat block, with new Scratch repeat block.
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "@@ -431,8 +431,57 @@ if (programming_lang == \"python\") {\n\"tooltip\": \"Stops the containing loop.\",\n\"helpUrl\": \"\"\n},\n+ // Controls repeat block\n+ {\n+ \"type\": \"controls_repeat_num_times\",\n+ \"message0\": \"repeat %1 %2 %3 %4\",\n+ \"args0\": [\n+ {\n+ \"type\": \"field_number\",\n+ \"name\": \"num\",\n+ \"value\": 0,\n+ \"min\": 0\n+ },\n+ {\n+ \"type\": \"input_dummy\"\n+ },\n+ {\n+ \"type\": \"input_statement\",\n+ \"name\": \"body\"\n+ },\n+ {\n+ \"type\": \"input_dummy\",\n+ \"align\": \"RIGHT\"\n+ }\n+ ],\n+ \"previousStatement\": null,\n+ \"nextStatement\": null,\n+ \"colour\": 45,\n+ \"tooltip\": \"Do some statements several times.\",\n+ \"helpUrl\": \"\"\n+ }\n]);\n+ // Controls repeat block\n+ Blockly.JavaScript['controls_repeat_num_times'] = function(block) {\n+ var number_num = block.getFieldValue('num') || '0';\n+ var statements_body = Blockly.JavaScript.statementToCode(block, 'body');\n+ var code = 'for (var count = 0; count < ' + number_num + '; count++) {\\n' + statements_body + '}\\n';\n+ return code;\n+ };\n+ Blockly.Python['controls_repeat_num_times'] = function(block) {\n+ var number_num = block.getFieldValue('num') || '0';\n+ var statements_body = Blockly.Python.statementToCode(block, 'body');\n+\n+ if (statements_body === \"\") {\n+ statements_body = ' pass'; // 2 spaces for indentation in Python\n+ }\n+\n+ // TODO: Assemble Python into code variable.\n+ var code = 'for count in range(' + number_num + '):\\n' + statements_body + '\\n';\n+ return code;\n+ };\n+\n// Controls, if, then, else block\nBlockly.JavaScript['controls_if_then_else'] = function(block) {\nvar value_condition = Blockly.JavaScript.valueToCode(block, 'condition', Blockly.JavaScript.ORDER_ATOMIC) || 'false';\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "</block>\n</category>\n<category name=\"Control\" colour=\"#ffab19\">\n- <block type=\"controls_repeat_ext\">\n+ <block type=\"controls_repeat_num_times\"></block>\n+ <!-- <block type=\"controls_repeat_ext\">\n<value name=\"TIMES\">\n<shadow type=\"math_number\">\n<field name=\"NUM\">10</field>\n</shadow>\n</value>\n- </block>\n+ </block> -->\n<!-- Forever loop? -->\n<!-- If then block? -->\n<!-- If then, else block? -->\n" } ]
Python
MIT License
uccser/cs-unplugged
Replaced the default Blockly repeat block, with new Scratch repeat block.
701,850
15.08.2021 22:17:53
-43,200
fba9a96580c8fc756b91d777e4227892b6c9f7e4
Replaced the defauly Blockly 'repeat until' block with Scratch 'repeat until' block
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "@@ -459,9 +459,44 @@ if (programming_lang == \"python\") {\n\"colour\": 45,\n\"tooltip\": \"Do some statements several times.\",\n\"helpUrl\": \"\"\n+ },\n+ // Controls repeat until block\n+ {\n+ \"type\": \"controls_repeat_until\",\n+ \"message0\": \"repeat until %1 %2\",\n+ \"args0\": [\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"condition\",\n+ \"check\": \"Boolean\"\n+ },\n+ {\n+ \"type\": \"input_statement\",\n+ \"name\": \"body\"\n+ }\n+ ],\n+ \"previousStatement\": null,\n+ \"nextStatement\": null,\n+ \"colour\": 45,\n+ \"tooltip\": \"Repeat a statement several times until a condition is met.\",\n+ \"helpUrl\": \"\"\n}\n]);\n+ // Controls repeat until block\n+ Blockly.JavaScript['controls_repeat_until'] = function(block) {\n+ var value_condition = Blockly.JavaScript.valueToCode(block, 'condition', Blockly.JavaScript.ORDER_ATOMIC) || 'false';\n+ var statements_body = Blockly.JavaScript.statementToCode(block, 'body');\n+ var code = 'while (!' + value_condition + ') {\\n' + statements_body + '}\\n';\n+ return code;\n+ };\n+ Blockly.Python['controls_repeat_until'] = function(block) {\n+ var value_condition = Blockly.Python.valueToCode(block, 'condition', Blockly.Python.ORDER_ATOMIC) || 'False';\n+ var statements_body = Blockly.Python.statementToCode(block, 'body') || ' pass';\n+ var code = 'while not ' + value_condition + ':\\n' + statements_body + '\\n';\n+ return code;\n+ };\n+\n// Controls repeat block\nBlockly.JavaScript['controls_repeat_num_times'] = function(block) {\nvar number_num = block.getFieldValue('num') || '0';\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "</category>\n<category name=\"Control\" colour=\"#ffab19\">\n<block type=\"controls_repeat_num_times\"></block>\n- <!-- <block type=\"controls_repeat_ext\">\n- <value name=\"TIMES\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">10</field>\n- </shadow>\n- </value>\n- </block> -->\n<!-- Forever loop? -->\n- <!-- If then block? -->\n- <!-- If then, else block? -->\n<block type=\"controls_if_then\"></block>\n<block type=\"controls_if_then_else\"></block>\n-\n- <block type=\"controls_whileUntil\">\n- <field name=\"MODE\">WHILE</field>\n- </block>\n- <!-- Stop block? -->\n+ <block type=\"controls_repeat_until\"></block>\n<block type=\"controls_stop\"></block>\n</category>\n<category name=\"Sensing\" colour=\"#4cbfe6\">\n<block type=\"math_number\">\n<field name=\"NUM\">0</field>\n</block>\n+ <block type=\"text\">\n+ <field name=\"TEXT\">abc</field>\n+ </block>\n<block type=\"operators_add\">\n<value name=\"x\">\n<shadow type=\"math_number\">\n" } ]
Python
MIT License
uccser/cs-unplugged
Replaced the defauly Blockly 'repeat until' block with Scratch 'repeat until' block
701,850
15.08.2021 22:25:42
-43,200
db2443234d4bb6b4150942b945257d4154139399
Fixed the custom repeat block by changing the block input type.
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "@@ -434,16 +434,12 @@ if (programming_lang == \"python\") {\n// Controls repeat block\n{\n\"type\": \"controls_repeat_num_times\",\n- \"message0\": \"repeat %1 %2 %3 %4\",\n+ \"message0\": \"repeat %1 %2 %3\",\n\"args0\": [\n{\n- \"type\": \"field_number\",\n+ \"type\": \"input_value\",\n\"name\": \"num\",\n- \"value\": 0,\n- \"min\": 0\n- },\n- {\n- \"type\": \"input_dummy\"\n+ \"check\": \"Number\"\n},\n{\n\"type\": \"input_statement\",\n@@ -499,21 +495,16 @@ if (programming_lang == \"python\") {\n// Controls repeat block\nBlockly.JavaScript['controls_repeat_num_times'] = function(block) {\n- var number_num = block.getFieldValue('num') || '0';\n+ var value_num = Blockly.JavaScript.valueToCode(block, 'num', Blockly.JavaScript.ORDER_ATOMIC) || '0';\nvar statements_body = Blockly.JavaScript.statementToCode(block, 'body');\n- var code = 'for (var count = 0; count < ' + number_num + '; count++) {\\n' + statements_body + '}\\n';\n+ var code = 'for (var count = 0; count < ' + value_num + '; count++) {\\n' + statements_body + '}\\n';\nreturn code;\n};\nBlockly.Python['controls_repeat_num_times'] = function(block) {\n- var number_num = block.getFieldValue('num') || '0';\n- var statements_body = Blockly.Python.statementToCode(block, 'body');\n-\n- if (statements_body === \"\") {\n- statements_body = ' pass'; // 2 spaces for indentation in Python\n- }\n+ var value_num = Blockly.Python.valueToCode(block, 'num', Blockly.Python.ORDER_ATOMIC) || '0';\n+ var statements_body = Blockly.Python.statementToCode(block, 'body') || ' pass';\n- // TODO: Assemble Python into code variable.\n- var code = 'for count in range(' + number_num + '):\\n' + statements_body + '\\n';\n+ var code = 'for count in range(' + value_num + '):\\n' + statements_body + '\\n';\nreturn code;\n};\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "</block>\n</category>\n<category name=\"Control\" colour=\"#ffab19\">\n- <block type=\"controls_repeat_num_times\"></block>\n+ <block type=\"controls_repeat_num_times\">\n+ <value name=\"num\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">10</field>\n+ </shadow>\n+ </value>\n+ </block>\n<!-- Forever loop? -->\n<block type=\"controls_if_then\"></block>\n<block type=\"controls_if_then_else\"></block>\n" } ]
Python
MIT License
uccser/cs-unplugged
Fixed the custom repeat block by changing the block input type.
701,850
15.08.2021 23:43:12
-43,200
60eda49d68a7a967bcc895b88b9cc4c1788d82d3
Fixed the look of the repeat block.
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "@@ -434,13 +434,17 @@ if (programming_lang == \"python\") {\n// Controls repeat block\n{\n\"type\": \"controls_repeat_num_times\",\n- \"message0\": \"repeat %1 %2 %3\",\n+ \"message0\": \"repeat %1 %2 %3 %4\",\n\"args0\": [\n{\n\"type\": \"input_value\",\n\"name\": \"num\",\n\"check\": \"Number\"\n},\n+ {\n+ \"type\": \"input_dummy\",\n+ \"align\": \"RIGHT\"\n+ },\n{\n\"type\": \"input_statement\",\n\"name\": \"body\"\n@@ -459,13 +463,16 @@ if (programming_lang == \"python\") {\n// Controls repeat until block\n{\n\"type\": \"controls_repeat_until\",\n- \"message0\": \"repeat until %1 %2\",\n+ \"message0\": \"repeat until %1 %2 %3\",\n\"args0\": [\n{\n\"type\": \"input_value\",\n\"name\": \"condition\",\n\"check\": \"Boolean\"\n},\n+ {\n+ \"type\": \"input_dummy\"\n+ },\n{\n\"type\": \"input_statement\",\n\"name\": \"body\"\n" } ]
Python
MIT License
uccser/cs-unplugged
Fixed the look of the repeat block.
701,850
16.08.2021 00:40:11
-43,200
ce63e4b7d96979d9fecd90f6f158299e69c438ee
Replaced the default Blockly 'pick random number' block, with Scratch version of it'
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "@@ -16,15 +16,6 @@ require('blockly/javascript');\nconst En = require('blockly/msg/en');\nBlockly.setLocale(En);\n-// Change default text of default blocks\n- const CustomEs = {\n- TEXT_PRINT_TITLE: \"say %1\",\n- MATH_RANDOM_INT_TITLE: \"pick random %1 to %2\",\n- CONTROLS_REPEAT_TITLE: \"repeat %1\",\n- CONTROLS_FOR_INPUT_DO: \"\"\n- }\n- Blockly.setLocale(CustomEs);\n-\n// Has to be global as other functions are using these variables\nlet myCodeMirror;\nlet workspace;\n@@ -347,6 +338,33 @@ if (programming_lang == \"python\") {\n\"tooltip\": \"Round a number up.\",\n\"helpUrl\": \"\"\n},\n+ // Operators pick random int block\n+ {\n+ \"type\": \"operators_random_int\",\n+ \"message0\": \"pick random %1 %2 to %3 %4\",\n+ \"args0\": [\n+ {\n+ \"type\": \"input_dummy\"\n+ },\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"a\",\n+ \"check\": \"Number\"\n+ },\n+ {\n+ \"type\": \"input_dummy\"\n+ },\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"b\",\n+ \"check\": \"Number\"\n+ }\n+ ],\n+ \"output\": \"Number\",\n+ \"colour\": 120,\n+ \"tooltip\": \"Return a random integer between the two numbers (inclusive).\",\n+ \"helpUrl\": \"\"\n+ },\n// Sensing ask and wait block\n{\n\"type\": \"sensing_ask_and_wait\",\n@@ -486,6 +504,33 @@ if (programming_lang == \"python\") {\n}\n]);\n+ // Operators pick random int block\n+ Blockly.JavaScript['operators_random_int'] = function(block) {\n+ var value_a = Blockly.JavaScript.valueToCode(block, 'a', Blockly.JavaScript.ORDER_ATOMIC) || '0';\n+ var value_b = Blockly.JavaScript.valueToCode(block, 'b', Blockly.JavaScript.ORDER_ATOMIC) || '0';\n+ var functionName = Blockly.JavaScript.provideFunction_(\n+ 'mathRandomInt',\n+ ['function ' + Blockly.JavaScript.FUNCTION_NAME_PLACEHOLDER_ +\n+ '(a, b) {',\n+ ' if (a > b) {',\n+ ' // Swap a and b to ensure a is smaller.',\n+ ' var c = a;',\n+ ' a = b;',\n+ ' b = c;',\n+ ' }',\n+ ' return Math.floor(Math.random() * (b - a + 1) + a);',\n+ '}']);\n+ var code = functionName + '(' + value_a + ', ' + value_b + ')';\n+ return [code, Blockly.JavaScript.ORDER_NONE];\n+ };\n+ Blockly.Python['operators_random_int'] = function(block) {\n+ Blockly.Python.definitions_['import_random'] = 'import random';\n+ var value_a = Blockly.Python.valueToCode(block, 'a', Blockly.Python.ORDER_NONE);\n+ var value_b = Blockly.Python.valueToCode(block, 'b', Blockly.Python.ORDER_NONE);\n+ var code = 'random.randint(' + value_a + ', ' + value_b + ')';\n+ return [code, Blockly.Python.ORDER_FUNCTION_CALL];\n+ };\n+\n// Controls repeat until block\nBlockly.JavaScript['controls_repeat_until'] = function(block) {\nvar value_condition = Blockly.JavaScript.valueToCode(block, 'condition', Blockly.JavaScript.ORDER_ATOMIC) || 'false';\n@@ -562,7 +607,6 @@ if (programming_lang == \"python\") {\n// Looks say block\nBlockly.JavaScript['looks_say'] = function(block) {\nvar value_value = Blockly.JavaScript.valueToCode(block, 'value', Blockly.JavaScript.ORDER_ATOMIC);\n- // TODO: Assemble JavaScript into code variable.\nvar code = 'alert(' + value_value + ');\\n';\nreturn code;\n};\n@@ -615,12 +659,10 @@ if (programming_lang == \"python\") {\n// Controls stop block\nBlockly.JavaScript['controls_stop'] = function(block) {\n- // TODO: Assemble JavaScript into code variable.\nvar code = 'break;\\n';\nreturn code;\n};\nBlockly.Python['controls_stop'] = function(block) {\n- // TODO: Assemble Python into code variable.\nvar code = 'break\\n';\nreturn code;\n};\n@@ -628,16 +670,12 @@ if (programming_lang == \"python\") {\n// Sensing ask and wait block\nBlockly.JavaScript['sensing_ask_and_wait'] = function(block) {\nvar value_question = Blockly.JavaScript.valueToCode(block, 'question', Blockly.JavaScript.ORDER_ATOMIC);\n- // TODO: Assemble JavaScript into code variable.\nvar code = 'prompt(' + value_question + ');\\n'\n- // TODO: Change ORDER_NONE to the correct strength.\nreturn [code, Blockly.JavaScript.ORDER_NONE];\n};\nBlockly.Python['sensing_ask_and_wait'] = function(block) {\nvar value_question = Blockly.Python.valueToCode(block, 'question', Blockly.Python.ORDER_ATOMIC);\n- // TODO: Assemble Python into code variable.\nvar code = 'input(' + value_question + ')\\n';\n- // TODO: Change ORDER_NONE to the correct strength.\nreturn [code, Blockly.Python.ORDER_NONE];\n};\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "</shadow>\n</value>\n</block>\n- <block type=\"math_random_int\">\n+ <block type=\"operators_random_int\">\n+ <value name=\"a\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">1</field>\n+ </shadow>\n+ </value>\n+ <value name=\"b\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">100</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <!-- <block type=\"math_random_int\">\n<value name=\"FROM\">\n<shadow type=\"math_number\">\n<field name=\"NUM\">1</field>\n<field name=\"NUM\">100</field>\n</shadow>\n</value>\n- </block>\n+ </block> -->\n<block type=\"logic_compare\">\n<field name=\"OP\">EQ</field>\n</block>\n" } ]
Python
MIT License
uccser/cs-unplugged
Replaced the default Blockly 'pick random number' block, with Scratch version of it'
701,850
16.08.2021 01:49:26
-43,200
2fedb3a5bc6b4b882d7d17be79e9c6022738ec17
Replaced default Blockly 'single operand' block with the Scratch 'math single operand' block.
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "@@ -318,6 +318,22 @@ if (programming_lang == \"python\") {\n\"tooltip\": \"Returns true if at least one of the inputs is true.\",\n\"helpUrl\": \"\"\n},\n+ // Operators logical NOT block\n+ {\n+ \"type\": \"operators_not\",\n+ \"message0\": \"not %1\",\n+ \"args0\": [\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"argument\",\n+ \"check\": \"Boolean\"\n+ }\n+ ],\n+ \"output\": \"Boolean\",\n+ \"colour\": 120,\n+ \"tooltip\": \"Return true if the input is false. Returns false if the input is true.\",\n+ \"helpUrl\": \"\"\n+ },\n// Operators round up block\n{\n\"type\": \"operators_round\",\n@@ -365,6 +381,85 @@ if (programming_lang == \"python\") {\n\"tooltip\": \"Return a random integer between the two numbers (inclusive).\",\n\"helpUrl\": \"\"\n},\n+ // Operators single operand block\n+ {\n+ \"type\": \"operators_single\",\n+ \"message0\": \"%1 of %2\",\n+ \"args0\": [\n+ {\n+ \"type\": \"field_dropdown\",\n+ \"name\": \"OP\",\n+ \"options\": [\n+ [\n+ \"abs\",\n+ \"ABS\"\n+ ],\n+ [\n+ \"floor\",\n+ \"FLOOR\"\n+ ],\n+ [\n+ \"ceiling\",\n+ \"CEIL\"\n+ ],\n+ [\n+ \"sqrt\",\n+ \"ROOT\"\n+ ],\n+ [\n+ \"sin\",\n+ \"SIN\"\n+ ],\n+ [\n+ \"cos\",\n+ \"COS\"\n+ ],\n+ [\n+ \"tan\",\n+ \"TAN\"\n+ ],\n+ [\n+ \"asin\",\n+ \"ASIN\"\n+ ],\n+ [\n+ \"acos\",\n+ \"ACOS\"\n+ ],\n+ [\n+ \"atan\",\n+ \"ATAN\"\n+ ],\n+ [\n+ \"ln\",\n+ \"LN\"\n+ ],\n+ [\n+ \"log\",\n+ \"LOG10\"\n+ ],\n+ [\n+ \"e ^\",\n+ \"EXP\"\n+ ],\n+ [\n+ \"10 ^\",\n+ \"POW10\"\n+ ]\n+ ]\n+ },\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"NUM\",\n+ \"check\": \"Number\",\n+ \"align\": \"RIGHT\"\n+ }\n+ ],\n+ \"output\": \"Number\",\n+ \"colour\": 120,\n+ \"tooltip\": \"Block for advanced math operators with single operand.\",\n+ \"helpUrl\": \"\"\n+ },\n// Sensing ask and wait block\n{\n\"type\": \"sensing_ask_and_wait\",\n@@ -504,6 +599,161 @@ if (programming_lang == \"python\") {\n}\n]);\n+ // Operators single operand block\n+ Blockly.JavaScript['operators_single'] = function(block) {\n+ // Math operators with single operand.\n+ var operator = block.getFieldValue('OP');\n+ var code;\n+ var arg;\n+ if (operator == 'SIN' || operator == 'COS' || operator == 'TAN') {\n+ arg = Blockly.JavaScript.valueToCode(block, 'NUM',\n+ Blockly.JavaScript.ORDER_DIVISION) || '0';\n+ } else {\n+ arg = Blockly.JavaScript.valueToCode(block, 'NUM',\n+ Blockly.JavaScript.ORDER_NONE) || '0';\n+ }\n+ // First, handle cases which generate values that don't need parentheses\n+ // wrapping the code.\n+ switch (operator) {\n+ case 'ABS':\n+ code = 'Math.abs(' + arg + ')';\n+ break;\n+ case 'FLOOR':\n+ code = 'Math.floor(' + arg + ')';\n+ break;\n+ case 'CEIL':\n+ code = 'Math.ceil(' + arg + ')';\n+ break;\n+ case 'ROOT':\n+ code = 'Math.sqrt(' + arg + ')';\n+ break;\n+ case 'SIN':\n+ code = 'Math.sin(' + arg + ' / 180 * Math.PI)';\n+ break;\n+ case 'COS':\n+ code = 'Math.cos(' + arg + ' / 180 * Math.PI)';\n+ break;\n+ case 'TAN':\n+ code = 'Math.tan(' + arg + ' / 180 * Math.PI)';\n+ break;\n+ case 'LN':\n+ code = 'Math.log(' + arg + ')';\n+ break;\n+ case 'EXP':\n+ code = 'Math.exp(' + arg + ')';\n+ break;\n+ case 'POW10':\n+ code = 'Math.pow(10,' + arg + ')';\n+ break;\n+ }\n+ if (code) {\n+ return [code, Blockly.JavaScript.ORDER_FUNCTION_CALL];\n+ }\n+ // Second, handle cases which generate values that may need parentheses\n+ // wrapping the code.\n+ switch (operator) {\n+ case 'LOG10':\n+ code = 'Math.log(' + arg + ') / Math.log(10)';\n+ break;\n+ case 'ASIN':\n+ code = 'Math.asin(' + arg + ') / Math.PI * 180';\n+ break;\n+ case 'ACOS':\n+ code = 'Math.acos(' + arg + ') / Math.PI * 180';\n+ break;\n+ case 'ATAN':\n+ code = 'Math.atan(' + arg + ') / Math.PI * 180';\n+ break;\n+ default:\n+ throw Error('Unknown math operator: ' + operator);\n+ }\n+ return [code, Blockly.JavaScript.ORDER_DIVISION];\n+ };\n+ Blockly.Python['operators_single'] = function(block) {\n+ // Math operators with single operand.\n+ var operator = block.getFieldValue('OP');\n+ var code;\n+ var arg;\n+\n+ Blockly.Python.definitions_['import_math'] = 'import math';\n+ if (operator == 'SIN' || operator == 'COS' || operator == 'TAN') {\n+ arg = Blockly.Python.valueToCode(block, 'NUM',\n+ Blockly.Python.ORDER_MULTIPLICATIVE) || '0';\n+ } else {\n+ arg = Blockly.Python.valueToCode(block, 'NUM',\n+ Blockly.Python.ORDER_NONE) || '0';\n+ }\n+\n+ // First, handle cases which generate values that don't need parentheses\n+ // wrapping the code.\n+ switch (operator) {\n+ case 'ABS':\n+ code = 'math.fabs(' + arg + ')';\n+ break;\n+ case 'FLOOR':\n+ code = 'math.floor(' + arg + ')';\n+ break;\n+ case 'CEIL':\n+ code = 'math.ceil(' + arg + ')';\n+ break;\n+ case 'ROOT':\n+ code = 'math.sqrt(' + arg + ')';\n+ break;\n+ case 'SIN':\n+ code = 'math.sin(' + arg + ' / 180.0 * math.pi)';\n+ break;\n+ case 'COS':\n+ code = 'math.cos(' + arg + ' / 180.0 * math.pi)';\n+ break;\n+ case 'TAN':\n+ code = 'math.tan(' + arg + ' / 180.0 * math.pi)';\n+ break;\n+ case 'LN':\n+ code = 'math.log(' + arg + ')';\n+ break;\n+ case 'LOG10':\n+ code = 'math.log10(' + arg + ')';\n+ break;\n+ case 'EXP':\n+ code = 'math.exp(' + arg + ')';\n+ break;\n+ case 'POW10':\n+ code = 'math.pow(10,' + arg + ')';\n+ break;\n+ }\n+ if (code) {\n+ return [code, Blockly.Python.ORDER_FUNCTION_CALL];\n+ }\n+ // Second, handle cases which generate values that may need parentheses\n+ // wrapping the code.\n+ switch (operator) {\n+ case 'ASIN':\n+ code = 'math.asin(' + arg + ') / math.pi * 180';\n+ break;\n+ case 'ACOS':\n+ code = 'math.acos(' + arg + ') / math.pi * 180';\n+ break;\n+ case 'ATAN':\n+ code = 'math.atan(' + arg + ') / math.pi * 180';\n+ break;\n+ default:\n+ throw Error('Unknown math operator: ' + operator);\n+ }\n+ return [code, Blockly.Python.ORDER_MULTIPLICATIVE];\n+ };\n+\n+ // Operators logical NOT block\n+ Blockly.JavaScript['operators_not'] = function(block) {\n+ var value_argument = Blockly.JavaScript.valueToCode(block, 'argument', Blockly.JavaScript.ORDER_LOGICAL_NOT) || 'true';\n+ var code = '!' + value_argument;\n+ return [code, Blockly.JavaScript.ORDER_LOGICAL_NOT];\n+ };\n+ Blockly.Python['operators_not'] = function(block) {\n+ var value_argument = Blockly.Python.valueToCode(block, 'argument', Blockly.Python.ORDER_LOGICAL_NOT);\n+ var code = 'not ' + value_argument;\n+ return [code, Blockly.Python.ORDER_LOGICAL_NOT];\n+ };\n+\n// Operators pick random int block\nBlockly.JavaScript['operators_random_int'] = function(block) {\nvar value_a = Blockly.JavaScript.valueToCode(block, 'a', Blockly.JavaScript.ORDER_ATOMIC) || '0';\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "</block>\n<block type=\"operators_and\"></block>\n<block type=\"operators_or\"></block>\n- <block type=\"logic_negate\"></block>\n+ <block type=\"operators_not\"></block>\n<block type=\"operators_join_string\">\n<value name=\"a\">\n<shadow type=\"text\">\n</shadow>\n</value>\n</block>\n- <block type=\"math_single\">\n- <field name=\"OP\">ROOT</field>\n+ <block type=\"operators_single\">\n+ <field name=\"OP\">ABS</field>\n<value name=\"NUM\">\n<shadow type=\"math_number\">\n<field name=\"NUM\">9</field>\n</shadow>\n</value>\n</block>\n- <!-- <block type=\"math_arithmetic\">\n- <field name=\"OP\">ADD</field>\n- <value name=\"A\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">1</field>\n- </shadow>\n- </value>\n- <value name=\"B\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">1</field>\n- </shadow>\n- </value>\n- </block> -->\n- <block type=\"math_trig\">\n- <field name=\"OP\">SIN</field>\n- <value name=\"NUM\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">45</field>\n- </shadow>\n- </value>\n- </block>\n- <!-- <block type=\"math_number_property\">\n- <mutation divisor_input=\"false\"></mutation>\n- <field name=\"PROPERTY\">EVEN</field>\n- <value name=\"NUMBER_TO_CHECK\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">0</field>\n- </shadow>\n- </value>\n- </block>\n- <block type=\"math_on_list\">\n- <mutation op=\"SUM\"></mutation>\n- <field name=\"OP\">SUM</field>\n- </block>\n- <block type=\"math_modulo\">\n- <value name=\"DIVIDEND\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">64</field>\n- </shadow>\n- </value>\n- <value name=\"DIVISOR\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">10</field>\n- </shadow>\n- </value>\n- </block>\n- <block type=\"math_constrain\">\n- <value name=\"VALUE\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">50</field>\n- </shadow>\n- </value>\n- <value name=\"LOW\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">1</field>\n- </shadow>\n- </value>\n- <value name=\"HIGH\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">100</field>\n- </shadow>\n- </value>\n- </block>\n- <block type=\"math_random_float\"></block> -->\n</category>\n<category name=\"Variables\" colour=\"#ff8c1a\" custom=\"VARIABLE\"></category>\n</xml>\n" } ]
Python
MIT License
uccser/cs-unplugged
Replaced default Blockly 'single operand' block with the Scratch 'math single operand' block.
701,850
16.08.2021 02:17:48
-43,200
04d00d43951726257d36468f67a54b30393d019f
Replaced default Blockly 'compare' block and added 'greater than', 'less than', 'equality' blocks.
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "@@ -460,6 +460,74 @@ if (programming_lang == \"python\") {\n\"tooltip\": \"Block for advanced math operators with single operand.\",\n\"helpUrl\": \"\"\n},\n+ // Operators greater than block\n+ {\n+ \"type\": \"operators_greater_than\",\n+ \"message0\": \"%1 > %2 %3\",\n+ \"args0\": [\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"A\"\n+ },\n+ {\n+ \"type\": \"input_dummy\"\n+ },\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"B\"\n+ }\n+ ],\n+ \"inputsInline\": true,\n+ \"output\": \"Boolean\",\n+ \"colour\": 120,\n+ \"tooltip\": \"Return true if the first input is greater than the second input.\",\n+ \"helpUrl\": \"\"\n+ },\n+ // Operators less than block\n+ {\n+ \"type\": \"operators_less_than\",\n+ \"message0\": \"%1 < %2 %3\",\n+ \"args0\": [\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"A\"\n+ },\n+ {\n+ \"type\": \"input_dummy\"\n+ },\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"B\"\n+ }\n+ ],\n+ \"output\": \"Boolean\",\n+ \"colour\": 120,\n+ \"tooltip\": \"Return true if the second input is greater than the first input.\",\n+ \"helpUrl\": \"\"\n+ },\n+ // Operators equality block\n+ {\n+ \"type\": \"operators_equality\",\n+ \"message0\": \"%1 = %2 %3\",\n+ \"args0\": [\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"A\"\n+ },\n+ {\n+ \"type\": \"input_dummy\"\n+ },\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"B\"\n+ }\n+ ],\n+ \"inputsInline\": true,\n+ \"output\": \"Boolean\",\n+ \"colour\": 120,\n+ \"tooltip\": \"Return true if both inputs equal each other.\",\n+ \"helpUrl\": \"\"\n+ },\n// Sensing ask and wait block\n{\n\"type\": \"sensing_ask_and_wait\",\n@@ -599,6 +667,55 @@ if (programming_lang == \"python\") {\n}\n]);\n+ // Operators equality block\n+ Blockly.JavaScript['operators_equality'] = function(block) {\n+ var order = Blockly.JavaScript.ORDER_RELATIONAL;\n+ var value_a = Blockly.JavaScript.valueToCode(block, 'A', order) || '0';\n+ var value_b = Blockly.JavaScript.valueToCode(block, 'B', order) || '0';\n+ var code = value_a + ' ==' + value_b;\n+ return [code, order];\n+ };\n+ Blockly.Python['operators_equality'] = function(block) {\n+ var order = Blockly.Python.ORDER_RELATIONAL;\n+ var value_a = Blockly.Python.valueToCode(block, 'A', order) || '0';\n+ var value_b = Blockly.Python.valueToCode(block, 'B', order) || '0';\n+ var code = value_a + ' == ' + value_b;\n+ return [code, order];\n+ };\n+\n+\n+ // Operators greater than block\n+ Blockly.JavaScript['operators_less_than'] = function(block) {\n+ var order = Blockly.JavaScript.ORDER_RELATIONAL;\n+ var value_a = Blockly.JavaScript.valueToCode(block, 'A', order);\n+ var value_b = Blockly.JavaScript.valueToCode(block, 'B', order);\n+ var code = value_a + ' < ' + value_b;\n+ return [code, order];\n+ };\n+ Blockly.Python['operators_less_than'] = function(block) {\n+ var order = Blockly.Python.ORDER_RELATIONAL;\n+ var value_a = Blockly.Python.valueToCode(block, 'A', order);\n+ var value_b = Blockly.Python.valueToCode(block, 'B', order);\n+ var code = value_a + ' < ' + value_b;\n+ return [code, order];\n+ };\n+\n+ // Operators greater than block\n+ Blockly.JavaScript['operators_greater_than'] = function(block) {\n+ var order = Blockly.JavaScript.ORDER_RELATIONAL;\n+ var value_a = Blockly.JavaScript.valueToCode(block, 'A', order);\n+ var value_b = Blockly.JavaScript.valueToCode(block, 'B', order);\n+ var code = value_a + ' > ' + value_b;\n+ return [code, order];\n+ };\n+ Blockly.Python['operators_greater_than'] = function(block) {\n+ var order = Blockly.Python.ORDER_RELATIONAL;\n+ var value_a = Blockly.Python.valueToCode(block, 'A', order);\n+ var value_b = Blockly.Python.valueToCode(block, 'B', order);\n+ var code = value_a + ' > ' + value_b;\n+ return [code, order];\n+ };\n+\n// Operators single operand block\nBlockly.JavaScript['operators_single'] = function(block) {\n// Math operators with single operand.\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "</shadow>\n</value>\n</block>\n- <!-- <block type=\"math_random_int\">\n- <value name=\"FROM\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">1</field>\n- </shadow>\n- </value>\n- <value name=\"TO\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">100</field>\n- </shadow>\n- </value>\n- </block> -->\n- <block type=\"logic_compare\">\n- <field name=\"OP\">EQ</field>\n- </block>\n+ <block type=\"operators_greater_than\"></block>\n+ <block type=\"operators_less_than\"></block>\n+ <block type=\"operators_equality\"></block>\n<block type=\"operators_and\"></block>\n<block type=\"operators_or\"></block>\n<block type=\"operators_not\"></block>\n" } ]
Python
MIT License
uccser/cs-unplugged
Replaced default Blockly 'compare' block and added 'greater than', 'less than', 'equality' blocks.
701,850
16.08.2021 09:21:41
-43,200
21b48b9c09a19a2a0dac75e4eb66476a8f258b60
Changed colour of blocks to match with Scratch blocks. Also added text, and number block so that the colour can be modified.
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/editor-options-menu.js", "new_path": "csunplugged/static/js/editor-options-menu.js", "diff": "@@ -78,8 +78,6 @@ function setupLessonNav() {\n// Hides the next/prev challenge buttons if there is no challenge available in that direction.\nconst index = getCurrentIndex();\n- console.log(\"INDEX\")\n- console.log(index);\nif (index === programming_exercises.length-1) {\n$(\"#next_challenge_button\").find('button').hide()\n}\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "@@ -9,12 +9,8 @@ var CodeMirror = require(\"codemirror\");\nrequire(\"codemirror/mode/python/python.js\");\n// Blockly editor imports\n-const Blockly = require('blockly/core');\n-require('blockly/blocks');\n+const Blockly = require('blockly');\nrequire('blockly/python');\n-require('blockly/javascript');\n-const En = require('blockly/msg/en');\n-Blockly.setLocale(En);\n// Has to be global as other functions are using these variables\nlet myCodeMirror;\n@@ -45,6 +41,12 @@ if (programming_lang == \"python\") {\n} else {\n// Set up blockly editor\ndocument.addEventListener(\"DOMContentLoaded\", function () {\n+\n+ const LOOKS_BLOCKS_COLOUR = '#9966ff'\n+ const CONTROL_BLOCKS_COLOUR = '#ffab19'\n+ const SENSING_BLOCKS_COLOUR = '#5cb1d6'\n+ const OPERATORS_BLOCKS_COLOUR = '#59c059'\n+\n// Custom Blockly blocks to look and act like Scratch\nBlockly.defineBlocksWithJsonArray([\n// Looks say block\n@@ -63,10 +65,43 @@ if (programming_lang == \"python\") {\n\"inputsInline\": true,\n\"previousStatement\": null,\n\"nextStatement\": null,\n- \"colour\": 240,\n+ \"colour\": LOOKS_BLOCKS_COLOUR,\n\"tooltip\": \"Say the specified text, number or other value.\",\n\"helpUrl\": \"\"\n},\n+ // Operators number block\n+ {\n+ \"type\": \"operators_number\",\n+ \"message0\": \"%1\",\n+ \"args0\": [{\n+ \"type\": \"field_number\",\n+ \"name\": \"NUM\",\n+ \"value\": 0\n+ }],\n+ \"output\": \"Number\",\n+ \"helpUrl\": \"\",\n+ \"colour\": '#4c97ff',\n+ \"tooltip\": \"A number.\",\n+ \"extensions\": [\"parent_tooltip_when_inline\"]\n+ },\n+ // Operators text block\n+ {\n+ \"type\": \"operators_string\",\n+ \"message0\": \"%1\",\n+ \"args0\": [{\n+ \"type\": \"field_input\",\n+ \"name\": \"TEXT\",\n+ \"text\": \"\"\n+ }],\n+ \"output\": \"String\",\n+ \"colour\": '#4c97ff',\n+ \"helpUrl\": \"\",\n+ \"tooltip\": \"A letter, word, or a line or text.\",\n+ \"extensions\": [\n+ \"text_quotes\",\n+ \"parent_tooltip_when_inline\"\n+ ]\n+ },\n// Operators modulo block\n{\n\"type\": \"operators_modulo\",\n@@ -89,7 +124,7 @@ if (programming_lang == \"python\") {\n],\n\"inputsInline\": true,\n\"output\": \"Number\",\n- \"colour\": '#7459c0',\n+ \"colour\": OPERATORS_BLOCKS_COLOUR,\n\"tooltip\": \"Return the modulo of the two numbers.\",\n\"helpUrl\": \"\"\n},\n@@ -114,7 +149,7 @@ if (programming_lang == \"python\") {\n],\n\"inputsInline\": true,\n\"output\": \"Number\",\n- \"colour\": 120,\n+ \"colour\": OPERATORS_BLOCKS_COLOUR,\n\"tooltip\": \"Return the product of the two numbers.\",\n\"helpUrl\": \"\"\n},\n@@ -139,7 +174,7 @@ if (programming_lang == \"python\") {\n],\n\"inputsInline\": true,\n\"output\": \"Number\",\n- \"colour\": 120,\n+ \"colour\": OPERATORS_BLOCKS_COLOUR,\n\"tooltip\": \"Return the quotient of the two numbers.\",\n\"helpUrl\": \"\"\n},\n@@ -164,7 +199,7 @@ if (programming_lang == \"python\") {\n],\n\"inputsInline\": true,\n\"output\": \"Number\",\n- \"colour\": 120,\n+ \"colour\": OPERATORS_BLOCKS_COLOUR,\n\"tooltip\": \"Return the sum of the two numbers.\",\n\"helpUrl\": \"\"\n},\n@@ -189,7 +224,7 @@ if (programming_lang == \"python\") {\n],\n\"inputsInline\": true,\n\"output\": \"Number\",\n- \"colour\": 120,\n+ \"colour\": OPERATORS_BLOCKS_COLOUR,\n\"tooltip\": \"Return the difference of the two numbers.\",\n\"helpUrl\": \"\"\n},\n@@ -214,7 +249,7 @@ if (programming_lang == \"python\") {\n],\n\"inputsInline\": true,\n\"output\": \"String\",\n- \"colour\": 120,\n+ \"colour\": OPERATORS_BLOCKS_COLOUR,\n\"tooltip\": \"Returns a combination of the two input strings added together.\",\n\"helpUrl\": \"\"\n},\n@@ -241,7 +276,7 @@ if (programming_lang == \"python\") {\n}\n],\n\"output\": \"String\",\n- \"colour\": 120,\n+ \"colour\": OPERATORS_BLOCKS_COLOUR,\n\"tooltip\": \"Returns the letter of the specified position. #1 is the first item.\",\n\"helpUrl\": \"\"\n},\n@@ -266,10 +301,29 @@ if (programming_lang == \"python\") {\n],\n\"inputsInline\": true,\n\"output\": \"Boolean\",\n- \"colour\": 120,\n+ \"colour\": OPERATORS_BLOCKS_COLOUR,\n\"tooltip\": \"Returns true if the second string is in the first string.\",\n\"helpUrl\": \"\"\n},\n+ // Operators length of\n+ {\n+ \"type\": \"operators_length_of\",\n+ \"message0\": \"length of %1 %2\",\n+ \"args0\": [\n+ {\n+ \"type\": \"input_value\",\n+ \"name\": \"VALUE\",\n+ \"check\": \"String\"\n+ },\n+ {\n+ \"type\": \"input_dummy\"\n+ }\n+ ],\n+ \"output\": \"Number\",\n+ \"colour\": OPERATORS_BLOCKS_COLOUR,\n+ \"tooltip\": \"\",\n+ \"helpUrl\": \"\"\n+ },\n// Operators logical AND block\n{\n\"type\": \"operators_and\",\n@@ -290,7 +344,7 @@ if (programming_lang == \"python\") {\n}\n],\n\"output\": \"Boolean\",\n- \"colour\": 120,\n+ \"colour\": OPERATORS_BLOCKS_COLOUR,\n\"tooltip\": \"Returns true if both inputs are true.\",\n\"helpUrl\": \"\"\n},\n@@ -314,23 +368,26 @@ if (programming_lang == \"python\") {\n}\n],\n\"output\": \"Boolean\",\n- \"colour\": 120,\n+ \"colour\": OPERATORS_BLOCKS_COLOUR,\n\"tooltip\": \"Returns true if at least one of the inputs is true.\",\n\"helpUrl\": \"\"\n},\n// Operators logical NOT block\n{\n\"type\": \"operators_not\",\n- \"message0\": \"not %1\",\n+ \"message0\": \"not %1 %2\",\n\"args0\": [\n{\n\"type\": \"input_value\",\n\"name\": \"argument\",\n\"check\": \"Boolean\"\n+ },\n+ {\n+ \"type\": \"input_dummy\"\n}\n],\n\"output\": \"Boolean\",\n- \"colour\": 120,\n+ \"colour\": OPERATORS_BLOCKS_COLOUR,\n\"tooltip\": \"Return true if the input is false. Returns false if the input is true.\",\n\"helpUrl\": \"\"\n},\n@@ -350,7 +407,7 @@ if (programming_lang == \"python\") {\n],\n\"inputsInline\": true,\n\"output\": \"Number\",\n- \"colour\": 120,\n+ \"colour\": OPERATORS_BLOCKS_COLOUR,\n\"tooltip\": \"Round a number up.\",\n\"helpUrl\": \"\"\n},\n@@ -377,14 +434,14 @@ if (programming_lang == \"python\") {\n}\n],\n\"output\": \"Number\",\n- \"colour\": 120,\n+ \"colour\": OPERATORS_BLOCKS_COLOUR,\n\"tooltip\": \"Return a random integer between the two numbers (inclusive).\",\n\"helpUrl\": \"\"\n},\n// Operators single operand block\n{\n\"type\": \"operators_single\",\n- \"message0\": \"%1 of %2\",\n+ \"message0\": \"%1 of %2 %3\",\n\"args0\": [\n{\n\"type\": \"field_dropdown\",\n@@ -453,10 +510,13 @@ if (programming_lang == \"python\") {\n\"name\": \"NUM\",\n\"check\": \"Number\",\n\"align\": \"RIGHT\"\n+ },\n+ {\n+ \"type\": \"input_dummy\"\n}\n],\n\"output\": \"Number\",\n- \"colour\": 120,\n+ \"colour\": OPERATORS_BLOCKS_COLOUR,\n\"tooltip\": \"Block for advanced math operators with single operand.\",\n\"helpUrl\": \"\"\n},\n@@ -479,7 +539,7 @@ if (programming_lang == \"python\") {\n],\n\"inputsInline\": true,\n\"output\": \"Boolean\",\n- \"colour\": 120,\n+ \"colour\": OPERATORS_BLOCKS_COLOUR,\n\"tooltip\": \"Return true if the first input is greater than the second input.\",\n\"helpUrl\": \"\"\n},\n@@ -501,7 +561,7 @@ if (programming_lang == \"python\") {\n}\n],\n\"output\": \"Boolean\",\n- \"colour\": 120,\n+ \"colour\": OPERATORS_BLOCKS_COLOUR,\n\"tooltip\": \"Return true if the second input is greater than the first input.\",\n\"helpUrl\": \"\"\n},\n@@ -524,7 +584,7 @@ if (programming_lang == \"python\") {\n],\n\"inputsInline\": true,\n\"output\": \"Boolean\",\n- \"colour\": 120,\n+ \"colour\": OPERATORS_BLOCKS_COLOUR,\n\"tooltip\": \"Return true if both inputs equal each other.\",\n\"helpUrl\": \"\"\n},\n@@ -544,7 +604,7 @@ if (programming_lang == \"python\") {\n],\n\"inputsInline\": true,\n\"output\": \"String\",\n- \"colour\": 180,\n+ \"colour\": SENSING_BLOCKS_COLOUR,\n\"tooltip\": \"Ask user for some text.\",\n\"helpUrl\": \"\"\n},\n@@ -568,7 +628,7 @@ if (programming_lang == \"python\") {\n],\n\"previousStatement\": null,\n\"nextStatement\": null,\n- \"colour\": 30,\n+ \"colour\": CONTROL_BLOCKS_COLOUR,\n\"tooltip\": \"\",\n\"helpUrl\": \"\"\n},\n@@ -599,7 +659,7 @@ if (programming_lang == \"python\") {\n],\n\"previousStatement\": null,\n\"nextStatement\": null,\n- \"colour\": 30,\n+ \"colour\": CONTROL_BLOCKS_COLOUR,\n\"tooltip\": \"\",\n\"helpUrl\": \"\"\n},\n@@ -608,7 +668,7 @@ if (programming_lang == \"python\") {\n\"type\": \"controls_stop\",\n\"message0\": \"stop\",\n\"previousStatement\": null,\n- \"colour\": 15,\n+ \"colour\": CONTROL_BLOCKS_COLOUR,\n\"tooltip\": \"Stops the containing loop.\",\n\"helpUrl\": \"\"\n},\n@@ -637,7 +697,7 @@ if (programming_lang == \"python\") {\n],\n\"previousStatement\": null,\n\"nextStatement\": null,\n- \"colour\": 45,\n+ \"colour\": CONTROL_BLOCKS_COLOUR,\n\"tooltip\": \"Do some statements several times.\",\n\"helpUrl\": \"\"\n},\n@@ -661,12 +721,61 @@ if (programming_lang == \"python\") {\n],\n\"previousStatement\": null,\n\"nextStatement\": null,\n- \"colour\": 45,\n+ \"colour\": CONTROL_BLOCKS_COLOUR,\n\"tooltip\": \"Repeat a statement several times until a condition is met.\",\n\"helpUrl\": \"\"\n}\n]);\n+ // Operators number block\n+ Blockly.JavaScript['operators_number'] = function(block) {\n+ // Numeric value.\n+ var code = Number(block.getFieldValue('NUM'));\n+ var order = code >= 0 ? Blockly.JavaScript.ORDER_ATOMIC :\n+ Blockly.JavaScript.ORDER_UNARY_NEGATION;\n+ return [code, order];\n+ };\n+ Blockly.Python['operators_number'] = function(block) {\n+ // Numeric value.\n+ var code = Number(block.getFieldValue('NUM'));\n+ var order;\n+ if (code == Infinity) {\n+ code = 'float(\"inf\")';\n+ order = Blockly.Python.ORDER_FUNCTION_CALL;\n+ } else if (code == -Infinity) {\n+ code = '-float(\"inf\")';\n+ order = Blockly.Python.ORDER_UNARY_SIGN;\n+ } else {\n+ order = code < 0 ? Blockly.Python.ORDER_UNARY_SIGN :\n+ Blockly.Python.ORDER_ATOMIC;\n+ }\n+ return [code, order];\n+ };\n+\n+ // Operators text block\n+ Blockly.JavaScript['operators_string'] = function(block) {\n+ // Text value.\n+ var code = Blockly.JavaScript.quote_(block.getFieldValue('TEXT'));\n+ return [code, Blockly.JavaScript.ORDER_ATOMIC];\n+ };\n+ Blockly.Python['operators_string'] = function(block) {\n+ // Text value.\n+ var code = Blockly.Python.quote_(block.getFieldValue('TEXT'));\n+ return [code, Blockly.Python.ORDER_ATOMIC];\n+ };\n+\n+ // Operators length of\n+ Blockly.JavaScript['operators_length_of'] = function(block) {\n+ // String or array length.\n+ var text = Blockly.JavaScript.valueToCode(block, 'VALUE', Blockly.JavaScript.ORDER_MEMBER) || '\\'\\'';\n+ return [text + '.length', Blockly.JavaScript.ORDER_MEMBER];\n+ };\n+ Blockly.Python['operators_length_of'] = function(block) {\n+ // Is the string null or array empty?\n+ var text = Blockly.Python.valueToCode(block, 'VALUE', Blockly.Python.ORDER_NONE) || '\\'\\'';\n+ return ['len(' + text + ')', Blockly.Python.ORDER_FUNCTION_CALL];\n+ };\n+\n// Operators equality block\nBlockly.JavaScript['operators_equality'] = function(block) {\nvar order = Blockly.JavaScript.ORDER_RELATIONAL;\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "</block>\n</category>\n<category name=\"Operators\" colour=\"#40bf4a\">\n- <block type=\"math_number\">\n+ <block type=\"operators_number\">\n<field name=\"NUM\">0</field>\n</block>\n- <block type=\"text\">\n+ <block type=\"operators_string\">\n<field name=\"TEXT\">abc</field>\n</block>\n<block type=\"operators_add\">\n</shadow>\n</value>\n</block>\n- <block type=\"text_length\">\n+ <block type=\"operators_length_of\">\n<value name=\"VALUE\">\n<shadow type=\"text\">\n<field name=\"TEXT\">abc</field>\n" } ]
Python
MIT License
uccser/cs-unplugged
Changed colour of blocks to match with Scratch blocks. Also added text, and number block so that the colour can be modified.
701,850
18.08.2021 06:57:07
-43,200
821d9acb7e75c317a0dc2017cfb1d76565ad3cea
Fixed comment and colour of sensing blocks.
[ { "change_type": "MODIFY", "old_path": "csunplugged/plugging_it_in/views.py", "new_path": "csunplugged/plugging_it_in/views.py", "diff": "@@ -135,7 +135,7 @@ class ProgrammingChallengeView(generic.DetailView):\ntry:\nprogramming_lang_slug = self.kwargs.get(\"programming_lang_slug\", None)\n- context[\"programming_lang\"] = programming_lang_slug.lower() # make sure the /python or /block-based is lower case, because this will get checked in the programming.\n+ context[\"programming_lang\"] = programming_lang_slug.lower() # make sure the /python or /block-based is lower case, because this will get checked in the programming-challenge.html page\nlesson_slug = self.kwargs.get(\"lesson_slug\", None)\nlesson = Lesson.objects.get(slug=lesson_slug)\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/static/js/custom-blockly-blocks.js", "new_path": "csunplugged/static/js/custom-blockly-blocks.js", "diff": "@@ -579,7 +579,7 @@ Blockly.defineBlocksWithJsonArray([\n],\n\"inputsInline\": true,\n\"output\": \"String\",\n- \"colour\": 180,\n+ \"colour\": SENSING_BLOCKS_COLOUR,\n\"tooltip\": \"Ask user for some text.\",\n\"helpUrl\": \"\"\n},\n" } ]
Python
MIT License
uccser/cs-unplugged
Fixed comment and colour of sensing blocks.
701,850
18.08.2021 11:46:49
-43,200
aaee5dadefab954c065edd05b1e0d5f74d50b0d4
Moved the xml toolbar from the programming-challenge.html to a separate xml file.
[ { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/templates/plugging_it_in/block-based-toolbox.xml", "diff": "+<xml xmlns=\"https://developers.google.com/blockly/xml\" id=\"toolbox\" style=\"display: none\">\n+ <category name=\"Values\" colour=\"#4c97ff\">\n+ <block type=\"operators_number\">\n+ <field name=\"NUM\">0</field>\n+ </block>\n+ <block type=\"operators_string\">\n+ <field name=\"TEXT\">abc</field>\n+ </block>\n+ </category>\n+ <category name=\"Looks\" colour=\"#9966ff\">\n+ <block type=\"looks_say\">\n+ <value name=\"value\">\n+ <shadow type=\"text\">\n+ <field name=\"TEXT\">abc</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ </category>\n+ <category name=\"Control\" colour=\"#ffab19\">\n+ <block type=\"controls_repeat_num_times\">\n+ <value name=\"num\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">10</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <!-- Forever loop? -->\n+ <block type=\"controls_if_then\"></block>\n+ <block type=\"controls_if_then_else\"></block>\n+ <block type=\"controls_repeat_until\"></block>\n+ <block type=\"controls_stop\"></block>\n+ </category>\n+ <category name=\"Sensing\" colour=\"#4cbfe6\">\n+ <block type=\"sensing_ask_and_wait\">\n+ <value name=\"question\">\n+ <shadow type=\"text\">\n+ <field name=\"TEXT\">What is your name?</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ </category>\n+ <category name=\"Operators\" colour=\"#40bf4a\">\n+ <block type=\"operators_add\">\n+ <value name=\"x\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">1</field>\n+ </shadow>\n+ </value>\n+ <value name=\"y\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">1</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"operators_subtract\">\n+ <value name=\"x\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">1</field>\n+ </shadow>\n+ </value>\n+ <value name=\"y\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">1</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"operators_multiply\">\n+ <value name=\"x\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">1</field>\n+ </shadow>\n+ </value>\n+ <value name=\"y\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">1</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"operators_divide\">\n+ <value name=\"x\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">1</field>\n+ </shadow>\n+ </value>\n+ <value name=\"y\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">1</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"operators_random_int\">\n+ <value name=\"a\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">1</field>\n+ </shadow>\n+ </value>\n+ <value name=\"b\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">100</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"operators_greater_than\"></block>\n+ <block type=\"operators_less_than\"></block>\n+ <block type=\"operators_equality\"></block>\n+ <block type=\"operators_and\"></block>\n+ <block type=\"operators_or\"></block>\n+ <block type=\"operators_not\"></block>\n+ <block type=\"operators_join_string\">\n+ <value name=\"a\">\n+ <shadow type=\"text\">\n+ <field name=\"TEXT\">apple </field>\n+ </shadow>\n+ </value>\n+ <value name=\"b\">\n+ <shadow type=\"text\">\n+ <field name=\"TEXT\">banana</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"operators_letter_of\">\n+ <value name=\"index\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">1</field>\n+ </shadow>\n+ </value>\n+ <value name=\"word\">\n+ <shadow type=\"text\">\n+ <field name=\"TEXT\">apple</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"operators_length_of\">\n+ <value name=\"VALUE\">\n+ <shadow type=\"text\">\n+ <field name=\"TEXT\">abc</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"operators_string_contains\">\n+ <value name=\"word\">\n+ <shadow type=\"text\">\n+ <field name=\"TEXT\">apple</field>\n+ </shadow>\n+ </value>\n+ <value name=\"subword\">\n+ <shadow type=\"text\">\n+ <field name=\"TEXT\">a</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ </block>\n+ <block type=\"operators_modulo\">\n+ <value name=\"a\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">-3</field>\n+ </shadow>\n+ </value>\n+ <value name=\"n\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">2</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"operators_round\">\n+ <value name=\"a\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">3.14</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"operators_single\">\n+ <field name=\"OP\">ABS</field>\n+ <value name=\"NUM\">\n+ <shadow type=\"math_number\">\n+ <field name=\"NUM\">9</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ </category>\n+ <category name=\"Variables\" colour=\"#ff8c1a\" custom=\"VARIABLE\"></category>\n+</xml>\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "<div class=\"col-12 col-md-5 programming__editor\">\n<p class='pii-block-heading'>{% trans \"Create your program in the editor below\" %}</p>\n<div id=\"blocklyDiv\" style=\"height: 100%; \"></div>\n- <xml xmlns=\"https://developers.google.com/blockly/xml\" id=\"toolbox\" style=\"display: none\">\n- <category name=\"Values\" colour=\"#4c97ff\">\n- <block type=\"operators_number\">\n- <field name=\"NUM\">0</field>\n- </block>\n- <block type=\"operators_string\">\n- <field name=\"TEXT\">abc</field>\n- </block>\n- </category>\n- <category name=\"Looks\" colour=\"#9966ff\">\n- <block type=\"looks_say\">\n- <value name=\"value\">\n- <shadow type=\"text\">\n- <field name=\"TEXT\">abc</field>\n- </shadow>\n- </value>\n- </block>\n- </category>\n- <category name=\"Control\" colour=\"#ffab19\">\n- <block type=\"controls_repeat_num_times\">\n- <value name=\"num\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">10</field>\n- </shadow>\n- </value>\n- </block>\n- <!-- Forever loop? -->\n- <block type=\"controls_if_then\"></block>\n- <block type=\"controls_if_then_else\"></block>\n- <block type=\"controls_repeat_until\"></block>\n- <block type=\"controls_stop\"></block>\n- </category>\n- <category name=\"Sensing\" colour=\"#4cbfe6\">\n- <block type=\"sensing_ask_and_wait\">\n- <value name=\"question\">\n- <shadow type=\"text\">\n- <field name=\"TEXT\">What is your name?</field>\n- </shadow>\n- </value>\n- </block>\n- </category>\n- <category name=\"Operators\" colour=\"#40bf4a\">\n- <block type=\"operators_add\">\n- <value name=\"x\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">1</field>\n- </shadow>\n- </value>\n- <value name=\"y\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">1</field>\n- </shadow>\n- </value>\n- </block>\n- <block type=\"operators_subtract\">\n- <value name=\"x\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">1</field>\n- </shadow>\n- </value>\n- <value name=\"y\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">1</field>\n- </shadow>\n- </value>\n- </block>\n- <block type=\"operators_multiply\">\n- <value name=\"x\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">1</field>\n- </shadow>\n- </value>\n- <value name=\"y\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">1</field>\n- </shadow>\n- </value>\n- </block>\n- <block type=\"operators_divide\">\n- <value name=\"x\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">1</field>\n- </shadow>\n- </value>\n- <value name=\"y\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">1</field>\n- </shadow>\n- </value>\n- </block>\n- <block type=\"operators_random_int\">\n- <value name=\"a\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">1</field>\n- </shadow>\n- </value>\n- <value name=\"b\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">100</field>\n- </shadow>\n- </value>\n- </block>\n- <block type=\"operators_greater_than\"></block>\n- <block type=\"operators_less_than\"></block>\n- <block type=\"operators_equality\"></block>\n- <block type=\"operators_and\"></block>\n- <block type=\"operators_or\"></block>\n- <block type=\"operators_not\"></block>\n- <block type=\"operators_join_string\">\n- <value name=\"a\">\n- <shadow type=\"text\">\n- <field name=\"TEXT\">apple </field>\n- </shadow>\n- </value>\n- <value name=\"b\">\n- <shadow type=\"text\">\n- <field name=\"TEXT\">banana</field>\n- </shadow>\n- </value>\n- </block>\n- <block type=\"operators_letter_of\">\n- <value name=\"index\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">1</field>\n- </shadow>\n- </value>\n- <value name=\"word\">\n- <shadow type=\"text\">\n- <field name=\"TEXT\">apple</field>\n- </shadow>\n- </value>\n- </block>\n- <block type=\"operators_length_of\">\n- <value name=\"VALUE\">\n- <shadow type=\"text\">\n- <field name=\"TEXT\">abc</field>\n- </shadow>\n- </value>\n- </block>\n- <block type=\"operators_string_contains\">\n- <value name=\"word\">\n- <shadow type=\"text\">\n- <field name=\"TEXT\">apple</field>\n- </shadow>\n- </value>\n- <value name=\"subword\">\n- <shadow type=\"text\">\n- <field name=\"TEXT\">a</field>\n- </shadow>\n- </value>\n- </block>\n- </block>\n- <block type=\"operators_modulo\">\n- <value name=\"a\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">-3</field>\n- </shadow>\n- </value>\n- <value name=\"n\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">2</field>\n- </shadow>\n- </value>\n- </block>\n- <block type=\"operators_round\">\n- <value name=\"a\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">3.14</field>\n- </shadow>\n- </value>\n- </block>\n- <block type=\"operators_single\">\n- <field name=\"OP\">ABS</field>\n- <value name=\"NUM\">\n- <shadow type=\"math_number\">\n- <field name=\"NUM\">9</field>\n- </shadow>\n- </value>\n- </block>\n- </category>\n- <category name=\"Variables\" colour=\"#ff8c1a\" custom=\"VARIABLE\"></category>\n- </xml>\n+ {% include \"plugging_it_in/block-based-toolbox.xml\" %}\n<div class=\"programming__submit d-flex justify-content-between align-items-center\">\n<div class=\"programming__submit_options d-flex justify-content-start\">\n<button class=\"editor_button\" id=\"blockly_editor_run_program_button\" >{% trans \"Run\" %}</button>\n" } ]
Python
MIT License
uccser/cs-unplugged
Moved the xml toolbar from the programming-challenge.html to a separate xml file.
701,850
18.08.2021 16:25:52
-43,200
cc57b7440a696a81074f1ab960f433270d17013e
Modify Blockly editor zoom controls
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "@@ -67,9 +67,9 @@ if (programming_lang == \"python\") {\nzoom : {\ncontrols : true,\nwheel : true,\n- startScale : 1,\n- maxScale : 3,\n- minScale : 0.3,\n+ startScale : 0.8,\n+ maxScale : 1.7,\n+ minScale : 0.5,\nscaleSpeed : 1.2\n}\n};\n" } ]
Python
MIT License
uccser/cs-unplugged
Modify Blockly editor zoom controls
701,850
19.08.2021 21:23:58
-43,200
cccdbdd786325b7b80c8d0a4b7022fc00ce342e8
Add boolean block in Values category and abstracted colour of Values block
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/custom-blockly-blocks.js", "new_path": "csunplugged/static/js/custom-blockly-blocks.js", "diff": "+const VALUES_BLOCKS_COLOUR = '#4c97ff'\nconst LOOKS_BLOCKS_COLOUR = '#9966ff'\nconst CONTROL_BLOCKS_COLOUR = '#ffab19'\nconst SENSING_BLOCKS_COLOUR = '#5cb1d6'\n@@ -7,6 +8,31 @@ function setupBlockly(Blockly) {\n// Custom Blockly blocks to look and act like Scratch\nBlockly.defineBlocksWithJsonArray([\n+ // Values boolean block\n+ {\n+ \"type\": \"values_boolean\",\n+ \"message0\": \"%1\",\n+ \"args0\": [\n+ {\n+ \"type\": \"field_dropdown\",\n+ \"name\": \"VALUE\",\n+ \"options\": [\n+ [\n+ \"true\",\n+ \"TRUE\"\n+ ],\n+ [\n+ \"false\",\n+ \"FALSE\"\n+ ]\n+ ]\n+ }\n+ ],\n+ \"output\": \"Boolean\",\n+ \"colour\": VALUES_BLOCKS_COLOUR,\n+ \"tooltip\": \"Returns either true or false.\",\n+ \"helpUrl\": \"\"\n+ },\n// Looks say block\n{\n\"type\": \"looks_say\",\n@@ -29,7 +55,7 @@ Blockly.defineBlocksWithJsonArray([\n},\n// Operators number block\n{\n- \"type\": \"operators_number\",\n+ \"type\": \"values_number\",\n\"message0\": \"%1\",\n\"args0\": [{\n\"type\": \"field_number\",\n@@ -38,13 +64,13 @@ Blockly.defineBlocksWithJsonArray([\n}],\n\"output\": \"Number\",\n\"helpUrl\": \"\",\n- \"colour\": '#4c97ff',\n+ \"colour\": VALUES_BLOCKS_COLOUR,\n\"tooltip\": \"A number.\",\n\"extensions\": [\"parent_tooltip_when_inline\"]\n},\n// Operators text block\n{\n- \"type\": \"operators_string\",\n+ \"type\": \"values_string\",\n\"message0\": \"%1\",\n\"args0\": [{\n\"type\": \"field_input\",\n@@ -52,7 +78,7 @@ Blockly.defineBlocksWithJsonArray([\n\"text\": \"\"\n}],\n\"output\": \"String\",\n- \"colour\": '#4c97ff',\n+ \"colour\": VALUES_BLOCKS_COLOUR,\n\"helpUrl\": \"\",\n\"tooltip\": \"A letter, word, or a line or text.\",\n\"extensions\": [\n@@ -702,15 +728,27 @@ Blockly.defineBlocksWithJsonArray([\n}\n]);\n+// Values boolean block\n+Blockly.JavaScript['values_boolean'] = function(block) {\n+ var dropdown_value = block.getFieldValue('VALUE');\n+ var code = (dropdown_value == 'TRUE') ? 'true' : 'false';\n+ return [code, Blockly.JavaScript.ORDER_ATOMIC];\n+};\n+Blockly.Python['values_boolean'] = function(block) {\n+ var dropdown_value = block.getFieldValue('VALUE');\n+ var code = (dropdown_value == 'TRUE') ? 'True' : 'False';\n+ return [code, Blockly.Python.ORDER_ATOMIC];\n+};\n+\n// Operators number block\n-Blockly.JavaScript['operators_number'] = function(block) {\n+Blockly.JavaScript['values_number'] = function(block) {\n// Numeric value.\nvar code = Number(block.getFieldValue('NUM'));\nvar order = code >= 0 ? Blockly.JavaScript.ORDER_ATOMIC :\nBlockly.JavaScript.ORDER_UNARY_NEGATION;\nreturn [code, order];\n};\n-Blockly.Python['operators_number'] = function(block) {\n+Blockly.Python['values_number'] = function(block) {\n// Numeric value.\nvar code = Number(block.getFieldValue('NUM'));\nvar order;\n@@ -728,12 +766,12 @@ Blockly.Python['operators_number'] = function(block) {\n};\n// Operators text block\n-Blockly.JavaScript['operators_string'] = function(block) {\n+Blockly.JavaScript['values_string'] = function(block) {\n// Text value.\nvar code = Blockly.JavaScript.quote_(block.getFieldValue('TEXT'));\nreturn [code, Blockly.JavaScript.ORDER_ATOMIC];\n};\n-Blockly.Python['operators_string'] = function(block) {\n+Blockly.Python['values_string'] = function(block) {\n// Text value.\nvar code = Blockly.Python.quote_(block.getFieldValue('TEXT'));\nreturn [code, Blockly.Python.ORDER_ATOMIC];\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/block-based-toolbox.xml", "new_path": "csunplugged/templates/plugging_it_in/block-based-toolbox.xml", "diff": "<xml xmlns=\"https://developers.google.com/blockly/xml\" id=\"toolbox\" style=\"display: none\">\n<category name=\"Values\" colour=\"#4c97ff\">\n- <block type=\"operators_number\">\n+ <block type=\"values_number\">\n<field name=\"NUM\">0</field>\n</block>\n- <block type=\"operators_string\">\n+ <block type=\"values_string\">\n<field name=\"TEXT\">abc</field>\n</block>\n+ <block type=\"values_boolean\"></block>\n</category>\n<category name=\"Looks\" colour=\"#9966ff\">\n<block type=\"looks_say\">\n" } ]
Python
MIT License
uccser/cs-unplugged
Add boolean block in Values category and abstracted colour of Values block
701,850
20.08.2021 14:09:56
-43,200
1c5d0b57ce5a8ddeae517e8fd53c9652b3e007f5
Replace 'ask and wait' block with 'ask and wait for text' block and 'ask and wait for number' block.'
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/custom-blockly-blocks.js", "new_path": "csunplugged/static/js/custom-blockly-blocks.js", "diff": "@@ -572,10 +572,10 @@ Blockly.defineBlocksWithJsonArray([\n\"tooltip\": \"Return true if both inputs equal each other.\",\n\"helpUrl\": \"\"\n},\n- // Sensing ask and wait block\n+ // Sensing ask and wait number block\n{\n- \"type\": \"sensing_ask_and_wait\",\n- \"message0\": \"ask %1 %2 and wait for type %3 %4\",\n+ \"type\": \"sensing_ask_and_wait_number\",\n+ \"message0\": \"ask %1 %2 and wait for number\",\n\"args0\": [\n{\n\"type\": \"input_dummy\"\n@@ -584,23 +584,26 @@ Blockly.defineBlocksWithJsonArray([\n\"type\": \"input_value\",\n\"name\": \"question\",\n\"check\": \"String\"\n+ }\n+ ],\n+ \"inputsInline\": true,\n+ \"output\": \"Number\",\n+ \"colour\": SENSING_BLOCKS_COLOUR,\n+ \"tooltip\": \"Ask user for some number.\",\n+ \"helpUrl\": \"\"\n},\n+ // Sensing ask and wait text block\n+ {\n+ \"type\": \"sensing_ask_and_wait_text\",\n+ \"message0\": \"ask %1 %2 and wait for text\",\n+ \"args0\": [\n{\n\"type\": \"input_dummy\"\n},\n{\n- \"type\": \"field_dropdown\",\n- \"name\": \"TYPE\",\n- \"options\": [\n- [\n- \"text\",\n- \"T\"\n- ],\n- [\n- \"number\",\n- \"N\"\n- ]\n- ]\n+ \"type\": \"input_value\",\n+ \"name\": \"question\",\n+ \"check\": \"String\"\n}\n],\n\"inputsInline\": true,\n@@ -1151,8 +1154,8 @@ Blockly.Python['controls_stop'] = function(block) {\nreturn code;\n};\n-// Sensing ask and wait block\n-Blockly.JavaScript['sensing_ask_and_wait'] = function(block) {\n+// Sensing ask and wait number block\n+Blockly.JavaScript['sensing_ask_and_wait_number'] = function(block) {\nif (block.getField('question')) {\n// Internal message.\nvar msg = Blockly.JavaScript.quote_(block.getFieldValue('question'));\n@@ -1160,16 +1163,42 @@ Blockly.JavaScript['sensing_ask_and_wait'] = function(block) {\n// External message.\nvar msg = Blockly.JavaScript.valueToCode(block, 'question', Blockly.JavaScript.ORDER_NONE) || '\\'\\'';\n}\n- var code = 'window.prompt(' + msg + ')';\n-\n- var dropdown_type = block.getFieldValue('TYPE');\n- if (dropdown_type === 'N') { // If asking for a number, then convert the input to a number.\n- code = 'Number(' + code + ')';\n+ var code = 'Number(window.prompt(' + msg + '))';\n+ return [code, Blockly.JavaScript.ORDER_FUNCTION_CALL];\n+ };\n+Blockly.Python['sensing_ask_and_wait_number'] = function(block) {\n+ var functionName = Blockly.Python.provideFunction_(\n+ 'text_prompt',\n+ ['def ' + Blockly.Python.FUNCTION_NAME_PLACEHOLDER_ + '(msg):',\n+ ' try:',\n+ ' return raw_input(msg)',\n+ ' except NameError:',\n+ ' return input(msg)']);\n+ if (block.getField('question')) {\n+ // Internal message.\n+ var msg = Blockly.Python.quote_(block.getFieldValue('question'));\n+ } else {\n+ // External message.\n+ var msg = Blockly.Python.valueToCode(block, 'question', Blockly.Python.ORDER_NONE) || '\\'\\'';\n}\n+ msg = '\"\"' // Replaces user input parameters to be blank so it matches the expected output\n+ var code = 'float(' + functionName + '(' + msg + '))';\n+ return [code, Blockly.Python.ORDER_FUNCTION_CALL];\n+ };\n+// Sensing ask and wait text block\n+Blockly.JavaScript['sensing_ask_and_wait_text'] = function(block) {\n+ if (block.getField('question')) {\n+ // Internal message.\n+ var msg = Blockly.JavaScript.quote_(block.getFieldValue('question'));\n+ } else {\n+ // External message.\n+ var msg = Blockly.JavaScript.valueToCode(block, 'question', Blockly.JavaScript.ORDER_NONE) || '\\'\\'';\n+ }\n+ var code = 'window.prompt(' + msg + ')';\nreturn [code, Blockly.JavaScript.ORDER_FUNCTION_CALL];\n};\n-Blockly.Python['sensing_ask_and_wait'] = function(block) {\n+Blockly.Python['sensing_ask_and_wait_text'] = function(block) {\nvar functionName = Blockly.Python.provideFunction_(\n'text_prompt',\n['def ' + Blockly.Python.FUNCTION_NAME_PLACEHOLDER_ + '(msg):',\n@@ -1187,10 +1216,6 @@ Blockly.Python['sensing_ask_and_wait'] = function(block) {\nmsg = '\"\"' // Replaces user input parameters to be blank so it matches the expected output\nvar code = functionName + '(' + msg + ')';\n- var dropdown_type = block.getFieldValue('TYPE');\n- if (dropdown_type === 'N') { // If asking for a number, then convert the input to a number.\n- code = 'float(' + functionName + '(' + msg + ')' + ')';\n- }\nreturn [code, Blockly.Python.ORDER_FUNCTION_CALL];\n};\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/block-based-toolbox.xml", "new_path": "csunplugged/templates/plugging_it_in/block-based-toolbox.xml", "diff": "<block type=\"controls_stop\"></block>\n</category>\n<category name=\"Sensing\" colour=\"#4cbfe6\">\n- <block type=\"sensing_ask_and_wait\">\n+ <block type=\"sensing_ask_and_wait_text\">\n<value name=\"question\">\n<shadow type=\"text\">\n- <field name=\"TEXT\">What is your name?</field>\n+ <field name=\"TEXT\">What's your name?</field>\n+ </shadow>\n+ </value>\n+ </block>\n+ <block type=\"sensing_ask_and_wait_number\">\n+ <value name=\"question\">\n+ <shadow type=\"text\">\n+ <field name=\"TEXT\">What's your age?</field>\n</shadow>\n</value>\n</block>\n" } ]
Python
MIT License
uccser/cs-unplugged
Replace 'ask and wait' block with 'ask and wait for text' block and 'ask and wait for number' block.'
701,850
20.08.2021 17:11:55
-43,200
99ac885d6e9656755448c574296dcce9634aea42
Add Block-based to a couple more questions
[ { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/binary-numbers/programming-challenges/binary-numbers-using-variable-operator-repeat/block-based-expected.md", "diff": "+```scratch\n+when green flag clicked\n+\n+set [number of dots v] to [1]\n+\n+repeat (5)\n+end\n+\n+say (number of dots) for (1) secs\n+\n+set [number of dots v] to ((number of dots) * (2))\n+```\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/binary-numbers/programming-challenges/binary-numbers-using-variable-operator-repeat/block-based-solution.md", "diff": "+```scratch\n+when green flag clicked\n+set [number of dots v] to [1]\n+repeat (5)\n+ say (number of dots) for (1) secs\n+ set [number of dots v] to ((number of dots) * (2))\n+end\n+```\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/binary-numbers/programming-challenges/binary-numbers-using-variable/block-based-expected.md", "diff": "+```scratch\n+when flag clicked\n+\n+say [1] for (1) secs\n+\n+say [2] for (1) secs\n+\n+say [4] for (1) secs\n+\n+say [8] for (1) secs\n+\n+say [16] for (1) secs\n+```\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/binary-numbers/programming-challenges/binary-numbers-using-variable/block-based-solution.md", "diff": "+```scratch\n+when green flag clicked\n+say [1] for (1) secs\n+say [2] for (1) secs\n+say [4] for (1) secs\n+say [8] for (1) secs\n+say [16] for (1) secs\n+```\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/structure/binary-numbers/programming-challenges/programming-challenges.yaml", "new_path": "csunplugged/topics/content/structure/binary-numbers/programming-challenges/programming-challenges.yaml", "diff": "@@ -19,6 +19,7 @@ binary-numbers-using-variable:\nprogramming-languages:\n- scratch\n- python\n+ - block-based\nlearning-outcomes:\n- programming-explain-sequencing\n- programming-describe-variables\n@@ -47,6 +48,7 @@ binary-numbers-using-variable-operator-repeat:\nprogramming-languages:\n- scratch\n- python\n+ - block-based\nlearning-outcomes:\n- programming-outline-variable-updates\n- programming-describe-variable-output\n" } ]
Python
MIT License
uccser/cs-unplugged
Add Block-based to a couple more questions
701,850
20.08.2021 21:49:39
-43,200
8549d6023fc56d64d7e36d8ea7f5a63b114213e3
Fix bug of code attempts not getting saved
[ { "change_type": "MODIFY", "old_path": "csunplugged/plugging_it_in/views.py", "new_path": "csunplugged/plugging_it_in/views.py", "diff": "@@ -161,7 +161,7 @@ class ProgrammingChallengeView(generic.DetailView):\ncontext[\"saved_attempts\"] = self.request.session.get('saved_attempts', {})\ntry:\n# Retrieves either the python or blockly code for a specific question, depending what the value of context[\"programming_lang\"] is\n- context[\"previous_submission\"] = context[\"saved_attempts\"][self.object.slug][context[\"programming_lang\"]]['code']\n+ context[\"previous_submission\"] = context[\"saved_attempts\"][self.object.slug][context[\"programming_lang\"]][\"code\"]\nexcept KeyError:\ncontext[\"previous_submission\"] = ''\n@@ -202,19 +202,21 @@ class SaveAttemptView(View):\nbody_unicode = request.body.decode('utf-8')\nbody = json.loads(body_unicode)\n- request.session['saved_attempts'] = request.session.get('saved_attempts', {})\n+ request.session['saved_attempts'] = request.session.get('saved_attempts', {body[\"challenge\"]: {}, body[\"programming_language\"]: \"\"})\n# To stop a \"passed\" or \"failed\" status being overridden by \"started\"\nif (not (body[\"status\"] == \"started\"\n- and request.session.get('saved_attempts', {}).get(body[\"challenge\"], {}).get(\"status\", \"\")\n+ and request.session.get('saved_attempts', {}).get(body[\"challenge\"], {}).get(body[\"programming_language\"], {}).get(\"status\", \"\")\nin {'passed', 'failed'})\nand body[\"attempt\"] != \"\"):\n# Saves the python attempt and blockly attempt in different places for the same question.\nrequest.session['saved_attempts'][body[\"challenge\"]][body[\"programming_language\"]] = {\n\"status\": body[\"status\"],\n\"code\": body[\"attempt\"],\n- \"programming_language\": body[\"programming_language\"]\n}\n+ # Set session as modified to force data updates to be saved.\n+ # https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Sessions\n+ request.session.modified = True\nreturn HttpResponse(\"Saved the attempt.\")\nelse:\nreturn HttpResponse(\"Response does not need to be saved.\")\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "let lesson_url = \"{% url 'plugging_it_in:lesson' topic.slug lesson.slug %}\";\nlet csrf_token = '{{ csrf_token }}';\nlet jobe_proxy_url = '{{ jobe_proxy_url }}';\n- let save_attempt_url = \"{% url 'plugging_it_in:save_attempt' %}\"\n- let programming_lang = \"{{ programming_lang }}\"\n- let previous_submission = \"{{ previous_submission }}\"\n+ let save_attempt_url = \"{% url 'plugging_it_in:save_attempt' %}\";\n+ let programming_lang = \"{{ programming_lang }}\";\n+ let previous_submission = `{{ previous_submission }}` // allows value of the variable previous_submission to go on multiline without causing syntax error.\n</script>\n<script src=\"{% static 'js/jobe-editor.js' %}\"></script>\n" } ]
Python
MIT License
uccser/cs-unplugged
Fix bug of code attempts not getting saved
701,850
21.08.2021 14:37:55
-43,200
66f88f03fe0db605cf3807b43ac2a99b69d6589a
Updated the information alert box of the Block-based language.
[ { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/lesson.html", "new_path": "csunplugged/templates/plugging_it_in/lesson.html", "diff": "</div>\n{% elif language.slug == \"block-based\" %}\n<div class=\"alert alert-info my-3\" role=\"alert\">\n- {% trans \"The following challenges uses Blockly, which have been adapted to look like Scratch.\" %}\n- {% trans \"If you're a Scratch programmer, click here to find out what the differences are. If you would like it to be purely in Scratch, click here, however this does not have an interactive editor for you to create your programs.\" %}\n+ {% trans \"The following challenges use Blockly, which have been adapted to look like Scratch and contains an interactive editor. To find out the differences, click here! If you like the challenges to be purely in Scratch, then go over to the Scratch tab instead.\" %}\n</div>\n{% endif %}\n{% include \"plugging_it_in/programming-challenges-table.html\" with language=language.name %}\n" } ]
Python
MIT License
uccser/cs-unplugged
Updated the information alert box of the Block-based language.
701,850
21.08.2021 17:44:36
-43,200
44f221aae03a7b80e0e06d4abbe54e62a7dde79b
Fixed two problems regarding the save coding attempt functionality for both Python & Block-based challenges. Fixed the problem with coding attempt not being saved properly when they attempt a second challenge. Fixed another problem where Python coding attempt with '\n' was causing an error in the programming-challenge.html
[ { "change_type": "MODIFY", "old_path": "csunplugged/plugging_it_in/views.py", "new_path": "csunplugged/plugging_it_in/views.py", "diff": "@@ -161,9 +161,13 @@ class ProgrammingChallengeView(generic.DetailView):\ncontext[\"saved_attempts\"] = self.request.session.get('saved_attempts', {})\ntry:\n# Retrieves either the python or blockly code for a specific question, depending what the value of context[\"programming_lang\"] is\n- context[\"previous_submission\"] = context[\"saved_attempts\"][self.object.slug][context[\"programming_lang\"]][\"code\"]\n+ if programming_lang_slug == \"python\":\n+ context[\"previous_text_based_submission\"] = context[\"saved_attempts\"][self.object.slug][context[\"programming_lang\"]][\"code\"]\n+ else:\n+ context[\"previous_block_based_submission\"] = context[\"saved_attempts\"][self.object.slug][context[\"programming_lang\"]][\"code\"]\nexcept KeyError:\n- context[\"previous_submission\"] = ''\n+ context[\"previous_text_based_submission\"] = ''\n+ context[\"previous_block_based_submission\"] = ''\nreturn context\n@@ -202,14 +206,20 @@ class SaveAttemptView(View):\nbody_unicode = request.body.decode('utf-8')\nbody = json.loads(body_unicode)\n- request.session['saved_attempts'] = request.session.get('saved_attempts', {body[\"challenge\"]: {}, body[\"programming_language\"]: \"\"})\n+ request.session['saved_attempts'] = request.session.get('saved_attempts', {})\n# To stop a \"passed\" or \"failed\" status being overridden by \"started\"\nif (not (body[\"status\"] == \"started\"\nand request.session.get('saved_attempts', {}).get(body[\"challenge\"], {}).get(body[\"programming_language\"], {}).get(\"status\", \"\")\nin {'passed', 'failed'})\nand body[\"attempt\"] != \"\"):\n- # Saves the python attempt and blockly attempt in different places for the same question.\n+\n+ # if attempting the current challenge for the first time\n+ # then initialise the challenge as an empty object to avoid KeyError when saving Python/Block-based attempt.\n+ if (body[\"challenge\"] not in request.session['saved_attempts']):\n+ request.session['saved_attempts'][body[\"challenge\"]] = {}\n+\n+ # Saves the python/block-based attempt in different places for the current challenge.\nrequest.session['saved_attempts'][body[\"challenge\"]][body[\"programming_language\"]] = {\n\"status\": body[\"status\"],\n\"code\": body[\"attempt\"],\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "@@ -76,10 +76,10 @@ if (programming_lang == \"python\") {\n/* Injects the blockly workspace */\nworkspace = Blockly.inject('blocklyDiv', options);\n- // Displays the user's previous submission\n- if (previous_submission) {\n- // Decodes the previous_submission which contains HTML entities. Outputs a string, and it converts it to XML\n- const xml_node = Blockly.Xml.textToDom(utils.decodeHTMLEntities(previous_submission))\n+ // Displays the user's previous block-based submission\n+ if (previous_block_based_submission) {\n+ // Decodes the previous_block_based_submission which contains HTML entities. Outputs a string, and it converts it to XML\n+ const xml_node = Blockly.Xml.textToDom(utils.decodeHTMLEntities(previous_block_based_submission))\nBlockly.Xml.domToWorkspace(xml_node, workspace);\n}\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "{% if programming_lang == 'python' %}\n<div class=\"col-12 col-md-4 programming__editor\">\n<p class='pii-block-heading'>{% trans \"Enter your code in the editor below\" %}</p>\n- <textarea id=\"codemirror_editor\">{{ previous_submission|safe }}</textarea>\n+ <textarea id=\"codemirror_editor\">{{ previous_text_based_submission|safe }}</textarea>\n<div class=\"programming__submit d-flex justify-content-between align-items-center\">\n<div class=\"programming__submit_options d-flex justify-content-start\">\n<button class=\"editor_button\" id=\"editor_check_button\" >{% trans \"Check\" %}</button>\nlet jobe_proxy_url = '{{ jobe_proxy_url }}';\nlet save_attempt_url = \"{% url 'plugging_it_in:save_attempt' %}\";\nlet programming_lang = \"{{ programming_lang }}\";\n- let previous_submission = `{{ previous_submission }}` // allows value of the variable previous_submission to go on multiline without causing syntax error.\n+ let previous_block_based_submission = \"{{ previous_block_based_submission }}\"\n</script>\n<script src=\"{% static 'js/jobe-editor.js' %}\"></script>\n" } ]
Python
MIT License
uccser/cs-unplugged
Fixed two problems regarding the save coding attempt functionality for both Python & Block-based challenges. Fixed the problem with coding attempt not being saved properly when they attempt a second challenge. Fixed another problem where Python coding attempt with '\n' was causing an error in the programming-challenge.html
701,850
22.08.2021 11:33:40
-43,200
1f3ca30e469faea498ecd941446b8469b67b2849
Fixed coding style to pass the cs unplugged style check Also removed duplicated URL pattern
[ { "change_type": "MODIFY", "old_path": "csunplugged/plugging_it_in/urls.py", "new_path": "csunplugged/plugging_it_in/urls.py", "diff": "@@ -23,12 +23,7 @@ urlpatterns = [\nname=\"lesson\"\n),\nurl(\n- r\"^(?P<topic_slug>[-\\w]+)/(?P<lesson_slug>[-\\w]+)/(?P<programming_challenge_slug>[-\\w]+)/$\",\n- views.ProgrammingChallengeView.as_view(),\n- name=\"programming_challenge\"\n- ),\n- url(\n- r\"^(?P<topic_slug>[-\\w]+)/(?P<lesson_slug>[-\\w]+)/(?P<programming_challenge_slug>[-\\w]+)/(?P<programming_lang_slug>[-\\w]+)/$\",\n+ r\"^(?P<topic_slug>[-\\w]+)/(?P<lesson_slug>[-\\w]+)/(?P<challenge_slug>[-\\w]+)/(?P<language_slug>[-\\w]+)/$\",\nviews.ProgrammingChallengeView.as_view(),\nname=\"programming_challenge\"\n),\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/plugging_it_in/views.py", "new_path": "csunplugged/plugging_it_in/views.py", "diff": "@@ -119,7 +119,7 @@ class ProgrammingChallengeView(generic.DetailView):\nreturn get_object_or_404(\nself.model.objects.select_related(),\ntopic__slug=self.kwargs.get(\"topic_slug\", None),\n- slug=self.kwargs.get(\"programming_challenge_slug\", None)\n+ slug=self.kwargs.get(\"challenge_slug\", None)\n)\ndef get_context_data(self, **kwargs):\n@@ -134,15 +134,15 @@ class ProgrammingChallengeView(generic.DetailView):\ncontext[\"topic\"] = self.object.topic\ntry:\n- programming_lang_slug = self.kwargs.get(\"programming_lang_slug\", None)\n- context[\"programming_lang\"] = programming_lang_slug.lower() # make sure the /python or /block-based is lower case, because this will get checked in the programming-challenge.html page\n+ language_slug = self.kwargs.get(\"language_slug\", None)\n+ context[\"programming_lang\"] = language_slug.lower() # ensure /python or /block-based is lower case\nlesson_slug = self.kwargs.get(\"lesson_slug\", None)\nlesson = Lesson.objects.get(slug=lesson_slug)\ncontext[\"lesson\"] = lesson\n- # Get Python challenges if programming_lang_slug == 'python' else get Block-based challanges\n- if (programming_lang_slug == \"python\"):\n+ # Get Python challenges if language_slug == 'python' else get Block-based challanges\n+ if (language_slug == \"python\"):\nchalllenges = lesson.retrieve_related_programming_challenges(\"Python\")\nelse:\nchalllenges = lesson.retrieve_related_programming_challenges(\"Block-based\")\n@@ -160,11 +160,12 @@ class ProgrammingChallengeView(generic.DetailView):\ncontext[\"jobe_proxy_url\"] = reverse('plugging_it_in:jobe_proxy')\ncontext[\"saved_attempts\"] = self.request.session.get('saved_attempts', {})\ntry:\n- # Retrieves either the python or blockly code for a specific question, depending what the value of context[\"programming_lang\"] is\n- if programming_lang_slug == \"python\":\n- context[\"previous_text_based_submission\"] = context[\"saved_attempts\"][self.object.slug][context[\"programming_lang\"]][\"code\"]\n+ # Retrieves python/blockly code for a specific question, depending what context[\"programming_lang\"] is\n+ lang = context[\"programming_lang\"]\n+ if language_slug == \"python\":\n+ context[\"previous_text_based_submission\"] = context[\"saved_attempts\"][self.object.slug][lang][\"code\"]\nelse:\n- context[\"previous_block_based_submission\"] = context[\"saved_attempts\"][self.object.slug][context[\"programming_lang\"]][\"code\"]\n+ context[\"previous_block_based_submission\"] = context[\"saved_attempts\"][self.object.slug][lang][\"code\"]\nexcept KeyError:\ncontext[\"previous_text_based_submission\"] = ''\ncontext[\"previous_block_based_submission\"] = ''\n@@ -210,21 +211,24 @@ class SaveAttemptView(View):\n# To stop a \"passed\" or \"failed\" status being overridden by \"started\"\nif (not (body[\"status\"] == \"started\"\n- and request.session.get('saved_attempts', {}).get(body[\"challenge\"], {}).get(body[\"programming_language\"], {}).get(\"status\", \"\")\n+ and request.session.get('saved_attempts', {})\n+ .get(body[\"challenge\"], {})\n+ .get(body[\"programming_language\"], {})\n+ .get(\"status\", \"\")\nin {'passed', 'failed'})\nand body[\"attempt\"] != \"\"):\n- # if attempting the current challenge for the first time\n- # then initialise the challenge as an empty object to avoid KeyError when saving Python/Block-based attempt.\n+ # if attempting the current challenge for the first time,\n+ # initialise the challenge as an empty object to avoid KeyError when saving user's attempt\nif (body[\"challenge\"] not in request.session['saved_attempts']):\nrequest.session['saved_attempts'][body[\"challenge\"]] = {}\n- # Saves the python/block-based attempt in different places for the current challenge.\n+ # Saves the python/block-based attempt in different places for the current challenge\nrequest.session['saved_attempts'][body[\"challenge\"]][body[\"programming_language\"]] = {\n\"status\": body[\"status\"],\n\"code\": body[\"attempt\"],\n}\n- # Set session as modified to force data updates to be saved.\n+ # Set session as modified to force data updates to be saved\n# https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Sessions\nrequest.session.modified = True\nreturn HttpResponse(\"Saved the attempt.\")\n" } ]
Python
MIT License
uccser/cs-unplugged
Fixed coding style to pass the cs unplugged style check - Also removed duplicated URL pattern
701,850
28.08.2021 01:43:11
-43,200
14119bf47bb5d57cc8758d2cafbeecbf4d0a5e02
Replaced the Shadow blocks with real Values blocks, and moved the position of the Values category to the bottom of the toolbar.
[ { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/block-based-toolbox.xml", "new_path": "csunplugged/templates/plugging_it_in/block-based-toolbox.xml", "diff": "<xml xmlns=\"https://developers.google.com/blockly/xml\" id=\"toolbox\" style=\"display: none\">\n- <category name=\"Values\" colour=\"#4c97ff\">\n- <block type=\"values_number\">\n- <field name=\"NUM\">0</field>\n- </block>\n+ <category name=\"Looks\" colour=\"#9966ff\">\n+ <block type=\"looks_say\">\n+ <value name=\"value\">\n<block type=\"values_string\">\n<field name=\"TEXT\">abc</field>\n</block>\n- <block type=\"values_boolean\"></block>\n- </category>\n- <category name=\"Looks\" colour=\"#9966ff\">\n+ </value>\n+ </block>\n<block type=\"looks_say\">\n<value name=\"value\">\n- <shadow type=\"text\">\n- <field name=\"TEXT\">abc</field>\n- </shadow>\n+ <block type=\"values_number\">\n+ <field name=\"NUM\">123</field>\n+ </block>\n</value>\n</block>\n</category>\n<category name=\"Control\" colour=\"#ffab19\">\n<block type=\"controls_repeat_num_times\">\n<value name=\"num\">\n- <shadow type=\"math_number\">\n+ <block type=\"values_number\">\n<field name=\"NUM\">10</field>\n- </shadow>\n+ </block>\n</value>\n</block>\n<!-- Forever loop? -->\n<category name=\"Sensing\" colour=\"#4cbfe6\">\n<block type=\"sensing_ask_and_wait_text\">\n<value name=\"question\">\n- <shadow type=\"text\">\n+ <block type=\"values_string\">\n<field name=\"TEXT\">What's your name?</field>\n- </shadow>\n+ </block>\n</value>\n</block>\n<block type=\"sensing_ask_and_wait_number\">\n<value name=\"question\">\n- <shadow type=\"text\">\n+ <block type=\"values_string\">\n<field name=\"TEXT\">What's your age?</field>\n- </shadow>\n+ </block>\n</value>\n</block>\n</category>\n<category name=\"Operators\" colour=\"#40bf4a\">\n<block type=\"operators_add\">\n<value name=\"x\">\n- <shadow type=\"math_number\">\n+ <block type=\"values_number\">\n<field name=\"NUM\">1</field>\n- </shadow>\n+ </block>\n</value>\n<value name=\"y\">\n- <shadow type=\"math_number\">\n+ <block type=\"values_number\">\n<field name=\"NUM\">1</field>\n- </shadow>\n+ </block>\n</value>\n</block>\n<block type=\"operators_subtract\">\n<value name=\"x\">\n- <shadow type=\"math_number\">\n+ <block type=\"values_number\">\n<field name=\"NUM\">1</field>\n- </shadow>\n+ </block>\n</value>\n<value name=\"y\">\n- <shadow type=\"math_number\">\n+ <block type=\"values_number\">\n<field name=\"NUM\">1</field>\n- </shadow>\n+ </block>\n</value>\n</block>\n<block type=\"operators_multiply\">\n<value name=\"x\">\n- <shadow type=\"math_number\">\n+ <block type=\"values_number\">\n<field name=\"NUM\">1</field>\n- </shadow>\n+ </block>\n</value>\n<value name=\"y\">\n- <shadow type=\"math_number\">\n+ <block type=\"values_number\">\n<field name=\"NUM\">1</field>\n- </shadow>\n+ </block>\n</value>\n</block>\n<block type=\"operators_divide\">\n<value name=\"x\">\n- <shadow type=\"math_number\">\n+ <block type=\"values_number\">\n<field name=\"NUM\">1</field>\n- </shadow>\n+ </block>\n</value>\n<value name=\"y\">\n- <shadow type=\"math_number\">\n+ <block type=\"values_number\">\n<field name=\"NUM\">1</field>\n- </shadow>\n+ </block>\n</value>\n</block>\n<block type=\"operators_random_int\">\n<value name=\"a\">\n- <shadow type=\"math_number\">\n+ <block type=\"values_number\">\n<field name=\"NUM\">1</field>\n- </shadow>\n+ </block>\n</value>\n<value name=\"b\">\n- <shadow type=\"math_number\">\n+ <block type=\"values_number\">\n<field name=\"NUM\">100</field>\n- </shadow>\n+ </block>\n</value>\n</block>\n<block type=\"operators_greater_than\"></block>\n<block type=\"operators_not\"></block>\n<block type=\"operators_join_string\">\n<value name=\"a\">\n- <shadow type=\"text\">\n+ <block type=\"values_string\">\n<field name=\"TEXT\">apple </field>\n- </shadow>\n+ </block>\n</value>\n<value name=\"b\">\n- <shadow type=\"text\">\n+ <block type=\"values_string\">\n<field name=\"TEXT\">banana</field>\n- </shadow>\n+ </block>\n</value>\n</block>\n<block type=\"operators_letter_of\">\n<value name=\"index\">\n- <shadow type=\"math_number\">\n+ <block type=\"values_number\">\n<field name=\"NUM\">1</field>\n- </shadow>\n+ </block>\n</value>\n<value name=\"word\">\n- <shadow type=\"text\">\n+ <block type=\"values_string\">\n<field name=\"TEXT\">apple</field>\n- </shadow>\n+ </block>\n</value>\n</block>\n<block type=\"operators_length_of\">\n<value name=\"VALUE\">\n- <shadow type=\"text\">\n+ <block type=\"values_string\">\n<field name=\"TEXT\">abc</field>\n- </shadow>\n+ </block>\n</value>\n</block>\n<block type=\"operators_string_contains\">\n<value name=\"word\">\n- <shadow type=\"text\">\n+ <block type=\"values_string\">\n<field name=\"TEXT\">apple</field>\n- </shadow>\n+ </block>\n</value>\n<value name=\"subword\">\n- <shadow type=\"text\">\n+ <block type=\"values_string\">\n<field name=\"TEXT\">a</field>\n- </shadow>\n+ </block>\n</value>\n</block>\n</block>\n<block type=\"operators_modulo\">\n<value name=\"a\">\n- <shadow type=\"math_number\">\n+ <block type=\"values_number\">\n<field name=\"NUM\">-3</field>\n- </shadow>\n+ </block>\n</value>\n<value name=\"n\">\n- <shadow type=\"math_number\">\n+ <block type=\"values_number\">\n<field name=\"NUM\">2</field>\n- </shadow>\n+ </block>\n</value>\n</block>\n<block type=\"operators_round\">\n<value name=\"a\">\n- <shadow type=\"math_number\">\n+ <block type=\"values_number\">\n<field name=\"NUM\">3.14</field>\n- </shadow>\n+ </block>\n</value>\n</block>\n<block type=\"operators_single\">\n<field name=\"OP\">ABS</field>\n<value name=\"NUM\">\n- <shadow type=\"math_number\">\n+ <block type=\"values_number\">\n<field name=\"NUM\">9</field>\n- </shadow>\n+ </block>\n</value>\n</block>\n</category>\n<category name=\"Variables\" colour=\"#ff8c1a\" custom=\"VARIABLE\"></category>\n+ <sep></sep>\n+ <category name=\"Values\" colour=\"#4c97ff\">\n+ <block type=\"values_number\">\n+ <field name=\"NUM\">0</field>\n+ </block>\n+ <block type=\"values_string\">\n+ <field name=\"TEXT\">abc</field>\n+ </block>\n+ <block type=\"values_boolean\"></block>\n+ </category>\n</xml>\n\\ No newline at end of file\n" } ]
Python
MIT License
uccser/cs-unplugged
Replaced the Shadow blocks with real Values blocks, and moved the position of the Values category to the bottom of the toolbar.
701,850
09.09.2021 06:38:03
-43,200
3ad460bf08bb05361026107844d7ee59d3dd3eed
Changed the Run button colour to be the same as Scratch's green flag colour.
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/scss/programming-editor.scss", "new_path": "csunplugged/static/scss/programming-editor.scss", "diff": "@import \"node_modules/bootstrap/scss/mixins\";\n$student-colour: #3044b3;\n-$student-colour-light: #5a9fffff;;\n+$student-colour-light: #5a9fffff;\n+$scratch-flag-colour: #4cbf56;\n+$scratch-flag-border-colour: #4ab750;\nhtml,\nbody {\n@@ -229,6 +231,11 @@ body {\nbackground-color: transparent;\n}\n+ #blockly_editor_run_program_button {\n+ border: 2px solid $scratch-flag-border-colour;\n+ background-color: $scratch-flag-colour;\n+ }\n+\n#editor_run_button:disabled {\nbackground-color: #a4caffff;\nborder-color: #a4caffff;\n" } ]
Python
MIT License
uccser/cs-unplugged
Changed the Run button colour to be the same as Scratch's green flag colour.
701,850
09.09.2021 06:40:06
-43,200
e1c5ce8e637ef0f51bb0da71f958e4c574d6ef0c
Changed the text of the Check button to "Submit".
[ { "change_type": "MODIFY", "old_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "new_path": "csunplugged/templates/plugging_it_in/programming-challenge.html", "diff": "<div class=\"programming__submit d-flex justify-content-between align-items-center\">\n<div class=\"programming__submit_options d-flex justify-content-start\">\n<button class=\"editor_button\" id=\"blockly_editor_run_program_button\" >{% trans \"Run\" %}</button>\n- <button class=\"editor_button\" id=\"editor_check_button\" >{% trans \"Check\" %}</button>\n+ <button class=\"editor_button\" id=\"editor_check_button\" >{% trans \"Submit\" %}</button>\n<button class=\"editor_button\" id=\"download_button\" >{% trans \"Download\" %}</button>\n</div>\n<div class=\"code_running_spinner spinner-grow\" role=\"status\">\n" } ]
Python
MIT License
uccser/cs-unplugged
Changed the text of the Check button to "Submit".
701,850
11.09.2021 18:19:56
-43,200
819b9503fdbd4e97163a05f9edfc4db88060380a
Added the zelos renderer to make the Block-based look like Scratch Zelos renderer changes the shapes of the blocks to be like Scratch.
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/jobe-editor.js", "new_path": "csunplugged/static/js/jobe-editor.js", "diff": "@@ -158,6 +158,7 @@ if (programming_lang == \"python\") {\n/* Workspace configurations */\nvar options = {\ntheme: blocklyTheme,\n+ renderer: 'zelos',\ntoolbox : toolbox,\ncollapse : true,\ncomments : true,\n" } ]
Python
MIT License
uccser/cs-unplugged
Added the zelos renderer to make the Block-based look like Scratch - Zelos renderer changes the shapes of the blocks to be like Scratch.
701,850
11.09.2021 18:22:20
-43,200
5bfaf3934688492762e27641a69e55e2dc23bdf5
Added the Programming Reminders for the Block-based system which includes screenshots of the blocks
[ { "change_type": "ADD", "old_path": "csunplugged/static/img/plugging-it-in/programming-reminders-block-based/add-one-to-value.png", "new_path": "csunplugged/static/img/plugging-it-in/programming-reminders-block-based/add-one-to-value.png", "diff": "Binary files /dev/null and b/csunplugged/static/img/plugging-it-in/programming-reminders-block-based/add-one-to-value.png differ\n" }, { "change_type": "ADD", "old_path": "csunplugged/static/img/plugging-it-in/programming-reminders-block-based/ask-and-wait-for-number.png", "new_path": "csunplugged/static/img/plugging-it-in/programming-reminders-block-based/ask-and-wait-for-number.png", "diff": "Binary files /dev/null and b/csunplugged/static/img/plugging-it-in/programming-reminders-block-based/ask-and-wait-for-number.png differ\n" }, { "change_type": "ADD", "old_path": "csunplugged/static/img/plugging-it-in/programming-reminders-block-based/ask-and-wait-for-text.png", "new_path": "csunplugged/static/img/plugging-it-in/programming-reminders-block-based/ask-and-wait-for-text.png", "diff": "Binary files /dev/null and b/csunplugged/static/img/plugging-it-in/programming-reminders-block-based/ask-and-wait-for-text.png differ\n" }, { "change_type": "ADD", "old_path": "csunplugged/static/img/plugging-it-in/programming-reminders-block-based/conditionals.png", "new_path": "csunplugged/static/img/plugging-it-in/programming-reminders-block-based/conditionals.png", "diff": "Binary files /dev/null and b/csunplugged/static/img/plugging-it-in/programming-reminders-block-based/conditionals.png differ\n" }, { "change_type": "ADD", "old_path": "csunplugged/static/img/plugging-it-in/programming-reminders-block-based/loops-repeat-until.png", "new_path": "csunplugged/static/img/plugging-it-in/programming-reminders-block-based/loops-repeat-until.png", "diff": "Binary files /dev/null and b/csunplugged/static/img/plugging-it-in/programming-reminders-block-based/loops-repeat-until.png differ\n" }, { "change_type": "ADD", "old_path": "csunplugged/static/img/plugging-it-in/programming-reminders-block-based/loops-repeat.png", "new_path": "csunplugged/static/img/plugging-it-in/programming-reminders-block-based/loops-repeat.png", "diff": "Binary files /dev/null and b/csunplugged/static/img/plugging-it-in/programming-reminders-block-based/loops-repeat.png differ\n" }, { "change_type": "ADD", "old_path": "csunplugged/static/img/plugging-it-in/programming-reminders-block-based/print-a-string.png", "new_path": "csunplugged/static/img/plugging-it-in/programming-reminders-block-based/print-a-string.png", "diff": "Binary files /dev/null and b/csunplugged/static/img/plugging-it-in/programming-reminders-block-based/print-a-string.png differ\n" }, { "change_type": "ADD", "old_path": "csunplugged/static/img/plugging-it-in/programming-reminders-block-based/print-a-variable.png", "new_path": "csunplugged/static/img/plugging-it-in/programming-reminders-block-based/print-a-variable.png", "diff": "Binary files /dev/null and b/csunplugged/static/img/plugging-it-in/programming-reminders-block-based/print-a-variable.png differ\n" }, { "change_type": "ADD", "old_path": "csunplugged/static/img/plugging-it-in/programming-reminders-block-based/set-variable-as-integer.png", "new_path": "csunplugged/static/img/plugging-it-in/programming-reminders-block-based/set-variable-as-integer.png", "diff": "Binary files /dev/null and b/csunplugged/static/img/plugging-it-in/programming-reminders-block-based/set-variable-as-integer.png differ\n" }, { "change_type": "ADD", "old_path": "csunplugged/static/img/plugging-it-in/programming-reminders-block-based/set-variable-as-string.png", "new_path": "csunplugged/static/img/plugging-it-in/programming-reminders-block-based/set-variable-as-string.png", "diff": "Binary files /dev/null and b/csunplugged/static/img/plugging-it-in/programming-reminders-block-based/set-variable-as-string.png differ\n" }, { "change_type": "ADD", "old_path": "csunplugged/static/img/plugging-it-in/programming-reminders-block-based/set-variable-from-calculation.png", "new_path": "csunplugged/static/img/plugging-it-in/programming-reminders-block-based/set-variable-from-calculation.png", "diff": "Binary files /dev/null and b/csunplugged/static/img/plugging-it-in/programming-reminders-block-based/set-variable-from-calculation.png differ\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/programming-reminders-block-based.md", "diff": "+# Programming Reminders\n+\n+#### Print statements\n+\n+###### Print a string directly\n+\n+{image file-path=\"img/plugging-it-in/programming-reminders-block-based/print-a-string.png\" caption=\"false\" alt=\"Blocks showing how to print a string\"}\n+\n+###### Print a variable\n+\n+{image file-path=\"img/plugging-it-in/programming-reminders-block-based/print-a-variable.png\" caption=\"false\" alt=\"Blocks showing how to print a variable\"}\n+\n+#### Variables\n+\n+###### Set a variable as a string\n+\n+{image file-path=\"img/plugging-it-in/programming-reminders-block-based/set-variable-as-string.png\" caption=\"false\" alt=\"Blocks showing how to set a variable as a string\"}\n+\n+###### Set a variable as an integer\n+\n+{image file-path=\"img/plugging-it-in/programming-reminders-block-based/set-variable-as-integer.png\" caption=\"false\" alt=\"Blocks showing how to set a variable as an integer\"}\n+\n+###### Set a variable from a calculation\n+\n+{image file-path=\"img/plugging-it-in/programming-reminders-block-based/set-variable-from-calculation.png\" caption=\"false\" alt=\"Blocks showing how to set a variable from a calculation\"}\n+\n+###### Set a variable from a user input (text)\n+\n+{image file-path=\"img/plugging-it-in/programming-reminders-block-based/ask-and-wait-for-text.png\" caption=\"false\" alt=\"Blocks showing how to set a variable from a user input (text)\"}\n+\n+###### Set a variable from a user input (number)\n+\n+{image file-path=\"img/plugging-it-in/programming-reminders-block-based/ask-and-wait-for-number.png\" caption=\"false\" alt=\"Blocks showing how to set a variable from a user input (number)\"}\n+\n+###### Add one to a value\n+\n+{image file-path=\"img/plugging-it-in/programming-reminders-block-based/add-one-to-value.png\" caption=\"false\" alt=\"Blocks showing how to add one to a value\"}\n+\n+#### Conditionals\n+\n+###### Find out the discount on fruit\n+\n+{image file-path=\"img/plugging-it-in/programming-reminders-block-based/conditionals.png\" caption=\"false\" alt=\"Blocks showing how to use conditional blocks\"}\n+\n+#### Loops\n+\n+###### Print string 10 times\n+\n+{image file-path=\"img/plugging-it-in/programming-reminders-block-based/loops-repeat.png\" caption=\"false\" alt=\"Blocks showing how to print a string\"}\n+\n+###### Print number until number reaches 10\n+\n+{image file-path=\"img/plugging-it-in/programming-reminders-block-based/loops-repeat-until.png\" caption=\"false\" alt=\"Blocks showing how to print a string\"}\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/_ProgrammingChallengesStructureLoader.py", "new_path": "csunplugged/topics/management/commands/_ProgrammingChallengesStructureLoader.py", "diff": "@@ -65,7 +65,7 @@ class ProgrammingChallengesStructureLoader(TranslatableModelLoader):\nprog_reminders_translations = self.get_blank_translation_dictionary()\n# scratch currently unsupported\n- if prog_language == \"python\":\n+ if prog_language == \"python\" or prog_language == \"block-based\":\nprog_reminders_filename = \"programming-reminders-{0}.md\".format(prog_language)\nprogramming_reminders_translations = self.get_markdown_translations(\nos.path.join(\n" } ]
Python
MIT License
uccser/cs-unplugged
Added the Programming Reminders for the Block-based system which includes screenshots of the blocks