rapid-router 5.4.1__py2.py3-none-any.whl → 7.6.8__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- example_project/rapid_router_test_settings.py +164 -0
- example_project/settings.py +152 -0
- example_project/urls.py +15 -0
- example_project/{example_project/wsgi.py → wsgi.py} +2 -1
- game/__init__.py +1 -1
- game/admin.py +43 -4
- game/app_settings.py +3 -7
- game/character.py +26 -18
- game/decor.py +172 -97
- game/end_to_end_tests/base_game_test.py +44 -33
- game/end_to_end_tests/editor_page.py +17 -2
- game/end_to_end_tests/game_page.py +127 -45
- game/end_to_end_tests/selenium_test_case.py +1 -20
- game/end_to_end_tests/test_cow_crashes.py +3 -5
- game/end_to_end_tests/test_language_dropdown.py +14 -0
- game/end_to_end_tests/test_level_editor.py +290 -0
- game/end_to_end_tests/test_level_failures.py +1 -1
- game/end_to_end_tests/test_level_selection.py +79 -0
- game/end_to_end_tests/test_play_through.py +240 -102
- game/end_to_end_tests/test_python_levels.py +44 -13
- game/end_to_end_tests/test_saving_workspace.py +22 -0
- game/forms.py +9 -2
- game/level_management.py +38 -29
- game/messages.py +1218 -203
- game/migrations/0001_squashed_0025_levels_ordering_pt1.py +19 -1
- game/migrations/0026_levels_pt2.py +13 -2
- game/migrations/0032_cannot_turn_left_level.py +13 -2
- game/migrations/0033_recursion_level.py +13 -2
- game/migrations/0034_joes_level.py +13 -2
- game/migrations/0035_disable_route_score_level_70.py +0 -2
- game/migrations/0036_level_score_73.py +0 -2
- game/migrations/0037_level_score_79.py +0 -2
- game/migrations/0038_level_score_40.py +0 -1
- game/migrations/0042_level_score_73.py +0 -2
- game/migrations/0048_add_cow_field_and_blocks.py +0 -2
- game/migrations/0049_level_score_34.py +0 -2
- game/migrations/0050_level_score_40.py +0 -2
- game/migrations/0051_level_score_49.py +0 -1
- game/migrations/0076_level_locked_for_class.py +19 -0
- game/migrations/0077_alter_level_next_level.py +52 -0
- game/migrations/0078_add_block_types.py +23 -0
- game/migrations/0079_populate_block_type_add_cow_blocks.py +60 -0
- game/migrations/0080_level_disable_algorithm_score.py +18 -0
- game/migrations/0081_first_12_levels_no_algo_score.py +29 -0
- game/migrations/0082_level_43_solution.py +16 -0
- game/migrations/0083_add_cows_to_existing_levels.py +195 -0
- game/migrations/0084_alter_block_block_type.py +18 -0
- game/migrations/0085_add_new_blocks.py +53 -0
- game/migrations/0086_loop_levels.py +482 -0
- game/migrations/0087_workspace_python_view_enabled.py +18 -0
- game/migrations/0088_rename_episodes.py +35 -0
- game/migrations/0089_episodes_in_development.py +30 -0
- game/migrations/0090_add_missing_model_solutions.py +144 -0
- game/migrations/0091_disable_algo_score_if_no_model_solution.py +46 -0
- game/migrations/0092_disable_algo_score_in_custom_levels.py +28 -0
- game/migrations/0093_alter_level_character_name.py +18 -0
- game/migrations/0094_add_hint_lesson_subtitle_to_levels.py +28 -0
- game/migrations/0095_level_commands.py +18 -0
- game/migrations/0096_alter_level_commands.py +18 -0
- game/migrations/0097_add_python_den_levels.py +1515 -0
- game/migrations/0098_add_episode_link_fields.py +44 -0
- game/migrations/0099_python_episodes_links.py +103 -0
- game/migrations/0100_reorder_python_levels.py +179 -0
- game/migrations/0101_rename_episodes.py +45 -0
- game/migrations/0102_reoder_episodes_13_14.py +136 -0
- game/migrations/0103_level_1015_solution.py +26 -0
- game/migrations/0104_remove_level_direct_drive.py +17 -0
- game/migrations/0105_delete_invalid_attempts.py +18 -0
- game/migrations/0106_fields_to_snake_case.py +48 -0
- game/migrations/0107_rename_worksheet_link_episode_student_worksheet_link.py +18 -0
- game/migrations/0108_episode_indy_worksheet_link.py +18 -0
- game/migrations/0109_create_episodes_23_and_24.py +99 -0
- game/migrations/0110_remove_episode_indy_worksheet_link_and_more.py +100 -0
- game/migrations/0111_create_worksheets.py +149 -0
- game/migrations/0112_worksheet_locked_classes.py +21 -0
- game/migrations/0113_level_needs_approval.py +18 -0
- game/migrations/0114_default_and_non_student_levels_no_approval.py +31 -0
- game/migrations/0115_level_level__default_does_not_need_approval.py +22 -0
- game/migrations/0116_update_worksheet_video_links.py +68 -0
- game/migrations/0117_update_solutions_to_if_else.py +61 -0
- game/models.py +157 -16
- game/permissions.py +34 -19
- game/python_den_urls.py +26 -0
- game/random_road.py +43 -127
- game/serializers.py +12 -17
- game/static/django_reverse_js/js/reverse.js +171 -0
- game/static/game/css/LilitaOne-Regular.ttf +0 -0
- game/static/game/css/backgrounds.css +14 -10
- game/static/game/css/dataTables.custom.css +4 -2
- game/static/game/css/dataTables.jqueryui.css +561 -320
- game/static/game/css/editor.css +47 -0
- game/static/game/css/game.css +43 -49
- game/static/game/css/game_screen.css +116 -53
- game/static/game/css/jquery.dataTables.css +455 -251
- game/static/game/css/level_editor.css +10 -1
- game/static/game/css/level_selection.css +32 -3
- game/static/game/css/level_share.css +6 -5
- game/static/game/css/skulpt/codemirror.css +1 -0
- game/static/game/image/Python_Den_hero_student.png +0 -0
- game/static/game/image/Python_levels_page.svg +1954 -0
- game/static/game/image/characters/front_view/Electric_van.svg +448 -0
- game/static/game/image/characters/top_view/Electric_van.svg +448 -0
- game/static/game/image/characters/top_view/Sleigh.svg +436 -0
- game/static/game/image/decor/city/solar_panel.svg +1200 -0
- game/static/game/image/decor/farm/solar_panel.svg +86 -0
- game/static/game/image/decor/grass/solar_panel.svg +86 -0
- game/static/game/image/decor/snow/barn.svg +1788 -0
- game/static/game/image/decor/snow/cfc.svg +1050 -147
- game/static/game/image/decor/snow/crops.svg +7370 -0
- game/static/game/image/decor/snow/hospital.svg +1220 -0
- game/static/game/image/decor/snow/house1.svg +971 -0
- game/static/game/image/decor/snow/house2.svg +1574 -0
- game/static/game/image/decor/snow/school.svg +1071 -0
- game/static/game/image/decor/snow/shop.svg +3211 -0
- game/static/game/image/decor/snow/solar_panel.svg +173 -0
- game/static/game/image/electric_van.svg +448 -0
- game/static/game/image/icons/add_house.svg +26 -0
- game/static/game/image/icons/delete_house.svg +26 -0
- game/static/game/image/icons/description.svg +1 -0
- game/static/game/image/icons/hint.svg +1 -0
- game/static/game/image/icons/if_else.svg +3 -0
- game/static/game/image/icons/python.svg +1 -1
- game/static/game/image/if_else_example.png +0 -0
- game/static/game/image/pigeon.svg +684 -0
- game/static/game/image/python_den_header.svg +19 -0
- game/static/game/js/animation.js +84 -28
- game/static/game/js/blockly/msg/js/bg.js +52 -1
- game/static/game/js/blockly/msg/js/ca.js +52 -1
- game/static/game/js/blockly/msg/js/en-gb.js +52 -1
- game/static/game/js/blockly/msg/js/en.js +52 -1
- game/static/game/js/blockly/msg/js/es.js +52 -1
- game/static/game/js/blockly/msg/js/fr.js +52 -1
- game/static/game/js/blockly/msg/js/hi.js +52 -1
- game/static/game/js/blockly/msg/js/it.js +52 -1
- game/static/game/js/blockly/msg/js/pl.js +52 -1
- game/static/game/js/blockly/msg/js/pt-br.js +52 -1
- game/static/game/js/blockly/msg/js/ru.js +52 -1
- game/static/game/js/blockly/msg/js/ur.js +52 -1
- game/static/game/js/blocklyCompiler.js +550 -392
- game/static/game/js/blocklyControl.js +335 -302
- game/static/game/js/blocklyCustomBlocks.js +691 -458
- game/static/game/js/blocklyCustomisations.js +3 -1
- game/static/game/js/button.js +12 -0
- game/static/game/js/cow.js +15 -130
- game/static/game/js/drawing.js +313 -201
- game/static/game/js/editor.js +23 -0
- game/static/game/js/game.js +148 -139
- game/static/game/js/jquery.dataTables.min.js +3 -159
- game/static/game/js/level_editor.js +823 -448
- game/static/game/js/level_moderation.js +33 -2
- game/static/game/js/level_selection.js +62 -25
- game/static/game/js/loadLanguages.js +21 -0
- game/static/game/js/map.js +106 -36
- game/static/game/js/model.js +55 -107
- game/static/game/js/pathFinder.js +73 -72
- game/static/game/js/program.js +184 -193
- game/static/game/js/pythonControl.js +14 -1
- game/static/game/js/scoreboard.js +0 -37
- game/static/game/js/scoreboardSharedLevels.js +48 -0
- game/static/game/js/sharing.js +22 -10
- game/static/game/js/skulpt/codemirror.js +5 -4
- game/static/game/js/skulpt/skulpt-stdlib.js +1 -1
- game/static/game/js/sound.js +52 -5
- game/static/game/js/van.js +0 -7
- game/static/game/raphael_image/characters/top_view/Electric_van.svg +448 -0
- game/static/game/raphael_image/characters/top_view/Sleigh.svg +436 -0
- game/static/game/raphael_image/decor/city/solar_panel.svg +1200 -0
- game/static/game/raphael_image/decor/farm/solar_panel.svg +86 -0
- game/static/game/raphael_image/decor/grass/solar_panel.svg +86 -0
- game/static/game/raphael_image/decor/snow/barn.svg +1788 -0
- game/static/game/raphael_image/decor/snow/cfc.svg +1050 -147
- game/static/game/raphael_image/decor/snow/crops.svg +7370 -0
- game/static/game/raphael_image/decor/snow/hospital.svg +1220 -0
- game/static/game/raphael_image/decor/snow/house1.svg +971 -0
- game/static/game/raphael_image/decor/snow/house2.svg +1574 -0
- game/static/game/raphael_image/decor/snow/school.svg +1071 -0
- game/static/game/raphael_image/decor/snow/shop.svg +3211 -0
- game/static/game/raphael_image/decor/snow/solar_panel.svg +173 -0
- game/static/game/raphael_image/pigeon.svg +685 -0
- game/static/game/raphael_image/sleigh_wreckage.svg +430 -0
- game/static/game/sass/game.scss +22 -6
- game/static/game/sound/clown_horn.mp3 +0 -0
- game/static/game/sound/clown_horn.ogg +0 -0
- game/static/game/sound/electric_van_starting.mp3 +0 -0
- game/static/game/sound/electric_van_starting.ogg +0 -0
- game/static/game/sound/pigeon.mp3 +0 -0
- game/static/game/sound/pigeon.ogg +0 -0
- game/static/game/sound/sleigh_bells.mp3 +0 -0
- game/static/game/sound/sleigh_bells.ogg +0 -0
- game/static/game/sound/sleigh_crash.mp3 +0 -0
- game/static/game/sound/sleigh_crash.ogg +0 -0
- game/templates/game/base.html +35 -15
- game/templates/game/basenonav.html +23 -17
- game/templates/game/game.html +236 -111
- game/templates/game/level_editor.html +353 -275
- game/templates/game/level_moderation.html +19 -6
- game/templates/game/level_selection.html +75 -62
- game/templates/game/python_den_level_selection.html +291 -0
- game/templates/game/python_den_worksheet.html +101 -0
- game/templates/game/scoreboard.html +88 -65
- game/tests/test_level_editor.py +210 -35
- game/tests/test_level_moderation.py +6 -20
- game/tests/test_level_selection.py +332 -11
- game/tests/test_python_den_worksheet.py +85 -0
- game/tests/test_scoreboard.py +258 -66
- game/tests/utils/level.py +43 -3
- game/tests/utils/teacher.py +2 -2
- game/theme.py +21 -21
- game/urls.py +125 -78
- game/views/language_code_conversions.py +90 -0
- game/views/level.py +201 -63
- game/views/level_editor.py +109 -48
- game/views/level_moderation.py +29 -6
- game/views/level_selection.py +179 -56
- game/views/level_solutions.py +600 -106
- game/views/scoreboard.py +181 -66
- game/views/worksheet.py +25 -0
- rapid_router-7.6.8.dist-info/METADATA +174 -0
- {rapid_router-5.4.1.dist-info → rapid_router-7.6.8.dist-info}/RECORD +222 -242
- {rapid_router-5.4.1.dist-info → rapid_router-7.6.8.dist-info}/WHEEL +1 -1
- rapid_router-7.6.8.dist-info/licenses/LICENSE.md +3 -0
- example_project/example_project/__init__.py +0 -1
- example_project/example_project/settings.py +0 -54
- example_project/example_project/urls.py +0 -16
- example_project/manage.py +0 -10
- game/autoconfig.py +0 -59
- game/csp_config.py +0 -23
- game/locale/ar_SA/LC_MESSAGES/django.mo +0 -0
- game/locale/ar_SA/LC_MESSAGES/django.po +0 -405
- game/locale/ar_SA/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/ar_SA/LC_MESSAGES/djangojs.po +0 -743
- game/locale/bg_BG/LC_MESSAGES/django.mo +0 -0
- game/locale/bg_BG/LC_MESSAGES/django.po +0 -405
- game/locale/bg_BG/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/bg_BG/LC_MESSAGES/djangojs.po +0 -739
- game/locale/ca_ES/LC_MESSAGES/django.mo +0 -0
- game/locale/ca_ES/LC_MESSAGES/django.po +0 -405
- game/locale/ca_ES/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/ca_ES/LC_MESSAGES/djangojs.po +0 -740
- game/locale/cs_CZ/LC_MESSAGES/django.mo +0 -0
- game/locale/cs_CZ/LC_MESSAGES/django.po +0 -405
- game/locale/cs_CZ/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/cs_CZ/LC_MESSAGES/djangojs.po +0 -741
- game/locale/cy_GB/LC_MESSAGES/django.mo +0 -0
- game/locale/cy_GB/LC_MESSAGES/django.po +0 -405
- game/locale/cy_GB/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/cy_GB/LC_MESSAGES/djangojs.po +0 -743
- game/locale/de_DE/LC_MESSAGES/django.mo +0 -0
- game/locale/de_DE/LC_MESSAGES/django.po +0 -405
- game/locale/de_DE/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/de_DE/LC_MESSAGES/djangojs.po +0 -739
- game/locale/el_GR/LC_MESSAGES/django.mo +0 -0
- game/locale/el_GR/LC_MESSAGES/django.po +0 -405
- game/locale/el_GR/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/el_GR/LC_MESSAGES/djangojs.po +0 -739
- game/locale/en_GB/LC_MESSAGES/django.mo +0 -0
- game/locale/en_GB/LC_MESSAGES/django.po +0 -405
- game/locale/en_GB/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/en_GB/LC_MESSAGES/djangojs.po +0 -739
- game/locale/es_ES/LC_MESSAGES/django.mo +0 -0
- game/locale/es_ES/LC_MESSAGES/django.po +0 -405
- game/locale/es_ES/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/es_ES/LC_MESSAGES/djangojs.po +0 -739
- game/locale/fi_FI/LC_MESSAGES/django.mo +0 -0
- game/locale/fi_FI/LC_MESSAGES/django.po +0 -405
- game/locale/fi_FI/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/fi_FI/LC_MESSAGES/djangojs.po +0 -739
- game/locale/fr_FR/LC_MESSAGES/django.mo +0 -0
- game/locale/fr_FR/LC_MESSAGES/django.po +0 -405
- game/locale/fr_FR/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/fr_FR/LC_MESSAGES/djangojs.po +0 -739
- game/locale/gu_IN/LC_MESSAGES/django.mo +0 -0
- game/locale/gu_IN/LC_MESSAGES/django.po +0 -405
- game/locale/gu_IN/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/gu_IN/LC_MESSAGES/djangojs.po +0 -739
- game/locale/hi_IN/LC_MESSAGES/django.mo +0 -0
- game/locale/hi_IN/LC_MESSAGES/django.po +0 -405
- game/locale/hi_IN/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/hi_IN/LC_MESSAGES/djangojs.po +0 -739
- game/locale/id_ID/LC_MESSAGES/django.mo +0 -0
- game/locale/id_ID/LC_MESSAGES/django.po +0 -405
- game/locale/id_ID/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/id_ID/LC_MESSAGES/djangojs.po +0 -738
- game/locale/it_IT/LC_MESSAGES/django.mo +0 -0
- game/locale/it_IT/LC_MESSAGES/django.po +0 -405
- game/locale/it_IT/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/it_IT/LC_MESSAGES/djangojs.po +0 -739
- game/locale/ja_JP/LC_MESSAGES/django.mo +0 -0
- game/locale/ja_JP/LC_MESSAGES/django.po +0 -405
- game/locale/ja_JP/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/ja_JP/LC_MESSAGES/djangojs.po +0 -738
- game/locale/lol_US/LC_MESSAGES/django.mo +0 -0
- game/locale/lol_US/LC_MESSAGES/django.po +0 -405
- game/locale/lol_US/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/lol_US/LC_MESSAGES/djangojs.po +0 -739
- game/locale/nb_NO/LC_MESSAGES/django.mo +0 -0
- game/locale/nb_NO/LC_MESSAGES/django.po +0 -405
- game/locale/nb_NO/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/nb_NO/LC_MESSAGES/djangojs.po +0 -739
- game/locale/nl_NL/LC_MESSAGES/django.mo +0 -0
- game/locale/nl_NL/LC_MESSAGES/django.po +0 -405
- game/locale/nl_NL/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/nl_NL/LC_MESSAGES/djangojs.po +0 -739
- game/locale/pl_PL/LC_MESSAGES/django.mo +0 -0
- game/locale/pl_PL/LC_MESSAGES/django.po +0 -405
- game/locale/pl_PL/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/pl_PL/LC_MESSAGES/djangojs.po +0 -741
- game/locale/pt_BR/LC_MESSAGES/django.mo +0 -0
- game/locale/pt_BR/LC_MESSAGES/django.po +0 -405
- game/locale/pt_BR/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/pt_BR/LC_MESSAGES/djangojs.po +0 -739
- game/locale/pt_PT/LC_MESSAGES/django.mo +0 -0
- game/locale/pt_PT/LC_MESSAGES/django.po +0 -405
- game/locale/pt_PT/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/pt_PT/LC_MESSAGES/djangojs.po +0 -739
- game/locale/ro_RO/LC_MESSAGES/django.mo +0 -0
- game/locale/ro_RO/LC_MESSAGES/django.po +0 -405
- game/locale/ro_RO/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/ro_RO/LC_MESSAGES/djangojs.po +0 -740
- game/locale/ru_RU/LC_MESSAGES/django.mo +0 -0
- game/locale/ru_RU/LC_MESSAGES/django.po +0 -405
- game/locale/ru_RU/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/ru_RU/LC_MESSAGES/djangojs.po +0 -741
- game/locale/sv_SE/LC_MESSAGES/django.mo +0 -0
- game/locale/sv_SE/LC_MESSAGES/django.po +0 -405
- game/locale/sv_SE/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/sv_SE/LC_MESSAGES/djangojs.po +0 -739
- game/locale/tl_PH/LC_MESSAGES/django.mo +0 -0
- game/locale/tl_PH/LC_MESSAGES/django.po +0 -405
- game/locale/tl_PH/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/tl_PH/LC_MESSAGES/djangojs.po +0 -739
- game/locale/tlh_AA/LC_MESSAGES/django.mo +0 -0
- game/locale/tlh_AA/LC_MESSAGES/django.po +0 -405
- game/locale/tlh_AA/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/tlh_AA/LC_MESSAGES/djangojs.po +0 -739
- game/locale/tr_TR/LC_MESSAGES/django.mo +0 -0
- game/locale/tr_TR/LC_MESSAGES/django.po +0 -405
- game/locale/tr_TR/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/tr_TR/LC_MESSAGES/djangojs.po +0 -740
- game/locale/ur_IN/LC_MESSAGES/django.mo +0 -0
- game/locale/ur_IN/LC_MESSAGES/django.po +0 -405
- game/locale/ur_IN/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/ur_IN/LC_MESSAGES/djangojs.po +0 -739
- game/locale/ur_PK/LC_MESSAGES/django.mo +0 -0
- game/locale/ur_PK/LC_MESSAGES/django.po +0 -405
- game/locale/ur_PK/LC_MESSAGES/djangojs.mo +0 -0
- game/locale/ur_PK/LC_MESSAGES/djangojs.po +0 -739
- game/static/game/image/actions/go.svg +0 -18
- game/static/game/image/icons/destination.svg +0 -9
- game/static/game/js/pqselect.min.js +0 -9
- game/static/game/js/widget-scroller.js +0 -906
- rapid_router-5.4.1.dist-info/LICENSE.md +0 -577
- rapid_router-5.4.1.dist-info/METADATA +0 -24
- {rapid_router-5.4.1.dist-info → rapid_router-7.6.8.dist-info}/top_level.txt +0 -0
game/static/game/js/program.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
var ocargo = ocargo || {};
|
|
4
4
|
|
|
@@ -6,298 +6,289 @@ var MAX_EXECUTION_STEPS = 10000;
|
|
|
6
6
|
|
|
7
7
|
/* Program */
|
|
8
8
|
|
|
9
|
-
ocargo.Program = function(events) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
ocargo.Program = function (events) {
|
|
10
|
+
this.thread = null;
|
|
11
|
+
this.procedures = {};
|
|
12
|
+
this.events = events;
|
|
13
|
+
this.variables = {};
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
ocargo.Program.prototype.run = function() {
|
|
16
|
-
ocargo.model.chooseNewCowPositions();
|
|
17
17
|
ocargo.model.reset();
|
|
18
18
|
this.thread.run(ocargo.model);
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
/* Thread */
|
|
22
22
|
|
|
23
|
-
ocargo.Thread = function(program) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
ocargo.Thread = function (program) {
|
|
24
|
+
this.stack = []; //each element is an array of commands attached to each start block (currently we only have one start block)
|
|
25
|
+
this.noExecutionSteps = 0;
|
|
26
|
+
this.program = program;
|
|
27
|
+
this.eventLevel = Event.MAX_LEVEL; // no event active
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
ocargo.Thread.prototype.run = function(model) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
ocargo.Thread.prototype.run = function (model) {
|
|
31
|
+
let failed = false;
|
|
32
|
+
while (!failed && this.canStep()) {
|
|
33
|
+
failed = !this.step(model);
|
|
34
|
+
}
|
|
35
|
+
if (!failed) {
|
|
36
|
+
model.programExecutionEnded();
|
|
37
|
+
}
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
ocargo.Thread.prototype.step = function(model) {
|
|
41
|
-
// check if any event condition is true
|
|
42
|
-
for (let i = 0; i < this.program.events.length; i++) {
|
|
43
|
-
let event = this.program.events[i];
|
|
44
|
-
model.shouldObserve = false;
|
|
45
|
-
if (event.condition(model)) {
|
|
46
|
-
event.execute(this, model);
|
|
47
|
-
}
|
|
48
|
-
model.shouldObserve = true;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
let commandToProcess = this.stack.shift();
|
|
52
|
-
this.noExecutionSteps ++;
|
|
53
|
-
|
|
54
|
-
if (this.noExecutionSteps > MAX_EXECUTION_STEPS) {
|
|
55
|
-
ocargo.game.sendAttempt(0);
|
|
56
|
-
// alert user to likely infinite loop
|
|
57
|
-
ocargo.animation.appendAnimation({
|
|
58
|
-
type: 'popup',
|
|
59
|
-
popupType: 'FAIL',
|
|
60
|
-
failSubtype: 'QUERY_INFINITE_LOOP',
|
|
61
|
-
popupMessage: gettext('It looks as though your program\'s been running a while. Check your repeat loops are okay.'),
|
|
62
|
-
popupHint: ocargo.game.registerFailure(),
|
|
63
|
-
description: 'failure popup'
|
|
64
|
-
});
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
let successful = true;
|
|
69
|
-
if (commandToProcess) {
|
|
70
|
-
successful = commandToProcess.execute(this, model);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (!successful) {
|
|
74
|
-
// Program crashed, queue a block highlight event
|
|
75
|
-
let block = commandToProcess.block;
|
|
76
|
-
queueHighlightIncorrect(model, block);
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return true;
|
|
81
|
-
};
|
|
82
41
|
|
|
83
|
-
|
|
84
|
-
|
|
42
|
+
let commandToProcess = this.stack.shift();
|
|
43
|
+
this.noExecutionSteps++;
|
|
44
|
+
|
|
45
|
+
if (this.noExecutionSteps > MAX_EXECUTION_STEPS) {
|
|
46
|
+
ocargo.game.sendAttempt(0);
|
|
47
|
+
// alert user to likely infinite loop
|
|
48
|
+
ocargo.animation.appendAnimation({
|
|
49
|
+
type: "popup",
|
|
50
|
+
popupType: "FAIL",
|
|
51
|
+
failSubtype: "QUERY_INFINITE_LOOP",
|
|
52
|
+
popupMessage: gettext(
|
|
53
|
+
"It looks as though your program's been running a while. Check your repeat loops are okay."
|
|
54
|
+
),
|
|
55
|
+
popupHint: ocargo.game.registerFailure(),
|
|
56
|
+
description: "failure popup",
|
|
57
|
+
});
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
let successful = true;
|
|
62
|
+
if (commandToProcess) {
|
|
63
|
+
successful = commandToProcess.execute(this, model);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!successful) {
|
|
67
|
+
// Program crashed, queue a block highlight event
|
|
68
|
+
let block = commandToProcess.block;
|
|
69
|
+
queueHighlightIncorrect(model, block);
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return true;
|
|
85
74
|
};
|
|
86
75
|
|
|
87
|
-
ocargo.Thread.prototype.
|
|
88
|
-
|
|
76
|
+
ocargo.Thread.prototype.canStep = function () {
|
|
77
|
+
return this.stack.length !== 0;
|
|
89
78
|
};
|
|
90
79
|
|
|
80
|
+
ocargo.Thread.prototype.pushToStack = function (commands) {
|
|
81
|
+
this.stack.unshift.apply(this.stack, commands);
|
|
82
|
+
};
|
|
91
83
|
|
|
92
84
|
/* Simplified blocks containing only id, type
|
|
93
85
|
* all methods after comile() uses simplified blocks */
|
|
94
86
|
function Block(id, type) {
|
|
95
|
-
|
|
96
|
-
|
|
87
|
+
this.id = id;
|
|
88
|
+
this.type = type;
|
|
97
89
|
}
|
|
98
90
|
|
|
99
91
|
/* Instructions */
|
|
100
92
|
|
|
101
93
|
function TurnLeftCommand(block) {
|
|
102
|
-
|
|
94
|
+
this.block = block;
|
|
103
95
|
}
|
|
104
96
|
|
|
105
|
-
TurnLeftCommand.prototype.execute = function(thread, model) {
|
|
106
|
-
|
|
107
|
-
|
|
97
|
+
TurnLeftCommand.prototype.execute = function (thread, model) {
|
|
98
|
+
queueHighlight(model, this.block);
|
|
99
|
+
return model.turnLeft();
|
|
108
100
|
};
|
|
109
101
|
|
|
110
|
-
|
|
111
|
-
|
|
112
102
|
function TurnRightCommand(block) {
|
|
113
|
-
|
|
103
|
+
this.block = block;
|
|
114
104
|
}
|
|
115
105
|
|
|
116
|
-
TurnRightCommand.prototype.execute = function(thread, model) {
|
|
117
|
-
|
|
118
|
-
|
|
106
|
+
TurnRightCommand.prototype.execute = function (thread, model) {
|
|
107
|
+
queueHighlight(model, this.block);
|
|
108
|
+
return model.turnRight();
|
|
119
109
|
};
|
|
120
110
|
|
|
121
|
-
|
|
122
|
-
|
|
123
111
|
function ForwardCommand(block) {
|
|
124
|
-
|
|
112
|
+
this.block = block;
|
|
125
113
|
}
|
|
126
114
|
|
|
127
|
-
ForwardCommand.prototype.execute = function(thread, model) {
|
|
128
|
-
|
|
129
|
-
|
|
115
|
+
ForwardCommand.prototype.execute = function (thread, model) {
|
|
116
|
+
queueHighlight(model, this.block);
|
|
117
|
+
return model.moveForwards();
|
|
130
118
|
};
|
|
131
119
|
|
|
132
|
-
|
|
133
|
-
|
|
134
120
|
function TurnAroundCommand(block) {
|
|
135
|
-
|
|
121
|
+
this.block = block;
|
|
136
122
|
}
|
|
137
123
|
|
|
138
|
-
TurnAroundCommand.prototype.execute = function(thread, model) {
|
|
139
|
-
|
|
140
|
-
|
|
124
|
+
TurnAroundCommand.prototype.execute = function (thread, model) {
|
|
125
|
+
queueHighlight(model, this.block);
|
|
126
|
+
return model.turnAround();
|
|
141
127
|
};
|
|
142
128
|
|
|
143
|
-
|
|
144
|
-
|
|
145
129
|
function WaitCommand(block) {
|
|
146
|
-
|
|
130
|
+
this.block = block;
|
|
147
131
|
}
|
|
148
132
|
|
|
149
|
-
WaitCommand.prototype.execute = function(thread, model) {
|
|
150
|
-
|
|
151
|
-
|
|
133
|
+
WaitCommand.prototype.execute = function (thread, model) {
|
|
134
|
+
queueHighlight(model, this.block);
|
|
135
|
+
return model.wait();
|
|
152
136
|
};
|
|
153
137
|
|
|
154
|
-
|
|
155
|
-
|
|
156
138
|
function DeliverCommand(block) {
|
|
157
|
-
|
|
139
|
+
this.block = block;
|
|
158
140
|
}
|
|
159
141
|
|
|
160
|
-
DeliverCommand.prototype.execute = function(thread, model) {
|
|
161
|
-
|
|
162
|
-
|
|
142
|
+
DeliverCommand.prototype.execute = function (thread, model) {
|
|
143
|
+
queueHighlight(model, this.block);
|
|
144
|
+
return model.deliver();
|
|
163
145
|
};
|
|
164
146
|
|
|
165
|
-
function SoundHornCommand(block){
|
|
166
|
-
|
|
147
|
+
function SoundHornCommand(block) {
|
|
148
|
+
this.block = block;
|
|
167
149
|
}
|
|
168
150
|
|
|
169
|
-
SoundHornCommand.prototype.execute = function(thread, model){
|
|
170
|
-
|
|
171
|
-
|
|
151
|
+
SoundHornCommand.prototype.execute = function (thread, model) {
|
|
152
|
+
queueHighlight(model, this.block, true);
|
|
153
|
+
return model.sound_horn();
|
|
172
154
|
};
|
|
173
155
|
|
|
174
|
-
function
|
|
175
|
-
|
|
156
|
+
function SetVariableCommand(block, name, valueFunction) {
|
|
157
|
+
this.block = block;
|
|
158
|
+
this.name = name;
|
|
159
|
+
this.valueFunction = valueFunction;
|
|
176
160
|
}
|
|
177
161
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
162
|
+
SetVariableCommand.prototype.execute = function (thread, model) {
|
|
163
|
+
queueHighlight(model, this.block);
|
|
164
|
+
thread.program.variables[this.name] = this.valueFunction();
|
|
165
|
+
return model.wait(); // TODO - need to change this if we don't want it to use fuel
|
|
181
166
|
};
|
|
182
167
|
|
|
183
|
-
function
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
168
|
+
function IncrementVariableCommand(block, name, incrValue) {
|
|
169
|
+
this.block = block;
|
|
170
|
+
this.name = name;
|
|
171
|
+
this.incrValue = incrValue;
|
|
187
172
|
}
|
|
188
173
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
thread.pushToStack(this.conditionalCommandSets[i].commands.slice());
|
|
194
|
-
return true;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
i++;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if(this.elseBody) {
|
|
201
|
-
thread.pushToStack(this.elseBody.slice());
|
|
202
|
-
}
|
|
203
|
-
return true;
|
|
174
|
+
IncrementVariableCommand.prototype.execute = function (thread, model) {
|
|
175
|
+
queueHighlight(model, this.block);
|
|
176
|
+
thread.program.variables[this.name] += this.incrValue;
|
|
177
|
+
return model.wait(); // TODO - need to change this if we don't want it to use fuel
|
|
204
178
|
};
|
|
205
179
|
|
|
180
|
+
function If(conditionalCommandSets, elseBody, block) {
|
|
181
|
+
this.conditionalCommandSets = conditionalCommandSets;
|
|
182
|
+
this.elseBody = elseBody;
|
|
183
|
+
this.block = block;
|
|
184
|
+
}
|
|
206
185
|
|
|
186
|
+
If.prototype.execute = function (thread, model) {
|
|
187
|
+
var i = 0;
|
|
188
|
+
while (i < this.conditionalCommandSets.length) {
|
|
189
|
+
if (this.conditionalCommandSets[i].condition(model)) {
|
|
190
|
+
thread.pushToStack(this.conditionalCommandSets[i].commands.slice());
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
i++;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (this.elseBody) {
|
|
198
|
+
thread.pushToStack(this.elseBody.slice());
|
|
199
|
+
}
|
|
200
|
+
return true;
|
|
201
|
+
};
|
|
207
202
|
|
|
208
203
|
function While(condition, body, block) {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
204
|
+
this.condition = condition;
|
|
205
|
+
this.body = body;
|
|
206
|
+
this.block = block;
|
|
212
207
|
}
|
|
213
208
|
|
|
214
|
-
While.prototype.execute = function(thread, model) {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
209
|
+
While.prototype.execute = function (thread, model) {
|
|
210
|
+
if (this.condition(model)) {
|
|
211
|
+
thread.pushToStack([this]);
|
|
212
|
+
thread.pushToStack(this.body.slice());
|
|
213
|
+
}
|
|
214
|
+
return true;
|
|
220
215
|
};
|
|
221
216
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
this.body = body;
|
|
227
|
-
this.block = block;
|
|
217
|
+
function Event(condition, body, block, conditionType) {
|
|
218
|
+
this.condition = condition;
|
|
219
|
+
this.body = body;
|
|
220
|
+
this.block = block;
|
|
228
221
|
}
|
|
229
222
|
|
|
230
|
-
Event.prototype.execute = function(thread, model) {
|
|
231
|
-
|
|
223
|
+
Event.prototype.execute = function (thread, model) {
|
|
224
|
+
thread.pushToStack(this.body.slice());
|
|
232
225
|
|
|
233
|
-
|
|
226
|
+
return true;
|
|
234
227
|
};
|
|
235
228
|
|
|
236
|
-
function Procedure(name,body,block) {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
229
|
+
function Procedure(name, body, block) {
|
|
230
|
+
this.name = name;
|
|
231
|
+
this.body = body;
|
|
232
|
+
this.block = block;
|
|
240
233
|
}
|
|
241
234
|
|
|
242
|
-
Procedure.prototype.execute = function(thread) {
|
|
243
|
-
|
|
244
|
-
|
|
235
|
+
Procedure.prototype.execute = function (thread) {
|
|
236
|
+
thread.pushToStack(this.body.slice());
|
|
237
|
+
return true;
|
|
245
238
|
};
|
|
246
239
|
|
|
247
240
|
function ProcedureCall(block) {
|
|
248
|
-
|
|
241
|
+
this.block = block;
|
|
249
242
|
}
|
|
250
243
|
|
|
251
|
-
ProcedureCall.prototype.bind = function(proc) {
|
|
252
|
-
|
|
244
|
+
ProcedureCall.prototype.bind = function (proc) {
|
|
245
|
+
this.proc = proc;
|
|
253
246
|
};
|
|
254
247
|
|
|
255
|
-
ProcedureCall.prototype.execute = function(thread) {
|
|
256
|
-
|
|
257
|
-
|
|
248
|
+
ProcedureCall.prototype.execute = function (thread) {
|
|
249
|
+
thread.pushToStack([this.proc]);
|
|
250
|
+
return true;
|
|
258
251
|
};
|
|
259
252
|
|
|
260
|
-
|
|
261
|
-
|
|
262
253
|
/* Highlighting of blocks */
|
|
263
254
|
|
|
264
255
|
function queueHighlight(model, block, keepHighlighting) {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
256
|
+
if (model.shouldObserve) {
|
|
257
|
+
ocargo.animation.appendAnimation({
|
|
258
|
+
type: "callable",
|
|
259
|
+
functionType: "highlight",
|
|
260
|
+
functionCall: makeHighLightCallable(block.id, keepHighlighting),
|
|
261
|
+
description: "Blockly highlight: " + block.type,
|
|
262
|
+
blockId: block.id,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
275
265
|
}
|
|
276
266
|
|
|
277
|
-
function queueHighlightIncorrect(model, block){
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
267
|
+
function queueHighlightIncorrect(model, block) {
|
|
268
|
+
if (model.shouldObserve) {
|
|
269
|
+
ocargo.animation.appendAnimation({
|
|
270
|
+
type: "callable",
|
|
271
|
+
functionType: "highlightIncorrect",
|
|
272
|
+
functionCall: makeHighLightIncorrectCallable(block.id),
|
|
273
|
+
description: "Blockly highlight incorrect: " + block.type,
|
|
274
|
+
blockId: block.id,
|
|
275
|
+
});
|
|
276
|
+
}
|
|
287
277
|
}
|
|
288
278
|
|
|
289
279
|
function makeHighLightCallable(id, keepHighlighting) {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
};
|
|
280
|
+
return function () {
|
|
281
|
+
ocargo.blocklyControl.clearAllSelections();
|
|
282
|
+
var block = Blockly.mainWorkspace.getBlockById(id);
|
|
283
|
+
block.keepHighlighting = keepHighlighting;
|
|
284
|
+
ocargo.blocklyControl.setBlockSelected(block, true);
|
|
285
|
+
};
|
|
297
286
|
}
|
|
298
287
|
|
|
299
|
-
function makeHighLightIncorrectCallable(id){
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
288
|
+
function makeHighLightIncorrectCallable(id) {
|
|
289
|
+
return function () {
|
|
290
|
+
ocargo.blocklyControl.highlightIncorrectBlock(
|
|
291
|
+
Blockly.mainWorkspace.getBlockById(id)
|
|
292
|
+
);
|
|
293
|
+
};
|
|
303
294
|
}
|
|
@@ -129,9 +129,22 @@ ocargo.PythonControl = function () {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
function outf(outputText) {
|
|
132
|
+
/** @type {string} */
|
|
133
|
+
let text = outputText
|
|
134
|
+
|
|
135
|
+
if (text.startsWith("ParseError: ")) {
|
|
136
|
+
text += "\nThis may be because your code has not been formatted correctly or you have not indented your code correctly."
|
|
137
|
+
} else if (text.startsWith("AttributeError: ")) {
|
|
138
|
+
text += "\nEnsure that the object has the method or property. Review the PY commands for help.\nYou may also be trying to import something that doesn't exist."
|
|
139
|
+
} else if (text.startsWith("NameError: ")) {
|
|
140
|
+
text += "\nName errors usually happen because you have misspelt a variable name. Double check your spelling."
|
|
141
|
+
} else if (text.startsWith("TypeError: ")) {
|
|
142
|
+
text += "\nType errors usually happen because you are trying to perform an illegal action on an object."
|
|
143
|
+
}
|
|
144
|
+
|
|
132
145
|
ocargo.animation.appendAnimation({
|
|
133
146
|
type: 'console',
|
|
134
|
-
text
|
|
147
|
+
text
|
|
135
148
|
});
|
|
136
149
|
}
|
|
137
150
|
|
|
@@ -69,49 +69,12 @@ $(document).ready(function () {
|
|
|
69
69
|
$(".previous").removeClass("paginate_button");
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
-
// Setup shared levels table
|
|
73
|
-
let sharedLevelsTable = $("#sharedLevelsTable").DataTable({
|
|
74
|
-
scrollY: false,
|
|
75
|
-
scrollX: true,
|
|
76
|
-
scrollCollapse: false,
|
|
77
|
-
paging: true,
|
|
78
|
-
deferRender: true,
|
|
79
|
-
language: {
|
|
80
|
-
emptyTable: "No data available in table",
|
|
81
|
-
loadingRecords: "Loading...",
|
|
82
|
-
processing: "Processing...",
|
|
83
|
-
search: "Search:",
|
|
84
|
-
zeroRecords: "No matching records found"
|
|
85
|
-
},
|
|
86
|
-
columnDefs: [
|
|
87
|
-
{
|
|
88
|
-
orderable: false,
|
|
89
|
-
targets: "no-sort"
|
|
90
|
-
}
|
|
91
|
-
]
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
new $.fn.dataTable.FixedColumns(sharedLevelsTable, {
|
|
95
|
-
leftColumns: 2,
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
$("#sharedLevelsTable_next").append(" >");
|
|
99
|
-
|
|
100
|
-
sharedLevelsTable.on("draw", () => {
|
|
101
|
-
$("#sharedLevelsTable_next").append(" >");
|
|
102
|
-
$("#sharedLevelsTable_previous").prepend("< ");
|
|
103
|
-
$(".next").removeClass("paginate_button");
|
|
104
|
-
$(".previous").removeClass("paginate_button");
|
|
105
|
-
});
|
|
106
|
-
|
|
107
72
|
$("#scoreboardSearch").on("keyup", function () {
|
|
108
73
|
table.search(this.value).draw();
|
|
109
|
-
sharedLevelsTable.search(this.value).draw();
|
|
110
74
|
});
|
|
111
75
|
|
|
112
76
|
$(window).on("load", function () {
|
|
113
77
|
table.columns.adjust();
|
|
114
|
-
sharedLevelsTable.columns.adjust();
|
|
115
78
|
});
|
|
116
79
|
}
|
|
117
80
|
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
$(document).ready(function () {
|
|
2
|
+
let scoreboardPresent = document.getElementById("scoreboardTable") !== null;
|
|
3
|
+
|
|
4
|
+
if (scoreboardPresent) {
|
|
5
|
+
// Setup shared levels table
|
|
6
|
+
let sharedLevelsTable = $("#sharedLevelsTable").DataTable({
|
|
7
|
+
scrollY: false,
|
|
8
|
+
scrollX: true,
|
|
9
|
+
scrollCollapse: false,
|
|
10
|
+
paging: true,
|
|
11
|
+
deferRender: true,
|
|
12
|
+
language: {
|
|
13
|
+
emptyTable: "No data available in table",
|
|
14
|
+
loadingRecords: "Loading...",
|
|
15
|
+
processing: "Processing...",
|
|
16
|
+
search: "Search:",
|
|
17
|
+
zeroRecords: "No matching records found"
|
|
18
|
+
},
|
|
19
|
+
columnDefs: [
|
|
20
|
+
{
|
|
21
|
+
orderable: false,
|
|
22
|
+
targets: "no-sort"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
new $.fn.dataTable.FixedColumns(sharedLevelsTable, {
|
|
28
|
+
leftColumns: 2,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
$("#sharedLevelsTable_next").append(" >");
|
|
32
|
+
|
|
33
|
+
sharedLevelsTable.on("draw", () => {
|
|
34
|
+
$("#sharedLevelsTable_next").append(" >");
|
|
35
|
+
$("#sharedLevelsTable_previous").prepend("< ");
|
|
36
|
+
$(".next").removeClass("paginate_button");
|
|
37
|
+
$(".previous").removeClass("paginate_button");
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
$("#scoreboardSearch").on("keyup", function () {
|
|
41
|
+
sharedLevelsTable.search(this.value).draw();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
$(window).on("load", function () {
|
|
45
|
+
sharedLevelsTable.columns.adjust();
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
});
|
game/static/game/js/sharing.js
CHANGED
|
@@ -8,8 +8,8 @@ var ocargo = ocargo || {};
|
|
|
8
8
|
ocargo.Sharing = function (getLevelId, validationFunction) {
|
|
9
9
|
this.text = [];
|
|
10
10
|
this.text.shared = gettext("Yes");
|
|
11
|
+
this.text.admin = gettext("Yes");
|
|
11
12
|
this.text.unshared = gettext("No");
|
|
12
|
-
this.text.pending = "...";
|
|
13
13
|
|
|
14
14
|
this.classesTaught = [];
|
|
15
15
|
this.fellowTeachers = [];
|
|
@@ -89,35 +89,47 @@ ocargo.Sharing.prototype.populateSharingTable = function (recipients) {
|
|
|
89
89
|
$("#shareLevelTable tr").off("click");
|
|
90
90
|
table.empty();
|
|
91
91
|
|
|
92
|
-
//
|
|
92
|
+
// sort by admins first
|
|
93
93
|
recipients.sort(function (a, b) {
|
|
94
|
-
if (a.
|
|
95
|
-
return -1
|
|
96
|
-
} else if (
|
|
97
|
-
return 1
|
|
94
|
+
if (a.admin && !b.admin) {
|
|
95
|
+
return -1
|
|
96
|
+
} else if (b.admin && !a.admin) {
|
|
97
|
+
return 1
|
|
98
98
|
}
|
|
99
99
|
return 0;
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
this.allShared = true;
|
|
103
|
-
// Add a row to the table for each
|
|
103
|
+
// Add a row to the table for each recipient
|
|
104
104
|
for (let i = 0; i < recipients.length; i++) {
|
|
105
105
|
let recipient = recipients[i];
|
|
106
|
-
let status = recipient.shared ? "shared" : "unshared";
|
|
106
|
+
let status = recipient.shared ? "shared" || "admin" : "unshared";
|
|
107
107
|
|
|
108
108
|
if (recipient.shared) {
|
|
109
109
|
status = "shared";
|
|
110
|
+
|
|
111
|
+
if (recipient.admin) {
|
|
112
|
+
status = "admin"
|
|
113
|
+
}
|
|
114
|
+
|
|
110
115
|
} else {
|
|
111
116
|
status = "unshared";
|
|
112
117
|
this.allShared = false;
|
|
113
118
|
}
|
|
119
|
+
|
|
120
|
+
let name_text = recipient.name
|
|
121
|
+
|
|
122
|
+
if (recipient.admin) {
|
|
123
|
+
name_text += (" (Admin)")
|
|
124
|
+
}
|
|
125
|
+
|
|
114
126
|
table.append(
|
|
115
127
|
'<tr value="' +
|
|
116
128
|
recipient.id +
|
|
117
129
|
'" status="' +
|
|
118
130
|
status +
|
|
119
|
-
'"><td>' +
|
|
120
|
-
$("<div>").text(
|
|
131
|
+
'"><td class="share_name">' +
|
|
132
|
+
$("<div>").text(name_text).html() +
|
|
121
133
|
'</td><td class="share_cell">' +
|
|
122
134
|
this.text[status] +
|
|
123
135
|
"</td></tr>"
|