warn when converting assignment to group assignment

closes CNVS-9187

Test plan:
  * make two assignments (not group assignments)
  * on assignment number one, submit some homework
  * edit the assignment and try to convert it to a group assignment,
    you should see a warning
  * try to convert assignment 2 to a group assignment.  there should be
    no warning

Change-Id: I196cbad54fbcfe6df4bcbc3b71d3175e92a104fb
Reviewed-on: https://gerrit.instructure.com/26955
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Amber Taniuchi <amber@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Cameron Matheson <cameron@instructure.com>
This commit is contained in:
Cameron Matheson 2013-12-04 10:46:35 -07:00
parent ac39cfcf22
commit c7f26b342d
6 changed files with 57 additions and 8 deletions

View File

@ -32,6 +32,10 @@ define [
@optionProperty 'groupCategories'
@optionProperty 'nested'
initialize: ->
super
@startedOutAsGroupAssignment = @parentModel.get('group_category_id')?
showGroupCategoryCreateDialog: =>
if @$groupCategoryID.val() == 'new'
# TODO: Yikes, we need to pull the javascript out of manage_groups.js
@ -47,6 +51,13 @@ define [
toggleGroupCategoryOptions: =>
@$groupCategoryOptions.toggleAccessibly @$hasGroupCategory.prop('checked')
@$(".group_submission_warning").toggleAccessibly(
!@startedOutAsGroupAssignment and
@$hasGroupCategory.prop('checked') and
@parentModel.attributes.has_submitted_submissions
)
if @$hasGroupCategory.prop('checked') and @groupCategories.length == 0
@showGroupCategoryCreateDialog()

View File

@ -370,6 +370,7 @@ class AssignmentsController < ApplicationController
:ASSIGNMENT_INDEX_URL => polymorphic_url([@context, :assignments]),
}
hash[:ASSIGNMENT] = assignment_json(@assignment, @current_user, session, override_dates: false)
hash[:ASSIGNMENT][:has_submitted_submissions] = @assignment.has_submitted_submissions?
hash[:URL_ROOT] = polymorphic_url([:api_v1, @context, :assignments])
hash[:CANCEL_TO] = @assignment.new_record? ? polymorphic_url([@context, :assignments]) : polymorphic_url([@context, @assignment])
hash[:CONTEXT_ID] = @context.id

View File

@ -283,6 +283,7 @@ class DiscussionTopicsController < ApplicationController
if @topic.assignment.present?
hash[:ATTRIBUTES][:assignment][:assignment_overrides] =
(assignment_overrides_json(@topic.assignment.overrides_visible_to(@current_user)))
hash[:ATTRIBUTES][:assignment][:has_student_submissions] = @topic.assignment.has_student_submissions?
end
categories = @context.respond_to?(:group_categories) ? @context.group_categories : []

View File

@ -9,6 +9,12 @@
</label>
</div>
<div class="group_submission_warning alert controls" style="display:none">
{{#t "students_already_submitted_warning"}}Prior individual submissions will
not be counted as group submissions and will show incorrectly in
speedgrader.{{/t}}
</div>
<div id="group_category_options" style="{{hiddenUnless groupCategoryId}}">
<div class="controls">

View File

@ -1,5 +1,6 @@
define [
'jquery'
'underscore'
'compiled/collections/SectionCollection'
'compiled/models/Assignment'
'compiled/models/DueDateList'
@ -13,19 +14,22 @@ define [
'compiled/views/assignments/PeerReviewsSelector'
'helpers/jquery.simulate'
'helpers/fakeENV'
], ($, SectionCollection, Assignment, DueDateList, Section,
], ($, _, SectionCollection, Assignment, DueDateList, Section,
AssignmentGroupSelector, DueDateListView, DueDateOverrideView, EditView,
GradingTypeSelector, GroupCategorySelector, PeerReviewsSelector) ->
fixtures = $('#fixtures')
editView = ->
defaultAssignmentOpts =
name: 'Test Assignment'
assignment_overrides: []
editView = (assignmentOpts = {}) ->
$('<form id="content"></form>').appendTo fixtures
assignment = new Assignment
name: 'Test Assignment'
assignment_overrides: []
assignmentOpts = _.extend {}, assignmentOpts, defaultAssignmentOpts
assignment = new Assignment assignmentOpts
sectionList = new SectionCollection [Section.defaultDueDateSection()]
dueDateList = new DueDateList assignment.get('assignment_overrides'), sectionList, assignment
@ -101,4 +105,28 @@ define [
equal view.getFormData()['groupCategoryId'], null
ENV.GROUP_CATEGORIES = null
ENV.ASSIGNMENT_GROUPS = null
ENV.ASSIGNMENT_GROUPS = null
test 'shows a warning when dangerously changing group status', ->
# bleh
window.addGroupCategory = ->
checkWarning = (view, showsWarning) ->
$("#assignment_toggle_advanced_options").click()
equal $(".group_submission_warning").is(":visible"), false
$("#assignment_has_group_category").click()
equal $(".group_submission_warning").is(":visible"), showsWarning
$("#assignment_has_group_category").click()
equal $(".group_submission_warning").is(":visible"), false
# should warn here
view = editView has_submitted_submissions: true
checkWarning view, true
# don't show the warning if you start out with a group
view = editView has_submitted_submissions: true, group_category_id: 1
checkWarning view, false
# don't show the warning if there are no submitted submissions
view = editView
checkWarning view, false

View File

@ -335,8 +335,10 @@ describe AssignmentsController do
course_with_teacher_logged_in(:active_all => true)
course_assignment
get 'edit', :course_id => @course.id, :id => @assignment.id
assigns[:js_env][:ASSIGNMENT].should ==
subject.send(:assignment_json,@assignment,assigns[:current_user],session)
expected_assignment_json = subject.send(:assignment_json, @assignment,
assigns[:current_user], session)
expected_assignment_json[:has_submitted_submissions] = @assignment.has_submitted_submissions?
assigns[:js_env][:ASSIGNMENT].should == expected_assignment_json
assigns[:js_env][:ASSIGNMENT_OVERRIDES].should ==
subject.send(:assignment_overrides_json,
@assignment.overrides_visible_to(assigns[:current_user]))