Don't consider test student submissions when determining course unpublishability
Fixes CNVS-14490 Test plan: - Create a new course, and an assignment within - Enter student view to generate the test student enrollment - Submit the assignment as the test student - As a teacher, give the student a score for the assignment - With the test student's submission graded, the course should still be unpublishable Change-Id: Ib11fb7a2baa834ddf0a7f39a8ac12542539ab1e4 Reviewed-on: https://gerrit.instructure.com/39009 Reviewed-by: Simon Williams <simon@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> QA-Review: Amber Taniuchi <amber@instructure.com> Product-Review: Simon Williams <simon@instructure.com>
This commit is contained in:
parent
5c09df93e5
commit
60bb447102
|
@ -1757,7 +1757,7 @@ class CoursesController < ApplicationController
|
|||
if params[:course][:event] && @course.grants_right?(@current_user, session, :change_course_state)
|
||||
event = params[:course].delete(:event)
|
||||
event = event.to_sym
|
||||
if event == :claim && @course.submissions.with_point_data.exists?
|
||||
if event == :claim && !@course.unpublishable?
|
||||
flash[:error] = t('errors.unpublish', 'Course cannot be unpublished if student submissions exist.')
|
||||
redirect_to(course_url(@course)) and return
|
||||
else
|
||||
|
|
|
@ -372,6 +372,11 @@ class Course < ActiveRecord::Base
|
|||
license_data[:readable_license]
|
||||
end
|
||||
|
||||
def unpublishable?
|
||||
ids = self.all_real_students.pluck :id
|
||||
!self.submissions.with_point_data.where(:user_id => ids).exists?
|
||||
end
|
||||
|
||||
def self.update_account_associations(courses_or_course_ids, opts = {})
|
||||
return [] if courses_or_course_ids.empty?
|
||||
opts.reverse_merge! :account_chain_cache => {}
|
||||
|
|
|
@ -47,14 +47,14 @@
|
|||
<i class="icon-unpublished"></i>
|
||||
</span>
|
||||
<% else %>
|
||||
<% if @context.submissions.with_point_data.exists? %>
|
||||
<% unpublish_tooltip = t('tooltips.cannot_unpublish_course', %{You cannot unpublish this course if there are graded student submissions}) %>
|
||||
<span data-tooltip title="<%= unpublish_tooltip %>" id='course-status' class='published-status published pull-right'>
|
||||
<% if @context.unpublishable? %>
|
||||
<span data-tooltip title="" id='course-status' class='published-status published pull-right'>
|
||||
<%= t('labels.course_status_published', %{Course is Published}) %>
|
||||
<i class="icon-publish"></i>
|
||||
</span>
|
||||
<% else %>
|
||||
<span data-tooltip title="" id='course-status' class='published-status published pull-right'>
|
||||
<% unpublish_tooltip = t('tooltips.cannot_unpublish_course', %{You cannot unpublish this course if there are graded student submissions}) %>
|
||||
<span data-tooltip title="<%= unpublish_tooltip %>" id='course-status' class='published-status published pull-right'>
|
||||
<%= t('labels.course_status_published', %{Course is Published}) %>
|
||||
<i class="icon-publish"></i>
|
||||
</span>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<div id="course_show_secondary">
|
||||
<% @can_manage_content = can_do(@context, @current_user, :manage_content) %>
|
||||
<% if @context.feature_enabled?(:draft_state) %>
|
||||
<% if @can_manage_content && can_do(@context, @current_user, :change_course_state) && !@context.submissions.with_point_data.exists? %>
|
||||
<% if @can_manage_content && can_do(@context, @current_user, :change_course_state) && @context.unpublishable? %>
|
||||
<div id="course_status" class="text-center">
|
||||
<h4>
|
||||
<%= t('headers.course_status', %{Course Status}) %>
|
||||
|
|
|
@ -1040,6 +1040,16 @@ describe CoursesController do
|
|||
@course.workflow_state.should == 'claimed'
|
||||
end
|
||||
|
||||
it "should allow the course to be unpublished if it contains only graded student view submissions" do
|
||||
assignment = @course.assignments.create!(:workflow_state => 'published')
|
||||
sv_student = @course.student_view_student
|
||||
sub = assignment.grade_student sv_student, { :grade => 1, :grader => @teacher }
|
||||
user_session @teacher
|
||||
put 'update', :id => @course.id, :course => { :event => 'claim' }
|
||||
@course.reload
|
||||
@course.workflow_state.should == 'claimed'
|
||||
end
|
||||
|
||||
it "should lock active course announcements" do
|
||||
user_session(@teacher)
|
||||
active_announcement = @course.announcements.create!(:title => 'active', :message => 'test')
|
||||
|
|
Loading…
Reference in New Issue