See Release Notes
Long Term Support Release
Differences Between: [Versions 39 and 310]
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 * Provides the {@link workshopform_numerrors_privacy_provider_testcase} class. 19 * 20 * @package workshopform_numerrors 21 * @category test 22 * @copyright 2018 David Mudrák <david@moodle.com> 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 defined('MOODLE_INTERNAL') || die(); 27 28 global $CFG; 29 30 use core_privacy\local\request\writer; 31 32 /** 33 * Unit tests for the privacy API implementation. 34 * 35 * @copyright 2018 David Mudrák <david@moodle.com> 36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 37 */ 38 class workshopform_numerrors_privacy_provider_testcase extends advanced_testcase { 39 40 /** 41 * Test {@link workshopform_numerrors\privacy\provider::export_assessment_form()} implementation. 42 */ 43 public function test_export_assessment_form() { 44 global $DB; 45 $this->resetAfterTest(); 46 $this->setAdminUser(); 47 48 $this->generator = $this->getDataGenerator(); 49 $this->workshopgenerator = $this->generator->get_plugin_generator('mod_workshop'); 50 51 $this->course1 = $this->generator->create_course(); 52 53 $this->workshop11 = $this->generator->create_module('workshop', [ 54 'course' => $this->course1, 55 'name' => 'Workshop11', 56 ]); 57 $DB->set_field('workshop', 'phase', 50, ['id' => $this->workshop11->id]); 58 59 $this->dim1 = $DB->insert_record('workshopform_numerrors', [ 60 'workshopid' => $this->workshop11->id, 61 'sort' => 1, 62 'description' => 'Assertion 1 description', 63 'descriptionformat' => FORMAT_MARKDOWN, 64 'descriptiontrust' => 0, 65 'grade0' => 'No', 66 'grade1' => 'Yes', 67 'weight' => 1, 68 ]); 69 70 $this->dim2 = $DB->insert_record('workshopform_numerrors', [ 71 'workshopid' => $this->workshop11->id, 72 'sort' => 2, 73 'description' => 'Assertion 2 description', 74 'descriptionformat' => FORMAT_MARKDOWN, 75 'descriptiontrust' => 0, 76 'grade0' => 'Missing', 77 'grade1' => 'Present', 78 'weight' => 1, 79 ]); 80 81 $this->student1 = $this->generator->create_user(); 82 $this->student2 = $this->generator->create_user(); 83 84 $this->submission111 = $this->workshopgenerator->create_submission($this->workshop11->id, $this->student1->id); 85 86 $this->assessment1112 = $this->workshopgenerator->create_assessment($this->submission111, $this->student2->id, [ 87 'grade' => 92, 88 ]); 89 90 $DB->insert_record('workshop_grades', [ 91 'assessmentid' => $this->assessment1112, 92 'strategy' => 'numerrors', 93 'dimensionid' => $this->dim1, 94 'grade' => 1, 95 'peercomment' => 'Awesome', 96 'peercommentformat' => FORMAT_PLAIN, 97 ]); 98 99 $DB->insert_record('workshop_grades', [ 100 'assessmentid' => $this->assessment1112, 101 'strategy' => 'numerrors', 102 'dimensionid' => $this->dim2, 103 'grade' => 0, 104 'peercomment' => 'Missing', 105 'peercommentformat' => FORMAT_PLAIN, 106 ]); 107 108 $contextlist = new \core_privacy\local\request\approved_contextlist($this->student2, 'mod_workshop', [ 109 \context_module::instance($this->workshop11->cmid)->id, 110 ]); 111 112 \mod_workshop\privacy\provider::export_user_data($contextlist); 113 114 $writer = writer::with_context(\context_module::instance($this->workshop11->cmid)); 115 116 $form = $writer->get_data([ 117 get_string('myassessments', 'mod_workshop'), 118 $this->assessment1112, 119 get_string('assessmentform', 'mod_workshop'), 120 get_string('pluginname', 'workshopform_numerrors'), 121 ]); 122 123 $this->assertEquals('Assertion 1 description', $form->assertions[0]->description); 124 $this->assertEquals(0, $form->assertions[1]->grade); 125 $this->assertEquals('Missing', $form->assertions[1]->peercomment); 126 } 127 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body