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,852
20.04.2017 13:48:52
-43,200
fe1cac72d80d529fd68e23e0cbdb751681af350a
Move coverage report into scripts to fail if coverage requirements are not met.
[ { "change_type": "MODIFY", "old_path": ".travis.yml", "new_path": ".travis.yml", "diff": "@@ -21,9 +21,10 @@ script:\n- flake8 --config=../.flake8\n- coverage run --rcfile=../.coveragerc manage.py test --pattern \"test_*.py\" -v 3\n- 'if [ \"$TRAVIS_PULL_REQUEST\" != \"false\" ]; then manage.py test --pattern \"test_*.py\" --reverse -v 0; fi'\n+ - coverage report --rcfile=../.coveragerc\nafter_script:\n- coverage report --rcfile=../.coveragerc\n+ True\n#coveralls\n# Stop email notifications but post to organisation Slack channel\n" } ]
Python
MIT License
uccser/cs-unplugged
Move coverage report into scripts to fail if coverage requirements are not met.
701,852
20.04.2017 13:51:33
-43,200
7532f03b3cc111936f8d4a1ac5283726c588fe65
comment out after script for now.
[ { "change_type": "MODIFY", "old_path": ".travis.yml", "new_path": ".travis.yml", "diff": "@@ -23,8 +23,7 @@ script:\n- 'if [ \"$TRAVIS_PULL_REQUEST\" != \"false\" ]; then manage.py test --pattern \"test_*.py\" --reverse -v 0; fi'\n- coverage report --rcfile=../.coveragerc\n-after_script:\n- True\n+#after_script:\n#coveralls\n# Stop email notifications but post to organisation Slack channel\n" } ]
Python
MIT License
uccser/cs-unplugged
comment out after script for now.
701,852
20.04.2017 14:00:06
-43,200
2c0d7159e6e3962ed267e9770a748b781532ce62
add coveralls coverage
[ { "change_type": "MODIFY", "old_path": ".travis.yml", "new_path": ".travis.yml", "diff": "@@ -9,7 +9,6 @@ python:\n# Install dependencies\ninstall:\n- - pip install flake8 coverage coveralls\n- pip install -r requirements/base.txt\n- pip install -r requirements/test.txt\n@@ -23,8 +22,8 @@ script:\n- 'if [ \"$TRAVIS_PULL_REQUEST\" != \"false\" ]; then manage.py test --pattern \"test_*.py\" --reverse -v 0; fi'\n- coverage report --rcfile=../.coveragerc\n-#after_script:\n- #coveralls\n+after_script:\n+ coveralls\n# Stop email notifications but post to organisation Slack channel\nnotifications:\n" }, { "change_type": "MODIFY", "old_path": "requirements/test.txt", "new_path": "requirements/test.txt", "diff": "@@ -8,5 +8,9 @@ django-extensions==1.7.7\n# Check Python style\nflake8==3.3.0\n+#Coverage Tools\n+coverage==4.0.3\n+python-coveralls==2.9.1\n+\n# Mock Database\nmodel_mommy==1.3.2\n" } ]
Python
MIT License
uccser/cs-unplugged
add coveralls coverage
701,852
20.04.2017 14:00:56
-43,200
b46c373f064a53b95790b7d200a5e3c4f8946e92
remove reporting out of scripts to be handled by coveralls.
[ { "change_type": "MODIFY", "old_path": ".travis.yml", "new_path": ".travis.yml", "diff": "@@ -20,7 +20,6 @@ script:\n- flake8 --config=../.flake8\n- coverage run --rcfile=../.coveragerc manage.py test --pattern \"test_*.py\" -v 3\n- 'if [ \"$TRAVIS_PULL_REQUEST\" != \"false\" ]; then manage.py test --pattern \"test_*.py\" --reverse -v 0; fi'\n- - coverage report --rcfile=../.coveragerc\nafter_script:\ncoveralls\n" } ]
Python
MIT License
uccser/cs-unplugged
remove reporting out of scripts to be handled by coveralls.
701,852
20.04.2017 14:15:08
-43,200
089e1d130157a5e023417352555e524b337e9334
configure manage.py to be executable.
[ { "change_type": "MODIFY", "old_path": ".travis.yml", "new_path": ".travis.yml", "diff": "@@ -13,13 +13,14 @@ install:\n- pip install -r requirements/test.txt\nbefore_script:\n- cd csunplugged/\n+ - cd csunplugged/\n+ - chmod +x manage.py\n# Runs test suite\nscript:\n- flake8 --config=../.flake8\n- coverage run --rcfile=../.coveragerc manage.py test --pattern \"test_*.py\" -v 3\n- - 'if [ \"$TRAVIS_PULL_REQUEST\" != \"false\" ]; then manage.py test --pattern \"test_*.py\" --reverse -v 0; fi'\n+ - 'if [ \"$TRAVIS_PULL_REQUEST\" != \"false\" ]; then ./manage.py test --pattern \"test_*.py\" --reverse -v 0; fi'\nafter_script:\ncoveralls\n" } ]
Python
MIT License
uccser/cs-unplugged
configure manage.py to be executable.
701,852
20.04.2017 16:49:42
-43,200
1312c556062186c474e9350e07bfaec0ca458069
Allow language specification of base test.
[ { "change_type": "MODIFY", "old_path": "csunplugged/tests/BaseTest.py", "new_path": "csunplugged/tests/BaseTest.py", "diff": "@@ -7,6 +7,7 @@ class BaseTest(SimpleTestCase):\ndef __init__(self, *args, **kwargs):\nsuper().__init__(*args, **kwargs)\n+ self.language = None\n@classmethod\ndef setUpClass(self):\n@@ -24,7 +25,8 @@ class BaseTest(SimpleTestCase):\n'''Called before each test.\nSets the language to English, and creates a new client.\n'''\n- activate('en')\n+ if self.language is not None:\n+ activate(self.language)\nself.client = Client()\ndef tearDown(self):\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/tests/BaseTestWithDB.py", "new_path": "csunplugged/tests/BaseTestWithDB.py", "diff": "@@ -8,6 +8,7 @@ class BaseTestWithDB(TestCase):\ndef __init__(self, *args, **kwargs):\nsuper().__init__(*args, **kwargs)\n+ self.language = None\n@classmethod\ndef setUpTestData(self):\n@@ -35,7 +36,8 @@ class BaseTestWithDB(TestCase):\n'''Called before each test.\nSets the language to English, creates a new user and logs into the database\n'''\n- activate('en') # TODO\n+ if self.language is not None:\n+ activate(self.language)\nself.test_user = User.objects.create_user(self.username, self.email, self.password)\nlogin = self.client.login(username=self.username, password=self.password)\nself.assertEqual(login, True)\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/urls/test_all_curriculum_integrations.py", "new_path": "csunplugged/tests/topics/urls/test_all_curriculum_integrations.py", "diff": "@@ -6,6 +6,7 @@ class AllCurriculumIntegrationsURLTest(BaseTestWithDB):\ndef __init__(self, *args, **kwargs):\nsuper().__init__(*args, **kwargs)\n+ self.language = 'en'\ndef test_valid_curriculum_integration(self):\nurl = reverse('topics:all_curriculum_integrations')\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/urls/test_index.py", "new_path": "csunplugged/tests/topics/urls/test_index.py", "diff": "@@ -6,6 +6,7 @@ class IndexURLTest(BaseTestWithDB):\ndef __init__(self, *args, **kwargs):\nsuper().__init__(*args, **kwargs)\n+ self.language = 'en'\ndef test_valid_index(self):\nurl = reverse('topics:index')\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/urls/test_integration.py", "new_path": "csunplugged/tests/topics/urls/test_integration.py", "diff": "@@ -6,6 +6,7 @@ class IntegrationURLTest(BaseTestWithDB):\ndef __init__(self, *args, **kwargs):\nsuper().__init__(*args, **kwargs)\n+ self.language = 'en'\ndef test_valid_integration(self):\nurl = reverse('topics:integration', args=['binary-numbers', 'binary-bracelets'])\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/urls/test_integration_list.py", "new_path": "csunplugged/tests/topics/urls/test_integration_list.py", "diff": "@@ -6,6 +6,7 @@ class IntegrationListURLTest(BaseTestWithDB):\ndef __init__(self, *args, **kwargs):\nsuper().__init__(*args, **kwargs)\n+ self.language = 'en'\ndef test_valid_integration_list(self):\nurl = reverse('topics:integration_list', args=['binary-numbers'])\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/urls/test_lesson.py", "new_path": "csunplugged/tests/topics/urls/test_lesson.py", "diff": "@@ -6,6 +6,7 @@ class LessonURLTest(BaseTestWithDB):\ndef __init__(self, *args, **kwargs):\nsuper().__init__(*args, **kwargs)\n+ self.language = 'en'\ndef test_valid_lesson(self):\nurl = reverse('topics:lesson', args=['binary-numbers', 'unit-plan', 'lesson-1'])\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/urls/test_other_resources.py", "new_path": "csunplugged/tests/topics/urls/test_other_resources.py", "diff": "@@ -6,6 +6,7 @@ class OtherResourcesURLTest(BaseTestWithDB):\ndef __init__(self, *args, **kwargs):\nsuper().__init__(*args, **kwargs)\n+ self.language = 'en'\ndef test_valid_other_resources(self):\nurl = reverse('topics:other_resources', args=['binary-numbers'])\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/urls/test_programming_exercise.py", "new_path": "csunplugged/tests/topics/urls/test_programming_exercise.py", "diff": "@@ -6,6 +6,7 @@ class ProgrammingExerciseURLTest(BaseTestWithDB):\ndef __init__(self, *args, **kwargs):\nsuper().__init__(*args, **kwargs)\n+ self.language = 'en'\ndef test_valid_programming_exercise(self):\nurl = reverse('topics:programming_exercise', args=['binary-numbers', 'unit-plan', 'lesson-1', 'exercise-1'])\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/urls/test_programming_exercise_difficulty.py", "new_path": "csunplugged/tests/topics/urls/test_programming_exercise_difficulty.py", "diff": "@@ -6,6 +6,7 @@ class ProgrammingExerciseDifficultyURLTest(BaseTestWithDB):\ndef __init__(self, *args, **kwargs):\nsuper().__init__(*args, **kwargs)\n+ self.language = 'en'\ndef test_valid_programming_exercise_difficulty(self):\nurl = reverse('topics:programming_exercise_difficulty', args=['1'])\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/urls/test_programming_exercise_language_solution.py", "new_path": "csunplugged/tests/topics/urls/test_programming_exercise_language_solution.py", "diff": "@@ -6,6 +6,7 @@ class ProgrammingExerciseLanguageSolutionURLTest(BaseTestWithDB):\ndef __init__(self, *args, **kwargs):\nsuper().__init__(*args, **kwargs)\n+ self.language = 'en'\ndef test_valid_programming_exercise_language_solution(self):\nargs = ['binary-numbers', 'unit-plan', 'lesson-1', 'exercise-1', 'python']\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/urls/test_programming_exercises_list.py", "new_path": "csunplugged/tests/topics/urls/test_programming_exercises_list.py", "diff": "@@ -6,6 +6,7 @@ class ProgrammingExercisesListURLTest(BaseTestWithDB):\ndef __init__(self, *args, **kwargs):\nsuper().__init__(*args, **kwargs)\n+ self.language = 'en'\ndef test_valid_programming_exercises_list(self):\nurl = reverse('topics:programming_exercises_list', args=['binary-numbers', 'unit-plan', 'lesson-1'])\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/urls/test_topic.py", "new_path": "csunplugged/tests/topics/urls/test_topic.py", "diff": "@@ -6,6 +6,7 @@ class TopicURLTest(BaseTestWithDB):\ndef __init__(self, *args, **kwargs):\nsuper().__init__(*args, **kwargs)\n+ self.language = 'en'\ndef test_valid_topic(self):\nurl = reverse('topics:topic', args=['binary-numbers'])\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/urls/test_unit_plan.py", "new_path": "csunplugged/tests/topics/urls/test_unit_plan.py", "diff": "@@ -6,6 +6,7 @@ class UnitPlanURLTest(BaseTestWithDB):\ndef __init__(self, *args, **kwargs):\nsuper().__init__(*args, **kwargs)\n+ self.language = 'en'\ndef test_valid_unit_plan(self):\nurl = reverse('topics:unit_plan', args=['binary-numbers', 'unit-plan'])\n" } ]
Python
MIT License
uccser/cs-unplugged
Allow language specification of base test.
701,852
21.04.2017 11:14:11
-43,200
fd77d431fee62b68fe9d6999aa6855cf87967bb2
Update docstrings due to changes in methods.
[ { "change_type": "MODIFY", "old_path": "csunplugged/tests/BaseTest.py", "new_path": "csunplugged/tests/BaseTest.py", "diff": "@@ -23,7 +23,7 @@ class BaseTest(SimpleTestCase):\ndef setUp(self):\n'''Called before each test.\n- Sets the language to English, and creates a new client.\n+ Sets the language if specified and creates a new client.\n'''\nif self.language is not None:\nactivate(self.language)\n@@ -31,6 +31,5 @@ class BaseTest(SimpleTestCase):\ndef tearDown(self):\n'''Called after each test.\n- Deletes the user.\n'''\npass\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/tests/BaseTestWithDB.py", "new_path": "csunplugged/tests/BaseTestWithDB.py", "diff": "@@ -12,7 +12,7 @@ class BaseTestWithDB(TestCase):\n@classmethod\ndef setUpTestData(self):\n- '''Setup data for the whole TestCase.\n+ '''Setup data for the whole class.\n'''\npass\n@@ -34,7 +34,7 @@ class BaseTestWithDB(TestCase):\ndef setUp(self):\n'''Called before each test.\n- Sets the language to English, creates a new user and logs into the database\n+ Sets the language if specified, creates a new user and logs into the database\n'''\nif self.language is not None:\nactivate(self.language)\n" } ]
Python
MIT License
uccser/cs-unplugged
Update docstrings due to changes in methods.
701,852
21.04.2017 11:35:21
-43,200
7415dd91b3beffeb19800afedc66c562ba70ed07
Create user once for class when testing.
[ { "change_type": "MODIFY", "old_path": "csunplugged/tests/BaseTest.py", "new_path": "csunplugged/tests/BaseTest.py", "diff": "@@ -10,16 +10,16 @@ class BaseTest(SimpleTestCase):\nself.language = None\n@classmethod\n- def setUpClass(self):\n+ def setUpClass(cls):\n'''Called before tests in class.\n'''\n- super(BaseTest, self).setUpClass()\n+ super(BaseTest, cls).setUpClass()\n@classmethod\n- def tearDownClass(self):\n+ def tearDownClass(cls):\n'''Called after tests in class.\n'''\n- super(BaseTest, self).setUpClass()\n+ super(BaseTest, cls).tearDownClass()\ndef setUp(self):\n'''Called before each test.\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/tests/BaseTestWithDB.py", "new_path": "csunplugged/tests/BaseTestWithDB.py", "diff": "@@ -10,35 +10,37 @@ class BaseTestWithDB(TestCase):\nsuper().__init__(*args, **kwargs)\nself.language = None\n+\n@classmethod\n- def setUpTestData(self):\n+ def setUpTestData(cls):\n'''Setup data for the whole class.\n+ Creates a new user.\n'''\n- pass\n+ super(BaseTestWithDB, cls).setUpTestData()\n+ cls.username = 'test'\n+ cls.email = 'test@test.com'\n+ cls.password = 'test'\n+ cls.test_user = User.objects.create_user(cls.username, cls.email, cls.password)\n@classmethod\n- def setUpClass(self):\n+ def setUpClass(cls):\n'''Called before tests in class.\n'''\n- super(BaseTestWithDB, self).setUpClass()\n- self.client = Client()\n- self.username = 'test'\n- self.email = 'test@test.com'\n- self.password = 'test'\n+ super(BaseTestWithDB, cls).setUpClass()\n+ cls.client = Client()\n@classmethod\n- def tearDownClass(self):\n+ def tearDownClass(cls):\n'''Called after tests in class.\n'''\n- super(BaseTestWithDB, self).setUpClass()\n+ super(BaseTestWithDB, cls).tearDownClass()\ndef setUp(self):\n'''Called before each test.\n- Sets the language if specified, creates a new user and logs into the database\n+ Sets the language if specified, logs into the database\n'''\nif self.language is not None:\nactivate(self.language)\n- self.test_user = User.objects.create_user(self.username, self.email, self.password)\nlogin = self.client.login(username=self.username, password=self.password)\nself.assertEqual(login, True)\n@@ -46,4 +48,4 @@ class BaseTestWithDB(TestCase):\n'''Called after each test.\nDeletes the user.\n'''\n- self.test_user.delete()\n+ pass\n" } ]
Python
MIT License
uccser/cs-unplugged
Create user once for class when testing.
701,852
21.04.2017 12:35:06
-43,200
bd57295297bf0d1e0c052b1e0f3e52220523fe22
flake8 fixes for unused variable, reverting to previous code.
[ { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/views/test_index_view.py", "new_path": "csunplugged/tests/topics/views/test_index_view.py", "diff": "@@ -15,13 +15,14 @@ class IndexViewTest(BaseTestWithDB):\nself.assertEqual(response.status_code, 200)\ndef test_index_with_one_topic(self):\n- new_topic = Topic.objects.create(\n+ new_topic = Topic(\nslug='binary-numbers',\nname='Binary Numbers',\ncontent='content',\nother_resources='content',\nicon='icon'\n)\n+ new_topic.save()\nurl = reverse('topics:index')\nresponse = self.client.get(url)\n" } ]
Python
MIT License
uccser/cs-unplugged
flake8 fixes for unused variable, reverting to previous code.
701,852
25.05.2017 09:24:37
-43,200
bf916b2a83d03e45467b8fc0c957bc16bed392e2
Select repo sources to avoid issues with CDN returning 503s.
[ { "change_type": "MODIFY", "old_path": "infrastructure/nginx/Dockerfile", "new_path": "infrastructure/nginx/Dockerfile", "diff": "FROM nginx:latest\n+# Populate sources with closest neighbours\n+# Resolves issues with failing builds, should be removed in future\n+RUN apt-get update \\\n+ && apt-get install -y netselect-apt --no-install-suggests \\\n+ && netselect-apt stretch \\\n+ && mv sources.list /etc/apt/sources.list\n+\n# Install Node.js and other dependencies\n-RUN apt-get update && \\\n- apt-get -y install curl gnupg2 && \\\n- curl -sL https://deb.nodesource.com/setup_6.x | bash - && \\\n- apt-get -y install python build-essential nodejs\n+RUN apt-get update \\\n+ && apt-get install --no-install-suggests -y \\\n+ curl \\\n+ gnupg2 \\\n+ python \\\n+ build-essential \\\n+ && curl -sL https://deb.nodesource.com/setup_6.x \\\n+ && curl -sL https://deb.nodesource.com/setup_6.x | bash - \\\n+ && apt-get install --no-install-suggests -y \\\n+ nodejs \\\n+ && apt-get remove --purge -y gnupg2 && apt-get -y --purge autoremove \\\n+ && rm -rf /var/lib/apt/lists/*\n+\nWORKDIR /app\n-RUN npm install --global gulp-cli\n-RUN npm install --global node-gyp\n-RUN apt-get update && apt-get install -y \\\n+RUN npm install --global gulp-cli node-gyp\n+RUN apt-get update \\\n+ && apt-get install --no-install-suggests -y \\\nlibcairo2-dev \\\nlibjpeg-dev \\\nlibpango1.0-dev \\\nlibgif-dev \\\n- g++\n+ g++ \\\n+ && rm -rf /var/lib/apt/lists/*\n+\nADD csunplugged/package.json /app/\nRUN npm install\nADD ./csunplugged/ /app/\n" } ]
Python
MIT License
uccser/cs-unplugged
Select repo sources to avoid issues with CDN returning 503s.
701,852
25.05.2017 10:37:43
-43,200
e437023a3f82c72f46732e977f68de6b6d72e120
Remove printing of the Nodejs install script.
[ { "change_type": "MODIFY", "old_path": "infrastructure/nginx/Dockerfile", "new_path": "infrastructure/nginx/Dockerfile", "diff": "@@ -14,7 +14,6 @@ RUN apt-get update \\\ngnupg2 \\\npython \\\nbuild-essential \\\n- && curl -sL https://deb.nodesource.com/setup_6.x \\\n&& curl -sL https://deb.nodesource.com/setup_6.x | bash - \\\n&& apt-get install --no-install-suggests -y \\\nnodejs \\\n" } ]
Python
MIT License
uccser/cs-unplugged
Remove printing of the Nodejs install script.
701,852
19.06.2017 15:51:27
-43,200
20d98f1961babeaf4be50dfd6bffc16728c5c95a
Minor whitespacing fixes.
[ { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/design-a-bee-bot/design-a-bee-bot.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/design-a-bee-bot/design-a-bee-bot.md", "diff": "## Requirement:\n{panel type=\"general\" title=\"Note\"}\n+\nThis is a very complex program, but if students can understand it then they will have tackled a deep concept in computer science, which is implementing a programming language using another programming language! For students with less programming experience, it may be more helpful to start with the complete project and make modifications to it, such as adding a new command (like \"spin\", which spins the cat on the spot). See **KidBots challenges 1.2 and 1.3** for the complete solutions and the instructions for adding a spin button.\n+\n{panel end}\nWrite a program to simulate a Bee-Bot, which can be programmed with five commands (forward, left, right, back, pause). Pressing the four commands stores them in a list called \"source code\", and pressing the GO button will activate a script that goes through the list of commands and moves the cat according to each command.\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modify-a-bee-bot/scratch-solution.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modify-a-bee-bot/scratch-solution.md", "diff": "**The Button Sprites**\nforward:\n+\n```scratch\nwhen this sprite clicked\ninsert [forward] at (last v) of [source code v]\n```\nbackward:\n+\n```scratch\nwhen this sprite clicked\ninsert [backward] at (last v) of [source code v]\n```\nleft:\n+\n```scratch\nwhen this sprite clicked\ninsert [turn left] at (last v) of [source code v]\n```\nright:\n+\n```scratch\nwhen this sprite clicked\ninsert [turn right] at (last v) of [source code v]\n```\ngo:\n+\n```scratch\nwhen this sprite clicked\nbroadcast [go v]\n```\nhome:\n+\n```scratch\nwhen this sprite clicked\nbroadcast [home v]\n```\nundo:\n+\n```scratch\nwhen this sprite clicked\ndelete (last v) of [source code v]\n```\nspin:\n+\n```scratch\nwhen this sprite clicked\ninsert [spin] at (last v) of [source code v]\n```\nclear:\n+\n```scratch\nwhen this sprite clicked\ndelete (all v) of [source code v]\n@@ -57,6 +66,7 @@ delete (all v) of [source code v]\n**The Sprites**\nMouse:\n+\n```scratch\nwhen green flag clicked\nset size to (30) %\n@@ -64,6 +74,7 @@ go to x: ((pick random (-1) to (4)) * (50)) y: ((pick random (-3) to (3)) * (50)\n```\nCat:\n+\n```scratch\nwhen I receive [go v]\nset [statement v] to [0]\n" } ]
Python
MIT License
uccser/cs-unplugged
Minor whitespacing fixes.
701,852
19.06.2017 16:35:37
-43,200
e73710b7dd93af8734ea9ec092ef686cd21d531e
Add configuration for geometry programming challenges.
[ { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/programming-challenges.yaml", "diff": "+draw-a-square-without-loop:\n+ challenge-set-number: 1\n+ challenge-number: 1\n+ difficulty-level: 1\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-sequencing\n+ - programming-explain-output\n+\n+draw-a-square-with-loop:\n+ challenge-set-number: 1\n+ challenge-number: 2\n+ difficulty-level: 1\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-sequencing\n+ - programming-explain-output\n+ - programming-identify-loop\n+\n+rotation-of-a-square:\n+ challenge-set-number: 1\n+ challenge-number: 3\n+ difficulty-level: 1\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-sequencing\n+ - programming-explain-output\n+ - programming-identify-loop\n+\n+draw-a-triangle-without-loop:\n+ challenge-set-number: 2\n+ challenge-number: 1\n+ difficulty-level: 1\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-sequencing\n+ - programming-explain-output\n+\n+draw-a-triangle-with-loop:\n+ challenge-set-number: 2\n+ challenge-number: 2\n+ difficulty-level: 1\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-sequencing\n+ - programming-explain-output\n+ - programming-identify-loop\n+\n+rotation-of-a-triangle:\n+ challenge-set-number: 2\n+ challenge-number: 3\n+ difficulty-level: 1\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-sequencing\n+ - programming-explain-output\n+ - programming-identify-loop\n+\n+draw-a-pentagon-without-loop:\n+ challenge-set-number: 3\n+ challenge-number: 1\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-sequencing\n+ - programming-explain-output\n+\n+draw-a-pentagon-with-loop:\n+ challenge-set-number: 3\n+ challenge-number: 2\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-sequencing\n+ - programming-explain-output\n+ - programming-identify-loop\n+\n+rotation-of-a-pentagon:\n+ challenge-set-number: 3\n+ challenge-number: 3\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-sequencing\n+ - programming-explain-output\n+ - programming-identify-loop\n+\n+draw-a-360-sided-polygon:\n+ challenge-set-number: 4\n+ challenge-number: 1\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-sequencing\n+ - programming-explain-output\n+ - programming-identify-loop\n+\n+draw-a-circle-with-radius-100:\n+ challenge-set-number: 4\n+ challenge-number: 2\n+ difficulty-level: 3\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-describe-mathematical-operations\n+ - programming-describe-variables\n+ - programming-explain-sequencing\n+ - programming-explain-output\n+ extra-challenge: extra-challenge.md\n+\n+rotation-of-a-circle:\n+ challenge-set-number: 4\n+ challenge-number: 3\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-describe-mathematical-operations\n+ - programming-describe-variables\n+ - programming-explain-sequencing\n+ - programming-explain-output\n+ extra-challenge: extra-challenge.md\n+\n+draw-a-regular-polygon:\n+ challenge-set-number: 5\n+ challenge-number: 1\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-asking-input-end-user\n+ - programming-explain-sequencing\n+ - programming-describe-variables\n+ - programming-identify-loop\n+ extra-challenge: extra-challenge.md\n+\n+calculate-inside-angles-of-regular-polygons:\n+ challenge-set-number: 5\n+ challenge-number: 2\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-asking-input-end-user\n+ - programming-explain-sequencing\n+ - programming-describe-variables\n+ - programming-identify-loop\n+\n+draw-different-types-of-angles:\n+ challenge-set-number: 6\n+ challenge-number: 1\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-identify-if-statement\n+ - programming-describe-variables\n+ - programming-describe-mathematical-operations\n+\n+draw-different-types-of-triangles:\n+ challenge-set-number: 6\n+ challenge-number: 2\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-identify-if-statement\n+ - programming-describe-variables\n+ - programming-describe-mathematical-operations\n+\n+draw-a-5-pointed-star:\n+ challenge-set-number: 7\n+ challenge-number: 1\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-sequencing\n+ - programming-describe-variables\n+ - programming-identify-loop\n+\n+draw-a-star-with-odd-points:\n+ challenge-set-number: 7\n+ challenge-number: 2\n+ difficulty-level: 3\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-identify-loop\n+ - programming-describe-variables\n+ - programming-describe-mathematical-operations\n+\n+draw-a-star-without-crossing-lines:\n+ challenge-set-number: 7\n+ challenge-number: 3\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-sequencing\n+ - programming-describe-variables\n+ - programming-identify-loop\n+\n+draw-a-star:\n+ challenge-set-number: 7\n+ challenge-number: 4\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-sequencing\n+ - programming-describe-variables\n+ - programming-identify-loop\n+\n+draw-a-rhombus:\n+ challenge-set-number: 8\n+ challenge-number: 1\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-sequencing\n+ - programming-describe-variables\n+ - programming-identify-loop\n+ - programming-explain-asking-input-end-user\n+\n+draw-a-cube:\n+ challenge-set-number: 8\n+ challenge-number: 2\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-sequencing\n+ - programming-describe-variables\n+ - programming-identify-loop\n+\n+translation:\n+ challenge-set-number: 8\n+ challenge-number: 3\n+ difficulty-level: 3\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-sequencing\n+ - programming-describe-variables\n+ - programming-identify-loop\n+ - programming-describe-mathematical-operations\n+\n+reflection:\n+ challenge-set-number: 9\n+ challenge-number: 1\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-sequencing\n+ - programming-describe-variables\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/unplugged-programming.yaml", "new_path": "csunplugged/topics/content/en/unplugged-programming/unplugged-programming.yaml", "diff": "@@ -2,3 +2,5 @@ unit-plans:\n- kidbots-unit-plan/kidbots-unit-plan.yaml\nicon: img/topics/unplugged-programming-icon.png\n+\n+programming-challenges: programming-challenges/programming-challenges.yaml\n" } ]
Python
MIT License
uccser/cs-unplugged
Add configuration for geometry programming challenges.
701,852
19.06.2017 16:50:39
-43,200
36a4ad50cd48c7c4646508606ad3a45f9c5c98ba
tidy and fix.
[ { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/catch-the-mouse-random/catch-the-mouse-random.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/catch-the-mouse-random/catch-the-mouse-random.md", "diff": "-# Catch the Mouse (with random backdrops)\n+# Catch the mouse (with random backdrops)\n## Requirement:\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/catch-the-mouse/catch-the-mouse.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/catch-the-mouse/catch-the-mouse.md", "diff": "-# Catch the Mouse\n+# Catch the mouse\n## Requirement:\n" }, { "change_type": "RENAME", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/design-a-bee-bot/design-a-bee-bot.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/design-bee-bot/design-bee-bot.md", "diff": "" }, { "change_type": "RENAME", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/design-a-bee-bot/scratch-expected.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/design-bee-bot/scratch-expected.md", "diff": "" }, { "change_type": "RENAME", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/design-a-bee-bot/scratch-hints.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/design-bee-bot/scratch-hints.md", "diff": "" }, { "change_type": "RENAME", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/design-a-bee-bot/scratch-solution.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/design-bee-bot/scratch-solution.md", "diff": "" }, { "change_type": "RENAME", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modify-a-bee-bot/modify-a-bee-bot.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modify-bee-bot/modify-bee-bot.md", "diff": "" }, { "change_type": "RENAME", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modify-a-bee-bot/scratch-expected.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modify-bee-bot/scratch-expected.md", "diff": "" }, { "change_type": "RENAME", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modify-a-bee-bot/scratch-solution.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modify-bee-bot/scratch-solution.md", "diff": "" }, { "change_type": "RENAME", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/program-a-bee-bot/program-a-bee-bot.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/program-bee-bot/program-bee-bot.md", "diff": "" }, { "change_type": "RENAME", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/program-a-bee-bot/scratch-expected.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/program-bee-bot/scratch-expected.md", "diff": "" }, { "change_type": "RENAME", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/program-a-bee-bot/scratch-solution.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/program-bee-bot/scratch-solution.md", "diff": "" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/programming-challenges.yaml", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/programming-challenges.yaml", "diff": "-design-a-bee-bot:\n+design-bee-bot:\nchallenge-set-number: 1\nchallenge-number: 1\ndifficulty-level: 3\nprogramming-languages:\n- scratch\n-program-a-bee-bot:\n+program-bee-bot:\nchallenge-set-number: 1\nchallenge-number: 2\ndifficulty-level: 1\nprogramming-languages:\n- scratch\n-modify-a-bee-bot:\n+modify-bee-bot:\nchallenge-set-number: 1\nchallenge-number: 3\ndifficulty-level: 2\n" } ]
Python
MIT License
uccser/cs-unplugged
tidy and fix.
701,852
19.06.2017 17:14:21
-43,200
ab192c4c11f3d80fa22d44429f71dfa4f32a5d4a
Added programming exercises on squares.
[ { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-square-with-loop/draw-square-with-loop.md", "diff": "+# Draw a square (with a loop)\n+\n+##Requirement:\n+\n+Write a program that draws a square, starting from point x:0, y:0, with its sides equal to 100 steps. You must use a repeat loop for this challenge.\n+\n+##Testing examples:\n+\n+There are no testing examples for this challenge.\n+\n+Click on the green flag to see the expected output of your program.\n+\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-square-with-loop/extra-challenge.md", "diff": "+**Extra challenge #1:** Write a program that takes the length of a side of a square as the input, draws the square with the given side and displays its perimeter as the output.\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-square-with-loop/scratch-expected.md", "diff": "+Click on the green flag to see the expected output of your program.\n+\n+{iframe link=\"https://scratch.mit.edu/projects/embed/152445283/?autostart=false\"}\n+\n+{panel type=\"help\" title=\"Recommended blocks\"}\n+\n+```scratch:split:random\n+when green flag clicked\n+```\n+\n+```scratch:split:random\n+clear\n+\n+pen down\n+\n+pen up\n+```\n+\n+```scratch:split:random\n+go to x: (0) y: (0)\n+\n+move (100) steps\n+\n+turn cw (90) degrees\n+```\n+\n+```scratch:split:random\n+repeat (4)\n+end\n+\n+wait (1) secs\n+```\n+\n+{panel end}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-square-with-loop/scratch-hints.md", "diff": "+ - A square has four equal sides and four equal angles (90-degree angles, or right angles).\n+\n+ - Block WAIT() secs waits specified number of seconds, then continues with next block. To be able to see each sides of the square being drawn, use the wait block after turning each angle.\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-square-with-loop/scratch-solution.md", "diff": "+```scratch\n+when green flag clicked\n+clear\n+go to x: (0) y: (0)\n+pen down\n+repeat (4)\n+ move (100) steps\n+ turn cw (90) degrees\n+ wait (1) secs\n+end\n+pen up\n+```\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-square-without-loop/draw-square-without-loop.md", "diff": "+# Draw a square (without a loop)\n+\n+##Requirement:\n+\n+Write a program that draws a square, starting from point x:0, y:0, with its sides equal to 100 steps without using a repeat loop.\n+\n+##Testing examples:\n+\n+There are no testing examples for this challenge.\n+\n+Click on the green flag to see the expected output of your program.\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-square-without-loop/scratch-expected.md", "diff": "+Click on the green flag to see the expected output of your program.\n+\n+{iframe link=\"https://scratch.mit.edu/projects/embed/152445214/?autostart=false\"}\n+\n+{panel type=\"help\" title=\"Recommended blocks\"}\n+\n+```scratch:split:random\n+when green flag clicked\n+```\n+\n+```scratch:split:random\n+clear\n+\n+pen down\n+\n+pen up\n+```\n+\n+```scratch:split:random\n+go to x: (0) y: (0)\n+\n+move (100) steps\n+\n+turn cw (90) degrees\n+```\n+\n+```scratch:split:random\n+wait (1) secs\n+```\n+\n+{panel end}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-square-without-loop/scratch-hints.md", "diff": "+ - A square has four equal sides and four equal angles (90-degree angles, or right angles).\n+\n+ - The block WAIT() secs waits specified number of seconds, then continues with next block. To be able to see each sides of the square being drawn, use the wait block after turning each angle.\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-square-without-loop/scratch-solution.md", "diff": "+```scratch\n+when green flag clicked\n+clear\n+go to x: (0) y: (0)\n+pen down\n+move (100) steps\n+turn cw (90) degrees\n+wait (1) secs\n+move (100) steps\n+turn cw (90) degrees\n+wait (1) secs\n+move (100) steps\n+turn cw (90) degrees\n+wait (1) secs\n+move (100) steps\n+turn cw (90) degrees\n+wait (1) secs\n+pen up\n+```\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/programming-challenges.yaml", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/programming-challenges.yaml", "diff": "-draw-a-square-without-loop:\n+draw-square-without-loop:\nchallenge-set-number: 1\nchallenge-number: 1\ndifficulty-level: 1\n@@ -8,7 +8,7 @@ draw-a-square-without-loop:\n- programming-explain-sequencing\n- programming-explain-output\n-draw-a-square-with-loop:\n+draw-square-with-loop:\nchallenge-set-number: 1\nchallenge-number: 2\ndifficulty-level: 1\n@@ -18,6 +18,7 @@ draw-a-square-with-loop:\n- programming-explain-sequencing\n- programming-explain-output\n- programming-identify-loop\n+ extra-challenge: extra-challenge.md\nrotation-of-a-square:\nchallenge-set-number: 1\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/rotation-of-a-square/rotation-of-a-square.md", "diff": "+# Draw a square (with a loop)\n+\n+##Requirement:\n+\n+Write a program that draws a square, starting from point x:0, y:0, with its sides equal to 100 steps. Your program must then draw squares that are each rotated 15 degrees from the previous one (forever), changing its colour every time it draws a new square.\n+\n+##Testing examples:\n+\n+There are no testing examples for this challenge.\n+\n+Click on the green flag to see the expected output of your program.\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/rotation-of-a-square/scratch-expected.md", "diff": "+Click on the green flag to see the expected output of your program.\n+\n+{iframe link=\"https://scratch.mit.edu/projects/embed/152445346/?autostart=false\"}\n+\n+{panel type=\"help\" title=\"Recommended blocks\"}\n+\n+```scratch:split:random\n+when green flag clicked\n+```\n+\n+```scratch:split:random\n+clear\n+\n+pen down\n+\n+pen up\n+\n+change pen color by (10)\n+```\n+\n+```scratch:split:random\n+go to x: (0) y: (0)\n+\n+move (100) steps\n+\n+turn cw (90) degrees\n+\n+turn cw (15) degrees\n+```\n+\n+```scratch:split:random\n+forever\n+end\n+\n+repeat (4)\n+end\n+\n+wait (1) secs\n+```\n+\n+{panel end}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/rotation-of-a-square/scratch-solution.md", "diff": "+```scratch\n+when green flag clicked\n+clear\n+go to x: (0) y: (0)\n+pen down\n+forever\n+ repeat (4)\n+ move (100) steps\n+ turn cw (90) degrees\n+ end\n+ turn cw (15) degrees\n+ change pen color by (10)\n+end\n+```\n" } ]
Python
MIT License
uccser/cs-unplugged
Added programming exercises on squares.
701,852
20.06.2017 11:59:15
-43,200
166cad09ec9681287cb9e4de1ebcdc86ff0f9acd
Pentagon programming challenges.
[ { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-pentagon-with-loop/draw-pentagon-with-loop.md", "diff": "+# Draw a pentagon (with a loop)\n+\n+## Requirement:\n+\n+Write a program that draws a pentagon (5 sides polygon), starting from point x:0, y:0, with its sides equal to 100 steps. You must use a repeat loop for this challenge.\n+\n+## Testing examples:\n+\n+There are no testing examples for this challenge.\n+\n+Click on the green flag to see the expected output of your program.\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-pentagon-with-loop/extra-challenge.md", "diff": "+**Extra challenge #1:** Write a program that takes the length of a side of a pentagon as the input, draws the pentagon with the given side and displays its perimeter as the output.\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-pentagon-with-loop/scratch-expected.md", "diff": "+Click on the green flag to see the expected output of your program.\n+\n+{iframe link=\"https://scratch.mit.edu/projects/embed/152447879/?autostart=false\"}\n+\n+{panel type=\"help\" title=\"Recommended blocks\"}\n+\n+```scratch:split:random\n+when green flag clicked\n+```\n+\n+```scratch:split:random\n+clear\n+\n+pen down\n+\n+pen up\n+```\n+\n+```scratch:split:random\n+go to x: (0) y: (0)\n+\n+move (100) steps\n+\n+turn cw (72) degrees\n+```\n+\n+```scratch:split:random\n+wait (1) secs\n+\n+repeat (5)\n+end\n+```\n+\n+{panel end}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-pentagon-with-loop/scratch-hints.md", "diff": "+ - A pentagon has five equal sides and five equal angles.\n+ - Block `scratch:wait () secs` waits specified number of seconds, then continues with next block. To be able to see each sides of the pentagon being drawn, use the wait block after turning each angle.\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-pentagon-with-loop/scratch-solution.md", "diff": "+```scratch\n+when green flag clicked\n+clear\n+go to x: (0) y: (0)\n+pen down\n+repeat (5)\n+ move (100) steps\n+ turn cw (72) degrees\n+ wait (1) secs\n+end\n+pen up\n+```\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-pentagon-without-loop/draw-pentagon-without-loop.md", "diff": "+# Draw a pentagon (without a loop)\n+\n+## Requirement:\n+\n+Write a program that draws a pentagon (5 sides polygon), starting from point x:0, y:0, with its sides equal to 100 steps without using a repeat loop.\n+\n+\n+## Testing examples:\n+\n+There are no testing examples for this challenge.\n+\n+Click on the green flag to see the expected output of your program.\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-pentagon-without-loop/scratch-expected.md", "diff": "+Click on the green flag to see the expected output of your program.\n+\n+{iframe link=\"https://scratch.mit.edu/projects/embed/152447785/?autostart=false\"}\n+\n+{panel type=\"help\" title=\"Recommended blocks\"}\n+\n+```scratch:split:random\n+when green flag clicked\n+```\n+\n+```scratch:split:random\n+clear\n+\n+pen down\n+\n+pen up\n+```\n+\n+```scratch:split:random\n+go to x: (0) y: (0)\n+\n+move (100) steps\n+\n+turn cw (72) degrees\n+```\n+\n+```scratch:split:random\n+wait (1) secs\n+```\n+\n+{panel end}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-pentagon-without-loop/scratch-hints.md", "diff": "+ - A pentagon has five equal sides and five equal angles.\n+ - Block `scratch:wait () secs` waits specified number of seconds, then continues with next block. To be able to see each sides of the pentagon being drawn, use the wait block after turning each angle.\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-pentagon-without-loop/scratch-solution.md", "diff": "+```scratch\n+when green flag clicked\n+clear\n+go to x: (0) y: (0)\n+pen down\n+move (100) steps\n+turn cw (72) degrees\n+wait (1) secs\n+move (100) steps\n+turn cw (72) degrees\n+wait (1) secs\n+move (100) steps\n+turn cw (72) degrees\n+wait (1) secs\n+move (100) steps\n+turn cw (72) degrees\n+wait (1) secs\n+move (100) steps\n+turn cw (72) degrees\n+wait (1) secs\n+pen up\n+```\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/programming-challenges.yaml", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/programming-challenges.yaml", "diff": "@@ -63,8 +63,9 @@ rotation-of-a-triangle:\n- programming-explain-sequencing\n- programming-explain-output\n- programming-identify-loop\n+ extra-challenge: extra-challenge.md\n-draw-a-pentagon-without-loop:\n+draw-pentagon-without-loop:\nchallenge-set-number: 3\nchallenge-number: 1\ndifficulty-level: 2\n@@ -74,7 +75,7 @@ draw-a-pentagon-without-loop:\n- programming-explain-sequencing\n- programming-explain-output\n-draw-a-pentagon-with-loop:\n+draw-pentagon-with-loop:\nchallenge-set-number: 3\nchallenge-number: 2\ndifficulty-level: 2\n@@ -84,6 +85,7 @@ draw-a-pentagon-with-loop:\n- programming-explain-sequencing\n- programming-explain-output\n- programming-identify-loop\n+ extra-challenge: extra-challenge.md\nrotation-of-a-pentagon:\nchallenge-set-number: 3\n@@ -95,8 +97,9 @@ rotation-of-a-pentagon:\n- programming-explain-sequencing\n- programming-explain-output\n- programming-identify-loop\n+ extra-challenge: extra-challenge.md\n-draw-a-360-sided-polygon:\n+draw-360-sided-polygon:\nchallenge-set-number: 4\nchallenge-number: 1\ndifficulty-level: 2\n@@ -107,7 +110,7 @@ draw-a-360-sided-polygon:\n- programming-explain-output\n- programming-identify-loop\n-draw-a-circle-with-radius-100:\n+draw-circle-with-radius-100:\nchallenge-set-number: 4\nchallenge-number: 2\ndifficulty-level: 3\n@@ -133,7 +136,7 @@ rotation-of-a-circle:\n- programming-explain-output\nextra-challenge: extra-challenge.md\n-draw-a-regular-polygon:\n+draw-regular-polygons:\nchallenge-set-number: 5\nchallenge-number: 1\ndifficulty-level: 2\n@@ -180,7 +183,7 @@ draw-different-types-of-triangles:\n- programming-describe-variables\n- programming-describe-mathematical-operations\n-draw-a-5-pointed-star:\n+draw-5-pointed-star:\nchallenge-set-number: 7\nchallenge-number: 1\ndifficulty-level: 2\n@@ -191,7 +194,7 @@ draw-a-5-pointed-star:\n- programming-describe-variables\n- programming-identify-loop\n-draw-a-star-with-odd-points:\n+draw-star-with-odd-points:\nchallenge-set-number: 7\nchallenge-number: 2\ndifficulty-level: 3\n@@ -202,7 +205,7 @@ draw-a-star-with-odd-points:\n- programming-describe-variables\n- programming-describe-mathematical-operations\n-draw-a-star-without-crossing-lines:\n+draw-star-without-crossing-lines:\nchallenge-set-number: 7\nchallenge-number: 3\ndifficulty-level: 2\n@@ -213,7 +216,7 @@ draw-a-star-without-crossing-lines:\n- programming-describe-variables\n- programming-identify-loop\n-draw-a-star:\n+draw-star:\nchallenge-set-number: 7\nchallenge-number: 4\ndifficulty-level: 2\n@@ -224,7 +227,7 @@ draw-a-star:\n- programming-describe-variables\n- programming-identify-loop\n-draw-a-rhombus:\n+draw-rhombus:\nchallenge-set-number: 8\nchallenge-number: 1\ndifficulty-level: 2\n@@ -236,7 +239,7 @@ draw-a-rhombus:\n- programming-identify-loop\n- programming-explain-asking-input-end-user\n-draw-a-cube:\n+draw-cube:\nchallenge-set-number: 8\nchallenge-number: 2\ndifficulty-level: 2\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/rotation-of-a-pentagon/rotation-of-a-pentagon.md", "diff": "+# Rotation of a pentagon\n+\n+## Requirement:\n+\n+Write a program that draws a pentagon, starting from point x:0, y:0, with its sides equal to 100 steps. Your program must then draw pentagons that are each rotated 15 degrees from the previous one (forever), changing its colour every time it draws a new pentagon.\n+\n+## Testing examples:\n+\n+There are no testing examples for this challenge.\n+\n+Click on the green flag to see the expected output of your program.\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/rotation-of-a-pentagon/scratch-expected.md", "diff": "+Click on the green flag to see the expected output of your program.\n+\n+{iframe link=\"https://scratch.mit.edu/projects/embed/152447963/?autostart=false\"}\n+\n+{panel type=\"help\" title=\"Recommended blocks\"}\n+\n+```scratch:split:random\n+when green flag clicked\n+```\n+\n+```scratch:split:random\n+clear\n+\n+pen down\n+\n+pen up\n+\n+change pen color by (10)\n+```\n+\n+```scratch:split:random\n+go to x: (0) y: (0)\n+\n+move (100) steps\n+\n+turn cw (72) degrees\n+\n+turn cw (15) degrees\n+```\n+\n+```scratch:split:random\n+wait (1) secs\n+\n+repeat (5)\n+end\n+\n+forever\n+end\n+```\n+\n+{panel end}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/rotation-of-a-pentagon/scratch-solution.md", "diff": "+```scratch\n+when green flag clicked\n+clear\n+go to x: (0) y: (0)\n+pen down\n+forever\n+ repeat (5)\n+ move (100) steps\n+ turn cw (72) degrees\n+ end\n+ turn cw (15) degrees\n+ change pen color by (10)\n+end\n+```\n" } ]
Python
MIT License
uccser/cs-unplugged
Pentagon programming challenges.
701,852
20.06.2017 12:45:55
-43,200
0bb8a5983297bb25aefd6e4e51c878d1bfb3089e
Circle programming challenges.
[ { "change_type": "ADD", "old_path": "csunplugged/static/img/topics/programming-challenges/circle_red.png", "new_path": "csunplugged/static/img/topics/programming-challenges/circle_red.png", "diff": "Binary files /dev/null and b/csunplugged/static/img/topics/programming-challenges/circle_red.png differ\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-360-sided-polygon/draw-360-sided-polygon.md", "diff": "+# Draw a 360 sided polygon\n+\n+## Requirement:\n+\n+Write a program that draws a 360-gon, a polygon with 360 sides of length 1 step, turing one degree at each point. Note: The sides are so small that this will look like a circle, but a 360 sided polygon is geometrically different from a circle (i.e. circle has infinite number of sides). Still, in the following challenges we will call it a circle.\n+\n+## Testing examples:\n+\n+There are no testing examples for this challenge.\n+\n+Click on the green flag to see the expected output of your program.\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-360-sided-polygon/scratch-expected.md", "diff": "+Click on the green flag to see the expected output of your program.\n+\n+{iframe link=\"https://scratch.mit.edu/projects/embed/152909804/?autostart=false\"}\n+\n+{panel type=\"help\" title=\"Recommended blocks\"}\n+\n+```scratch:split:random\n+when green flag clicked\n+```\n+\n+```scratch:split:random\n+clear\n+\n+pen down\n+\n+pen up\n+```\n+\n+```scratch:split:random\n+go to x: (0) y: (0)\n+\n+move (1) steps\n+\n+turn cw (1) degrees\n+```\n+\n+```scratch:split:random\n+wait (1) secs\n+\n+repeat (360)\n+end\n+```\n+\n+{panel end}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-360-sided-polygon/scratch-solution.md", "diff": "+```scratch\n+when green flag clicked\n+clear\n+go to x: (0) y: (0)\n+pen down\n+repeat (360)\n+ move (1) steps\n+ turn cw (1) degrees\n+end\n+pen up\n+```\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-circle-with-radius-100/draw-circle-with-radius-100.md", "diff": "+# Draw a circle with radius 100\n+\n+## Requirement:\n+\n+Write a program that draws a circle, with the given centre point x:0, y:0, and its radius equal to 100 steps. You can use the same method as challenge 4.1 above i.e. draw a 360-sided polygon, but this time you will need to work out how long each side is based on the circumference of the circle, and you'll need to work out the circumference from the radius.\n+\n+## Testing examples:\n+\n+There are no testing examples for this challenge.\n+\n+Click on the green flag to see the expected output of your program.\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-circle-with-radius-100/scratch-expected.md", "diff": "+Click on the green flag to see the expected output of your program.\n+\n+{iframe link=\"https://scratch.mit.edu/projects/embed/152451264/?autostart=false\"}\n+\n+{panel type=\"help\" title=\"Recommended blocks\"}\n+\n+```scratch:split:random\n+when green flag clicked\n+```\n+\n+```scratch:split:random\n+clear\n+\n+pen down\n+\n+pen up\n+```\n+\n+```scratch:split:random\n+set [pi v] to [3.1415]\n+\n+set [radius v] to [100]\n+```\n+\n+```scratch:split:random\n+go to x: (0) y: (0)\n+\n+point in direction (0 v)\n+\n+point in direction (90 v)\n+\n+move (radius) steps\n+\n+move ((((radius) * (2)) * (pi)) / (360)) steps\n+\n+turn ccw (1) degrees\n+```\n+\n+```scratch:split:random\n+wait (1) secs\n+\n+repeat (360)\n+end\n+```\n+\n+{panel end}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-circle-with-radius-100/scratch-solution.md", "diff": "+```scratch\n+when green flag clicked\n+clear\n+go to x: (0) y: (0)\n+point in direction (90 v)\n+set [pi v] to [3.1415]\n+set [radius v] to [100]\n+move (radius) steps\n+point in direction (0 v)\n+pen down\n+repeat (360)\n+ move ((((radius) * (2)) * (pi)) / (360)) steps\n+ turn ccw (1) degrees\n+end\n+pen up\n+```\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/rotation-of-a-circle/rotation-of-a-circle.md", "diff": "+# Rotation of a circle\n+\n+## Requirement:\n+\n+Write a program that draws a circle, with the given centre point x:0, y:0, and its radius equal to 50 steps. Your program must then draw circles that are each rotated 15 degrees from the previous one (forever), changing its colour every time it draws a new circle.\n+\n+## Testing examples:\n+\n+There are no testing examples for this challenge.\n+\n+Click on the green flag to see the expected output of your program.\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/rotation-of-a-circle/scratch-expected.md", "diff": "+Click on the green flag to see the expected output of your program.\n+\n+{iframe link=\"https://scratch.mit.edu/projects/embed/152451264/?autostart=false\"}\n+\n+{panel type=\"help\" title=\"Recommended blocks\"}\n+\n+```scratch:split:random\n+when green flag clicked\n+```\n+\n+```scratch:split:random\n+clear\n+\n+pen down\n+\n+pen up\n+```\n+\n+```scratch:split:random\n+set [pi v] to [3.1415]\n+\n+set [radius v] to [100]\n+```\n+\n+```scratch:split:random\n+go to x: (0) y: (0)\n+\n+point in direction (0 v)\n+\n+point in direction (90 v)\n+\n+move (radius) steps\n+\n+move ((((radius) * (2)) * (pi)) / (360)) steps\n+\n+turn ccw (1) degrees\n+```\n+\n+```scratch:split:random\n+wait (1) secs\n+\n+repeat (360)\n+end\n+```\n+\n+{panel end}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/rotation-of-a-circle/scratch-solution.md", "diff": "+```scratch\n+when green flag clicked\n+clear\n+go to x: (0) y: (0)\n+point in direction (90 v)\n+set [pi v] to [3.1415]\n+set [radius v] to [100]\n+move (radius) steps\n+point in direction (0 v)\n+pen down\n+repeat (360)\n+ move ((((radius) * (2)) * (pi)) / (360)) steps\n+ turn ccw (1) degrees\n+end\n+pen up\n+```\n" } ]
Python
MIT License
uccser/cs-unplugged
Circle programming challenges.
701,852
20.06.2017 12:59:06
-43,200
407127dc377c55ede053c26b72e7cfd46eae8050
Regular polygon programming exercises.
[ { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/calculate-inside-angles-of-regular-polygons/calculate-inside-angles-of-regular-polygons.md", "diff": "+# Calculate the inside angles of regular polygons\n+\n+## Requirement:\n+\n+Write a program that draws any regular polygon with the number of sides entered by the user as the input and the length of each sides equal to 50 steps. It then displays the interior angles of the the polygon in degrees.\n+\n+## Testing examples:\n+\n+There are no testing examples for this challenge.\n+\n+Click on the green flag to see the expected output of your program.\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/calculate-inside-angles-of-regular-polygons/scratch-expected.md", "diff": "+Click on the green flag to see the expected output of your program.\n+\n+{iframe link=\"https://scratch.mit.edu/projects/embed/152496450/?autostart=false\"}\n+\n+{panel type=\"help\" title=\"Recommended blocks\"}\n+\n+```scratch:split:random\n+when green flag clicked\n+```\n+\n+```scratch:split:random\n+clear\n+\n+pen down\n+\n+pen up\n+```\n+\n+```scratch:split:random\n+set [sides v] to (answer)\n+\n+set [turning angle v] to ((360) / (sides))\n+\n+set [inside angle v] to ((180) - (turning angle))\n+```\n+\n+```scratch:split:random\n+go to x: (0) y: (0)\n+\n+point in direction (90 v)\n+\n+move (50) steps\n+\n+turn cw (turning angle) degrees\n+```\n+\n+```scratch:split:random\n+say (join (join [Each inside angle is ] (inside angle)) [ degrees.])\n+```\n+\n+```scratch:split:random\n+ask [Enter the number of sides of a regular polygon:] and wait\n+```\n+\n+```scratch:split:random\n+wait (1) secs\n+\n+repeat (sides)\n+end\n+```\n+\n+{panel end}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/calculate-inside-angles-of-regular-polygons/scratch-hints.md", "diff": "+ - A regular polygon has all angles equal and all sides equal.\n+ - The turning angle or external angle for a regular polygon can be calculated by dividing 360 by the number of sides of the polygon. Note that the turning angle at each vertex of the polygon is different from the inside or the interior angle (i.e. the turning angle and the inside angle of each vertex of the polygon add up to 180 degrees).\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/calculate-inside-angles-of-regular-polygons/scratch-solution.md", "diff": "+```scratch\n+when green flag clicked\n+clear\n+go to x: (0) y: (0)\n+point in direction (90 v)\n+ask [Enter the number of sides of a regular polygon:] and wait\n+set [sides v] to (answer)\n+set [turning angle v] to ((360) / (sides))\n+set [inside angle v] to ((180) - (turning angle))\n+pen down\n+repeat (sides)\n+ move (50) steps\n+ turn cw (turning angle) degrees\n+ wait (1) secs\n+end\n+pen up\n+say (join (join [Each inside angle is ] (inside angle)) [ degrees.])\n+```\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-regular-polygons/draw-regular-polygons.md", "diff": "+# Draw a regular polygon\n+\n+## Requirement:\n+\n+Write a program that draws any regular polygon with the number of sides entered by the user as the input and the length of each sides equal to 50 steps.\n+\n+## Testing examples:\n+\n+There are no testing examples for this challenge.\n+\n+Click on the green flag to see the expected output of your program.\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-regular-polygons/extra-challenge.md", "diff": "+**Extra challenge #1:** Write a program that takes the length of a side of a polygon as the input, draws the polygon with the given side and displays its perimeter as the output.\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-regular-polygons/scratch-expected.md", "diff": "+Click on the green flag to see the expected output of your program.\n+\n+{iframe link=\"https://scratch.mit.edu/projects/embed/152496450/?autostart=false\"}\n+\n+{panel type=\"help\" title=\"Recommended blocks\"}\n+\n+```scratch:split:random\n+when green flag clicked\n+```\n+\n+```scratch:split:random\n+clear\n+\n+pen down\n+\n+pen up\n+```\n+\n+```scratch:split:random\n+set [sides v] to (answer)\n+```\n+\n+```scratch:split:random\n+go to x: (0) y: (0)\n+\n+move (50) steps\n+\n+turn cw ((360) / (sides)) degrees\n+```\n+\n+```scratch:split:random\n+say [I'll draw a polygon with the number of sides you give me.] for (3) secs\n+```\n+\n+```scratch:split:random\n+ask [Enter the number of sides:] and wait\n+```\n+\n+```scratch:split:random\n+wait (1) secs\n+\n+repeat (sides)\n+end\n+```\n+\n+{panel end}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-regular-polygons/scratch-hints.md", "diff": "+ - A regular polygon has all angles equal and all sides equal.\n+ - The turning angle or external angle for a regular polygon can be calculated by dividing 360 by the number of sides of the polygon. Note that the turning angle at each vertex of the polygon is different from the inside or the interior angle (i.e. the turning angle and the inside angle of each vertex of the polygon add up to 180 degrees).\n+ - Block `scratch:wait () secs` waits specified number of seconds, then continues with next block. To be able to see each sides of the polygon being drawn, use the **wait** block after turning each angle.\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-regular-polygons/scratch-solution.md", "diff": "+```scratch\n+when green flag clicked\n+clear\n+go to x: (0) y: (0)\n+say [I'll draw a polygon with the number of sides you give me.] for (3) secs\n+ask [Enter the number of sides:] and wait\n+set [sides v] to (answer)\n+pen down\n+repeat (sides)\n+ move (50) steps\n+ turn cw ((360) / (sides)) degrees\n+end\n+pen up\n+```\n" } ]
Python
MIT License
uccser/cs-unplugged
Regular polygon programming exercises.
701,852
20.06.2017 14:04:29
-43,200
a643d76d86d65d648eff55866eaa5c918f5a3b0d
Angle porgramming challenges.
[ { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-different-types-of-angles/scratch-expected.md", "diff": "+Click on the green flag to see the expected output of your program.\n+\n+{iframe link=\"https://scratch.mit.edu/projects/embed/152883319/?autostart=false\"}\n+\n+{panel type=\"help\" title=\"Recommended blocks\"}\n+\n+```scratch:split:random\n+when green flag clicked\n+```\n+\n+```scratch:split:random\n+clear\n+\n+set pen size to (3)\n+\n+pen down\n+\n+pen up\n+```\n+\n+```scratch:split:random\n+set [angle v] to (answer)\n+```\n+\n+```scratch:split:random\n+go to x: (0) y: (0)\n+\n+point in direction (90 v)\n+\n+move (100) steps\n+\n+turn ccw ((180) - (angle)) degrees\n+```\n+\n+```scratch:split:random\n+say [The angle you entered is an acute angle.] for (3) secs\n+\n+say [The angle you entered is a right angle.] for (3) secs\n+\n+say [The angle you entered is an obtuse angle.] for (3) secs\n+\n+say [The angle you entered is a straight angle.] for (3) secs\n+\n+say [The angle you entered is a reflex angle.] for (3) secs\n+```\n+\n+```scratch:split:random\n+ask [Enter an angle between 0 and 360 (not including 0 and 360):] and wait\n+```\n+\n+```scratch:split:random\n+if <(angle) < [180]> then\n+else\n+end\n+\n+if <(angle) < [90]> then\n+else\n+end\n+\n+if <(angle) = [90]> then\n+else\n+end\n+\n+if <(angle) = [180]> then\n+else\n+end\n+```\n+\n+{panel end}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-different-types-of-angles/scratch-hints.md", "diff": "+Description of different angles:\n+\n+ - An acute angle is an angle between 0 and 90 degrees (not including 90).\n+ - A right angle is a 90 degrees angle.\n+ - Obtuse angle is an angle between 90 and 180 degree (not including 90 and 180).\n+ - A straight angle is a 180 degrees angle.\n+ - A reflex angle is an angle greater than 180 degrees.\n+\n+There are different ways to program checking the range using the **if()/else** blocks. Below are hints for two different ways you may program this:\n+\n+ - Use a series of **if()** blocks sequentially checking for the ranges in each if() block. If you need to check a range between two values you can use the `<> and <>` operator in the condition for your if() block (the AND operator reports true if both conditions are true).\n+\n+ - Use nested **if()** or **if()/else** blocks, which are **if()/else** blocks inside another set of **if()/else** blocks (i.e. a nested conditional statement is a conditional statement where the **if()** and/or **else** contains another conditional statement). For example:\n+\n+ ```scratch\n+ if <[angle] < [180]> then\n+ if <[angle] < [90]> then\n+ acute angle\n+ else\n+ if <[angle] = [90]> then\n+ right angle\n+ else\n+ obtuse angle\n+ end\n+ end\n+ else\n+ if <[angle] = [180]> then\n+ straight angle\n+ else\n+ reflex angle\n+ end\n+ end\n+ ```\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-different-types-of-angles/scratch-solution.md", "diff": "+**Solution #1:**\n+```scratch\n+when green flag clicked\n+clear\n+set pen size to (3)\n+go to x: (0) y: (0)\n+point in direction (90 v)\n+ask [Enter an angle between 0 and 360 (not including 0 and 360):] and wait\n+set [angle v] to (answer)\n+if <<(angle) > [0]> and <(angle) < [90]>> then\n+ say [The angle you entered is an acute angle.] for (3) secs\n+end\n+if <(angle) = [90]> then\n+ say [The angle you entered is a right angle.] for (3) secs\n+end\n+if <<(angle) > [90]> and <(angle) < [180]>> then\n+ say [The angle you entered is an obtuse angle.] for (3) secs\n+end\n+if <(angle) = [180]> then\n+ say [The angle you entered is a straight angle.] for (3) secs\n+end\n+if <(angle) > [180]> then\n+ say [The angle you entered is a reflex angle.] for (3) secs\n+end\n+pen down\n+move (100) steps\n+turn ccw ((180) - (angle)) degrees\n+move (100) steps\n+pen up\n+```\n+\n+**Solution #2:**\n+```scratch\n+when green flag clicked\n+clear\n+set pen size to (3)\n+go to x: (0) y: (0)\n+point in direction (90 v)\n+ask [Enter an angle between 0 and 360 (not including 0 and 360):] and wait\n+set [angle v] to (answer)\n+if <(angle) < [180]> then\n+ if <(angle) < [90]> then\n+ say [The angle you entered is an acute angle.] for (3) secs\n+ else\n+ if <(angle) = [90]> then\n+ say [The angle you entered is a right angle.] for (3) secs\n+ else\n+ say [The angle you entered is an obtuse angle.] for (3) secs\n+ end\n+ end\n+else\n+ if <(angle) = [180]> then\n+ say [The angle you entered is a straight angle.] for (3) secs\n+ else\n+ say [The angle you entered is a reflex angle.] for (3) secs\n+ end\n+end\n+pen down\n+move (100) steps\n+turn ccw ((180) - (angle)) degrees\n+move (100) steps\n+pen up\n+```\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-different-types-of-triangles/extra-challenge.md", "diff": "+**Extra challenge #1:** Edit your program so it would display a message if the angle entered by the user is not between 0 and 180 (i.e. less than or equal to 0 or greater than or equal to 180).\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-different-types-of-triangles/scratch-expected.md", "diff": "+Click on the green flag to see the expected output of your program.\n+\n+{iframe link=\"https://scratch.mit.edu/projects/embed/152883486/?autostart=false\"}\n+\n+{panel type=\"help\" title=\"Recommended blocks\"}\n+\n+```scratch:split:random\n+when green flag clicked\n+```\n+\n+```scratch:split:random\n+clear\n+\n+set pen size to (3)\n+\n+pen down\n+\n+pen up\n+```\n+\n+```scratch:split:random\n+set [angle v] to (answer)\n+```\n+\n+```scratch:split:random\n+go to x: (0) y: (0)\n+\n+point in direction (90 v)\n+\n+move (100) steps\n+\n+turn ccw ((180) - (angle)) degrees\n+```\n+\n+```scratch:split:random\n+say [This is an acute triangle.] for (2) secs\n+\n+say [This is a right triangle.] for (2) secs\n+\n+say [This is an obtuse triangle.] for (2) secs\n+```\n+\n+```scratch:split:random\n+ask [Enter an angle between 0 and 360 (not including 0 and 360):] and wait\n+```\n+\n+```scratch:split:random\n+if <(angle) < [90]> then\n+end\n+\n+if <(angle) = [90]> then\n+end\n+\n+if <(angle) > [90]> then\n+end\n+```\n+\n+{panel end}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-different-types-of-triangles/scratch-hints.md", "diff": "+ - A triangle with two sides equal is called an isosceles triangle.\n+ - In this challenge, the third side of the triangle can be drawn by connecting the third vertex (location of the sprite after drawing the angle in challenge 6.1) to the first vertex (x:0 y:0).\n+ - An acute triangle is a triangle which all angles are less than 90 degrees.\n+ - A right triangle is a triangle which has a right angle (90 degrees).\n+ - An obtuse triangle: has an angle more than 90 degrees.\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-different-types-of-triangles/scratch-solution.md", "diff": "+```scratch\n+when green flag clicked\n+clear\n+set pen size to (3)\n+go to x: (0) y: (0)\n+point in direction (90 v)\n+ask [Enter an angle between 0 and 180 (not including 0 and 180):] and wait\n+set [angle v] to (answer)\n+pen down\n+move (100) steps\n+turn ccw ((180) - (angle)) degrees\n+move (100) steps\n+go to x: (0) y: (0)\n+pen up\n+if <(angle) < [90]> then\n+ say [This is an acute triangle.] for (2) secs\n+end\n+if <(angle) = [90]> then\n+ say [This is a right triangle.] for (2) secs\n+end\n+if <(angle) > [90]> then\n+ say [This is an obtuse triangle.] for (2) secs\n+end\n+```\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/programming-challenges.yaml", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/programming-challenges.yaml", "diff": "@@ -182,6 +182,7 @@ draw-different-types-of-triangles:\n- programming-identify-if-statement\n- programming-describe-variables\n- programming-describe-mathematical-operations\n+ extra-challenge: extra-challenge.md\ndraw-5-pointed-star:\nchallenge-set-number: 7\n" } ]
Python
MIT License
uccser/cs-unplugged
Angle porgramming challenges.
701,852
20.06.2017 17:34:22
-43,200
966d9fcef20a77edb91ae77a617d4ef40f99b4b6
Url fixes and other minor changes.
[ { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/catch-the-mouse-random/scratch-expected.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/catch-the-mouse-random/scratch-expected.md", "diff": "{panel type=\"help\" title=\"Recommended blocks\"}\n```scratch:split:random\n-when I recieve [go v]\n+when I receive [go v]\nmove_forward()\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/catch-the-mouse/scratch-expected.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/catch-the-mouse/scratch-expected.md", "diff": "{panel type=\"help\" title=\"Recommended blocks\"}\n```scratch:split:random\n-when I recieve [go v]\n+when I receive [go v]\nmove_forward()\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/catch-the-mouse/scratch-solution.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/catch-the-mouse/scratch-solution.md", "diff": "**Backdrop 1**:\n```scratch\n-when I recieve [go v]\n+when I receive [go v]\nmove_forward(3)\nturn_left\nmove_forward(8)\n@@ -12,7 +12,7 @@ move_forward(2)\n**Backdrop 2**:\n```scratch\n-when I recieve [go v]\n+when I receive [go v]\nmove_forward(4)\nturn_left\nmove_forward(7)\n@@ -25,7 +25,7 @@ move_forward(1)\n**Backdrop 3**:\n```scratch\n-when I recieve [go v]\n+when I receive [go v]\nturn_left\nmove_forward(6)\nturn_right\n@@ -39,7 +39,7 @@ move_forward(2)\n**Backdrop 4**:\n```scratch\n-when I recieve [go v]\n+when I receive [go v]\nmove_forward(2)\nturn_left\nmove_forward(8)\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/design-bee-bot/scratch-expected.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/design-bee-bot/scratch-expected.md", "diff": "-Click on the green flag, and used the buttons to see the expected output of your program.\n+Click on the green flag, and use the buttons to see the expected output of your program.\n{iframe link=\"https://scratch.mit.edu/projects/embed/158364683/?autostart=false\"}\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/design-bee-bot/scratch-hints.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/design-bee-bot/scratch-hints.md", "diff": "-Remix the program provided at https://scratch.mit.edu/projects/159722851/ and change its name to: **KidBots challenge 1.1 Design a Bee-Bot.**\n+Remix the program provided at [https://scratch.mit.edu/projects/159722851/](https://scratch.mit.edu/projects/159722851/) and change its name to: **KidBots challenge 1.1 Design a Bee-Bot.**\nWhen the green flag is clicked your program should do the following:\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modify-bee-bot/scratch-expected.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modify-bee-bot/scratch-expected.md", "diff": "-Click on the green flag, and used the buttons to see the expected output of your program.\n+Click on the green flag, and use the buttons to see the expected output of your program.\n{iframe link=\"https://scratch.mit.edu/projects/embed/164789645/?autostart=false\"}\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/program-bee-bot/program-bee-bot.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/program-bee-bot/program-bee-bot.md", "diff": "## Requirement:\n-Program your Bee-Bot (remix the program provided at https://scratch.mit.edu/projects/158364683/) by giving instructions to the cat so the cat catches the mouse.\n+Program your Bee-Bot (remix the program provided at [https://scratch.mit.edu/projects/158364683/](https://scratch.mit.edu/projects/158364683/)) by giving instructions to the cat so the cat catches the mouse.\nPressing the four commands stores them in a list called \"source code\", and pressing the GO button will activate a script that goes through the list of commands and moves the cat according to each command.\n" } ]
Python
MIT License
uccser/cs-unplugged
Url fixes and other minor changes.
701,852
21.06.2017 14:40:57
-43,200
82226d4ce7d0e5c124651dac9f5da94879137c71
PR fixes and test.
[ { "change_type": "RENAME", "old_path": "csunplugged/tests/topics/loaders/assets/programming_challenges/basic-config.yaml", "new_path": "csunplugged/tests/topics/loaders/assets/programming_challenges/basic-config-1.yaml", "diff": "" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/tests/topics/loaders/assets/programming_challenges/basic-config-2.yaml", "diff": "+programming-challenge-2:\n+ challenge-set-number: 1\n+ challenge-number: 2\n+ difficulty-level: 1\n+ programming-languages:\n+ - language-1\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/tests/topics/loaders/assets/programming_challenges/programming-challenge-2/language-1-expected.md", "diff": "+{panel type=\"general\" title=\"Note\"}\n+Etiam in massa. Nam ut metus. In rhoncus venenatis tellus. Etiam aliquam. Ut\n+aliquam lectus ut lectus. Nam turpis lacus, tristique sit amet, convallis\n+sollicitudin, commodo a, purus. Nulla vitae eros a diam blandit mollis. Proin\n+luctus feugiat eros. Pellentesque habitant morbi tristique senectus et netus et\n+malesuada fames ac turpis egestas. Duis ultricies urna. Etiam enim urna,\n+pharetra suscipit, varius et, congue quis, odio. Donec lobortis, elit bibendum\n+euismod faucibus, velit nibh egestas libero, vitae pellentesque elit augue ut\n+massa.\n+{panel end}\n+\n+Nulla consequat erat at massa. Vivamus id mi. Morbi purus enim, dapibus a,\n+facilisis non, tincidunt at, enim. Vestibulum ante ipsum primis in faucibus\n+orci luctus et ultrices posuere cubilia Curae; Duis imperdiet eleifend arcu.\n+Cras magna ligula, consequat at, tempor non, posuere nec, libero. Vestibulum\n+vel ipsum. Praesent congue justo et nunc. Vestibulum nec felis vitae nisl\n+pharetra sollicitudin. Quisque nec arcu vel tellus tristique vestibulum. Aenean\n+vel lacus. Mauris dolor erat, commodo ut, dapibus vehicula, lobortis sit amet,\n+orci. Aliquam augue. In semper nisi nec libero. Cras magna ipsum, scelerisque\n+et, tempor eget, gravida nec, lacus. Fusce eros nisi, ullamcorper blandit,\n+ultricies eget, elementum eget, pede. Phasellus id risus vitae nisl ullamcorper\n+congue. Proin est.\n+\n+Sed eleifend odio sed leo. Mauris tortor turpis, dignissim vel, ornare ac,\n+ultricies quis, magna. Phasellus lacinia, augue ac dictum tempor, nisi felis\n+ornare magna, eu vehicula tellus enim eu neque. Fusce est eros, sagittis eget,\n+interdum a, ornare suscipit, massa. Sed vehicula elementum ligula. Aliquam erat\n+volutpat. Donec odio. Quisque nunc. Integer cursus feugiat magna. Fusce ac elit\n+ut elit aliquam suscipit. Duis leo est, interdum nec, varius in, facilisis\n+vitae, odio. Phasellus eget leo at urna adipiscing vulputate. Nam eu erat vel\n+arcu tristique mattis. Nullam placerat lorem non augue. Cras et velit. Morbi\n+sapien nulla, volutpat a, tristique eu, molestie ac, felis.\n+\n+Suspendisse sit amet tellus non odio porta pellentesque. Nulla facilisi.\n+Integer iaculis condimentum augue. Nullam urna nulla, vestibulum quis, lacinia\n+eget, ullamcorper eu, dui. Quisque dignissim consequat nisl. Pellentesque porta\n+augue in diam. Duis mattis. Aliquam et mi quis turpis pellentesque consequat.\n+Suspendisse nulla erat, lacinia nec, pretium vitae, feugiat ac, quam. Etiam sed\n+tellus vel est ultrices condimentum. Vestibulum euismod. Vivamus blandit.\n+Pellentesque eu urna. Vestibulum consequat sem vitae dui. In dictum feugiat\n+quam. Phasellus placerat. In sem nisl, elementum vitae, venenatis nec, lacinia\n+ac, arcu. Pellentesque gravida egestas mi. Integer rutrum tincidunt libero.\n+\n+Duis viverra. Nulla diam lectus, tincidunt et, scelerisque vitae, aliquam\n+vitae, justo. Quisque eget erat. Donec aliquet porta magna. Sed nisl. Ut\n+tellus. Suspendisse quis mi eget dolor sagittis tristique. Aenean non pede eget\n+nisl bibendum gravida. Class aptent taciti sociosqu ad litora torquent per\n+conubia nostra, per inceptos himenaeos. Morbi laoreet. Suspendisse potenti.\n+Donec accumsan porta felis.\n+\n+Fusce tristique leo quis pede. Cras nibh. Sed eget est vitae tortor mollis\n+ullamcorper. Suspendisse placerat dolor a dui. Vestibulum condimentum dui et\n+elit. Pellentesque porttitor ipsum at ipsum. Nam massa. Duis lorem. Donec\n+porta. Proin ligula. Aenean nunc massa, dapibus quis, imperdiet id, commodo a,\n+lacus. Cras sit amet.\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/tests/topics/loaders/assets/programming_challenges/programming-challenge-2/language-1-hints.md", "diff": "+Etiam in massa. Nam ut metus. In rhoncus venenatis tellus. Etiam aliquam. Ut\n+aliquam lectus ut lectus. Nam turpis lacus, tristique sit amet, convallis\n+sollicitudin, commodo a, purus. Nulla vitae eros a diam blandit mollis. Proin\n+luctus feugiat eros. Pellentesque habitant morbi tristique senectus et netus et\n+malesuada fames ac turpis egestas. Duis ultricies urna. Etiam enim urna,\n+pharetra suscipit, varius et, congue quis, odio. Donec lobortis, elit bibendum\n+euismod faucibus, velit nibh egestas libero, vitae pellentesque elit augue ut\n+massa.\n+\n+Nulla consequat erat at massa. Vivamus id mi. Morbi purus enim, dapibus a,\n+facilisis non, tincidunt at, enim. Vestibulum ante ipsum primis in faucibus\n+orci luctus et ultrices posuere cubilia Curae; Duis imperdiet eleifend arcu.\n+Cras magna ligula, consequat at, tempor non, posuere nec, libero. Vestibulum\n+vel ipsum. Praesent congue justo et nunc. Vestibulum nec felis vitae nisl\n+pharetra sollicitudin. Quisque nec arcu vel tellus tristique vestibulum. Aenean\n+vel lacus. Mauris dolor erat, commodo ut, dapibus vehicula, lobortis sit amet,\n+orci. Aliquam augue. In semper nisi nec libero. Cras magna ipsum, scelerisque\n+et, tempor eget, gravida nec, lacus. Fusce eros nisi, ullamcorper blandit,\n+ultricies eget, elementum eget, pede. Phasellus id risus vitae nisl ullamcorper\n+congue. Proin est.\n+\n+Sed eleifend odio sed leo. Mauris tortor turpis, dignissim vel, ornare ac,\n+ultricies quis, magna. Phasellus lacinia, augue ac dictum tempor, nisi felis\n+ornare magna, eu vehicula tellus enim eu neque. Fusce est eros, sagittis eget,\n+interdum a, ornare suscipit, massa. Sed vehicula elementum ligula. Aliquam erat\n+volutpat. Donec odio. Quisque nunc. Integer cursus feugiat magna. Fusce ac elit\n+ut elit aliquam suscipit. Duis leo est, interdum nec, varius in, facilisis\n+vitae, odio. Phasellus eget leo at urna adipiscing vulputate. Nam eu erat vel\n+arcu tristique mattis. Nullam placerat lorem non augue. Cras et velit. Morbi\n+sapien nulla, volutpat a, tristique eu, molestie ac, felis.\n+\n+Suspendisse sit amet tellus non odio porta pellentesque. Nulla facilisi.\n+Integer iaculis condimentum augue. Nullam urna nulla, vestibulum quis, lacinia\n+eget, ullamcorper eu, dui. Quisque dignissim consequat nisl. Pellentesque porta\n+augue in diam. Duis mattis. Aliquam et mi quis turpis pellentesque consequat.\n+Suspendisse nulla erat, lacinia nec, pretium vitae, feugiat ac, quam. Etiam sed\n+tellus vel est ultrices condimentum. Vestibulum euismod. Vivamus blandit.\n+Pellentesque eu urna. Vestibulum consequat sem vitae dui. In dictum feugiat\n+quam. Phasellus placerat. In sem nisl, elementum vitae, venenatis nec, lacinia\n+ac, arcu. Pellentesque gravida egestas mi. Integer rutrum tincidunt libero.\n+\n+Duis viverra. Nulla diam lectus, tincidunt et, scelerisque vitae, aliquam\n+vitae, justo. Quisque eget erat. Donec aliquet porta magna. Sed nisl. Ut\n+tellus. Suspendisse quis mi eget dolor sagittis tristique. Aenean non pede eget\n+nisl bibendum gravida. Class aptent taciti sociosqu ad litora torquent per\n+conubia nostra, per inceptos himenaeos. Morbi laoreet. Suspendisse potenti.\n+Donec accumsan porta felis.\n+\n+Fusce tristique leo quis pede. Cras nibh. Sed eget est vitae tortor mollis\n+ullamcorper. Suspendisse placerat dolor a dui. Vestibulum condimentum dui et\n+elit. Pellentesque porttitor ipsum at ipsum. Nam massa. Duis lorem. Donec\n+porta. Proin ligula. Aenean nunc massa, dapibus quis, imperdiet id, commodo a,\n+lacus. Cras sit amet.\n+\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/tests/topics/loaders/assets/programming_challenges/programming-challenge-2/language-1-solution.md", "diff": "+Etiam in massa. Nam ut metus. In rhoncus venenatis tellus. Etiam aliquam. Ut\n+aliquam lectus ut lectus. Nam turpis lacus, tristique sit amet, convallis\n+sollicitudin, commodo a, purus. Nulla vitae eros a diam blandit mollis. Proin\n+luctus feugiat eros. Pellentesque habitant morbi tristique senectus et netus et\n+malesuada fames ac turpis egestas. Duis ultricies urna. Etiam enim urna,\n+pharetra suscipit, varius et, congue quis, odio. Donec lobortis, elit bibendum\n+euismod faucibus, velit nibh egestas libero, vitae pellentesque elit augue ut\n+massa.\n+\n+Nulla consequat erat at massa. Vivamus id mi. Morbi purus enim, dapibus a,\n+facilisis non, tincidunt at, enim. Vestibulum ante ipsum primis in faucibus\n+orci luctus et ultrices posuere cubilia Curae; Duis imperdiet eleifend arcu.\n+Cras magna ligula, consequat at, tempor non, posuere nec, libero. Vestibulum\n+vel ipsum. Praesent congue justo et nunc. Vestibulum nec felis vitae nisl\n+pharetra sollicitudin. Quisque nec arcu vel tellus tristique vestibulum. Aenean\n+vel lacus. Mauris dolor erat, commodo ut, dapibus vehicula, lobortis sit amet,\n+orci. Aliquam augue. In semper nisi nec libero. Cras magna ipsum, scelerisque\n+et, tempor eget, gravida nec, lacus. Fusce eros nisi, ullamcorper blandit,\n+ultricies eget, elementum eget, pede. Phasellus id risus vitae nisl ullamcorper\n+congue. Proin est.\n+\n+Sed eleifend odio sed leo. Mauris tortor turpis, dignissim vel, ornare ac,\n+ultricies quis, magna. Phasellus lacinia, augue ac dictum tempor, nisi felis\n+ornare magna, eu vehicula tellus enim eu neque. Fusce est eros, sagittis eget,\n+interdum a, ornare suscipit, massa. Sed vehicula elementum ligula. Aliquam erat\n+volutpat. Donec odio. Quisque nunc. Integer cursus feugiat magna. Fusce ac elit\n+ut elit aliquam suscipit. Duis leo est, interdum nec, varius in, facilisis\n+vitae, odio. Phasellus eget leo at urna adipiscing vulputate. Nam eu erat vel\n+arcu tristique mattis. Nullam placerat lorem non augue. Cras et velit. Morbi\n+sapien nulla, volutpat a, tristique eu, molestie ac, felis.\n+\n+Suspendisse sit amet tellus non odio porta pellentesque. Nulla facilisi.\n+Integer iaculis condimentum augue. Nullam urna nulla, vestibulum quis, lacinia\n+eget, ullamcorper eu, dui. Quisque dignissim consequat nisl. Pellentesque porta\n+augue in diam. Duis mattis. Aliquam et mi quis turpis pellentesque consequat.\n+Suspendisse nulla erat, lacinia nec, pretium vitae, feugiat ac, quam. Etiam sed\n+tellus vel est ultrices condimentum. Vestibulum euismod. Vivamus blandit.\n+Pellentesque eu urna. Vestibulum consequat sem vitae dui. In dictum feugiat\n+quam. Phasellus placerat. In sem nisl, elementum vitae, venenatis nec, lacinia\n+ac, arcu. Pellentesque gravida egestas mi. Integer rutrum tincidunt libero.\n+\n+Duis viverra. Nulla diam lectus, tincidunt et, scelerisque vitae, aliquam\n+vitae, justo. Quisque eget erat. Donec aliquet porta magna. Sed nisl. Ut\n+tellus. Suspendisse quis mi eget dolor sagittis tristique. Aenean non pede eget\n+nisl bibendum gravida. Class aptent taciti sociosqu ad litora torquent per\n+conubia nostra, per inceptos himenaeos. Morbi laoreet. Suspendisse potenti.\n+Donec accumsan porta felis.\n+\n+Fusce tristique leo quis pede. Cras nibh. Sed eget est vitae tortor mollis\n+ullamcorper. Suspendisse placerat dolor a dui. Vestibulum condimentum dui et\n+elit. Pellentesque porttitor ipsum at ipsum. Nam massa. Duis lorem. Donec\n+porta. Proin ligula. Aenean nunc massa, dapibus quis, imperdiet id, commodo a,\n+lacus. Cras sit amet.\n+\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/tests/topics/loaders/assets/programming_challenges/programming-challenge-2/programming-challenge-2.md", "diff": "+# Programming Challenge 2\n+\n+Etiam in massa. Nam ut metus. In rhoncus venenatis tellus. Etiam aliquam. Ut\n+aliquam lectus ut lectus. Nam turpis lacus, tristique sit amet, convallis\n+sollicitudin, commodo a, purus. Nulla vitae eros a diam blandit mollis. Proin\n+luctus feugiat eros. Pellentesque habitant morbi tristique senectus et netus et\n+malesuada fames ac turpis egestas. Duis ultricies urna. Etiam enim urna,\n+pharetra suscipit, varius et, congue quis, odio. Donec lobortis, elit bibendum\n+euismod faucibus, velit nibh egestas libero, vitae pellentesque elit augue ut\n+massa.\n+\n+Nulla consequat erat at massa. Vivamus id mi. Morbi purus enim, dapibus a,\n+facilisis non, tincidunt at, enim. Vestibulum ante ipsum primis in faucibus\n+orci luctus et ultrices posuere cubilia Curae; Duis imperdiet eleifend arcu.\n+Cras magna ligula, consequat at, tempor non, posuere nec, libero. Vestibulum\n+vel ipsum. Praesent congue justo et nunc. Vestibulum nec felis vitae nisl\n+pharetra sollicitudin. Quisque nec arcu vel tellus tristique vestibulum. Aenean\n+vel lacus. Mauris dolor erat, commodo ut, dapibus vehicula, lobortis sit amet,\n+orci. Aliquam augue. In semper nisi nec libero. Cras magna ipsum, scelerisque\n+et, tempor eget, gravida nec, lacus. Fusce eros nisi, ullamcorper blandit,\n+ultricies eget, elementum eget, pede. Phasellus id risus vitae nisl ullamcorper\n+congue. Proin est.\n+\n+Sed eleifend odio sed leo. Mauris tortor turpis, dignissim vel, ornare ac,\n+ultricies quis, magna. Phasellus lacinia, augue ac dictum tempor, nisi felis\n+ornare magna, eu vehicula tellus enim eu neque. Fusce est eros, sagittis eget,\n+interdum a, ornare suscipit, massa. Sed vehicula elementum ligula. Aliquam erat\n+volutpat. Donec odio. Quisque nunc. Integer cursus feugiat magna. Fusce ac elit\n+ut elit aliquam suscipit. Duis leo est, interdum nec, varius in, facilisis\n+vitae, odio. Phasellus eget leo at urna adipiscing vulputate. Nam eu erat vel\n+arcu tristique mattis. Nullam placerat lorem non augue. Cras et velit. Morbi\n+sapien nulla, volutpat a, tristique eu, molestie ac, felis.\n+\n+Suspendisse sit amet tellus non odio porta pellentesque. Nulla facilisi.\n+Integer iaculis condimentum augue. Nullam urna nulla, vestibulum quis, lacinia\n+eget, ullamcorper eu, dui. Quisque dignissim consequat nisl. Pellentesque porta\n+augue in diam. Duis mattis. Aliquam et mi quis turpis pellentesque consequat.\n+Suspendisse nulla erat, lacinia nec, pretium vitae, feugiat ac, quam. Etiam sed\n+tellus vel est ultrices condimentum. Vestibulum euismod. Vivamus blandit.\n+Pellentesque eu urna. Vestibulum consequat sem vitae dui. In dictum feugiat\n+quam. Phasellus placerat. In sem nisl, elementum vitae, venenatis nec, lacinia\n+ac, arcu. Pellentesque gravida egestas mi. Integer rutrum tincidunt libero.\n+\n+Duis viverra. Nulla diam lectus, tincidunt et, scelerisque vitae, aliquam\n+vitae, justo. Quisque eget erat. Donec aliquet porta magna. Sed nisl. Ut\n+tellus. Suspendisse quis mi eget dolor sagittis tristique. Aenean non pede eget\n+nisl bibendum gravida. Class aptent taciti sociosqu ad litora torquent per\n+conubia nostra, per inceptos himenaeos. Morbi laoreet. Suspendisse potenti.\n+Donec accumsan porta felis.\n+\n+Fusce tristique leo quis pede. Cras nibh. Sed eget est vitae tortor mollis\n+ullamcorper. Suspendisse placerat dolor a dui. Vestibulum condimentum dui et\n+elit. Pellentesque porttitor ipsum at ipsum. Nam massa. Duis lorem. Donec\n+porta. Proin ligula. Aenean nunc massa, dapibus quis, imperdiet id, commodo a,\n+lacus. Cras sit amet.\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/loaders/test_programming_challenges_loader.py", "new_path": "csunplugged/tests/topics/loaders/test_programming_challenges_loader.py", "diff": "@@ -6,6 +6,8 @@ from tests.topics.TopicsTestDataGenerator import TopicsTestDataGenerator\nfrom topics.models import ProgrammingChallenge\nfrom topics.management.commands._ProgrammingChallengesLoader import ProgrammingChallengesLoader\n+from utils.errors.MarkdownStyleError import MarkdownStyleError\n+\nclass ProgrammingChallengesLoaderTest(BaseTestWithDB):\n@@ -15,7 +17,7 @@ class ProgrammingChallengesLoaderTest(BaseTestWithDB):\nself.loader_name = \"programming_challenges\"\ndef test_basic_config(self):\n- config_file = os.path.join(self.loader_name, \"basic-config.yaml\")\n+ config_file = os.path.join(self.loader_name, \"basic-config-1.yaml\")\nself.test_data.create_difficulty_level(\"1\")\nself.test_data.create_programming_language(\"1\")\n@@ -30,3 +32,15 @@ class ProgrammingChallengesLoaderTest(BaseTestWithDB):\npe_objects,\n[\"<ProgrammingChallenge: Programming Challenge 1>\"]\n)\n+\n+ def test_markdown_with_style_error(self):\n+ config_file = os.path.join(self.loader_name, \"basic-config-2.yaml\")\n+\n+ self.test_data.create_difficulty_level(\"1\")\n+ self.test_data.create_programming_language(\"1\")\n+ topic = self.test_data.create_topic(\"1\")\n+\n+ pe_loader = ProgrammingChallengesLoader(config_file, topic, self.test_data.LOADER_ASSET_PATH)\n+\n+ with self.assertRaises(MarkdownStyleError):\n+ pe_loader.load()\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-circle-with-radius-100/draw-circle-with-radius-100.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-circle-with-radius-100/draw-circle-with-radius-100.md", "diff": "## Requirement:\n-Write a program that draws a circle, with the given centre point x:0, y:0, and its radius equal to 100 steps. You can use the same method as challenge 4.1 above i.e. draw a 360-sided polygon, but this time you will need to work out how long each side is based on the circumference of the circle, and you'll need to work out the circumference from the radius.\n+Write a program that draws a circle, with the given centre point x:0, y:0, and its radius equal to 100 steps. You can use the same method as the \"Draw a 360-sided polygon\" challenge, but this time you will need to work out how long each side is based on the circumference of the circle, and you'll need to work out the circumference from the radius.\n## Testing examples:\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/rotation-of-a-triangle/rotation-of-a-triangle.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/rotation-of-a-triangle/rotation-of-a-triangle.md", "diff": "Write a program that draws a triangle, starting from point x:0, y:0, with its each 3 sides equal to 100 steps. Your program must then draw triangles that are each rotated 15 degrees from the previous one, changing its colour every time it draws a new triangle.\n-\n## Testing examples:\nThere are no testing examples for this challenge.\n" } ]
Python
MIT License
uccser/cs-unplugged
PR fixes and test.
701,852
21.06.2017 15:42:38
-43,200
a02aa06fe578f935fd597e74a7a5a6ee97340b44
Update configuration for Numeracy programming challenges.
[ { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/learning-outcomes.yaml", "new_path": "csunplugged/topics/content/en/learning-outcomes.yaml", "diff": "@@ -226,6 +226,11 @@ programming-describe-variable-output:\ncurriculum-areas:\n- programming\n+programming-describe-function:\n+ text: Describe the reason why you wrote a function in your program.\n+ curriculum-areas:\n+ - programming\n+\nprogramming-identify-loop:\ntext: Identify how and when to use a loop to repeat a set of instructions.\ncurriculum-areas:\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/programming-challenges.yaml", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/programming-challenges.yaml", "diff": "@@ -32,3 +32,157 @@ catch-the-mouse-random:\ndifficulty-level: 2\nprogramming-languages:\n- scratch\n+\n+add-in-parts-1-digit-number:\n+ challenge-set-number: 1\n+ challenge-number: 1\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-join-concatenate\n+ - programming-describe-variables\n+ - programming-explain-asking-input-end-user\n+\n+add-in-parts-2-digit-number:\n+ challenge-set-number: 1\n+ challenge-number: 2\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-join-concatenate\n+ - programming-describe-variables\n+ - programming-explain-asking-input-end-user\n+\n+add-in-parts-quiz:\n+ challenge-set-number: 1\n+ challenge-number: 3\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-join-concatenate\n+ - programming-describe-variables\n+ - programming-explain-asking-input-end-user\n+\n+go-up-10-numbers:\n+ challenge-set-number: 2\n+ challenge-number: 1\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-join-concatenate\n+ - programming-describe-variables\n+ - programming-explain-asking-input-end-user\n+ - programming-identify-if-statement\n+ extra-challenge: extra-challenge.md\n+\n+go-up-1-10-100-numbers:\n+ challenge-set-number: 2\n+ challenge-number: 2\n+ difficulty-level: 3\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-join-concatenate\n+ - programming-describe-variables\n+ - programming-explain-asking-input-end-user\n+ - programming-identify-if-statement\n+\n+calculate-exponents:\n+ challenge-set-number: 3\n+ challenge-number: 1\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-join-concatenate\n+ - programming-describe-variables\n+ - programming-explain-asking-input-end-user\n+ - programming-identify-if-statement\n+\n+check-if-divisor:\n+ challenge-set-number: 4\n+ challenge-number: 1\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-join-concatenate\n+ - programming-describe-variables\n+ - programming-explain-asking-input-end-user\n+ - programming-identify-if-statement\n+\n+check-if-divisor-series:\n+ challenge-set-number: 4\n+ challenge-number: 2\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-join-concatenate\n+ - programming-describe-variables\n+ - programming-explain-asking-input-end-user\n+ - programming-identify-if-statement\n+\n+find-factors:\n+ challenge-set-number: 4\n+ challenge-number: 3\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-join-concatenate\n+ - programming-describe-variables\n+ - programming-explain-asking-input-end-user\n+ - programming-identify-if-statement\n+\n+check-prime:\n+ challenge-set-number: 4\n+ challenge-number: 4\n+ difficulty-level: 3\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-join-concatenate\n+ - programming-describe-variables\n+ - programming-explain-asking-input-end-user\n+ - programming-identify-loop\n+\n+generate-primes:\n+ challenge-set-number: 4\n+ challenge-number: 5\n+ difficulty-level: 3\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-join-concatenate\n+ - programming-describe-variables\n+ - programming-explain-asking-input-end-user\n+ - programming-identify-loop\n+ - programming-identify-if-statement\n+\n+find-prime-factors:\n+ challenge-set-number: 5\n+ challenge-number: 1\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-mod\n+ - programming-describe-function\n+ - programming-outline-variable-updates\n+\n+flip-coins:\n+ challenge-set-number: 4\n+ challenge-number: 6\n+ difficulty-level: 3\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-join-concatenate\n+ - programming-describe-variables\n+ - programming-explain-asking-input-end-user\n+ - programming-identify-if-statement\n" } ]
Python
MIT License
uccser/cs-unplugged
Update configuration for Numeracy programming challenges.
701,852
21.06.2017 16:37:27
-43,200
e273cbb5652e684e2714f0ce3e5b8aace5f11153
Numeracy go-up programming challenges.
[ { "change_type": "ADD", "old_path": "csunplugged/static/img/topics/programming-challenges/numeracy-go-up-list.png", "new_path": "csunplugged/static/img/topics/programming-challenges/numeracy-go-up-list.png", "diff": "Binary files /dev/null and b/csunplugged/static/img/topics/programming-challenges/numeracy-go-up-list.png differ\n" }, { "change_type": "DELETE", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/go-up-1-10-100-numbers/add-in-parts-1-digit-number.md", "new_path": null, "diff": "-# Title\n-\n-## Requirement:\n-\n-## Testing examples:\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/go-up-1-10-100-numbers/scratch-expected.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/go-up-1-10-100-numbers/scratch-expected.md", "diff": "Click on the green flag to see the expected output of your program.\n-{iframe link=\"https://scratch.mit.edu/projects/embed/?????/?autostart=false\"}\n+{iframe link=\"https://scratch.mit.edu/projects/embed/149428180/?autostart=false\"}\n{panel type=\"help\" title=\"Recommended blocks\"}\n```scratch:split:random\n+when green flag clicked\n+```\n+\n+```scratch:split:random\n+set [upper range v] to (answer)\n+\n+set [number v] to (pick random (1) to (upper range))\n+\n+set [numbers after v] to (item (random v) of [numbers after list v] :: list)\n+```\n+\n+```scratch:split:random\n+ask [Enter a number as the upper range:] and wait\n+\n+ask (join (join [What is the number after ] (number)) [?]) and wait\n+\n+ask (join (join (join (join [What's ] (numbers after)) [ numbers after ]) (number)) [?]) and wait\n+```\n+\n+```scratch:split:random\n+say [Well done!] for (3) secs\n+\n+say (join [Nice try! The right answer is: ] ((number) + (numbers after))) for (3) secs\n+```\n+\n+```scratch:split:random\n+forever\n+end\n+\n+if <(numbers after) = [1]> then\n+else\n+end\n+if <(answer) = ((number) + (numbers after))> then\n+else\n+end\n```\n{panel end}\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/go-up-1-10-100-numbers/scratch-hints.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/go-up-1-10-100-numbers/scratch-hints.md", "diff": "+- Make a list of length 3 containing numbers 1, 10 and 100.\n+ {image-inline file-path=\"img/topics/programming-challenges/numeracy-go-up-list.png\n+\"}\n+\n+- To choose an item randomly from the list use the block: `scratch:item (random v) of [list v]`\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/go-up-1-10-100-numbers/scratch-solution.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/go-up-1-10-100-numbers/scratch-solution.md", "diff": "```scratch\n-\n+when green flag clicked\n+say [I'll generate a random number between 1 and a number you enter.] for (5) secs\n+ask [Enter a number as the upper range:] and wait\n+set [upper range v] to (answer)\n+forever\n+ set [number v] to (pick random (1) to (upper range))\n+ set [numbers after v] to (item (random v) of [numbers after list v] :: list)\n+ if <(numbers after) = [1]> then\n+ ask (join (join [What is the number after ] (number)) [?]) and wait\n+ else\n+ ask (join (join (join (join [What's ] (numbers after)) [ numbers after ]) (number)) [?]) and wait\n+ end\n+ if <(answer) = ((number) + (numbers after))> then\n+ say [Well done!] for (3) secs\n+ else\n+ say (join [Nice try! The right answer is: ] ((number) + (numbers after))) for (3) secs\n+ end\n+end\n```\n" }, { "change_type": "DELETE", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/go-up-10-numbers/add-in-parts-1-digit-number.md", "new_path": null, "diff": "-# Title\n-\n-## Requirement:\n-\n-## Testing examples:\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/go-up-10-numbers/scratch-expected.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/go-up-10-numbers/scratch-expected.md", "diff": "Click on the green flag to see the expected output of your program.\n-{iframe link=\"https://scratch.mit.edu/projects/embed/?????/?autostart=false\"}\n+{iframe link=\"https://scratch.mit.edu/projects/embed/149427886/?autostart=false\"}\n{panel type=\"help\" title=\"Recommended blocks\"}\n```scratch:split:random\n+when green flag clicked\n+set [number v] to (pick random (1) to (100))\n+\n+ask (join (join [What's 10 numbers after ] (number)) [?]) and wait\n+\n+say [Well done!]\n+\n+say (join (join (join (join (join (answer) [ is a good try! But 10 numbers after ]) (number)) [ is ]) ((number) + (10))) [.])\n+\n+if <(answer) = ((number) + (10))> then\n+else\n+end\n```\n{panel end}\n" }, { "change_type": "DELETE", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/go-up-10-numbers/scratch-hints.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/go-up-10-numbers/scratch-hints.md", "diff": "" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/go-up-10-numbers/scratch-solution.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/go-up-10-numbers/scratch-solution.md", "diff": "```scratch\n-\n+when green flag clicked\n+set [number v] to (pick random (1) to (100))\n+ask (join (join [What's 10 numbers after ] (number)) [?]) and wait\n+if <(answer) = ((number) + (10))> then\n+ say [Well done!]\n+else\n+ say (join (join (join (join (join (answer) [ is a good try! But 10 numbers after ]) (number)) [ is ]) ((number) + (10))) [.])\n+end\n```\n" } ]
Python
MIT License
uccser/cs-unplugged
Numeracy go-up programming challenges.
701,852
21.06.2017 16:46:52
-43,200
ea899be3255ab9b6804287049a824cb3f36fce79
Exponents programming challenge.
[ { "change_type": "DELETE", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/calculate-exponents/add-in-parts-1-digit-number.md", "new_path": null, "diff": "-# Title\n-\n-## Requirement:\n-\n-## Testing examples:\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/calculate-exponents/scratch-expected.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/calculate-exponents/scratch-expected.md", "diff": "Click on the green flag to see the expected output of your program.\n-{iframe link=\"https://scratch.mit.edu/projects/embed/?????/?autostart=false\"}\n+{iframe link=\"https://scratch.mit.edu/projects/embed/149428305/?autostart=false\"}\n{panel type=\"help\" title=\"Recommended blocks\"}\n```scratch:split:random\n+when green flag clicked\n+```\n+\n+```scratch:split:random\n+set [result v] to [1]\n+\n+set [base v] to (answer)\n+set [power v] to (answer)\n+\n+set [result v] to ((result) * (base))\n+```\n+\n+```scratch:split:random\n+ask [Enter an integer for the base:] and wait\n+\n+ask [Enter a positve integer for the power:] and wait\n+```\n+\n+```scratch:split:random\n+say (join (join (join (join (base) [^]) (power)) [ = ]) (result))\n+```\n+\n+```scratch:split:random\n+repeat (power)\n+end\n```\n{panel end}\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/calculate-exponents/scratch-solution.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/calculate-exponents/scratch-solution.md", "diff": "```scratch\n-\n+when green flag clicked\n+set [result v] to [1]\n+ask [Enter an integer for the base:] and wait\n+set [base v] to (answer)\n+ask [Enter a positve integer for the power:] and wait\n+set [power v] to (answer)\n+repeat (power)\n+ set [result v] to ((result) * (base))\n+end\n+say (join (join (join (join (base) [^]) (power)) [ = ]) (result))\n```\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/programming-challenges.yaml", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/programming-challenges.yaml", "diff": "@@ -102,6 +102,7 @@ calculate-exponents:\n- programming-describe-variables\n- programming-explain-asking-input-end-user\n- programming-identify-if-statement\n+ extra-challenge: extra-challenge.md\ncheck-if-divisor:\nchallenge-set-number: 4\n" } ]
Python
MIT License
uccser/cs-unplugged
Exponents programming challenge.
701,852
21.06.2017 16:58:04
-43,200
328dfaba99337f29b25e43dd2a67b7a2759735a4
check if divisor programming challenges.
[ { "change_type": "DELETE", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/check-if-divisor-series/add-in-parts-1-digit-number.md", "new_path": null, "diff": "-# Title\n-\n-## Requirement:\n-\n-## Testing examples:\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/check-if-divisor-series/scratch-expected.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/check-if-divisor-series/scratch-expected.md", "diff": "Click on the green flag to see the expected output of your program.\n-{iframe link=\"https://scratch.mit.edu/projects/embed/?????/?autostart=false\"}\n+{iframe link=\"https://scratch.mit.edu/projects/embed/149428874/?autostart=false\"}\n{panel type=\"help\" title=\"Recommended blocks\"}\n```scratch:split:random\n+when green flag clicked\n+```\n+\n+```scratch:split:random\n+set [number1 v] to (answer)\n+\n+set [number2 v] to (answer)\n+```\n+\n+```scratch:split:random\n+ask [Enter a number:] and wait\n+\n+ask (join [Enter a number to check if it's a divisor of the number ] (number1)) and wait\n+```\n+\n+```scratch:split:random\n+say (join (join (number2) [ is a divisor of the number ]) (number1)) for (3) secs\n+\n+say (join (join (number2) [ is not a divisor of the number ]) (number1)) for (3) secs\n+```\n+\n+```scratch:split:random\n+forever\n+end\n+if <((number1) mod (number2)) = [0]> then\n+else\n+end\n```\n{panel end}\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/check-if-divisor-series/scratch-solution.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/check-if-divisor-series/scratch-solution.md", "diff": "```scratch\n-\n+when green flag clicked\n+ask [Enter a number:] and wait\n+set [number1 v] to (answer)\n+forever\n+ ask (join [Enter a number to check if it's a divisor of the number ] (number1)) and wait\n+ set [number2 v] to (answer)\n+ if <((number1) mod (number2)) = [0]> then\n+ say (join (join (number2) [ is a divisor of the number ]) (number1)) for (3) secs\n+ else\n+ say (join (join (number2) [ is not a divisor of the number ]) (number1)) for (3) secs\n+ end\n+end\n```\n" }, { "change_type": "DELETE", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/check-if-divisor/add-in-parts-1-digit-number.md", "new_path": null, "diff": "-# Title\n-\n-## Requirement:\n-\n-## Testing examples:\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/check-if-divisor/scratch-expected.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/check-if-divisor/scratch-expected.md", "diff": "Click on the green flag to see the expected output of your program.\n-{iframe link=\"https://scratch.mit.edu/projects/embed/?????/?autostart=false\"}\n+{iframe link=\"https://scratch.mit.edu/projects/embed/149428777/?autostart=false\"}\n{panel type=\"help\" title=\"Recommended blocks\"}\n```scratch:split:random\n+when green flag clicked\n+```\n+\n+```scratch:split:random\n+set [number1 v] to (answer)\n+\n+set [number2 v] to (answer)\n+```\n+\n+```scratch:split:random\n+ask [Enter the 1st number:] and wait\n+ask [Enter the 2nd number:] and wait\n+```\n+\n+```scratch:split:random\n+say (join (join (number2) [ is a divisor of the number ]) (number1))\n+\n+say (join (join (number2) [ is not a divisor of the number ]) (number1))\n+```\n+\n+```scratch:split:random\n+if <((number1) mod (number2)) = [0]> then\n+else\n+end\n```\n{panel end}\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/check-if-divisor/scratch-solution.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/check-if-divisor/scratch-solution.md", "diff": "```scratch\n-\n+when green flag clicked\n+say [Enter 2 numbers and I'll tell you if the second number is a divisor of the first number.] for (5) secs\n+ask [Enter the 1st number:] and wait\n+set [number1 v] to (answer)\n+ask [Enter the 2nd number:] and wait\n+set [number2 v] to (answer)\n+if <((number1) mod (number2)) = [0]> then\n+ say (join (join (number2) [ is a divisor of the number ]) (number1))\n+else\n+ say (join (join (number2) [ is not a divisor of the number ]) (number1))\n+end\n```\n" } ]
Python
MIT License
uccser/cs-unplugged
check if divisor programming challenges.
701,852
22.06.2017 14:45:03
-43,200
aef06989b266e7d09e08be82b317c8483fcb032a
Markdown file formatting and PR fixxes.
[ { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/catch-the-mouse-random/scratch-expected.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/catch-the-mouse-random/scratch-expected.md", "diff": "```scratch:split:random\nwhen I receive [go v]\n-move_forward()\n+move_forward() :: custom\n-turn_left\n+turn_left :: custom\n-turn_right\n+turn_right :: custom\n```\n{panel end}\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/catch-the-mouse/scratch-expected.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/catch-the-mouse/scratch-expected.md", "diff": "```scratch:split:random\nwhen I receive [go v]\n-move_forward()\n+move_forward() :: custom\n-turn_left\n+turn_left :: custom\n-turn_right\n+turn_right :: custom\n```\n{panel end}\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/catch-the-mouse/scratch-solution.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/catch-the-mouse/scratch-solution.md", "diff": "```scratch\nwhen I receive [go v]\n-move_forward(3)\n-turn_left\n-move_forward(8)\n-turn_right\n-move_forward(2)\n+move_forward(3) :: custom\n+turn_left :: custom\n+move_forward(8) :: custom\n+turn_right :: custom\n+move_forward(2) :: custom\n```\n**Backdrop 2**:\n```scratch\nwhen I receive [go v]\n-move_forward(4)\n-turn_left\n-move_forward(7)\n-turn_right\n-move_forward(1)\n-turn_left\n-move_forward(1)\n+move_forward(4) :: custom\n+turn_left :: custom\n+move_forward(7) :: custom\n+turn_right :: custom\n+move_forward(1) :: custom\n+turn_left :: custom\n+move_forward(1) :: custom\n```\n**Backdrop 3**:\n```scratch\nwhen I receive [go v]\n-turn_left\n-move_forward(6)\n-turn_right\n-move_forward(3)\n-turn_left\n-move_forward(2)\n-turn_right\n-move_forward(2)\n+turn_left :: custom\n+move_forward(6) :: custom\n+turn_right :: custom\n+move_forward(3) :: custom\n+turn_left :: custom\n+move_forward(2) :: custom\n+turn_right :: custom\n+move_forward(2) :: custom\n```\n**Backdrop 4**:\n```scratch\nwhen I receive [go v]\n-move_forward(2)\n-turn_left\n-move_forward(8)\n-turn_right\n-move_forward(3)\n+move_forward(2) :: custom\n+turn_left :: custom\n+move_forward(8) :: custom\n+turn_right :: custom\n+move_forward(3) :: custom\n```\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-different-types-of-angles/scratch-hints.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-different-types-of-angles/scratch-hints.md", "diff": "@@ -6,11 +6,14 @@ Description of different angles:\n- A straight angle is a 180 degrees angle.\n- A reflex angle is an angle greater than 180 degrees.\n-There are different ways to program checking the range using the **if()/else** blocks. Below are hints for two different ways you may program this:\n+There are different ways to program checking the range using the **if()/else** blocks.\n+Below are hints for two different ways you may program this:\n-- Use a series of **if()** blocks sequentially checking for the ranges in each if() block. If you need to check a range between two values you can use the `scratch:<> and <>` operator in the condition for your if() block (the AND operator reports true if both conditions are true).\n+- Use a series of **if()** blocks sequentially checking for the ranges in each if() block.\n+ If you need to check a range between two values you can use the `scratch:<> and <>` operator in the condition for your if() block (the AND operator reports true if both conditions are true).\n-- Use nested **if()** or **if()/else** blocks, which are **if()/else** blocks inside another set of **if()/else** blocks (i.e. a nested conditional statement is a conditional statement where the **if()** and/or **else** contains another conditional statement). For example:\n+- Use nested **if()** or **if()/else** blocks, which are **if()/else** blocks inside another set of **if()/else** blocks (i.e. a nested conditional statement is a conditional statement where the **if()** and/or **else** contains another conditional statement).\n+ For example:\n```scratch:\nif <[angle] < [180]> then\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-pentagon-without-loop/scratch-hints.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-pentagon-without-loop/scratch-hints.md", "diff": "- A pentagon has five equal sides and five equal angles.\n-- Block `scratch:wait () secs` waits specified number of seconds, then continues with next block. To be able to see each sides of the pentagon being drawn, use the wait block after turning each angle.\n+- Block `scratch:wait () secs` waits specified number of seconds, then continues with next block.\n+ To be able to see each sides of the pentagon being drawn, use the wait block after turning each angle.\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-square-with-loop/scratch-hints.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-square-with-loop/scratch-hints.md", "diff": "- A square has four equal sides and four equal angles (90-degree angles, or right angles).\n-- Block `scratch:wait () secs` waits specified number of seconds, then continues with next block. To be able to see each sides of the square being drawn, use the wait block after turning each angle.\n+- Block `scratch:wait () secs` waits specified number of seconds, then continues with next block.\n+ To be able to see each sides of the square being drawn, use the wait block after turning each angle.\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-square-without-loop/scratch-hints.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/draw-square-without-loop/scratch-hints.md", "diff": "- A square has four equal sides and four equal angles (90-degree angles, or right angles).\n-- The block `scratch:wait () secs` waits specified number of seconds, then continues with next block. To be able to see each sides of the square being drawn, use the wait block after turning each angle.\n+- The block `scratch:wait () secs` waits specified number of seconds, then continues with next block.\n+ To be able to see each sides of the square being drawn, use the wait block after turning each angle.\n" } ]
Python
MIT License
uccser/cs-unplugged
Markdown file formatting and PR fixxes.
701,852
26.06.2017 10:24:37
-43,200
6a54538353a97185375cfcdd3a8b472a84307698
Added support for https apt-gets for nginx for travis.
[ { "change_type": "MODIFY", "old_path": "infrastructure/nginx/Dockerfile", "new_path": "infrastructure/nginx/Dockerfile", "diff": "@@ -9,6 +9,8 @@ RUN apt-get update \\\n# Install Node.js and other dependencies\nRUN apt-get update \\\n+ && apt-get install -y \\\n+ apt-transport-https \\\n&& apt-get install --no-install-suggests -y \\\ncurl \\\ngnupg2 \\\n" } ]
Python
MIT License
uccser/cs-unplugged
Added support for https apt-gets for nginx for travis.
701,852
26.06.2017 10:50:53
-43,200
d475846c15118418396ed268dabf6bcdb6a99699
travis build try removing broken packages.
[ { "change_type": "MODIFY", "old_path": "infrastructure/nginx/Dockerfile", "new_path": "infrastructure/nginx/Dockerfile", "diff": "@@ -8,9 +8,8 @@ RUN apt-get update \\\n&& mv sources.list /etc/apt/sources.list\n# Install Node.js and other dependencies\n-RUN apt-get update \\\n- && apt-get install -y \\\n- apt-transport-https \\\n+RUN apt-get autoremove\n+ && apt-get update \\\n&& apt-get install --no-install-suggests -y \\\ncurl \\\ngnupg2 \\\n" } ]
Python
MIT License
uccser/cs-unplugged
travis build try removing broken packages.
701,852
26.06.2017 11:15:53
-43,200
416117a607996696fc88c1d78fe24aea1b1e5985
include necessary packages.
[ { "change_type": "MODIFY", "old_path": "infrastructure/nginx/Dockerfile", "new_path": "infrastructure/nginx/Dockerfile", "diff": "@@ -14,6 +14,8 @@ RUN apt-get autoremove \\\ncurl \\\ngnupg2 \\\npython \\\n+ g++ \\\n+ libc-dev \\\nbuild-essential \\\n&& curl -sL https://deb.nodesource.com/setup_6.x | bash - \\\n&& apt-get install --no-install-suggests -y \\\n" } ]
Python
MIT License
uccser/cs-unplugged
include necessary packages.
701,852
26.06.2017 11:23:45
-43,200
11dc6e3323c1d98d871878fbf6bd055d8f426bf6
fix libc to libc6
[ { "change_type": "MODIFY", "old_path": "infrastructure/nginx/Dockerfile", "new_path": "infrastructure/nginx/Dockerfile", "diff": "@@ -15,7 +15,7 @@ RUN apt-get autoremove \\\ngnupg2 \\\npython \\\ng++ \\\n- libc-dev \\\n+ libc6-dev \\\nbuild-essential \\\n&& curl -sL https://deb.nodesource.com/setup_6.x | bash - \\\n&& apt-get install --no-install-suggests -y \\\n" } ]
Python
MIT License
uccser/cs-unplugged
fix libc to libc6
701,852
26.06.2017 11:30:39
-43,200
19a91e07e92024bed0895195cb07e02627c7d200
It appears that automatic installation of requirements does not occur anymore.
[ { "change_type": "MODIFY", "old_path": "infrastructure/nginx/Dockerfile", "new_path": "infrastructure/nginx/Dockerfile", "diff": "@@ -15,6 +15,7 @@ RUN apt-get autoremove \\\ngnupg2 \\\npython \\\ng++ \\\n+ libc6 \\\nlibc6-dev \\\nbuild-essential \\\n&& curl -sL https://deb.nodesource.com/setup_6.x | bash - \\\n" } ]
Python
MIT License
uccser/cs-unplugged
It appears that automatic installation of requirements does not occur anymore.
701,852
26.06.2017 11:36:15
-43,200
c290a3456246e109a4b4918e215f493f05925d7e
Something seems up with these dependencies.
[ { "change_type": "MODIFY", "old_path": "infrastructure/nginx/Dockerfile", "new_path": "infrastructure/nginx/Dockerfile", "diff": "@@ -16,7 +16,6 @@ RUN apt-get autoremove \\\npython \\\ng++ \\\nlibc6 \\\n- libc6-dev \\\nbuild-essential \\\n&& curl -sL https://deb.nodesource.com/setup_6.x | bash - \\\n&& apt-get install --no-install-suggests -y \\\n" } ]
Python
MIT License
uccser/cs-unplugged
Something seems up with these dependencies.
701,852
26.06.2017 12:06:57
-43,200
e041ab34242a33d20e59f56db29140e8954c7e96
Tell nginx to fix broken dependencies if possible.
[ { "change_type": "MODIFY", "old_path": "infrastructure/nginx/Dockerfile", "new_path": "infrastructure/nginx/Dockerfile", "diff": "@@ -8,14 +8,13 @@ RUN apt-get update \\\n&& mv sources.list /etc/apt/sources.list\n# Install Node.js and other dependencies\n-RUN apt-get autoremove \\\n- && apt-get update \\\n- && apt-get install --no-install-suggests -y \\\n+RUN apt-get update \\\n+ && apt-get autoclean \\\n+ && apt-get autoremove \\\n+ && apt-get install --no-install-suggests -y -f \\\ncurl \\\ngnupg2 \\\npython \\\n- g++ \\\n- libc6 \\\nbuild-essential \\\n&& curl -sL https://deb.nodesource.com/setup_6.x | bash - \\\n&& apt-get install --no-install-suggests -y \\\n" } ]
Python
MIT License
uccser/cs-unplugged
Tell nginx to fix broken dependencies if possible.
701,852
26.06.2017 13:39:45
-43,200
02362f48e46b568ddc7114d04b0de0653301d17a
Enable security updates.
[ { "change_type": "MODIFY", "old_path": "infrastructure/nginx/Dockerfile", "new_path": "infrastructure/nginx/Dockerfile", "diff": "@@ -5,13 +5,13 @@ FROM nginx:latest\nRUN apt-get update \\\n&& apt-get install -y netselect-apt --no-install-suggests \\\n&& netselect-apt stretch \\\n+ && echo deb http://security.debian.org/debian-security stretch/updates main >> sources.list \\\n+ && cat sources.list \\\n&& mv sources.list /etc/apt/sources.list\n# Install Node.js and other dependencies\nRUN apt-get update \\\n- && apt-get autoclean \\\n- && apt-get autoremove \\\n- && apt-get install --no-install-suggests -y -f \\\n+ && apt-get install --no-install-suggests -y \\\ncurl \\\ngnupg2 \\\npython \\\n" } ]
Python
MIT License
uccser/cs-unplugged
Enable security updates.
701,852
27.06.2017 10:55:43
-43,200
164f70d05aa70e86897a2647fbbf5ce2ceda1f16
Add modulo numbers configuration.
[ { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/learning-outcomes.yaml", "new_path": "csunplugged/topics/content/en/learning-outcomes.yaml", "diff": "@@ -303,6 +303,11 @@ programming-identify-list-store-data:\ncurriculum-areas:\n- programming\n+programming-show-item-specified-position-list:\n+ text: Show how to access an the item at a specified position in a list.\n+ curriculum-areas:\n+ - programming\n+\n# UNPLUGGED PROGRAMMING LEARNING OUTCOMES\nunplugged-programming-apply-addition-multiplication:\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/programming-challenges.yaml", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/programming-challenges.yaml", "diff": "@@ -472,3 +472,97 @@ flip-coins:\n- programming-describe-variables\n- programming-explain-asking-input-end-user\n- programming-identify-if-statement\n+\n+modulo-even-odd-numbers:\n+ challenge-set-number: 1\n+ challenge-number: 1\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-asking-input-end-user\n+ - programming-identify-if-statement\n+\n+modulo-check-divisor:\n+ challenge-set-number: 2\n+ challenge-number: 1\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-identify-if-statement\n+ - programming-explain-join-concatenate\n+ - programming-describe-variables\n+\n+modulo-add-hours-12-hour-clock:\n+ challenge-set-number: 3\n+ challenge-number: 1\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-identify-if-statement\n+ - programming-explain-join-concatenate\n+ - programming-describe-variables\n+\n+modulo-add-hours-12-hour-clock-without-mod:\n+ challenge-set-number: 3\n+ challenge-number: 2\n+ difficulty-level: 2\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-describe-mathematical-operations\n+ - programming-explain-join-concatenate\n+ - programming-describe-variables\n+\n+modulo-add-hours-24-hour-clock:\n+ challenge-set-number: 3\n+ challenge-number: 3\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-identify-if-statement\n+ - programming-explain-join-concatenate\n+ - programming-describe-variables\n+ extra-challenge: extra-challenge.md\n+\n+modulo-display-midi-note:\n+ challenge-set-number: 4\n+ challenge-number: 1\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-mod\n+ - programming-explain-asking-input-end-user\n+ - programming-identify-loop\n+\n+modulo-add-months:\n+ challenge-set-number: 5\n+ challenge-number: 1\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-explain-join-concatenate\n+ - programming-describe-variables\n+ - programming-show-item-specified-position-list\n+\n+modulo-add-video-timings:\n+ challenge-set-number: 6\n+ challenge-number: 1\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-describe-variables\n+ - programming-explain-join-concatenate\n+ - programming-describe-mathematical-operations\n+\n+modulo-check-leap-year:\n+ challenge-set-number: 7\n+ challenge-number: 1\n+ programming-languages:\n+ - scratch\n+ learning-outcomes:\n+ - programming-describe-mathematical-operations\n+ - programming-explain-mod\n+ - programming-identify-if-statement\n" } ]
Python
MIT License
uccser/cs-unplugged
Add modulo numbers configuration.
701,852
27.06.2017 10:58:01
-43,200
628db2fcaebfbd41e84e12a0d254f4c210d101a2
Add programming challenges to modulo lesson.
[ { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/numeracy-unit-plan/lessons/lessons.yaml", "new_path": "csunplugged/topics/content/en/unplugged-programming/numeracy-unit-plan/lessons/lessons.yaml", "diff": "@@ -11,9 +11,12 @@ modulo:\nclassroom-resources:\n- Counters to mark positions.\nprogramming-challenges:\n- - check-if-divisor\n- - check-if-divisor-series\n- - find-factors\n- - check-prime\n- - generate-primes\n- - find-prime-factors\n+ - modulo-even-odd-numbers\n+ - modulo-check-divisor\n+ - modulo-add-hours-12-hour-clock\n+ - modulo-add-hours-12-hour-clock-without-mod\n+ - modulo-add-hours-24-hour-clock\n+ - modulo-display-midi-note\n+ - modulo-add-months\n+ - modulo-add-video-timings\n+ - modulo-check-leap-year\n" } ]
Python
MIT License
uccser/cs-unplugged
Add programming challenges to modulo lesson.
701,852
27.06.2017 13:04:49
-43,200
0648cda6ebe7ddad55cbd8b1ed0495f11157d4ca
Fixed some mistakes with incorrect scratch porgramming loading.
[ { "change_type": "RENAME", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-add-hours-12-hour-clock-without-mod/modulo-add-hours-12-hour-without-mod.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-add-hours-12-hour-clock-without-mod/modulo-add-hours-12-hour-clock-without-mod.md", "diff": "" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-add-hours-12-hour-clock/modulo-add-hours-12-hour-clock.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-add-hours-12-hour-clock/modulo-add-hours-12-hour-clock.md", "diff": "## Requirement:\n-Write a program that adds hours on a clock; for example, on a 12-hour clock, 11 o'clock plus 3 hours is 2 o'clock. This can be done using the modulo operator, except you need to adjust the output so that 0 in mod 12 is displayed as 12. See [challenge \"Add hours on a clock (12-hour clock)\"]('topics:programming_challenge' 'unplugged-programming' 'modulo-add-hours-24-hour-clock') if a 24-hour clock is usual in your country.\n+Write a program that adds hours on a clock; for example, on a 12-hour clock, 11 o'clock plus 3 hours is 2 o'clock. This can be done using the modulo operator, except you need to adjust the output so that 0 in mod 12 is displayed as 12. See [challenge \"Add hours on a clock (24-hour clock)\"]('topics:programming_challenge' 'unplugged-programming' 'modulo-add-hours-24-hour-clock') if a 24-hour clock is usual in your country.\n## Testing examples:\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-add-hours-12-hour-clock/scratch-expected.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-add-hours-12-hour-clock/scratch-expected.md", "diff": "Click on the green flag to see the expected output of your program.\n-{iframe link=\"https://scratch.mit.edu/projects/embed/153740678/?autostart=false\"}\n+{iframe link=\"https://scratch.mit.edu/projects/embed/165593878/?autostart=false\"}\n{panel type=\"help\" title=\"Recommended blocks for solution 1\"}\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-display-midi-note/scratch-expected.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-display-midi-note/scratch-expected.md", "diff": "Click on the green flag to see the expected output of your program.\n-{iframe link=\"https://scratch.mit.edu/projects/embed/153740678/?autostart=false\"}\n+{iframe link=\"https://scratch.mit.edu/projects/embed/165595531/?autostart=false\"}\n{panel type=\"help\" title=\"Recommended blocks for solution 1\"}\n" } ]
Python
MIT License
uccser/cs-unplugged
Fixed some mistakes with incorrect scratch porgramming loading.
701,852
27.06.2017 14:50:58
-43,200
a7701554b8eadd5fe538faac641325ac8f190ac0
Style fix modulo programming challenge markdown files.
[ { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-add-hours-12-hour-clock/modulo-add-hours-12-hour-clock.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-add-hours-12-hour-clock/modulo-add-hours-12-hour-clock.md", "diff": "## Requirement:\n-Write a program that adds hours on a clock; for example, on a 12-hour clock, 11 o'clock plus 3 hours is 2 o'clock. This can be done using the modulo operator, except you need to adjust the output so that 0 in mod 12 is displayed as 12. See [challenge \"Add hours on a clock (24-hour clock)\"]('topics:programming_challenge' 'unplugged-programming' 'modulo-add-hours-24-hour-clock') if a 24-hour clock is usual in your country.\n+Write a program that adds hours on a clock; for example, on a 12-hour clock, 11 o'clock plus 3 hours is 2 o'clock.\n+This can be done using the modulo operator, except you need to adjust the output so that 0 in mod 12 is displayed as 12.\n+See [challenge \"Add hours on a clock (24-hour clock)\"]('topics:programming_challenge' 'unplugged-programming' 'modulo-add-hours-24-hour-clock') if a 24-hour clock is usual in your country.\n## Testing examples:\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-add-hours-24-hour-clock/modulo-add-hours-24-hour-clock.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-add-hours-24-hour-clock/modulo-add-hours-24-hour-clock.md", "diff": "## Requirement:\n-Write a program that adds hours on a clock; for example, on a 24-hour clock, 11 o'clock plus 3 hours is 14:00. This can be done using the modulo operator.\n+Write a program that adds hours on a clock; for example, on a 24-hour clock, 11 o'clock plus 3 hours is 14:00.\n+This can be done using the modulo operator.\n## Testing examples:\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-add-video-timings/modulo-add-video-timings.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-add-video-timings/modulo-add-video-timings.md", "diff": "## Requirement:\nRemix the program provided at [https://scratch.mit.edu/projects/165770195/](https://scratch.mit.edu/projects/165770195/).\n-Write 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. 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. The output of your program should be 1 hour, 5 minutes and 41 seconds.\n+Write 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+The output of your program should be 1 hour, 5 minutes and 41 seconds.\n## Testing examples:\n" } ]
Python
MIT License
uccser/cs-unplugged
Style fix modulo programming challenge markdown files.
701,852
27.06.2017 15:04:22
-43,200
d231b7c3d248c9cb6c6fffcfb7e6d61b2c5ff4fe
Modulo programming description added.
[ { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/numeracy-unit-plan/lessons/lessons.yaml", "new_path": "csunplugged/topics/content/en/unplugged-programming/numeracy-unit-plan/lessons/lessons.yaml", "diff": "@@ -20,3 +20,4 @@ modulo:\n- modulo-add-months\n- modulo-add-video-timings\n- modulo-check-leap-year\n+ programming-challenges-description: modulo-programming.md\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/en/unplugged-programming/numeracy-unit-plan/lessons/modulo-programming.md", "diff": "+These programming challenges revolve around the \"modulo\" function (\"mod\" in Scratch, or \"%\" in some languages).\n+The modulo function occurs so much in Computer Science that we think it's worth exploring in its own right.\n+The exercises here correspond to some of the Unplugged modulo activities.\n+You'll also find programming exercises that use modulo in the exercises relating to hash tables for searching, the check digits for error detection.\n" } ]
Python
MIT License
uccser/cs-unplugged
Modulo programming description added.
701,852
27.06.2017 15:12:54
-43,200
ffc8c52c66ed124a7640b5a86d2eb3c5075da136
Fix incorrect recommended blocks panels.
[ { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-add-hours-12-hour-clock-without-mod/scratch-expected.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-add-hours-12-hour-clock-without-mod/scratch-expected.md", "diff": "@@ -2,7 +2,7 @@ Click on the green flag to see the expected output of your program.\n{iframe link=\"https://scratch.mit.edu/projects/embed/165945729/?autostart=false\"}\n-{panel type=\"help\" title=\"Recommended blocks for solution 1\"}\n+{panel type=\"help\" title=\"Recommended blocks\"}\n```scratch:split:random\nwhen green flag clicked\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-add-hours-12-hour-clock/scratch-expected.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-add-hours-12-hour-clock/scratch-expected.md", "diff": "@@ -2,7 +2,7 @@ Click on the green flag to see the expected output of your program.\n{iframe link=\"https://scratch.mit.edu/projects/embed/165593878/?autostart=false\"}\n-{panel type=\"help\" title=\"Recommended blocks for solution 1\"}\n+{panel type=\"help\" title=\"Recommended blocks\"}\n```scratch:split:random\nwhen green flag clicked\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-add-hours-24-hour-clock/scratch-expected.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-add-hours-24-hour-clock/scratch-expected.md", "diff": "@@ -2,7 +2,7 @@ Click on the green flag to see the expected output of your program.\n{iframe link=\"https://scratch.mit.edu/projects/embed/165919715/?autostart=false\"}\n-{panel type=\"help\" title=\"Recommended blocks for solution 1\"}\n+{panel type=\"help\" title=\"Recommended blocks\"}\n```scratch:split:random\nwhen green flag clicked\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-add-months/scratch-expected.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-add-months/scratch-expected.md", "diff": "@@ -2,7 +2,7 @@ Click on the green flag to see the expected output of your program.\n{iframe link=\"https://scratch.mit.edu/projects/embed/165598015/?autostart=false\"}\n-{panel type=\"help\" title=\"Recommended blocks for solution 1\"}\n+{panel type=\"help\" title=\"Recommended blocks\"}\n```scratch:split:random\nwhen green flag clicked\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-add-video-timings/scratch-expected.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-add-video-timings/scratch-expected.md", "diff": "@@ -2,7 +2,7 @@ Click on the green flag to see the expected output of your program.\n{iframe link=\"https://scratch.mit.edu/projects/embed/165605502/?autostart=false\"}\n-{panel type=\"help\" title=\"Recommended blocks for solution 1\"}\n+{panel type=\"help\" title=\"Recommended blocks\"}\n```scratch:split:random\nwhen green flag clicked\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-check-divisor/scratch-expected.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-check-divisor/scratch-expected.md", "diff": "@@ -2,7 +2,7 @@ Click on the green flag to see the expected output of your program.\n{iframe link=\"https://scratch.mit.edu/projects/embed/149428777/?autostart=false\"}\n-{panel type=\"help\" title=\"Recommended blocks for solution 1\"}\n+{panel type=\"help\" title=\"Recommended blocks\"}\n```scratch:split:random\nwhen green flag clicked\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-check-leap-year/scratch-expected.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-check-leap-year/scratch-expected.md", "diff": "@@ -2,7 +2,7 @@ Click on the green flag to see the expected output of your program.\n{iframe link=\"https://scratch.mit.edu/projects/embed/165754830/?autostart=false\"}\n-{panel type=\"help\" title=\"Recommended blocks for solution 1\"}\n+{panel type=\"help\" title=\"Recommended blocks\"}\n```scratch:split:random\nwhen green flag clicked\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-display-midi-note/scratch-expected.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-display-midi-note/scratch-expected.md", "diff": "@@ -2,7 +2,7 @@ Click on the green flag to see the expected output of your program.\n{iframe link=\"https://scratch.mit.edu/projects/embed/165595531/?autostart=false\"}\n-{panel type=\"help\" title=\"Recommended blocks for solution 1\"}\n+{panel type=\"help\" title=\"Recommended blocks\"}\n```scratch:split:random\nwhen green flag clicked\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-even-odd-numbers/scratch-expected.md", "new_path": "csunplugged/topics/content/en/unplugged-programming/programming-challenges/modulo-even-odd-numbers/scratch-expected.md", "diff": "@@ -2,7 +2,7 @@ Click on the green flag to see the expected output of your program.\n{iframe link=\"https://scratch.mit.edu/projects/embed/148426036/?autostart=false\"}\n-{panel type=\"help\" title=\"Recommended blocks for solution 1\"}\n+{panel type=\"help\" title=\"Recommended blocks\"}\n```scratch:split:random\nwhen green flag clicked\n" } ]
Python
MIT License
uccser/cs-unplugged
Fix incorrect recommended blocks panels.
701,852
20.07.2017 11:29:09
-43,200
9b99802484db736fc7a7e2748b98e6d024cf9bb5
Lesson configurations and lesson 2 content.
[ { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/learning-outcomes.yaml", "new_path": "csunplugged/topics/content/en/learning-outcomes.yaml", "diff": "@@ -342,6 +342,22 @@ search-algorithms-explore-probability-value-random-set:\nsearch-algorithms-explain-range-unsorted-lists:\ntext: Explain the range of the number of guesses for unsorted lists.\n+search-algorithms-identify-sequential-binary:\n+ text: Identify search algorithms for sorted and unsorted lists (sequential and binary search).\n+\n+search-algorithms-explain-decomposition-binary:\n+ text: Explain how they used decomposition to divide and conquer when doing a binary search.\n+\n+search-algorithms-describe-time-size-input-different:\n+ text: Describe how the time taken grows with the size of the input, and most importantly how it grows in different ways for two different algorithms.\n+\n+search-algorithms-describe-compare-values:\n+ text: Describe how to compare number values for equality and inequality (greater than, less than).\n+\n+search-algorithms-explain-unsorted-lists:\n+ text: Explain the range of the number of guesses for unsorted lists compared to sorted lists.\n+\n+\n# UNPLUGGED PROGRAMMING LEARNING OUTCOMES\nunplugged-programming-apply-addition-multiplication:\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/searching-algorithms/sequential-and-binary-search-unit-plan/lessons/lessons.yaml", "new_path": "csunplugged/topics/content/en/searching-algorithms/sequential-and-binary-search-unit-plan/lessons/lessons.yaml", "diff": "@@ -9,3 +9,37 @@ how-many-guesses:\nclassroom-resources:\n- Payment system such as tokens or marbles\n- A recording system (e.g. a post-it note for each student)\n+\n+divide-and-conquer:\n+ duration: 30\n+ computational-thinking-links: divide-and-conquer-ct-links.md\n+ learning-outcomes:\n+ - search-algorithms-identify-sequential-binary\n+ - search-algorithms-explain-decomposition-binary\n+ - search-algorithms-describe-time-size-input-different\n+ - search-algorithms-describe-compare-values\n+ - search-algorithms-explain-unsorted-lists\n+ classroom-resources:\n+ - Payment system such as tokens or marbles.\n+ - A recording system (e.g. a post-it note for each student)\n+\n+the-great-treasure-hunt-unsorted:\n+ duration: 30\n+ computational-thinking-links: the-great-treasure-hunt-unsorted-ct-links.md\n+ learning-outcomes:\n+ - search-algorithms-identify-unsorted-lists\n+ - search-algorithms-describe-time-size-input\n+ - search-algorithms-explain-range-unsorted-lists\n+ - search-algorithms-explore-probability-value-random-set\n+\n+the-great-treasure-hunt-sorted:\n+ duration: 45\n+ computational-thinking-links: the-great-treasure-hunt-sorted-ct-links.md\n+ learning-outcomes:\n+ - search-algorithms-identify-sequential-binary\n+ - search-algorithms-explain-decomposition-binary\n+ - search-algorithms-describe-time-size-input-different\n+ - search-algorithms-describe-compare-values\n+ - search-algorithms-explain-unsorted-lists\n+ classroom-resources:\n+ - Pencils\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/searching-algorithms/sequential-and-binary-search-unit-plan/sequential-and-binary-search-unit-plan.yaml", "new_path": "csunplugged/topics/content/en/searching-algorithms/sequential-and-binary-search-unit-plan/sequential-and-binary-search-unit-plan.yaml", "diff": "@@ -5,3 +5,9 @@ age-groups:\n8-10:\nhow-many-guesses:\nnumber: 1\n+ divide-and-conquer:\n+ number: 2\n+ the-great-treasure-hunt-unsorted:\n+ number: 3\n+ the-great-treasure-hunt-sorted:\n+ number: 4\n" } ]
Python
MIT License
uccser/cs-unplugged
Lesson configurations and lesson 2 content.
701,852
20.07.2017 13:25:23
-43,200
c7aa40a2090d6b1239bf50614df2585a642e3261
Formatting and link fix.
[ { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/searching-algorithms/sequential-and-binary-search-unit-plan/lessons/divide-and-conquer-ct-links.md", "new_path": "csunplugged/topics/content/en/searching-algorithms/sequential-and-binary-search-unit-plan/lessons/divide-and-conquer-ct-links.md", "diff": "@@ -71,6 +71,7 @@ Students will generally be able to logically reason and recognise that the best\nIf we check that card and compare it to the number we are searching for what does that tell us about all the cards to the left of that card?\nAll the cards to the right of that card?\nStudents can deduce which cards they can now eliminate based on the card they have checked.\n+\nAsking students to explain how they came to this conclusion is a great way to exercise their thinking skills, by getting them to articulate the logical steps they followed to come to this conclusion, and why it makes sense that doubling the number of cards only needs 1 more check.\nUnderstanding why divide and conquer will only ever require a specific small number of steps at most (for example it will never take more than 5 checks for 19 cards, or 20 checks for 1,000,000 cards) also requires a high level of logical reasoning.\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/searching-algorithms/sequential-and-binary-search-unit-plan/lessons/the-great-treasure-hunt-sorted-ct-links.md", "new_path": "csunplugged/topics/content/en/searching-algorithms/sequential-and-binary-search-unit-plan/lessons/the-great-treasure-hunt-sorted-ct-links.md", "diff": "@@ -13,6 +13,7 @@ Who are the students who not only can explain the exact process to find the real\n{panel type=\"ct-abstraction\" title=\"Abstraction\"}\nAs in lesson 2 and lesson 3, we can ignore many details about the items we are searching for.\n+\nAlso, as discussed in lesson 2, we can use the divide and conquer approach for more problems than just searching through an ordered list of numbers. We can use it to search through any set of objects that can be placed in ascending order (such as words in alphabetical order).\n#### Examples of what you could look for:\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/searching-algorithms/sequential-and-binary-search-unit-plan/lessons/the-great-treasure-hunt-sorted.md", "new_path": "csunplugged/topics/content/en/searching-algorithms/sequential-and-binary-search-unit-plan/lessons/the-great-treasure-hunt-sorted.md", "diff": "@@ -16,6 +16,7 @@ As with lesson 3, on each sheet are 26 treasure chests with lots of money in the\nAll money has a serial number on it and in each of the treasure chests all the notes start with the same serial number.\nThe only problem is there is only one treasure chest that has the real money in it, the rest are fake.\nYou know what the serial number on the real money is, and your challenge is to find the treasure chest with the real money in it, in the least amount of guesses.\n+\nGuide students through how the game will work by following the instructions on the [Treasure Hunt Instructions pdf](https://www.example.com) (although this time the numbers will be in sorted order).\n{panel type=\"math\" title=\"Mathematical Links\"}\n" } ]
Python
MIT License
uccser/cs-unplugged
Formatting and link fix.
701,852
27.07.2017 18:09:26
-43,200
981bdac9c552b0dcdeac5a3bbb975d9386e2eb24
Fix pango to clear wheezyprint error.
[ { "change_type": "MODIFY", "old_path": "Dockerfile-local", "new_path": "Dockerfile-local", "diff": "@@ -10,19 +10,36 @@ ARG DEBIAN_FRONTEND=noninteractive\nENV DJANGO_PRODUCTION=False\n+# Install custom Pango version\n+\n+# Install FreeType2 then HarfBuzz then reinstall FreeType2\n+RUN apt-get update && apt-get install -y \\\n+ bzip2 \\\n+ gperf \\\n+ libbz2-dev \\\n+ libffi-dev \\\n+ libtinfo-dev \\\n+ libmount-dev \\\n+ libicu52 \\\n+ libpcre3 \\\n+ libglib2.0-dev \\\n+ libgdk-pixbuf2.0-dev \\\n+ libcairo2-dev\n+\n+RUN mkdir /pango-install/\n+COPY ./csunplugged/pango-install.sh /pango-install/\n+RUN chmod +x /pango-install/pango-install.sh\n+RUN /pango-install/pango-install.sh\n+\n# Install packages (including Weasyprint dependencies), running of Python 3.4.2\nRUN apt-get update && apt-get install -y \\\npython3 \\\npython3-dev \\\npython3-pip \\\n- libffi-dev \\\n- libcairo2-dev \\\npython-dev \\\npython-pip \\\npython-lxml \\\npython-cffi \\\n- libpango1.0-0 \\\n- libgdk-pixbuf2.0-0 \\\nshared-mime-info\nRUN apt-get clean && rm /var/lib/apt/lists/*_*\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/pango-install.sh", "diff": "+#!/bin/bash\n+cd /pango-install/\n+\n+# Install libffi\n+# echo 'Obtaining libffi'\n+# wget ftp://sourceware.org/pub/libffi/libffi-3.2.1.tar.gz\n+# tar -xf libffi-3.2.1.tar.gz\n+# cd libffi-3.2.1\n+#\n+# echo 'Configuring libffi'\n+# sed -e '/^includesdir/ s/$(libdir).*$/$(includedir)/' \\\n+# -i include/Makefile.in &&\n+#\n+# sed -e '/^includedir/ s/=.*$/=@includedir@/' \\\n+# -e 's/^Cflags: -I${includedir}/Cflags:/' \\\n+# -i libffi.pc.in &&\n+#\n+# ./configure --prefix=/usr --disable-static &&\n+# make\n+#\n+# echo 'Installing libffi'\n+# make install\n+# cd ..\n+\n+# Install Bzip2\n+# echo 'Obtaining Bzip2'\n+# wget ftp://sources.redhat.com/pub/bzip2/v102/bzip2-1.0.2.tar.gz\n+# tar -xf bzip2-1.0.2.tar.gz\n+# cd bzip2-1.0.2\n+#\n+# echo 'Configuring Bzip2'\n+# make -f Makefile-libbz2_so\n+# make clean\n+# make\n+#\n+# echo 'Installing Bzip2'\n+# make PREFIX=/usr install\n+# cp -v bzip2-shared /bin/bzip2\n+# cp -av libbz2.so* /lib\n+# ln -sv ../../lib/libbz2.so.1.0 /usr/lib/libbz2.so\n+# rm -v /usr/bin/{bunzip2,bzcat,bzip2}\n+# ln -sv bzip2 /bin/bunzip2\n+# ln -sv bzip2 /bin/bzcat\n+# cd ..\n+\n+# Install ncurses\n+# echo 'Obtaining ncurses'\n+# wget ftp://ftp.gnu.org/gnu/ncurses/ncurses-6.0.tar.gz\n+# tar -xf ncurses-6.0.tar.gz\n+# cd ncurses-6.0\n+#\n+# echo 'Configuring ncurses'\n+# sed -i '/LIBTOOL_INSTALL/d' c++/Makefile.in\n+# ./configure --prefix=/usr \\\n+# --mandir=/usr/share/man \\\n+# --with-shared \\\n+# --without-debug \\\n+# --without-normal \\\n+# --enable-pc-files \\\n+# --enable-widec\n+# make\n+#\n+# echo 'Installing ncurses'\n+# make install\n+# mv -v /usr/lib/libncursesw.so.6* /lib\n+# ln -sfv ../../lib/$(readlink /usr/lib/libncursesw.so) /usr/lib/libncursesw.so\n+# for lib in ncurses form panel menu ; do\n+# rm -vf /usr/lib/lib${lib}.so\n+# echo \"INPUT(-l${lib}w)\" > /usr/lib/lib${lib}.so\n+# ln -sfv ${lib}w.pc /usr/lib/pkgconfig/${lib}.pc\n+# done\n+# rm -vf /usr/lib/libcursesw.so\n+# echo \"INPUT(-lncursesw)\" > /usr/lib/libcursesw.so\n+# ln -sfv libncurses.so /usr/lib/libcurses.so\n+# cd ..\n+\n+# Install readline\n+# echo 'Obtaining readline'\n+# wget http://ftp.gnu.org/gnu/readline/readline-7.0.tar.gz\n+# tar -xf readline-7.0.tar.gz\n+# cd readline-7.0\n+#\n+# echo 'Configuring readline'\n+# sed -i '/MV.*old/d' Makefile.in\n+# sed -i '/{OLDSUFF}/c:' support/shlib-install\n+# ./configure --prefix=/usr \\\n+# --disable-static \\\n+# --docdir=/usr/share/doc/readline-7.0\n+# make SHLIB_LIBS=\"-L/tools/lib -lncursesw\"\n+#\n+# echo 'Installing readline'\n+# make SHLIB_LIBS=\"-L/tools/lib -lncurses\" install\n+# mv -v /usr/lib/lib{readline,history}.so.* /lib\n+# ln -sfv ../../lib/$(readlink /usr/lib/libreadline.so) /usr/lib/libreadline.so\n+# ln -sfv ../../lib/$(readlink /usr/lib/libhistory.so ) /usr/lib/libhistory.so\n+# cd ..\n+\n+# Install PCRE\n+# echo 'Obtaining PCRE'\n+# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.bz2\n+# tar -xf pcre-8.41.tar.bz2\n+# cd pcre-8.41\n+#\n+# echo 'Configuring PCRE'\n+# ./configure --prefix=/usr \\\n+# --docdir=/usr/share/doc/pcre-8.41 \\\n+# --enable-unicode-properties \\\n+# --enable-pcre16 \\\n+# --enable-pcre32 \\\n+# --enable-pcregrep-libz \\\n+# --enable-pcregrep-libbz2 \\\n+# --enable-pcretest-libreadline \\\n+# --disable-static &&\n+# make\n+#\n+# echo 'Installing PCRE'\n+# make install &&\n+# mv -v /usr/lib/libpcre.so.* /lib &&\n+# ln -sfv ../../lib/$(readlink /usr/lib/libpcre.so) /usr/lib/libpcre.so\n+# cd ..\n+\n+# Install gettext\n+# echo 'Obtaining gettext'\n+# wget http://ftp.gnu.org/pub/gnu/gettext/gettext-0.19.8.tar.gz\n+# tar -xf gettext-0.19.8.tar.gz\n+# cd gettext-0.19.8\n+#\n+# echo 'Configuring getext'\n+# sed -i '/^TESTS =/d' gettext-runtime/tests/Makefile.in &&\n+# sed -i 's/test-lock..EXEEXT.//' gettext-tools/gnulib-tests/Makefile.in\n+#\n+# ./configure --prefix=/usr \\\n+# --disable-static\n+# make\n+#\n+# echo 'Installing gettext'\n+# make install\n+# cd ..\n+\n+# Install util-linux (for libmount)\n+# echo 'Obtaining util-linux'\n+# wget https://www.kernel.org/pub/linux/utils/util-linux/v2.30/util-linux-2.30.1.tar.gz\n+# tar -xf util-linux-2.30.1.tar.gz\n+# cd util-linux-2.30.1\n+#\n+# echo 'Configuring util-linux'\n+# mkdir -pv /var/lib/hwclock\n+# ./configure ADJTIME_PATH=/var/lib/hwclock/adjtime \\\n+# --docdir=/usr/share/doc/util-linux-2.30.1 \\\n+# --disable-chfn-chsh \\\n+# --disable-login \\\n+# --disable-nologin \\\n+# --disable-su \\\n+# --disable-setpriv \\\n+# --disable-runuser \\\n+# --disable-pylibmount \\\n+# --disable-static \\\n+# --without-python \\\n+# --without-systemd \\\n+# --without-systemdsystemunitdir\n+# make\n+#\n+# echo \"Installing util-linux\"\n+# make install\n+# cd ..\n+\n+# Install GLib\n+# echo 'Obtaining GLib'\n+# wget ftp://ftp.gnome.org/pub/gnome/sources/glib/2.52/glib-2.52.3.tar.xz\n+# tar -xf glib-2.52.3.tar.xz\n+# cd glib-2.52.3\n+#\n+# echo 'Configuring GLib'\n+# ./configure --prefix=/usr --with-pcre=system &&\n+# make\n+#\n+# echo 'Installing GLib'\n+# make install\n+# cd ..\n+\n+# Install libpng\n+echo 'Obtaining libpng'\n+wget http://downloads.sourceforge.net/libpng/libpng-1.6.29.tar.xz\n+tar -xf libpng-1.6.29.tar.xz\n+cd libpng-1.6.29\n+\n+echo 'Configuring libpng'\n+LIBS=-lpthread ./configure --prefix=/usr --disable-static &&\n+make\n+\n+echo 'Installing libpng'\n+make install &&\n+mkdir -v /usr/share/doc/libpng-1.6.29 &&\n+cp -v README libpng-manual.txt /usr/share/doc/libpng-1.6.29\n+cd ..\n+\n+# Install Which\n+echo 'Obtaining Which'\n+wget ftp://ftp.gnu.org/gnu/which/which-2.21.tar.gz\n+tar -xf which-2.21.tar.gz\n+cd which-2.21\n+\n+echo 'Configuring Which'\n+./configure --prefix=/usr &&\n+make\n+\n+echo 'Installing Which'\n+make install\n+cd ..\n+\n+# Install FreeType\n+echo 'Obtaining FreeType'\n+wget http://downloads.sourceforge.net/freetype/freetype-2.8.tar.bz2\n+tar -xf freetype-2.8.tar.bz2\n+cd freetype-2.8\n+\n+echo 'Configuring FreeType'\n+sed -ri \"s:.*(AUX_MODULES.*valid):\\1:\" modules.cfg &&\n+sed -r \"s:.*(#.*SUBPIXEL_RENDERING) .*:\\1:\" \\\n+ -i include/freetype/config/ftoption.h &&\n+./configure --prefix=/usr --disable-static &&\n+make\n+\n+echo 'Installing FreeType'\n+make install &&\n+install -v -m755 -d /usr/share/doc/freetype-2.8 &&\n+cp -v -R docs/* /usr/share/doc/freetype-2.8\n+cd ..\n+\n+# Install ICU-59.1\n+# echo 'Obtaining ICU'\n+# wget http://download.icu-project.org/files/icu4c/59.1/icu4c-59_1-src.tgz\n+# tar -xf icu4c-59_1-src.tgz\n+# cd icu\n+#\n+# echo 'Configuring ICU'\n+# cd source &&\n+# ./configure --prefix=/usr &&\n+# make\n+#\n+# echo 'Installing ICU'\n+# make install\n+# cd ../..\n+\n+# Install HarfBuzz with FreeType2\n+echo 'Obtaining HarfBuzz'\n+wget http://www.freedesktop.org/software/harfbuzz/release/harfbuzz-1.4.6.tar.bz2\n+tar -xf harfbuzz-1.4.6.tar.bz2\n+cd harfbuzz-1.4.6\n+\n+echo 'Configuring HarfBuzz'\n+./configure --prefix=/usr --with-gobject &&\n+make\n+\n+echo 'Installing HarfBuzz'\n+make install\n+cd ..\n+\n+# Reinstall FreeType2 with HarfBuzz support\n+echo 'Reinstalling FreeType2'\n+cd freetype-2.8\n+./configure --prefix=/usr --disable-static &&\n+make &&\n+make install &&\n+install -v -m755 -d /usr/share/doc/freetype-2.8 &&\n+cp -v -R docs/* /usr/share/doc/freetype-2.8\n+cd ..\n+\n+# Install Fontconfig-2\n+echo 'Obtaining Fontconfig'\n+wget http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.12.4.tar.bz2\n+tar -xf fontconfig-2.12.4.tar.bz2\n+cd fontconfig-2.12.4\n+\n+echo 'Configuring Fontconfig'\n+rm -f src/fcobjshash.h\n+./configure --prefix=/usr \\\n+ --sysconfdir=/etc \\\n+ --localstatedir=/var \\\n+ --disable-docs \\\n+ --docdir=/usr/share/doc/fontconfig-2.12.4 &&\n+make\n+\n+echo 'Installing Fontconfig'\n+make install\n+cd ..\n+\n+# install Pango-1.40\n+echo 'Obtaining Pango'\n+wget ftp://ftp.gnome.org/pub/gnome/sources/pango/1.40/pango-1.40.6.tar.xz\n+tar -xf pango-1.40.6.tar.xz\n+cd pango-1.40.6\n+\n+echo 'Configuring Pango'\n+./configure --prefix=/usr --sysconfdir=/etc &&\n+make\n+\n+echo 'Installing Pango'\n+make install\n+\n+cd /\n" } ]
Python
MIT License
uccser/cs-unplugged
Fix pango to clear wheezyprint error.
701,852
27.07.2017 22:00:25
-43,200
066331ac46ba165831f6b537f0720469e212470f
Tidy pango install script.
[ { "change_type": "MODIFY", "old_path": "csunplugged/pango-install.sh", "new_path": "csunplugged/pango-install.sh", "diff": "#!/bin/bash\ncd /pango-install/\n-# Install libffi\n-# echo 'Obtaining libffi'\n-# wget ftp://sourceware.org/pub/libffi/libffi-3.2.1.tar.gz\n-# tar -xf libffi-3.2.1.tar.gz\n-# cd libffi-3.2.1\n-#\n-# echo 'Configuring libffi'\n-# sed -e '/^includesdir/ s/$(libdir).*$/$(includedir)/' \\\n-# -i include/Makefile.in &&\n-#\n-# sed -e '/^includedir/ s/=.*$/=@includedir@/' \\\n-# -e 's/^Cflags: -I${includedir}/Cflags:/' \\\n-# -i libffi.pc.in &&\n-#\n-# ./configure --prefix=/usr --disable-static &&\n-# make\n-#\n-# echo 'Installing libffi'\n-# make install\n-# cd ..\n-\n-# Install Bzip2\n-# echo 'Obtaining Bzip2'\n-# wget ftp://sources.redhat.com/pub/bzip2/v102/bzip2-1.0.2.tar.gz\n-# tar -xf bzip2-1.0.2.tar.gz\n-# cd bzip2-1.0.2\n-#\n-# echo 'Configuring Bzip2'\n-# make -f Makefile-libbz2_so\n-# make clean\n-# make\n-#\n-# echo 'Installing Bzip2'\n-# make PREFIX=/usr install\n-# cp -v bzip2-shared /bin/bzip2\n-# cp -av libbz2.so* /lib\n-# ln -sv ../../lib/libbz2.so.1.0 /usr/lib/libbz2.so\n-# rm -v /usr/bin/{bunzip2,bzcat,bzip2}\n-# ln -sv bzip2 /bin/bunzip2\n-# ln -sv bzip2 /bin/bzcat\n-# cd ..\n-\n-# Install ncurses\n-# echo 'Obtaining ncurses'\n-# wget ftp://ftp.gnu.org/gnu/ncurses/ncurses-6.0.tar.gz\n-# tar -xf ncurses-6.0.tar.gz\n-# cd ncurses-6.0\n-#\n-# echo 'Configuring ncurses'\n-# sed -i '/LIBTOOL_INSTALL/d' c++/Makefile.in\n-# ./configure --prefix=/usr \\\n-# --mandir=/usr/share/man \\\n-# --with-shared \\\n-# --without-debug \\\n-# --without-normal \\\n-# --enable-pc-files \\\n-# --enable-widec\n-# make\n-#\n-# echo 'Installing ncurses'\n-# make install\n-# mv -v /usr/lib/libncursesw.so.6* /lib\n-# ln -sfv ../../lib/$(readlink /usr/lib/libncursesw.so) /usr/lib/libncursesw.so\n-# for lib in ncurses form panel menu ; do\n-# rm -vf /usr/lib/lib${lib}.so\n-# echo \"INPUT(-l${lib}w)\" > /usr/lib/lib${lib}.so\n-# ln -sfv ${lib}w.pc /usr/lib/pkgconfig/${lib}.pc\n-# done\n-# rm -vf /usr/lib/libcursesw.so\n-# echo \"INPUT(-lncursesw)\" > /usr/lib/libcursesw.so\n-# ln -sfv libncurses.so /usr/lib/libcurses.so\n-# cd ..\n-\n-# Install readline\n-# echo 'Obtaining readline'\n-# wget http://ftp.gnu.org/gnu/readline/readline-7.0.tar.gz\n-# tar -xf readline-7.0.tar.gz\n-# cd readline-7.0\n-#\n-# echo 'Configuring readline'\n-# sed -i '/MV.*old/d' Makefile.in\n-# sed -i '/{OLDSUFF}/c:' support/shlib-install\n-# ./configure --prefix=/usr \\\n-# --disable-static \\\n-# --docdir=/usr/share/doc/readline-7.0\n-# make SHLIB_LIBS=\"-L/tools/lib -lncursesw\"\n-#\n-# echo 'Installing readline'\n-# make SHLIB_LIBS=\"-L/tools/lib -lncurses\" install\n-# mv -v /usr/lib/lib{readline,history}.so.* /lib\n-# ln -sfv ../../lib/$(readlink /usr/lib/libreadline.so) /usr/lib/libreadline.so\n-# ln -sfv ../../lib/$(readlink /usr/lib/libhistory.so ) /usr/lib/libhistory.so\n-# cd ..\n-\n-# Install PCRE\n-# echo 'Obtaining PCRE'\n-# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.bz2\n-# tar -xf pcre-8.41.tar.bz2\n-# cd pcre-8.41\n-#\n-# echo 'Configuring PCRE'\n-# ./configure --prefix=/usr \\\n-# --docdir=/usr/share/doc/pcre-8.41 \\\n-# --enable-unicode-properties \\\n-# --enable-pcre16 \\\n-# --enable-pcre32 \\\n-# --enable-pcregrep-libz \\\n-# --enable-pcregrep-libbz2 \\\n-# --enable-pcretest-libreadline \\\n-# --disable-static &&\n-# make\n-#\n-# echo 'Installing PCRE'\n-# make install &&\n-# mv -v /usr/lib/libpcre.so.* /lib &&\n-# ln -sfv ../../lib/$(readlink /usr/lib/libpcre.so) /usr/lib/libpcre.so\n-# cd ..\n-\n-# Install gettext\n-# echo 'Obtaining gettext'\n-# wget http://ftp.gnu.org/pub/gnu/gettext/gettext-0.19.8.tar.gz\n-# tar -xf gettext-0.19.8.tar.gz\n-# cd gettext-0.19.8\n-#\n-# echo 'Configuring getext'\n-# sed -i '/^TESTS =/d' gettext-runtime/tests/Makefile.in &&\n-# sed -i 's/test-lock..EXEEXT.//' gettext-tools/gnulib-tests/Makefile.in\n-#\n-# ./configure --prefix=/usr \\\n-# --disable-static\n-# make\n-#\n-# echo 'Installing gettext'\n-# make install\n-# cd ..\n-\n-# Install util-linux (for libmount)\n-# echo 'Obtaining util-linux'\n-# wget https://www.kernel.org/pub/linux/utils/util-linux/v2.30/util-linux-2.30.1.tar.gz\n-# tar -xf util-linux-2.30.1.tar.gz\n-# cd util-linux-2.30.1\n-#\n-# echo 'Configuring util-linux'\n-# mkdir -pv /var/lib/hwclock\n-# ./configure ADJTIME_PATH=/var/lib/hwclock/adjtime \\\n-# --docdir=/usr/share/doc/util-linux-2.30.1 \\\n-# --disable-chfn-chsh \\\n-# --disable-login \\\n-# --disable-nologin \\\n-# --disable-su \\\n-# --disable-setpriv \\\n-# --disable-runuser \\\n-# --disable-pylibmount \\\n-# --disable-static \\\n-# --without-python \\\n-# --without-systemd \\\n-# --without-systemdsystemunitdir\n-# make\n-#\n-# echo \"Installing util-linux\"\n-# make install\n-# cd ..\n-\n-# Install GLib\n-# echo 'Obtaining GLib'\n-# wget ftp://ftp.gnome.org/pub/gnome/sources/glib/2.52/glib-2.52.3.tar.xz\n-# tar -xf glib-2.52.3.tar.xz\n-# cd glib-2.52.3\n-#\n-# echo 'Configuring GLib'\n-# ./configure --prefix=/usr --with-pcre=system &&\n-# make\n-#\n-# echo 'Installing GLib'\n-# make install\n-# cd ..\n-\n# Install libpng\necho 'Obtaining libpng'\nwget http://downloads.sourceforge.net/libpng/libpng-1.6.29.tar.xz\n@@ -227,21 +50,6 @@ install -v -m755 -d /usr/share/doc/freetype-2.8 &&\ncp -v -R docs/* /usr/share/doc/freetype-2.8\ncd ..\n-# Install ICU-59.1\n-# echo 'Obtaining ICU'\n-# wget http://download.icu-project.org/files/icu4c/59.1/icu4c-59_1-src.tgz\n-# tar -xf icu4c-59_1-src.tgz\n-# cd icu\n-#\n-# echo 'Configuring ICU'\n-# cd source &&\n-# ./configure --prefix=/usr &&\n-# make\n-#\n-# echo 'Installing ICU'\n-# make install\n-# cd ../..\n-\n# Install HarfBuzz with FreeType2\necho 'Obtaining HarfBuzz'\nwget http://www.freedesktop.org/software/harfbuzz/release/harfbuzz-1.4.6.tar.bz2\n" } ]
Python
MIT License
uccser/cs-unplugged
Tidy pango install script.
701,852
31.07.2017 18:41:14
-43,200
1fef775c332b99faafef853578ac377a9a4692e0
Added learning-outcomes cirriculum areas.
[ { "change_type": "MODIFY", "old_path": "csunplugged/topics/content/en/learning-outcomes.yaml", "new_path": "csunplugged/topics/content/en/learning-outcomes.yaml", "diff": "@@ -332,31 +332,48 @@ programming-show-item-specified-position-list:\nsearch-algorithms-identify-unsorted-lists:\ntext: Identify search algorithms for unsorted lists (sequential search).\n+ curriculum-areas:\n+ - algorithms\nsearch-algorithms-describe-time-size-input:\ntext: Describe how the time taken grows with the size of the input.\n+ curriculum-areas:\n+ - generalising-and-patterns\nsearch-algorithms-explore-probability-value-random-set:\ntext: Explore the probability of finding a particular value in a random set.\n+ curriculum-areas:\n+ - statistics\nsearch-algorithms-explain-range-unsorted-lists:\ntext: Explain the range of the number of guesses for unsorted lists.\n+ curriculum-areas:\n+ - statistics\nsearch-algorithms-identify-sequential-binary:\ntext: Identify search algorithms for sorted and unsorted lists (sequential and binary search).\n+ curriculum-areas:\n+ - algorithms\nsearch-algorithms-explain-decomposition-binary:\ntext: Explain how they used decomposition to divide and conquer when doing a binary search.\n+ curriculum-areas:\n+ - decomposition\nsearch-algorithms-describe-time-size-input-different:\ntext: Describe how the time taken grows with the size of the input, and most importantly how it grows in different ways for two different algorithms.\n+ curriculum-areas:\n+ - generalising-and-patterns\nsearch-algorithms-describe-compare-values:\ntext: Describe how to compare number values for equality and inequality (greater than, less than).\n+ curriculum-areas:\n+ - numeracy\nsearch-algorithms-explain-unsorted-lists:\ntext: Explain the range of the number of guesses for unsorted lists compared to sorted lists.\n-\n+ curriculum-areas:\n+ - statistics\n# UNPLUGGED PROGRAMMING LEARNING OUTCOMES\n" } ]
Python
MIT License
uccser/cs-unplugged
Added learning-outcomes cirriculum areas.
701,852
02.08.2017 16:49:38
-43,200
00ad5eccd5243d10fb91f021ce43668595ca9406
Setup for dockerhub repos and travis and docker multi stage build.
[ { "change_type": "MODIFY", "old_path": ".travis.yml", "new_path": ".travis.yml", "diff": "@@ -12,10 +12,11 @@ install:\njobs:\ninclude:\n- stage: build\n- script: ./csu start\n+ script: ./infrastructure/docker-build.sh\n- stage: test\n- script: ./csu dev test\n+ script: ./csu start\n+ - script: ./csu dev test\n- script: ./csu dev test_backwards\n- script: ./csu dev style\n- script: ./csu dev docs\n" }, { "change_type": "MODIFY", "old_path": "csu", "new_path": "csu", "diff": "@@ -54,7 +54,7 @@ function helpmenu {\n# Start development environment\nfunction start {\nprintf \"Creating systems...\\n\"\n- docker-compose up -d\n+ docker-compose pull --ignore-pull-failures && docker-compose up -d\nprintf \"\\n\"\n# Run helper functions\nupdate\n@@ -183,12 +183,12 @@ function static_scratch {\n# Collecting static files\nfunction collect_static {\nprintf \"\\nCollecting static files...\"\n- docker-compose exec django /docker_venv/bin/python3 ./manage.py collectstatic --no-input --clear\n+ docker-compose exec csu-django /docker_venv/bin/python3 ./manage.py collectstatic --no-input --clear\n}\n# Run shell\nfunction shell {\n- docker-compose exec django bash\n+ docker-compose exec csu-django bash\n}\nfunction shell_help {\nprintf \" shell Open shell to Django folder.\\n\"\n@@ -197,10 +197,10 @@ function shell_help {\n# Run style checks\nfunction style {\nprintf \"Running PEP8 style checker...\\n\"\n- docker-compose exec django /docker_venv/bin/flake8\n+ docker-compose exec csu-django /docker_venv/bin/flake8\npep8_status=$?\nprintf \"\\nRunning Python docstring checker...\\n\"\n- docker-compose exec django /docker_venv/bin/pydocstyle --count --explain\n+ docker-compose exec csu-django /docker_venv/bin/pydocstyle --count --explain\npydocstyle_status=$?\n! (( $pep8_status || $pydocstyle_status ))\n}\n@@ -211,7 +211,7 @@ function style_help {\n# Run test suite\nfunction test_suite {\nprintf \"Running test suite...\\n\"\n- docker-compose exec django /docker_venv/bin/coverage run --rcfile=/cs-unplugged/.coveragerc ./manage.py test --settings=config.settings.testing --pattern \"test_*.py\" -v 3\n+ docker-compose exec csu-django /docker_venv/bin/coverage run --rcfile=/cs-unplugged/.coveragerc ./manage.py test --settings=config.settings.testing --pattern \"test_*.py\" -v 3\n}\nfunction test_suite_help {\nprintf \" test Run test suite with code coverage.\\n\"\n@@ -220,7 +220,7 @@ function test_suite_help {\n# Run specific test suite\nfunction test_specific {\nprintf \"Running specific test suite...\\n\"\n- docker-compose exec django /docker_venv/bin/python3 ./manage.py test --settings=config.settings.testing \"${1}\" -v 3\n+ docker-compose exec csu-django /docker_venv/bin/python3 ./manage.py test --settings=config.settings.testing \"${1}\" -v 3\n}\nfunction test_specific_help {\nprintf \" test_specific Run specific test suite. Pass in parameter\\n\"\n@@ -230,8 +230,8 @@ function test_specific_help {\n# Display test coverage table\nfunction test_coverage {\nprintf \"Displaying test suite coverage...\\n\"\n- docker-compose exec django /docker_venv/bin/coverage xml -i\n- docker-compose exec django /docker_venv/bin/coverage report -m --skip-covered\n+ docker-compose exec csu-django /docker_venv/bin/coverage xml -i\n+ docker-compose exec csu-django /docker_venv/bin/coverage report -m --skip-covered\n}\nfunction test_coverage_help {\nprintf \" test_coverage Display code coverage report.\\n\"\n@@ -242,7 +242,7 @@ function test_suite_backwards {\nprintf \"Running test suite backwards...\\n\"\nif [ \"$TRAVIS_PULL_REQUEST\" != \"false\" ]\nthen\n- docker-compose exec django /docker_venv/bin/python3 ./manage.py test --settings=config.settings.testing --pattern \"test_*.py\" --reverse -v 0\n+ docker-compose exec csu-django /docker_venv/bin/python3 ./manage.py test --settings=config.settings.testing --pattern \"test_*.py\" --reverse -v 0\nfi\n}\nfunction test_suite_backwards_help {\n" }, { "change_type": "MODIFY", "old_path": "docker-compose.yml", "new_path": "docker-compose.yml", "diff": "@@ -4,10 +4,11 @@ services:\nrestart: always\nimage: postgres\n- django:\n+ csu-django:\nbuild:\ncontext: .\ndockerfile: ./Dockerfile-local\n+ image: uccser/csu-django:local-2.0.0-alpha.4\ncommand: /cs-unplugged/csunplugged/docker-development-entrypoint.sh\nvolumes:\n- .:/cs-unplugged\n@@ -19,14 +20,15 @@ services:\ndepends_on:\n- postgres\n- nginx:\n+ csu-nginx:\nbuild:\ncontext: .\ndockerfile: ./infrastructure/nginx/Dockerfile\n+ image: uccser/csu-nginx:1.0.1\nvolumes:\n- ./csunplugged/:/app/\n- /app/node_modules\ndepends_on:\n- - django\n+ - csu-django\nports:\n- \"80:80\"\n" }, { "change_type": "ADD", "old_path": null, "new_path": "infrastructure/docker-build.sh", "diff": "+#!/bin/bash\n+\n+docker login -u=\"$DOCKER_USERNAME\" -p=\"$DOCKER_PASSWORD\"\n+docker-compose build\n+\n+django_image=\"csu-django\"\n+django_version=\"local-2.0.0-alpha.4\"\n+\n+nginx_image=\"csu-nginx\"\n+nginx_version=\"1.0.1\"\n+\n+docker tag $DOCKER_USERNAME/$django_image:$django_version $DOCKER_USERNAME/$django_image:latest\n+docker tag $DOCKER_USERNAME/$nginx_image:$nginx_version $DOCKER_USERNAME/$nginx_image:latest\n+\n+# push it\n+docker push $DOCKER_USERNAME/$django_image:latest\n+docker push $DOCKER_USERNAME/$django_image:$django_version\n+\n+docker push $DOCKER_USERNAME/$nginx_image:latest\n+docker push $DOCKER_USERNAME/$nginx_image:$nginx_version\n" } ]
Python
MIT License
uccser/cs-unplugged
Setup for dockerhub repos and travis and docker multi stage build.
701,852
02.08.2017 17:08:30
-43,200
d9f36dff5c360ad332c0ee3b25518f2d4bb004f6
Trying to figure out multiple sequential scripts within a stage.
[ { "change_type": "MODIFY", "old_path": ".travis.yml", "new_path": ".travis.yml", "diff": "@@ -15,11 +15,12 @@ jobs:\nscript: ./infrastructure/docker-build.sh\n- stage: test\n- script: ./csu start\n- - script: ./csu dev test\n- - script: ./csu dev test_backwards\n- - script: ./csu dev style\n- - script: ./csu dev docs\n+ script:\n+ - ./csu start\n+ - ./csu dev test\n+ - ./csu dev test_backwards\n+ - ./csu dev style\n+ - ./csu dev docs\n- stage: deploy\nscript: skip\n" } ]
Python
MIT License
uccser/cs-unplugged
Trying to figure out multiple sequential scripts within a stage.
701,852
04.08.2017 18:03:53
-43,200
00b14f9c4daa8e66479afc6f1bb02c41b483a8f1
Change to use our base-docker files and parallelise scripts.
[ { "change_type": "MODIFY", "old_path": ".travis.yml", "new_path": ".travis.yml", "diff": "@@ -16,11 +16,11 @@ jobs:\n- stage: test\nscript:\n- - ./csu start\n- - ./csu dev test\n- - ./csu dev test_backwards\n- - ./csu dev style\n- - ./csu dev docs\n+ - script: ./csu start\n+ - script: ./csu dev test\n+ - script: ./csu dev test_backwards\n+ - script: ./csu dev style\n+ - script: ./csu dev docs\n- stage: deploy\nscript: skip\n" }, { "change_type": "MODIFY", "old_path": "Dockerfile", "new_path": "Dockerfile", "diff": "# This Dockerfile is based off the Google App Engine Python runtime image\n# https://github.com/GoogleCloudPlatform/python-runtime\n-FROM gcr.io/google-appengine/python\n+FROM uccser/django:1.11.4\n# Add metadata to Docker image\nLABEL maintainer=\"csse-education-research@canterbury.ac.nz\"\n# Set terminal to be noninteractive\nARG DEBIAN_FRONTEND=noninteractive\n-\nENV DJANGO_PRODUCTION=True\n-# Install packages, running of Python 3.4.2\n-RUN apt-get update && apt-get install -y \\\n- python3 \\\n- python3-dev \\\n- python3-pip\n-RUN apt-get clean && rm /var/lib/apt/lists/*_*\n-\nEXPOSE 8080\nRUN mkdir /csunplugged\nWORKDIR /csunplugged\n# Copy and install Python dependencies\n-RUN python -m virtualenv --python=python3.4 /docker_venv\nCOPY requirements /requirements\nRUN /docker_venv/bin/pip3 install -r /requirements/production.txt\n" }, { "change_type": "MODIFY", "old_path": "Dockerfile-local", "new_path": "Dockerfile-local", "diff": "# This Dockerfile is based off the Google App Engine Python runtime image\n# https://github.com/GoogleCloudPlatform/python-runtime\n-FROM gcr.io/google-appengine/python\n+FROM uccser/django:1.11.4-with-weasyprint\n# Add metadata to Docker image\nLABEL maintainer=\"csse-education-research@canterbury.ac.nz\"\n@@ -9,54 +9,10 @@ LABEL maintainer=\"csse-education-research@canterbury.ac.nz\"\nARG DEBIAN_FRONTEND=noninteractive\nENV DJANGO_PRODUCTION=False\n-\n-# Install custom Pango version\n-\n-# Install FreeType2 then HarfBuzz then reinstall FreeType2\n-RUN apt-get update && apt-get install -y \\\n- bzip2 \\\n- gperf \\\n- libbz2-dev \\\n- libffi-dev \\\n- libtinfo-dev \\\n- libmount-dev \\\n- libicu52 \\\n- libpcre3 \\\n- libglib2.0-dev \\\n- libgdk-pixbuf2.0-dev \\\n- libcairo2-dev\n-\n-RUN mkdir /pango-install/\n-COPY ./csunplugged/pango-install.sh /pango-install/\n-RUN chmod +x /pango-install/pango-install.sh\n-RUN /pango-install/pango-install.sh\n-\n-# Install packages (including Weasyprint dependencies), running of Python 3.4.2\n-RUN apt-get update && apt-get install -y \\\n- python3 \\\n- python3-dev \\\n- python3-pip \\\n- python-dev \\\n- python-pip \\\n- python-lxml \\\n- python-cffi \\\n- fontconfig \\\n- shared-mime-info\n-RUN apt-get clean && rm /var/lib/apt/lists/*_*\n-\nEXPOSE 8080\n# Copy and create virtual environment\nCOPY requirements /requirements\n-RUN python -m virtualenv --python=python3.4 /docker_venv\n-\n-# Install Weasyprint dependencies\n-RUN /docker_venv/bin/pip3 install -U pip setuptools\n-RUN /docker_venv/bin/pip3 install packaging==16.8\n-RUN /docker_venv/bin/pip3 install appdirs==1.4.3\n-RUN /docker_venv/bin/pip3 install html5lib==1.0b9\n-RUN /docker_venv/bin/pip3 install six==1.10.0\n-RUN /docker_venv/bin/pip3 install weasyprint==0.36\n# Install dependencies\nRUN /docker_venv/bin/pip3 install -r /requirements/local.txt\n" }, { "change_type": "MODIFY", "old_path": "csu", "new_path": "csu", "diff": "@@ -54,7 +54,7 @@ function helpmenu {\n# Start development environment\nfunction start {\nprintf \"Creating systems...\\n\"\n- docker-compose pull --ignore-pull-failures && docker-compose up -d\n+ docker-compose up -d\nprintf \"\\n\"\n# Run helper functions\nupdate\n@@ -183,12 +183,12 @@ function static_scratch {\n# Collecting static files\nfunction collect_static {\nprintf \"\\nCollecting static files...\"\n- docker-compose exec csu-django /docker_venv/bin/python3 ./manage.py collectstatic --no-input --clear\n+ docker-compose exec django /docker_venv/bin/python3 ./manage.py collectstatic --no-input --clear\n}\n# Run shell\nfunction shell {\n- docker-compose exec csu-django bash\n+ docker-compose exec django bash\n}\nfunction shell_help {\nprintf \" shell Open shell to Django folder.\\n\"\n@@ -197,10 +197,10 @@ function shell_help {\n# Run style checks\nfunction style {\nprintf \"Running PEP8 style checker...\\n\"\n- docker-compose exec csu-django /docker_venv/bin/flake8\n+ docker-compose exec django /docker_venv/bin/flake8\npep8_status=$?\nprintf \"\\nRunning Python docstring checker...\\n\"\n- docker-compose exec csu-django /docker_venv/bin/pydocstyle --count --explain\n+ docker-compose exec django /docker_venv/bin/pydocstyle --count --explain\npydocstyle_status=$?\n! (( $pep8_status || $pydocstyle_status ))\n}\n@@ -211,7 +211,7 @@ function style_help {\n# Run test suite\nfunction test_suite {\nprintf \"Running test suite...\\n\"\n- docker-compose exec csu-django /docker_venv/bin/coverage run --rcfile=/cs-unplugged/.coveragerc ./manage.py test --settings=config.settings.testing --pattern \"test_*.py\" -v 3\n+ docker-compose exec django /docker_venv/bin/coverage run --rcfile=/cs-unplugged/.coveragerc ./manage.py test --settings=config.settings.testing --pattern \"test_*.py\" -v 3\n}\nfunction test_suite_help {\nprintf \" test Run test suite with code coverage.\\n\"\n@@ -220,7 +220,7 @@ function test_suite_help {\n# Run specific test suite\nfunction test_specific {\nprintf \"Running specific test suite...\\n\"\n- docker-compose exec csu-django /docker_venv/bin/python3 ./manage.py test --settings=config.settings.testing \"${1}\" -v 3\n+ docker-compose exec django /docker_venv/bin/python3 ./manage.py test --settings=config.settings.testing \"${1}\" -v 3\n}\nfunction test_specific_help {\nprintf \" test_specific Run specific test suite. Pass in parameter\\n\"\n@@ -230,8 +230,8 @@ function test_specific_help {\n# Display test coverage table\nfunction test_coverage {\nprintf \"Displaying test suite coverage...\\n\"\n- docker-compose exec csu-django /docker_venv/bin/coverage xml -i\n- docker-compose exec csu-django /docker_venv/bin/coverage report -m --skip-covered\n+ docker-compose exec django /docker_venv/bin/coverage xml -i\n+ docker-compose exec django /docker_venv/bin/coverage report -m --skip-covered\n}\nfunction test_coverage_help {\nprintf \" test_coverage Display code coverage report.\\n\"\n@@ -242,7 +242,7 @@ function test_suite_backwards {\nprintf \"Running test suite backwards...\\n\"\nif [ \"$TRAVIS_PULL_REQUEST\" != \"false\" ]\nthen\n- docker-compose exec csu-django /docker_venv/bin/python3 ./manage.py test --settings=config.settings.testing --pattern \"test_*.py\" --reverse -v 0\n+ docker-compose exec django /docker_venv/bin/python3 ./manage.py test --settings=config.settings.testing --pattern \"test_*.py\" --reverse -v 0\nfi\n}\nfunction test_suite_backwards_help {\n" }, { "change_type": "DELETE", "old_path": "csunplugged/pango-install.sh", "new_path": null, "diff": "-#!/bin/bash\n-cd /pango-install/\n-\n-# Install libpng\n-echo 'Obtaining libpng'\n-wget --quiet http://downloads.sourceforge.net/libpng/libpng-1.6.29.tar.xz\n-tar -xf libpng-1.6.29.tar.xz\n-cd libpng-1.6.29\n-\n-echo 'Configuring libpng'\n-LIBS=-lpthread ./configure --prefix=/usr --disable-static &&\n-make\n-\n-echo 'Installing libpng'\n-make install &&\n-mkdir -v /usr/share/doc/libpng-1.6.29 &&\n-cp -v README libpng-manual.txt /usr/share/doc/libpng-1.6.29\n-cd ..\n-\n-# Install Which\n-echo 'Obtaining Which'\n-wget --quiet ftp://ftp.gnu.org/gnu/which/which-2.21.tar.gz\n-tar -xf which-2.21.tar.gz\n-cd which-2.21\n-\n-echo 'Configuring Which'\n-./configure --prefix=/usr &&\n-make\n-\n-echo 'Installing Which'\n-make install\n-cd ..\n-\n-# Install FreeType\n-echo 'Obtaining FreeType'\n-wget --quiet http://downloads.sourceforge.net/freetype/freetype-2.8.tar.bz2\n-tar -xf freetype-2.8.tar.bz2\n-cd freetype-2.8\n-\n-echo 'Configuring FreeType'\n-sed -ri \"s:.*(AUX_MODULES.*valid):\\1:\" modules.cfg &&\n-sed -r \"s:.*(#.*SUBPIXEL_RENDERING) .*:\\1:\" \\\n- -i include/freetype/config/ftoption.h &&\n-./configure --prefix=/usr --disable-static &&\n-make\n-\n-echo 'Installing FreeType'\n-make install &&\n-install -v -m755 -d /usr/share/doc/freetype-2.8 &&\n-cp -v -R docs/* /usr/share/doc/freetype-2.8\n-cd ..\n-\n-# Install HarfBuzz with FreeType2\n-echo 'Obtaining HarfBuzz'\n-wget --quiet http://www.freedesktop.org/software/harfbuzz/release/harfbuzz-1.4.6.tar.bz2\n-tar -xf harfbuzz-1.4.6.tar.bz2\n-cd harfbuzz-1.4.6\n-\n-echo 'Configuring HarfBuzz'\n-./configure --prefix=/usr --with-gobject &&\n-make\n-\n-echo 'Installing HarfBuzz'\n-make install\n-cd ..\n-\n-# Reinstall FreeType2 with HarfBuzz support\n-echo 'Reinstalling FreeType2'\n-cd freetype-2.8\n-./configure --prefix=/usr --disable-static &&\n-make &&\n-make install &&\n-install -v -m755 -d /usr/share/doc/freetype-2.8 &&\n-cp -v -R docs/* /usr/share/doc/freetype-2.8\n-cd ..\n-\n-# Install Fontconfig-2\n-echo 'Obtaining Fontconfig'\n-wget --quiet http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.12.4.tar.bz2\n-tar -xf fontconfig-2.12.4.tar.bz2\n-cd fontconfig-2.12.4\n-\n-echo 'Configuring Fontconfig'\n-rm -f src/fcobjshash.h\n-./configure --prefix=/usr \\\n- --sysconfdir=/etc \\\n- --localstatedir=/var \\\n- --disable-docs \\\n- --docdir=/usr/share/doc/fontconfig-2.12.4 &&\n-make\n-\n-echo 'Installing Fontconfig'\n-make install\n-cd ..\n-\n-# install Pango-1.40\n-echo 'Obtaining Pango'\n-wget --quiet ftp://ftp.gnome.org/pub/gnome/sources/pango/1.40/pango-1.40.6.tar.xz\n-tar -xf pango-1.40.6.tar.xz\n-cd pango-1.40.6\n-\n-echo 'Configuring Pango'\n-./configure --prefix=/usr --sysconfdir=/etc &&\n-make\n-\n-echo 'Installing Pango'\n-make install\n-\n-cd /\n" }, { "change_type": "MODIFY", "old_path": "docker-compose.yml", "new_path": "docker-compose.yml", "diff": "@@ -4,11 +4,10 @@ services:\nrestart: always\nimage: postgres\n- csu-django:\n+ django:\nbuild:\ncontext: .\ndockerfile: ./Dockerfile-local\n- image: uccser/csu-django:local-2.0.0-alpha.4\ncommand: /cs-unplugged/csunplugged/docker-development-entrypoint.sh\nvolumes:\n- .:/cs-unplugged\n@@ -20,15 +19,14 @@ services:\ndepends_on:\n- postgres\n- csu-nginx:\n+ nginx:\nbuild:\ncontext: .\ndockerfile: ./infrastructure/nginx/Dockerfile\n- image: uccser/csu-nginx:1.0.1\nvolumes:\n- ./csunplugged/:/app/\n- /app/node_modules\ndepends_on:\n- - csu-django\n+ - django\nports:\n- \"80:80\"\n" }, { "change_type": "DELETE", "old_path": "infrastructure/docker-build.sh", "new_path": null, "diff": "-#!/bin/bash\n-\n-docker login -u=\"$DOCKER_USERNAME\" -p=\"$DOCKER_PASSWORD\"\n-docker-compose build\n-\n-django_image=\"csu-django\"\n-django_version=\"local-2.0.0-alpha.4\"\n-\n-nginx_image=\"csu-nginx\"\n-nginx_version=\"1.0.1\"\n-\n-docker tag $DOCKER_USERNAME/$django_image:$django_version $DOCKER_USERNAME/$django_image:latest\n-docker tag $DOCKER_USERNAME/$nginx_image:$nginx_version $DOCKER_USERNAME/$nginx_image:latest\n-\n-# push it\n-docker push $DOCKER_USERNAME/$django_image:latest\n-docker push $DOCKER_USERNAME/$django_image:$django_version\n-\n-docker push $DOCKER_USERNAME/$nginx_image:latest\n-docker push $DOCKER_USERNAME/$nginx_image:$nginx_version\n" }, { "change_type": "MODIFY", "old_path": "infrastructure/nginx/Dockerfile", "new_path": "infrastructure/nginx/Dockerfile", "diff": "-FROM nginx:latest\n+FROM uccser/nginx-with-gulp:1.13.3\n-# Populate sources with closest neighbours\n-# Resolves issues with failing builds, should be removed in future\n-RUN apt-get update \\\n- && apt-get install -y netselect-apt --no-install-suggests \\\n- && netselect-apt stretch \\\n- && echo deb http://security.debian.org/debian-security stretch/updates main >> sources.list \\\n- && mv sources.list /etc/apt/sources.list\n-\n-# Install Node.js and other dependencies\n-RUN apt-get update \\\n- && apt-get install --no-install-suggests -y \\\n- curl \\\n- gnupg2 \\\n- python \\\n- build-essential \\\n- && curl -sL https://deb.nodesource.com/setup_6.x | bash - \\\n- && apt-get install --no-install-suggests -y \\\n- nodejs \\\n- && apt-get remove --purge -y gnupg2 && apt-get -y --purge autoremove \\\n- && rm -rf /var/lib/apt/lists/*\n-\n-WORKDIR /app\n-RUN npm install --global gulp-cli node-gyp\nRUN apt-get update \\\n&& apt-get install --no-install-suggests -y \\\nlibcairo2-dev \\\n- libjpeg-dev \\\nlibpango1.0-dev \\\n+ libjpeg-dev \\\nlibgif-dev \\\n- g++ \\\n&& rm -rf /var/lib/apt/lists/*\nADD csunplugged/package.json /app/\n" } ]
Python
MIT License
uccser/cs-unplugged
Change to use our base-docker files and parallelise scripts.
701,852
04.08.2017 18:17:50
-43,200
a2473f1e130525fcdf5b82783a3eefddca768945
Add continuous integration commands to csu script.
[ { "change_type": "MODIFY", "old_path": ".travis.yml", "new_path": ".travis.yml", "diff": "@@ -11,16 +11,11 @@ install:\n- sudo docker-compose --version\njobs:\ninclude:\n- - stage: build\n- script: ./infrastructure/docker-build.sh\n-\n- stage: test\n- script:\n- - script: ./csu start\n- - script: ./csu dev test\n- - script: ./csu dev test_backwards\n- - script: ./csu dev style\n- - script: ./csu dev docs\n+ - script: ./csu ci test_with_coverage\n+ - script: ./csu ci test_backwards\n+ - script: ./csu ci style\n+ - script: ./csu ci docs\n- stage: deploy\nscript: skip\n@@ -35,9 +30,6 @@ jobs:\nskip_cleanup: true\non:\nbranch: master\n-after_script:\n- - \"./csu dev test_coverage\"\n- - bash <(curl -s https://codecov.io/bash)\nnotifications:\nemail: false\nslack:\n" }, { "change_type": "MODIFY", "old_path": "csu", "new_path": "csu", "diff": "@@ -294,6 +294,40 @@ function logs_help {\nprintf \" logs View logs.\\n\"\n}\n+function process_ci_command() {\n+ if [ $# -lt 1 ]\n+ then\n+ printf \"${RED}ERROR: ci command requires one parameter!${NC}\\n\"\n+ helpmenu\n+ exit 1\n+ else\n+ case \"$1\" in\n+ docs)\n+ docker-compose up -d\n+ documentation\n+ exit\n+ ;;\n+ style)\n+ docker-compose up -d\n+ style\n+ exit\n+ ;;\n+ test_with_coverage)\n+ docker-compose up -d\n+ test_suite\n+ test_coverage\n+ bash <(curl -s https://codecov.io/bash)\n+ exit\n+ ;;\n+ test_backwards)\n+ docker-compose up -d\n+ test_suite_backwards\n+ exit\n+ ;;\n+ esac\n+ fi\n+}\n+\nfunction process_dev_command() {\nif [ $# -lt 1 ]\nthen\n@@ -387,6 +421,9 @@ case \"$1\" in\nclean\nexit\n;;\n+ ci)\n+ process_ci_command $2\n+ ;;\ndev)\nprocess_dev_command $2 $3\n;;\n" } ]
Python
MIT License
uccser/cs-unplugged
Add continuous integration commands to csu script.
701,852
04.08.2017 18:23:22
-43,200
52f4e508efb043479d3b5a7d6a4ee360855ab731
fix issue in travis file.
[ { "change_type": "MODIFY", "old_path": ".travis.yml", "new_path": ".travis.yml", "diff": "@@ -12,7 +12,7 @@ install:\njobs:\ninclude:\n- stage: test\n- - script: ./csu ci test_with_coverage\n+ script: ./csu ci test_with_coverage\n- script: ./csu ci test_backwards\n- script: ./csu ci style\n- script: ./csu ci docs\n" } ]
Python
MIT License
uccser/cs-unplugged
fix issue in travis file.
701,852
04.08.2017 19:39:59
-43,200
73cecc859653e6e777f41de5788b7b00de94a0c2
Fix test_backwards to ensure correct error status.
[ { "change_type": "MODIFY", "old_path": "csu", "new_path": "csu", "diff": "@@ -240,10 +240,12 @@ function test_coverage_help {\n# Run test suite backwards for CI testing\nfunction test_suite_backwards {\nprintf \"Running test suite backwards...\\n\"\n- if [ \"$TRAVIS_PULL_REQUEST\" != \"false\" ]\n- then\n+ status=0\n+ if [ \"$TRAVIS_PULL_REQUEST\" != \"false\" ]; then\ndocker-compose exec django /docker_venv/bin/python3 ./manage.py test --settings=config.settings.testing --pattern \"test_*.py\" --reverse -v 0\n+ status=$?\nfi\n+ ! (( ${status} ))\n}\nfunction test_suite_backwards_help {\nprintf \" test_backwards Run test suite backwards.\\n\"\n" } ]
Python
MIT License
uccser/cs-unplugged
Fix test_backwards to ensure correct error status.
701,852
04.08.2017 19:49:00
-43,200
3fe7c975dfae64d54d1cc45c0932067cc750acea
try a sequential build to test speed.
[ { "change_type": "MODIFY", "old_path": ".travis.yml", "new_path": ".travis.yml", "diff": "@@ -9,15 +9,12 @@ python:\ninstall:\n- sudo docker --version\n- sudo docker-compose --version\n-jobs:\n- include:\n- - stage: test\n- script: ./csu ci test_with_coverage\n- - script: ./csu ci test_backwards\n- - script: ./csu ci style\n- - script: ./csu ci docs\n-\n- - stage: deploy\n+script:\n+ - ./csu ci test_with_coverage\n+ - ./csu ci test_backwards\n+ - ./csu ci style\n+ - ./csu ci docs\n+deploy:\nscript: skip\ndeploy:\n- provider: script\n" }, { "change_type": "MODIFY", "old_path": "csu", "new_path": "csu", "diff": "@@ -316,24 +316,18 @@ function process_ci_command() {\nelse\ncase \"$1\" in\ndocs)\n- docker-compose up -d\ndocumentation\nexit\n;;\nstyle)\n- docker-compose up -d\nstyle\nexit\n;;\ntest_with_coverage)\n- docker-compose up -d\n- update\ntest_with_coverage\nexit\n;;\ntest_backwards)\n- docker-compose up -d\n- update\ntest_suite_backwards\nexit\n;;\n" }, { "change_type": "MODIFY", "old_path": "infrastructure/dev-deploy/dev-deploy.sh", "new_path": "infrastructure/dev-deploy/dev-deploy.sh", "diff": "#!/bin/bash\n# Deploy the system to the development website.\n-./csu start\n# Generate production static files\n./csu dev static_prod\n" } ]
Python
MIT License
uccser/cs-unplugged
try a sequential build to test speed.
701,852
04.08.2017 20:54:04
-43,200
ad82a72984814a3c920466bebfa5c271918b6f61
Tidy travis config, and remove unncessary line from prod deploy.
[ { "change_type": "MODIFY", "old_path": ".travis.yml", "new_path": ".travis.yml", "diff": "@@ -9,14 +9,13 @@ python:\ninstall:\n- sudo docker --version\n- sudo docker-compose --version\n-script:\n+before_script:\n- ./csu start\n+script:\n- ./csu ci test_with_coverage\n- ./csu ci test_backwards\n- ./csu ci style\n- ./csu ci docs\n-deploy:\n- script: skip\ndeploy:\n- provider: script\nscript: bash ./infrastructure/dev-deploy/dev-deploy.sh\n" }, { "change_type": "MODIFY", "old_path": "infrastructure/prod-deploy/prod-deploy.sh", "new_path": "infrastructure/prod-deploy/prod-deploy.sh", "diff": "#!/bin/bash\n# Deploy the system to the production website.\n-./csu start\n# Generate production static files\n./csu dev static_prod\n" } ]
Python
MIT License
uccser/cs-unplugged
Tidy travis config, and remove unncessary line from prod deploy.
701,845
08.08.2017 16:28:34
-43,200
8cb2d66ad40a43ada3f0f5a7f958b88ce0e90778
Made csu script more script-y
[ { "change_type": "MODIFY", "old_path": "csu", "new_path": "csu", "diff": "# - When 'start' is run open website in default browser without creating\n# new terminal prompt.\n-# Constants\n+set -e\n+\nRED='\\033[0;31m'\nGREEN='\\033[0;32m'\nNC='\\033[0m' # No Color\n-# Print out help information\n-function helpmenu {\n- printf \"Script for performing tasks related to the CS Unplugged repository.\\n\\n\"\n- printf \"Usage: ./csu [COMMAND]\\n\"\n- printf \"Replace [COMMAND] with a word from the list below.\\n\\n\"\n- printf \"COMMAND list:\\n\"\n- build_help\n- clean_help\n- printf \" dev [DEV_COMMAND] Run a developer command.\\n\"\n- end_help\n- printf \" help View all help.\\n\"\n- restart_help\n- start_help\n- update_help\n- wipe_help\n- printf \"\\nDEV_COMMAND list:\\n\"\n- documentation_help\n- flush_help\n- logs_help\n- makemigrations_help\n- makeresources_help\n- migrate_help\n- shell_help\n- static_help\n- static_prod_help\n- style_help\n- test_suite_help\n- test_suite_backwards_help\n- test_coverage_help\n- test_specific_help\n- updatedata_help\n+cmd_helps=()\n+dev_cmd_helps=()\n+\n+defhelp() {\n+ if [ \"$1\" = '-dev' ]; then\n+ local command=\"${2?}\"\n+ local text=\"${3?}\"\n+ local help_str\n+ help_str=\"$(printf ' %-18s %s' \"$command\" \"$text\")\"\n+ dev_cmd_helps+=(\"$help_str\")\n+ else\n+ local command=\"${1?}\"\n+ local text=\"${2?}\"\n+ local help_str\n+ help_str=\"$(printf ' %-18s %s' \"$command\" \"$text\")\"\n+ cmd_helps+=(\"$help_str\")\n+ fi\n}\n+# Print out help information\n+cmd_help() {\n+ echo \"Script for performing tasks related to the CS Unplugged repository.\"\n+ echo\n+ echo \"Usage: ./csu [COMMAND]\"\n+ echo \"Replace [COMMAND] with a word from the list below.\"\n+ echo\n+ echo \"COMMAND list:\"\n+ for str in \"${cmd_helps[@]}\"; do\n+ echo -e \"$str\"\n+ done\n+ echo\n+ echo \"DEV_COMMAND list:\"\n+ for str in \"${dev_cmd_helps[@]}\"; do\n+ echo -e \"$str\"\n+ done\n+}\n+\n+defhelp help 'View all help.'\n+defhelp 'dev [DEV_COMMAND]' 'Run a developer command.'\n+\n# Start development environment\n-function start {\n- printf \"Creating systems...\\n\"\n+cmd_start() {\n+ echo \"Creating systems...\"\ndocker-compose up -d\n- printf \"\\n\"\n+ echo \"\"\n# Run helper functions\n- update\n+ cmd_update\n# Alert user that system is ready\n- printf \"\\n${GREEN}Systems are ready!${NC}\\n\"\n- printf \"Open your preferred web browser to the URL 'localhost'\\n\"\n-}\n-function start_help {\n- printf \" start Start development environment (this also runs\\n\"\n- printf \" the update command).\\n\"\n+ echo -e \"\\n${GREEN}Systems are ready!${NC}\"\n+ echo \"Open your preferred web browser to the URL 'localhost'\"\n}\n+defhelp start 'Start development environment (this also runs the update command).'\n+\n# Stop development environment\n-function end {\n- printf \"Stopping systems... (takes roughly 10 to 20 seconds)\\n\"\n+cmd_end() {\n+ echo \"Stopping systems... (takes roughly 10 to 20 seconds)\"\ndocker-compose down\n- printf \"\\nDeleting system volumes...\\n\"\n+ echo\n+ echo \"Deleting system volumes...\"\ndocker volume ls -qf dangling=true | xargs -r docker volume rm\n}\n-function end_help {\n- printf \" end Stop development environment.\\n\"\n-}\n+defhelp end 'Stop development environment.'\n-# Stop and then restart development environment\n-function restart_help {\n- printf \" restart Stop and then restart development environment.\\n\"\n+cmd_restart() {\n+ cmd_end\n+ cmd_start\n}\n+defhelp restart 'Stop and then restart development environment.'\n# Run Django migrate and updatedata commands\n-function update {\n- static\n+cmd_update() {\n+ cmd_static\n- printf \"\\n\"\n- migrate\n+ echo \"\"\n+ cmd_migrate\n- printf \"\\n\"\n- updatedata\n+ echo \"\"\n+ cmd_updatedata\n- static_scratch\n- collect_static\n-}\n-function update_help {\n- printf \" update Run Django migrate and updatedata commands\\n\"\n- printf \" and build static files.\\n\"\n+ cmd_static_scratch\n+ cmd_collect_static\n}\n+defhelp update 'Run Django migrate and updatedata commands and build static files.'\n# Run Django flush command\n-function flush {\n+dev_flush() {\ndocker-compose exec django /docker_venv/bin/python3 ./manage.py flush\n}\n-function flush_help {\n- printf \" flush Run Django flush command.\\n\"\n-}\n+defhelp -dev flush 'Run Django flush command.'\n# Run Django makemigrations command\n-function makemigrations {\n- printf \"Creating database migrations...\\n\"\n+dev_makemigrations() {\n+ echo \"Creating database migrations...\"\ndocker-compose exec django /docker_venv/bin/python3 ./manage.py makemigrations\n}\n-function makemigrations_help {\n- printf \" makemigrations Run Django makemigrations command.\\n\"\n-}\n+defhelp -dev makemigrations 'Run Django makemigrations command.'\n# Run Django makeresources command\n-function makeresources {\n- printf \"Creating static resource PDFs...\\n\"\n+dev_makeresources() {\n+ echo \"Creating static resource PDFs...\"\ndocker-compose exec django /docker_venv/bin/python3 ./manage.py makeresources\n}\n-function makeresources_help {\n- printf \" makeresources Run Django makeresources command.\\n\"\n-}\n+defhelp -dev makeresources 'Run Django makeresources command.'\n# Run Django migrate command\n-function migrate {\n- printf \"Applying database migrations...\\n\"\n+dev_migrate() {\n+ echo \"Applying database migrations...\"\ndocker-compose exec django /docker_venv/bin/python3 ./manage.py migrate\n}\n-function migrate_help {\n- printf \" migrate Run Django migrate command.\\n\"\n-}\n+defhelp -dev migrate 'Run Django migrate command.'\n# Run Django updatedata command\n-function updatedata {\n- printf \"Loading topics content...\\n\"\n+dev_updatedata() {\n+ echo \"Loading topics content...\"\ndocker-compose exec django /docker_venv/bin/python3 ./manage.py updatedata\n}\n-function updatedata_help {\n- printf \" updatedata Run updatedata command.\\n\"\n-}\n+defhelp -dev updatedata 'Run updatedata command.'\n# Build Docker images\n-function build {\n- printf \"Building Docker images...\\n\"\n+dev_build() {\n+ echo \"Building Docker images...\"\ndocker-compose build\n- printf \"\\nDeleting untagged images...\\n\"\n+ echo\n+ echo \"Deleting untagged images...\"\ndocker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi\n}\n-function build_help {\n- printf \" build Build or rebuild Docker images.\\n\"\n-}\n+defhelp -dev build 'Build or rebuild Docker images.'\n# Build static files\n-function static {\n- printf \"Building static files...\\n\"\n+dev_static() {\n+ echo \"Building static files...\"\ndocker-compose exec nginx gulp build\n}\n-function static_help {\n- printf \" static Build static files.\\n\"\n-}\n+defhelp -dev static 'Build static files.'\n# Build production static files\n-function static_prod {\n- printf \"Building production static files...\\n\"\n+dev_static_prod() {\n+ echo \"Building production static files...\"\ndocker-compose exec nginx gulp build --production\n}\n-function static_prod_help {\n- printf \" static_prod Build production static files.\\n\"\n-}\n+defhelp -dev static_prod 'Build production static files.'\n# Build scratch static files\n-function static_scratch {\n- printf \"Building scratch images...\\n\"\n+cmd_static_scratch() {\n+ echo \"Building scratch images...\"\ndocker-compose exec nginx gulp scratch\n}\n# Collecting static files\n-function collect_static {\n- printf \"\\nCollecting static files...\"\n+cmd_collect_static() {\n+ echo\n+ echo \"Collecting static files.\"\ndocker-compose exec django /docker_venv/bin/python3 ./manage.py collectstatic --no-input --clear\n}\n# Run shell\n-function shell {\n+dev_shell() {\ndocker-compose exec django bash\n}\n-function shell_help {\n- printf \" shell Open shell to Django folder.\\n\"\n-}\n+defhelp -dev shell 'Open shell to Django folder.'\n# Run style checks\n-function style {\n- printf \"Running PEP8 style checker...\\n\"\n+dev_style() {\n+ echo \"Running PEP8 style checker...\"\ndocker-compose exec django /docker_venv/bin/flake8\npep8_status=$?\n- printf \"\\nRunning Python docstring checker...\\n\"\n+ echo\n+ echo \"Running Python docstring checker...\"\ndocker-compose exec django /docker_venv/bin/pydocstyle --count --explain\npydocstyle_status=$?\n- ! (( $pep8_status || $pydocstyle_status ))\n-}\n-function style_help {\n- printf \" style Run style checks.\\n\"\n+ ! (( pep8_status || pydocstyle_status ))\n}\n+defhelp -dev style 'Run style checks.'\n# Run test suite\n-function test_suite {\n- printf \"Running test suite...\\n\"\n+dev_test_suite() {\n+ echo \"Running test suite...\"\ndocker-compose exec django /docker_venv/bin/coverage run --rcfile=/cs-unplugged/.coveragerc ./manage.py test --settings=config.settings.testing --pattern \"test_*.py\" -v 3\n}\n-function test_suite_help {\n- printf \" test Run test suite with code coverage.\\n\"\n-}\n+defhelp -dev test 'Run test suite with code coverage.'\n# Run specific test suite\n-function test_specific {\n- printf \"Running specific test suite...\\n\"\n+dev_test_specific() {\n+ echo \"Running specific test suite...\"\ndocker-compose exec django /docker_venv/bin/python3 ./manage.py test --settings=config.settings.testing \"${1}\" -v 3\n}\n-function test_specific_help {\n- printf \" test_specific Run specific test suite. Pass in parameter\\n\"\n- printf \" of Python test module.\\n\"\n-}\n+defhelp -dev test_specific 'Run specific test suite. Pass in parameter of Python test module.'\n# Display test coverage table\n-function test_coverage {\n- printf \"Displaying test suite coverage...\\n\"\n+dev_test_coverage() {\n+ echo \"Displaying test suite coverage...\"\ndocker-compose exec django /docker_venv/bin/coverage xml -i\ndocker-compose exec django /docker_venv/bin/coverage report -m --skip-covered\n}\n-function test_coverage_help {\n- printf \" test_coverage Display code coverage report.\\n\"\n-}\n+defhelp -dev test_coverage 'Display code coverage report.'\n# Run test suite backwards for CI testing\n-function test_suite_backwards {\n- printf \"Running test suite backwards...\\n\"\n- if [ \"$TRAVIS_PULL_REQUEST\" != \"false\" ]\n- then\n+dev_test_suite_backwards() {\n+ echo \"Running test suite backwards...\"\n+ if [ \"$TRAVIS_PULL_REQUEST\" != \"false\" ]; then\ndocker-compose exec django /docker_venv/bin/python3 ./manage.py test --settings=config.settings.testing --pattern \"test_*.py\" --reverse -v 0\nfi\n}\n-function test_suite_backwards_help {\n- printf \" test_backwards Run test suite backwards.\\n\"\n-}\n+defhelp -dev test_suite_backwards 'Run test suite backwards.'\n# Generates the documentation (with warnings as errors)\n-function documentation {\n- printf \"Removing any existing documentation...\\n\"\n+dev_docs() {\n+ echo \"Removing any existing documentation...\"\ndocker-compose exec django rm -rf /cs-unplugged/docs/build/\ndocker-compose exec django mkdir /cs-unplugged/docs/build/\n- printf \"\\nCreating documentation...\\n\"\n+ echo\n+ echo \"Creating documentation...\"\ndocker-compose exec django /docker_venv/bin/sphinx-build -W /cs-unplugged/docs/source/ /cs-unplugged/docs/build/\n}\n-function documentation_help {\n- printf \" docs Generate documentation.\\n\"\n-}\n+defhelp -dev docs 'Generate documentation.'\n# Delete all untagged dangling Docker images\n-function clean {\n- printf \"If the following commands return an argument not found error,\\n\"\n- printf \"this is because there is nothing to delete for clean up.\\n\"\n+cmd_clean() {\n+ echo \"If the following commands return an argument not found error,\"\n+ echo \"this is because there is nothing to delete for clean up.\"\n- printf \"\\nDeleting unused volumes...\\n\"\n+ echo\n+ echo \"Deleting unused volumes...\"\ndocker volume ls -qf dangling=true | xargs -r docker volume rm\n- printf \"\\nDeleting exited containers...\\n\"\n+ echo\n+ echo \"Deleting exited containers...\"\ndocker ps --filter status=dead --filter status=exited -aq | xargs docker rm -v\n- printf \"\\nDeleting dangling images...\\n\"\n- docker rmi $(docker images -f \"dangling=true\" -q)\n-}\n-function clean_help {\n- printf \" clean Delete unused Docker files.\\n\"\n+ echo\n+ echo \"Deleting dangling images...\"\n+ docker images -f \"dangling=true\" -q | xargs docker rmi\n}\n+defhelp clean 'Delete unused Docker files.'\n# Delete all Docker containers and images\n-function wipe {\n- docker rm $(docker ps -a -q)\n- docker rmi $(docker images -q)\n-}\n-function wipe_help {\n- printf \" wipe Delete all Docker containers and images.\\n\"\n+cmd_wipe() {\n+ docker ps -a -q | xargs docker rm\n+ docker images -q | xargs docker rmi\n}\n+defhelp wipe 'Delete all Docker containers and images.'\n# View logs\n-function logs {\n+cmd_logs() {\ndocker-compose logs\n}\n-function logs_help {\n- printf \" logs View logs.\\n\"\n+defhelp logs 'View logs.'\n+\n+silent() {\n+ \"$@\" > /dev/null 2>&1\n}\n-function process_dev_command() {\n- if [ $# -lt 1 ]\n- then\n- printf \"${RED}ERROR: dev command requires one parameter!${NC}\\n\"\n- helpmenu\n- exit 1\n+cmd_dev() {\n+ local cmd=\"$1\"\n+ shift\n+ if [ -z \"$cmd\" ]; then\n+ echo -e \"${RED}ERROR: dev command requires one parameter!${NC}\"\n+ cmd_help\n+ return 1\n+ fi\n+ if silent type \"dev_$cmd\"; then\n+ \"dev_$cmd\" \"$@\"\n+ exit $?\nelse\n- case \"$1\" in\n- docs)\n- documentation\n- exit\n- ;;\n- flush)\n- flush\n- exit\n- ;;\n- logs)\n- logs\n- exit\n- ;;\n- makeresources)\n- makeresources\n- exit\n- ;;\n- makemigrations)\n- makemigrations\n- exit\n- ;;\n- migrate)\n- migrate\n- exit\n- ;;\n- shell)\n- shell\n- exit\n- ;;\n- static)\n- static\n- static_scratch\n- collect_static\n- exit\n- ;;\n- static_prod)\n- static_prod\n- static_scratch\n- collect_static\n- exit\n- ;;\n- style)\n- style\n- exit\n- ;;\n- test)\n- test_suite\n- exit\n- ;;\n- test_backwards)\n- test_suite_backwards\n- exit\n- ;;\n- test_coverage)\n- test_coverage\n- exit\n- ;;\n- test_specific)\n- test_specific $2\n- exit\n- ;;\n- updatedata)\n- updatedata\n- exit\n- ;;\n- esac\n+ echo -e \"${RED}ERROR: Unknown command!${NC}\"\n+ echo \"Type './csu help' for available commands.\"\n+ return 1\nfi\n}\n-\n# If no command given\n-if [ $# -eq 0 ]\n-then\n- printf \"${RED}ERROR: This script requires a command!${NC}\\n\"\n- helpmenu\n+if [ $# -eq 0 ]; then\n+ echo -e \"${RED}ERROR: This script requires a command!${NC}\"\n+ cmd_help\nexit 1\nfi\n-case \"$1\" in\n- build)\n- build\n- exit\n- ;;\n- clean)\n- clean\n- exit\n- ;;\n- dev)\n- process_dev_command $2 $3\n- ;;\n- end)\n- end\n- exit\n- ;;\n- help)\n- helpmenu\n- exit\n- ;;\n- restart)\n- end\n- start\n- exit\n- ;;\n- start)\n- start\n- exit\n- ;;\n- update)\n- update\n- exit\n- ;;\n- wipe)\n- wipe\n- exit\n- ;;\n-esac\n-\n-# If no command triggered\n-printf \"${RED}ERROR: Unknown command!${NC}\\n\"\n-printf \"Type './csu help' for available commands.\\n\"\n+cmd=\"$1\"\n+shift\n+if silent type \"cmd_$cmd\" 2> /dev/null; then\n+ \"cmd_$cmd\" \"$@\"\n+ exit $?\n+else\n+ echo -e \"${RED}ERROR: Unknown command!${NC}\"\n+ echo \"Type './csu help' for available commands.\"\nexit 1\n+fi\n" } ]
Python
MIT License
uccser/cs-unplugged
Made csu script more script-y
701,845
08.08.2017 20:13:49
-43,200
caa2a95026510c47ac25994f3a8fec08dc2caefc
Fix some incorrect command names
[ { "change_type": "MODIFY", "old_path": "csu", "new_path": "csu", "diff": "@@ -91,13 +91,13 @@ defhelp restart 'Stop and then restart development environment.'\n# Run Django migrate and updatedata commands\ncmd_update() {\n- cmd_static\n+ dev_static\necho \"\"\n- cmd_migrate\n+ dev_migrate\necho \"\"\n- cmd_updatedata\n+ dev_updatedata\ncmd_static_scratch\ncmd_collect_static\n" } ]
Python
MIT License
uccser/cs-unplugged
Fix some incorrect command names
701,852
09.08.2017 17:03:48
-43,200
f1e5a58a0758beb0ea1086f01c574c15a1862dd9
Removed aliases to functions as they weren't working, made ci commands functions as they may change in future.
[ { "change_type": "MODIFY", "old_path": "csu", "new_path": "csu", "diff": "@@ -193,7 +193,6 @@ dev_style() {\n! (( pep8_status || pydocstyle_status ))\n}\ndefhelp -dev style 'Run style checks.'\n-alias ci_style=dev_style\n# Run test suite\ndev_test_suite() {\n@@ -229,7 +228,6 @@ dev_test_backwards() {\nreturn $status\n}\ndefhelp -dev test_backwards 'Run test suite backwards.'\n-alias ci_test_backwards=dev_test_backwards\n# Generates the documentation (with warnings as errors)\ndev_docs() {\n@@ -241,7 +239,6 @@ dev_docs() {\ndocker-compose exec django /docker_venv/bin/sphinx-build -W /cs-unplugged/docs/source/ /cs-unplugged/docs/build/\n}\ndefhelp -dev docs 'Generate documentation.'\n-alias ci_docs=dev_docs\n# Delete all untagged dangling Docker images\ncmd_clean() {\n@@ -284,6 +281,18 @@ ci_test_with_coverage() {\n! (( $test_status || $coverage_status ))\n}\n+ci_style() {\n+ dev_style\n+}\n+\n+ci_test_backwards() {\n+ dev_test_backwards\n+}\n+\n+ci_docs() {\n+ dev_docs\n+}\n+\ncmd_ci() {\ncmd_start\nlocal cmd=\"$1\"\n" } ]
Python
MIT License
uccser/cs-unplugged
Removed aliases to functions as they weren't working, made ci commands functions as they may change in future.
701,852
06.09.2017 12:29:28
-43,200
28e0b42455e4c8061826607519c4b20b09b48453
Update Django the correct way, remove requirements from base.txt.
[ { "change_type": "MODIFY", "old_path": "Dockerfile", "new_path": "Dockerfile", "diff": "# This Dockerfile is based off the Google App Engine Python runtime image\n# https://github.com/GoogleCloudPlatform/python-runtime\n-FROM uccser/django:1.11.4\n+FROM uccser/django:1.11.5\n# Add metadata to Docker image\nLABEL maintainer=\"csse-education-research@canterbury.ac.nz\"\n" }, { "change_type": "MODIFY", "old_path": "Dockerfile-local", "new_path": "Dockerfile-local", "diff": "# This Dockerfile is based off the Google App Engine Python runtime image\n# https://github.com/GoogleCloudPlatform/python-runtime\n-FROM uccser/django:1.11.4-with-weasyprint\n+FROM uccser/django:1.11.5-with-weasyprint\n# Add metadata to Docker image\nLABEL maintainer=\"csse-education-research@canterbury.ac.nz\"\n" }, { "change_type": "MODIFY", "old_path": "requirements/base.txt", "new_path": "requirements/base.txt", "diff": "# Verified bug on Python 3.5.1\nwheel==0.29.0\n-# Django\n-django==1.11.5\n-\n-# Configuration\n-django-environ==0.4.3\n-\n# Resources\nPillow==4.2.1\nyattag==1.8.0\n@@ -18,15 +12,5 @@ yattag==1.8.0\nverto==0.6.1\npython-markdown-math==0.3\n-# Python-PostgreSQL Database Adapter\n-psycopg2==2.7.3\n-\n-# Templates\n-django-bootstrap-breadcrumbs==0.8.2\n-\n# YAML Loading\nPyYAML==3.12\n-\n-# Web serving\n-gevent==1.2.2\n-gunicorn==19.7.1\n" } ]
Python
MIT License
uccser/cs-unplugged
Update Django the correct way, remove requirements from base.txt.
701,855
09.10.2017 12:57:02
-46,800
86a922e01cd0d2fac6ef191132c7cc080424a1e1
Add csu command to reboot django container after exception occurs.
[ { "change_type": "MODIFY", "old_path": "csu", "new_path": "csu", "diff": "@@ -182,6 +182,13 @@ dev_shell() {\n}\ndefhelp -dev shell \"Open shell to Django folder.\"\n+# Reboot Django Docker container\n+dev_reboot_django() {\n+ echo \"Rebooting Django Docker container...\"\n+ docker-compose up -d django\n+}\n+defhelp -dev reboot_django 'Reboot Django Docker container.'\n+\n# Run style checks\ndev_style() {\necho \"Running PEP8 style checker...\"\n" } ]
Python
MIT License
uccser/cs-unplugged
Add csu command to reboot django container after exception occurs.
701,855
16.10.2017 18:28:18
-46,800
e120e1f1cb80ff24fefa27097ef7611e1560ff37
Modify models to store translated content (fixes Register new database columns for translated content using django-modeltranslation. Add abstract base class for models with translatable content. This class has a repeated CharField which stores the available languages for that content.
[ { "change_type": "MODIFY", "old_path": "csunplugged/config/settings/base.py", "new_path": "csunplugged/config/settings/base.py", "diff": "@@ -36,6 +36,7 @@ DJANGO_APPS = [\n]\nTHIRD_PARTY_APPS = [\n\"django_bootstrap_breadcrumbs\",\n+ \"modeltranslation\",\n]\n# Apps specific for this project go here.\n@@ -98,7 +99,13 @@ FIXTURE_DIRS = (\nTIME_ZONE = \"UTC\"\n# See: https://docs.djangoproject.com/en/dev/ref/settings/#language-code\n-LANGUAGE_CODE = \"en-us\"\n+LANGUAGE_CODE = \"en\"\n+\n+LANGUAGES = (\n+ (\"en\", \"English\"),\n+ (\"de\", \"German\"),\n+ (\"fr\", \"French\"),\n+)\n# See: https://docs.djangoproject.com/en/dev/ref/settings/#site-id\nSITE_ID = 1\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/models.py", "new_path": "csunplugged/topics/models.py", "diff": "\"\"\"Models for the topics application.\"\"\"\nfrom django.db import models\n+from django.utils.translation import get_language\nfrom django.contrib.postgres.fields import ArrayField, JSONField, IntegerRangeField\nfrom resources.models import Resource\n+class TranslatableModel(models.Model):\n+ languages = ArrayField(models.CharField(max_length=5), size=100, default=[])\n+\n+ class Meta:\n+ abstract = True\n+\n+ @property\n+ def translation_available(self):\n+ return get_language() in self.languages\nclass GlossaryTerm(models.Model):\n\"\"\"Model for glossary term in database.\"\"\"\n@@ -21,7 +31,6 @@ class GlossaryTerm(models.Model):\n\"\"\"\nreturn self.term\n-\nclass CurriculumArea(models.Model):\n\"\"\"Model for curriculum area in database.\"\"\"\n@@ -52,7 +61,6 @@ class CurriculumArea(models.Model):\nordering = [\"number\", \"name\"]\n-\nclass LearningOutcome(models.Model):\n\"\"\"Model for learning outcome in database.\"\"\"\n@@ -78,7 +86,7 @@ class LearningOutcome(models.Model):\nordering = [\"curriculum_areas__number\", \"curriculum_areas__name\", \"text\"]\n-class Topic(models.Model):\n+class Topic(TranslatableModel):\n\"\"\"Model for topic in database.\"\"\"\n# Auto-incrementing 'id' field is automatically set by Django\n@@ -88,6 +96,7 @@ class Topic(models.Model):\nother_resources = models.TextField(null=True)\nicon = models.CharField(max_length=100, null=True)\n+\ndef __str__(self):\n\"\"\"Text representation of Topic object.\n@@ -97,7 +106,7 @@ class Topic(models.Model):\nreturn self.name\n-class UnitPlan(models.Model):\n+class UnitPlan(TranslatableModel):\n\"\"\"Model for unit plan in database.\"\"\"\n# Auto-incrementing 'id' field is automatically set by Django\n@@ -137,7 +146,7 @@ class ProgrammingChallengeDifficulty(models.Model):\nreturn self.name\n-class ProgrammingChallenge(models.Model):\n+class ProgrammingChallenge(TranslatableModel):\n\"\"\"Model for programming challenge in database.\"\"\"\n# Auto-incrementing 'id' field is automatically set by Django\n@@ -197,7 +206,7 @@ class ProgrammingChallengeLanguage(models.Model):\nreturn self.name\n-class ProgrammingChallengeImplementation(models.Model):\n+class ProgrammingChallengeImplementation(TranslatableModel):\n\"\"\"Model for programming challenge language implementation in database.\"\"\"\n# Auto-incrementing 'id' field is automatically set by Django\n@@ -255,8 +264,7 @@ class AgeGroup(models.Model):\nordering = [\"ages\"]\n-\n-class Lesson(models.Model):\n+class Lesson(TranslatableModel):\n\"\"\"Model for lesson in database.\"\"\"\n# Auto-incrementing 'id' field is automatically set by Django\n@@ -363,7 +371,7 @@ class ProgrammingChallengeNumber(models.Model):\nchallenge_number = models.PositiveSmallIntegerField()\n-class CurriculumIntegration(models.Model):\n+class CurriculumIntegration(TranslatableModel):\n\"\"\"Model for curriculum integration in database.\"\"\"\n# Auto-incrementing 'id' field is automatically set by Django\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/translation.py", "diff": "+from modeltranslation.translator import translator, TranslationOptions\n+from topics.models import Topic, UnitPlan, ProgrammingChallenge, ProgrammingChallengeImplementation, Lesson, CurriculumIntegration\n+\n+class TopicTranslationOptions(TranslationOptions):\n+ fields = ('name', 'content', 'other_resources')\n+\n+class UnitPlanTranslationOptions(TranslationOptions):\n+ fields = ('name', 'content', 'computational_thinking_links')\n+\n+class ProgrammingChallengeTranslationOptions(TranslationOptions):\n+ fields = ('name', 'content', 'extra_challenge')\n+\n+class ProgrammingChallengeImplementationTranslationOptions(TranslationOptions):\n+ fields = ('expected_result', 'hints', 'solution')\n+\n+class LessonTranslationOptions(TranslationOptions):\n+ fields = ('name', 'content')\n+\n+class CurriculumIntegrationTranslationOptions(TranslationOptions):\n+ fields = ('name', 'content')\n+\n+\n+\n+translator.register(Topic, TopicTranslationOptions)\n+translator.register(UnitPlan, UnitPlanTranslationOptions)\n+translator.register(ProgrammingChallenge, ProgrammingChallengeTranslationOptions)\n+translator.register(ProgrammingChallengeImplementation, ProgrammingChallengeImplementationTranslationOptions)\n+translator.register(Lesson, LessonTranslationOptions)\n+translator.register(CurriculumIntegration, CurriculumIntegrationTranslationOptions)\n" } ]
Python
MIT License
uccser/cs-unplugged
Modify models to store translated content (fixes #614) Register new database columns for translated content using django-modeltranslation. Add abstract base class for models with translatable content. This class has a repeated CharField which stores the available languages for that content.
701,855
16.10.2017 18:56:48
-46,800
4b744c370719eaf8207360a9471cf9eec7422171
Update GlossaryTerm model to handle translated content
[ { "change_type": "MODIFY", "old_path": "csunplugged/topics/models.py", "new_path": "csunplugged/topics/models.py", "diff": "@@ -15,7 +15,7 @@ class TranslatableModel(models.Model):\ndef translation_available(self):\nreturn get_language() in self.languages\n-class GlossaryTerm(models.Model):\n+class GlossaryTerm(TranslatableModel):\n\"\"\"Model for glossary term in database.\"\"\"\n# Auto-incrementing 'id' field is automatically set by Django\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/translation.py", "new_path": "csunplugged/topics/translation.py", "diff": "from modeltranslation.translator import translator, TranslationOptions\n-from topics.models import Topic, UnitPlan, ProgrammingChallenge, ProgrammingChallengeImplementation, Lesson, CurriculumIntegration\n+from topics.models import Topic, UnitPlan, ProgrammingChallenge, ProgrammingChallengeImplementation, Lesson, CurriculumIntegration, GlossaryTerm\nclass TopicTranslationOptions(TranslationOptions):\nfields = ('name', 'content', 'other_resources')\n@@ -19,6 +19,9 @@ class LessonTranslationOptions(TranslationOptions):\nclass CurriculumIntegrationTranslationOptions(TranslationOptions):\nfields = ('name', 'content')\n+class GlossaryTermTranslationOptions(TranslationOptions):\n+ fields = ('term', 'definition')\n+\ntranslator.register(Topic, TopicTranslationOptions)\n@@ -27,3 +30,4 @@ translator.register(ProgrammingChallenge, ProgrammingChallengeTranslationOptions\ntranslator.register(ProgrammingChallengeImplementation, ProgrammingChallengeImplementationTranslationOptions)\ntranslator.register(Lesson, LessonTranslationOptions)\ntranslator.register(CurriculumIntegration, CurriculumIntegrationTranslationOptions)\n+translator.register(GlossaryTerm, GlossaryTermTranslationOptions)\n" } ]
Python
MIT License
uccser/cs-unplugged
Update GlossaryTerm model to handle translated content (#614)
701,855
17.10.2017 12:31:31
-46,800
1d8b68163e823e23b02c3e0207a83e43115f0570
Cleanup and style fixes for internationalization of models/loaders. Relevant to
[ { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/_AgeGroupsLoader.py", "new_path": "csunplugged/topics/management/commands/_AgeGroupsLoader.py", "diff": "\"\"\"Custom loader for loading age group.\"\"\"\n-import os.path\n-\nfrom django.db import transaction\nfrom utils.BaseLoader import BaseLoader\nfrom utils.errors.MissingRequiredFieldError import MissingRequiredFieldError\n-from utils.errors.CouldNotFindMarkdownFileError import CouldNotFindMarkdownFileError\nfrom topics.models import AgeGroup\n@@ -15,14 +12,8 @@ class AgeGroupsLoader(BaseLoader):\n\"\"\"Loader for age group content.\"\"\"\ndef __init__(self, **kwargs):\n- \"\"\"Create the loader for loading age groups.\n-\n- Args:\n- structure_file_path: File path to YAML file (str).\n- \"\"\"\n- # inner_path, structure_file = os.path.split(structure_file_path)\n+ \"\"\"Create the loader for loading age groups.\"\"\"\nsuper().__init__(**kwargs)\n- # self.structure_file_path = structure_file_path\n@transaction.atomic\ndef load(self):\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/_CurriculumAreasLoader.py", "new_path": "csunplugged/topics/management/commands/_CurriculumAreasLoader.py", "diff": "\"\"\"Custom loader for loading curriculum areas.\"\"\"\n-import os.path\n-\nfrom django.db import transaction\nfrom utils.BaseLoader import BaseLoader\nfrom utils.errors.MissingRequiredFieldError import MissingRequiredFieldError\n-from utils.errors.CouldNotFindMarkdownFileError import CouldNotFindMarkdownFileError\nfrom topics.models import CurriculumArea\n@@ -16,14 +13,8 @@ class CurriculumAreasLoader(BaseLoader):\n\"\"\"Loader for curriculum area content.\"\"\"\ndef __init__(self, **kwargs):\n- \"\"\"Create the loader for loading curriculum areas.\n-\n- Args:\n- structure_file_path: File path to YAML file (str).\n- BASE_PATH: Base file path (str).\n- \"\"\"\n+ \"\"\"Create the loader for loading curriculum areas.\"\"\"\nsuper().__init__(**kwargs)\n- # self.structure_file_path = structure_file_path\n@transaction.atomic\ndef load(self):\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/_CurriculumIntegrationsLoader.py", "new_path": "csunplugged/topics/management/commands/_CurriculumIntegrationsLoader.py", "diff": "\"\"\"Custom loader for loading curriculum integrations.\"\"\"\n-import os.path\n-\nfrom utils.BaseLoader import BaseLoader\nfrom utils.language_utils import get_default_language, get_available_languages\n@@ -20,7 +18,6 @@ class CurriculumIntegrationsLoader(BaseLoader):\n\"\"\"Create the loader for loading curriculum integrations.\nArgs:\n- structure_file_path: File path for structure YAML file (str).\ntopic: Object of related topic model (Topic).\n\"\"\"\nsuper().__init__(**kwargs)\n@@ -60,7 +57,7 @@ class CurriculumIntegrationsLoader(BaseLoader):\nfor language in get_available_languages():\ntry:\nintegration_content = self.convert_md_file(\n- self.get_locale_path(language, \"{}.md\".format(integration_slug)),\n+ self.get_localised_file(language, \"{}.md\".format(integration_slug)),\nself.structure_file_path\n)\ncontent_translations[language] = integration_content\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/_GlossaryTermsLoader.py", "new_path": "csunplugged/topics/management/commands/_GlossaryTermsLoader.py", "diff": "\"\"\"Custom loader for loading glossary terms.\"\"\"\n-import os.path\nfrom os import listdir\nfrom django.db import transaction\n@@ -10,18 +9,11 @@ from utils.errors.CouldNotFindMarkdownFileError import CouldNotFindMarkdownFileE\nfrom topics.models import GlossaryTerm\n-\nclass GlossaryTermsLoader(BaseLoader):\n\"\"\"Custom loader for loading glossary terms.\"\"\"\ndef __init__(self, **kwargs):\n- \"\"\"Create the loader for loading glossary terms.\n-\n- Args:\n- glossary_folder_path: Folder path to definition files (str).\n- structure_file_path: Path to the config file, used for errors (str).\n- BASE_PATH: Base file path (str).\n- \"\"\"\n+ \"\"\"Create the loader for loading glossary terms.\"\"\"\nsuper().__init__(**kwargs)\nself.FILE_EXTENSION = \".md\"\n@@ -29,7 +21,7 @@ class GlossaryTermsLoader(BaseLoader):\ndef load(self):\n\"\"\"Load the glossary content into the database.\"\"\"\nglossary_slugs = set()\n- for filename in listdir(self.get_locale_path(\"en\", None)):\n+ for filename in listdir(self.get_localised_dir(get_default_language())):\nif filename.endswith(self.FILE_EXTENSION):\nglossary_slug = filename[:-len(self.FILE_EXTENSION)]\nglossary_slugs.add(glossary_slug)\n@@ -42,7 +34,7 @@ class GlossaryTermsLoader(BaseLoader):\ncontent_translations = {}\nfor language in get_available_languages():\nglossary_term = GlossaryTerm.objects.get(slug=glossary_slug)\n- glossary_file_path = self.get_locale_path(\n+ glossary_file_path = self.get_localised_file(\nlanguage,\n\"{}{}\".format(glossary_slug, self.FILE_EXTENSION)\n)\n@@ -55,6 +47,7 @@ class GlossaryTermsLoader(BaseLoader):\nexcept CouldNotFindMarkdownFileError:\nif language == get_default_language():\nraise\n+\nfor language in content_translations:\nsetattr(glossary_term, \"definition_{}\".format(language), content_translations[language].html_string)\nsetattr(glossary_term, \"term_{}\".format(language), content_translations[language].title)\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/_LearningOutcomesLoader.py", "new_path": "csunplugged/topics/management/commands/_LearningOutcomesLoader.py", "diff": "\"\"\"Custom loader for loading learning outcomes.\"\"\"\n-import os.path\nfrom django.db import transaction\nfrom utils.BaseLoader import BaseLoader\nfrom utils.errors.MissingRequiredFieldError import MissingRequiredFieldError\nfrom utils.errors.KeyNotFoundError import KeyNotFoundError\n-from utils.errors.CouldNotFindMarkdownFileError import CouldNotFindMarkdownFileError\nfrom topics.models import (\nLearningOutcome,\nCurriculumArea,\n@@ -17,12 +15,7 @@ class LearningOutcomesLoader(BaseLoader):\n\"\"\"Custom loader for loading learning outcomes.\"\"\"\ndef __init__(self, **kwargs):\n- \"\"\"Create the loader for loading learning outcomes.\n-\n- Args:\n- structure_file_path: File path to YAML file (str).\n- BASE_PATH: Base file path (str).\n- \"\"\"\n+ \"\"\"Create the loader for loading learning outcomes.\"\"\"\nsuper().__init__(**kwargs)\n@transaction.atomic\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/_LessonsLoader.py", "new_path": "csunplugged/topics/management/commands/_LessonsLoader.py", "diff": "\"\"\"Custom loader for loading lessons.\"\"\"\n-import os.path\nfrom utils.BaseLoader import BaseLoader\nfrom utils.language_utils import get_default_language, get_available_languages\nfrom utils.convert_heading_tree_to_dict import convert_heading_tree_to_dict\n@@ -26,14 +25,9 @@ class LessonsLoader(BaseLoader):\n\"\"\"Create the loader for loading lessons.\nArgs:\n- lessons_structure_file_path: file path to lessons yaml file (str).\ntopic: Object of Topic model (Topic).\nunit_plan: Object of UnitPlan model (UnitPlan).\n- BASE_PATH: Base file path (str).\n- INNER_PATH: Path to lesson directory from locale root (str).\n\"\"\"\n- # lesson_path, structure_file = os.path.split(lessons_structure_file_path)\n- # inner_path = os.path.join(unit_path, lesson_path)\nsuper().__init__(**kwargs)\nself.topic = topic\nself.unit_plan = unit_plan\n@@ -58,12 +52,11 @@ class LessonsLoader(BaseLoader):\n\"Lesson\"\n)\n- available_translations = lesson_structure.get('available_translations', [\"en\", \"de\"])\ncontent_translations = {}\nct_links_translations = {}\nfor language in get_available_languages():\n# Build the file path to the lesson\"s md file\n- file_path = self.get_locale_path(language, \"{}.md\".format(lesson_slug))\n+ file_path = self.get_localised_file(language, \"{}.md\".format(lesson_slug))\ntry:\nlesson_content = self.convert_md_file(\n@@ -77,7 +70,7 @@ class LessonsLoader(BaseLoader):\nif \"computational-thinking-links\" in lesson_structure:\nfilename = lesson_structure[\"computational-thinking-links\"]\n- file_path = self.get_locale_path(language, filename)\n+ file_path = self.get_localised_file(language, filename)\ntry:\nct_links_content = self.convert_md_file(\n@@ -96,12 +89,13 @@ class LessonsLoader(BaseLoader):\nelse:\nlesson_duration = None\n+ # TODO: Handle l10n of heading tree\nheading_tree = None\nif lesson_content.heading_tree:\nheading_tree = convert_heading_tree_to_dict(lesson_content.heading_tree)\nif \"programming-challenges-description\" in lesson_structure:\n- file_name = lesson_structure[\"programming-challenges-description\"]\n+ filename = lesson_structure[\"programming-challenges-description\"]\nfile_path = self.locale_path(language, filename)\ntry:\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/_ProgrammingChallengesLoader.py", "new_path": "csunplugged/topics/management/commands/_ProgrammingChallengesLoader.py", "diff": "@@ -24,10 +24,7 @@ class ProgrammingChallengesLoader(BaseLoader):\n\"\"\"Create the loader for loading programming challenges.\nArgs:\n- structure_file_path: File path for structure YAML file (str).\ntopic: Object of related topic model (Topic).\n- BASE_PATH: Base file path (str).\n- INNER_PATH: Path to programming challenge directory from locale root (str).\n\"\"\"\nsuper().__init__(**kwargs)\nself.topic = topic\n@@ -70,7 +67,8 @@ class ProgrammingChallengesLoader(BaseLoader):\nextra_challenge_translations = {}\nfor language in get_available_languages():\n# Build the path to the programming challenge's folder\n- file_path = self.get_locale_path(language,\n+ file_path = self.get_localised_file(\n+ language,\nos.path.join(challenge_slug, \"{}.md\")\n)\n@@ -116,10 +114,22 @@ class ProgrammingChallengesLoader(BaseLoader):\ndifficulty=difficulty_level\n)\nfor language in content_translations:\n- setattr(programming_challenge, \"content_{}\".format(language), content_translations[language].html_string)\n- setattr(programming_challenge, \"name_{}\".format(language), content_translations[language].title)\n+ setattr(\n+ programming_challenge,\n+ \"content_{}\".format(language),\n+ content_translations[language].html_string\n+ )\n+ setattr(\n+ programming_challenge,\n+ \"name_{}\".format(language),\n+ content_translations[language].title\n+ )\nfor language in extra_challenge_translations:\n- setattr(programming_challenge, \"extra_challenge_{}\".format(language), extra_challenge_translations[language])\n+ setattr(\n+ programming_challenge,\n+ \"extra_challenge_{}\".format(language),\n+ extra_challenge_translations[language]\n+ )\nprogramming_challenge.save()\n@@ -149,7 +159,7 @@ class ProgrammingChallengesLoader(BaseLoader):\nhint_translations = {}\nfor translation_language in get_available_languages():\n- file_path = self.get_locale_path(\n+ file_path = self.get_localised_file(\nlanguage,\nos.path.join(challenge_slug, \"{}.md\")\n)\n@@ -166,7 +176,6 @@ class ProgrammingChallengesLoader(BaseLoader):\nif language == get_default_language():\nraise\n-\n# Load example solution\ntry:\nsolution_content = self.convert_md_file(\n@@ -201,11 +210,23 @@ class ProgrammingChallengesLoader(BaseLoader):\ntopic=self.topic\n)\nfor translation_language in solution_translations:\n- setattr(implementation, \"solution_{}\".format(translation_language), solution_translations[translation_language])\n+ setattr(\n+ implementation,\n+ \"solution_{}\".format(translation_language),\n+ solution_translations[translation_language]\n+ )\nfor translation_language in hint_translations:\n- setattr(implementation, \"hint_{}\".format(translation_language), hint_translations[translation_language])\n+ setattr(\n+ implementation,\n+ \"hint_{}\".format(translation_language),\n+ hint_translations[translation_language]\n+ )\nfor translation_language in expected_result_translations:\n- setattr(implementation, \"expected_result_{}\".format(translation_language), expected_result_translations[translation_language])\n+ setattr(\n+ implementation,\n+ \"expected_result_{}\".format(translation_language),\n+ expected_result_translations[translation_language]\n+ )\nimplementation.save()\nLOG_TEMPLATE = \"Added language implementation: {}\"\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/_ProgrammingChallengesStructureLoader.py", "new_path": "csunplugged/topics/management/commands/_ProgrammingChallengesStructureLoader.py", "diff": "\"\"\"Custom loader for loading structure of programming challenges.\"\"\"\n-import os.path\nfrom django.db import transaction\nfrom utils.BaseLoader import BaseLoader\nfrom utils.errors.MissingRequiredFieldError import MissingRequiredFieldError\n-from utils.errors.CouldNotFindMarkdownFileError import CouldNotFindMarkdownFileError\n-\nfrom topics.models import ProgrammingChallengeLanguage, ProgrammingChallengeDifficulty\n@@ -16,12 +13,7 @@ class ProgrammingChallengesStructureLoader(BaseLoader):\n\"\"\"Custom loader for loading structure of programming challenges.\"\"\"\ndef __init__(self, **kwargs):\n- \"\"\"Create the loader for loading structure of programming challenges.\n-\n- Args:\n- structure_file_path: File path for structure YAML file (str).\n- BASE_PATH: Base file path (str).\n- \"\"\"\n+ \"\"\"Create the loader for loading structure of programming challenges.\"\"\"\nsuper().__init__(**kwargs)\n@transaction.atomic\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/_TopicLoader.py", "new_path": "csunplugged/topics/management/commands/_TopicLoader.py", "diff": "import os.path\nfrom django.db import transaction\n-from django.conf import settings\nfrom utils.BaseLoader import BaseLoader\nfrom utils.language_utils import get_available_languages, get_default_language\n@@ -22,14 +21,10 @@ class TopicLoader(BaseLoader):\nArgs:\nfactory: LoaderFactory object for creating loaders (LoaderFactory).\n- structure_file_path: File path for structure YAML file (str).\n- BASE_PATH: Base file path (str).\n\"\"\"\nsuper().__init__(**kwargs)\nself.factory = factory\n-\n- self.topic_slug = self.INNER_PATH\n-\n+ self.topic_slug = self.content_path\n@transaction.atomic\ndef load(self):\n@@ -51,11 +46,12 @@ class TopicLoader(BaseLoader):\ncontent_translations = {}\nother_resources_translations = {}\n+\n# Convert the content to HTML\nfor language in get_available_languages():\ntry:\ntopic_content = self.convert_md_file(\n- self.get_locale_path(language, \"{}.md\".format(self.topic_slug)),\n+ self.get_localised_file(language, \"{}.md\".format(self.topic_slug)),\nself.structure_file_path\n)\ncontent_translations[language] = topic_content\n@@ -63,14 +59,13 @@ class TopicLoader(BaseLoader):\nif language == get_default_language():\nraise\n-\n# If other resources are given, convert to HTML\nif \"other-resources\" in topic_structure:\ntopic_other_resources_file = topic_structure[\"other-resources\"]\nif topic_other_resources_file is not None:\ntry:\nother_resources_content = self.convert_md_file(\n- self.get_locale_path(language, topic_other_resources_file),\n+ self.get_localised_file(language, topic_other_resources_file),\nself.structure_file_path\n)\nother_resources_translations[language] = other_resources_content.html_string\n@@ -78,8 +73,6 @@ class TopicLoader(BaseLoader):\nif language == get_default_language():\nraise\n-\n-\n# Check if icon is given\nif \"icon\" in topic_structure:\ntopic_icon = topic_structure[\"icon\"]\n@@ -110,33 +103,37 @@ class TopicLoader(BaseLoader):\nif \"programming-challenges\" in topic_structure:\nprogramming_challenges_structure_file_path = topic_structure[\"programming-challenges\"]\nif programming_challenges_structure_file_path is not None:\n- programming_challenges_path, structure_filename = os.path.split(programming_challenges_structure_file_path)\n+ programming_challenges_path, structure_filename = os.path.split(\n+ programming_challenges_structure_file_path\n+ )\nself.factory.create_programming_challenges_loader(\ntopic,\n- BASE_PATH=self.BASE_PATH,\n- INNER_PATH=os.path.join(self.INNER_PATH, programming_challenges_path),\n- STRUCTURE_FILE=structure_filename\n+ base_path=self.base_path,\n+ content_path=os.path.join(self.content_path, programming_challenges_path),\n+ structure_filename=structure_filename\n).load()\n# Load unit plans\nfor unit_plan_file_path in unit_plans:\n- inner_path, structure_filename = os.path.split(unit_plan_file_path)\n+ content_path, structure_filename = os.path.split(unit_plan_file_path)\nself.factory.create_unit_plan_loader(\ntopic,\n- BASE_PATH=self.BASE_PATH,\n- INNER_PATH=os.path.join(self.INNER_PATH, inner_path),\n- STRUCTURE_FILE=structure_filename\n+ base_path=self.base_path,\n+ content_path=os.path.join(self.content_path, content_path),\n+ structure_filename=structure_filename\n).load()\nif \"curriculum-integrations\" in topic_structure:\ncurriculum_integrations_structure_file_path = topic_structure[\"curriculum-integrations\"]\nif curriculum_integrations_structure_file_path is not None:\n- curriculum_integrations_path, structure_filename = os.path.split(curriculum_integrations_structure_file_path)\n+ curriculum_integrations_path, structure_filename = os.path.split(\n+ curriculum_integrations_structure_file_path\n+ )\nself.factory.create_curriculum_integrations_loader(\ntopic,\n- BASE_PATH=self.BASE_PATH,\n- INNER_PATH=os.path.join(self.INNER_PATH, curriculum_integrations_path),\n- STRUCTURE_FILE=structure_filename\n+ base_path=self.base_path,\n+ content_path=os.path.join(self.content_path, curriculum_integrations_path),\n+ structure_filename=structure_filename\n).load()\nself.log(\"\")\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/_UnitPlanLoader.py", "new_path": "csunplugged/topics/management/commands/_UnitPlanLoader.py", "diff": "import os.path\n-from django.conf import settings\n-\nfrom utils.BaseLoader import BaseLoader\nfrom utils.language_utils import get_available_languages, get_default_language\nfrom utils.convert_heading_tree_to_dict import convert_heading_tree_to_dict\n@@ -27,14 +25,11 @@ class UnitPlanLoader(BaseLoader):\nArgs:\nfactory: LoaderFactory object for creating loaders (LoaderFactory).\n- structure_file_path: File path for structure YAML file (str).\ntopic: Object of related topic model (Topic).\n- BASE_PATH: Base file path (str).\n- INNER_PATH: Path to unit plan directory from locale root (str).\n\"\"\"\nsuper().__init__(**kwargs)\nself.factory = factory\n- self.unit_plan_slug = os.path.splitext(self.STRUCTURE_FILE)[0]\n+ self.unit_plan_slug = os.path.splitext(self.structure_filename)[0]\nself.topic = topic\ndef load(self):\n@@ -55,7 +50,7 @@ class UnitPlanLoader(BaseLoader):\ntry:\n# Convert the content to HTML\nunit_plan_content = self.convert_md_file(\n- self.get_locale_path(language, \"{}.md\".format(self.unit_plan_slug)),\n+ self.get_localised_file(language, \"{}.md\".format(self.unit_plan_slug)),\nself.structure_file_path\n)\ncontent_translations[language] = unit_plan_content\n@@ -70,7 +65,7 @@ class UnitPlanLoader(BaseLoader):\nif \"computational-thinking-links\" in unit_plan_structure:\nfilename = unit_plan_structure[\"computational-thinking-links\"]\n- file_path = self.get_locale_path(language, filename)\n+ file_path = self.get_localised_file(language, filename)\ntry:\nct_links_content = self.convert_md_file(\nfile_path,\n@@ -116,9 +111,9 @@ class UnitPlanLoader(BaseLoader):\nself.factory.create_lessons_loader(\nself.topic,\nunit_plan,\n- INNER_PATH=os.path.join(self.INNER_PATH, lesson_path),\n- STRUCTURE_FILE=lesson_structure_file,\n- BASE_PATH=self.BASE_PATH,\n+ content_path=os.path.join(self.content_path, lesson_path),\n+ structure_filename=lesson_structure_file,\n+ base_path=self.base_path,\n).load()\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/loadtopics.py", "new_path": "csunplugged/topics/management/commands/loadtopics.py", "diff": "@@ -21,13 +21,14 @@ class Command(BaseCommand):\nattribute.\n\"\"\"\nfactory = LoaderFactory()\n+\n# Get structure and content files\nbase_loader = BaseLoader()\n- BASE_PATH = \"topics/content/\"\n+ base_path = \"topics/content/\"\nstructure_file_path = os.path.join(\n- BASE_PATH,\n- base_loader.STRUCTURE_DIR,\n+ base_path,\n+ base_loader.structure_dir,\n\"structure.yaml\"\n)\n@@ -38,9 +39,9 @@ class Command(BaseCommand):\nif curriculum_areas_structure_file_path is not None:\ncurriculum_areas_path, structure_filename = os.path.split(curriculum_areas_structure_file_path)\nfactory.create_curriculum_areas_loader(\n- BASE_PATH=BASE_PATH,\n- INNER_PATH=curriculum_areas_path,\n- STRUCTURE_FILE=structure_filename\n+ base_path=base_path,\n+ content_path=curriculum_areas_path,\n+ structure_filename=structure_filename\n).load()\nif \"learning-outcomes\" in structure_file:\n@@ -48,27 +49,29 @@ class Command(BaseCommand):\nif learning_outcomes_structure_file_path is not None:\nlearning_outcomes_path, structure_filename = os.path.split(learning_outcomes_structure_file_path)\nfactory.create_learning_outcomes_loader(\n- BASE_PATH=BASE_PATH,\n- INNER_PATH=learning_outcomes_path,\n- STRUCTURE_FILE=structure_filename\n+ base_path=base_path,\n+ content_path=learning_outcomes_path,\n+ structure_filename=structure_filename\n).load()\nif \"programming-challenges-structure\" in structure_file:\nprogramming_challenges_structure_file_path = structure_file[\"programming-challenges-structure\"]\nif programming_challenges_structure_file_path is not None:\n- programming_challenges_path, structure_filename = os.path.split(programming_challenges_structure_file_path)\n+ programming_challenges_path, structure_filename = os.path.split(\n+ programming_challenges_structure_file_path\n+ )\nfactory.create_programming_challenges_structure_loader(\n- BASE_PATH=BASE_PATH,\n- INNER_PATH=programming_challenges_path,\n- STRUCTURE_FILE=structure_filename\n+ base_path=base_path,\n+ content_path=programming_challenges_path,\n+ structure_filename=structure_filename\n).load()\nif \"glossary-folder\" in structure_file:\nglossary_folder_path = structure_file[\"glossary-folder\"]\nif glossary_folder_path is not None:\nfactory.create_glossary_terms_loader(\n- BASE_PATH=BASE_PATH,\n- INNER_PATH=glossary_folder_path,\n+ base_path=base_path,\n+ content_path=glossary_folder_path,\n).load()\nif structure_file[\"age-groups\"] is None:\n@@ -82,9 +85,9 @@ class Command(BaseCommand):\nif age_groups_structure_file_path is not None:\nage_groups_path, structure_filename = os.path.split(age_groups_structure_file_path)\nfactory.create_age_groups_loader(\n- INNER_PATH=age_groups_path,\n- BASE_PATH=BASE_PATH,\n- STRUCTURE_FILE=structure_filename\n+ content_path=age_groups_path,\n+ base_path=base_path,\n+ structure_filename=structure_filename\n).load()\nif structure_file[\"topics\"] is None:\n@@ -98,7 +101,7 @@ class Command(BaseCommand):\ntopic_path = topic\ntopic_structure_file = \"{}.yaml\".format(topic)\nfactory.create_topic_loader(\n- BASE_PATH=BASE_PATH,\n- INNER_PATH=topic_path,\n- STRUCTURE_FILE=topic_structure_file\n+ base_path=base_path,\n+ content_path=topic_path,\n+ structure_filename=topic_structure_file\n).load()\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/models.py", "new_path": "csunplugged/topics/models.py", "diff": "@@ -5,16 +5,23 @@ from django.utils.translation import get_language\nfrom django.contrib.postgres.fields import ArrayField, JSONField, IntegerRangeField\nfrom resources.models import Resource\n+\nclass TranslatableModel(models.Model):\n+ \"\"\"Abstract base class for models needing to store list of available languages.\"\"\"\n+\nlanguages = ArrayField(models.CharField(max_length=5), size=100, default=[])\nclass Meta:\n+ \"\"\"Mark class as abstract.\"\"\"\n+\nabstract = True\n@property\ndef translation_available(self):\n+ \"\"\"Check if model content is available in current language.\"\"\"\nreturn get_language() in self.languages\n+\nclass GlossaryTerm(TranslatableModel):\n\"\"\"Model for glossary term in database.\"\"\"\n@@ -31,6 +38,7 @@ class GlossaryTerm(TranslatableModel):\n\"\"\"\nreturn self.term\n+\nclass CurriculumArea(models.Model):\n\"\"\"Model for curriculum area in database.\"\"\"\n@@ -61,6 +69,7 @@ class CurriculumArea(models.Model):\nordering = [\"number\", \"name\"]\n+\nclass LearningOutcome(models.Model):\n\"\"\"Model for learning outcome in database.\"\"\"\n@@ -96,7 +105,6 @@ class Topic(TranslatableModel):\nother_resources = models.TextField(null=True)\nicon = models.CharField(max_length=100, null=True)\n-\ndef __str__(self):\n\"\"\"Text representation of Topic object.\n@@ -264,6 +272,7 @@ class AgeGroup(models.Model):\nordering = [\"ages\"]\n+\nclass Lesson(TranslatableModel):\n\"\"\"Model for lesson in database.\"\"\"\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/translation.py", "new_path": "csunplugged/topics/translation.py", "diff": "+\"\"\"Translation options for localised models.\n+\n+Utilised by django-modeltranslation. See http://django-modeltranslation.readthedocs.io\n+\"\"\"\n+\nfrom modeltranslation.translator import translator, TranslationOptions\n-from topics.models import Topic, UnitPlan, ProgrammingChallenge, ProgrammingChallengeImplementation, Lesson, CurriculumIntegration, GlossaryTerm\n+from topics.models import (\n+ Topic,\n+ UnitPlan,\n+ ProgrammingChallenge,\n+ ProgrammingChallengeImplementation,\n+ Lesson,\n+ CurriculumIntegration,\n+ GlossaryTerm\n+)\n+\nclass TopicTranslationOptions(TranslationOptions):\n+ \"\"\"Translation options for Topic model.\"\"\"\n+\nfields = ('name', 'content', 'other_resources')\n+\nclass UnitPlanTranslationOptions(TranslationOptions):\n+ \"\"\"Translation options for UnitPlan model.\"\"\"\n+\nfields = ('name', 'content', 'computational_thinking_links')\n+\nclass ProgrammingChallengeTranslationOptions(TranslationOptions):\n+ \"\"\"Translation options for ProgrammingChallenge model.\"\"\"\n+\nfields = ('name', 'content', 'extra_challenge')\n+\nclass ProgrammingChallengeImplementationTranslationOptions(TranslationOptions):\n+ \"\"\"Translation options for ProgrammingChallengeImplementation model.\"\"\"\n+\nfields = ('expected_result', 'hints', 'solution')\n+\nclass LessonTranslationOptions(TranslationOptions):\n+ \"\"\"Translation options for Lesson model.\"\"\"\n+\nfields = ('name', 'content')\n+\nclass CurriculumIntegrationTranslationOptions(TranslationOptions):\n+ \"\"\"Translation options for CurriculumIntegration model.\"\"\"\n+\nfields = ('name', 'content')\n+\nclass GlossaryTermTranslationOptions(TranslationOptions):\n- fields = ('term', 'definition')\n+ \"\"\"Translation options for UnitPlan model.\"\"\"\n+ fields = ('term', 'definition')\ntranslator.register(Topic, TopicTranslationOptions)\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/utils/BaseLoader.py", "new_path": "csunplugged/utils/BaseLoader.py", "diff": "@@ -24,35 +24,59 @@ from utils.errors.CouldNotFindConfigFileError import CouldNotFindConfigFileError\nclass BaseLoader():\n\"\"\"Base loader class for individual loaders.\"\"\"\n- def __init__(self, BASE_PATH=\"\", STRUCTURE_DIR='en', INNER_PATH=\"\", STRUCTURE_FILE=\"\"):\n+ def __init__(self, base_path=\"\", structure_dir='en', content_path=\"\", structure_filename=\"\"):\n\"\"\"Create a BaseLoader object.\nArgs:\n- BASE_PATH: string of base content path, which stores has one directory\n- per locale, plus a special structure directory (str).\n- STRUCTURE_DIR: directory after BASE_PATH in which\n- language-independent structure files are stored (str).\n- INNER_PATH: Path from locale/structure direcory to required directory (str).\n- YAML_FILENAME: Path to YAML file\n+ base_path: path to content_root, eg. \"topics/content/\" (str).\n+ structure_dir: name of directory under base_path storing structure files (str).\n+ content_path: path within locale/structure dir to content directory, eg. \"binary-numbers/unit-plan\" (str).\n+ structure_filename: name of yaml file, eg. \"unit-plan.yaml\" (str).\n\"\"\"\n- self.BASE_PATH = BASE_PATH\n- self.STRUCTURE_DIR = STRUCTURE_DIR\n- self.INNER_PATH = INNER_PATH\n- self.STRUCTURE_FILE = STRUCTURE_FILE\n+ self.base_path = base_path\n+ self.structure_dir = structure_dir\n+ self.content_path = content_path\n+ self.structure_filename = structure_filename\nself.setup_md_to_html_converter()\n- def get_locale_path(self, locale, filename):\n- return self.get_full_path(locale, filename)\n+ def get_localised_file(self, language, filename):\n+ \"\"\"Get full path to localised version of given file.\n- def get_full_path(self, locale_or_structure_dir, filename):\n- if filename:\n- return os.path.join(self.BASE_PATH, locale_or_structure_dir, self.INNER_PATH, filename)\n- else:\n- return os.path.join(self.BASE_PATH, locale_or_structure_dir, self.INNER_PATH)\n+ Args:\n+ language: language code, matching a directory in self.base_path (str).\n+ filename: path to file from the content directory of the loader (str).\n+ \"\"\"\n+ return os.path.join(\n+ self.get_localised_dir(language),\n+ filename\n+ )\n+\n+ def get_localised_dir(self, language):\n+ \"\"\"Return full path to the localised content directory of the loader.\n+\n+ Args:\n+ language: language code, matching a directory in self.base_path (str).\n+ \"\"\"\n+ return os.path.join(\n+ self.base_path,\n+ language,\n+ self.content_path\n+ )\n@property\ndef structure_file_path(self):\n- return self.get_full_path(self.STRUCTURE_DIR, self.STRUCTURE_FILE)\n+ \"\"\"Return full path to structure yaml file of the loader.\n+\n+ This assumes that the structure file is located in the same directory\n+ as self.content_path, but inside the special 'structure' directory\n+ instead of a language directory.\n+ \"\"\"\n+ return os.path.join(\n+ self.base_path,\n+ self.structure_dir,\n+ self.content_path,\n+ self.structure_filename\n+ )\ndef setup_md_to_html_converter(self):\n\"\"\"Create Markdown converter.\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/utils/LoaderFactory.py", "new_path": "csunplugged/utils/LoaderFactory.py", "diff": "@@ -56,6 +56,6 @@ class LoaderFactory:\n\"\"\"Create unit plan loader.\"\"\"\nreturn UnitPlanLoader(self, topic, **kwargs)\n- def create_resources_loader(self, structure_file, BASE_PATH):\n+ def create_resources_loader(self, structure_file, base_path):\n\"\"\"Create resources loader.\"\"\"\n- return ResourcesLoader(structure_file, BASE_PATH)\n+ return ResourcesLoader(structure_file, base_path)\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/utils/language_utils.py", "new_path": "csunplugged/utils/language_utils.py", "diff": "+\"\"\"Module containing utility functions for internationalization.\"\"\"\n+\nfrom django.conf import settings\n+\ndef get_available_languages():\n+ \"\"\"Return the list of language codes defined in django settings.\"\"\"\nreturn [code for code, name in settings.LANGUAGES]\n+\ndef get_default_language():\n+ \"\"\"Return the language code of the default language.\"\"\"\nreturn settings.LANGUAGE_CODE\n" } ]
Python
MIT License
uccser/cs-unplugged
Cleanup and style fixes for internationalization of models/loaders. Relevant to #614, #615
701,855
17.10.2017 12:38:26
-46,800
5cfe57384eed44f42ec874fb00a3fd1371bc8c94
Update ResourceLoader to reflect changes in the BaseLoader class. This is essentially a patch, until the resources application can be modified for internationalization.
[ { "change_type": "MODIFY", "old_path": "csunplugged/resources/management/commands/_ResourcesLoader.py", "new_path": "csunplugged/resources/management/commands/_ResourcesLoader.py", "diff": "@@ -12,14 +12,14 @@ from resources.models import Resource\nclass ResourcesLoader(BaseLoader):\n\"\"\"Custom loader for loading resources.\"\"\"\n- def __init__(self, structure_file, BASE_PATH):\n+ def __init__(self, structure_file, base_path):\n\"\"\"Create the loader for loading resources.\nArgs:\nstructure_file: file path for structure YAML file (str).\n- BASE_PATH: base file path (str).\n+ base_path: base file path (str).\n\"\"\"\n- super().__init__(BASE_PATH)\n+ super().__init__(base_path)\nself.structure_file = structure_file\n@transaction.atomic\n@@ -31,7 +31,7 @@ class ResourcesLoader(BaseLoader):\nattribute.\n\"\"\"\nresources_structure = self.load_yaml_file(\n- self.BASE_PATH.format(\n+ self.base_path.format(\nself.structure_file\n)\n)\n" } ]
Python
MIT License
uccser/cs-unplugged
Update ResourceLoader to reflect changes in the BaseLoader class. This is essentially a patch, until the resources application can be modified for internationalization.
701,855
17.10.2017 14:54:22
-46,800
54fc511d47b939f1924454c1343b0cd7a5669361
Implement translation of heading tree in Lesson/UnitPlan loaders. Relevant to
[ { "change_type": "MODIFY", "old_path": "csunplugged/config/settings/base.py", "new_path": "csunplugged/config/settings/base.py", "diff": "@@ -214,3 +214,5 @@ AUTH_PASSWORD_VALIDATORS = [\n\"NAME\": \"django.contrib.auth.password_validation.NumericPasswordValidator\",\n},\n]\n+\n+MODELTRANSLATION_CUSTOM_FIELDS = ('JSONField',)\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/_LessonsLoader.py", "new_path": "csunplugged/topics/management/commands/_LessonsLoader.py", "diff": "@@ -54,6 +54,9 @@ class LessonsLoader(BaseLoader):\ncontent_translations = {}\nct_links_translations = {}\n+ heading_tree_translations = {}\n+ programming_description_translations = {}\n+\nfor language in get_available_languages():\n# Build the file path to the lesson\"s md file\nfile_path = self.get_localised_file(language, \"{}.md\".format(lesson_slug))\n@@ -84,19 +87,13 @@ class LessonsLoader(BaseLoader):\nif language == get_default_language():\nraise\n- if \"duration\" in lesson_structure:\n- lesson_duration = lesson_structure[\"duration\"]\n- else:\n- lesson_duration = None\n-\n- # TODO: Handle l10n of heading tree\n- heading_tree = None\nif lesson_content.heading_tree:\nheading_tree = convert_heading_tree_to_dict(lesson_content.heading_tree)\n+ heading_tree_translations[language] = heading_tree\nif \"programming-challenges-description\" in lesson_structure:\nfilename = lesson_structure[\"programming-challenges-description\"]\n- file_path = self.locale_path(language, filename)\n+ file_path = self.get_localised_file(language, filename)\ntry:\nprogramming_description_content = self.convert_md_file(\n@@ -105,12 +102,10 @@ class LessonsLoader(BaseLoader):\nheading_required=False,\nremove_title=False,\n)\n- programming_description = programming_description_content.html_string\n+ programming_description_translations[language] = programming_description_content.html_string\nexcept CouldNotFindMarkdownFileError:\nif language == get_default_language():\nraise\n- else:\n- programming_description = None\nclassroom_resources = lesson_structure.get(\"classroom-resources\", None)\nif isinstance(classroom_resources, list):\n@@ -134,20 +129,48 @@ class LessonsLoader(BaseLoader):\n\"List of strings.\"\n)\n+ if \"duration\" in lesson_structure:\n+ lesson_duration = lesson_structure[\"duration\"]\n+ else:\n+ lesson_duration = None\n+\nlesson = self.topic.lessons.create(\nunit_plan=self.unit_plan,\nslug=lesson_slug,\nduration=lesson_duration,\nlanguages=list(content_translations.keys()),\n- heading_tree=heading_tree,\n- programming_challenges_description=programming_description,\nclassroom_resources=classroom_resources,\n)\n+\nfor language in content_translations:\n- setattr(lesson, \"content_{}\".format(language), content_translations[language].html_string)\n- setattr(lesson, \"name_{}\".format(language), content_translations[language].title)\n+ setattr(\n+ lesson,\n+ \"content_{}\".format(language),\n+ content_translations[language].html_string\n+ )\n+ setattr(\n+ lesson,\n+ \"name_{}\".format(language),\n+ content_translations[language].title\n+ )\nfor language in ct_links_translations:\n- setattr(lesson, \"computational_thinking_links_{}\".format(language), ct_links_translations[language])\n+ setattr(\n+ lesson,\n+ \"computational_thinking_links_{}\".format(language),\n+ ct_links_translations[language]\n+ )\n+ for language in programming_description_translations:\n+ setattr(\n+ lesson,\n+ \"programming_challenges_description_{}\".format(language),\n+ programming_description_translations[language]\n+ )\n+ for language in heading_tree_translations:\n+ setattr(\n+ lesson,\n+ \"heading_tree_{}\".format(language),\n+ heading_tree_translations[language]\n+ )\nlesson.save()\n# Add programming challenges\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/_UnitPlanLoader.py", "new_path": "csunplugged/topics/management/commands/_UnitPlanLoader.py", "diff": "@@ -45,6 +45,7 @@ class UnitPlanLoader(BaseLoader):\navailable_translations = unit_plan_structure.get('available_translations', [\"en\", \"de\"])\ncontent_translations = {}\nct_links_translations = {}\n+ heading_tree_translations = {}\nfor language in get_available_languages():\ntry:\n@@ -58,10 +59,9 @@ class UnitPlanLoader(BaseLoader):\nif language == get_default_language():\nraise\n- # TODO: Implement translation for heading tree\n- # heading_tree = None\n- # if unit_plan_content.heading_tree:\n- # heading_tree = convert_heading_tree_to_dict(unit_plan_content.heading_tree)\n+ if unit_plan_content.heading_tree:\n+ heading_tree = convert_heading_tree_to_dict(unit_plan_content.heading_tree)\n+ heading_tree_translations[language] = heading_tree\nif \"computational-thinking-links\" in unit_plan_structure:\nfilename = unit_plan_structure[\"computational-thinking-links\"]\n@@ -90,6 +90,8 @@ class UnitPlanLoader(BaseLoader):\nsetattr(unit_plan, \"heading_tree_{}\".format(language), heading_tree)\nfor language in ct_links_translations:\nsetattr(unit_plan, \"computational_thinking_links_{}\".format(language), ct_links_translations[language])\n+ for language in heading_tree_translations:\n+ setattr(unit_plan, \"heading_tree_{}\".format(language), heading_tree_translations[language])\nunit_plan.save()\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/translation.py", "new_path": "csunplugged/topics/translation.py", "diff": "@@ -24,7 +24,7 @@ class TopicTranslationOptions(TranslationOptions):\nclass UnitPlanTranslationOptions(TranslationOptions):\n\"\"\"Translation options for UnitPlan model.\"\"\"\n- fields = ('name', 'content', 'computational_thinking_links')\n+ fields = ('name', 'content', 'computational_thinking_links', 'heading_tree')\nclass ProgrammingChallengeTranslationOptions(TranslationOptions):\n@@ -42,7 +42,7 @@ class ProgrammingChallengeImplementationTranslationOptions(TranslationOptions):\nclass LessonTranslationOptions(TranslationOptions):\n\"\"\"Translation options for Lesson model.\"\"\"\n- fields = ('name', 'content')\n+ fields = ('name', 'content', 'heading_tree')\nclass CurriculumIntegrationTranslationOptions(TranslationOptions):\n" } ]
Python
MIT License
uccser/cs-unplugged
Implement translation of heading tree in Lesson/UnitPlan loaders. Relevant to #614, #615
701,855
17.10.2017 15:42:27
-46,800
aa2752502fd17bb5ce7d63523d29722e8c877da2
Add canterbury.ac.nz domains to allowed hosts in local settings
[ { "change_type": "MODIFY", "old_path": "csunplugged/config/settings/local.py", "new_path": "csunplugged/config/settings/local.py", "diff": "@@ -55,6 +55,8 @@ INSTALLED_APPS += [\"debug_toolbar\", ] # noqa: F405\nINTERNAL_IPS = [\"127.0.0.1\", \"10.0.2.2\", ]\n+ALLOWED_HOSTS = ['.canterbury.ac.nz', 'localhost', '127.0.0.1', '[::1]']\n+\ndef show_django_debug_toolbar(request):\n\"\"\"Show Django Debug Toolbar in every request when running locally.\n" } ]
Python
MIT License
uccser/cs-unplugged
Add canterbury.ac.nz domains to allowed hosts in local settings
701,855
17.10.2017 16:12:54
-46,800
531419cb4cc724c26543583aa09618a8abba82b1
Database migrations for new translation fields
[ { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/migrations/0082_auto_20171017_0306.py", "diff": "+# -*- coding: utf-8 -*-\n+# Generated by Django 1.11.5 on 2017-10-17 03:06\n+from __future__ import unicode_literals\n+\n+import django.contrib.postgres.fields\n+import django.contrib.postgres.fields.jsonb\n+from django.db import migrations, models\n+\n+\n+class Migration(migrations.Migration):\n+\n+ dependencies = [\n+ ('topics', '0081_unitplan_computational_thinking_links'),\n+ ]\n+\n+ operations = [\n+ migrations.AddField(\n+ model_name='curriculumintegration',\n+ name='content_de',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='curriculumintegration',\n+ name='content_en',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='curriculumintegration',\n+ name='content_fr',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='curriculumintegration',\n+ name='languages',\n+ field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=5), default=[], size=100),\n+ ),\n+ migrations.AddField(\n+ model_name='curriculumintegration',\n+ name='name_de',\n+ field=models.CharField(max_length=200, null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='curriculumintegration',\n+ name='name_en',\n+ field=models.CharField(max_length=200, null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='curriculumintegration',\n+ name='name_fr',\n+ field=models.CharField(max_length=200, null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='glossaryterm',\n+ name='definition_de',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='glossaryterm',\n+ name='definition_en',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='glossaryterm',\n+ name='definition_fr',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='glossaryterm',\n+ name='languages',\n+ field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=5), default=[], size=100),\n+ ),\n+ migrations.AddField(\n+ model_name='glossaryterm',\n+ name='term_de',\n+ field=models.CharField(max_length=200, null=True, unique=True),\n+ ),\n+ migrations.AddField(\n+ model_name='glossaryterm',\n+ name='term_en',\n+ field=models.CharField(max_length=200, null=True, unique=True),\n+ ),\n+ migrations.AddField(\n+ model_name='glossaryterm',\n+ name='term_fr',\n+ field=models.CharField(max_length=200, null=True, unique=True),\n+ ),\n+ migrations.AddField(\n+ model_name='lesson',\n+ name='content_de',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='lesson',\n+ name='content_en',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='lesson',\n+ name='content_fr',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='lesson',\n+ name='heading_tree_de',\n+ field=django.contrib.postgres.fields.jsonb.JSONField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='lesson',\n+ name='heading_tree_en',\n+ field=django.contrib.postgres.fields.jsonb.JSONField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='lesson',\n+ name='heading_tree_fr',\n+ field=django.contrib.postgres.fields.jsonb.JSONField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='lesson',\n+ name='languages',\n+ field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=5), default=[], size=100),\n+ ),\n+ migrations.AddField(\n+ model_name='lesson',\n+ name='name_de',\n+ field=models.CharField(max_length=100, null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='lesson',\n+ name='name_en',\n+ field=models.CharField(max_length=100, null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='lesson',\n+ name='name_fr',\n+ field=models.CharField(max_length=100, null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='programmingchallenge',\n+ name='content_de',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='programmingchallenge',\n+ name='content_en',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='programmingchallenge',\n+ name='content_fr',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='programmingchallenge',\n+ name='extra_challenge_de',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='programmingchallenge',\n+ name='extra_challenge_en',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='programmingchallenge',\n+ name='extra_challenge_fr',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='programmingchallenge',\n+ name='languages',\n+ field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=5), default=[], size=100),\n+ ),\n+ migrations.AddField(\n+ model_name='programmingchallenge',\n+ name='name_de',\n+ field=models.CharField(max_length=200, null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='programmingchallenge',\n+ name='name_en',\n+ field=models.CharField(max_length=200, null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='programmingchallenge',\n+ name='name_fr',\n+ field=models.CharField(max_length=200, null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='programmingchallengeimplementation',\n+ name='expected_result_de',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='programmingchallengeimplementation',\n+ name='expected_result_en',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='programmingchallengeimplementation',\n+ name='expected_result_fr',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='programmingchallengeimplementation',\n+ name='hints_de',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='programmingchallengeimplementation',\n+ name='hints_en',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='programmingchallengeimplementation',\n+ name='hints_fr',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='programmingchallengeimplementation',\n+ name='languages',\n+ field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=5), default=[], size=100),\n+ ),\n+ migrations.AddField(\n+ model_name='programmingchallengeimplementation',\n+ name='solution_de',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='programmingchallengeimplementation',\n+ name='solution_en',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='programmingchallengeimplementation',\n+ name='solution_fr',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='topic',\n+ name='content_de',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='topic',\n+ name='content_en',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='topic',\n+ name='content_fr',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='topic',\n+ name='languages',\n+ field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=5), default=[], size=100),\n+ ),\n+ migrations.AddField(\n+ model_name='topic',\n+ name='name_de',\n+ field=models.CharField(max_length=100, null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='topic',\n+ name='name_en',\n+ field=models.CharField(max_length=100, null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='topic',\n+ name='name_fr',\n+ field=models.CharField(max_length=100, null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='topic',\n+ name='other_resources_de',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='topic',\n+ name='other_resources_en',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='topic',\n+ name='other_resources_fr',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='unitplan',\n+ name='computational_thinking_links_de',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='unitplan',\n+ name='computational_thinking_links_en',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='unitplan',\n+ name='computational_thinking_links_fr',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='unitplan',\n+ name='content_de',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='unitplan',\n+ name='content_en',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='unitplan',\n+ name='content_fr',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='unitplan',\n+ name='heading_tree_de',\n+ field=django.contrib.postgres.fields.jsonb.JSONField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='unitplan',\n+ name='heading_tree_en',\n+ field=django.contrib.postgres.fields.jsonb.JSONField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='unitplan',\n+ name='heading_tree_fr',\n+ field=django.contrib.postgres.fields.jsonb.JSONField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='unitplan',\n+ name='languages',\n+ field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=5), default=[], size=100),\n+ ),\n+ migrations.AddField(\n+ model_name='unitplan',\n+ name='name_de',\n+ field=models.CharField(max_length=100, null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='unitplan',\n+ name='name_en',\n+ field=models.CharField(max_length=100, null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='unitplan',\n+ name='name_fr',\n+ field=models.CharField(max_length=100, null=True),\n+ ),\n+ ]\n" } ]
Python
MIT License
uccser/cs-unplugged
Database migrations for new translation fields
701,855
17.10.2017 17:51:14
-46,800
462ad789f557a2fb7d53b19219d647a3705a2fc3
Fix help string for test_suite command in ./csu script.
[ { "change_type": "MODIFY", "old_path": "csu", "new_path": "csu", "diff": "@@ -207,7 +207,7 @@ dev_test_suite() {\necho \"Running test suite...\"\ndocker-compose exec django /docker_venv/bin/coverage run --rcfile=/cs-unplugged/.coveragerc ./manage.py test --settings=config.settings.testing --pattern \"test_*.py\" -v 3\n}\n-defhelp -dev test 'Run test suite with code coverage.'\n+defhelp -dev test_suite 'Run test suite with code coverage.'\n# Run specific test suite\ndev_test_specific() {\n" } ]
Python
MIT License
uccser/cs-unplugged
Fix help string for test_suite command in ./csu script.
701,855
18.10.2017 11:21:42
-46,800
8e0e76dcdb4603d998fe731f3e138dcb75859566
Omit prod/local settings files from code coverage checks
[ { "change_type": "MODIFY", "old_path": ".coveragerc", "new_path": ".coveragerc", "diff": "@@ -14,6 +14,10 @@ omit =\n*/migrations/*\n# Omit database proxy file used with Google Cloud SQL Proxy\ncsunplugged/config/settings/database_proxy.py\n+ # Omit settings files for local and production environments\n+ # TODO: Add integration tests for local and production environments\n+ csunplugged/config/settings/production.py\n+ csunplugged/config/settings/local.py\n[report]\nfail_under=20\n" } ]
Python
MIT License
uccser/cs-unplugged
Omit prod/local settings files from code coverage checks
701,855
18.10.2017 14:15:07
-46,800
019b713fa38ba323a2b9304c8dd3830326f0eb9f
Update default structure directory on BaseLoader
[ { "change_type": "MODIFY", "old_path": "csunplugged/utils/BaseLoader.py", "new_path": "csunplugged/utils/BaseLoader.py", "diff": "@@ -24,7 +24,7 @@ from utils.errors.CouldNotFindConfigFileError import CouldNotFindConfigFileError\nclass BaseLoader():\n\"\"\"Base loader class for individual loaders.\"\"\"\n- def __init__(self, base_path=\"\", structure_dir=\"en\", content_path=\"\", structure_filename=\"\"):\n+ def __init__(self, base_path=\"\", structure_dir=\"structure\", content_path=\"\", structure_filename=\"\"):\n\"\"\"Create a BaseLoader object.\nArgs:\n" } ]
Python
MIT License
uccser/cs-unplugged
Update default structure directory on BaseLoader
701,855
18.10.2017 14:19:49
-46,800
048c5417f6331478cfd905513317d664433afd83
Add missing translation tags to base.html
[ { "change_type": "MODIFY", "old_path": "csunplugged/templates/base.html", "new_path": "csunplugged/templates/base.html", "diff": "<ul class=\"list-unstyled\">\n<li>\n<a href=\"https://twitter.com/UCCSEd\">\n- Twitter\n+ {% trans \"Twitter\" %}\n</a>\n</li>\n<li>\n<a href=\"https://www.youtube.com/user/csunplugged\">\n- YouTube\n+ {% trans \"YouTube\" %}\n</a>\n</li>\n<li>\n<a href=\"https://github.com/uccser/cs-unplugged\">\n- GitHub\n+ {% trans \"GitHub\" %}\n</a>\n</li>\n</ul>\n</div>\n<div class=\"modal-body\" id=\"glossary-modal-definition\"></div>\n<div class=\"modal-footer\">\n- <button type=\"button\" class=\"btn btn-secondary\" data-dismiss=\"modal\">Close</button>\n+ <button type=\"button\" class=\"btn btn-secondary\" data-dismiss=\"modal\">{% trans \"Close\" %}</button>\n</div>\n</div>\n</div>\n" } ]
Python
MIT License
uccser/cs-unplugged
Add missing translation tags to base.html
701,855
18.10.2017 19:07:48
-46,800
86f0f887dcb11996c7fd2a11eda429d41f72f40c
Add makemessages and compilemessages commands to csu script
[ { "change_type": "MODIFY", "old_path": "csu", "new_path": "csu", "diff": "@@ -132,6 +132,20 @@ dev_makeresources() {\n}\ndefhelp -dev makeresources 'Run Django makeresources command.'\n+# Run Django makemessages command\n+dev_makemessages() {\n+ echo \"Creating message files...\"\n+ docker-compose exec django /docker_venv/bin/python3 ./manage.py makemessages -l en\n+}\n+defhelp -dev makemessages 'Run Django makemessages command.'\n+\n+# Run Django compilemessages command\n+dev_compilemessages() {\n+ echo \"Compiling message files...\"\n+ docker-compose exec django /docker_venv/bin/python3 ./manage.py compilemessages\n+}\n+defhelp -dev compilemessages 'Run Django compilemessages command.'\n+\n# Run Django migrate command\ndev_migrate() {\necho \"Applying database migrations...\"\n" } ]
Python
MIT License
uccser/cs-unplugged
Add makemessages and compilemessages commands to csu script
701,855
19.10.2017 14:22:42
-46,800
9109527f5c55c8a4db130b8ed941274d3e7d7659
Add missing lesson content fields to TranslationOptions
[ { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/migrations/0083_auto_20171019_0024.py", "diff": "+# -*- coding: utf-8 -*-\n+# Generated by Django 1.11.5 on 2017-10-19 00:24\n+from __future__ import unicode_literals\n+\n+from django.db import migrations, models\n+\n+\n+class Migration(migrations.Migration):\n+\n+ dependencies = [\n+ ('topics', '0082_auto_20171017_0306'),\n+ ]\n+\n+ operations = [\n+ migrations.AddField(\n+ model_name='lesson',\n+ name='computational_thinking_links_de',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='lesson',\n+ name='computational_thinking_links_en',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='lesson',\n+ name='computational_thinking_links_fr',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='lesson',\n+ name='programming_challenges_description_de',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='lesson',\n+ name='programming_challenges_description_en',\n+ field=models.TextField(null=True),\n+ ),\n+ migrations.AddField(\n+ model_name='lesson',\n+ name='programming_challenges_description_fr',\n+ field=models.TextField(null=True),\n+ ),\n+ ]\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/translation.py", "new_path": "csunplugged/topics/translation.py", "diff": "@@ -42,7 +42,7 @@ class ProgrammingChallengeImplementationTranslationOptions(TranslationOptions):\nclass LessonTranslationOptions(TranslationOptions):\n\"\"\"Translation options for Lesson model.\"\"\"\n- fields = ('name', 'content', 'heading_tree')\n+ fields = ('name', 'content', 'computational_thinking_links', 'programming_challenges_description', 'heading_tree')\nclass CurriculumIntegrationTranslationOptions(TranslationOptions):\n" } ]
Python
MIT License
uccser/cs-unplugged
Add missing lesson content fields to TranslationOptions (#614)
701,855
19.10.2017 14:26:19
-46,800
415e7f04d09d32a53b9cd05d7d41b4cd2743ad5b
Extract translatable strings from database using vinaigrette
[ { "change_type": "MODIFY", "old_path": "csunplugged/config/settings/base.py", "new_path": "csunplugged/config/settings/base.py", "diff": "@@ -37,6 +37,7 @@ DJANGO_APPS = [\nTHIRD_PARTY_APPS = [\n\"django_bootstrap_breadcrumbs\",\n\"modeltranslation\",\n+ \"vinaigrette\",\n]\n# Apps specific for this project go here.\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/models.py", "new_path": "csunplugged/topics/models.py", "diff": "@@ -4,6 +4,7 @@ from django.db import models\nfrom django.utils.translation import get_language\nfrom django.contrib.postgres.fields import ArrayField, JSONField, IntegerRangeField\nfrom resources.models import Resource\n+import vinaigrette\nclass TranslatableModel(models.Model):\n@@ -427,3 +428,14 @@ class ResourceDescription(models.Model):\nresource = models.ForeignKey(Resource, on_delete=models.CASCADE)\nlesson = models.ForeignKey(Lesson, on_delete=models.CASCADE)\ndescription = models.CharField(max_length=300)\n+\n+\n+# Register translatable strings populated from yaml files using vinaigrette\n+vinaigrette.register(CurriculumArea, [\"name\"])\n+vinaigrette.register(ProgrammingChallengeDifficulty, [\"name\"])\n+vinaigrette.register(ProgrammingChallengeLanguage, [\"name\"])\n+vinaigrette.register(AgeGroup, ['description'])\n+vinaigrette.register(ResourceDescription, ['description'])\n+# TODO: Implement translation of classroom resources\n+# (vinaigrette does not support translation of an array of strings)\n+# vinaigrette.register(Lesson, ['classroom_resources'])\n" } ]
Python
MIT License
uccser/cs-unplugged
Extract translatable strings from database using vinaigrette (#612)
701,855
19.10.2017 18:12:34
-46,800
5d3215e348cf0991edec71813bd0327ac3ccef5f
I18n of resource models/loaders
[ { "change_type": "RENAME", "old_path": "csunplugged/resources/content/resources.yaml", "new_path": "csunplugged/resources/content/structure/resources.yaml", "diff": "" }, { "change_type": "MODIFY", "old_path": "csunplugged/resources/management/commands/_ResourcesLoader.py", "new_path": "csunplugged/resources/management/commands/_ResourcesLoader.py", "diff": "@@ -12,15 +12,9 @@ from resources.models import Resource\nclass ResourcesLoader(BaseLoader):\n\"\"\"Custom loader for loading resources.\"\"\"\n- def __init__(self, structure_file, base_path):\n- \"\"\"Create the loader for loading resources.\n-\n- Args:\n- structure_file: file path for structure YAML file (str).\n- base_path: base file path (str).\n- \"\"\"\n- super().__init__(base_path)\n- self.structure_file = structure_file\n+ def __init__(self, **kwargs):\n+ \"\"\"Create the loader for loading resources.\"\"\"\n+ super().__init__(**kwargs)\n@transaction.atomic\ndef load(self):\n@@ -30,11 +24,7 @@ class ResourcesLoader(BaseLoader):\nMissingRequiredFieldError: when no object can be found with the matching\nattribute.\n\"\"\"\n- resources_structure = self.load_yaml_file(\n- self.base_path.format(\n- self.structure_file\n- )\n- )\n+ resources_structure = self.load_yaml_file(self.structure_file_path)\nfor (resource_slug, resource_structure) in resources_structure.items():\ntry:\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/resources/management/commands/loadresources.py", "new_path": "csunplugged/resources/management/commands/loadresources.py", "diff": "@@ -12,11 +12,11 @@ class Command(BaseCommand):\ndef handle(self, *args, **options):\n\"\"\"Automatically called when the loadresources command is given.\"\"\"\n- BASE_PATH = \"resources/content/{}\"\n+ BASE_PATH = \"resources/content/\"\nresource_structure_file = \"resources.yaml\"\nfactory = LoaderFactory()\nfactory.create_resources_loader(\n- resource_structure_file,\n- BASE_PATH\n+ structure_filename=resource_structure_file,\n+ base_path=BASE_PATH\n).load()\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/resources/models.py", "new_path": "csunplugged/resources/models.py", "diff": "\"\"\"Models for the resources application.\"\"\"\nfrom django.db import models\n+import vinaigrette\nclass Resource(models.Model):\n@@ -21,3 +22,7 @@ class Resource(models.Model):\nName of resource (str).\n\"\"\"\nreturn self.name\n+\n+\n+# Extract resource names for tranlsation on makemessages command.\n+vinaigrette.register(Resource, [\"name\"])\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/utils/LoaderFactory.py", "new_path": "csunplugged/utils/LoaderFactory.py", "diff": "@@ -56,6 +56,6 @@ class LoaderFactory:\n\"\"\"Create unit plan loader.\"\"\"\nreturn UnitPlanLoader(self, topic, **kwargs)\n- def create_resources_loader(self, structure_file, base_path):\n+ def create_resources_loader(self, **kwargs):\n\"\"\"Create resources loader.\"\"\"\n- return ResourcesLoader(structure_file, base_path)\n+ return ResourcesLoader(**kwargs)\n" } ]
Python
MIT License
uccser/cs-unplugged
I18n of resource models/loaders (#612, #613, #614, #615)
701,855
20.10.2017 15:01:18
-46,800
3c222c46d1c6b06531fb8a26216ac8f6301d2934
Modify reboot_django command to restart even if already running
[ { "change_type": "MODIFY", "old_path": "csu", "new_path": "csu", "diff": "@@ -199,7 +199,7 @@ defhelp -dev shell \"Open shell to Django folder.\"\n# Reboot Django Docker container\ndev_reboot_django() {\necho \"Rebooting Django Docker container...\"\n- docker-compose up -d django\n+ docker-compose restart django\n}\ndefhelp -dev reboot_django 'Reboot Django Docker container.'\n" } ]
Python
MIT License
uccser/cs-unplugged
Modify reboot_django command to restart even if already running
701,855
20.10.2017 15:03:22
-46,800
771321405c56c23bec4aa6b05d2a058a12d43568
Fix minor translation error in topics template
[ { "change_type": "MODIFY", "old_path": "csunplugged/templates/topics/topic.html", "new_path": "csunplugged/templates/topics/topic.html", "diff": "<div class=\"link-box-container\">\n<a class=\"link-box link-box-md-6\" href=\"{% url 'topics:unit_plan' topic.slug unit_plan.slug %}\">\n<h3 id=\"{{ unit_plan.slug }}\" class=\"link-box-title\">\n- {% blocktrans %}\n- <span class=\"text-muted\">Unit plan:</span> {{ unit_plan.name }}\n- {% endblocktrans %}\n+ <span class=\"text-muted\">{% trans \"Unit plan:\" %}</span> {{ unit_plan.name }}\n</h3>\n</a>\n</div>\n" } ]
Python
MIT License
uccser/cs-unplugged
Fix minor translation error in topics template
701,855
24.10.2017 23:06:21
-46,800
fcb2e916fef86abc48348b590cd1252a94432fd0
Bug fixes found while updating loader tests
[ { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/_ClassroomResourcesLoader.py", "new_path": "csunplugged/topics/management/commands/_ClassroomResourcesLoader.py", "diff": "from django.db import transaction\nfrom utils.BaseLoader import BaseLoader\n-from utils.errors import InvalidConfigValueError\n+from utils.errors.InvalidConfigValueError import InvalidConfigValueError\nfrom topics.models import ClassroomResource\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/_GlossaryTermsLoader.py", "new_path": "csunplugged/topics/management/commands/_GlossaryTermsLoader.py", "diff": "@@ -51,6 +51,7 @@ class GlossaryTermsLoader(BaseLoader):\nfor language in content_translations:\nsetattr(glossary_term, \"definition_{}\".format(language), content_translations[language].html_string)\nsetattr(glossary_term, \"term_{}\".format(language), content_translations[language].title)\n+ glossary_term.languages.append(language)\nglossary_term.save()\nself.log(\"Added glossary term: {}\".format(glossary_term.__str__()))\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/_LessonsLoader.py", "new_path": "csunplugged/topics/management/commands/_LessonsLoader.py", "diff": "@@ -87,10 +87,6 @@ class LessonsLoader(BaseLoader):\nif language == get_default_language():\nraise\n- if lesson_content.heading_tree:\n- heading_tree = convert_heading_tree_to_dict(lesson_content.heading_tree)\n- heading_tree_translations[language] = heading_tree\n-\nif \"programming-challenges-description\" in lesson_structure:\nfilename = lesson_structure[\"programming-challenges-description\"]\nfile_path = self.get_localised_file(language, filename)\n@@ -120,15 +116,22 @@ class LessonsLoader(BaseLoader):\n)\nfor language in content_translations:\n+ translation = content_translations[language]\nsetattr(\nlesson,\n\"content_{}\".format(language),\n- content_translations[language].html_string\n+ translation.html_string\n)\nsetattr(\nlesson,\n\"name_{}\".format(language),\n- content_translations[language].title\n+ translation.title\n+ )\n+ if translation.heading_tree:\n+ setattr(\n+ lesson,\n+ \"heading_tree_{}\".format(language),\n+ convert_heading_tree_to_dict(translation.heading_tree)\n)\nfor language in ct_links_translations:\nsetattr(\n@@ -142,12 +145,8 @@ class LessonsLoader(BaseLoader):\n\"programming_challenges_description_{}\".format(language),\nprogramming_description_translations[language]\n)\n- for language in heading_tree_translations:\n- setattr(\n- lesson,\n- \"heading_tree_{}\".format(language),\n- heading_tree_translations[language]\n- )\n+\n+\nlesson.save()\n# Add programming challenges\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/_ProgrammingChallengesLoader.py", "new_path": "csunplugged/topics/management/commands/_ProgrammingChallengesLoader.py", "diff": "@@ -160,7 +160,7 @@ class ProgrammingChallengesLoader(BaseLoader):\nfor translation_language in get_available_languages():\nfile_path = self.get_localised_file(\n- language,\n+ translation_language,\nos.path.join(challenge_slug, \"{}.md\")\n)\ntry:\n@@ -173,7 +173,7 @@ class ProgrammingChallengesLoader(BaseLoader):\n)\nexpected_result_translations[translation_language] = expected_result_content.html_string\nexcept CouldNotFindMarkdownFileError:\n- if language == get_default_language():\n+ if translation_language == get_default_language():\nraise\n# Load example solution\n@@ -187,7 +187,7 @@ class ProgrammingChallengesLoader(BaseLoader):\n)\nsolution_translations[translation_language] = solution_content.html_string\nexcept CouldNotFindMarkdownFileError:\n- if language == get_default_language():\n+ if translation_language == get_default_language():\nraise\n# Load hint if given\n@@ -204,7 +204,7 @@ class ProgrammingChallengesLoader(BaseLoader):\npass\nimplementation = ProgrammingChallengeImplementation(\n- languages=list(solution_translations.keys()),\n+ languages=list(set(solution_translations.keys()) & set(expected_result_translations.keys())),\nlanguage=language_object,\nchallenge=programming_challenge,\ntopic=self.topic\n@@ -218,7 +218,7 @@ class ProgrammingChallengesLoader(BaseLoader):\nfor translation_language in hint_translations:\nsetattr(\nimplementation,\n- \"hint_{}\".format(translation_language),\n+ \"hints_{}\".format(translation_language),\nhint_translations[translation_language]\n)\nfor translation_language in expected_result_translations:\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/_UnitPlanLoader.py", "new_path": "csunplugged/topics/management/commands/_UnitPlanLoader.py", "diff": "@@ -41,8 +41,6 @@ class UnitPlanLoader(BaseLoader):\nbe found in the config file.\n\"\"\"\nunit_plan_structure = self.load_yaml_file(self.structure_file_path)\n-\n- available_translations = unit_plan_structure.get('available_translations', [\"en\", \"de\"])\ncontent_translations = {}\nct_links_translations = {}\nheading_tree_translations = {}\n@@ -80,7 +78,7 @@ class UnitPlanLoader(BaseLoader):\nunit_plan = self.topic.unit_plans.create(\nslug=self.unit_plan_slug,\n- languages=available_translations,\n+ languages=list(content_translations.keys()),\n)\nfor language in content_translations:\nsetattr(unit_plan, \"content_{}\".format(language), content_translations[language].html_string)\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/models.py", "new_path": "csunplugged/topics/models.py", "diff": "@@ -451,4 +451,3 @@ vinaigrette.register(ProgrammingChallengeLanguage, [\"name\"])\nvinaigrette.register(AgeGroup, ['description'])\nvinaigrette.register(ResourceDescription, ['description'])\nvinaigrette.register(ClassroomResource, ['description'])\n-\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/translation.py", "new_path": "csunplugged/topics/translation.py", "diff": "@@ -41,7 +41,6 @@ class ProgrammingChallengeImplementationTranslationOptions(TranslationOptions):\nclass LessonTranslationOptions(TranslationOptions):\n\"\"\"Translation options for Lesson model.\"\"\"\n-\nfields = ('name', 'content', 'computational_thinking_links', 'programming_challenges_description', 'heading_tree')\n" } ]
Python
MIT License
uccser/cs-unplugged
Bug fixes found while updating loader tests
701,855
24.10.2017 23:41:04
-46,800
161d359e919bb37729a53d272e902ef0cf01894b
Remove unneeded Lorem Ipsum - round 2
[ { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/loaders/assets/unit_plan/en/missing-name/missing-name.md", "new_path": "csunplugged/tests/topics/loaders/assets/unit_plan/en/missing-name/missing-name.md", "diff": "@@ -51,4 +51,3 @@ ullamcorper. Suspendisse placerat dolor a dui. Vestibulum condimentum dui et\nelit. Pellentesque porttitor ipsum at ipsum. Nam massa. Duis lorem. Donec\nporta. Proin ligula. Aenean nunc massa, dapibus quis, imperdiet id, commodo a,\nlacus. Cras sit amet.\n-\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/loaders/assets/unit_plan/en/unit-plan-1/missing-age-groups.md", "new_path": "csunplugged/tests/topics/loaders/assets/unit_plan/en/unit-plan-1/missing-age-groups.md", "diff": "# Unit Plan 1\n-Etiam in massa. Nam ut metus. In rhoncus venenatis tellus. Etiam aliquam. Ut\n-aliquam lectus ut lectus. Nam turpis lacus, tristique sit amet, convallis\n-sollicitudin, commodo a, purus. Nulla vitae eros a diam blandit mollis. Proin\n-luctus feugiat eros. Pellentesque habitant morbi tristique senectus et netus et\n-malesuada fames ac turpis egestas. Duis ultricies urna. Etiam enim urna,\n-pharetra suscipit, varius et, congue quis, odio. Donec lobortis, elit bibendum\n-euismod faucibus, velit nibh egestas libero, vitae pellentesque elit augue ut\n-massa.\n-\n-Nulla consequat erat at massa. Vivamus id mi. Morbi purus enim, dapibus a,\n-facilisis non, tincidunt at, enim. Vestibulum ante ipsum primis in faucibus\n-orci luctus et ultrices posuere cubilia Curae; Duis imperdiet eleifend arcu.\n-Cras magna ligula, consequat at, tempor non, posuere nec, libero. Vestibulum\n-vel ipsum. Praesent congue justo et nunc. Vestibulum nec felis vitae nisl\n-pharetra sollicitudin. Quisque nec arcu vel tellus tristique vestibulum. Aenean\n-vel lacus. Mauris dolor erat, commodo ut, dapibus vehicula, lobortis sit amet,\n-orci. Aliquam augue. In semper nisi nec libero. Cras magna ipsum, scelerisque\n-et, tempor eget, gravida nec, lacus. Fusce eros nisi, ullamcorper blandit,\n-ultricies eget, elementum eget, pede. Phasellus id risus vitae nisl ullamcorper\n-congue. Proin est.\n-\n-Sed eleifend odio sed leo. Mauris tortor turpis, dignissim vel, ornare ac,\n-ultricies quis, magna. Phasellus lacinia, augue ac dictum tempor, nisi felis\n-ornare magna, eu vehicula tellus enim eu neque. Fusce est eros, sagittis eget,\n-interdum a, ornare suscipit, massa. Sed vehicula elementum ligula. Aliquam erat\n-volutpat. Donec odio. Quisque nunc. Integer cursus feugiat magna. Fusce ac elit\n-ut elit aliquam suscipit. Duis leo est, interdum nec, varius in, facilisis\n-vitae, odio. Phasellus eget leo at urna adipiscing vulputate. Nam eu erat vel\n-arcu tristique mattis. Nullam placerat lorem non augue. Cras et velit. Morbi\n-sapien nulla, volutpat a, tristique eu, molestie ac, felis.\n-\n-Suspendisse sit amet tellus non odio porta pellentesque. Nulla facilisi.\n-Integer iaculis condimentum augue. Nullam urna nulla, vestibulum quis, lacinia\n-eget, ullamcorper eu, dui. Quisque dignissim consequat nisl. Pellentesque porta\n-augue in diam. Duis mattis. Aliquam et mi quis turpis pellentesque consequat.\n-Suspendisse nulla erat, lacinia nec, pretium vitae, feugiat ac, quam. Etiam sed\n-tellus vel est ultrices condimentum. Vestibulum euismod. Vivamus blandit.\n-Pellentesque eu urna. Vestibulum consequat sem vitae dui. In dictum feugiat\n-quam. Phasellus placerat. In sem nisl, elementum vitae, venenatis nec, lacinia\n-ac, arcu. Pellentesque gravida egestas mi. Integer rutrum tincidunt libero.\n-\n-Duis viverra. Nulla diam lectus, tincidunt et, scelerisque vitae, aliquam\n-vitae, justo. Quisque eget erat. Donec aliquet porta magna. Sed nisl. Ut\n-tellus. Suspendisse quis mi eget dolor sagittis tristique. Aenean non pede eget\n-nisl bibendum gravida. Class aptent taciti sociosqu ad litora torquent per\n-conubia nostra, per inceptos himenaeos. Morbi laoreet. Suspendisse potenti.\n-Donec accumsan porta felis.\n-\n-Fusce tristique leo quis pede. Cras nibh. Sed eget est vitae tortor mollis\n-ullamcorper. Suspendisse placerat dolor a dui. Vestibulum condimentum dui et\n-elit. Pellentesque porttitor ipsum at ipsum. Nam massa. Duis lorem. Donec\n-porta. Proin ligula. Aenean nunc massa, dapibus quis, imperdiet id, commodo a,\n-lacus. Cras sit amet.\n+English unit plan content.\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/loaders/assets/unit_plan/en/unit-plan-1/missing-lesson-keys.md", "new_path": "csunplugged/tests/topics/loaders/assets/unit_plan/en/unit-plan-1/missing-lesson-keys.md", "diff": "# Unit Plan 1\n-Etiam in massa. Nam ut metus. In rhoncus venenatis tellus. Etiam aliquam. Ut\n-aliquam lectus ut lectus. Nam turpis lacus, tristique sit amet, convallis\n-sollicitudin, commodo a, purus. Nulla vitae eros a diam blandit mollis. Proin\n-luctus feugiat eros. Pellentesque habitant morbi tristique senectus et netus et\n-malesuada fames ac turpis egestas. Duis ultricies urna. Etiam enim urna,\n-pharetra suscipit, varius et, congue quis, odio. Donec lobortis, elit bibendum\n-euismod faucibus, velit nibh egestas libero, vitae pellentesque elit augue ut\n-massa.\n-\n-Nulla consequat erat at massa. Vivamus id mi. Morbi purus enim, dapibus a,\n-facilisis non, tincidunt at, enim. Vestibulum ante ipsum primis in faucibus\n-orci luctus et ultrices posuere cubilia Curae; Duis imperdiet eleifend arcu.\n-Cras magna ligula, consequat at, tempor non, posuere nec, libero. Vestibulum\n-vel ipsum. Praesent congue justo et nunc. Vestibulum nec felis vitae nisl\n-pharetra sollicitudin. Quisque nec arcu vel tellus tristique vestibulum. Aenean\n-vel lacus. Mauris dolor erat, commodo ut, dapibus vehicula, lobortis sit amet,\n-orci. Aliquam augue. In semper nisi nec libero. Cras magna ipsum, scelerisque\n-et, tempor eget, gravida nec, lacus. Fusce eros nisi, ullamcorper blandit,\n-ultricies eget, elementum eget, pede. Phasellus id risus vitae nisl ullamcorper\n-congue. Proin est.\n-\n-Sed eleifend odio sed leo. Mauris tortor turpis, dignissim vel, ornare ac,\n-ultricies quis, magna. Phasellus lacinia, augue ac dictum tempor, nisi felis\n-ornare magna, eu vehicula tellus enim eu neque. Fusce est eros, sagittis eget,\n-interdum a, ornare suscipit, massa. Sed vehicula elementum ligula. Aliquam erat\n-volutpat. Donec odio. Quisque nunc. Integer cursus feugiat magna. Fusce ac elit\n-ut elit aliquam suscipit. Duis leo est, interdum nec, varius in, facilisis\n-vitae, odio. Phasellus eget leo at urna adipiscing vulputate. Nam eu erat vel\n-arcu tristique mattis. Nullam placerat lorem non augue. Cras et velit. Morbi\n-sapien nulla, volutpat a, tristique eu, molestie ac, felis.\n-\n-Suspendisse sit amet tellus non odio porta pellentesque. Nulla facilisi.\n-Integer iaculis condimentum augue. Nullam urna nulla, vestibulum quis, lacinia\n-eget, ullamcorper eu, dui. Quisque dignissim consequat nisl. Pellentesque porta\n-augue in diam. Duis mattis. Aliquam et mi quis turpis pellentesque consequat.\n-Suspendisse nulla erat, lacinia nec, pretium vitae, feugiat ac, quam. Etiam sed\n-tellus vel est ultrices condimentum. Vestibulum euismod. Vivamus blandit.\n-Pellentesque eu urna. Vestibulum consequat sem vitae dui. In dictum feugiat\n-quam. Phasellus placerat. In sem nisl, elementum vitae, venenatis nec, lacinia\n-ac, arcu. Pellentesque gravida egestas mi. Integer rutrum tincidunt libero.\n-\n-Duis viverra. Nulla diam lectus, tincidunt et, scelerisque vitae, aliquam\n-vitae, justo. Quisque eget erat. Donec aliquet porta magna. Sed nisl. Ut\n-tellus. Suspendisse quis mi eget dolor sagittis tristique. Aenean non pede eget\n-nisl bibendum gravida. Class aptent taciti sociosqu ad litora torquent per\n-conubia nostra, per inceptos himenaeos. Morbi laoreet. Suspendisse potenti.\n-Donec accumsan porta felis.\n-\n-Fusce tristique leo quis pede. Cras nibh. Sed eget est vitae tortor mollis\n-ullamcorper. Suspendisse placerat dolor a dui. Vestibulum condimentum dui et\n-elit. Pellentesque porttitor ipsum at ipsum. Nam massa. Duis lorem. Donec\n-porta. Proin ligula. Aenean nunc massa, dapibus quis, imperdiet id, commodo a,\n-lacus. Cras sit amet.\n-\n+English unit plan content.\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/loaders/assets/unit_plan/en/unit-plan-1/missing-lesson-number.md", "new_path": "csunplugged/tests/topics/loaders/assets/unit_plan/en/unit-plan-1/missing-lesson-number.md", "diff": "# Unit Plan 1\n-Etiam in massa. Nam ut metus. In rhoncus venenatis tellus. Etiam aliquam. Ut\n-aliquam lectus ut lectus. Nam turpis lacus, tristique sit amet, convallis\n-sollicitudin, commodo a, purus. Nulla vitae eros a diam blandit mollis. Proin\n-luctus feugiat eros. Pellentesque habitant morbi tristique senectus et netus et\n-malesuada fames ac turpis egestas. Duis ultricies urna. Etiam enim urna,\n-pharetra suscipit, varius et, congue quis, odio. Donec lobortis, elit bibendum\n-euismod faucibus, velit nibh egestas libero, vitae pellentesque elit augue ut\n-massa.\n-\n-Nulla consequat erat at massa. Vivamus id mi. Morbi purus enim, dapibus a,\n-facilisis non, tincidunt at, enim. Vestibulum ante ipsum primis in faucibus\n-orci luctus et ultrices posuere cubilia Curae; Duis imperdiet eleifend arcu.\n-Cras magna ligula, consequat at, tempor non, posuere nec, libero. Vestibulum\n-vel ipsum. Praesent congue justo et nunc. Vestibulum nec felis vitae nisl\n-pharetra sollicitudin. Quisque nec arcu vel tellus tristique vestibulum. Aenean\n-vel lacus. Mauris dolor erat, commodo ut, dapibus vehicula, lobortis sit amet,\n-orci. Aliquam augue. In semper nisi nec libero. Cras magna ipsum, scelerisque\n-et, tempor eget, gravida nec, lacus. Fusce eros nisi, ullamcorper blandit,\n-ultricies eget, elementum eget, pede. Phasellus id risus vitae nisl ullamcorper\n-congue. Proin est.\n-\n-Sed eleifend odio sed leo. Mauris tortor turpis, dignissim vel, ornare ac,\n-ultricies quis, magna. Phasellus lacinia, augue ac dictum tempor, nisi felis\n-ornare magna, eu vehicula tellus enim eu neque. Fusce est eros, sagittis eget,\n-interdum a, ornare suscipit, massa. Sed vehicula elementum ligula. Aliquam erat\n-volutpat. Donec odio. Quisque nunc. Integer cursus feugiat magna. Fusce ac elit\n-ut elit aliquam suscipit. Duis leo est, interdum nec, varius in, facilisis\n-vitae, odio. Phasellus eget leo at urna adipiscing vulputate. Nam eu erat vel\n-arcu tristique mattis. Nullam placerat lorem non augue. Cras et velit. Morbi\n-sapien nulla, volutpat a, tristique eu, molestie ac, felis.\n-\n-Suspendisse sit amet tellus non odio porta pellentesque. Nulla facilisi.\n-Integer iaculis condimentum augue. Nullam urna nulla, vestibulum quis, lacinia\n-eget, ullamcorper eu, dui. Quisque dignissim consequat nisl. Pellentesque porta\n-augue in diam. Duis mattis. Aliquam et mi quis turpis pellentesque consequat.\n-Suspendisse nulla erat, lacinia nec, pretium vitae, feugiat ac, quam. Etiam sed\n-tellus vel est ultrices condimentum. Vestibulum euismod. Vivamus blandit.\n-Pellentesque eu urna. Vestibulum consequat sem vitae dui. In dictum feugiat\n-quam. Phasellus placerat. In sem nisl, elementum vitae, venenatis nec, lacinia\n-ac, arcu. Pellentesque gravida egestas mi. Integer rutrum tincidunt libero.\n-\n-Duis viverra. Nulla diam lectus, tincidunt et, scelerisque vitae, aliquam\n-vitae, justo. Quisque eget erat. Donec aliquet porta magna. Sed nisl. Ut\n-tellus. Suspendisse quis mi eget dolor sagittis tristique. Aenean non pede eget\n-nisl bibendum gravida. Class aptent taciti sociosqu ad litora torquent per\n-conubia nostra, per inceptos himenaeos. Morbi laoreet. Suspendisse potenti.\n-Donec accumsan porta felis.\n-\n-Fusce tristique leo quis pede. Cras nibh. Sed eget est vitae tortor mollis\n-ullamcorper. Suspendisse placerat dolor a dui. Vestibulum condimentum dui et\n-elit. Pellentesque porttitor ipsum at ipsum. Nam massa. Duis lorem. Donec\n-porta. Proin ligula. Aenean nunc massa, dapibus quis, imperdiet id, commodo a,\n-lacus. Cras sit amet.\n-\n+English unit plan content.\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/loaders/assets/unit_plan/en/unit-plan-1/missing-lessons-config.md", "new_path": "csunplugged/tests/topics/loaders/assets/unit_plan/en/unit-plan-1/missing-lessons-config.md", "diff": "# Unit Plan 1\n-Etiam in massa. Nam ut metus. In rhoncus venenatis tellus. Etiam aliquam. Ut\n-aliquam lectus ut lectus. Nam turpis lacus, tristique sit amet, convallis\n-sollicitudin, commodo a, purus. Nulla vitae eros a diam blandit mollis. Proin\n-luctus feugiat eros. Pellentesque habitant morbi tristique senectus et netus et\n-malesuada fames ac turpis egestas. Duis ultricies urna. Etiam enim urna,\n-pharetra suscipit, varius et, congue quis, odio. Donec lobortis, elit bibendum\n-euismod faucibus, velit nibh egestas libero, vitae pellentesque elit augue ut\n-massa.\n-\n-Nulla consequat erat at massa. Vivamus id mi. Morbi purus enim, dapibus a,\n-facilisis non, tincidunt at, enim. Vestibulum ante ipsum primis in faucibus\n-orci luctus et ultrices posuere cubilia Curae; Duis imperdiet eleifend arcu.\n-Cras magna ligula, consequat at, tempor non, posuere nec, libero. Vestibulum\n-vel ipsum. Praesent congue justo et nunc. Vestibulum nec felis vitae nisl\n-pharetra sollicitudin. Quisque nec arcu vel tellus tristique vestibulum. Aenean\n-vel lacus. Mauris dolor erat, commodo ut, dapibus vehicula, lobortis sit amet,\n-orci. Aliquam augue. In semper nisi nec libero. Cras magna ipsum, scelerisque\n-et, tempor eget, gravida nec, lacus. Fusce eros nisi, ullamcorper blandit,\n-ultricies eget, elementum eget, pede. Phasellus id risus vitae nisl ullamcorper\n-congue. Proin est.\n-\n-Sed eleifend odio sed leo. Mauris tortor turpis, dignissim vel, ornare ac,\n-ultricies quis, magna. Phasellus lacinia, augue ac dictum tempor, nisi felis\n-ornare magna, eu vehicula tellus enim eu neque. Fusce est eros, sagittis eget,\n-interdum a, ornare suscipit, massa. Sed vehicula elementum ligula. Aliquam erat\n-volutpat. Donec odio. Quisque nunc. Integer cursus feugiat magna. Fusce ac elit\n-ut elit aliquam suscipit. Duis leo est, interdum nec, varius in, facilisis\n-vitae, odio. Phasellus eget leo at urna adipiscing vulputate. Nam eu erat vel\n-arcu tristique mattis. Nullam placerat lorem non augue. Cras et velit. Morbi\n-sapien nulla, volutpat a, tristique eu, molestie ac, felis.\n-\n-Suspendisse sit amet tellus non odio porta pellentesque. Nulla facilisi.\n-Integer iaculis condimentum augue. Nullam urna nulla, vestibulum quis, lacinia\n-eget, ullamcorper eu, dui. Quisque dignissim consequat nisl. Pellentesque porta\n-augue in diam. Duis mattis. Aliquam et mi quis turpis pellentesque consequat.\n-Suspendisse nulla erat, lacinia nec, pretium vitae, feugiat ac, quam. Etiam sed\n-tellus vel est ultrices condimentum. Vestibulum euismod. Vivamus blandit.\n-Pellentesque eu urna. Vestibulum consequat sem vitae dui. In dictum feugiat\n-quam. Phasellus placerat. In sem nisl, elementum vitae, venenatis nec, lacinia\n-ac, arcu. Pellentesque gravida egestas mi. Integer rutrum tincidunt libero.\n-\n-Duis viverra. Nulla diam lectus, tincidunt et, scelerisque vitae, aliquam\n-vitae, justo. Quisque eget erat. Donec aliquet porta magna. Sed nisl. Ut\n-tellus. Suspendisse quis mi eget dolor sagittis tristique. Aenean non pede eget\n-nisl bibendum gravida. Class aptent taciti sociosqu ad litora torquent per\n-conubia nostra, per inceptos himenaeos. Morbi laoreet. Suspendisse potenti.\n-Donec accumsan porta felis.\n-\n-Fusce tristique leo quis pede. Cras nibh. Sed eget est vitae tortor mollis\n-ullamcorper. Suspendisse placerat dolor a dui. Vestibulum condimentum dui et\n-elit. Pellentesque porttitor ipsum at ipsum. Nam massa. Duis lorem. Donec\n-porta. Proin ligula. Aenean nunc massa, dapibus quis, imperdiet id, commodo a,\n-lacus. Cras sit amet.\n-\n+English unit plan content.\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/loaders/assets/unit_plan/en/unit-plan-1/unit-plan-1.md", "new_path": "csunplugged/tests/topics/loaders/assets/unit_plan/en/unit-plan-1/unit-plan-1.md", "diff": "# Unit Plan 1\n-Etiam in massa. Nam ut metus. In rhoncus venenatis tellus. Etiam aliquam. Ut\n-aliquam lectus ut lectus. Nam turpis lacus, tristique sit amet, convallis\n-sollicitudin, commodo a, purus. Nulla vitae eros a diam blandit mollis. Proin\n-luctus feugiat eros. Pellentesque habitant morbi tristique senectus et netus et\n-malesuada fames ac turpis egestas. Duis ultricies urna. Etiam enim urna,\n-pharetra suscipit, varius et, congue quis, odio. Donec lobortis, elit bibendum\n-euismod faucibus, velit nibh egestas libero, vitae pellentesque elit augue ut\n-massa.\n-\n-Nulla consequat erat at massa. Vivamus id mi. Morbi purus enim, dapibus a,\n-facilisis non, tincidunt at, enim. Vestibulum ante ipsum primis in faucibus\n-orci luctus et ultrices posuere cubilia Curae; Duis imperdiet eleifend arcu.\n-Cras magna ligula, consequat at, tempor non, posuere nec, libero. Vestibulum\n-vel ipsum. Praesent congue justo et nunc. Vestibulum nec felis vitae nisl\n-pharetra sollicitudin. Quisque nec arcu vel tellus tristique vestibulum. Aenean\n-vel lacus. Mauris dolor erat, commodo ut, dapibus vehicula, lobortis sit amet,\n-orci. Aliquam augue. In semper nisi nec libero. Cras magna ipsum, scelerisque\n-et, tempor eget, gravida nec, lacus. Fusce eros nisi, ullamcorper blandit,\n-ultricies eget, elementum eget, pede. Phasellus id risus vitae nisl ullamcorper\n-congue. Proin est.\n-\n-Sed eleifend odio sed leo. Mauris tortor turpis, dignissim vel, ornare ac,\n-ultricies quis, magna. Phasellus lacinia, augue ac dictum tempor, nisi felis\n-ornare magna, eu vehicula tellus enim eu neque. Fusce est eros, sagittis eget,\n-interdum a, ornare suscipit, massa. Sed vehicula elementum ligula. Aliquam erat\n-volutpat. Donec odio. Quisque nunc. Integer cursus feugiat magna. Fusce ac elit\n-ut elit aliquam suscipit. Duis leo est, interdum nec, varius in, facilisis\n-vitae, odio. Phasellus eget leo at urna adipiscing vulputate. Nam eu erat vel\n-arcu tristique mattis. Nullam placerat lorem non augue. Cras et velit. Morbi\n-sapien nulla, volutpat a, tristique eu, molestie ac, felis.\n-\n-Suspendisse sit amet tellus non odio porta pellentesque. Nulla facilisi.\n-Integer iaculis condimentum augue. Nullam urna nulla, vestibulum quis, lacinia\n-eget, ullamcorper eu, dui. Quisque dignissim consequat nisl. Pellentesque porta\n-augue in diam. Duis mattis. Aliquam et mi quis turpis pellentesque consequat.\n-Suspendisse nulla erat, lacinia nec, pretium vitae, feugiat ac, quam. Etiam sed\n-tellus vel est ultrices condimentum. Vestibulum euismod. Vivamus blandit.\n-Pellentesque eu urna. Vestibulum consequat sem vitae dui. In dictum feugiat\n-quam. Phasellus placerat. In sem nisl, elementum vitae, venenatis nec, lacinia\n-ac, arcu. Pellentesque gravida egestas mi. Integer rutrum tincidunt libero.\n-\n-Duis viverra. Nulla diam lectus, tincidunt et, scelerisque vitae, aliquam\n-vitae, justo. Quisque eget erat. Donec aliquet porta magna. Sed nisl. Ut\n-tellus. Suspendisse quis mi eget dolor sagittis tristique. Aenean non pede eget\n-nisl bibendum gravida. Class aptent taciti sociosqu ad litora torquent per\n-conubia nostra, per inceptos himenaeos. Morbi laoreet. Suspendisse potenti.\n-Donec accumsan porta felis.\n-\n-Fusce tristique leo quis pede. Cras nibh. Sed eget est vitae tortor mollis\n-ullamcorper. Suspendisse placerat dolor a dui. Vestibulum condimentum dui et\n-elit. Pellentesque porttitor ipsum at ipsum. Nam massa. Duis lorem. Donec\n-porta. Proin ligula. Aenean nunc massa, dapibus quis, imperdiet id, commodo a,\n-lacus. Cras sit amet.\n-\n+English unit plan content.\n" } ]
Python
MIT License
uccser/cs-unplugged
Remove unneeded Lorem Ipsum - round 2
701,855
25.10.2017 12:07:57
-46,800
ce68783f68d55e25a9d73e2a03f2cd082927b2ab
Modify glossary request to include current language
[ { "change_type": "MODIFY", "old_path": "csunplugged/static/js/website.js", "new_path": "csunplugged/static/js/website.js", "diff": "@@ -19,10 +19,9 @@ function open_glossary_definition() {\n// TODO: Allow code to work for different languages\n$(\"#glossary-modal-term\").text(\"Loading glossary definition...\");\n$(\"#glossary-modal-definition\").html(\"\");\n- var url = \"/topics/glossary/json/\";\n$.ajax({\ntype: \"GET\",\n- url: url,\n+ url: glossary_url,\ndata: \"term=\" + slug,\nasync: true,\ncache: true,\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/templates/base.html", "new_path": "csunplugged/templates/base.html", "diff": "</div>\n<!-- jQuery first, then Tether, then Bootstrap JS. -->\n+ <script>\n+ glossary_url = \"{% url 'topics:glossary_json' %}\"\n+ </script>\n<script src=\"{% static 'js/jquery-3.1.1.min.js' %}\"></script>\n<script src=\"{% static 'js/tether.min.js' %}\"></script>\n<script src=\"{% static 'js/bootstrap.min.js' %}\"></script>\n" } ]
Python
MIT License
uccser/cs-unplugged
Modify glossary request to include current language
701,855
25.10.2017 13:31:46
-46,800
accad8e26c24ef374a2e313897c824ead39f2448
Style fixes after merge develop->translation
[ { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/_CurriculumIntegrationsLoader.py", "new_path": "csunplugged/topics/management/commands/_CurriculumIntegrationsLoader.py", "diff": "\"\"\"Custom loader for loading curriculum integrations.\"\"\"\n-import os.path\n-\nfrom django.core.exceptions import ObjectDoesNotExist\nfrom utils.BaseLoader import BaseLoader\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/_LessonsLoader.py", "new_path": "csunplugged/topics/management/commands/_LessonsLoader.py", "diff": "\"\"\"Custom loader for loading lessons.\"\"\"\n-import os.path\nfrom django.core.exceptions import ObjectDoesNotExist\nfrom utils.BaseLoader import BaseLoader\nfrom utils.language_utils import get_default_language, get_available_languages\nfrom utils.convert_heading_tree_to_dict import convert_heading_tree_to_dict\nfrom utils.errors.MissingRequiredFieldError import MissingRequiredFieldError\nfrom utils.errors.KeyNotFoundError import KeyNotFoundError\n-from utils.errors.InvalidConfigValueError import InvalidConfigValueError\nfrom utils.errors.CouldNotFindMarkdownFileError import CouldNotFindMarkdownFileError\n" } ]
Python
MIT License
uccser/cs-unplugged
Style fixes after merge develop->translation
701,855
27.10.2017 00:50:45
-46,800
bbb5ee42b5b368a2d2923802d6908fc6aca6cfc5
Continuing refactor of loaders, WIP
[ { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/topics/content/de/binary-art.md", "diff": "+# Binary Art\n+\n+{image file-path=\"img/topics/binary_grids.png\"}\n+\n+- Write a secret message by colouring in the grids\n+- Write your name in binary art\n+- Write your birthdate in binary art\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/_CurriculumIntegrationsLoader.py", "new_path": "csunplugged/topics/management/commands/_CurriculumIntegrationsLoader.py", "diff": "@@ -4,7 +4,7 @@ from django.core.exceptions import ObjectDoesNotExist\nfrom utils.BaseLoader import BaseLoader\nfrom utils.language_utils import get_default_language, get_available_languages\n-\n+from utils.TranslatableModelLoader import TranslatableModelLoader\nfrom utils.errors.KeyNotFoundError import KeyNotFoundError\nfrom utils.errors.MissingRequiredFieldError import MissingRequiredFieldError\nfrom utils.errors.CouldNotFindMarkdownFileError import CouldNotFindMarkdownFileError\n@@ -13,7 +13,7 @@ from utils.errors.CouldNotFindMarkdownFileError import CouldNotFindMarkdownFileE\nfrom topics.models import CurriculumArea, Lesson\n-class CurriculumIntegrationsLoader(BaseLoader):\n+class CurriculumIntegrationsLoader(TranslatableModelLoader):\n\"\"\"Custom loader for loading curriculum integrations.\"\"\"\ndef __init__(self, topic, **kwargs):\n@@ -45,6 +45,14 @@ class CurriculumIntegrationsLoader(BaseLoader):\n\"Curriculum Integration\"\n)\n+ integration_translations = self.get_blank_translation_dictionary()\n+\n+ content_filename = \"{}.md\".format(integration_slug)\n+ content_translations = self.get_markdown_translations(content_filename)\n+ for language, content in content_translations.items():\n+ integration_translations[language]['content'] = content.html_string\n+ integration_translations[language]['name'] = content.title\n+\nintegration_number = integration_data.get(\"number\", None)\nintegration_curriculum_areas = integration_data.get(\"curriculum-areas\", None)\nif None in [integration_number, integration_curriculum_areas]:\n@@ -54,27 +62,12 @@ class CurriculumIntegrationsLoader(BaseLoader):\n\"Curriculum Integration\"\n)\n- content_translations = {}\n-\n- for language in get_available_languages():\n- try:\n- integration_content = self.convert_md_file(\n- self.get_localised_file(language, \"{}.md\".format(integration_slug)),\n- self.structure_file_path\n- )\n- content_translations[language] = integration_content\n- except CouldNotFindMarkdownFileError:\n- if language == get_default_language():\n- raise\n-\nintegration = self.topic.curriculum_integrations.create(\nslug=integration_slug,\nnumber=integration_number,\n- languages=list(content_translations.keys()),\n)\n- for language in content_translations:\n- setattr(integration, \"content_{}\".format(language), content_translations[language].html_string)\n- setattr(integration, \"name_{}\".format(language), content_translations[language].title)\n+ self.populate_translations(integration, integration_translations)\n+ self.mark_translation_availability(integration, required_fields=['name', 'content'])\nintegration.save()\n# Add curriculum areas\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/_GlossaryTermsLoader.py", "new_path": "csunplugged/topics/management/commands/_GlossaryTermsLoader.py", "diff": "@@ -7,9 +7,11 @@ from utils.BaseLoader import BaseLoader\nfrom utils.language_utils import get_available_languages, get_default_language\nfrom utils.errors.CouldNotFindMarkdownFileError import CouldNotFindMarkdownFileError\nfrom topics.models import GlossaryTerm\n+from utils.TranslatableModelLoader import TranslatableModelLoader\n-class GlossaryTermsLoader(BaseLoader):\n+\n+class GlossaryTermsLoader(TranslatableModelLoader):\n\"\"\"Custom loader for loading glossary terms.\"\"\"\ndef __init__(self, **kwargs):\n@@ -21,38 +23,29 @@ class GlossaryTermsLoader(BaseLoader):\ndef load(self):\n\"\"\"Load the glossary content into the database.\"\"\"\nglossary_slugs = set()\n+\nfor filename in listdir(self.get_localised_dir(get_default_language())):\nif filename.endswith(self.FILE_EXTENSION):\nglossary_slug = filename[:-len(self.FILE_EXTENSION)]\nglossary_slugs.add(glossary_slug)\n+\n+ for glossary_slug in glossary_slugs:\n+ term_translations = self.get_blank_translation_dictionary()\n+\n+ content_filename = \"{}.md\".format(glossary_slug)\n+ content_translations = self.get_markdown_translations(content_filename)\n+\n+ for language, content in content_translations.items():\n+ term_translations[language]['definition'] = content.html_string\n+ term_translations[language]['term'] = content.title\n+\nglossary_term = GlossaryTerm(\nslug=glossary_slug,\n)\n+ self.populate_translations(glossary_term, term_translations)\n+ self.mark_translation_availability(glossary_term, required_fields=['term', 'definition'])\nglossary_term.save()\n- for glossary_slug in glossary_slugs:\n- content_translations = {}\n- for language in get_available_languages():\n- glossary_term = GlossaryTerm.objects.get(slug=glossary_slug)\n- glossary_file_path = self.get_localised_file(\n- language,\n- \"{}{}\".format(glossary_slug, self.FILE_EXTENSION)\n- )\n- try:\n- glossary_term_content = self.convert_md_file(\n- glossary_file_path,\n- self.structure_file_path\n- )\n- content_translations[language] = glossary_term_content\n- except CouldNotFindMarkdownFileError:\n- if language == get_default_language():\n- raise\n-\n- for language in content_translations:\n- setattr(glossary_term, \"definition_{}\".format(language), content_translations[language].html_string)\n- setattr(glossary_term, \"term_{}\".format(language), content_translations[language].title)\n- glossary_term.languages.append(language)\n- glossary_term.save()\nself.log(\"Added glossary term: {}\".format(glossary_term.__str__()))\nself.log(\"All glossary terms loaded!\\n\")\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/_LearningOutcomesLoader.py", "new_path": "csunplugged/topics/management/commands/_LearningOutcomesLoader.py", "diff": "@@ -31,13 +31,9 @@ class LearningOutcomesLoader(TranslatableModelLoader):\nlearning_outcomes = self.load_yaml_file(self.structure_file_path)\nlearning_outcomes_translations = self.get_yaml_translations(\"learning-outcomes-strings.yaml\")\nfor (outcome_slug, outcome_data) in learning_outcomes.items():\n- # if (\"text\" not in outcome_data) or (outcome_data[\"text\"] is None):\n- # raise MissingRequiredFieldError(\n- # self.structure_file_path,\n- # [\"text\"],\n- # \"Learning Outcome\"\n- # )\n- translations = learning_outcomes_translations.get(outcome_slug, dict())\n+\n+ translations = self.get_blank_translation_dictionary()\n+ translations.update(learning_outcomes_translations.get(outcome_slug, dict()))\n# Create outcome objects and save to db\noutcome = LearningOutcome(\n@@ -50,8 +46,7 @@ class LearningOutcomesLoader(TranslatableModelLoader):\n# Add curriculum areas\ncurriculum_area_slugs = outcome_data.get(\"curriculum-areas\", [])\n- # if curriculum_area_slugs is None:\n- # raise Exception(outcome_slug)\n+\nfor curriculum_area_slug in curriculum_area_slugs:\ntry:\ncurriculum_area = CurriculumArea.objects.get(\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/_LessonsLoader.py", "new_path": "csunplugged/topics/management/commands/_LessonsLoader.py", "diff": "@@ -48,7 +48,6 @@ class LessonsLoader(TranslatableModelLoader):\nfor (lesson_slug, lesson_structure) in lessons_structure.items():\n-\nif lesson_structure is None:\nraise MissingRequiredFieldError(\nself.structure_file_path,\n@@ -56,12 +55,12 @@ class LessonsLoader(TranslatableModelLoader):\n\"Lesson\"\n)\n- lesson_translations = {} # Language, then fields, then values\n+ lesson_translations = self.get_blank_translation_dictionary() # Language, then fields, then values\ncontent_filename = \"{}.md\".format(lesson_slug)\ncontent_translations = self.get_markdown_translations(content_filename)\nfor language, content in content_translations.items():\n- lesson_translations[language] = dict()\n+ # lesson_translations.setdefault(language, dict())\nlesson_translations[language]['content'] = content.html_string\nlesson_translations[language]['name'] = content.title\nif content.heading_tree:\n@@ -76,6 +75,7 @@ class LessonsLoader(TranslatableModelLoader):\nremove_title=False,\n)\nfor language, content in ct_links_translations.items():\n+ # lesson_translations.setdefault(language, dict())\nlesson_translations[language]['computational_thinking_links'] = content.html_string\nif \"programming-challenges-description\" in lesson_structure:\n@@ -86,6 +86,7 @@ class LessonsLoader(TranslatableModelLoader):\nremove_title=False,\n)\nfor language, content in pcd_translations.items():\n+ # lesson_translations.setdefault(language, dict())\nlesson_translations[language]['programming_challenges_description'] = content.html_string\nif \"duration\" in lesson_structure:\n@@ -98,10 +99,8 @@ class LessonsLoader(TranslatableModelLoader):\nslug=lesson_slug,\nduration=lesson_duration,\n)\n- # raise Exception(lesson_translations)\nself.populate_translations(lesson, lesson_translations)\nself.mark_translation_availability(lesson, required_fields=['name', 'content'])\n- # raise Exception(lesson.name)\nlesson.save()\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/_ProgrammingChallengesLoader.py", "new_path": "csunplugged/topics/management/commands/_ProgrammingChallengesLoader.py", "diff": "@@ -8,6 +8,8 @@ from utils.language_utils import get_available_languages, get_default_language\nfrom utils.errors.CouldNotFindMarkdownFileError import CouldNotFindMarkdownFileError\nfrom utils.errors.KeyNotFoundError import KeyNotFoundError\nfrom utils.errors.MissingRequiredFieldError import MissingRequiredFieldError\n+from utils.TranslatableModelLoader import TranslatableModelLoader\n+\nfrom topics.models import (\n@@ -18,7 +20,7 @@ from topics.models import (\n)\n-class ProgrammingChallengesLoader(BaseLoader):\n+class ProgrammingChallengesLoader(TranslatableModelLoader):\n\"\"\"Custom loader for loading programming challenges.\"\"\"\ndef __init__(self, topic, **kwargs):\n@@ -51,12 +53,14 @@ class ProgrammingChallengesLoader(BaseLoader):\n\"Programming Challenge\"\n)\n+ challenge_translations = self.get_blank_translation_dictionary() # Language, then fields, then values\n+\n# Retrieve required variables from md file\nchallenge_set_number = challenge_structure.get(\"challenge-set-number\", None)\nchallenge_number = challenge_structure.get(\"challenge-number\", None)\n- challenge_languages = challenge_structure.get(\"programming-languages\", None)\n+ challenge_prog_languages = challenge_structure.get(\"programming-languages\", None)\nchallenge_difficulty = challenge_structure.get(\"difficulty-level\", None)\n- if None in [challenge_set_number, challenge_number, challenge_languages, challenge_difficulty]:\n+ if None in [challenge_set_number, challenge_number, challenge_prog_languages, challenge_difficulty]:\nraise MissingRequiredFieldError(\nself.structure_file_path,\n[\"challenge-set-number\", \"challenge-number\",\n@@ -64,37 +68,23 @@ class ProgrammingChallengesLoader(BaseLoader):\n\"Programming Challenge\"\n)\n- content_translations = {}\n- extra_challenge_translations = {}\n- for language in get_available_languages():\n- # Build the path to the programming challenge's folder\n- file_path = self.get_localised_file(\n- language,\n- os.path.join(challenge_slug, \"{}.md\")\n+ content_filename = \"{0}.md\".format(challenge_slug)\n+ content_translations = self.get_markdown_translations(\n+ os.path.join(challenge_slug, content_filename)\n)\n- try:\n- challenge_content = self.convert_md_file(\n- file_path.format(challenge_slug),\n- self.structure_file_path\n- )\n- content_translations[language] = challenge_content\n- except CouldNotFindMarkdownFileError:\n- if language == get_default_language():\n- raise\n+ for language, content in content_translations.items():\n+ challenge_translations[language]['content'] = content.html_string\n+ challenge_translations[language]['name'] = content.title\nchallenge_extra_challenge_file = challenge_structure.get(\"extra-challenge\", None)\nif challenge_extra_challenge_file:\n- try:\n- challenge_extra_challenge_content = self.convert_md_file(\n- file_path.format(challenge_extra_challenge_file[:-3]),\n- self.structure_file_path,\n+ extra_challenge_translations = self.get_markdown_translations(\n+ os.path.join(challenge_slug, challenge_extra_challenge_file),\nheading_required=False,\n)\n- extra_challenge_translations[language] = challenge_extra_challenge_content.html_string\n- except CouldNotFindMarkdownFileError:\n- if language == get_default_language():\n- raise\n+ for language, content in extra_challenge_translations.items():\n+ challenge_translations[language]['extra_challenge'] = content.html_string\ntry:\ndifficulty_level = ProgrammingChallengeDifficulty.objects.get(\n@@ -109,36 +99,20 @@ class ProgrammingChallengesLoader(BaseLoader):\nprogramming_challenge = self.topic.programming_challenges.create(\nslug=challenge_slug,\n- languages=list(content_translations.keys()),\nchallenge_set_number=challenge_set_number,\nchallenge_number=challenge_number,\ndifficulty=difficulty_level\n)\n- for language in content_translations:\n- setattr(\n- programming_challenge,\n- \"content_{}\".format(language),\n- content_translations[language].html_string\n- )\n- setattr(\n- programming_challenge,\n- \"name_{}\".format(language),\n- content_translations[language].title\n- )\n- for language in extra_challenge_translations:\n- setattr(\n- programming_challenge,\n- \"extra_challenge_{}\".format(language),\n- extra_challenge_translations[language]\n- )\n+ self.populate_translations(programming_challenge, challenge_translations)\n+ self.mark_translation_availability(programming_challenge, required_fields=['name', 'content'])\nprogramming_challenge.save()\nLOG_TEMPLATE = \"Added programming challenge: {}\"\nself.log(LOG_TEMPLATE.format(programming_challenge.name), 1)\n- for language in challenge_languages:\n- if language is None:\n+ for prog_language in challenge_prog_languages:\n+ if prog_language is None:\nraise MissingRequiredFieldError(\nself.structure_file_path,\n[\"challenge-set-number\", \"challenge-number\",\n@@ -146,88 +120,54 @@ class ProgrammingChallengesLoader(BaseLoader):\n\"Programming Challenge\"\n)\ntry:\n- language_object = ProgrammingChallengeLanguage.objects.get(\n- slug=language\n+ prog_language_object = ProgrammingChallengeLanguage.objects.get(\n+ slug=prog_language\n)\nexcept ObjectDoesNotExist:\nraise KeyNotFoundError(\nself.structure_file_path,\n- language,\n+ prog_language,\n\"Programming Challenge Language\"\n)\n- expected_result_translations = {}\n- solution_translations = {}\n- hint_translations = {}\n- for translation_language in get_available_languages():\n- file_path = self.get_localised_file(\n- translation_language,\n- os.path.join(challenge_slug, \"{}.md\")\n+ implementation_translations = self.get_blank_translation_dictionary()\n+\n+ filename_template = os.path.join(\n+ challenge_slug,\n+ \"{}-{{}}.md\".format(prog_language)\n)\n- try:\n- expected_result_content = self.convert_md_file(\n- file_path.format(\n- \"{}-expected\".format(language)\n- ),\n- self.structure_file_path,\n+\n+ expected_result_translations = self.get_markdown_translations(\n+ filename_template.format('expected'),\nheading_required=False\n)\n- expected_result_translations[translation_language] = expected_result_content.html_string\n- except CouldNotFindMarkdownFileError:\n- if translation_language == get_default_language():\n- raise\n+ for language, content in expected_result_translations.items():\n+ implementation_translations[language]['expected_result'] = content.html_string\n- # Load example solution\n- try:\n- solution_content = self.convert_md_file(\n- file_path.format(\n- \"{}-solution\".format(language)\n- ),\n- self.structure_file_path,\n+ solution_translations = self.get_markdown_translations(\n+ filename_template.format('solution'),\nheading_required=False\n)\n- solution_translations[translation_language] = solution_content.html_string\n- except CouldNotFindMarkdownFileError:\n- if translation_language == get_default_language():\n- raise\n+ for language, content in solution_translations.items():\n+ implementation_translations[language]['solution'] = content.html_string\n- # Load hint if given\n- try:\n- hint_content = self.convert_md_file(\n- file_path.format(\n- \"{}-hints\".format(language)\n- ),\n- self.structure_file_path,\n- heading_required=False\n+ hints_translations = self.get_markdown_translations(\n+ filename_template.format('hints'),\n+ heading_required=False,\n+ required=False\n)\n- hint_translations[translation_language] = hint_content.html_string\n- except CouldNotFindMarkdownFileError:\n- pass\n+ for language, content in hints_translations.items():\n+ implementation_translations[language]['hints'] = content.html_string\nimplementation = ProgrammingChallengeImplementation(\n- languages=list(set(solution_translations.keys()) & set(expected_result_translations.keys())),\n- language=language_object,\n+ language=prog_language_object,\nchallenge=programming_challenge,\ntopic=self.topic\n)\n- for translation_language in solution_translations:\n- setattr(\n- implementation,\n- \"solution_{}\".format(translation_language),\n- solution_translations[translation_language]\n- )\n- for translation_language in hint_translations:\n- setattr(\n- implementation,\n- \"hints_{}\".format(translation_language),\n- hint_translations[translation_language]\n- )\n- for translation_language in expected_result_translations:\n- setattr(\n- implementation,\n- \"expected_result_{}\".format(translation_language),\n- expected_result_translations[translation_language]\n- )\n+\n+ self.populate_translations(implementation, implementation_translations)\n+ self.mark_translation_availability(implementation, required_fields=['solution', 'expected_result'])\n+\nimplementation.save()\nLOG_TEMPLATE = \"Added language implementation: {}\"\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/_ProgrammingChallengesStructureLoader.py", "new_path": "csunplugged/topics/management/commands/_ProgrammingChallengesStructureLoader.py", "diff": "@@ -5,11 +5,11 @@ from django.utils import translation\nfrom utils.BaseLoader import BaseLoader\nfrom utils.language_utils import get_available_languages, get_default_language\nfrom utils.errors.MissingRequiredFieldError import MissingRequiredFieldError\n-\n+from utils.TranslatableModelLoader import TranslatableModelLoader\nfrom topics.models import ProgrammingChallengeLanguage, ProgrammingChallengeDifficulty\n-class ProgrammingChallengesStructureLoader(BaseLoader):\n+class ProgrammingChallengesStructureLoader(TranslatableModelLoader):\n\"\"\"Custom loader for loading structure of programming challenges.\"\"\"\ndef __init__(self, **kwargs):\n@@ -25,20 +25,6 @@ class ProgrammingChallengesStructureLoader(BaseLoader):\nattribute.\n\"\"\"\nstructure = self.load_yaml_file(self.structure_file_path)\n- translation_strings = {}\n- prog_language_translation_strings = {}\n- difficulties_translation_strings = {}\n- for language in get_available_languages():\n- try:\n- strings_dict = self.load_yaml_file(\n- self.get_localised_file(language, \"programming-challenges-structure-strings.yaml\")\n- )\n- except:\n- strings_dict = {}\n- translation_strings[language] = strings_dict\n- # prog_language_translation_strings.setdefault()\n- # prog_language_translation_strings[language] = strings_dict.get(\"languages\", dict())\n- # difficulties_translation_strings[language] = strings_dict.get(\"difficulties\", dict())\nprog_languages = structure.get(\"languages\", None)\ndifficulty_levels = structure.get(\"difficulties\", None)\n@@ -49,6 +35,8 @@ class ProgrammingChallengesStructureLoader(BaseLoader):\n\"Programming Challenge Structure\"\n)\n+ prog_languages_translations = self.get_yaml_translations(\"programming-challenges-languages-strings.yaml\")\n+\nfor (prog_language, prog_language_data) in prog_languages.items():\nif prog_language_data is None:\n@@ -59,12 +47,11 @@ class ProgrammingChallengesStructureLoader(BaseLoader):\n)\n# Check for required fields\n- prog_language_name = prog_language_data.get(\"name\", None)\nprog_language_number = prog_language_data.get(\"number\", None)\n- if prog_language_name is None or prog_language_number is None:\n+ if prog_language_number is None:\nraise MissingRequiredFieldError(\nself.structure_file_path,\n- [\"name\", \"number\"],\n+ [\"number\"],\n\"Programming Challenge Language\"\n)\n@@ -76,47 +63,28 @@ class ProgrammingChallengesStructureLoader(BaseLoader):\nnew_prog_language = ProgrammingChallengeLanguage(\nslug=prog_language,\n- # name=prog_language_name,\nnumber=prog_language_number,\nicon=prog_language_icon\n)\n- for language in translation_strings:\n- name = translation_strings[language].get(\"languages\", {}).get(prog_language)\n- if name:\n- with translation.override(language):\n- new_prog_language.name = name\n- new_prog_language.languages.append(language)\n+\n+ translations = prog_languages_translations.get(prog_language, dict())\n+ self.populate_translations(new_prog_language, translations)\n+ self.mark_translation_availability(new_prog_language, required_fields=['name'])\nnew_prog_language.save()\nself.log(\"Added programming langauge: {}\".format(new_prog_language.__str__()))\n- for difficulty in difficulty_levels:\n+ difficulties_translations = self.get_yaml_translations(\"programming-challenges-difficulties-strings.yaml\")\n- # if difficulty_data is None:\n- # raise MissingRequiredFieldError(\n- # self.structure_file_path,\n- # [\"name\"],\n- # \"Programming Challenge Difficulty\"\n- # )\n-\n- # difficulty_name = difficulty_data.get(\"name\", None)\n- # if difficulty_name is None:\n- # raise MissingRequiredFieldError(\n- # self.structure_file_path,\n- # [\"name\"],\n- # \"Programming Challenge Difficulty\"\n- # )\n+ for difficulty in difficulty_levels:\nnew_difficulty = ProgrammingChallengeDifficulty(\nlevel=difficulty,\n- # name=difficulty_name\n)\n- for language in translation_strings:\n- name = translation_strings[language].get(\"difficulties\", {}).get(difficulty)\n- if name:\n- with translation.override(language):\n- new_difficulty.name = name\n- new_difficulty.languages.append(language)\n+\n+ translations = difficulties_translations.get(difficulty, dict())\n+ self.populate_translations(new_difficulty, translations)\n+ self.mark_translation_availability(new_difficulty, required_fields=['name'])\nnew_difficulty.save()\nself.log(\"Added programming difficulty level: {}\".format(new_difficulty.__str__()))\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/utils/TranslatableModelLoader.py", "new_path": "csunplugged/utils/TranslatableModelLoader.py", "diff": "@@ -46,7 +46,7 @@ class TranslatableModelLoader(BaseLoader):\n**kwargs\n)\nexcept CouldNotFindMarkdownFileError:\n- if language == get_default_language():\n+ if required and language == get_default_language():\nraise\nreturn content_translations\n@@ -70,3 +70,6 @@ class TranslatableModelLoader(BaseLoader):\n):\navailable_languages.append(language)\nmodel.languages = available_languages\n+\n+ def get_blank_translation_dictionary(self):\n+ return { language: dict() for language in get_available_languages() }\n" } ]
Python
MIT License
uccser/cs-unplugged
Continuing refactor of loaders, WIP
701,855
30.10.2017 13:00:18
-46,800
8998fece3b2ed6b60a26921bfd28fcc20958f659
Fix loading of computational thinking links translations
[ { "change_type": "MODIFY", "old_path": "csunplugged/topics/management/commands/_UnitPlanLoader.py", "new_path": "csunplugged/topics/management/commands/_UnitPlanLoader.py", "diff": "@@ -59,7 +59,7 @@ class UnitPlanLoader(TranslatableModelLoader):\nremove_title=False,\n)\nfor language, content in ct_links_translations.items():\n- unit_plan_translations[language][\"other_resources\"] = content.html_string\n+ unit_plan_translations[language][\"computational_thinking_links\"] = content.html_string\nunit_plan = self.topic.unit_plans.create(\nslug=self.unit_plan_slug,\n" } ]
Python
MIT License
uccser/cs-unplugged
Fix loading of computational thinking links translations
701,855
30.10.2017 15:02:37
-46,800
0439b1102abbe89e248154772c798cabcc8d9ad2
Update topic view tests to reflect i18n view changes
[ { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/TopicsTestDataGenerator.py", "new_path": "csunplugged/tests/topics/TopicsTestDataGenerator.py", "diff": "@@ -83,6 +83,7 @@ class TopicsTestDataGenerator:\nname=\"Area {}\".format(number),\nnumber=number,\nparent=parent,\n+ languages=['en'],\n)\narea.save()\nreturn area\n@@ -100,6 +101,7 @@ class TopicsTestDataGenerator:\nslug=\"topic-{}\".format(number),\nname=\"Topic {}\".format(number),\ncontent=\"<p>Content for topic {}.</p>\".format(number),\n+ languages=['en'],\n)\ntopic.save()\nreturn topic\n@@ -119,6 +121,7 @@ class TopicsTestDataGenerator:\nslug=\"unit-plan-{}\".format(number),\nname=\"Unit Plan {}\".format(number),\ncontent=\"<p>Content for unit plan {}.</p>\".format(number),\n+ languages=['en'],\n)\nunit_plan.save()\nreturn unit_plan\n@@ -145,6 +148,7 @@ class TopicsTestDataGenerator:\n),\nduration=number,\ncontent=\"<p>Content for lesson {}.</p>\".format(number),\n+ languages=['en'],\n)\nlesson.save()\nif age_group:\n@@ -167,7 +171,8 @@ class TopicsTestDataGenerator:\n\"\"\"\nage_group = AgeGroup(\nslug=\"{}-{}\".format(min_age, max_age),\n- ages=(min_age, max_age)\n+ ages=(min_age, max_age),\n+ languages=['en'],\n)\nage_group.save()\nreturn age_group\n@@ -183,7 +188,8 @@ class TopicsTestDataGenerator:\n\"\"\"\ndifficulty = ProgrammingChallengeDifficulty(\nlevel=\"1\",\n- name=\"Difficulty-{}\".format(number)\n+ name=\"Difficulty-{}\".format(number),\n+ languages=['en'],\n)\ndifficulty.save()\nreturn difficulty\n@@ -201,6 +207,7 @@ class TopicsTestDataGenerator:\nslug=\"language-{}\".format(number),\nname=\"Language {}\".format(number),\nnumber=number,\n+ languages=['en'],\n)\nlanguage.save()\nreturn language\n@@ -240,6 +247,7 @@ class TopicsTestDataGenerator:\ncontent=content,\nextra_challenge=extra_challenge,\ndifficulty=difficulty,\n+ languages=['en'],\n)\nchallenge.save()\nreturn challenge\n@@ -273,6 +281,7 @@ class TopicsTestDataGenerator:\nexpected_result=expected_result,\nhints=hints,\nsolution=solution,\n+ languages=['en'],\n)\nimplementation.save()\nreturn implementation\n@@ -289,6 +298,7 @@ class TopicsTestDataGenerator:\noutcome = LearningOutcome(\nslug=\"outcome-{}\".format(number),\ntext=\"Outcome {}\".format(number),\n+ languages=['en'],\n)\noutcome.save()\nreturn outcome\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/views/test_glossary_view.py", "new_path": "csunplugged/tests/topics/views/test_glossary_view.py", "diff": "@@ -19,7 +19,8 @@ class GlossaryViewTest(BaseTestWithDB):\nterm = GlossaryTerm(\nslug=\"algorithm\",\nterm=\"Algorithms\",\n- definition=\"<p>Algorithms definition.</p>\"\n+ definition=\"<p>Algorithms definition.</p>\",\n+ languages=[\"en\"]\n)\nterm.save()\n@@ -36,13 +37,15 @@ class GlossaryViewTest(BaseTestWithDB):\nterm1 = GlossaryTerm(\nslug=\"algorithm\",\nterm=\"Algorithms\",\n- definition=\"<p>Algorithms definition.</p>\"\n+ definition=\"<p>Algorithms definition.</p>\",\n+ languages=[\"en\"]\n)\nterm1.save()\nterm2 = GlossaryTerm(\nslug=\"pixel\",\nterm=\"Pixel\",\n- definition=\"<p>Pixel definition.</p>\"\n+ definition=\"<p>Pixel definition.</p>\",\n+ languages=[\"en\"]\n)\nterm2.save()\n@@ -59,19 +62,22 @@ class GlossaryViewTest(BaseTestWithDB):\nterm_c = GlossaryTerm(\nslug=\"c\",\nterm=\"C\",\n- definition=\"\"\n+ definition=\"C\",\n+ languages=[\"en\"]\n)\nterm_c.save()\nterm_b = GlossaryTerm(\nslug=\"b\",\nterm=\"B\",\n- definition=\"\"\n+ definition=\"B\",\n+ languages=[\"en\"]\n)\nterm_b.save()\nterm_a = GlossaryTerm(\nslug=\"a\",\nterm=\"A\",\n- definition=\"\"\n+ definition=\"A\",\n+ languages=[\"en\"]\n)\nterm_a.save()\n@@ -92,7 +98,8 @@ class GlossaryViewTest(BaseTestWithDB):\nterm = GlossaryTerm(\nslug=\"algorithm\",\nterm=\"Algorithms\",\n- definition=\"<p>Algorithms definition.</p>\"\n+ definition=\"<p>Algorithms definition.</p>\",\n+ languages=[\"en\"]\n)\nterm.save()\n@@ -104,7 +111,8 @@ class GlossaryViewTest(BaseTestWithDB):\n{\n\"definition\": \"<p>Algorithms definition.</p>\",\n\"slug\": \"algorithm\",\n- \"term\": \"Algorithms\"\n+ \"term\": \"Algorithms\",\n+ \"translated\": True\n}\n)\n@@ -112,13 +120,15 @@ class GlossaryViewTest(BaseTestWithDB):\nterm1 = GlossaryTerm(\nslug=\"algorithm\",\nterm=\"Algorithms\",\n- definition=\"<p>Algorithms definition.</p>\"\n+ definition=\"<p>Algorithms definition.</p>\",\n+ languages=[\"en\"]\n)\nterm1.save()\nterm2 = GlossaryTerm(\nslug=\"pixel\",\nterm=\"Pixel\",\n- definition=\"<p>Pixel definition.</p>\"\n+ definition=\"<p>Pixel definition.</p>\",\n+ languages=[\"en\"]\n)\nterm2.save()\n@@ -130,7 +140,8 @@ class GlossaryViewTest(BaseTestWithDB):\n{\n\"definition\": \"<p>Pixel definition.</p>\",\n\"slug\": \"pixel\",\n- \"term\": \"Pixel\"\n+ \"term\": \"Pixel\",\n+ \"translated\": True\n}\n)\n" } ]
Python
MIT License
uccser/cs-unplugged
Update topic view tests to reflect i18n view changes
701,855
30.10.2017 22:23:04
-46,800
541d57c4c75bd6d8196fe5a74e4b2a4a504bb188
Change ConfigFile->YAMLFile in custom exception classes These exceptions apply to all yaml files. These used to be only config files, but are now also used for files storing translatable strings.
[ { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/loaders/test_age_groups_loader.py", "new_path": "csunplugged/tests/topics/loaders/test_age_groups_loader.py", "diff": "@@ -6,9 +6,9 @@ from tests.topics.TopicsTestDataGenerator import TopicsTestDataGenerator\nfrom topics.models import AgeGroup\nfrom topics.management.commands._AgeGroupsLoader import AgeGroupsLoader\n-from utils.errors.CouldNotFindConfigFileError import CouldNotFindConfigFileError\n+from utils.errors.CouldNotFindYAMLFileError import CouldNotFindYAMLFileError\nfrom utils.errors.MissingRequiredFieldError import MissingRequiredFieldError\n-from utils.errors.EmptyConfigFileError import EmptyConfigFileError\n+from utils.errors.EmptyYAMLFileError import EmptyYAMLFileError\nclass AgeGroupsLoaderTest(BaseTestWithDB):\n@@ -32,7 +32,7 @@ class AgeGroupsLoaderTest(BaseTestWithDB):\nconfig_file = \"missing.yaml\"\ngroup_loader = AgeGroupsLoader(structure_filename=config_file, base_path=self.base_path)\nself.assertRaises(\n- CouldNotFindConfigFileError,\n+ CouldNotFindYAMLFileError,\ngroup_loader.load,\n)\n@@ -40,7 +40,7 @@ class AgeGroupsLoaderTest(BaseTestWithDB):\nconfig_file = \"empty.yaml\"\ngroup_loader = AgeGroupsLoader(structure_filename=config_file, base_path=self.base_path)\nself.assertRaises(\n- EmptyConfigFileError,\n+ EmptyYAMLFileError,\ngroup_loader.load,\n)\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/loaders/test_curriculum_areas_loader.py", "new_path": "csunplugged/tests/topics/loaders/test_curriculum_areas_loader.py", "diff": "@@ -6,9 +6,9 @@ from tests.topics.TopicsTestDataGenerator import TopicsTestDataGenerator\nfrom topics.models import CurriculumArea\nfrom topics.management.commands._CurriculumAreasLoader import CurriculumAreasLoader\n-from utils.errors.CouldNotFindConfigFileError import CouldNotFindConfigFileError\n+from utils.errors.CouldNotFindYAMLFileError import CouldNotFindYAMLFileError\nfrom utils.errors.MissingRequiredFieldError import MissingRequiredFieldError\n-from utils.errors.EmptyConfigFileError import EmptyConfigFileError\n+from utils.errors.EmptyYAMLFileError import EmptyYAMLFileError\nclass CurriculumAreasLoaderTest(BaseTestWithDB):\n@@ -32,7 +32,7 @@ class CurriculumAreasLoaderTest(BaseTestWithDB):\nconfig_file = \"missing.yaml\"\narea_loader = CurriculumAreasLoader(structure_filename=config_file, base_path=self.base_path)\nself.assertRaises(\n- CouldNotFindConfigFileError,\n+ CouldNotFindYAMLFileError,\narea_loader.load,\n)\n@@ -40,7 +40,7 @@ class CurriculumAreasLoaderTest(BaseTestWithDB):\nconfig_file = \"empty.yaml\"\narea_loader = CurriculumAreasLoader(structure_filename=config_file, base_path=self.base_path)\nself.assertRaises(\n- EmptyConfigFileError,\n+ EmptyYAMLFileError,\narea_loader.load,\n)\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/loaders/test_lessons_loader.py", "new_path": "csunplugged/tests/topics/loaders/test_lessons_loader.py", "diff": "@@ -8,8 +8,8 @@ from django.utils import translation\nfrom topics.models import Lesson\nfrom topics.management.commands._LessonsLoader import LessonsLoader\n-from utils.errors.CouldNotFindConfigFileError import CouldNotFindConfigFileError\n-from utils.errors.EmptyConfigFileError import EmptyConfigFileError\n+from utils.errors.CouldNotFindYAMLFileError import CouldNotFindYAMLFileError\n+from utils.errors.EmptyYAMLFileError import EmptyYAMLFileError\nfrom utils.errors.EmptyMarkdownFileError import EmptyMarkdownFileError\nfrom utils.errors.KeyNotFoundError import KeyNotFoundError\nfrom utils.errors.MissingRequiredFieldError import MissingRequiredFieldError\n@@ -479,7 +479,7 @@ class LessonsLoaderTest(BaseTestWithDB):\nbase_path=self.base_path\n)\nself.assertRaises(\n- CouldNotFindConfigFileError,\n+ CouldNotFindYAMLFileError,\nlesson_loader.load,\n)\n@@ -494,7 +494,7 @@ class LessonsLoaderTest(BaseTestWithDB):\nbase_path=self.base_path\n)\nself.assertRaises(\n- EmptyConfigFileError,\n+ EmptyYAMLFileError,\nlesson_loader.load,\n)\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/tests/topics/loaders/test_topic_loader.py", "new_path": "csunplugged/tests/topics/loaders/test_topic_loader.py", "diff": "@@ -9,7 +9,7 @@ from topics.management.commands._TopicLoader import TopicLoader\nfrom django.utils import translation\n-from utils.errors.CouldNotFindConfigFileError import CouldNotFindConfigFileError\n+from utils.errors.CouldNotFindYAMLFileError import CouldNotFindYAMLFileError\nfrom utils.errors.NoHeadingFoundInMarkdownFileError import NoHeadingFoundInMarkdownFileError\nfrom utils.errors.EmptyMarkdownFileError import EmptyMarkdownFileError\nfrom utils.errors.MissingRequiredFieldError import MissingRequiredFieldError\n@@ -64,7 +64,7 @@ class TopicLoaderTest(BaseTestWithDB):\nstructure_filename=structure_filename\n)\nself.assertRaises(\n- CouldNotFindConfigFileError,\n+ CouldNotFindYAMLFileError,\ntopic_loader.load,\n)\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/utils/BaseLoader.py", "new_path": "csunplugged/utils/BaseLoader.py", "diff": "@@ -15,10 +15,10 @@ from .check_glossary_links import check_converter_glossary_links\nfrom utils.errors.CouldNotFindMarkdownFileError import CouldNotFindMarkdownFileError\nfrom utils.errors.MarkdownStyleError import MarkdownStyleError\nfrom utils.errors.EmptyMarkdownFileError import EmptyMarkdownFileError\n-from utils.errors.EmptyConfigFileError import EmptyConfigFileError\n-from utils.errors.InvalidConfigFileError import InvalidConfigFileError\n+from utils.errors.EmptyYAMLFileError import EmptyYAMLFileError\n+from utils.errors.InvalidYAMLFileError import InvalidYAMLFileError\nfrom utils.errors.NoHeadingFoundInMarkdownFileError import NoHeadingFoundInMarkdownFileError\n-from utils.errors.CouldNotFindConfigFileError import CouldNotFindConfigFileError\n+from utils.errors.CouldNotFindYAMLFileError import CouldNotFindYAMLFileError\nclass BaseLoader():\n@@ -168,25 +168,25 @@ class BaseLoader():\nEither list or string, depending on structure of given yaml file\nRaises:\n- CouldNotFindConfigFileError: when a given config file cannot be found.\n- InvalidConfigFileError: when a given config file is incorrectly formatted.\n- EmptyConfigFileError: when a give config file is empty.\n+ CouldNotFindYAMLFileError: when a given config file cannot be found.\n+ InvalidYAMLFileError: when a given config file is incorrectly formatted.\n+ EmptyYAMLFileError: when a give config file is empty.\n\"\"\"\ntry:\nyaml_file = open(yaml_file_path, encoding=\"UTF-8\").read()\nexcept FileNotFoundError:\n- raise CouldNotFindConfigFileError(yaml_file_path)\n+ raise CouldNotFindYAMLFileError(yaml_file_path)\ntry:\nyaml_contents = yaml.load(yaml_file)\nexcept yaml.YAMLError:\n- raise InvalidConfigFileError(yaml_file_path)\n+ raise InvalidYAMLFileError(yaml_file_path)\nif yaml_contents is None:\n- raise EmptyConfigFileError(yaml_file_path)\n+ raise EmptyYAMLFileError(yaml_file_path)\nif isinstance(yaml_contents, dict) is False:\n- raise InvalidConfigFileError(yaml_file_path)\n+ raise InvalidYAMLFileError(yaml_file_path)\nreturn yaml_contents\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/utils/TranslatableModelLoader.py", "new_path": "csunplugged/utils/TranslatableModelLoader.py", "diff": "from utils.BaseLoader import BaseLoader\nfrom utils.language_utils import get_available_languages, get_default_language\n-from utils.errors.CouldNotFindConfigFileError import CouldNotFindConfigFileError\n+from utils.errors.CouldNotFindYAMLFileError import CouldNotFindYAMLFileError\nfrom utils.errors.CouldNotFindMarkdownFileError import CouldNotFindMarkdownFileError\nfrom utils.errors.InvalidConfigValueError import InvalidConfigValueError\nfrom utils.errors.MissingRequiredModelsError import MissingRequiredModelsError\n@@ -58,7 +58,7 @@ class TranslatableModelLoader(BaseLoader):\ntranslations_filename = self.get_localised_file(language, filename)\ntry:\nyaml = self.load_yaml_file(translations_filename)\n- except CouldNotFindConfigFileError:\n+ except CouldNotFindYAMLFileError:\nif required_slugs and language == get_default_language():\nraise\nyaml = {}\n" }, { "change_type": "DELETE", "old_path": "csunplugged/utils/errors/CouldNotFindConfigFileError.py", "new_path": null, "diff": "-\"\"\"Custom error for missing config file.\"\"\"\n-\n-from .Error import Error\n-\n-ERROR_MESSAGE = \"\\nCould not find config file.\\n\"\n-\n-\n-class CouldNotFindConfigFileError(Error):\n- \"\"\"Custom error for missing config file.\"\"\"\n-\n- def __init__(self, config_file_path):\n- \"\"\"Create the error for missing config file.\"\"\"\n- super().__init__()\n- self.config_file_path = config_file_path\n-\n- def __str__(self):\n- \"\"\"\n- Override default error string.\n-\n- Returns:\n- Error message for missing config file.\n- \"\"\"\n- base_message = self.base_message.format(filename=self.config_file_path)\n- return base_message + ERROR_MESSAGE + self.missing_file_suggestions\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/utils/errors/CouldNotFindYAMLFileError.py", "diff": "+\"\"\"Custom error for missing yaml file.\"\"\"\n+\n+from .Error import Error\n+\n+ERROR_MESSAGE = \"\\nCould not find yaml file.\\n\"\n+\n+\n+class CouldNotFindYAMLFileError(Error):\n+ \"\"\"Custom error for missing yaml file.\"\"\"\n+\n+ def __init__(self, yaml_file_path):\n+ \"\"\"Create the error for missing yaml file.\"\"\"\n+ super().__init__()\n+ self.yaml_file_path = yaml_file_path\n+\n+ def __str__(self):\n+ \"\"\"\n+ Override default error string.\n+\n+ Returns:\n+ Error message for missing yaml file.\n+ \"\"\"\n+ base_message = self.base_message.format(filename=self.yaml_file_path)\n+ return base_message + ERROR_MESSAGE + self.missing_file_suggestions\n" }, { "change_type": "RENAME", "old_path": "csunplugged/utils/errors/EmptyConfigFileError.py", "new_path": "csunplugged/utils/errors/EmptyYAMLFileError.py", "diff": "-\"\"\"Custom error for empty config file.\"\"\"\n+\"\"\"Custom error for empty yaml file.\"\"\"\nfrom .Error import Error\n-ERROR_MESSAGE = \"\\nA config file cannot be empty.\\n\"\n+ERROR_MESSAGE = \"\\nA yaml file cannot be empty.\\n\"\n-class EmptyConfigFileError(Error):\n- \"\"\"Custom error for empty config file.\"\"\"\n+class EmptyYAMLFileError(Error):\n+ \"\"\"Custom error for empty yaml file.\"\"\"\ndef __init__(self, yaml_file_path):\n- \"\"\"Create the error for empty config file.\"\"\"\n+ \"\"\"Create the error for empty yaml file.\"\"\"\nsuper().__init__()\nself.yaml_file_path = yaml_file_path\n@@ -17,6 +17,6 @@ class EmptyConfigFileError(Error):\n\"\"\"Override default error string.\nReturns:\n- Error message for empty config file.\n+ Error message for empty yaml file.\n\"\"\"\nreturn self.base_message.format(filename=self.yaml_file_path) + ERROR_MESSAGE\n" }, { "change_type": "RENAME", "old_path": "csunplugged/utils/errors/InvalidConfigFileError.py", "new_path": "csunplugged/utils/errors/InvalidYAMLFileError.py", "diff": "-\"\"\"Custom error for invalid config file.\"\"\"\n+\"\"\"Custom error for invalid yaml file.\"\"\"\nfrom .Error import Error\nERROR_MESSAGE = \"\"\"\n-Invalid configuration file.\n+Invalid yaml file.\nOptions:\n- Does the file match the expected layout?\n@@ -12,11 +12,11 @@ Options:\n\"\"\"\n-class InvalidConfigFileError(Error):\n- \"\"\"custom error for invalid config file.\"\"\"\n+class InvalidYAMLFileError(Error):\n+ \"\"\"custom error for invalid yaml file.\"\"\"\ndef __init__(self, yaml_file_path):\n- \"\"\"Create error for invalid config file.\"\"\"\n+ \"\"\"Create error for invalid yaml file.\"\"\"\nsuper().__init__()\nself.yaml_file_path = yaml_file_path\n@@ -24,6 +24,6 @@ class InvalidConfigFileError(Error):\n\"\"\"Override default error string.\nReturns:\n- Error message for invalid config file.\n+ Error message for invalid yaml file.\n\"\"\"\nreturn self.base_message.format(filename=self.yaml_file_path) + ERROR_MESSAGE\n" } ]
Python
MIT License
uccser/cs-unplugged
Change ConfigFile->YAMLFile in custom exception classes These exceptions apply to all yaml files. These used to be only config files, but are now also used for files storing translatable strings.
701,855
01.11.2017 21:34:21
-46,800
5a281e615fd7aa779cef3ff3c812a6c0bb7828fa
Initial commit of Crowdin config file
[ { "change_type": "ADD", "old_path": null, "new_path": "crowdin_content.yaml", "diff": "+#\n+# Your crowdin's credentials\n+#\n+\"project_identifier\": \"cs-unplugged\"\n+\"api_key_env\": CROWDIN_API_KEY\n+\"base_path\": \"\"\n+#\"base_url\" : \"\"\n+\n+#\n+# Choose file structure in crowdin\n+# e.g. true or false\n+#\n+\"preserve_hierarchy\": true\n+\n+#\n+# Files configuration\n+#\n+files: [\n+ {\n+ \"source\": \"/csunplugged/topics/content/en/**/*.yaml\",\n+ \"translation\": \"/csunplugged/topics/content/%two_letters_code%/**/%original_file_name%\",\n+\n+ # The parameter \"update_option\" is optional. If it is not set, translations for changed strings will be lost. Useful for typo fixes and minor changes in source strings.\n+ # e.g. \"update_as_unapproved\" or \"update_without_changes\"\n+ #\n+ #\"update_option\" : \"\",\n+ },\n+ {\n+ \"source\": \"/csunplugged/topics/content/en/**/*.md\",\n+ \"translation\": \"/csunplugged/topics/content/%two_letters_code%/**/%original_file_name%\",\n+ }\n+]\n" } ]
Python
MIT License
uccser/cs-unplugged
Initial commit of Crowdin config file
701,855
03.11.2017 18:51:55
-46,800
1b64a99b375b7afe993196bacdf4f89f9d2fc33d
Add TextBoxDrawer utility class for resource text overlays
[ { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/utils/TextBoxDrawer.py", "diff": "+\"\"\"Module for TextBoxDrawer class.\"\"\"\n+\n+from PIL import ImageFont\n+import xml.etree.ElementTree as ET\n+\n+\n+class TextBox(object):\n+ \"\"\"Class to store position/dimensions of a text box.\"\"\"\n+\n+ def __init__(self, x, y, width, height):\n+ \"\"\"Initialise TextBox.\"\"\"\n+ self.x = x\n+ self.y = y\n+ self.width = width\n+ self.height = height\n+\n+\n+class TextBoxDrawer(object):\n+ \"\"\"Class to draw text boxes onto an image.\n+\n+ Text_box layout is defined by elements in an exported SVG.\n+ \"\"\"\n+\n+ def __init__(self, image, draw, svg_path):\n+ \"\"\"Initialise TextBoxDrawer.\n+\n+ Args:\n+ image: PIL Image object\n+ draw: PIL ImageDraw object\n+ svg_path: (str) path to SVG file for text box layout\n+ \"\"\"\n+ self.image = image\n+ self.draw = draw\n+ self.svg = self.load_svg(svg_path)\n+ self.width_ratio, self.height_ratio = self.get_dimension_ratios()\n+\n+ def load_svg(self, svg_path):\n+ \"\"\"Load SVG element tree.\"\"\"\n+ return ET.parse(svg_path).getroot()\n+\n+ def get_dimension_ratios(self):\n+ \"\"\"Get ratios between SVG and image coordinate spaces.\n+\n+ Returns:\n+ (width_ratio, height_ratio) tuple.\n+ \"\"\"\n+ vbx, vby, vbw, vbh = map(int, self.svg.attrib['viewBox'].split())\n+ width, height = self.image.size\n+ width_ratio = width / vbw\n+ height_ratio = height / vbh\n+ return width_ratio, height_ratio\n+\n+ def get_box(self, box_id):\n+ \"\"\"Get TextBox object representing the box with the given ID.\n+\n+ Args:\n+ box_id: (str) identifier of the textbox, matching the 'id' attribute\n+ of a rectangle element in the SVG\n+ Returns:\n+ TextBox object\n+ \"\"\"\n+ element = self.svg.find('{{http://www.w3.org/2000/svg}}rect[@id=\"{}\"]'.format(box_id))\n+ return TextBox(\n+ x=float(element.attrib.get('x', 0)) * self.width_ratio,\n+ y=float(element.attrib.get('y', 0)) * self.height_ratio,\n+ width=float(element.attrib['width']) * self.width_ratio,\n+ height=float(element.attrib['height']) * self.height_ratio\n+ )\n+\n+ def write_text_box(self, box_id, string, **kwargs):\n+ \"\"\"Write text onto image in the space defined by the given textbox.\n+\n+ Args:\n+ box_id: (str) identifier of the textbox, matching the 'id' attribute\n+ of a rectangle element in the SVG\n+ string: (str) text to write\n+ \"\"\"\n+ box = self.get_box(box_id)\n+ self.write_text_box_object(box, string, **kwargs)\n+\n+ def get_text_width(self, font, text):\n+ \"\"\"Get width of given text in given font.\n+\n+ Args:\n+ font: PIL.ImageFont object\n+ text: (str) text to get width of\n+ \"\"\"\n+ return font.getsize(text)[0]\n+\n+ def get_font_height(self, font):\n+ \"\"\"Get height of given font.\n+\n+ Args:\n+ font: PIL.ImageFont object\n+ \"\"\"\n+ ascent, descent = font.getmetrics()\n+ return ascent + descent\n+\n+ def get_font(self, font_path, font_size):\n+ \"\"\"Get ImageFont instance for given font path/size.\"\"\"\n+ return ImageFont.truetype(font_path, font_size)\n+\n+ def write_text_box_object(self, text_box, text, font_path=\"static/fonts/NotoSans-Regular.ttf\",\n+ font_size=11, horiz_just='left', vert_just='top',\n+ justify_last_line=False, **kwargs):\n+ \"\"\"Write text into text_box by modifying line breaks and font size as required.\n+\n+ Args:\n+ text_box: TextBox object\n+ text: (str) text to write\n+ font_path: (str) path to font .ttf file\n+ font_size: (int) target font size, may be reduced to fit if required\n+ horiz_just: (str) left, center, right or justify\n+ vert_just: (str) top, center, bottom\n+ justify_last_line: (bool) if True, fully justify the last line\n+ \"\"\"\n+ font_size_is_ok = False\n+ while not font_size_is_ok:\n+ font = self.get_font(font_path, font_size)\n+ line_height = self.get_font_height(font)\n+ lines = []\n+ line = []\n+ words = text.split()\n+ for word in words:\n+ new_line = ' '.join(line + [word])\n+ size = self.get_text_width(font, new_line)\n+ if size <= text_box.width:\n+ line.append(word)\n+ else:\n+ lines.append(line)\n+ line = [word]\n+ if line:\n+ lines.append(line)\n+ lines = [' '.join(line) for line in lines if line]\n+ text_height = len(lines) * line_height\n+\n+ if text_height <= text_box.height:\n+ font_size_is_ok = True\n+ else:\n+ font_size = max(int(0.9 * font_size), 1)\n+\n+ if vert_just == 'top':\n+ height = text_box.y\n+ elif vert_just == 'center':\n+ height = text_box.y + (text_box.height - text_height)/2\n+ elif vert_just == 'bottom':\n+ height = text_box.y + (text_box.height - text_height)\n+ for index, line in enumerate(lines):\n+ if horiz_just == 'left':\n+ self.draw.text((text_box.x, height), line, font=font, **kwargs)\n+ elif horiz_just == 'right':\n+ total_width = self.get_text_width(font, line)\n+ x_left = text_box.x + text_box.width - total_width\n+ self.draw.text((x_left, height), line, font=font, **kwargs)\n+ elif horiz_just == 'center':\n+ total_width = self.get_text_width(font, line)\n+ x_left = int(text_box.x + ((text_box.width - total_width) / 2))\n+ self.draw.text((x_left, height), line, font=font, **kwargs)\n+ elif horiz_just == 'justify':\n+ words = line.split()\n+ if (index == len(lines) - 1 and not justify_last_line) or \\\n+ len(words) == 1:\n+ self.draw.text((text_box.x, height), line, font=font, **kwargs)\n+ continue\n+ line_without_spaces = ''.join(words)\n+ total_width = self.get_text_width(font, line_without_spaces)\n+ space_width = (text_box.width - total_width) / (len(words) - 1.0)\n+ start_x = text_box.x\n+ for word in words[:-1]:\n+ self.draw.text((start_x, height), word, font=font, **kwargs)\n+ word_width = self.get_text_width(font, word)\n+ start_x += word_width + space_width\n+ last_word_width = self.get_text_width(font, words[-1])\n+ last_word_x = text_box.x + text_box.width - last_word_width\n+ self.draw.text((last_word_x, height), words[-1], font=font, **kwargs)\n+ height += line_height\n" } ]
Python
MIT License
uccser/cs-unplugged
Add TextBoxDrawer utility class for resource text overlays
701,855
05.11.2017 12:55:56
-46,800
a7102c122f161fc1bc1306b424d2fcd323d7d32b
Modify multiline text rendering to more closely mimic AI textbox
[ { "change_type": "MODIFY", "old_path": "csunplugged/utils/TextBoxDrawer.py", "new_path": "csunplugged/utils/TextBoxDrawer.py", "diff": "\"\"\"Module for TextBoxDrawer class.\"\"\"\nfrom PIL import ImageFont\n-import xml.etree.ElementTree as ET\n-\n+from lxml import etree as ET\nclass TextBox(object):\n\"\"\"Class to store position/dimensions of a text box.\"\"\"\n@@ -44,7 +43,7 @@ class TextBoxDrawer(object):\nReturns:\n(width_ratio, height_ratio) tuple.\n\"\"\"\n- vbx, vby, vbw, vbh = map(int, self.svg.attrib['viewBox'].split())\n+ vbx, vby, vbw, vbh = map(float, self.svg.attrib['viewBox'].split())\nwidth, height = self.image.size\nwidth_ratio = width / vbw\nheight_ratio = height / vbh\n@@ -59,12 +58,15 @@ class TextBoxDrawer(object):\nReturns:\nTextBox object\n\"\"\"\n- element = self.svg.find('{{http://www.w3.org/2000/svg}}rect[@id=\"{}\"]'.format(box_id))\n+ text_layer = self.svg.find('{http://www.w3.org/2000/svg}g[@id=\"text\"]')\n+ text_elem = text_layer.find('{{http://www.w3.org/2000/svg}}text[@id=\"{}\"]'.format(box_id))\n+ box_elem = text_elem.getprevious()\n+\nreturn TextBox(\n- x=float(element.attrib.get('x', 0)) * self.width_ratio,\n- y=float(element.attrib.get('y', 0)) * self.height_ratio,\n- width=float(element.attrib['width']) * self.width_ratio,\n- height=float(element.attrib['height']) * self.height_ratio\n+ x=float(box_elem.attrib.get('x', 0)) * self.width_ratio,\n+ y=float(box_elem.attrib.get('y', 0)) * self.height_ratio,\n+ width=float(box_elem.attrib['width']) * self.width_ratio,\n+ height=float(box_elem.attrib['height']) * self.height_ratio\n)\ndef write_text_box(self, box_id, string, **kwargs):\n@@ -100,9 +102,9 @@ class TextBoxDrawer(object):\n\"\"\"Get ImageFont instance for given font path/size.\"\"\"\nreturn ImageFont.truetype(font_path, font_size)\n- def write_text_box_object(self, text_box, text, font_path=\"static/fonts/NotoSans-Regular.ttf\",\n+ def write_text_box_object(self, text_box, text, font_path=\"static/fonts/PatrickHand-Regular.ttf\",\nfont_size=11, horiz_just='left', vert_just='top',\n- justify_last_line=False, **kwargs):\n+ justify_last_line=False, line_spacing=4, color=(0, 0, 0)):\n\"\"\"Write text into text_box by modifying line breaks and font size as required.\nArgs:\n@@ -117,7 +119,6 @@ class TextBoxDrawer(object):\nfont_size_is_ok = False\nwhile not font_size_is_ok:\nfont = self.get_font(font_path, font_size)\n- line_height = self.get_font_height(font)\nlines = []\nline = []\nwords = text.split()\n@@ -132,7 +133,14 @@ class TextBoxDrawer(object):\nif line:\nlines.append(line)\nlines = [' '.join(line) for line in lines if line]\n- text_height = len(lines) * line_height\n+ text_width, text_height = self.draw.multiline_textsize(\n+ '\\n'.join(lines),\n+ font=font,\n+ spacing=line_spacing)\n+\n+ # Reduce text_height by offset at top\n+ (_, _), (_, offset_y) = font.font.getsize(text)\n+ text_height -= offset_y\nif text_height <= text_box.height:\nfont_size_is_ok = True\n@@ -140,37 +148,27 @@ class TextBoxDrawer(object):\nfont_size = max(int(0.9 * font_size), 1)\nif vert_just == 'top':\n- height = text_box.y\n+ y = text_box.y\nelif vert_just == 'center':\n- height = text_box.y + (text_box.height - text_height)/2\n+ y = text_box.y + (text_box.height - text_height)/2\nelif vert_just == 'bottom':\n- height = text_box.y + (text_box.height - text_height)\n- for index, line in enumerate(lines):\n+ y = text_box.y + (text_box.height - text_height)\n+\nif horiz_just == 'left':\n- self.draw.text((text_box.x, height), line, font=font, **kwargs)\n- elif horiz_just == 'right':\n- total_width = self.get_text_width(font, line)\n- x_left = text_box.x + text_box.width - total_width\n- self.draw.text((x_left, height), line, font=font, **kwargs)\n+ x = text_box.x\nelif horiz_just == 'center':\n- total_width = self.get_text_width(font, line)\n- x_left = int(text_box.x + ((text_box.width - total_width) / 2))\n- self.draw.text((x_left, height), line, font=font, **kwargs)\n- elif horiz_just == 'justify':\n- words = line.split()\n- if (index == len(lines) - 1 and not justify_last_line) or \\\n- len(words) == 1:\n- self.draw.text((text_box.x, height), line, font=font, **kwargs)\n- continue\n- line_without_spaces = ''.join(words)\n- total_width = self.get_text_width(font, line_without_spaces)\n- space_width = (text_box.width - total_width) / (len(words) - 1.0)\n- start_x = text_box.x\n- for word in words[:-1]:\n- self.draw.text((start_x, height), word, font=font, **kwargs)\n- word_width = self.get_text_width(font, word)\n- start_x += word_width + space_width\n- last_word_width = self.get_text_width(font, words[-1])\n- last_word_x = text_box.x + text_box.width - last_word_width\n- self.draw.text((last_word_x, height), words[-1], font=font, **kwargs)\n- height += line_height\n+ x = text_box.x + (text_box.width - text_width)/2\n+ elif horiz_just == 'top':\n+ x = text_box.x + (text_box.width - text_width)\n+\n+ # Remove offset from top line, to mimic AI textbox behavior\n+ y -= offset_y\n+\n+ self.draw.multiline_text(\n+ (x, y),\n+ '\\n'.join(lines),\n+ fill=color,\n+ font=font,\n+ align=horiz_just,\n+ spacing=line_spacing\n+ )\n" } ]
Python
MIT License
uccser/cs-unplugged
Modify multiline text rendering to more closely mimic AI textbox
701,855
05.11.2017 19:36:32
-46,800
d48722cda8ebfebe3510bad97ea6bd6e8dcd6cee
Improvements to TextBoxDrawer Extraction of color/font/size information from svg I18n: support for different language fonts, and bidi support Fix line breaking to use language-independent algorithm
[ { "change_type": "MODIFY", "old_path": "csunplugged/utils/TextBoxDrawer.py", "new_path": "csunplugged/utils/TextBoxDrawer.py", "diff": "\"\"\"Module for TextBoxDrawer class.\"\"\"\n+from django.utils.translation import get_language, get_language_bidi\nfrom PIL import ImageFont\nfrom lxml import etree as ET\n+import tinycss\n+import os\n+from bidi.algorithm import get_display\n+from uniseg.linebreak import line_break_units\n+import arabic_reshaper\n+\n+DEFAULT_FONT = \"static/fonts/NotoSans-Regular.ttf\"\n+DEFAULT_FONT_OVERRIDES = {\n+ \"ja\": \"static/fonts/NotoSansCJKjp-Regular.otf\",\n+ \"he\": \"static/fonts/OpenSansHebrew-Regular.ttf\",\n+ \"ar\": \"static/fonts/DejaVuSans.ttf\",\n+}\n+DEFAULT_FONT_SIZE = 20\n+DEFAULT_COLOR = (0, 0, 0)\n+\n+FONT_MAX_ORD = {\n+ \"PatrickHand-Regular\": 255,\n+}\n+\nclass TextBox(object):\n\"\"\"Class to store position/dimensions of a text box.\"\"\"\n- def __init__(self, x, y, width, height):\n+ def __init__(self, x, y, width, height, color, font_path, font_size):\n\"\"\"Initialise TextBox.\"\"\"\nself.x = x\nself.y = y\nself.width = width\nself.height = height\n+ self.color = color\n+ self.font_path = font_path\n+ self.font_size = font_size\nclass TextBoxDrawer(object):\n@@ -62,11 +85,33 @@ class TextBoxDrawer(object):\ntext_elem = text_layer.find('{{http://www.w3.org/2000/svg}}text[@id=\"{}\"]'.format(box_id))\nbox_elem = text_elem.getprevious()\n+ tspan_element = text_elem.find('{http://www.w3.org/2000/svg}tspan')\n+ if tspan_element is not None:\n+ # Use style of the first line of text\n+ style_attrib = tspan_element.attrib['style']\n+ else:\n+ # Use style of the only line of text\n+ style_attrib = text_elem.attrib['style']\n+ rules, _ = tinycss.make_parser().parse_style_attr(style_attrib)\n+ style = {}\n+ for rule in rules:\n+ style[rule.name] = rule.value[0].value\n+ color = style.get('fill')\n+ font = style.get('font-family')\n+ size = style.get('font-size')\n+ if size:\n+ font_size = int(size * self.height_ratio) # Convert font size into image coord space\n+ else:\n+ font_size = None\n+\nreturn TextBox(\nx=float(box_elem.attrib.get('x', 0)) * self.width_ratio,\ny=float(box_elem.attrib.get('y', 0)) * self.height_ratio,\nwidth=float(box_elem.attrib['width']) * self.width_ratio,\n- height=float(box_elem.attrib['height']) * self.height_ratio\n+ height=float(box_elem.attrib['height']) * self.height_ratio,\n+ color=color,\n+ font_path=\"static/fonts/{}.ttf\".format(font),\n+ font_size=font_size\n)\ndef write_text_box(self, box_id, string, **kwargs):\n@@ -102,37 +147,67 @@ class TextBoxDrawer(object):\n\"\"\"Get ImageFont instance for given font path/size.\"\"\"\nreturn ImageFont.truetype(font_path, font_size)\n- def write_text_box_object(self, text_box, text, font_path=\"static/fonts/PatrickHand-Regular.ttf\",\n- font_size=11, horiz_just='left', vert_just='top',\n- justify_last_line=False, line_spacing=4, color=(0, 0, 0)):\n+ def get_default_font(self):\n+ \"\"\"Get default font for the current language.\"\"\"\n+ language = get_language()\n+ if language in DEFAULT_FONT_OVERRIDES:\n+ return DEFAULT_FONT_OVERRIDES[language]\n+ return DEFAULT_FONT\n+\n+ def write_text_box_object(self, text_box, text, font_path=None,\n+ font_size=None, horiz_just='left', vert_just='top',\n+ line_spacing=4, color=None):\n\"\"\"Write text into text_box by modifying line breaks and font size as required.\nArgs:\ntext_box: TextBox object\ntext: (str) text to write\n- font_path: (str) path to font .ttf file\n- font_size: (int) target font size, may be reduced to fit if required\n+ font_path: (str) path to font .ttf file. This parameter is checked\n+ first, followed by an attempt to match the font from the SVG,\n+ and then a fallback language\n+ font_size: (int) target font size, may be reduced to fit if required.\n+ This parameter is checked first, falling back to the original\n+ font size from the SVG\nhoriz_just: (str) left, center, right or justify\nvert_just: (str) top, center, bottom\n- justify_last_line: (bool) if True, fully justify the last line\n+ line_spacing: (int) number of pixels between text lines\n+ color: (RGB 3-tuple or HEX string) text color. This parameter is\n+ checked first, falling back to the original color from the SVG\n\"\"\"\n+ if get_language() == 'ar':\n+ text = arabic_reshaper.reshape(text)\n+\n+ font_path = font_path or text_box.font_path\n+ if font_path:\n+ font_name = os.path.splitext(os.path.basename(font_path))[0]\n+ max_ord_allowed = FONT_MAX_ORD[font_name]\n+ max_ord = ord(max(text, key=ord))\n+ if max_ord > max_ord_allowed:\n+ # Text contains codepoints without a glyph in requested font\n+ font_path = self.get_default_font()\n+ else:\n+ font_path = self.get_default_font()\n+\n+ font_size = font_size or text_box.font_size or DEFAULT_FONT_SIZE\n+ color = color or text_box.color or DEFAULT_COLOR\n+\nfont_size_is_ok = False\nwhile not font_size_is_ok:\nfont = self.get_font(font_path, font_size)\nlines = []\n- line = []\n- words = text.split()\n- for word in words:\n- new_line = ' '.join(line + [word])\n- size = self.get_text_width(font, new_line)\n- if size <= text_box.width:\n- line.append(word)\n- else:\n+ line = \"\"\n+ breakable_units = line_break_units(text)\n+ for unit in breakable_units:\n+ potential_line = line + unit\n+ size = self.get_text_width(font, potential_line)\n+ if size >= text_box.width:\nlines.append(line)\n- line = [word]\n+ line = unit\n+ else:\n+ line += unit\n+\nif line:\nlines.append(line)\n- lines = [' '.join(line) for line in lines if line]\ntext_width, text_height = self.draw.multiline_textsize(\n'\\n'.join(lines),\nfont=font,\n@@ -145,8 +220,19 @@ class TextBoxDrawer(object):\nif text_height <= text_box.height:\nfont_size_is_ok = True\nelse:\n+ # Decrease font size exponentially, and try again\nfont_size = max(int(0.9 * font_size), 1)\n+ text = '\\n'.join(lines)\n+ if get_language_bidi():\n+ # Get RTL text\n+ text = get_display(text)\n+ # Flip horizontal justification\n+ if horiz_just == \"right\":\n+ horiz_just = \"left\"\n+ elif horiz_just == \"left\":\n+ horiz_just = \"right\"\n+\nif vert_just == 'top':\ny = text_box.y\nelif vert_just == 'center':\n@@ -158,7 +244,7 @@ class TextBoxDrawer(object):\nx = text_box.x\nelif horiz_just == 'center':\nx = text_box.x + (text_box.width - text_width)/2\n- elif horiz_just == 'top':\n+ elif horiz_just == 'right':\nx = text_box.x + (text_box.width - text_width)\n# Remove offset from top line, to mimic AI textbox behavior\n@@ -166,7 +252,7 @@ class TextBoxDrawer(object):\nself.draw.multiline_text(\n(x, y),\n- '\\n'.join(lines),\n+ text,\nfill=color,\nfont=font,\nalign=horiz_just,\n" } ]
Python
MIT License
uccser/cs-unplugged
Improvements to TextBoxDrawer - Extraction of color/font/size information from svg - I18n: support for different language fonts, and bidi support - Fix line breaking to use language-independent algorithm
701,855
05.11.2017 19:40:49
-46,800
92c01be43b80247ce2233851dd74b041bb9d44b0
Modify Barcode Checksum Poster resource to dynamically overlay text
[ { "change_type": "MODIFY", "old_path": "csunplugged/resources/views/BarcodeChecksumPosterResourceGenerator.py", "new_path": "csunplugged/resources/views/BarcodeChecksumPosterResourceGenerator.py", "diff": "\"\"\"Class for Barcode Checksum Poster resource generator.\"\"\"\n-from PIL import Image\n+from PIL import Image, ImageDraw\nfrom utils.BaseResourceGenerator import BaseResourceGenerator\n+from utils.TextBoxDrawer import TextBoxDrawer\n+from django.utils.translation import ugettext as _\nclass BarcodeChecksumPosterResourceGenerator(BaseResourceGenerator):\n@@ -17,9 +19,40 @@ class BarcodeChecksumPosterResourceGenerator(BaseResourceGenerator):\nReturns:\nA dictionary of the one page for the resource.\n\"\"\"\n- image_path = \"static/img/resources/barcode-checksum-poster/{}-digits.png\"\n- image_path = image_path.format(self.requested_options[\"barcode_length\"])\n+ path = \"static/img/resources/barcode-checksum-poster/{}-digits\"\n+ path = path.format(self.requested_options[\"barcode_length\"])\n+ image_path = \"{}.png\".format(path)\n+ svg_path = \"{}.svg\".format(path)\nimage = Image.open(image_path)\n+\n+ draw = ImageDraw.Draw(image)\n+ textbox_drawer = TextBoxDrawer(image, draw, svg_path)\n+\n+ textbox_drawer.write_text_box(\n+ \"title\",\n+ _(\"13 Digit Barcode\"),\n+ horiz_just=\"center\",\n+ vert_just=\"center\",\n+ )\n+\n+ headings = {\n+ \"heading1\": _(\"Separate!\"),\n+ \"heading2\": _(\"Operate!\"),\n+ \"heading3\": _(\"Calculate!\")\n+ }\n+\n+ for heading_id, heading in headings.items():\n+ textbox_drawer.write_text_box(\n+ heading_id,\n+ heading,\n+ )\n+\n+ textbox_drawer.write_text_box(\n+ \"paragraph\",\n+ _(\"Remember that this algorithm uses modulo 10, so we are only \"\n+ \"interested in the number in the one's column.\"),\n+ )\n+\nreturn {\"type\": \"image\", \"data\": image}\n@property\n" } ]
Python
MIT License
uccser/cs-unplugged
Modify Barcode Checksum Poster resource to dynamically overlay text
701,855
05.11.2017 19:42:40
-46,800
b3e394a5db4c106e400451bfe786cdf76c7c95e8
Add sample fonts for development of TextBoxDrawer These fonts are not intended for production, and are for prototyping i18n features of the resource generation process.
[ { "change_type": "ADD", "old_path": "csunplugged/static/fonts/DejaVuSans.ttf", "new_path": "csunplugged/static/fonts/DejaVuSans.ttf", "diff": "Binary files /dev/null and b/csunplugged/static/fonts/DejaVuSans.ttf differ\n" }, { "change_type": "ADD", "old_path": "csunplugged/static/fonts/NotoSansCJKjp-Regular.otf", "new_path": "csunplugged/static/fonts/NotoSansCJKjp-Regular.otf", "diff": "Binary files /dev/null and b/csunplugged/static/fonts/NotoSansCJKjp-Regular.otf differ\n" }, { "change_type": "ADD", "old_path": "csunplugged/static/fonts/OpenSansHebrew-Regular.ttf", "new_path": "csunplugged/static/fonts/OpenSansHebrew-Regular.ttf", "diff": "Binary files /dev/null and b/csunplugged/static/fonts/OpenSansHebrew-Regular.ttf differ\n" } ]
Python
MIT License
uccser/cs-unplugged
Add sample fonts for development of TextBoxDrawer These fonts are not intended for production, and are for prototyping i18n features of the resource generation process.
701,855
05.11.2017 19:48:13
-46,800
baea8641a3225f24cb608d3663895a377d4867b8
Add sample assets for prototype of dynamic text field rendering
[ { "change_type": "MODIFY", "old_path": "csunplugged/locale/de/LC_MESSAGES/django.po", "new_path": "csunplugged/locale/de/LC_MESSAGES/django.po", "diff": "@@ -21,3 +21,25 @@ msgstr \"\"\n#: topics/templates/topics/index.html:3\nmsgid \"Topics\"\nmsgstr \"Thema\"\n+\n+#: resources/views/BarcodeChecksumPosterResourceGenerator.py:34\n+msgid \"13 Digit Barcode\"\n+msgstr \"13 Stellige Strichcode\"\n+\n+#: resources/views/BarcodeChecksumPosterResourceGenerator.py:42\n+msgid \"Separate!\"\n+msgstr \"Getrennte!\"\n+\n+#: resources/views/BarcodeChecksumPosterResourceGenerator.py:43\n+msgid \"Operate!\"\n+msgstr \"Arbeiten!\"\n+\n+#: resources/views/BarcodeChecksumPosterResourceGenerator.py:44\n+msgid \"Calculate!\"\n+msgstr \"Berechnen!\"\n+\n+#: resources/views/BarcodeChecksumPosterResourceGenerator.py:57\n+msgid \"\"\n+\"Remember that this algorithm uses modulo 10, so we are only interested in \"\n+\"the number in the one's column.\"\n+msgstr \"Denken Sie daran, dass dieser Algorithmus Modulo 10 verwendet, so dass wir nur an der Zahl in der Spalte des einen interessiert sind.\"\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/locale/en/LC_MESSAGES/django.po", "diff": "+# SOME DESCRIPTIVE TITLE.\n+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER\n+# This file is distributed under the same license as the PACKAGE package.\n+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.\n+#\n+#, fuzzy\n+msgid \"\"\n+msgstr \"\"\n+\"Project-Id-Version: PACKAGE VERSION\\n\"\n+\"Report-Msgid-Bugs-To: \\n\"\n+\"POT-Creation-Date: 2017-11-04 09:16+0000\\n\"\n+\"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n\"\n+\"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n\"\n+\"Language-Team: LANGUAGE <LL@li.org>\\n\"\n+\"Language: \\n\"\n+\"MIME-Version: 1.0\\n\"\n+\"Content-Type: text/plain; charset=UTF-8\\n\"\n+\"Content-Transfer-Encoding: 8bit\\n\"\n+\n+#: resources/views/BarcodeChecksumPosterResourceGenerator.py:34\n+msgid \"13 Digit Barcode\"\n+msgstr \"\"\n+\n+#: resources/views/BarcodeChecksumPosterResourceGenerator.py:42\n+msgid \"Separate!\"\n+msgstr \"\"\n+\n+#: resources/views/BarcodeChecksumPosterResourceGenerator.py:43\n+msgid \"Operate!\"\n+msgstr \"\"\n+\n+#: resources/views/BarcodeChecksumPosterResourceGenerator.py:44\n+msgid \"Calculate!\"\n+msgstr \"\"\n+\n+#: resources/views/BarcodeChecksumPosterResourceGenerator.py:57\n+msgid \"\"\n+\"Remember that this algorithm uses modulo 10, so we are only interested in \"\n+\"the number in the one's column.\"\n+msgstr \"\"\n+\n+#: templates/general/about.html:16\n+msgid \"About\"\n+msgstr \"\"\n+\n+#: templates/general/computational-thinking.html:17\n+msgid \"Computational Thinking and CS Unplugged\"\n+msgstr \"\"\n+\n+#: templates/general/contact.html:17\n+msgid \"Contact Us\"\n+msgstr \"\"\n+\n+#: templates/general/index.html:15\n+msgid \"Computer Science\"\n+msgstr \"\"\n+\n+#: templates/general/index.html:16\n+msgid \"without a computer\"\n+msgstr \"\"\n+\n+#: templates/general/people.html:17\n+msgid \"People\"\n+msgstr \"\"\n+\n+#: templates/general/principles.html:18\n+msgid \"Principles\"\n+msgstr \"\"\n+\n+#: templates/resources/index.html:8 templates/resources/index.html:17\n+msgid \"Resources\"\n+msgstr \"\"\n+\n+#: templates/topics/all-curriculum-integration-list.html:8\n+#: templates/topics/all-curriculum-integration-list.html:18\n+msgid \"Curriculum Integrations\"\n+msgstr \"\"\n+\n+#: templates/topics/index.html:8 templates/topics/index.html:17\n+msgid \"Topics\"\n+msgstr \"\"\n" }, { "change_type": "MODIFY", "old_path": "csunplugged/static/img/resources/barcode-checksum-poster/13-digits.png", "new_path": "csunplugged/static/img/resources/barcode-checksum-poster/13-digits.png", "diff": "Binary files a/csunplugged/static/img/resources/barcode-checksum-poster/13-digits.png and b/csunplugged/static/img/resources/barcode-checksum-poster/13-digits.png differ\n" }, { "change_type": "ADD", "old_path": null, "new_path": "csunplugged/static/img/resources/barcode-checksum-poster/13-digits.svg", "diff": "+<?xml version=\"1.0\" encoding=\"utf-8\"?>\n+<!-- Generator: Adobe Illustrator 22.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->\n+<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"\n+ viewBox=\"0 0 555.4 841.9\" style=\"enable-background:new 0 0 555.4 841.9;\" xml:space=\"preserve\">\n+<g id=\"Layer_1\">\n+\n+ <image style=\"overflow:visible;\" width=\"2133\" height=\"2957\" xlink:href=\"../../../../../../../Downloads/13barcode_resource_textless.png\" transform=\"matrix(0.2604 0 0 0.2604 0 71.89)\">\n+ </image>\n+</g>\n+<g id=\"text\">\n+ <rect x=\"100.7\" y=\"9.9\" style=\"fill:none;\" width=\"354\" height=\"49.6\"/>\n+\n+ <text id=\"title\" transform=\"matrix(1 0 0 1 116.9529 49.2147)\" style=\"fill:#14B24B; font-family:'PatrickHand-Regular'; font-size:55px;\">13 Digit Barcode</text>\n+ <rect x=\"5\" y=\"81.9\" style=\"fill:none;\" width=\"93\" height=\"20\"/>\n+ <text id=\"heading1\" transform=\"matrix(1 0 0 1 5 97.62)\" style=\"font-family:'PatrickHand-Regular'; font-size:22px;\">Heading 1</text>\n+ <rect x=\"6\" y=\"315.9\" style=\"fill:none;\" width=\"91\" height=\"19\"/>\n+\n+ <text id=\"heading2\" transform=\"matrix(1 0 0 1 6 331.62)\" style=\"fill:#CB4C9B; font-family:'PatrickHand-Regular'; font-size:22px;\">Heading 2</text>\n+ <rect x=\"5\" y=\"188.4\" style=\"fill:none;\" width=\"97.5\" height=\"89\"/>\n+ <text id=\"paragraph\" transform=\"matrix(1 0 0 1 5 197.6849)\"><tspan x=\"0\" y=\"0\" style=\"font-family:'PatrickHand-Regular'; font-size:13px;\">This is the descrip</tspan><tspan x=\"85.2\" y=\"0\" style=\"font-family:'PatrickHand-Regular'; font-size:13px;\">-</tspan><tspan x=\"0\" y=\"15.6\" style=\"font-family:'PatrickHand-Regular'; font-size:13px;\">tion of the resource. </tspan><tspan x=\"0\" y=\"31.2\" style=\"font-family:'PatrickHand-Regular'; font-size:13px;\">It is q uite long and </tspan><tspan x=\"0\" y=\"46.8\" style=\"font-family:'PatrickHand-Regular'; font-size:13px;\">goes on and on. Lots </tspan><tspan x=\"0\" y=\"62.4\" style=\"font-family:'PatrickHand-Regular'; font-size:13px;\">of explaining, yes. </tspan><tspan x=\"0\" y=\"78\" style=\"font-family:'PatrickHand-Regular'; font-size:13px;\">On and on and on.g</tspan></text>\n+ <rect x=\"8.2\" y=\"477.4\" style=\"fill:none;\" width=\"91\" height=\"19\"/>\n+\n+ <text id=\"heading3\" transform=\"matrix(1 0 0 1 8.25 493.1057)\" style=\"fill:#02B8E9; font-family:'PatrickHand-Regular'; font-size:22px;\">Heading 3</text>\n+</g>\n+</svg>\n" } ]
Python
MIT License
uccser/cs-unplugged
Add sample assets for prototype of dynamic text field rendering
701,855
05.11.2017 19:51:05
-46,800
6fbfed212d55b4aabe133172878d42fc1ab821b2
Update requirements for implementation of dynamic text field rendering
[ { "change_type": "MODIFY", "old_path": "requirements/base.txt", "new_path": "requirements/base.txt", "diff": "@@ -7,6 +7,7 @@ wheel==0.30.0\n# Resources\nPillow==4.3.0\nyattag==1.9.2\n+tinycss==0.4\n# Markdown\nverto==0.6.1\n@@ -17,3 +18,11 @@ PyYAML==3.12\n# System tools\ntqdm==4.19.4\n+\n+# XML Parsing\n+lxml==4.1.1\n+\n+# I18n\n+uniseg==0.7.1\n+python-bidi==0.4.0\n+arabic-reshaper==2.0.8\n" } ]
Python
MIT License
uccser/cs-unplugged
Update requirements for implementation of dynamic text field rendering
701,860
06.11.2017 15:03:41
-46,800
bf4dde90b58e5c9f6704384ecc30a52df3bc77b7
Add animations for 'Sending rocket to Mars' (fixes
[ { "change_type": "ADD", "old_path": "csunplugged/static/img/topics/kidbots-rocket-2.gif", "new_path": "csunplugged/static/img/topics/kidbots-rocket-2.gif", "diff": "Binary files /dev/null and b/csunplugged/static/img/topics/kidbots-rocket-2.gif differ\n" }, { "change_type": "DELETE", "old_path": "csunplugged/static/img/topics/kidbots-rocket-2.png", "new_path": "csunplugged/static/img/topics/kidbots-rocket-2.png", "diff": "Binary files a/csunplugged/static/img/topics/kidbots-rocket-2.png and /dev/null differ\n" }, { "change_type": "ADD", "old_path": "csunplugged/static/img/topics/kidbots-rocket-3.gif", "new_path": "csunplugged/static/img/topics/kidbots-rocket-3.gif", "diff": "Binary files /dev/null and b/csunplugged/static/img/topics/kidbots-rocket-3.gif differ\n" }, { "change_type": "DELETE", "old_path": "csunplugged/static/img/topics/kidbots-rocket-3.png", "new_path": "csunplugged/static/img/topics/kidbots-rocket-3.png", "diff": "Binary files a/csunplugged/static/img/topics/kidbots-rocket-3.png and /dev/null differ\n" }, { "change_type": "ADD", "old_path": "csunplugged/static/img/topics/kidbots-rocket-4.gif", "new_path": "csunplugged/static/img/topics/kidbots-rocket-4.gif", "diff": "Binary files /dev/null and b/csunplugged/static/img/topics/kidbots-rocket-4.gif differ\n" }, { "change_type": "DELETE", "old_path": "csunplugged/static/img/topics/kidbots-rocket-4.png", "new_path": "csunplugged/static/img/topics/kidbots-rocket-4.png", "diff": "Binary files a/csunplugged/static/img/topics/kidbots-rocket-4.png and /dev/null differ\n" } ]
Python
MIT License
uccser/cs-unplugged
Add animations for 'Sending rocket to Mars' (fixes #664)
701,855
06.11.2017 15:21:39
-46,800
e8ba0da699e0620d9853d20c1505c695a536d319
Modify extraction of SVG elements to be more tolerant to possible situations
[ { "change_type": "MODIFY", "old_path": "csunplugged/utils/TextBoxDrawer.py", "new_path": "csunplugged/utils/TextBoxDrawer.py", "diff": "@@ -83,7 +83,11 @@ class TextBoxDrawer(object):\n\"\"\"\ntext_layer = self.svg.find('{http://www.w3.org/2000/svg}g[@id=\"text\"]')\ntext_elem = text_layer.find('{{http://www.w3.org/2000/svg}}text[@id=\"{}\"]'.format(box_id))\n+ if text_elem:\nbox_elem = text_elem.getprevious()\n+ else:\n+ box_elem = text_layer.find('{{http://www.w3.org/2000/svg}}rect[@id=\"{}\"]'.format(box_id))\n+ text_elem = box_elem.getnext()\ntspan_element = text_elem.find('{http://www.w3.org/2000/svg}tspan')\nif tspan_element is not None:\n" } ]
Python
MIT License
uccser/cs-unplugged
Modify extraction of SVG elements to be more tolerant to possible situations
701,860
06.11.2017 17:46:23
-46,800
70ba6bd717658b9edd28dd2be7f6c0489343b5de
Add animations needed for 'The Great Treasure Hunt (Unsorted)' (fixes
[ { "change_type": "ADD", "old_path": "csunplugged/static/img/topics/linear_search.gif", "new_path": "csunplugged/static/img/topics/linear_search.gif", "diff": "Binary files /dev/null and b/csunplugged/static/img/topics/linear_search.gif differ\n" }, { "change_type": "ADD", "old_path": "csunplugged/static/img/topics/linear_search_chests.gif", "new_path": "csunplugged/static/img/topics/linear_search_chests.gif", "diff": "Binary files /dev/null and b/csunplugged/static/img/topics/linear_search_chests.gif differ\n" } ]
Python
MIT License
uccser/cs-unplugged
Add animations needed for 'The Great Treasure Hunt (Unsorted)' (fixes #665)
701,860
06.11.2017 18:30:56
-46,800
9955aaa9a9676e60f0666e997897f2c9f0fb86b5
Add image in The Great Treasure Hunt Unsorted lesson. (fixes
[ { "change_type": "ADD", "old_path": "csunplugged/static/img/topics/child_searches_book.png", "new_path": "csunplugged/static/img/topics/child_searches_book.png", "diff": "Binary files /dev/null and b/csunplugged/static/img/topics/child_searches_book.png differ\n" } ]
Python
MIT License
uccser/cs-unplugged
Add image in The Great Treasure Hunt Unsorted lesson. (fixes #665)
701,855
06.11.2017 19:16:06
-46,800
1f0b1137e208f95511a43a1defe5bf6a85868eb1
Add support for text box rotation in resource text overlay
[ { "change_type": "MODIFY", "old_path": "csunplugged/utils/TextBoxDrawer.py", "new_path": "csunplugged/utils/TextBoxDrawer.py", "diff": "\"\"\"Module for TextBoxDrawer class.\"\"\"\nfrom django.utils.translation import get_language, get_language_bidi\n-from PIL import ImageFont\n+from PIL import ImageFont, Image, ImageDraw\nfrom lxml import etree as ET\nimport tinycss\nimport os\nfrom bidi.algorithm import get_display\nfrom uniseg.linebreak import line_break_units\nimport arabic_reshaper\n+import math\nDEFAULT_FONT = \"static/fonts/NotoSans-Regular.ttf\"\nDEFAULT_FONT_OVERRIDES = {\n@@ -26,15 +27,26 @@ FONT_MAX_ORD = {\nclass TextBox(object):\n\"\"\"Class to store position/dimensions of a text box.\"\"\"\n- def __init__(self, x, y, width, height, color, font_path, font_size):\n- \"\"\"Initialise TextBox.\"\"\"\n- self.x = x\n- self.y = y\n+ def __init__(self, vertices, width, height, color, font_path, font_size, angle):\n+ \"\"\"Initialise TextBox.\n+\n+ Args:\n+ vertices: (list of 4 (x,y) tuples) vertex coords - in PNG coordinate\n+ space - ordered clockwise from top left\n+ width: (float) width of textbox in PNG space\n+ height: (float) height of textbox in PNG space\n+ color: (RGB 3-tuple or HEX string) text color, if given in SVG\n+ font_path: (str) path to font, if given in SVG\n+ font_size: (int) font size, if given in SVG\n+ angle: (float) rotation angle of textbox, anti-clockwise\n+ \"\"\"\n+ self.vertices = vertices\nself.width = width\nself.height = height\nself.color = color\nself.font_path = font_path\nself.font_size = font_size\n+ self.angle = angle # In radians\nclass TextBoxDrawer(object):\n@@ -81,7 +93,7 @@ class TextBoxDrawer(object):\nReturns:\nTextBox object\n\"\"\"\n- text_layer = self.svg.find('{http://www.w3.org/2000/svg}g[@id=\"text\"]')\n+ text_layer = self.svg.find('{http://www.w3.org/2000/svg}g[@id=\"TEXT\"]')\ntext_elem = text_layer.find('{{http://www.w3.org/2000/svg}}text[@id=\"{}\"]'.format(box_id))\nif text_elem:\nbox_elem = text_elem.getprevious()\n@@ -102,20 +114,46 @@ class TextBoxDrawer(object):\nstyle[rule.name] = rule.value[0].value\ncolor = style.get('fill')\nfont = style.get('font-family')\n- size = style.get('font-size')\n- if size:\n- font_size = int(size * self.height_ratio) # Convert font size into image coord space\n+ font_size = style.get('font-size')\n+\n+ x = float(box_elem.attrib.get('x', 0))\n+ y = float(box_elem.attrib.get('y', 0))\n+ width = float(box_elem.attrib['width'])\n+ height = float(box_elem.attrib['height'])\n+\n+ # SVG coord space\n+ vertices = [\n+ (x, y), (x + width, y), (x + width, y + height), (x, y + height)\n+ ]\n+\n+ rect_transform = box_elem.attrib.get('transform')\n+ if rect_transform and rect_transform.startswith(\"matrix\"):\n+ a, b, c, d, e, f = list(map(float, rect_transform[7:-1].split()))\n+ for i, (x, y) in enumerate(vertices):\n+ new_x = (a*x) + (c*y) + e\n+ new_y = (b*x) + (d*y) + f\n+ vertices[i] = (new_x, new_y)\n+ # x, y = new_x, new_y\n+ # Assume rotation without scaling\n+ angle = math.acos(a)\nelse:\n- font_size = None\n+ angle = 0\n+\n+ # Convert into PNG Coordinate Space\n+ vertices = [(x * self.width_ratio, y * self.height_ratio) for (x, y) in vertices]\n+ width *= self.width_ratio\n+ height *= self.height_ratio\n+ if font_size:\n+ font_size = int(font_size * self.height_ratio)\nreturn TextBox(\n- x=float(box_elem.attrib.get('x', 0)) * self.width_ratio,\n- y=float(box_elem.attrib.get('y', 0)) * self.height_ratio,\n- width=float(box_elem.attrib['width']) * self.width_ratio,\n- height=float(box_elem.attrib['height']) * self.height_ratio,\n+ vertices=vertices,\n+ width=width,\n+ height=height,\ncolor=color,\nfont_path=\"static/fonts/{}.ttf\".format(font),\n- font_size=font_size\n+ font_size=font_size,\n+ angle=angle,\n)\ndef write_text_box(self, box_id, string, **kwargs):\n@@ -238,22 +276,42 @@ class TextBoxDrawer(object):\nhoriz_just = \"right\"\nif vert_just == 'top':\n- y = text_box.y\n+ y = 0\nelif vert_just == 'center':\n- y = text_box.y + (text_box.height - text_height)/2\n+ y = (text_box.height - text_height)/2\nelif vert_just == 'bottom':\n- y = text_box.y + (text_box.height - text_height)\n+ y = (text_box.height - text_height)\nif horiz_just == 'left':\n- x = text_box.x\n+ x = 0\nelif horiz_just == 'center':\n- x = text_box.x + (text_box.width - text_width)/2\n+ x = (text_box.width - text_width)/2\nelif horiz_just == 'right':\n- x = text_box.x + (text_box.width - text_width)\n+ x = (text_box.width - text_width)\n# Remove offset from top line, to mimic AI textbox behavior\ny -= offset_y\n+ if text_box.angle != 0:\n+ text_img = Image.new(\"RGBA\", (int(text_box.width), int(text_box.height)))\n+ draw_text = ImageDraw.Draw(text_img)\n+ draw_text.multiline_text(\n+ (x, y),\n+ text,\n+ fill=color,\n+ font=font,\n+ align=horiz_just,\n+ spacing=line_spacing\n+ )\n+ text_img = text_img.rotate(math.degrees(text_box.angle), expand=1)\n+ vertices_xvals, vertices_yvals = zip(*text_box.vertices)\n+ px = int(min(vertices_xvals))\n+ py = int(min(vertices_yvals))\n+ self.image.paste(text_img, (px, py), text_img)\n+ else:\n+ topleft_x, topleft_y = text_box.vertices[0]\n+ x += topleft_x\n+ y += topleft_y\nself.draw.multiline_text(\n(x, y),\ntext,\n@@ -262,3 +320,9 @@ class TextBoxDrawer(object):\nalign=horiz_just,\nspacing=line_spacing\n)\n+\n+ def draw_crosshair(self, point):\n+ \"\"\"Draw a black crosshair at the specified point.\"\"\"\n+ x, y = point\n+ self.draw.line([(x - 30, y), (x + 30, y)], fill=(150, 150, 150), width=5)\n+ self.draw.line([(x, y - 30), (x, y + 30)], fill=(150, 150, 150), width=5)\n" } ]
Python
MIT License
uccser/cs-unplugged
Add support for text box rotation in resource text overlay
701,860
07.11.2017 11:39:20
-46,800
f1a82f8255ab9eda92a77443dddc1b8205937f00
Add documentation for media, especially animations.
[ { "change_type": "MODIFY", "old_path": "docs/source/developer/index.rst", "new_path": "docs/source/developer/index.rst", "diff": "@@ -12,6 +12,7 @@ The following pages are for those wanting to develop the CS Unplugged system.\nwebsite_design\ngeneral\ntopics\n+ media\nresources\ndev\ndeployment\n" }, { "change_type": "ADD", "old_path": null, "new_path": "docs/source/developer/media.rst", "diff": "+Media Application\n+##############################################################################\n+\n+.. warning::\n+\n+ The documentation for this page is still being written.\n+\n+ This page will cover:\n+\n+ - Animations\n+ - GIF conversion using the SWF > MP4 > GIF conversion pipeline\n+ - Images\n+ - Video\n+\n+Animations\n+==============================================================================\n+\n+Animations are located in either the ``general``, or ``topics``\n+directory at: ``csunplugged/static/img``.\n+\n+Animations are currently created by creating the elements using Adobe Illustrator and then animated on Adobe Animate.\n+The frame rate used is normally 30fps, but this does not need to be strictly followed.\n+The animations are then exported in a .gif format.\n+\n+The SWF > MP4 > GIF Pipeline\n+------------------------------------------------------------------------------\n+Sometimes, exporting as a .gif file will not work on Adobe Animate (exports with incorrect colours, or incomplete animations).\n+In this case, the animation must follow the rather convuluted SWF > MP4 > GIF pipeline.\n+\n+1. The animation is exported in a .swf format in Adobe Animate.\n+2. The animation is converted to a .mp4 file using a conversion tool, such as `Swivel <https://www.newgrounds.com/wiki/creator-resources/flash-resources/swivel>`_.\n+3. The animation is converted to a .gif file using a conversion tool, such as `ezgif <https://ezgif.com/video-to-gif>`\n+\n+Adding an animation to a lesson/unit plan\n+------------------------------------------------------------------------------\n+The animation can then be added to the correct placement in a lesson/unit plan by following this example:\n+\n+.. code-block:: markdown\n+\n+ image file-path=\"img/topics/filename.gif\" alt=\"Description of animation.\"}\n" } ]
Python
MIT License
uccser/cs-unplugged
Add documentation for media, especially animations.
701,860
07.11.2017 11:42:18
-46,800
d2e6891d91565be43d215a2f723219371a0b7202
Fix link for ezgif
[ { "change_type": "MODIFY", "old_path": "docs/source/developer/media.rst", "new_path": "docs/source/developer/media.rst", "diff": "@@ -29,7 +29,7 @@ In this case, the animation must follow the rather convuluted SWF > MP4 > GIF pi\n1. The animation is exported in a .swf format in Adobe Animate.\n2. The animation is converted to a .mp4 file using a conversion tool, such as `Swivel <https://www.newgrounds.com/wiki/creator-resources/flash-resources/swivel>`_.\n-3. The animation is converted to a .gif file using a conversion tool, such as `ezgif <https://ezgif.com/video-to-gif>`\n+3. The animation is converted to a .gif file using a conversion tool, such as `ezgif <https://ezgif.com/video-to-gif>`_.\nAdding an animation to a lesson/unit plan\n------------------------------------------------------------------------------\n" } ]
Python
MIT License
uccser/cs-unplugged
Fix link for ezgif
701,860
07.11.2017 12:02:31
-46,800
578ce2460a537775127af7ac025d1db37ef1cc8e
fix documentation based on requested changes
[ { "change_type": "MODIFY", "old_path": "docs/source/developer/media.rst", "new_path": "docs/source/developer/media.rst", "diff": "-Media Application\n+Media\n##############################################################################\n.. warning::\n@@ -15,8 +15,7 @@ Media Application\nAnimations\n==============================================================================\n-Animations are located in either the ``general``, or ``topics``\n-directory at: ``csunplugged/static/img``.\n+Animations are located in the ``csunplugged/static/img`` directory.\nAnimations are currently created by creating the elements using Adobe Illustrator and then animated on Adobe Animate.\nThe frame rate used is normally 30fps, but this does not need to be strictly followed.\n" } ]
Python
MIT License
uccser/cs-unplugged
fix documentation based on requested changes
701,860
07.11.2017 12:45:17
-46,800
d8cd20da3a21eae3deb5cdb1e5ff75b6191a1695
add documentation fixes based on requested changes again
[ { "change_type": "MODIFY", "old_path": "docs/source/developer/media.rst", "new_path": "docs/source/developer/media.rst", "diff": "@@ -29,11 +29,3 @@ In this case, the animation must follow the rather convuluted SWF > MP4 > GIF pi\n1. The animation is exported in a .swf format in Adobe Animate.\n2. The animation is converted to a .mp4 file using a conversion tool, such as `Swivel <https://www.newgrounds.com/wiki/creator-resources/flash-resources/swivel>`_.\n3. The animation is converted to a .gif file using a conversion tool, such as `ezgif <https://ezgif.com/video-to-gif>`_.\n-\n-Adding an animation to a lesson/unit plan\n-------------------------------------------------------------------------------\n-The animation can then be added to the correct placement in a lesson/unit plan by following this example:\n-\n-.. code-block:: markdown\n-\n- image file-path=\"img/topics/filename.gif\" alt=\"Description of animation.\"}\n" } ]
Python
MIT License
uccser/cs-unplugged
add documentation fixes based on requested changes again