From 85e1a19b9eb078978f298f3b96edae385b4919af Mon Sep 17 00:00:00 2001 From: Liz Abinante Date: Mon, 7 Apr 2014 14:29:20 -0500 Subject: [PATCH] gb2 - grade in comments box fixes CNVS-4734 test plan: * in gradebook 2 * change a grade in the gradebook cell * click the submission comments dialog box for a submission * for a graded submission: verify that it is displayed in the grading box * for an ungraded submission: verify that the grading box is empty * change the grade (for all grading types) and hit 'Update Grade' * verify that the grade is updated in the cell * verify that the assignment group grades are recalculated * verify that all members of a group have their grades updated for group assignments * verify that the set default grades dialog works correctly for all grading types Change-Id: Id6d117c9f126136a358f975604e973fe1ad36bb1 Reviewed-on: https://gerrit.instructure.com/32960 Tested-by: Jenkins QA-Review: Anna Koalenz Reviewed-by: Mike Nomitch Product-Review: Liz Abinante --- .../SubmissionDetailsDialog.coffee | 14 ++++++++++++++ app/coffeescripts/gradebook2/Gradebook.coffee | 1 + .../gradebook2/SetDefaultGradeDialog.coffee | 1 + .../jst/SubmissionDetailsDialog.sass | 10 ++++------ .../jst/SubmissionDetailsDialog.handlebars | 5 +++++ app/views/jst/_grading_box.handlebars | 17 ++++++++--------- spec/selenium/gradebook2_grade_edit_spec.rb | 17 ++++++++++++++++- 7 files changed, 49 insertions(+), 16 deletions(-) diff --git a/app/coffeescripts/SubmissionDetailsDialog.coffee b/app/coffeescripts/SubmissionDetailsDialog.coffee index ec65143d0b3..5caf04ce7ba 100644 --- a/app/coffeescripts/SubmissionDetailsDialog.coffee +++ b/app/coffeescripts/SubmissionDetailsDialog.coffee @@ -11,6 +11,7 @@ define [ 'jqueryui/dialog' 'jquery.instructure_misc_plugins' 'vendor/jquery.scrollTo' + 'vendor/jquery.ba-tinypubsub' ], (I18n, $, submissionDetailsDialog, {extractDataFor}) -> class SubmissionDetailsDialog @@ -22,9 +23,12 @@ define [ @url = @options.change_grade_url.replace(":assignment", @assignment.id).replace(":submission", @student.id) @submission = $.extend {}, @student["assignment_#{@assignment.id}"], + inputName: 'submission[posted_grade]' assignment: @assignment speedGraderUrl: speedGraderUrl loading: true + showPointsPossible: (@assignment.points_possible || @assignment.points_possible == '0') && @assignment.grading_type != "gpa_scale" + @submission["assignment_grading_type_is_#{@assignment.grading_type}"] = true @dialog = $('
') @dialog.html(submissionDetailsDialog(@submission)) .dialog @@ -32,9 +36,18 @@ define [ width: 600 resizable: false open: @scrollCommentsToBottom + .delegate 'select', 'change', (event) => @dialog.find('.submission_detail').each (index) -> $(this).showIf(index == event.currentTarget.selectedIndex) + .delegate '.submission_details_grade_form', 'submit', (event) => + event.preventDefault() + $(event.currentTarget.form).disableWhileLoading $.ajaxJSON @url, 'PUT', $(event.currentTarget).getFormData(), (data) => + @update(data) + $.publish 'submissions_updated', [@submission.all_submissions] + setTimeout => + @dialog.dialog('close') + , 500 .delegate '.submission_details_add_comment_form', 'submit', (event) => event.preventDefault() $(event.currentTarget).disableWhileLoading $.ajaxJSON @url, 'PUT', $(event.currentTarget).getFormData(), (data) => @@ -48,6 +61,7 @@ define [ open: => @dialog.dialog('open') + $('.submission_details_dialog .assignment-name').focus() scrollCommentsToBottom: => @dialog.find('.submission_details_comments').scrollTop(999999) diff --git a/app/coffeescripts/gradebook2/Gradebook.coffee b/app/coffeescripts/gradebook2/Gradebook.coffee index d8296e28536..18c4c7b7de0 100644 --- a/app/coffeescripts/gradebook2/Gradebook.coffee +++ b/app/coffeescripts/gradebook2/Gradebook.coffee @@ -715,6 +715,7 @@ define [ .delegate '.gradebook-cell-comment', 'click.gradebook', (event) => event.preventDefault() data = $(event.currentTarget).data() + $(@grid.getActiveCellNode()).removeClass('editable') SubmissionDetailsDialog.open @assignments[data.assignmentId], @student(data.userId.toString()), @options .delegate '.minimized', 'mouseenter' : @hoverMinimizedCell, diff --git a/app/coffeescripts/gradebook2/SetDefaultGradeDialog.coffee b/app/coffeescripts/gradebook2/SetDefaultGradeDialog.coffee index 0b35f4e4401..4d009578443 100644 --- a/app/coffeescripts/gradebook2/SetDefaultGradeDialog.coffee +++ b/app/coffeescripts/gradebook2/SetDefaultGradeDialog.coffee @@ -25,6 +25,7 @@ define [ assignment: @assignment showPointsPossible: (@assignment.points_possible || @assignment.points_possible == '0') && @assignment.grading_type != "gpa_scale" url: "/courses/#{@context_id}/gradebook/update_submission" + inputName: 'default_grade' templateLocals["assignment_grading_type_is_#{@assignment.grading_type}"] = true @$dialog = $(setDefaultGradeDialogTemplate(templateLocals)) @$dialog.dialog( diff --git a/app/stylesheets/jst/SubmissionDetailsDialog.sass b/app/stylesheets/jst/SubmissionDetailsDialog.sass index 57079e517ae..f95bc2ffb74 100644 --- a/app/stylesheets/jst/SubmissionDetailsDialog.sass +++ b/app/stylesheets/jst/SubmissionDetailsDialog.sass @@ -1,16 +1,15 @@ .submission_details_dialog .more-details-link - float: right font-size: 1.2em line-height: 42px h1, .h1 - margin: 20px 0 0 + margin: 20px 0 0 padding: 0 12px font-size: 23px .submission-details padding: 10px h1, .h1 - margin: 0 -10px 15px + margin: 0 -10px 15px border-bottom: 1px solid #bbb h2, h2 select, .h2, .h2 select font-size: 15px @@ -32,7 +31,7 @@ padding: 0 12px position: relative background: #A3A3A3 url(/images/messages/messages-background.png) 0 0 repeat - + .comment background: #fff clear: both @@ -74,5 +73,4 @@ display: inline font-weight: normal .btn - float: right - + float: right \ No newline at end of file diff --git a/app/views/jst/SubmissionDetailsDialog.handlebars b/app/views/jst/SubmissionDetailsDialog.handlebars index 99818007831..c0191b76743 100644 --- a/app/views/jst/SubmissionDetailsDialog.handlebars +++ b/app/views/jst/SubmissionDetailsDialog.handlebars @@ -1,6 +1,11 @@

