Skip to content

Commit

Permalink
Merge pull request #23938 from code-dot-org/staging
Browse files Browse the repository at this point in the history
DTT (Staging > Test) [robo-dtt]
  • Loading branch information
deploy-code-org committed Jul 26, 2018
2 parents d208039 + bd3fbd6 commit 272567a
Show file tree
Hide file tree
Showing 30 changed files with 103 additions and 65 deletions.
15 changes: 12 additions & 3 deletions dashboard/app/controllers/libraries_controller.rb
@@ -1,6 +1,10 @@
class LibrariesController < ApplicationController
before_action :require_levelbuilder_mode
load_and_authorize_resource find_by: :name
before_action :require_levelbuilder_mode, except: :show
load_and_authorize_resource find_by: :name, except: :show

def show
render plain: Library.content_from_cache(params[:id])
end

def new
render 'edit'
Expand All @@ -13,14 +17,19 @@ def create
def update
if @library.update library_params
redirect_to(
edit_library_path(id: @library.id),
edit_library_path(id: @library.name),
notice: 'Library saved',
)
else
render action: 'edit'
end
end

def destroy
@library.destroy
redirect_to(libraries_path, notice: 'Library Deleted')
end

private

def library_params
Expand Down
13 changes: 12 additions & 1 deletion dashboard/app/models/library.rb
Expand Up @@ -13,7 +13,9 @@ class Library < ApplicationRecord
include MultiFileSeeded
CONFIG_DIRECTORY = 'libraries'
SUBDIRECTORY_ATTRIBUTES = []
EXTENSION = 'js'
EXTENSION = 'interpreted.js'

after_save {@@all_library_names = nil}

def file_content
content
Expand All @@ -25,4 +27,13 @@ def self.properties_from_file(path, content)
content: content,
}
end

def self.content_from_cache(name)
@@all_library_names ||= Library.distinct.pluck(:name)
return nil unless @@all_library_names.include? name

Rails.cache.fetch("libraries/#{name}", force: !Script.should_cache?) do
Library.find_by(name: name).content
end
end
end
5 changes: 5 additions & 0 deletions dashboard/app/models/user.rb
Expand Up @@ -247,6 +247,7 @@ class User < ActiveRecord::Base

has_many :user_geos, -> {order 'updated_at desc'}

before_validation :normalize_parent_email
validate :validate_parent_email

after_create :associate_with_potential_pd_enrollments
Expand Down Expand Up @@ -2080,6 +2081,10 @@ def get_student_hidden_ids(assign_id, hidden_stages)
end
end

def normalize_parent_email
self.parent_email = nil if parent_email.blank?
end

# Parent email is not required, but if it is present, it must be a
# well-formed email address.
def validate_parent_email
Expand Down
2 changes: 1 addition & 1 deletion dashboard/app/views/devise/registrations/edit.html.haml
Expand Up @@ -24,7 +24,7 @@
.field
= f.label :parent_email, class: "label-bold"
= f.email_field :parent_email, autocomplete: 'off', maxlength: 255
- else
- if !current_user.parent_managed_account?
.field
= f.label :email, class: "label-bold"
- if current_user.migrated? && !current_user.student?
Expand Down
10 changes: 0 additions & 10 deletions dashboard/app/views/levels/editors/_gamelab.html.haml
Expand Up @@ -89,16 +89,6 @@
= f.label 'Custom setup code'
= f.text_field :custom_setup_code

.field
= f.label :helper_libraries
%p
Select
%a.select_all{href: '#'} all
\/
%a.select_none{href: '#'} none
(shift-click or cmd-click to select multiple).
= f.select :helper_libraries, (Library.distinct.pluck(:name) + @level.helper_libraries).uniq.sort, {}, {multiple: true}

.field
= f.label 'Validation code'
%p
Expand Down
10 changes: 10 additions & 0 deletions dashboard/app/views/levels/editors/_gamelab_jr.html.haml
Expand Up @@ -30,6 +30,16 @@
= f.label :hide_custom_blocks, 'Do not automatically add block pool and custom blocks to the toolbox'
= boolean_check_box f, :hide_custom_blocks

.field
= f.label :helper_libraries
%p
Select
%a.select_all{href: '#'} all
\/
%a.select_none{href: '#'} none
(shift-click or cmd-click to select multiple).
= f.select :helper_libraries, (Library.distinct.pluck(:name) + @level.helper_libraries).uniq.sort, {}, {multiple: true}

