Skip to content

Commit

Permalink
Merge pull request #7839 from code-dot-org/staging
Browse files Browse the repository at this point in the history
DTT: Merge staging to test
  • Loading branch information
ashercodeorg committed Apr 12, 2016
2 parents a32ff40 + 59d9d1a commit bf8938d
Show file tree
Hide file tree
Showing 128 changed files with 1,564 additions and 334 deletions.
129 changes: 129 additions & 0 deletions dashboard/app/controllers/transfers_controller.rb
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
2 changes: 1 addition & 1 deletion dashboard/app/views/levels/_unplug.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@
:javascript
var videoOptions = #{video.summarize(false).to_json};
var videoHeight = #{page_width} / (16 / 9);
createVideoWithFallback($('.video-container'), videoOptions, #{page_width}, videoHeight);
window.dashboard.videos.createVideoWithFallback($('.video-container'), videoOptions, #{page_width}, videoHeight);
10 changes: 7 additions & 3 deletions dashboard/config/locales/dsls.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ en:
AppLab Level U3L19 - variable re-assignment challenge pt1:
AppLab Level U3L19 - variable re-assignment challenge pt1: AppLab Level U3L19 - variable re-assignment challenge pt1
description here: description here
CSD U3 Variables Reassign Predict No Response: {}
CSP Journal Entry Placeholder:
CSP Journal Entry Placeholder: CSP Journal Entry Placeholder
Eventually replace this with a free-response journal entry level: Eventually replace this with a free-response journal entry level
Expand Down Expand Up @@ -2650,6 +2651,11 @@ en:
Test of 2 correct answer multi choice: Test of 2 correct answer multi choice
There are two answers here that are correct. Looks like you can choose either one and be right.: There are two answers here that are correct. Looks like you can choose either one and be right.
What is 2 + 2?: What is 2 + 2?
CSD U3 Variables Reassign Predict Multi:
A 10 will be displayed. Once a variable is full you cannot put another value in it: A 10 will be displayed. Once a variable is full you cannot put another value in it
A 20 will be displayed. New values replace old values in a variable: A 20 will be displayed. New values replace old values in a variable
A 30 will be displayed. Variables grow as you add more to them: A 30 will be displayed. Variables grow as you add more to them
An error will be generated.: An error will be generated.
'CSP U4L04 Assessment 1 ':
Question: Question
right answer: right answer
Expand Down Expand Up @@ -4626,9 +4632,7 @@ en:
Convert Blocks to Math: Convert Blocks to Math
Type out the arithmetic expression that matches this code: Type out the arithmetic expression that matches this code
Type the arithmetic expression here: Type the arithmetic expression here
CSD U3 Variables Reassign Predict:
Enter prompt here: Enter prompt here
Make a Prediction: Make a Prediction
CSD U3 Variables Reassign Predict: {}
'CSP U4L04 Assessment 2 ':
Enter answer here: Enter answer here
Enter prompt here: Enter prompt here
Expand Down
3 changes: 3 additions & 0 deletions dashboard/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def redirect_to_teacher_dashboard
end
end

post '/dashboardapi/sections/transfers', to: 'transfers#create'
post '/api/sections/transfers', to: 'transfers#create'

get '/sh/:id', to: redirect('/c/%{id}')
get '/sh/:id/:action', to: redirect('/c/%{id}/%{action}')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ markdown <<MARKDOWN
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
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
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
58 changes: 58 additions & 0 deletions dashboard/config/scripts/levels/CSD U3 Random Color.level
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 dashboard/config/scripts/levels/CSD U3 Random Width Height.level
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>
Loading

0 comments on commit bf8938d

Please sign in to comment.