{{assignment.name}}

+
+ + {{> grading_box}} + +
{{#if speedGraderUrl }} {{#t "more_details_in_the_speedgrader"}}More details in the SpeedGrader{{/t}} {{/if}} diff --git a/app/views/jst/_grading_box.handlebars b/app/views/jst/_grading_box.handlebars index e434f258b83..b94336e3671 100644 --- a/app/views/jst/_grading_box.handlebars +++ b/app/views/jst/_grading_box.handlebars @@ -1,23 +1,22 @@ {{#if assignment_grading_type_is_points}} - + {{/if}} {{#if assignment_grading_type_is_percent}} - - - % + + {{/if}} {{#if assignment_grading_type_is_letter_grade}} - + {{/if}} {{#if assignment_grading_type_is_gpa_scale}} - + {{/if}} {{#if assignment_grading_type_is_pass_fail}} - - - + + {{/if}} {{#if showPointsPossible}} diff --git a/spec/selenium/gradebook2_grade_edit_spec.rb b/spec/selenium/gradebook2_grade_edit_spec.rb index 2d017c9cee8..1e74703ced4 100755 --- a/spec/selenium/gradebook2_grade_edit_spec.rb +++ b/spec/selenium/gradebook2_grade_edit_spec.rb @@ -1,5 +1,5 @@ require File.expand_path(File.dirname(__FILE__) + '/helpers/gradebook2_common') -describe "edititing grades" do +describe "editing grades" do include_examples "in-process server selenium tests" ASSIGNMENT_1_POINTS = "10" @@ -25,6 +25,21 @@ describe "edititing grades" do data_setup end + context 'submission details dialog' do + it 'successfully grades a submission' do + get "/courses/#{@course.id}/gradebook2" + wait_for_ajaximations + open_comment_dialog(0, 0) + grade_box = f("form.submission_details_grade_form input.grading_value") + grade_box.attribute('value').should == ASSIGNMENT_1_POINTS + set_value(grade_box, 7) + f("form.submission_details_grade_form button").click + wait_for_ajax_requests + validate_cell_text(f('#gradebook_grid .container_1 .slick-row:nth-child(1) .slick-cell:nth-child(1)'), '7') + final_score_for_row(0).should == "80%" + end + end + it "should update a graded quiz and have the points carry over to the quiz attempts page" do points = 50 q = factory_with_protected_attributes(@course.quizzes, :title => "new quiz", :points_possible => points, :quiz_type => 'assignment', :workflow_state => 'available')