Skip to content

Commit 2e66787

Browse files
committed
assignments: no changing group status after students submit (frontend)
closes CNVS-11813 Test plan: * make an assignment * submit some homework * make sure you can't turn it into a group assignment * repeat the above steps for a group assignment (you shouldn't be able to make it an individual assignment, or change the group category) Change-Id: I9fe2cb1b01972492e3707307281cee7954f8c56c Reviewed-on: https://gerrit.instructure.com/32717 Reviewed-by: Simon Williams <simon@instructure.com> QA-Review: Caleb Guanzon <cguanzon@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> Product-Review: Cameron Matheson <cameron@instructure.com>
1 parent 241d31e commit 2e66787

3 files changed

Lines changed: 33 additions & 41 deletions

File tree

app/coffeescripts/views/assignments/GroupCategorySelector.coffee

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ define [
3838
# delete this after Ifa654f7d853fd167d5bfbaee6184657209d58272 hits prod
3939
gc.id = gc.id.toString() for gc in @groupCategories
4040

41-
@startedOutAsGroupAssignment = @parentModel.get('group_category_id')?
42-
4341
showGroupCategoryCreateDialog: =>
4442
if @$groupCategoryID.val() == 'new'
4543
# TODO: Yikes, we need to pull the javascript out of manage_groups.js
@@ -56,30 +54,30 @@ define [
5654
toggleGroupCategoryOptions: =>
5755
@$groupCategoryOptions.toggleAccessibly @$hasGroupCategory.prop('checked')
5856

59-
@$(".group_submission_warning").toggleAccessibly(
60-
!@startedOutAsGroupAssignment and
61-
@$hasGroupCategory.prop('checked') and
62-
@parentModel.attributes.has_submitted_submissions
63-
)
64-
6557
if @$hasGroupCategory.prop('checked') and @groupCategories.length == 0
6658
@showGroupCategoryCreateDialog()
6759

6860
toJSON: =>
6961
frozenAttributes = @parentModel.frozenAttributes()
62+
groupCategoryFrozen = _.include frozenAttributes, 'group_category_id'
63+
groupCategoryLocked = @parentModel.attributes.has_submitted_submissions
7064

7165
groupCategoryId: @parentModel.groupCategoryId()
7266
groupCategories: @groupCategories
7367
gradeGroupStudentsIndividually: @parentModel.gradeGroupStudentsIndividually()
74-
frozenAttributes: frozenAttributes
75-
groupCategoryIdFrozen: _.include(frozenAttributes, 'group_category_id')
68+
groupCategoryLocked: groupCategoryLocked
69+
70+
hasGroupCategoryDisabled: groupCategoryFrozen || groupCategoryLocked
71+
gradeIndividuallyDisabled: groupCategoryFrozen
72+
groupCategoryIdDisabled: groupCategoryFrozen || groupCategoryLocked
73+
7674
nested: @nested
7775
prefix: 'assignment' if @nested
7876

7977
filterFormData: (data) =>
8078
hasGroupCategory = data.has_group_category
8179
delete data.has_group_category
82-
unless hasGroupCategory is '1'
80+
if hasGroupCategory == '0'
8381
data.group_category_id = null
8482
data.grade_group_students_individually = false
8583
data

app/views/jst/assignments/GroupCategorySelector.handlebars

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,25 @@
44

55
<div class="form-column-right">
66
<div class="border border-trbl border-round">
7-
87
{{!-- Group Assignment selection --}}
98
<label class="checkbox flush">
109
{{checkbox "has_group_category"
1110
id="assignment_has_group_category"
1211
prefix=prefix
1312
checked=groupCategoryId
14-
disabled=groupCategoryIdFrozen}}
13+
disabled=hasGroupCategoryDisabled}}
1514
{{#t "is_group_assignment"}}This is a Group Assignment{{/t}}
1615
</label>
1716

1817
{{!-- Individual grading? --}}
1918
<div class="nested">
20-
<div class="group_submission_warning alert" style="display:none">
21-
{{#t "students_already_submitted_warning"}}Prior individual submissions will
22-
not be counted as group submissions and will show incorrectly in
23-
speedgrader.{{/t}}
24-
</div>
2519
<div id="group_category_options" style="{{hiddenUnless groupCategoryId}}">
2620
<label class="checkbox" >
2721
{{checkbox "grade_group_students_individually"
2822
id=null
2923
prefix=prefix
3024
checked=gradeGroupStudentsIndividually
31-
disabled=groupCategoryIdFrozen}}
25+
disabled=gradeIndividuallyDisabled}}
3226
{{#t "grade_group_students_individually"}}
3327
Assign Grades to Each Student Individually
3428
{{/t}}
@@ -40,7 +34,7 @@
4034
</label>
4135
<select id="assignment_group_category_id"
4236
name="{{#if nested}}assignment[group_category_id]{{else}}group_category_id{{/if}}"
43-
{{disabledIfIncludes frozenAttributes "group_category_id"}}>
37+
{{disabledIf groupCategoryIdDisabled}}>
4438
{{#each groupCategories}}
4539
<option value="{{id}}" {{selectedIf ../groupCategoryId this.id}}>
4640
{{name}}
@@ -52,5 +46,14 @@
5246
</select>
5347
</div>
5448
</div>
49+
50+
{{#if groupCategoryLocked}}
51+
<div class="group_category_locked_explanation alert"
52+
style="margin: 15px 20px 0">
53+
{{#t "group_category_locked_explanation"}}Students have already
54+
submitted homework on this assignment, so group settings cannot be
55+
changed.{{/t}}
56+
</div>
57+
{{/if}}
5558
</div>
5659
</div>

spec/coffeescripts/views/assignments/EditViewSpec.coffee

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -102,32 +102,23 @@ define [
102102
view = editView description: "<p>&lt;E&gt;</p>"
103103
equal view.$description.val().match(desc), desc
104104

105-
# fragile spec
106-
checkWarning = (view, showsWarning) ->
107-
view.$("#assignment_toggle_advanced_options").click()
108-
equal view.$(".group_submission_warning").is(":visible"), false, 'warning isn\'t initially shown'
109-
view.$("#assignment_has_group_category").click()
110-
# equal view.$(".group_submission_warning").is(":visible"), showsWarning, 'warning has expected visibility of visible:'+showsWarning
111-
view.$("#assignment_has_group_category").click()
112-
equal view.$(".group_submission_warning").is(":visible"), false, 'warning is hidden after clicking again'
113-
114-
module 'EditView: warning on group status change',
105+
module 'EditView: group category locked',
115106
setup: ->
116107
fakeENV.setup()
117108
window.addGroupCategory = sinon.stub()
118109
teardown: ->
119110
fakeENV.teardown()
120111
window.addGroupCategory = null
121112

122-
test 'warns when has submitted submissions', ->
113+
test 'lock down group category after students submit', ->
123114
view = editView has_submitted_submissions: true
124-
checkWarning view, true
125-
126-
test 'does not warn if starting with a group', ->
127-
view = editView has_submitted_submissions: true, group_category_id: 1
128-
checkWarning view, false
129-
130-
test 'does not warn if there are no submitted submissions', ->
131-
view = editView()
132-
checkWarning view, false
133-
115+
ok view.$(".group_category_locked_explanation").length
116+
ok view.$("#assignment_has_group_category").prop("disabled")
117+
ok view.$("#assignment_group_category_id").prop("disabled")
118+
ok !view.$("[type=checkbox][name=grade_group_students_individually]").prop("disabled")
119+
120+
view = editView has_submitted_submissions: false
121+
equal view.$(".group_category_locked_explanation").length, 0
122+
ok !view.$("#assignment_has_group_category").prop("disabled")
123+
ok !view.$("#assignment_group_category_id").prop("disabled")
124+
ok !view.$("[type=checkbox][name=grade_group_students_individually]").prop("disabled")

0 commit comments

Comments
 (0)