Esempio n. 1
0
 /**
  * Set the marking allocation for multiple users
  *
  * @return void
  */
 protected function process_set_batch_marking_allocation()
 {
     global $CFG, $DB;
     // Include batch marking allocation form.
     require_once $CFG->dirroot . '/mod/assign/batchsetallocatedmarkerform.php';
     $formparams = array('userscount' => 0, 'usershtml' => '');
     list($sort, $params) = users_order_by_sql();
     $markers = get_users_by_capability($this->get_context(), 'mod/assign:grade', '', $sort);
     $markerlist = array();
     foreach ($markers as $marker) {
         $markerlist[$marker->id] = fullname($marker);
     }
     $formparams['markers'] = $markerlist;
     $mform = new mod_assign_batch_set_allocatedmarker_form(null, $formparams);
     if ($mform->is_cancelled()) {
         return true;
     }
     if ($formdata = $mform->get_data()) {
         $useridlist = explode(',', $formdata->selectedusers);
         $marker = $DB->get_record('user', array('id' => $formdata->allocatedmarker), '*', MUST_EXIST);
         foreach ($useridlist as $userid) {
             $flags = $this->get_user_flags($userid, true);
             if ($flags->workflowstate == ASSIGN_MARKING_WORKFLOW_STATE_READYFORREVIEW || $flags->workflowstate == ASSIGN_MARKING_WORKFLOW_STATE_INREVIEW || $flags->workflowstate == ASSIGN_MARKING_WORKFLOW_STATE_READYFORRELEASE || $flags->workflowstate == ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) {
                 continue;
                 // Allocated marker can only be changed in certain workflow states.
             }
             $flags->allocatedmarker = $marker->id;
             if ($this->update_user_flags($flags)) {
                 $user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
                 \mod_assign\event\marker_updated::create_from_marker($this, $user, $marker)->trigger();
             }
         }
     }
 }
Esempio n. 2
0
 /**
  * Set the marking allocation for multiple users
  *
  * @return void
  */
 protected function process_set_batch_marking_allocation()
 {
     global $DB;
     require_sesskey();
     require_capability('mod/assign:manageallocations', $this->context);
     $batchusers = required_param('selectedusers', PARAM_TEXT);
     $markerid = required_param('allocatedmarker', PARAM_INT);
     $marker = $DB->get_record('user', array('id' => $markerid), '*', MUST_EXIST);
     $useridlist = explode(',', $batchusers);
     foreach ($useridlist as $userid) {
         $flags = $this->get_user_flags($userid, true);
         if ($flags->workflowstate == ASSIGN_MARKING_WORKFLOW_STATE_READYFORREVIEW || $flags->workflowstate == ASSIGN_MARKING_WORKFLOW_STATE_INREVIEW || $flags->workflowstate == ASSIGN_MARKING_WORKFLOW_STATE_READYFORRELEASE || $flags->workflowstate == ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) {
             continue;
             // Allocated marker can only be changed in certain workflow states.
         }
         $flags->allocatedmarker = $marker->id;
         if ($this->update_user_flags($flags)) {
             $user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
             $params = array('id' => $user->id, 'fullname' => fullname($user), 'marker' => fullname($marker));
             $message = get_string('setmarkerallocationforlog', 'assign', $params);
             $addtolog = $this->add_to_log('set marking allocation', $message, '', true);
             $params = array('context' => $this->context, 'objectid' => $this->get_instance()->id, 'relateduserid' => $userid, 'other' => array('markerid' => $marker->id));
             $event = \mod_assign\event\marker_updated::create($params);
             $event->set_legacy_logdata($addtolog);
             $event->trigger();
         }
     }
 }
Esempio n. 3
0
 /**
  * Set the marking allocation for multiple users
  *
  * @return void
  */
 protected function process_set_batch_marking_allocation()
 {
     global $CFG, $DB;
     // Include batch marking allocation form.
     require_once $CFG->dirroot . '/mod/assign/batchsetallocatedmarkerform.php';
     $formparams = array('userscount' => 0, 'usershtml' => '');
     $markers = get_users_by_capability($this->get_context(), 'mod/assign:grade');
     $markerlist = array();
     foreach ($markers as $marker) {
         $markerlist[$marker->id] = fullname($marker);
     }
     $formparams['markers'] = $markerlist;
     $mform = new mod_assign_batch_set_allocatedmarker_form(null, $formparams);
     if ($mform->is_cancelled()) {
         return true;
     }
     if ($formdata = $mform->get_data()) {
         $useridlist = explode(',', $formdata->selectedusers);
         $marker = $DB->get_record('user', array('id' => $formdata->allocatedmarker), '*', MUST_EXIST);
         foreach ($useridlist as $userid) {
             $flags = $this->get_user_flags($userid, true);
             if ($flags->workflowstate == ASSIGN_MARKING_WORKFLOW_STATE_READYFORREVIEW || $flags->workflowstate == ASSIGN_MARKING_WORKFLOW_STATE_INREVIEW || $flags->workflowstate == ASSIGN_MARKING_WORKFLOW_STATE_READYFORRELEASE || $flags->workflowstate == ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) {
                 continue;
                 // Allocated marker can only be changed in certain workflow states.
             }
             $flags->allocatedmarker = $marker->id;
             if ($this->update_user_flags($flags)) {
                 $user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
                 $params = array('id' => $user->id, 'fullname' => fullname($user), 'marker' => fullname($marker));
                 $message = get_string('setmarkerallocationforlog', 'assign', $params);
                 $addtolog = $this->add_to_log('set marking allocation', $message, '', true);
                 $params = array('context' => $this->context, 'objectid' => $this->get_instance()->id, 'relateduserid' => $userid, 'other' => array('markerid' => $marker->id));
                 $event = \mod_assign\event\marker_updated::create($params);
                 $event->set_legacy_logdata($addtolog);
                 $event->trigger();
             }
         }
     }
 }