Skip to content

Commit

Permalink
Merge pull request #40800 from code-dot-org/rename-20
Browse files Browse the repository at this point in the history
Random renaming of stage to lesson
  • Loading branch information
dmcavoy committed May 27, 2021
2 parents bf33893 + ffbd3f4 commit f456183
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 32 deletions.
26 changes: 13 additions & 13 deletions dashboard/app/controllers/admin_standards_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@ def index
def import_standards
script = Script.find_by_name(params["unit_name"])

code_studio_stages = {}
code_studio_lessons = {}
script&.lessons&.each do |lesson|
code_studio_stages[lesson.localized_name] = lesson
code_studio_lessons[lesson.localized_name] = lesson
end

missing_standards = []
missing_stages = []
missing_lessons = []

curriculum_builder_lessons = params["lessons"]

curriculum_builder_lessons&.each do |lesson|
stage = code_studio_stages[lesson["title"]]
curriculum_builder_lessons&.each do |l|
lesson = code_studio_lessons[l["title"]]

unless stage
missing_stages << lesson["title"]
unless lesson
missing_lessons << l["title"]
end

updated_standards = []

lesson["standards"].each do |standard|
l["standards"].each do |standard|
framework = Framework.find_by(shortcode: standard['framework'].downcase)
code_studio_standard = Standard.find_by(
{
Expand All @@ -45,16 +45,16 @@ def import_standards
missing_standards << standard["shortcode"]
end

if code_studio_standard && stage
if code_studio_standard && lesson
updated_standards << code_studio_standard
end
end
stage&.standards = updated_standards
stage&.save!
lesson&.standards = updated_standards
lesson&.save!
end

if !missing_standards.empty? || !missing_stages.empty?
render json: {status: 'failure', message: "Couldn't find standards: #{missing_standards}. Couldn't find stages: #{missing_stages}"}
if !missing_standards.empty? || !missing_lessons.empty?
render json: {status: 'failure', message: "Couldn't find standards: #{missing_standards}. Couldn't find lessons: #{missing_lessons}"}
else
render json: {status: 'success', message: "Hooray! Importing standards associations for #{script&.name} worked."}
end
Expand Down
2 changes: 1 addition & 1 deletion dashboard/app/models/levels/bubble_choice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def sublevel_at(index)
end

# Returns a sublevel's position in the parent level. Can be used for generating
# a sublevel URL (/s/:script_name/lessons/:stage_pos/levels/:puzzle_pos/sublevel/:sublevel_pos).
# a sublevel URL (/s/:script_name/lessons/:lesson_pos/levels/:puzzle_pos/sublevel/:sublevel_pos).
# @param [Level] sublevel
# @return [Integer] The sublevel's position (i.e., its index + 1) under the parent level.
def sublevel_position(sublevel)
Expand Down
2 changes: 1 addition & 1 deletion dashboard/app/models/levels/level.rb
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def delete_custom_level_file
end

# Overriden in subclasses, provides a summary for rendering thumbnails on the
# stage extras page
# lesson extras page
def summarize_as_bonus
{}
end
Expand Down
4 changes: 2 additions & 2 deletions dashboard/app/models/plc/enrollment_module_assignment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def status

# Legacy PD courses do not have modules. However, they have user-completion-status for different sections
# in similar ways - look at all the levels, and see what the user progress is for them.
def self.lessons_based_status(stages, user, script)
all_levels = stages.flat_map(&:script_levels).flat_map(&:levels)
def self.lessons_based_status(lessons, user, script)
all_levels = lessons.flat_map(&:script_levels).flat_map(&:levels)
levels_tracked = all_levels.reject {|level| [External, ExternalLink].include?(level.class) || level.try(:peer_reviewable?)}

user_progress_on_tracked_levels = UserLevel.where(user: user, level: levels_tracked, script: script)
Expand Down
16 changes: 8 additions & 8 deletions dashboard/app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2331,14 +2331,14 @@ def hidden_script_ids(sections)

# This method will extract a list of hidden ids by section. The type of ids depends
# on the input. If hidden_lessons is true, id is expected to be a script id and
# we look for stages that are hidden. If hidden_lessons is false, id is expected
# we look for lessons that are hidden. If hidden_lessons is false, id is expected
# to be a course_id, and we look for hidden scripts.
# @param {boolean} hidden_lessons - True if we're looking for hidden stages, false
# @param {boolean} hidden_lessons - True if we're looking for hidden lessons, false
# if we're looking for hidden scripts.
# @return {Hash<string,number[]>
def get_teacher_hidden_ids(hidden_lessons)
# If we're a teacher, we want to go through each of our sections and return
# a mapping from section id to hidden stages/scripts in that section
# a mapping from section id to hidden lessons/scripts in that section
hidden_by_section = {}
sections.each do |section|
hidden_by_section[section.id] = hidden_lessons ? hidden_lesson_ids([section]) : hidden_script_ids([section])
Expand All @@ -2347,10 +2347,10 @@ def get_teacher_hidden_ids(hidden_lessons)
end

# This method method will go through each of the sections in which we're a member
# and determine which stages/scripts should be hidden
# @param {boolean} hidden_lessons - True if we're looking for hidden stages, false
# and determine which lessons/scripts should be hidden
# @param {boolean} hidden_lessons - True if we're looking for hidden lessons, false
# if we're looking for hidden scripts.
# @return {number[]} Set of stage/script ids that should be hidden
# @return {number[]} Set of lesson/script ids that should be hidden
def get_student_hidden_ids(assign_id, hidden_lessons)
sections = sections_as_student
return [] if sections.empty?
Expand All @@ -2361,11 +2361,11 @@ def get_student_hidden_ids(assign_id, hidden_lessons)
end

if assigned_sections.empty?
# if we have no sections matching this assignment, we consider a stage/script
# if we have no sections matching this assignment, we consider a lesson/script
# hidden if any of our sections hides it
return (hidden_lessons ? hidden_lesson_ids(sections) : hidden_script_ids(sections)).uniq
else
# if we do have sections matching this assignment, we consider a stage/script
# if we do have sections matching this assignment, we consider a lesson/script
# hidden only if it is hidden in every one of the sections the student belongs
# to that match this assignment
all_ids = hidden_lessons ? hidden_lesson_ids(assigned_sections) : hidden_script_ids(assigned_sections)
Expand Down
2 changes: 1 addition & 1 deletion dashboard/app/models/user_permission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class UserPermission < ApplicationRecord
FACILITATOR = 'facilitator'.freeze,
# Grants access to viewing hidden scripts.
HIDDEN_SCRIPT_ACCESS = 'hidden_script_access'.freeze,
# Grants access to managing (e.g., editing) levels, stages, scripts, etc.
# Grants access to managing (e.g., editing) levels, lessons, scripts, etc.
# Also grants access to viewing extra links related to editing these.
# Also makes the account satisfy authorized_teacher?.
LEVELBUILDER = 'levelbuilder'.freeze,
Expand Down
2 changes: 1 addition & 1 deletion dashboard/lib/policies/inline_answer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def self.visible?(user, script_level)
# even if they are not authorized
return true if user.try(:teacher?) && script && (script.k5_course? || script.k5_draft_course?)

# Teachers can also put stages into a readonly mode in which students are
# Teachers can also put lessons into a readonly mode in which students are
# able to view the answers
user_level = UserLevel.find_by(user: user, level: script_level.level)
return true if user_level.try(:readonly_answers)
Expand Down
8 changes: 4 additions & 4 deletions dashboard/test/integration/db_query_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def setup
sign_in student

script = Script.get_from_cache('allthethings')
stage = script.lessons.first
level = stage.script_levels.first.levels.first
lesson = script.lessons.first
level = lesson.script_levels.first.levels.first

create :user_level,
user: student,
Expand All @@ -35,8 +35,8 @@ def setup
sign_in student

script = Script.hoc_2014_script
stage = script.lessons.first
level = stage.script_levels.first.levels.first
lesson = script.lessons.first
level = lesson.script_levels.first.levels.first

create :user_level,
user: student,
Expand Down
2 changes: 1 addition & 1 deletion dashboard/test/lib/policies/inline_answer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Policies::InlineAnswerTest < ActiveSupport::TestCase
refute Policies::InlineAnswer.visible?(@authorized_teacher, create(:script_level, script: plc_script))
end

test 'visible? returns true for all kinds of users if the stage is in readonly mode for that user' do
test 'visible? returns true for all kinds of users if the lesson is in readonly mode for that user' do
script_level = create(:script_level)
create(:user_level, user: @student, level: script_level.level, submitted: true, readonly_answers: true)
assert Policies::InlineAnswer.visible?(@student, script_level)
Expand Down

0 comments on commit f456183

Please sign in to comment.