public function testable_process_set_batch_marking_allocation($selectedusers, $markerid) { global $CFG; require_once $CFG->dirroot . '/mod/setask/batchsetallocatedmarkerform.php'; // Simulate the form submission. $data = array(); $data['id'] = $this->get_course_module()->id; $data['selectedusers'] = $selectedusers; $data['allocatedmarker'] = $markerid; $data['action'] = 'setbatchmarkingallocation'; mod_setask_batch_set_allocatedmarker_form::mock_submit($data); return parent::process_set_batch_marking_allocation(); }
/** * 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/setask/batchsetallocatedmarkerform.php'; $formparams = array('userscount' => 0, 'usershtml' => ''); list($sort, $params) = users_order_by_sql(); $markers = get_users_by_capability($this->get_context(), 'mod/setask:grade', '', $sort); $markerlist = array(); foreach ($markers as $marker) { $markerlist[$marker->id] = fullname($marker); } $formparams['markers'] = $markerlist; $mform = new mod_setask_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_setask\event\marker_updated::create_from_marker($this, $user, $marker)->trigger(); } } } }