allow observers to view all module content
test plan: * make a course with modules with completion requirements and sequential progress * log in as an observer in the course * should not be required to complete content to view it closes #CNVS-9216 Change-Id: Id2ac39e8d1199bed0e2b17c3d04a58d5c7f4304c Reviewed-on: https://gerrit.instructure.com/39622 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Jeremy Stanley <jeremy@instructure.com> QA-Review: Trevor deHaan <tdehaan@instructure.com> Product-Review: Hilary Scharton <hilary@instructure.com>
This commit is contained in:
parent
3d640c7078
commit
069ee249bc
|
@ -374,11 +374,12 @@ class ContextModulesController < ApplicationController
|
|||
@progressions = ContextModuleProgression.where(:context_module_id => context_module_ids).each{|p| p.evaluate }
|
||||
end
|
||||
end
|
||||
render :json => @progressions
|
||||
else
|
||||
elsif @context.grants_right?(@current_user, session, :participate_as_student)
|
||||
@progressions = @context.context_modules.active.order(:id).map{|m| m.evaluate_for(@current_user) }
|
||||
render :json => @progressions
|
||||
else
|
||||
@progressions = []
|
||||
end
|
||||
render :json => @progressions
|
||||
elsif !@context.feature_enabled?(:draft_state)
|
||||
redirect_to named_context_url(@context, :context_context_modules_url, :anchor => "student_progressions")
|
||||
elsif !@context.grants_right?(@current_user, session, :view_all_grades)
|
||||
|
|
|
@ -175,7 +175,10 @@ class ContextModule < ActiveRecord::Base
|
|||
return true
|
||||
elsif !self.active?
|
||||
return false
|
||||
elsif self.context.user_has_been_observer?(user)
|
||||
return true
|
||||
end
|
||||
|
||||
progression = self.evaluate_for(user)
|
||||
# if the progression is locked, then position in the progression doesn't
|
||||
# matter. we're not available.
|
||||
|
|
|
@ -442,6 +442,34 @@ describe ContextModule do
|
|||
@module2.available_for?(@user, :tag => @tag2, :deep_check_if_needed => true).should be_false
|
||||
end
|
||||
|
||||
it "should be available to observers" do
|
||||
course_module
|
||||
@assignment = @course.assignments.create!(:title => "some assignment")
|
||||
@tag = @module.add_item({:id => @assignment.id, :type => 'assignment'})
|
||||
@module.completion_requirements = {@tag.id => {:type => 'must_view'}}
|
||||
@module.save!
|
||||
@student = User.create!(:name => "some name")
|
||||
@course.enroll_student(@student)
|
||||
|
||||
@module2 = @course.context_modules.create!(:name => "another module")
|
||||
@module2.prerequisites = "module_#{@module.id}"
|
||||
@assignment2 = @course.assignments.create!(:title => 'a2')
|
||||
@tag2 = @module2.add_item({:id => @assignment2.id, :type => 'assignment'})
|
||||
@module2.completion_requirements = {@tag2.id => {:type => 'must_view'}}
|
||||
@module2.save!
|
||||
|
||||
@module2.prerequisites.should_not be_empty
|
||||
@module2.available_for?(@student, :tag => @tag2, :deep_check_if_needed => true).should be_false
|
||||
|
||||
@course.enroll_user(user, 'ObserverEnrollment', :enrollment_state => 'active', :associated_user_id => @student.id)
|
||||
user_session(@user)
|
||||
|
||||
@module2.available_for?(@user, :tag => @tag2, :deep_check_if_needed => true).should be_true
|
||||
|
||||
@module2.update_attribute(:require_sequential_progress, true)
|
||||
@module2.available_for?(@user, :tag => @tag2).should be_true
|
||||
end
|
||||
|
||||
it "should create an unlocked progression if there are prerequisites that are met" do
|
||||
course_module
|
||||
@user = User.create!(:name => "some name")
|
||||
|
|
|
@ -71,6 +71,24 @@ describe "context_modules" do
|
|||
context_modules[2].find_element(:css, '.context_module_criterion').should include_text(@module_2.name)
|
||||
end
|
||||
|
||||
it "should not lock modules for observers" do
|
||||
@course.enroll_user(user, 'ObserverEnrollment', :enrollment_state => 'active', :associated_user_id => @student.id)
|
||||
user_session(@user)
|
||||
|
||||
go_to_modules
|
||||
|
||||
# shouldn't show the teacher's "show student progression" button
|
||||
ff('.module_progressions_link').should_not be_present
|
||||
|
||||
context_modules = ff('.context_module')
|
||||
#initial check to make sure everything was setup correctly
|
||||
ff('.context_module .progression_container').each do |item|
|
||||
item.text.strip.should be_blank
|
||||
end
|
||||
get "/courses/#{@course.id}/assignments/#{@assignment_2.id}"
|
||||
f('#content').should_not include_text("hasn't been unlocked yet")
|
||||
end
|
||||
|
||||
it "should show overridden due dates for assignments" do
|
||||
override = assignment_override_model(:assignment => @assignment_2)
|
||||
override.override_due_at(4.days.from_now)
|
||||
|
|
Loading…
Reference in New Issue