-
Notifications
You must be signed in to change notification settings - Fork 482
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7839 from code-dot-org/staging
DTT: Merge staging to test
- Loading branch information
Showing
128 changed files
with
1,564 additions
and
334 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
class TransfersController < ApplicationController | ||
before_filter :authenticate_user! | ||
skip_before_filter :verify_authenticity_token | ||
|
||
# POST /sections/:id/transfers | ||
def create | ||
new_section_code = params[:new_section_code] | ||
|
||
begin | ||
new_section = Section.find_by!(code: new_section_code) | ||
rescue ActiveRecord::RecordNotFound | ||
# TODO: i18n | ||
render json: { | ||
error: "Sorry, but that section does not exist. Please enter a different section code." | ||
}, status: :not_found | ||
return | ||
end | ||
|
||
# This is needed when we eventually allow students to be in multiple sections | ||
if params.has_key?(:current_section_code) | ||
current_section_code = params[:current_section_code] | ||
else | ||
# TODO: i18n | ||
render json: { | ||
error: "Please provide current_section_code." | ||
}, status: :bad_request | ||
return | ||
end | ||
|
||
if new_section_code == current_section_code | ||
# TODO: i18n | ||
render json: { | ||
error: "The current section cannot be the same as the new section." | ||
}, status: :bad_request | ||
return | ||
end | ||
|
||
begin | ||
current_section = Section.find_by!(code: current_section_code) | ||
rescue ActiveRecord::RecordNotFound | ||
# TODO: i18n | ||
render json: { | ||
error: "Sorry, but section #{current_section_code} does not exist. Please enter a different section code." | ||
}, status: :not_found | ||
return | ||
end | ||
|
||
if current_section.user != current_user | ||
# TODO: i18n | ||
render json: { | ||
error: "You cannot move students from a section that does not belong to you." | ||
}, status: :forbidden | ||
return | ||
end | ||
|
||
# As of right now, this only applies to transfers to another teacher | ||
# When students are allowed to be in multiple sections, this will also be needed | ||
# for transfers between the current logged-in teacher | ||
if new_section.user == current_user | ||
stay_enrolled_in_current_section = false | ||
elsif params.has_key?(:stay_enrolled_in_current_section) | ||
stay_enrolled_in_current_section = params[:stay_enrolled_in_current_section] | ||
else | ||
# TODO: i18n | ||
render json: { | ||
error: "Please provide stay_enrolled_in_current_section." | ||
}, status: :bad_request | ||
return | ||
end | ||
|
||
if params.has_key?(:student_ids) | ||
student_ids = params[:student_ids].split(',').map(&:to_i) | ||
else | ||
# TODO: i18n | ||
render json: { | ||
error: "Please provide student_ids." | ||
}, status: :bad_request | ||
return | ||
end | ||
|
||
begin | ||
students = User.find(student_ids) | ||
rescue ActiveRecord::RecordNotFound | ||
# TODO: i18n | ||
render json: { | ||
error: "One or more students could not be found." | ||
}, status: :not_found | ||
return | ||
end | ||
|
||
if student_ids.count != current_user.followers.where(student_user_id: student_ids).count | ||
# TODO: i18n | ||
render json: { | ||
error: "All the students must currently be enrolled in your section." | ||
}, status: :forbidden | ||
return | ||
end | ||
|
||
if new_section.user != current_user | ||
new_section_teacher = new_section.user | ||
if students.any? {|student| Follower.exists?(student_user: student, user_id: new_section_teacher.id)} | ||
render json: { | ||
error: "You cannot move these students because this teacher already has them in another section." | ||
}, status: :bad_request | ||
return | ||
end | ||
end | ||
|
||
students.each do |student| | ||
if new_section.user == current_user | ||
follower_same_user_teacher = student.followeds.find_by_section_id(current_section.id) | ||
follower_same_user_teacher.update_attributes!(section_id: new_section.id) | ||
else | ||
if !student.followeds.exists?(section_id: new_section.id) | ||
student.followeds.create!(user_id: new_section.user_id, section: new_section) | ||
end | ||
|
||
if !stay_enrolled_in_current_section | ||
student.followeds.find_by_section_id(current_section.id).destroy | ||
end | ||
end | ||
|
||
student.assign_script(new_section.script) if new_section.script | ||
end | ||
|
||
# TODO: Email students if they're transferred to another teacher | ||
render json: {}, status: :no_content | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
dashboard/config/scripts/csd_u3_variables_reassign_predict_multi.multi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name 'CSD U3 Variables Reassign Predict Multi' | ||
wrong 'A 10 will be displayed. Once a variable is full you cannot put another value in it' | ||
right 'A 20 will be displayed. New values replace old values in a variable' | ||
wrong 'A 30 will be displayed. Variables grow as you add more to them' | ||
wrong 'An error will be generated.' | ||
|
||
markdown <<MARKDOWN | ||
# Make a Prediction | ||
|
||
This program **creates a variable** and then sets its value twice in a row. **What value will be displayed when the console.log() statement runs?** | ||
|
||
![](https://images.code.org/0375d4215c5cc4b937c9333390deb81c-image-1460404063955.47.09 PM.png) | ||
|
||
**Once you've submitted your answer, be ready to discuss your reasoning with your classmates** | ||
MARKDOWN |
11 changes: 11 additions & 0 deletions
11
dashboard/config/scripts/csd_u3_variables_reassign_predict_no_response.external
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name 'CSD U3 Variables Reassign Predict No Response' | ||
css 'unplugged' | ||
markdown <<MARKDOWN | ||
# Make a Prediction | ||
|
||
This program **creates a variable** and then sets its value twice in a row. **What value will be displayed when the console.log() statement runs?** | ||
|
||
![](https://images.code.org/0375d4215c5cc4b937c9333390deb81c-image-1460404063955.47.09 PM.png) | ||
|
||
**Once you've submitted your answer be prepared to discuss your reasoning with your classmates.** | ||
MARKDOWN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<Gamelab> | ||
<config><![CDATA[{ | ||
"game_id": 50, | ||
"created_at": "2016-04-12T18:30:46.000Z", | ||
"level_num": "custom", | ||
"user_id": 1, | ||
"properties": { | ||
"skin": "gamelab", | ||
"code_functions": { | ||
"color": null, | ||
"fill": null, | ||
"noFill": null, | ||
"stroke": null, | ||
"strokeWeight": null, | ||
"noStroke": null, | ||
"arc": null, | ||
"ellipse": null, | ||
"line": null, | ||
"point": null, | ||
"rect": null, | ||
"regularPolygon": null, | ||
"shape": null, | ||
"randomNumber_min_max": null, | ||
"console.log": null | ||
}, | ||
"edit_code": true, | ||
"embed": "false", | ||
"start_blocks": "// Use randomNumber() to draw some\r\n//randomized shapes\r\n", | ||
"is_k1": "false", | ||
"skip_instructions_popup": "false", | ||
"never_autoplay_video": "false", | ||
"disable_param_editing": "true", | ||
"disable_variable_editing": "false", | ||
"use_modal_function_editor": "false", | ||
"use_contract_editor": "false", | ||
"contract_highlight": "false", | ||
"contract_collapse": "false", | ||
"examples_highlight": "false", | ||
"examples_collapse": "false", | ||
"examples_required": "false", | ||
"definition_highlight": "false", | ||
"definition_collapse": "false", | ||
"disable_examples": "false", | ||
"droplet_tooltips_disabled": "false", | ||
"lock_zero_param_functions": "false", | ||
"free_play": "true", | ||
"text_mode_at_start": "false", | ||
"submittable": "false", | ||
"hide_view_data_button": "true", | ||
"debugger_disabled": "false", | ||
"markdown_instructions": "# Randomized Colors\r\n\r\nCould you use randomNumber() to pick random colors as well? Back in unit 2 you learned that colors can be composed of Red Green and Blue channel values - each of which is represented by a number value. What's the maximum and minimum that those channels can be set to?\r\n\r\n# Do This\r\n\r\nUsing the `color()` function, set the `fill` or `stroke` of your shape to a random color.\r\n\r\n# Challenge\r\n\r\nCan you generate random colors that are limited to a narrow range of colors? Like randomly purpl-ish, or randomly teal-ish?", | ||
"instructions": "Could you use randomNumber() to pick random colors as well? Try setting one or more of the channels in the rgb block with a random number. What should the maximum value be?" | ||
}, | ||
"published": true, | ||
"notes": "" | ||
}]]></config> | ||
<blocks/> | ||
</Gamelab> |
58 changes: 58 additions & 0 deletions
58
dashboard/config/scripts/levels/CSD U3 Random Width Height.level
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<Gamelab> | ||
<config><![CDATA[{ | ||
"game_id": 50, | ||
"created_at": "2016-04-11T23:18:06.000Z", | ||
"level_num": "custom", | ||
"user_id": 1, | ||
"properties": { | ||
"skin": "gamelab", | ||
"code_functions": { | ||
"fill": null, | ||
"noFill": null, | ||
"stroke": null, | ||
"strokeWeight": null, | ||
"noStroke": null, | ||
"arc": null, | ||
"ellipse": null, | ||
"line": null, | ||
"point": null, | ||
"rect": null, | ||
"regularPolygon": null, | ||
"shape": null, | ||
"randomNumber_max": null, | ||
"randomNumber_min_max": null, | ||
"console.log": null | ||
}, | ||
"edit_code": true, | ||
"embed": "false", | ||
"start_blocks": "// Use randomNumber() to draw some\r\n//randomized shapes\r\n", | ||
"is_k1": "false", | ||
"skip_instructions_popup": "false", | ||
"never_autoplay_video": "false", | ||
"disable_param_editing": "true", | ||
"disable_variable_editing": "false", | ||
"use_modal_function_editor": "false", | ||
"use_contract_editor": "false", | ||
"contract_highlight": "false", | ||
"contract_collapse": "false", | ||
"examples_highlight": "false", | ||
"examples_collapse": "false", | ||
"examples_required": "false", | ||
"definition_highlight": "false", | ||
"definition_collapse": "false", | ||
"disable_examples": "false", | ||
"droplet_tooltips_disabled": "false", | ||
"lock_zero_param_functions": "false", | ||
"free_play": "true", | ||
"text_mode_at_start": "false", | ||
"submittable": "false", | ||
"hide_view_data_button": "true", | ||
"debugger_disabled": "false", | ||
"markdown_instructions": "# Randomized Shapes\r\n\r\nLet's see how we can used randomization in our drawings. Each of the parameters from the shape functions you've seen can be replaced with calls to `randomNumber()`. Try drawing some images that are slightly randomized each time.\r\n\r\n# Do This\r\n\r\nPick a shape function and use calls to `randomNumber()` in place of one or more of the parameters. Maker sure you run it a few times so you can see the effect of randomization.", | ||
"instructions": "Pick a shape function and use calls to randomNumber() in place of one or more of the parameters. Maker sure you run it a few times so you can see the effect of randomization." | ||
}, | ||
"published": true, | ||
"notes": "" | ||
}]]></config> | ||
<blocks/> | ||
</Gamelab> |
Oops, something went wrong.