Differences Between: [Versions 311 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * The testable assign class. 19 * 20 * @package mod_assign 21 * @copyright 2014 Adrian Greeve <adrian@moodle.com> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 defined('MOODLE_INTERNAL') || die(); 26 27 global $CFG; 28 require_once($CFG->dirroot . '/mod/assign/locallib.php'); 29 30 /** 31 * Test subclass that makes all the protected methods we want to test public. 32 */ 33 class mod_assign_testable_assign extends assign { 34 35 public function testable_show_intro() { 36 return parent::show_intro(); 37 } 38 39 public function testable_delete_grades() { 40 return parent::delete_grades(); 41 } 42 43 public function testable_apply_grade_to_user($formdata, $userid, $attemptnumber) { 44 return parent::apply_grade_to_user($formdata, $userid, $attemptnumber); 45 } 46 47 public function testable_format_submission_for_log(stdClass $submission) { 48 return parent::format_submission_for_log($submission); 49 } 50 51 public function testable_get_grading_userid_list() { 52 return parent::get_grading_userid_list(); 53 } 54 55 public function testable_is_graded($userid) { 56 return parent::is_graded($userid); 57 } 58 59 public function testable_update_submission(stdClass $submission, $userid, $updatetime, $teamsubmission) { 60 return parent::update_submission($submission, $userid, $updatetime, $teamsubmission); 61 } 62 63 public function testable_process_add_attempt($userid = 0) { 64 return parent::process_add_attempt($userid); 65 } 66 67 public function testable_process_save_quick_grades($postdata) { 68 // Ugly hack to get something into the method. 69 global $_POST; 70 $_POST = $postdata; 71 return parent::process_save_quick_grades(); 72 } 73 74 public function testable_process_set_batch_marking_allocation($selectedusers, $markerid) { 75 global $CFG; 76 require_once($CFG->dirroot . '/mod/assign/batchsetallocatedmarkerform.php'); 77 78 // Simulate the form submission. 79 $data = array(); 80 $data['id'] = $this->get_course_module()->id; 81 $data['selectedusers'] = $selectedusers; 82 $data['allocatedmarker'] = $markerid; 83 $data['action'] = 'setbatchmarkingallocation'; 84 mod_assign_batch_set_allocatedmarker_form::mock_submit($data); 85 86 return parent::process_set_batch_marking_allocation(); 87 } 88 89 public function testable_process_set_batch_marking_workflow_state($selectedusers, $state) { 90 global $CFG; 91 require_once($CFG->dirroot . '/mod/assign/batchsetmarkingworkflowstateform.php'); 92 93 // Simulate the form submission. 94 $data = array(); 95 $data['id'] = $this->get_course_module()->id; 96 $data['selectedusers'] = $selectedusers; 97 $data['markingworkflowstate'] = $state; 98 $data['action'] = 'setbatchmarkingworkflowstate'; 99 mod_assign_batch_set_marking_workflow_state_form::mock_submit($data); 100 101 return parent::process_set_batch_marking_workflow_state(); 102 } 103 104 public function testable_submissions_open($userid = 0) { 105 return parent::submissions_open($userid); 106 } 107 108 public function testable_save_user_extension($userid, $extensionduedate) { 109 return parent::save_user_extension($userid, $extensionduedate); 110 } 111 112 public function testable_get_graders($userid) { 113 // Changed method from protected to public. 114 return parent::get_graders($userid); 115 } 116 117 public function testable_get_notifiable_users($userid) { 118 return parent::get_notifiable_users($userid); 119 } 120 121 public function testable_view_batch_set_workflow_state($selectedusers) { 122 global $PAGE; 123 $PAGE->set_url('/mod/assign/view.php'); 124 $mform = $this->testable_grading_batch_operations_form('setmarkingworkflowstate', $selectedusers); 125 return parent::view_batch_set_workflow_state($mform); 126 } 127 128 public function testable_view_batch_markingallocation($selectedusers) { 129 global $PAGE; 130 $PAGE->set_url('/mod/assign/view.php'); 131 $mform = $this->testable_grading_batch_operations_form('setmarkingallocation', $selectedusers); 132 return parent::view_batch_markingallocation($mform); 133 } 134 135 public function testable_grading_batch_operations_form($operation, $selectedusers) { 136 global $CFG; 137 138 require_once($CFG->dirroot . '/mod/assign/gradingbatchoperationsform.php'); 139 140 // Mock submit the grading operations form. 141 $data = array(); 142 $data['id'] = $this->get_course_module()->id; 143 $data['selectedusers'] = $selectedusers; 144 $data['returnaction'] = 'grading'; 145 $data['operation'] = $operation; 146 mod_assign_grading_batch_operations_form::mock_submit($data); 147 148 // Set required variables in the form. 149 $formparams = array(); 150 $formparams['submissiondrafts'] = 1; 151 $formparams['duedate'] = 1; 152 $formparams['attemptreopenmethod'] = ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL; 153 $formparams['feedbackplugins'] = array(); 154 $formparams['markingworkflow'] = 1; 155 $formparams['markingallocation'] = 1; 156 $formparams['cm'] = $this->get_course_module()->id; 157 $formparams['context'] = $this->get_context(); 158 $mform = new mod_assign_grading_batch_operations_form(null, $formparams); 159 160 return $mform; 161 } 162 163 public function testable_update_activity_completion_records($teamsubmission, 164 $requireallteammemberssubmit, 165 $submission, 166 $userid, 167 $complete, 168 $completion) { 169 return parent::update_activity_completion_records($teamsubmission, 170 $requireallteammemberssubmit, 171 $submission, 172 $userid, 173 $complete, 174 $completion); 175 } 176 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body