.field
=f.label 'Custom helper library code'
%p
Expand Down
2 changes: 1 addition & 1 deletion dashboard/app/views/libraries/edit.html.haml
Expand Up @@ -2,7 +2,7 @@
= stylesheet_link_tag 'css/levelbuilder', media: 'all'
= stylesheet_link_tag asset_path('css/common.css'), media: 'all'

%h1= @library.new_record? ? 'New Blockly Function' : 'Editing Blockly Function'
%h1= @library.new_record? ? 'New Library' : 'Editing Library'

.library-edit-container
.editor
Expand Down
2 changes: 1 addition & 1 deletion dashboard/config/locales/scripts.en.yml
Expand Up @@ -7739,7 +7739,7 @@ en:
Programming in Maze:
name: Coding with Angry Birds
Debugging in Maze:
name: Debugging with Angry Birds
name: Debugging with Scrat
Programming in Collector:
name: Collecting Treasure with Laurel
Programming in Artist:
Expand Down
5 changes: 3 additions & 2 deletions dashboard/config/scripts/levels/CSD U1L07 TFMD_2018.level
Expand Up @@ -9,11 +9,12 @@
"display_name": "Lesson Overview",
"reference": "/curriculum/csd-18/unit1/7/overview/index.html",
"parent_level_id": 13419,
"name_suffix": "_2018"
"name_suffix": "_2018",
"teacher_markdown": "[key]\r\n\r\n* [App Exploration](https://docs.google.com/document/d/1PD_VjGx5L7oBjAl0ij4qwcmsY08cR0gQEz4WLoEK0G4/edit?usp=sharing) - Exemplar ([PDF](https://docs.google.com/document/d/1PD_VjGx5L7oBjAl0ij4qwcmsY08cR0gQEz4WLoEK0G4/export?format=pdf) | [DOCX](https://docs.google.com/document/d/1PD_VjGx5L7oBjAl0ij4qwcmsY08cR0gQEz4WLoEK0G4/export?format=doc))\r\n\r\n[/key]"
},
"published": true,
"notes": "",
"audit_log": "[{\"changed_at\":\"2018-01-09 22:43:36 +0000\",\"changed\":[\"reference\"],\"changed_by_id\":1,\"changed_by_email\":\"josh@code.org\"},{\"changed_at\":\"2018-05-04 18:02:44 +0000\",\"changed\":[\"reference\"],\"changed_by_id\":1,\"changed_by_email\":\"josh@code.org\"},{\"changed_at\":\"2018-05-04 18:03:03 +0000\",\"changed\":[],\"changed_by_id\":1,\"changed_by_email\":\"josh@code.org\"},{\"changed_at\":\"2018-05-04 18:03:43 +0000\",\"changed\":[\"reference\",\"teacher_markdown\"],\"changed_by_id\":1,\"changed_by_email\":\"josh@code.org\"},{\"changed_at\":\"2018-05-04 18:04:45 +0000\",\"changed\":[\"reference\",\"teacher_markdown\"],\"changed_by_id\":1,\"changed_by_email\":\"josh@code.org\"},{\"changed_at\":\"2018-05-04 18:05:59 +0000\",\"changed\":[\"reference\",\"teacher_markdown\"],\"changed_by_id\":1,\"changed_by_email\":\"josh@code.org\"},{\"changed_at\":\"2018-05-04 18:06:38 +0000\",\"changed\":[\"reference\",\"teacher_markdown\"],\"changed_by_id\":1,\"changed_by_email\":\"josh@code.org\"},{\"changed_at\":\"2018-05-04 18:07:21 +0000\",\"changed\":[\"reference\",\"teacher_markdown\"],\"changed_by_id\":1,\"changed_by_email\":\"josh@code.org\"},{\"changed_at\":\"2018-05-04 18:09:26 +0000\",\"changed\":[\"reference\",\"teacher_markdown\"],\"changed_by_id\":1,\"changed_by_email\":\"josh@code.org\"},{\"changed_at\":\"2018-06-11 15:59:06 +0000\",\"changed\":[\"teacher_markdown\"],\"changed_by_id\":324,\"changed_by_email\":\"elizabeth@code.org\"}]",
"audit_log": "[{\"changed_at\":\"2018-01-09 22:43:36 +0000\",\"changed\":[\"reference\"],\"changed_by_id\":1,\"changed_by_email\":\"josh@code.org\"},{\"changed_at\":\"2018-05-04 18:02:44 +0000\",\"changed\":[\"reference\"],\"changed_by_id\":1,\"changed_by_email\":\"josh@code.org\"},{\"changed_at\":\"2018-05-04 18:03:03 +0000\",\"changed\":[],\"changed_by_id\":1,\"changed_by_email\":\"josh@code.org\"},{\"changed_at\":\"2018-05-04 18:03:43 +0000\",\"changed\":[\"reference\",\"teacher_markdown\"],\"changed_by_id\":1,\"changed_by_email\":\"josh@code.org\"},{\"changed_at\":\"2018-05-04 18:04:45 +0000\",\"changed\":[\"reference\",\"teacher_markdown\"],\"changed_by_id\":1,\"changed_by_email\":\"josh@code.org\"},{\"changed_at\":\"2018-05-04 18:05:59 +0000\",\"changed\":[\"reference\",\"teacher_markdown\"],\"changed_by_id\":1,\"changed_by_email\":\"josh@code.org\"},{\"changed_at\":\"2018-05-04 18:06:38 +0000\",\"changed\":[\"reference\",\"teacher_markdown\"],\"changed_by_id\":1,\"changed_by_email\":\"josh@code.org\"},{\"changed_at\":\"2018-05-04 18:07:21 +0000\",\"changed\":[\"reference\",\"teacher_markdown\"],\"changed_by_id\":1,\"changed_by_email\":\"josh@code.org\"},{\"changed_at\":\"2018-05-04 18:09:26 +0000\",\"changed\":[\"reference\",\"teacher_markdown\"],\"changed_by_id\":1,\"changed_by_email\":\"josh@code.org\"},{\"changed_at\":\"2018-06-11 15:59:06 +0000\",\"changed\":[\"teacher_markdown\"],\"changed_by_id\":324,\"changed_by_email\":\"elizabeth@code.org\"},{\"changed_at\":\"2018-07-24 23:56:53 +0000\",\"changed\":[],\"changed_by_id\":324,\"changed_by_email\":\"elizabeth@code.org\"}]",
"level_concept_difficulty": {
}
}]]></config>
Expand Down
14 changes: 11 additions & 3 deletions dashboard/config/scripts/levels/CSDU4 - Design Mode - 16.level
Expand Up @@ -23,7 +23,7 @@
"encrypted_examples": "rekFzZUJd6xk+soKqRLxkkGXuqBxi0o1wHmJkDYN354EDO2i915c95r96j1r\ne3cr\n",
"embed": "false",
"instructions": "Add an event handler for the button using the \"Insert and show\" link in the Design Mode Events tab. (Click to see full instructions).",
"markdown_instructions": "# Activate Your Button\r\nIn the last lesson you focused on laying out a page of your app in Design Mode. This is a great, quick way to get the visual side of an app figured out, but it's not very functional. If you click any of the buttons you added, nothing happens. Now you're work towards adding some basic functionality by making the buttons in your app actually _do_ something!\r\n\r\n**Goal:** Add code using Design Mode to make the button respond to a click.\r\n\r\n# Do This\r\nYour starter app has two elements, a _label_ with the id `titleLabel` and a _button_ with the id `changeTitleButton`. To start with, you're going to make the button log a message to the console when it's clicked.\r\n\r\n* In Design Mode, **click on the provided button to edit its properties**\r\n* Click on the **Events** tab\r\n* Insert an `onEvent` from Design Mode by clicking **Insert and show code** under the **Events Tab**.\r\n* Take a look at the block that was added to the **Code Mode** tab.\r\n* Run the program, click your button and **look for the output in the *Debug Console*** below the workspace instead of the app window. We will discuss the *Debug Console* on the next level.",
"markdown_instructions": "# Activate Your Button\r\nIn the last lesson you focused on laying out a page of your app in Design Mode. This is a great, quick way to get the visual side of an app figured out, but it's not very functional. If you click any of the buttons you added, nothing happens. Now you're work towards adding some basic functionality by making the buttons in your app actually _do_ something!\r\n\r\n**Goal:** Add code using Design Mode to make the button respond to a click.\r\n\r\n# Do This\r\nYour starter app has two elements, a _label_ with the id `titleLabel` and a _button_ with the id `changeTitleButton`. To start with, you're going to make the button log a message to the console when it's clicked.\r\n\r\n* In Design Mode, **click on the provided button to edit its properties**\r\n* Click on the **Events** tab\r\n* Insert an `onEvent` from Design Mode by clicking **Insert and show code** under the **Events Tab**.\r\n* Take a look at the block that was added to the **Code Mode** tab.\r\n* Run the program, click your button and **look for the output in the _Debug Console_** below the workspace instead of the app window. We will discuss the *Debug Console* on the next level.",
"is_k1": "false",
"skip_instructions_popup": "false",
"never_autoplay_video": "false",
Expand Down Expand Up @@ -57,12 +57,20 @@
"instructions_important": "false",
"makerlab_enabled": "false",
"show_debug_watch": "false",
"contained_level_names": null
"contained_level_names": null,
"disable_procedure_autopopulate": "false",
"top_level_procedure_autopopulate": "false",
"hide_share_and_remix": "false",
"disable_if_else_editing": "false",
"show_type_hints": "false",
"include_shared_functions": "false",
"expand_debugger": "false"
},
"published": true,
"notes": "",
"audit_log": "[{\"changed_at\":\"2018-07-24 23:56:43 +0000\",\"changed\":[\"code_functions\",\"encrypted_examples\",\"markdown_instructions\",\"contained_level_names\"],\"changed_by_id\":156,\"changed_by_email\":\"elijah@code.org\"}]",
"level_concept_difficulty": {
}
}]]></config>
<blocks/>
</Applab>
</Applab>
Expand Up @@ -41,10 +41,10 @@
"execute_palette_apis_only": "false",
"encrypted_examples": "dHbUA3gk7VhtRBEgitVJ2G4KY6h18bhOvNAJ0+jx68nrIGq1KrFqaRrTcN45\ngr6b\n",
"project_template_level_name": "U3L12 Chaser Template",
"contained_level_names": null,
"instructions_important": "false",
"fail_on_lint_errors": "false",
"makerlab_enabled": "false"
"makerlab_enabled": "false",
"contained_level_names": null
},
"published": true,
"notes": "",
Expand Down
19 changes: 1 addition & 18 deletions dashboard/config/scripts/levels/MC_HOC_2017_01_RETRY.level

