canvas-lms/spec/integration/context_module_spec.rb

280 lines
11 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
#
# Copyright (C) 2011 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'nokogiri'
describe ContextModule do
def course_module
course_with_student_logged_in(:active_all => true)
@module = @course.context_modules.create!(:name => "some module")
end
describe "index" do
it "should require manage_content permission before showing add controls" do
course_with_teacher_logged_in active_all: true
get "/courses/#{@course.id}/modules"
doc = Nokogiri::HTML5(response.body)
expect(doc.at_css('.add_module_link')).not_to be_nil
@course.account.role_overrides.create! role: ta_role, permission: 'manage_content', enabled: false
course_with_ta course: @course
user_session(@ta)
get "/courses/#{@course.id}/modules"
doc = Nokogiri::HTML5(response.body)
expect(doc.at_css('.add_module_link')).to be_nil
end
end
it "should clear the page cache on individual tag change" do
enable_cache do
course_with_teacher_logged_in(:active_all => true)
context_module = @course.context_modules.create!
content_tag = context_module.add_item :type => 'context_module_sub_header', :title => "My Sub Header Title"
ContextModule.where(:id => context_module).update_all(:updated_at => 1.hour.ago)
get "/courses/#{@course.id}/modules"
expect(response.body).to match(/My Sub Header Title/)
content_tag.update(:title => "My New Title")
touch module outside content_tag save txn to prevent deadlock fixes CNVS-7757 test plan: - open two Rails consoles - in each, create a bunch of items in the same module at the same time, e.g. mod = ContextModule.last 100.times do |x| mod.add_item type: 'context_module_sub_header', title: "item #{x}" end - each console should finish adding its items or, when deployed in a production-like environment (with multiple app servers, or at least a multithreaded server) - generate a curl command line to add an item to a module (works with a subheader, so you don't need corresponding assets) curl -H "Authorization: Bearer {token} \ https://<canvas>/api/v1/courses/XXX/modules/YYY/items \ -F module_item[title]=newthing -F module_item[type]=SubHeader & (the trailing &, after a space, means run in the background; that is, don't wait for the preceding request to finish before returning to the command line) - run the preceding command several times in rapid succession (up, enter, up, enter, etc.) (I was able to reproduce in less than 10 requests) - look at the json blocks returned, and make sure none of them are an internal server error (if they are, there will be an error report number you can look up and see if the deadlock happened) Change-Id: I63834cfd98393e5207625db27d18451103aa2944 Reviewed-on: https://gerrit.instructure.com/23783 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Rob Orton <rob@instructure.com> QA-Review: August Thornton <august@instructure.com> Product-Review: Jeremy Stanley <jeremy@instructure.com>
2013-08-28 00:46:08 +08:00
get "/courses/#{@course.id}/modules"
expect(response.body).to match(/My New Title/)
end
end
describe "must_contribute" do
before do
course_module
@module.require_sequential_progress = true
@module.save!
end
def before_after
@module.completion_requirements = { @tag.id => { :type => 'must_contribute' } }
@module.save!
@progression = @module.evaluate_for(@user)
expect(@progression).not_to be_nil
expect(@progression).not_to be_completed
expect(@progression).to be_unlocked
expect(@progression.current_position).to eql(@tag.position)
yield
@progression = @module.evaluate_for(@user)
expect(@progression).to be_completed
expect(@progression.current_position).to eql(@tag.position)
end
it "should progress for discussions" do
@discussion = @course.discussion_topics.create!(:title => "talk")
@tag = @module.add_item(:type => 'discussion_topic', :id => @discussion.id)
before_after do
post "/courses/#{@course.id}/discussion_entries", params: {:discussion_entry => { :message => 'ohai', :discussion_topic_id => @discussion.id }}
expect(response).to be_redirect
end
end
it "should progress for wiki pages" do
@page = @course.wiki_pages.create!(:title => "talk page", :body => 'ohai', :editing_roles => 'teachers,students')
@tag = @module.add_item(:type => 'wiki_page', :id => @page.id)
before_after do
put "/api/v1/courses/#{@course.id}/pages/#{@page.url}", params: {:wiki_page => { :body => 'i agree', :title => 'talk page' }}
end
end
it "should progress for assignment discussions" do
@assignment = @course.assignments.create!(:title => 'talk assn', :submission_types => 'discussion_topic')
@tag = @module.add_item(:type => 'assignment', :id => @assignment.id)
before_after do
post "/courses/#{@course.id}/discussion_entries", params: {:discussion_entry => { :message => 'ohai', :discussion_topic_id => @assignment.discussion_topic.id }}
expect(response).to be_redirect
end
end
end
allow module progression when background job hasn't finished If a user just completed a module and hasn't gone to the modules page and clicks the next module item button that goes into the next module (not another item within the same module), the next module will still be locked. (If they click before the delayed job is run) This commit makes it so that clicking on a module item link that goes to a locked item will cause the module progressions to be recalculated in-request before the user is redirected to the destination resource. This should happen fairly infrequently since the user will only be able to access a locked module item link under the circumstances mentioned in the first paragraph. (locked items are disabled while on the modules page) Test Plan: * Run canvas in production with caching on and Delayed Jobs not running * Create a module with a quiz as the last item * Make it so that the module isn't complete unless the student has scored at least 1 * Create a second module with an assignment as the first item * Make it so that module isn't unlocked until the first module is complete * Add a student and publish the course * Log in as student * Go to the quiz in the first module * Observe that clicking the next module item button takes you to the assignment but that it is locked. * Take the quiz and score at least 1, _do not_ go to the modules page after this is done. * Click the next module item button and make sure the assignment is unlocked closes #6254 Change-Id: I0719ecdc75af2d5c61bf78fbe2f07c4f21f2e24d Reviewed-on: https://gerrit.instructure.com/7362 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com>
2011-12-08 11:06:24 +08:00
describe "progressing before job is run" do
def progression_testing(progress_by_item_link)
allow module progression when background job hasn't finished If a user just completed a module and hasn't gone to the modules page and clicks the next module item button that goes into the next module (not another item within the same module), the next module will still be locked. (If they click before the delayed job is run) This commit makes it so that clicking on a module item link that goes to a locked item will cause the module progressions to be recalculated in-request before the user is redirected to the destination resource. This should happen fairly infrequently since the user will only be able to access a locked module item link under the circumstances mentioned in the first paragraph. (locked items are disabled while on the modules page) Test Plan: * Run canvas in production with caching on and Delayed Jobs not running * Create a module with a quiz as the last item * Make it so that the module isn't complete unless the student has scored at least 1 * Create a second module with an assignment as the first item * Make it so that module isn't unlocked until the first module is complete * Add a student and publish the course * Log in as student * Go to the quiz in the first module * Observe that clicking the next module item button takes you to the assignment but that it is locked. * Take the quiz and score at least 1, _do not_ go to the modules page after this is done. * Click the next module item button and make sure the assignment is unlocked closes #6254 Change-Id: I0719ecdc75af2d5c61bf78fbe2f07c4f21f2e24d Reviewed-on: https://gerrit.instructure.com/7362 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com>
2011-12-08 11:06:24 +08:00
enable_cache do
@is_attachment = false
course_with_student_logged_in(:active_all => true)
@quiz = @course.quizzes.create!(:title => "new quiz", :shuffle_answers => true)
fix content tag state synchronization test plan (non-draft-state): - as a teacher * create each of the following: - assignment - discussion - page (hidden from students) - page (not hidden from students) - quiz (leaving it unpublished) * add each of the above items to a module * refresh the modules page - each of the above items should be listed - as a student * navigate to the modules page - the hidden page and quiz should not be listed - all other items should be listed * click on the first item in the module * click through each of the 'Next' buttons - only items listed in the module should be presented test plan (draft-state): - as a teacher * create each of the following: - assignment - discussion - page - quiz * add each of the above items to a module * refresh the modules page - each of the above items should be listed - as a student * navigate to the modules page - only published items should be visible * click on the first item in the module * click through each of the 'Next' buttons - only published items should be presented * publishing items (as a teacher) should make them available to the student in the module progression as well as the modules page closes CNVS-10831 Change-Id: Ia84e56f42438ff531a4e15784eefaec2ead8ecdd Reviewed-on: https://gerrit.instructure.com/30312 Reviewed-by: Jeremy Stanley <jeremy@instructure.com> Product-Review: Jeremy Stanley <jeremy@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> QA-Review: Jeremy Stanley <jeremy@instructure.com>
2014-02-11 06:48:17 +08:00
@quiz.publish!
# separate timestamps so touch_context will actually invalidate caches
Timecop.freeze(4.seconds.ago) do
@mod1 = @course.context_modules.create!(:name => "some module")
@mod1.require_sequential_progress = true
@mod1.save!
@tag1 = @mod1.add_item(:type => 'quiz', :id => @quiz.id)
@mod1.completion_requirements = {@tag1.id => {:type => 'min_score', :min_score => 1}}
@mod1.save!
end
Timecop.freeze(2.second.ago) do
@mod2 = @course.context_modules.create!(:name => "dependant module")
@mod2.prerequisites = "module_#{@mod1.id}"
@mod2.save!
end
fix content tag state synchronization test plan (non-draft-state): - as a teacher * create each of the following: - assignment - discussion - page (hidden from students) - page (not hidden from students) - quiz (leaving it unpublished) * add each of the above items to a module * refresh the modules page - each of the above items should be listed - as a student * navigate to the modules page - the hidden page and quiz should not be listed - all other items should be listed * click on the first item in the module * click through each of the 'Next' buttons - only items listed in the module should be presented test plan (draft-state): - as a teacher * create each of the following: - assignment - discussion - page - quiz * add each of the above items to a module * refresh the modules page - each of the above items should be listed - as a student * navigate to the modules page - only published items should be visible * click on the first item in the module * click through each of the 'Next' buttons - only published items should be presented * publishing items (as a teacher) should make them available to the student in the module progression as well as the modules page closes CNVS-10831 Change-Id: Ia84e56f42438ff531a4e15784eefaec2ead8ecdd Reviewed-on: https://gerrit.instructure.com/30312 Reviewed-by: Jeremy Stanley <jeremy@instructure.com> Product-Review: Jeremy Stanley <jeremy@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> QA-Review: Jeremy Stanley <jeremy@instructure.com>
2014-02-11 06:48:17 +08:00
# all modules, tags, etc need to be published
expect(@mod1).to be_published
expect(@mod2).to be_published
expect(@quiz).to be_published
expect(@tag1).to be_published
fix content tag state synchronization test plan (non-draft-state): - as a teacher * create each of the following: - assignment - discussion - page (hidden from students) - page (not hidden from students) - quiz (leaving it unpublished) * add each of the above items to a module * refresh the modules page - each of the above items should be listed - as a student * navigate to the modules page - the hidden page and quiz should not be listed - all other items should be listed * click on the first item in the module * click through each of the 'Next' buttons - only items listed in the module should be presented test plan (draft-state): - as a teacher * create each of the following: - assignment - discussion - page - quiz * add each of the above items to a module * refresh the modules page - each of the above items should be listed - as a student * navigate to the modules page - only published items should be visible * click on the first item in the module * click through each of the 'Next' buttons - only published items should be presented * publishing items (as a teacher) should make them available to the student in the module progression as well as the modules page closes CNVS-10831 Change-Id: Ia84e56f42438ff531a4e15784eefaec2ead8ecdd Reviewed-on: https://gerrit.instructure.com/30312 Reviewed-by: Jeremy Stanley <jeremy@instructure.com> Product-Review: Jeremy Stanley <jeremy@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> QA-Review: Jeremy Stanley <jeremy@instructure.com>
2014-02-11 06:48:17 +08:00
allow module progression when background job hasn't finished If a user just completed a module and hasn't gone to the modules page and clicks the next module item button that goes into the next module (not another item within the same module), the next module will still be locked. (If they click before the delayed job is run) This commit makes it so that clicking on a module item link that goes to a locked item will cause the module progressions to be recalculated in-request before the user is redirected to the destination resource. This should happen fairly infrequently since the user will only be able to access a locked module item link under the circumstances mentioned in the first paragraph. (locked items are disabled while on the modules page) Test Plan: * Run canvas in production with caching on and Delayed Jobs not running * Create a module with a quiz as the last item * Make it so that the module isn't complete unless the student has scored at least 1 * Create a second module with an assignment as the first item * Make it so that module isn't unlocked until the first module is complete * Add a student and publish the course * Log in as student * Go to the quiz in the first module * Observe that clicking the next module item button takes you to the assignment but that it is locked. * Take the quiz and score at least 1, _do not_ go to the modules page after this is done. * Click the next module item button and make sure the assignment is unlocked closes #6254 Change-Id: I0719ecdc75af2d5c61bf78fbe2f07c4f21f2e24d Reviewed-on: https://gerrit.instructure.com/7362 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com>
2011-12-08 11:06:24 +08:00
yield '<div id="test_content">yay!</div>'
expect(@tag2).to be_published
fix content tag state synchronization test plan (non-draft-state): - as a teacher * create each of the following: - assignment - discussion - page (hidden from students) - page (not hidden from students) - quiz (leaving it unpublished) * add each of the above items to a module * refresh the modules page - each of the above items should be listed - as a student * navigate to the modules page - the hidden page and quiz should not be listed - all other items should be listed * click on the first item in the module * click through each of the 'Next' buttons - only items listed in the module should be presented test plan (draft-state): - as a teacher * create each of the following: - assignment - discussion - page - quiz * add each of the above items to a module * refresh the modules page - each of the above items should be listed - as a student * navigate to the modules page - only published items should be visible * click on the first item in the module * click through each of the 'Next' buttons - only published items should be presented * publishing items (as a teacher) should make them available to the student in the module progression as well as the modules page closes CNVS-10831 Change-Id: Ia84e56f42438ff531a4e15784eefaec2ead8ecdd Reviewed-on: https://gerrit.instructure.com/30312 Reviewed-by: Jeremy Stanley <jeremy@instructure.com> Product-Review: Jeremy Stanley <jeremy@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> QA-Review: Jeremy Stanley <jeremy@instructure.com>
2014-02-11 06:48:17 +08:00
# verify the second item is locked (doesn't display)
allow module progression when background job hasn't finished If a user just completed a module and hasn't gone to the modules page and clicks the next module item button that goes into the next module (not another item within the same module), the next module will still be locked. (If they click before the delayed job is run) This commit makes it so that clicking on a module item link that goes to a locked item will cause the module progressions to be recalculated in-request before the user is redirected to the destination resource. This should happen fairly infrequently since the user will only be able to access a locked module item link under the circumstances mentioned in the first paragraph. (locked items are disabled while on the modules page) Test Plan: * Run canvas in production with caching on and Delayed Jobs not running * Create a module with a quiz as the last item * Make it so that the module isn't complete unless the student has scored at least 1 * Create a second module with an assignment as the first item * Make it so that module isn't unlocked until the first module is complete * Add a student and publish the course * Log in as student * Go to the quiz in the first module * Observe that clicking the next module item button takes you to the assignment but that it is locked. * Take the quiz and score at least 1, _do not_ go to the modules page after this is done. * Click the next module item button and make sure the assignment is unlocked closes #6254 Change-Id: I0719ecdc75af2d5c61bf78fbe2f07c4f21f2e24d Reviewed-on: https://gerrit.instructure.com/7362 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com>
2011-12-08 11:06:24 +08:00
get @test_url
if @test_url.match?('files')
expect(response.status).to eq(403)
else
expect(response).to be_successful
end
html = Nokogiri::HTML5(response.body)
expect(html.css('#test_content').length).to eq(@test_content_length || 0)
fix content tag state synchronization test plan (non-draft-state): - as a teacher * create each of the following: - assignment - discussion - page (hidden from students) - page (not hidden from students) - quiz (leaving it unpublished) * add each of the above items to a module * refresh the modules page - each of the above items should be listed - as a student * navigate to the modules page - the hidden page and quiz should not be listed - all other items should be listed * click on the first item in the module * click through each of the 'Next' buttons - only items listed in the module should be presented test plan (draft-state): - as a teacher * create each of the following: - assignment - discussion - page - quiz * add each of the above items to a module * refresh the modules page - each of the above items should be listed - as a student * navigate to the modules page - only published items should be visible * click on the first item in the module * click through each of the 'Next' buttons - only published items should be presented * publishing items (as a teacher) should make them available to the student in the module progression as well as the modules page closes CNVS-10831 Change-Id: Ia84e56f42438ff531a4e15784eefaec2ead8ecdd Reviewed-on: https://gerrit.instructure.com/30312 Reviewed-by: Jeremy Stanley <jeremy@instructure.com> Product-Review: Jeremy Stanley <jeremy@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> QA-Review: Jeremy Stanley <jeremy@instructure.com>
2014-02-11 06:48:17 +08:00
# complete first module's requirements
p1 = @mod1.evaluate_for(@student)
expect(p1.workflow_state).to eq 'unlocked'
fix content tag state synchronization test plan (non-draft-state): - as a teacher * create each of the following: - assignment - discussion - page (hidden from students) - page (not hidden from students) - quiz (leaving it unpublished) * add each of the above items to a module * refresh the modules page - each of the above items should be listed - as a student * navigate to the modules page - the hidden page and quiz should not be listed - all other items should be listed * click on the first item in the module * click through each of the 'Next' buttons - only items listed in the module should be presented test plan (draft-state): - as a teacher * create each of the following: - assignment - discussion - page - quiz * add each of the above items to a module * refresh the modules page - each of the above items should be listed - as a student * navigate to the modules page - only published items should be visible * click on the first item in the module * click through each of the 'Next' buttons - only published items should be presented * publishing items (as a teacher) should make them available to the student in the module progression as well as the modules page closes CNVS-10831 Change-Id: Ia84e56f42438ff531a4e15784eefaec2ead8ecdd Reviewed-on: https://gerrit.instructure.com/30312 Reviewed-by: Jeremy Stanley <jeremy@instructure.com> Product-Review: Jeremy Stanley <jeremy@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> QA-Review: Jeremy Stanley <jeremy@instructure.com>
2014-02-11 06:48:17 +08:00
@quiz_submission = @quiz.generate_submission(@student)
Quizzes::SubmissionGrader.new(@quiz_submission).grade_submission
@quiz_submission.workflow_state = 'complete'
@quiz_submission.manually_scored = true
allow module progression when background job hasn't finished If a user just completed a module and hasn't gone to the modules page and clicks the next module item button that goes into the next module (not another item within the same module), the next module will still be locked. (If they click before the delayed job is run) This commit makes it so that clicking on a module item link that goes to a locked item will cause the module progressions to be recalculated in-request before the user is redirected to the destination resource. This should happen fairly infrequently since the user will only be able to access a locked module item link under the circumstances mentioned in the first paragraph. (locked items are disabled while on the modules page) Test Plan: * Run canvas in production with caching on and Delayed Jobs not running * Create a module with a quiz as the last item * Make it so that the module isn't complete unless the student has scored at least 1 * Create a second module with an assignment as the first item * Make it so that module isn't unlocked until the first module is complete * Add a student and publish the course * Log in as student * Go to the quiz in the first module * Observe that clicking the next module item button takes you to the assignment but that it is locked. * Take the quiz and score at least 1, _do not_ go to the modules page after this is done. * Click the next module item button and make sure the assignment is unlocked closes #6254 Change-Id: I0719ecdc75af2d5c61bf78fbe2f07c4f21f2e24d Reviewed-on: https://gerrit.instructure.com/7362 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com>
2011-12-08 11:06:24 +08:00
@quiz_submission.kept_score = 1
@quiz_submission.save!
fix content tag state synchronization test plan (non-draft-state): - as a teacher * create each of the following: - assignment - discussion - page (hidden from students) - page (not hidden from students) - quiz (leaving it unpublished) * add each of the above items to a module * refresh the modules page - each of the above items should be listed - as a student * navigate to the modules page - the hidden page and quiz should not be listed - all other items should be listed * click on the first item in the module * click through each of the 'Next' buttons - only items listed in the module should be presented test plan (draft-state): - as a teacher * create each of the following: - assignment - discussion - page - quiz * add each of the above items to a module * refresh the modules page - each of the above items should be listed - as a student * navigate to the modules page - only published items should be visible * click on the first item in the module * click through each of the 'Next' buttons - only published items should be presented * publishing items (as a teacher) should make them available to the student in the module progression as well as the modules page closes CNVS-10831 Change-Id: Ia84e56f42438ff531a4e15784eefaec2ead8ecdd Reviewed-on: https://gerrit.instructure.com/30312 Reviewed-by: Jeremy Stanley <jeremy@instructure.com> Product-Review: Jeremy Stanley <jeremy@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> QA-Review: Jeremy Stanley <jeremy@instructure.com>
2014-02-11 06:48:17 +08:00
# navigate to the second item (forcing update to progression)
next_link = progress_by_item_link ?
"/courses/#{@course.id}/modules/items/#{@tag2.id}" :
"/courses/#{@course.id}/modules/#{@mod2.id}/items/first"
get next_link
expect(response).to be_redirect
expect(response.location.ends_with?("module_item_id=#{@tag2.id}")).to be_truthy
fix content tag state synchronization test plan (non-draft-state): - as a teacher * create each of the following: - assignment - discussion - page (hidden from students) - page (not hidden from students) - quiz (leaving it unpublished) * add each of the above items to a module * refresh the modules page - each of the above items should be listed - as a student * navigate to the modules page - the hidden page and quiz should not be listed - all other items should be listed * click on the first item in the module * click through each of the 'Next' buttons - only items listed in the module should be presented test plan (draft-state): - as a teacher * create each of the following: - assignment - discussion - page - quiz * add each of the above items to a module * refresh the modules page - each of the above items should be listed - as a student * navigate to the modules page - only published items should be visible * click on the first item in the module * click through each of the 'Next' buttons - only published items should be presented * publishing items (as a teacher) should make them available to the student in the module progression as well as the modules page closes CNVS-10831 Change-Id: Ia84e56f42438ff531a4e15784eefaec2ead8ecdd Reviewed-on: https://gerrit.instructure.com/30312 Reviewed-by: Jeremy Stanley <jeremy@instructure.com> Product-Review: Jeremy Stanley <jeremy@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> QA-Review: Jeremy Stanley <jeremy@instructure.com>
2014-02-11 06:48:17 +08:00
# verify the second item is accessible
allow module progression when background job hasn't finished If a user just completed a module and hasn't gone to the modules page and clicks the next module item button that goes into the next module (not another item within the same module), the next module will still be locked. (If they click before the delayed job is run) This commit makes it so that clicking on a module item link that goes to a locked item will cause the module progressions to be recalculated in-request before the user is redirected to the destination resource. This should happen fairly infrequently since the user will only be able to access a locked module item link under the circumstances mentioned in the first paragraph. (locked items are disabled while on the modules page) Test Plan: * Run canvas in production with caching on and Delayed Jobs not running * Create a module with a quiz as the last item * Make it so that the module isn't complete unless the student has scored at least 1 * Create a second module with an assignment as the first item * Make it so that module isn't unlocked until the first module is complete * Add a student and publish the course * Log in as student * Go to the quiz in the first module * Observe that clicking the next module item button takes you to the assignment but that it is locked. * Take the quiz and score at least 1, _do not_ go to the modules page after this is done. * Click the next module item button and make sure the assignment is unlocked closes #6254 Change-Id: I0719ecdc75af2d5c61bf78fbe2f07c4f21f2e24d Reviewed-on: https://gerrit.instructure.com/7362 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com>
2011-12-08 11:06:24 +08:00
get @test_url
expect(response).to be_successful
html = Nokogiri::HTML5(response.body)
allow module progression when background job hasn't finished If a user just completed a module and hasn't gone to the modules page and clicks the next module item button that goes into the next module (not another item within the same module), the next module will still be locked. (If they click before the delayed job is run) This commit makes it so that clicking on a module item link that goes to a locked item will cause the module progressions to be recalculated in-request before the user is redirected to the destination resource. This should happen fairly infrequently since the user will only be able to access a locked module item link under the circumstances mentioned in the first paragraph. (locked items are disabled while on the modules page) Test Plan: * Run canvas in production with caching on and Delayed Jobs not running * Create a module with a quiz as the last item * Make it so that the module isn't complete unless the student has scored at least 1 * Create a second module with an assignment as the first item * Make it so that module isn't unlocked until the first module is complete * Add a student and publish the course * Log in as student * Go to the quiz in the first module * Observe that clicking the next module item button takes you to the assignment but that it is locked. * Take the quiz and score at least 1, _do not_ go to the modules page after this is done. * Click the next module item button and make sure the assignment is unlocked closes #6254 Change-Id: I0719ecdc75af2d5c61bf78fbe2f07c4f21f2e24d Reviewed-on: https://gerrit.instructure.com/7362 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com>
2011-12-08 11:06:24 +08:00
if @is_attachment
expect(html.at_css('#file_content')['src']).to match %r{#{@test_url.split("?").first}}
elsif @is_wiki_page
expect(html.css('#wiki_page_show').length).to eq 1
allow module progression when background job hasn't finished If a user just completed a module and hasn't gone to the modules page and clicks the next module item button that goes into the next module (not another item within the same module), the next module will still be locked. (If they click before the delayed job is run) This commit makes it so that clicking on a module item link that goes to a locked item will cause the module progressions to be recalculated in-request before the user is redirected to the destination resource. This should happen fairly infrequently since the user will only be able to access a locked module item link under the circumstances mentioned in the first paragraph. (locked items are disabled while on the modules page) Test Plan: * Run canvas in production with caching on and Delayed Jobs not running * Create a module with a quiz as the last item * Make it so that the module isn't complete unless the student has scored at least 1 * Create a second module with an assignment as the first item * Make it so that module isn't unlocked until the first module is complete * Add a student and publish the course * Log in as student * Go to the quiz in the first module * Observe that clicking the next module item button takes you to the assignment but that it is locked. * Take the quiz and score at least 1, _do not_ go to the modules page after this is done. * Click the next module item button and make sure the assignment is unlocked closes #6254 Change-Id: I0719ecdc75af2d5c61bf78fbe2f07c4f21f2e24d Reviewed-on: https://gerrit.instructure.com/7362 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com>
2011-12-08 11:06:24 +08:00
else
expect(html.css('#test_content').length).to eq 1
allow module progression when background job hasn't finished If a user just completed a module and hasn't gone to the modules page and clicks the next module item button that goes into the next module (not another item within the same module), the next module will still be locked. (If they click before the delayed job is run) This commit makes it so that clicking on a module item link that goes to a locked item will cause the module progressions to be recalculated in-request before the user is redirected to the destination resource. This should happen fairly infrequently since the user will only be able to access a locked module item link under the circumstances mentioned in the first paragraph. (locked items are disabled while on the modules page) Test Plan: * Run canvas in production with caching on and Delayed Jobs not running * Create a module with a quiz as the last item * Make it so that the module isn't complete unless the student has scored at least 1 * Create a second module with an assignment as the first item * Make it so that module isn't unlocked until the first module is complete * Add a student and publish the course * Log in as student * Go to the quiz in the first module * Observe that clicking the next module item button takes you to the assignment but that it is locked. * Take the quiz and score at least 1, _do not_ go to the modules page after this is done. * Click the next module item button and make sure the assignment is unlocked closes #6254 Change-Id: I0719ecdc75af2d5c61bf78fbe2f07c4f21f2e24d Reviewed-on: https://gerrit.instructure.com/7362 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com>
2011-12-08 11:06:24 +08:00
end
end
end
allow module progression when background job hasn't finished If a user just completed a module and hasn't gone to the modules page and clicks the next module item button that goes into the next module (not another item within the same module), the next module will still be locked. (If they click before the delayed job is run) This commit makes it so that clicking on a module item link that goes to a locked item will cause the module progressions to be recalculated in-request before the user is redirected to the destination resource. This should happen fairly infrequently since the user will only be able to access a locked module item link under the circumstances mentioned in the first paragraph. (locked items are disabled while on the modules page) Test Plan: * Run canvas in production with caching on and Delayed Jobs not running * Create a module with a quiz as the last item * Make it so that the module isn't complete unless the student has scored at least 1 * Create a second module with an assignment as the first item * Make it so that module isn't unlocked until the first module is complete * Add a student and publish the course * Log in as student * Go to the quiz in the first module * Observe that clicking the next module item button takes you to the assignment but that it is locked. * Take the quiz and score at least 1, _do not_ go to the modules page after this is done. * Click the next module item button and make sure the assignment is unlocked closes #6254 Change-Id: I0719ecdc75af2d5c61bf78fbe2f07c4f21f2e24d Reviewed-on: https://gerrit.instructure.com/7362 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com>
2011-12-08 11:06:24 +08:00
it "should progress to assignment" do
[true, false].each do |progress_type|
progression_testing(progress_type) do |content|
asmnt = @course.assignments.create!(:title => 'assignment', :description => content)
@test_url = "/courses/#{@course.id}/assignments/#{asmnt.id}"
@tag2 = @mod2.add_item(:type => 'assignment', :id => asmnt.id)
expect(@tag2).to be_published
end
allow module progression when background job hasn't finished If a user just completed a module and hasn't gone to the modules page and clicks the next module item button that goes into the next module (not another item within the same module), the next module will still be locked. (If they click before the delayed job is run) This commit makes it so that clicking on a module item link that goes to a locked item will cause the module progressions to be recalculated in-request before the user is redirected to the destination resource. This should happen fairly infrequently since the user will only be able to access a locked module item link under the circumstances mentioned in the first paragraph. (locked items are disabled while on the modules page) Test Plan: * Run canvas in production with caching on and Delayed Jobs not running * Create a module with a quiz as the last item * Make it so that the module isn't complete unless the student has scored at least 1 * Create a second module with an assignment as the first item * Make it so that module isn't unlocked until the first module is complete * Add a student and publish the course * Log in as student * Go to the quiz in the first module * Observe that clicking the next module item button takes you to the assignment but that it is locked. * Take the quiz and score at least 1, _do not_ go to the modules page after this is done. * Click the next module item button and make sure the assignment is unlocked closes #6254 Change-Id: I0719ecdc75af2d5c61bf78fbe2f07c4f21f2e24d Reviewed-on: https://gerrit.instructure.com/7362 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com>
2011-12-08 11:06:24 +08:00
end
end
allow module progression when background job hasn't finished If a user just completed a module and hasn't gone to the modules page and clicks the next module item button that goes into the next module (not another item within the same module), the next module will still be locked. (If they click before the delayed job is run) This commit makes it so that clicking on a module item link that goes to a locked item will cause the module progressions to be recalculated in-request before the user is redirected to the destination resource. This should happen fairly infrequently since the user will only be able to access a locked module item link under the circumstances mentioned in the first paragraph. (locked items are disabled while on the modules page) Test Plan: * Run canvas in production with caching on and Delayed Jobs not running * Create a module with a quiz as the last item * Make it so that the module isn't complete unless the student has scored at least 1 * Create a second module with an assignment as the first item * Make it so that module isn't unlocked until the first module is complete * Add a student and publish the course * Log in as student * Go to the quiz in the first module * Observe that clicking the next module item button takes you to the assignment but that it is locked. * Take the quiz and score at least 1, _do not_ go to the modules page after this is done. * Click the next module item button and make sure the assignment is unlocked closes #6254 Change-Id: I0719ecdc75af2d5c61bf78fbe2f07c4f21f2e24d Reviewed-on: https://gerrit.instructure.com/7362 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com>
2011-12-08 11:06:24 +08:00
it "should progress to discussion topic" do
[true, false].each do |progress_type|
progression_testing(progress_type) do |content|
discussion = @course.discussion_topics.create!(:title => "topic", :message => content)
@test_url = "/courses/#{@course.id}/discussion_topics/#{discussion.id}"
@tag2 = @mod2.add_item(:type => 'discussion_topic', :id => discussion.id)
expect(@tag2).to be_published
end
allow module progression when background job hasn't finished If a user just completed a module and hasn't gone to the modules page and clicks the next module item button that goes into the next module (not another item within the same module), the next module will still be locked. (If they click before the delayed job is run) This commit makes it so that clicking on a module item link that goes to a locked item will cause the module progressions to be recalculated in-request before the user is redirected to the destination resource. This should happen fairly infrequently since the user will only be able to access a locked module item link under the circumstances mentioned in the first paragraph. (locked items are disabled while on the modules page) Test Plan: * Run canvas in production with caching on and Delayed Jobs not running * Create a module with a quiz as the last item * Make it so that the module isn't complete unless the student has scored at least 1 * Create a second module with an assignment as the first item * Make it so that module isn't unlocked until the first module is complete * Add a student and publish the course * Log in as student * Go to the quiz in the first module * Observe that clicking the next module item button takes you to the assignment but that it is locked. * Take the quiz and score at least 1, _do not_ go to the modules page after this is done. * Click the next module item button and make sure the assignment is unlocked closes #6254 Change-Id: I0719ecdc75af2d5c61bf78fbe2f07c4f21f2e24d Reviewed-on: https://gerrit.instructure.com/7362 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com>
2011-12-08 11:06:24 +08:00
end
end
allow module progression when background job hasn't finished If a user just completed a module and hasn't gone to the modules page and clicks the next module item button that goes into the next module (not another item within the same module), the next module will still be locked. (If they click before the delayed job is run) This commit makes it so that clicking on a module item link that goes to a locked item will cause the module progressions to be recalculated in-request before the user is redirected to the destination resource. This should happen fairly infrequently since the user will only be able to access a locked module item link under the circumstances mentioned in the first paragraph. (locked items are disabled while on the modules page) Test Plan: * Run canvas in production with caching on and Delayed Jobs not running * Create a module with a quiz as the last item * Make it so that the module isn't complete unless the student has scored at least 1 * Create a second module with an assignment as the first item * Make it so that module isn't unlocked until the first module is complete * Add a student and publish the course * Log in as student * Go to the quiz in the first module * Observe that clicking the next module item button takes you to the assignment but that it is locked. * Take the quiz and score at least 1, _do not_ go to the modules page after this is done. * Click the next module item button and make sure the assignment is unlocked closes #6254 Change-Id: I0719ecdc75af2d5c61bf78fbe2f07c4f21f2e24d Reviewed-on: https://gerrit.instructure.com/7362 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com>
2011-12-08 11:06:24 +08:00
it "should progress to a quiz" do
[true, false].each do |progress_type|
progression_testing(progress_type) do |content|
quiz = @course.quizzes.create!(:title => "quiz", :description => content)
fix content tag state synchronization test plan (non-draft-state): - as a teacher * create each of the following: - assignment - discussion - page (hidden from students) - page (not hidden from students) - quiz (leaving it unpublished) * add each of the above items to a module * refresh the modules page - each of the above items should be listed - as a student * navigate to the modules page - the hidden page and quiz should not be listed - all other items should be listed * click on the first item in the module * click through each of the 'Next' buttons - only items listed in the module should be presented test plan (draft-state): - as a teacher * create each of the following: - assignment - discussion - page - quiz * add each of the above items to a module * refresh the modules page - each of the above items should be listed - as a student * navigate to the modules page - only published items should be visible * click on the first item in the module * click through each of the 'Next' buttons - only published items should be presented * publishing items (as a teacher) should make them available to the student in the module progression as well as the modules page closes CNVS-10831 Change-Id: Ia84e56f42438ff531a4e15784eefaec2ead8ecdd Reviewed-on: https://gerrit.instructure.com/30312 Reviewed-by: Jeremy Stanley <jeremy@instructure.com> Product-Review: Jeremy Stanley <jeremy@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> QA-Review: Jeremy Stanley <jeremy@instructure.com>
2014-02-11 06:48:17 +08:00
quiz.publish!
@test_url = "/courses/#{@course.id}/quizzes/#{quiz.id}"
@tag2 = @mod2.add_item(:type => 'quiz', :id => quiz.id)
expect(@tag2).to be_published
end
allow module progression when background job hasn't finished If a user just completed a module and hasn't gone to the modules page and clicks the next module item button that goes into the next module (not another item within the same module), the next module will still be locked. (If they click before the delayed job is run) This commit makes it so that clicking on a module item link that goes to a locked item will cause the module progressions to be recalculated in-request before the user is redirected to the destination resource. This should happen fairly infrequently since the user will only be able to access a locked module item link under the circumstances mentioned in the first paragraph. (locked items are disabled while on the modules page) Test Plan: * Run canvas in production with caching on and Delayed Jobs not running * Create a module with a quiz as the last item * Make it so that the module isn't complete unless the student has scored at least 1 * Create a second module with an assignment as the first item * Make it so that module isn't unlocked until the first module is complete * Add a student and publish the course * Log in as student * Go to the quiz in the first module * Observe that clicking the next module item button takes you to the assignment but that it is locked. * Take the quiz and score at least 1, _do not_ go to the modules page after this is done. * Click the next module item button and make sure the assignment is unlocked closes #6254 Change-Id: I0719ecdc75af2d5c61bf78fbe2f07c4f21f2e24d Reviewed-on: https://gerrit.instructure.com/7362 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com>
2011-12-08 11:06:24 +08:00
end
end
allow module progression when background job hasn't finished If a user just completed a module and hasn't gone to the modules page and clicks the next module item button that goes into the next module (not another item within the same module), the next module will still be locked. (If they click before the delayed job is run) This commit makes it so that clicking on a module item link that goes to a locked item will cause the module progressions to be recalculated in-request before the user is redirected to the destination resource. This should happen fairly infrequently since the user will only be able to access a locked module item link under the circumstances mentioned in the first paragraph. (locked items are disabled while on the modules page) Test Plan: * Run canvas in production with caching on and Delayed Jobs not running * Create a module with a quiz as the last item * Make it so that the module isn't complete unless the student has scored at least 1 * Create a second module with an assignment as the first item * Make it so that module isn't unlocked until the first module is complete * Add a student and publish the course * Log in as student * Go to the quiz in the first module * Observe that clicking the next module item button takes you to the assignment but that it is locked. * Take the quiz and score at least 1, _do not_ go to the modules page after this is done. * Click the next module item button and make sure the assignment is unlocked closes #6254 Change-Id: I0719ecdc75af2d5c61bf78fbe2f07c4f21f2e24d Reviewed-on: https://gerrit.instructure.com/7362 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com>
2011-12-08 11:06:24 +08:00
it "should progress to a wiki page" do
[true, false].each do |progress_type|
progression_testing(progress_type) do |content|
page = @course.wiki_pages.create!(:title => "wiki", :body => content)
@test_url = "/courses/#{@course.id}/pages/#{page.url}"
@tag2 = @mod2.add_item(:type => 'wiki_page', :id => page.id)
expect(@tag2).to be_published
@is_wiki_page = true
end
allow module progression when background job hasn't finished If a user just completed a module and hasn't gone to the modules page and clicks the next module item button that goes into the next module (not another item within the same module), the next module will still be locked. (If they click before the delayed job is run) This commit makes it so that clicking on a module item link that goes to a locked item will cause the module progressions to be recalculated in-request before the user is redirected to the destination resource. This should happen fairly infrequently since the user will only be able to access a locked module item link under the circumstances mentioned in the first paragraph. (locked items are disabled while on the modules page) Test Plan: * Run canvas in production with caching on and Delayed Jobs not running * Create a module with a quiz as the last item * Make it so that the module isn't complete unless the student has scored at least 1 * Create a second module with an assignment as the first item * Make it so that module isn't unlocked until the first module is complete * Add a student and publish the course * Log in as student * Go to the quiz in the first module * Observe that clicking the next module item button takes you to the assignment but that it is locked. * Take the quiz and score at least 1, _do not_ go to the modules page after this is done. * Click the next module item button and make sure the assignment is unlocked closes #6254 Change-Id: I0719ecdc75af2d5c61bf78fbe2f07c4f21f2e24d Reviewed-on: https://gerrit.instructure.com/7362 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com>
2011-12-08 11:06:24 +08:00
end
end
allow module progression when background job hasn't finished If a user just completed a module and hasn't gone to the modules page and clicks the next module item button that goes into the next module (not another item within the same module), the next module will still be locked. (If they click before the delayed job is run) This commit makes it so that clicking on a module item link that goes to a locked item will cause the module progressions to be recalculated in-request before the user is redirected to the destination resource. This should happen fairly infrequently since the user will only be able to access a locked module item link under the circumstances mentioned in the first paragraph. (locked items are disabled while on the modules page) Test Plan: * Run canvas in production with caching on and Delayed Jobs not running * Create a module with a quiz as the last item * Make it so that the module isn't complete unless the student has scored at least 1 * Create a second module with an assignment as the first item * Make it so that module isn't unlocked until the first module is complete * Add a student and publish the course * Log in as student * Go to the quiz in the first module * Observe that clicking the next module item button takes you to the assignment but that it is locked. * Take the quiz and score at least 1, _do not_ go to the modules page after this is done. * Click the next module item button and make sure the assignment is unlocked closes #6254 Change-Id: I0719ecdc75af2d5c61bf78fbe2f07c4f21f2e24d Reviewed-on: https://gerrit.instructure.com/7362 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com>
2011-12-08 11:06:24 +08:00
it "should progress to an attachment" do
[true, false].each do |progress_type|
progression_testing(progress_type) do |content|
@is_attachment = true
att = Attachment.create!(:filename => 'test.html', :display_name => "test.html", :uploaded_data => StringIO.new(content), :folder => Folder.unfiled_folder(@course), :context => @course)
@test_url = "/courses/#{@course.id}/files/#{att.id}?fd_cookie_set=1"
@tag2 = @mod2.add_item(:type => 'attachment', :id => att.id)
expect(@tag2).to be_published
end
allow module progression when background job hasn't finished If a user just completed a module and hasn't gone to the modules page and clicks the next module item button that goes into the next module (not another item within the same module), the next module will still be locked. (If they click before the delayed job is run) This commit makes it so that clicking on a module item link that goes to a locked item will cause the module progressions to be recalculated in-request before the user is redirected to the destination resource. This should happen fairly infrequently since the user will only be able to access a locked module item link under the circumstances mentioned in the first paragraph. (locked items are disabled while on the modules page) Test Plan: * Run canvas in production with caching on and Delayed Jobs not running * Create a module with a quiz as the last item * Make it so that the module isn't complete unless the student has scored at least 1 * Create a second module with an assignment as the first item * Make it so that module isn't unlocked until the first module is complete * Add a student and publish the course * Log in as student * Go to the quiz in the first module * Observe that clicking the next module item button takes you to the assignment but that it is locked. * Take the quiz and score at least 1, _do not_ go to the modules page after this is done. * Click the next module item button and make sure the assignment is unlocked closes #6254 Change-Id: I0719ecdc75af2d5c61bf78fbe2f07c4f21f2e24d Reviewed-on: https://gerrit.instructure.com/7362 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com>
2011-12-08 11:06:24 +08:00
end
end
end
describe "caching" do
it "should cache the view separately for each time zone" do
enable_cache do
course_factory active_all: true
mod = @course.context_modules.create!
mod.unlock_at = Time.utc(2014, 12, 25, 12, 0)
mod.save!
teacher1 = teacher_in_course(active_all: true).user
teacher1.time_zone = 'America/Los_Angeles'
teacher1.save!
teacher2 = teacher_in_course(active_all: true).user
teacher2.time_zone = 'America/New_York'
teacher2.save!
user_session teacher1
get "/courses/#{@course.id}/modules"
expect(response).to be_successful
body1 = Nokogiri::HTML5(response.body)
user_session teacher2
get "/courses/#{@course.id}/modules"
expect(response).to be_successful
body2 = Nokogiri::HTML5(response.body)
expect(body1.at_css("#context_module_content_#{mod.id} .unlock_details").text).to match /4am/
expect(body2.at_css("#context_module_content_#{mod.id} .unlock_details").text).to match /7am/
end
end
end
end