示例#1
0
 /**
  * Copy a students previous attempt to a new attempt.
  *
  * @param int $assignmentid
  * @return array of warnings to indicate any errors.
  * @since Moodle 2.6
  */
 public static function copy_previous_attempt($assignmentid)
 {
     global $CFG, $USER;
     require_once "{$CFG->dirroot}/mod/assign/locallib.php";
     $params = self::validate_parameters(self::copy_previous_attempt_parameters(), array('assignmentid' => $assignmentid));
     $cm = get_coursemodule_from_instance('assign', $assignmentid, 0, false, MUST_EXIST);
     $context = context_module::instance($cm->id);
     self::validate_context($context);
     $assignment = new assign($context, $cm, null);
     $notices = array();
     $assignment->copy_previous_attempt($submissiondata, $notices);
     $warnings = array();
     foreach ($notices as $notice) {
         $warnings[] = self::generate_warning($assignmentid, 'couldnotcopyprevioussubmission', $notice);
     }
     return $warnings;
 }
示例#2
0
 /**
  * Copy a students previous attempt to a new attempt.
  *
  * @param int $assignmentid
  * @return array of warnings to indicate any errors.
  * @since Moodle 2.6
  */
 public static function copy_previous_attempt($assignmentid)
 {
     $params = self::validate_parameters(self::copy_previous_attempt_parameters(), array('assignmentid' => $assignmentid));
     $cm = get_coursemodule_from_instance('assign', $params['assignmentid'], 0, false, MUST_EXIST);
     $context = context_module::instance($cm->id);
     self::validate_context($context);
     $assignment = new assign($context, $cm, null);
     $notices = array();
     $assignment->copy_previous_attempt($notices);
     $warnings = array();
     foreach ($notices as $notice) {
         $warnings[] = self::generate_warning($assignmentid, 'couldnotcopyprevioussubmission', $notice);
     }
     return $warnings;
 }