예제 #1
0
 /**
  * Locks (prevent updates to) submissions in this setaskment.
  *
  * @param int $setaskmentid The id of the setaskment
  * @param array $userids Array of user ids to lock
  * @return array of warnings for each submission that could not be locked.
  * @since Moodle 2.6
  */
 public static function lock_submissions($setaskmentid, $userids)
 {
     global $CFG;
     require_once "{$CFG->dirroot}/mod/setask/locallib.php";
     $params = self::validate_parameters(self::lock_submissions_parameters(), array('setaskmentid' => $setaskmentid, 'userids' => $userids));
     $cm = get_coursemodule_from_instance('setask', $params['setaskmentid'], 0, false, MUST_EXIST);
     $context = context_module::instance($cm->id);
     self::validate_context($context);
     $setaskment = new setask($context, $cm, null);
     $warnings = array();
     foreach ($params['userids'] as $userid) {
         if (!$setaskment->lock_submission($userid)) {
             $detail = 'User id: ' . $userid . ', Assignment id: ' . $params['setaskmentid'];
             $warnings[] = self::generate_warning($params['setaskmentid'], 'couldnotlock', $detail);
         }
     }
     return $warnings;
 }