Large diffs are not rendered by default.

Expand Up @@ -32,7 +32,7 @@
"never_autoplay_video": "false",
"instructions_important": "false",
"discard_background": "false",
"authored_hints": "[{\"hint_class\":\"pointer\",\"hint_markdown\":\"Start by making a nested loop to create four octagons. Turn 45 degrees to make the octagon. Jump, then turn 90 degrees after each one.\",\"hint_id\":\"courseD_artist_nestedLoops_challenge1_a\",\"hint_type\":\"general\",\"tts_url\":\"https://tts.code.org/sharon22k/180/100/d39572365361b446d429a66f0efbde89/courseD_artist_nestedLoops_challenge1.mp3\"},{\"hint_class\":\"content\",\"hint_markdown\":\"Add code to draw a triangle inside of your nested loop. Use 120 degree turns for your triangle.\",\"hint_id\":\"courseD_artist_nestedLoops_challenge1_b\",\"hint_type\":\"general\",\"tts_url\":\"https://tts.code.org/sharon22k/180/100/4c93a0ed152a652f67867c828ff90934/courseD_artist_nestedLoops_challenge1.mp3\"},{\"hint_class\":\"bottom-out\",\"hint_markdown\":\"Use a nested loop:\\n - Repeat 8 times\\n - draw an octagon\\n - draw a triangle\\n - jump forward 50 pixels\\n - turn right by 90 degrees\",\"hint_id\":\"courseD_artist_nestedLoops_challenge1_c\",\"hint_type\":\"general\",\"tts_url\":\"https://tts.code.org/sharon22k/180/100/5a2f24b9c94cca348f0cb2fe28eed1d5/courseD_artist_nestedLoops_challenge1.mp3\"}]",
"authored_hints": "[{\"hint_class\":\"pointer\",\"hint_markdown\":\"Start by making a nested loop to create four octagons. Turn 45 degrees to make the octagon. Jump, then turn 90 degrees after each one.\",\"hint_id\":\"courseD_artist_nestedLoops_challenge1_a\",\"hint_type\":\"general\",\"tts_url\":\"https://tts.code.org/sharon22k/180/100/d39572365361b446d429a66f0efbde89/course2_artist_nestedLoops_challenge1.mp3\"},{\"hint_class\":\"content\",\"hint_markdown\":\"Add code to draw a triangle inside of your nested loop. Use 120 degree turns for your triangle.\",\"hint_id\":\"courseD_artist_nestedLoops_challenge1_b\",\"hint_type\":\"general\",\"tts_url\":\"https://tts.code.org/sharon22k/180/100/4c93a0ed152a652f67867c828ff90934/course2_artist_nestedLoops_challenge1.mp3\"},{\"hint_class\":\"bottom-out\",\"hint_markdown\":\"Use a nested loop:\\n - Repeat 8 times\\n - draw an octagon\\n - draw a triangle\\n - jump forward 50 pixels\\n - turn right by 90 degrees\",\"hint_id\":\"courseD_artist_nestedLoops_challenge1_c\",\"hint_type\":\"general\",\"tts_url\":\"https://tts.code.org/sharon22k/180/100/96372cb452056f5887ec6e4d95756e7c/course2_artist_nestedLoops_challenge1.mp3\"}]",
"markdown_instructions": "Can you figure out how to make a picture like this?\r\n\r\n- Both shapes have **50 pixel sides.**\r\n- The *octagons* are made with **45 degree** turns.\r\n- The *triangles* are made with **120 degree** turns.",
"hide_share_and_remix": "false",
"disable_if_else_editing": "false",
Expand Down Expand Up @@ -156,4 +156,4 @@
</xml>
</solution_blocks>
</blocks>
</Artist>
</Artist>
Expand Up @@ -32,7 +32,7 @@
"never_autoplay_video": "false",
"instructions_important": "false",
"discard_background": "false",
"authored_hints": "[{\"hint_class\":\"pointer\",\"hint_markdown\":\"To have 8 hexagons in your drawing, you'll need to turn **45 degrees** between each of them. Why? Because 360 degrees (a full turn around) divided by 8 (the number of hexagons) is 45 degrees.\",\"hint_id\":\"courseD_artist_nestedLoops8_a\",\"hint_type\":\"general\",\"tts_url\":\"https://tts.code.org/sharon22k/180/100/fedcf81da410abbed3c31f7cde8188af/courseD_artist_nestedLoops8.mp3\"},{\"hint_class\":\"content\",\"hint_markdown\":\"If you're stuck, start by looking at the last puzzle, then change the things that are different.\",\"hint_id\":\"courseD_artist_nestedLoops8_b\",\"hint_type\":\"general\",\"tts_url\":\"https://tts.code.org/sharon22k/180/100/566313c796c6550baeddf1d041a025ad/courseD_artist_nestedLoops8.mp3\"},{\"hint_class\":\"bottom-out\",\"hint_markdown\":\"Use a nested loop:\\n\\n - Repeat 8 times\\n - draw a hexagon\\n - jump forward 50 pixels\\n - turn right 45 degrees\",\"hint_id\":\"courseD_artist_nestedLoops8_c\",\"hint_type\":\"general\",\"tts_url\":\"https://tts.code.org/sharon22k/180/100/aa45ff9c55722d766662e7523628d9a5/courseD_artist_nestedLoops8.mp3\"}]",
"authored_hints": "[{\"hint_class\":\"pointer\",\"hint_markdown\":\"To have 8 hexagons in your drawing, you'll need to turn **45 degrees** between each of them. Why? Because 360 degrees (a full turn around) divided by 8 (the number of hexagons) is 45 degrees.\",\"hint_id\":\"courseD_artist_nestedLoops8_a\",\"hint_type\":\"general\",\"tts_url\":\"https://tts.code.org/sharon22k/180/100/fedcf81da410abbed3c31f7cde8188af/courseD_artist_nestedLoops8_2018.mp3\"},{\"hint_class\":\"content\",\"hint_markdown\":\"If you're stuck, start by looking at the last puzzle, then change the things that are different.\",\"hint_id\":\"courseD_artist_nestedLoops8_b\",\"hint_type\":\"general\",\"tts_url\":\"https://tts.code.org/sharon22k/180/100/566313c796c6550baeddf1d041a025ad/courseD_artist_nestedLoops8_2018.mp3\"},{\"hint_class\":\"bottom-out\",\"hint_markdown\":\"Use a nested loop:\\n\\n - Repeat 8 times\\n - draw a hexagon\\n - jump forward 50 pixels\\n - turn right 45 degrees\",\"hint_id\":\"courseD_artist_nestedLoops8_c\",\"hint_type\":\"general\",\"tts_url\":\"https://tts.code.org/sharon22k/180/100/aa45ff9c55722d766662e7523628d9a5/courseD_artist_nestedLoops8_2018.mp3\"}]",
"markdown_instructions": "Using what you have learned in the last couple of puzzles, build this image from the beginning.\r\n\r\n- Each hexagon has **50 pixel sides** and **60 degree turns**",
"hide_share_and_remix": "false",
"disable_if_else_editing": "false",
Expand Down Expand Up @@ -132,4 +132,4 @@
</xml>
</solution_blocks>
</blocks>
</Artist>
</Artist>

0 comments on commit 272567a

Please sign in to comment.