Skip to content

Commit

Permalink
curving gpa_scale grades works
Browse files Browse the repository at this point in the history
fixes: CNVS-12707

also srgb doesnt show curve grades button
if there are no possible points

test plan:
  - make an assignemnt that is gpa_scale
  - populate gb2 with grades
  - curve grades
    - all the grades shouldn't disappear
    - grades should make sense
  - non gpa_scale curving should work
  - curving on srgb should work as well

  - if an assignment has no points possible
    - neither gb shows the curve button/link

Change-Id: Ia02992e6d26959282fbd35982b17c441bdf68f2a
Reviewed-on: https://gerrit.instructure.com/34831
Reviewed-by: Simon Williams <[email protected]>
Product-Review: Simon Williams <[email protected]>
QA-Review: Simon Williams <[email protected]>
Tested-by: Simon Williams <[email protected]>
  • Loading branch information
Michael Nomitch authored and simonista committed May 15, 2014
1 parent a8dc60b commit 8b8f1b3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -547,13 +547,15 @@
>
{{#t 'set_default_grade'}}Set default grade{{/t}}
</button>
<button
id="curve_grades"
class="btn"
{{ action 'openDialog' 'curve_grades' target=view }}
>
{{#t 'curve_grades'}}Curve Grades{{/t}}
</button>
{{#if selectedAssignment.points_possible}}
<button
id="curve_grades"
class="btn"
{{ action 'openDialog' 'curve_grades' target=view }}
>
{{#t 'curve_grades'}}Curve Grades{{/t}}
</button>
{{/if}}
</div>
{{else}}
<p class="assignment_selection pad-box top-only">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,29 @@ define [
assignment_group_text = find(".assignment-group-grade").first().text()
equal(parseFloat(new_final_grade), "3")
notEqual(assignment_group_text.indexOf("3 / 100"), -1)

module 'screenreader_gradebook: curve grades display',
setup: ->
App = startApp()
visit('/').then =>
@controller = App.__container__.lookup('controller:screenreader_gradebook')
@selected = @controller.get('assignments').objectAt(0)
Ember.run =>
@controller.set('selectedAssignment', @selected)

teardown: ->
Ember.run App, 'destroy'

test 'curve grades button does display with points poisslbe', ->
curve_button_text = find('#curve_grades').text()
notEqual(curve_button_text.indexOf("Curve Grades"), -1)

test 'curve grades button does not display with 0 points poisslbe', ->
Ember.run =>
@controller.set('selectedAssignment.points_possible', 0)
equal(find('#curve_grades').text(), "")

test 'curve grades button does not display with null points poisslbe', ->
Ember.run =>
@controller.set('selectedAssignment.points_possible', null)
equal(find('#curve_grades').text(), "")
10 changes: 9 additions & 1 deletion app/coffeescripts/gradebook2/CurveGradesDialog.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,21 @@ define [
.formSubmit
disableWhileLoading: true
processData: (data) =>
if !@assignment.points_possible || @assignment.points_possible == "0"
errorBox = @$dialog.errorBox I18n.t("errors.no_points_possible", "Cannot curve without points possible")
setTimeout((-> errorBox.fadeOut(-> errorBox.remove())), 3500)
return false
cnt = 0
curves = @curve()
for idx of curves
pre = "submissions[submission_" + idx + "]"
data[pre + "[assignment_id]"] = data.assignment_id
data[pre + "[user_id]"] = idx
data[pre + "[grade]"] = curves[idx]
if @assignment.grading_type == "gpa_scale"
percent = (curves[idx]/@assignment.points_possible)*100
data[pre + "[grade]"] = "#{percent}%"
else
data[pre + "[grade]"] = curves[idx]
cnt++
if cnt == 0
errorBox = @$dialog.errorBox I18n.t("errors.none_to_update", "None to Update")
Expand Down

0 comments on commit 8b8f1b3

Please sign in to comment.