Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-41947

Bug with ASSIGN_SUBMISSION_STATUS_REOPENED and only one submission

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Critical Critical
    • None
    • 2.5.2, 2.5.5, 2.6
    • Assignment
    • MOODLE_25_STABLE, MOODLE_26_STABLE
      • Create one assignment
      • Submit one attempt with one student
      • Change assignment submission to ASSIGN_SUBMISSION_STATUS_REOPENED
      • Verify that the grading table shows correctly

      Hello,

      there is a bug introduced by MDL-38973 when you have a submission with status ASSIGN_SUBMISSION_STATUS_REOPENED and just one attempt.
      Here is the code that fails mod/assign/gradingtable.php:

       976                         if ($submission->status == ASSIGN_SUBMISSION_STATUS_REOPENED) {
       977                             // For a newly reopened submission - we want to show the previous submission in the table.
       978                             $this->get_group_and_submission($row->id, $group, $submission, $submission->attemptnumber-1);
       979                         }
      

      Here is the $row variable record that causes the bug:

      stdClass Object
      (
          [id] => 2267
          [picture] => 103145
          [firstname] => Foo bar
          [lastname] => (-----)
          [imagealt] => 
          [email] => mmmm@mmm.com
          [userid] => 2267
          [status] => reopened
          [submissionid] => 3877
          [firstsubmission] => 1379348815
          [timesubmitted] => 1379348815
          [attemptnumber] => 1
          [gradeid] => 2401
          [grade] => 
          [timemarked] => 1379348810
          [firstmarked] => 1379348810
          [mailed] => 1
          [locked] => 0
          [extensionduedate] => 0
      )
      

      Here is the obvius (but not exactly the best) fix:

      --- a/mod/assign/gradingtable.php
      +++ b/mod/assign/gradingtable.php
      @@ -988,7 +988,11 @@ class assign_grading_table extends table_sql implements renderable {
                       } else if ($row->submissionid) {
                           if ($row->status == ASSIGN_SUBMISSION_STATUS_REOPENED) {
                               // For a newly reopened submission - we want to show the previous submission in the table.
      -                        $submission = $this->assignment->get_user_submission($row->userid, false, $row->attemptnumber - 1);
      +                        if ($row->attemptnumber > 1) {
      +                            $submission = $this->assignment->get_user_submission($row->userid, false, $row->attemptnumber - 1)
      +                        } else {
      +                            $submission = $this->assignment->get_user_submission($row->userid, false, $row->attemptnumber);
      +                        }
                           } else {
                               $submission = new stdClass();
                               $submission->id = $row->submissionid;
      
      

      Would appreciate very much if someone could take a look.

      Kind regards,
      Daniel

            Unassigned Unassigned
            danielneis Daniel Neis Araujo
            Damyon Wiese Damyon Wiese
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.