Differences Between: [Versions 311 and 401] [Versions 311 and 402] [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 require_once($CFG->dirroot . '/grade/import/csv/classes/load_data.php'); 18 require_once($CFG->dirroot . '/grade/import/lib.php'); 19 20 /** 21 * Class to open up private methods in gradeimport_csv_load_data(). 22 */ 23 class phpunit_gradeimport_csv_load_data extends gradeimport_csv_load_data { 24 25 /** 26 * Method to open up the appropriate method for unit testing. 27 * 28 * @param object $record 29 * @param int $studentid 30 */ 31 public function test_insert_grade_record($record, $studentid) { 32 $this->importcode = 00001; 33 $this->insert_grade_record($record, $studentid); 34 } 35 36 /** 37 * Method to open up the appropriate method for unit testing. 38 */ 39 public function get_importcode() { 40 return $this->importcode; 41 } 42 43 /** 44 * Method to open up the appropriate method for unit testing. 45 * 46 * @param array $header The column headers from the CSV file. 47 * @param int $key Current row identifier. 48 * @param string $value The value for this row (final grade). 49 * @return array new grades that are ready for commiting to the gradebook. 50 */ 51 public function test_import_new_grade_item($header, $key, $value) { 52 $this->newgradeitems = null; 53 $this->importcode = 00001; 54 return $this->import_new_grade_item($header, $key, $value); 55 } 56 57 /** 58 * Method to open up the appropriate method for unit testing. 59 * 60 * @param string $value The value, from the csv file, being mapped to identify the user. 61 * @param array $userfields Contains the field and label being mapped from. 62 * @return int Returns the user ID if it exists, otherwise null. 63 */ 64 public function test_check_user_exists($value, $userfields) { 65 return $this->check_user_exists($value, $userfields); 66 } 67 68 /** 69 * Method to open up the appropriate method for unit testing. 70 * 71 * @param int $courseid The course ID. 72 * @param int $itemid The ID of the grade item that the feedback relates to. 73 * @param string $value The actual feedback being imported. 74 * @return object Creates a feedback object with the item ID and the feedback value. 75 */ 76 public function test_create_feedback($courseid, $itemid, $value) { 77 return $this->create_feedback($courseid, $itemid, $value); 78 } 79 80 /** 81 * Method to open up the appropriate method for unit testing. 82 */ 83 public function test_update_grade_item($courseid, $map, $key, $verbosescales, $value) { 84 return $this->update_grade_item($courseid, $map, $key, $verbosescales, $value); 85 } 86 87 /** 88 * Method to open up the appropriate method for unit testing. 89 * 90 * @param int $courseid The course ID. 91 * @param array $map Mapping information provided by the user. 92 * @param int $key The line that we are currently working on. 93 * @param bool $verbosescales Form setting for grading with scales. 94 * @param string $value The grade value . 95 * @return array grades to be updated. 96 */ 97 public function test_map_user_data_with_value($mappingidentifier, $value, $header, $map, $key, $courseid, $feedbackgradeid, 98 $verbosescales) { 99 // Set an import code. 100 $this->importcode = 00001; 101 $this->map_user_data_with_value($mappingidentifier, $value, $header, $map, $key, $courseid, $feedbackgradeid, 102 $verbosescales); 103 104 switch ($mappingidentifier) { 105 case 'userid': 106 case 'useridnumber': 107 case 'useremail': 108 case 'username': 109 return $this->studentid; 110 break; 111 case 'new': 112 return $this->newgrades; 113 break; 114 case 'feedback': 115 return $this->newfeedbacks; 116 break; 117 default: 118 return $this->newgrades; 119 break; 120 } 121 } 122 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body