Exemple #1
0
 /**
  * Ask the user to confirm they want to perform this batch operation
  *
  * @param moodleform $mform Set to a grading batch operations form
  * @return string - the page to view after processing these actions
  */
 protected function process_grading_batch_operation(&$mform)
 {
     global $CFG;
     require_once $CFG->dirroot . '/mod/assign/gradingbatchoperationsform.php';
     require_sesskey();
     $markingallocation = $this->get_instance()->markingallocation && has_capability('mod/assign:manageallocations', $this->context);
     $batchformparams = array('cm' => $this->get_course_module()->id, 'submissiondrafts' => $this->get_instance()->submissiondrafts, 'duedate' => $this->get_instance()->duedate, 'attemptreopenmethod' => $this->get_instance()->attemptreopenmethod, 'feedbackplugins' => $this->get_feedback_plugins(), 'context' => $this->get_context(), 'markingworkflow' => $this->get_instance()->markingworkflow, 'markingallocation' => $markingallocation);
     $formclasses = array('class' => 'gradingbatchoperationsform');
     $mform = new mod_assign_grading_batch_operations_form(null, $batchformparams, 'post', '', $formclasses);
     if ($data = $mform->get_data()) {
         // Get the list of users.
         $users = $data->selectedusers;
         $userlist = explode(',', $users);
         $prefix = 'plugingradingbatchoperation_';
         if ($data->operation == 'grantextension') {
             // Reset the form so the grant extension page will create the extension form.
             $mform = null;
             return 'grantextension';
         } else {
             if ($data->operation == 'setmarkingworkflowstate') {
                 return 'viewbatchsetmarkingworkflowstate';
             } else {
                 if ($data->operation == 'setmarkingallocation') {
                     return 'viewbatchmarkingallocation';
                 } else {
                     if (strpos($data->operation, $prefix) === 0) {
                         $tail = substr($data->operation, strlen($prefix));
                         list($plugintype, $action) = explode('_', $tail, 2);
                         $plugin = $this->get_feedback_plugin_by_type($plugintype);
                         if ($plugin) {
                             return 'plugingradingbatchoperation';
                         }
                     }
                 }
             }
         }
         foreach ($userlist as $userid) {
             if ($data->operation == 'lock') {
                 $this->process_lock_submission($userid);
             } else {
                 if ($data->operation == 'unlock') {
                     $this->process_unlock_submission($userid);
                 } else {
                     if ($data->operation == 'reverttodraft') {
                         $this->process_revert_to_draft($userid);
                     } else {
                         if ($data->operation == 'addattempt') {
                             if (!$this->get_instance()->teamsubmission) {
                                 $this->process_add_attempt($userid);
                             }
                         }
                     }
                 }
             }
         }
         if ($this->get_instance()->teamsubmission && $data->operation == 'addattempt') {
             // This needs to be handled separately so that each team submission is only re-opened one time.
             $this->process_add_attempt_group($userlist);
         }
     }
     return 'grading';
 }
 /**
  * Ask the user to confirm they want to perform this batch operation
  * @return string
  */
 private function process_batch_grading_operation()
 {
     global $CFG;
     require_once $CFG->dirroot . '/mod/assign/gradingbatchoperationsform.php';
     require_sesskey();
     $gradingbatchoperationsform = new mod_assign_grading_batch_operations_form(null, array('cm' => $this->get_course_module()->id, 'submissiondrafts' => $this->get_instance()->submissiondrafts), 'post', '', array('class' => 'gradingbatchoperationsform'));
     if ($data = $gradingbatchoperationsform->get_data()) {
         // get the list of users
         $users = $data->selectedusers;
         $userlist = explode(',', $users);
         foreach ($userlist as $userid) {
             if ($data->operation == 'lock') {
                 $this->process_lock($userid);
             } else {
                 if ($data->operation == 'unlock') {
                     $this->process_unlock($userid);
                 } else {
                     if ($data->operation == 'reverttodraft') {
                         $this->process_revert_to_draft($userid);
                     }
                 }
             }
         }
     }
     return true;
 }
    /**
     * Ask the user to confirm they want to perform this batch operation
     * @param moodleform $mform Set to a grading batch operations form
     * @return string - the page to view after processing these actions
     */
    private function process_grading_batch_operation(& $mform) {
        global $CFG;
        require_once($CFG->dirroot . '/mod/assign/gradingbatchoperationsform.php');
        require_sesskey();

        $mform = new mod_assign_grading_batch_operations_form(null,
                                                              array('cm'=>$this->get_course_module()->id,
                                                                    'submissiondrafts'=>$this->get_instance()->submissiondrafts,
                                                                    'duedate'=>$this->get_instance()->duedate,
                                                                    'feedbackplugins'=>$this->get_feedback_plugins()),
                                                              'post',
                                                              '',
                                                              array('class'=>'gradingbatchoperationsform'));

        if ($data = $mform->get_data()) {
            // get the list of users
            $users = $data->selectedusers;
            $userlist = explode(',', $users);

            $prefix = 'plugingradingbatchoperation_';

            if ($data->operation == 'grantextension') {
                return 'grantextension';
            } else if (strpos($data->operation, $prefix) === 0) {
                $tail = substr($data->operation, strlen($prefix));
                list($plugintype, $action) = explode('_', $tail, 2);

                $plugin = $this->get_feedback_plugin_by_type($plugintype);
                if ($plugin) {
                    return 'plugingradingbatchoperation';
                }
            }

            foreach ($userlist as $userid) {
                if ($data->operation == 'lock') {
                    $this->process_lock($userid);
                } else if ($data->operation == 'unlock') {
                    $this->process_unlock($userid);
                } else if ($data->operation == 'reverttodraft') {
                    $this->process_revert_to_draft($userid);
                }
            }
        }

        return 'grading';
    }
Exemple #4
0
 public function testable_grading_batch_operations_form($operation, $selectedusers)
 {
     global $CFG;
     require_once $CFG->dirroot . '/mod/assign/gradingbatchoperationsform.php';
     // Mock submit the grading operations form.
     $data = array();
     $data['id'] = $this->get_course_module()->id;
     $data['selectedusers'] = $selectedusers;
     $data['returnaction'] = 'grading';
     $data['operation'] = $operation;
     mod_assign_grading_batch_operations_form::mock_submit($data);
     // Set required variables in the form.
     $formparams = array();
     $formparams['submissiondrafts'] = 1;
     $formparams['duedate'] = 1;
     $formparams['attemptreopenmethod'] = ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL;
     $formparams['feedbackplugins'] = array();
     $formparams['markingworkflow'] = 1;
     $formparams['markingallocation'] = 1;
     $formparams['cm'] = $this->get_course_module()->id;
     $formparams['context'] = $this->get_context();
     $mform = new mod_assign_grading_batch_operations_form(null, $formparams);
     return $mform;
 }