Merge branch 'wip-mdl-27521-master' of git://github.com/phalacee/moodle
authorAparup Banerjee <aparup@moodle.com>
Tue, 8 Nov 2011 07:18:22 +0000 (15:18 +0800)
committerAparup Banerjee <aparup@moodle.com>
Tue, 8 Nov 2011 07:18:22 +0000 (15:18 +0800)
1  2 
mod/assignment/type/upload/assignment.class.php

@@@ -44,7 -44,6 +44,7 @@@ class assignment_upload extends assignm
          global $USER, $OUTPUT;
  
          require_capability('mod/assignment:view', $this->context);
 +        $cansubmit = has_capability('mod/assignment:submit', $this->context);
  
          add_to_log($this->course->id, 'assignment', 'view', "view.php?id={$this->cm->id}", $this->assignment->id, $this->cm->id);
  
              } else {
                  $filecount = 0;
              }
 +            if ($cansubmit or !empty($filecount)) { //if a user has submitted files using a previous role we should still show the files
 +                $this->view_feedback();
  
 -            $this->view_feedback();
 -
 -            if (!$this->drafts_tracked() or !$this->isopen() or $this->is_finalized($submission)) {
 -                echo $OUTPUT->heading(get_string('submission', 'assignment'), 3);
 -            } else {
 -                echo $OUTPUT->heading(get_string('submissiondraft', 'assignment'), 3);
 -            }
 +                if (!$this->drafts_tracked() or !$this->isopen() or $this->is_finalized($submission)) {
 +                    echo $OUTPUT->heading(get_string('submission', 'assignment'), 3);
 +                } else {
 +                    echo $OUTPUT->heading(get_string('submissiondraft', 'assignment'), 3);
 +                }
  
 -            if ($filecount and $submission) {
 -                echo $OUTPUT->box($this->print_user_files($USER->id, true), 'generalbox boxaligncenter', 'userfiles');
 -            } else {
 -                if (!$this->isopen() or $this->is_finalized($submission)) {
 -                    echo $OUTPUT->box(get_string('nofiles', 'assignment'), 'generalbox boxaligncenter nofiles', 'userfiles');
 +                if ($filecount and $submission) {
 +                    echo $OUTPUT->box($this->print_user_files($USER->id, true), 'generalbox boxaligncenter', 'userfiles');
                  } else {
 -                    echo $OUTPUT->box(get_string('nofilesyet', 'assignment'), 'generalbox boxaligncenter nofiles', 'userfiles');
 +                    if (!$this->isopen() or $this->is_finalized($submission)) {
 +                        echo $OUTPUT->box(get_string('nofiles', 'assignment'), 'generalbox boxaligncenter nofiles', 'userfiles');
 +                    } else {
 +                        echo $OUTPUT->box(get_string('nofilesyet', 'assignment'), 'generalbox boxaligncenter nofiles', 'userfiles');
 +                    }
                  }
 -            }
  
 -            if (has_capability('mod/assignment:submit', $this->context)) {
                  $this->view_upload_form();
 -            }
  
 -            if ($this->notes_allowed()) {
 -                echo $OUTPUT->heading(get_string('notes', 'assignment'), 3);
 -                $this->view_notes();
 -            }
 +                if ($this->notes_allowed()) {
 +                    echo $OUTPUT->heading(get_string('notes', 'assignment'), 3);
 +                    $this->view_notes();
 +                }
  
 -            $this->view_final_submission();
 +                $this->view_final_submission();
 +            }
          }
          $this->view_footer();
      }
      }
  
      function can_unfinalize($submission) {
+         if(is_bool($submission)) {
+             return false;
+         }
          if (!$this->drafts_tracked()) {
              return false;
          }
          if (has_capability('mod/assignment:grade', $this->context)
            and $this->isopen()
            and $this->is_finalized($submission)) {
  
      function can_finalize($submission) {
          global $USER;
+         if(is_bool($submission)) {
+             return false;
+         }
          if (!$this->drafts_tracked()) {
              return false;
          }