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_rubric_privacy_provider_testcase} class. 19 * 20 * @package workshopform_rubric 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 use core_privacy\tests\provider_testcase; 32 33 /** 34 * Unit tests for the privacy API implementation. 35 * 36 * @copyright 2018 David Mudrák <david@moodle.com> 37 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 38 */ 39 class workshopform_rubric_privacy_provider_testcase extends provider_testcase { 40 41 /** 42 * Test {@link workshopform_rubric\privacy\provider::export_assessment_form()} implementation. 43 */ 44 public function test_export_assessment_form() { 45 global $DB; 46 $this->resetAfterTest(); 47 $this->setAdminUser(); 48 49 $this->generator = $this->getDataGenerator(); 50 $this->workshopgenerator = $this->generator->get_plugin_generator('mod_workshop'); 51 52 $this->course1 = $this->generator->create_course(); 53 54 $this->workshop11 = $this->generator->create_module('workshop', [ 55 'course' => $this->course1, 56 'name' => 'Workshop11', 57 ]); 58 $DB->set_field('workshop', 'phase', 50, ['id' => $this->workshop11->id]); 59 60 $this->dim1 = $DB->insert_record('workshopform_rubric', [ 61 'workshopid' => $this->workshop11->id, 62 'sort' => 1, 63 'description' => 'Criterion 1 description', 64 'descriptionformat' => FORMAT_MARKDOWN, 65 ]); 66 67 $DB->insert_record('workshopform_rubric_levels', [ 68 'dimensionid' => $this->dim1, 69 'grade' => 0, 70 'definition' => 'Missing', 71 'definitionformat' => FORMAT_PLAIN, 72 ]); 73 74 $DB->insert_record('workshopform_rubric_levels', [ 75 'dimensionid' => $this->dim1, 76 'grade' => 1, 77 'definition' => 'Poor', 78 'definitionformat' => FORMAT_PLAIN, 79 ]); 80 81 $DB->insert_record('workshopform_rubric_levels', [ 82 'dimensionid' => $this->dim1, 83 'grade' => 2, 84 'definition' => 'Good', 85 'definitionformat' => FORMAT_PLAIN, 86 ]); 87 88 $this->dim2 = $DB->insert_record('workshopform_rubric', [ 89 'workshopid' => $this->workshop11->id, 90 'sort' => 2, 91 'description' => 'Criterion 2 description', 92 'descriptionformat' => FORMAT_MARKDOWN, 93 ]); 94 95 $DB->insert_record('workshopform_rubric_levels', [ 96 'dimensionid' => $this->dim2, 97 'grade' => 0, 98 'definition' => 'Missing', 99 'definitionformat' => FORMAT_PLAIN, 100 ]); 101 102 $DB->insert_record('workshopform_rubric_levels', [ 103 'dimensionid' => $this->dim2, 104 'grade' => 5, 105 'definition' => 'Great', 106 'definitionformat' => FORMAT_PLAIN, 107 ]); 108 109 $this->student1 = $this->generator->create_user(); 110 $this->student2 = $this->generator->create_user(); 111 112 $this->submission111 = $this->workshopgenerator->create_submission($this->workshop11->id, $this->student1->id); 113 114 $this->assessment1112 = $this->workshopgenerator->create_assessment($this->submission111, $this->student2->id, [ 115 'grade' => 92, 116 ]); 117 118 $DB->insert_record('workshop_grades', [ 119 'assessmentid' => $this->assessment1112, 120 'strategy' => 'rubric', 121 'dimensionid' => $this->dim1, 122 'grade' => 1, 123 'peercomment' => '', 124 'peercommentformat' => FORMAT_PLAIN, 125 ]); 126 127 $DB->insert_record('workshop_grades', [ 128 'assessmentid' => $this->assessment1112, 129 'strategy' => 'rubric', 130 'dimensionid' => $this->dim2, 131 'grade' => 5, 132 'peercomment' => '', 133 'peercommentformat' => FORMAT_PLAIN, 134 ]); 135 136 $contextlist = new \core_privacy\local\request\approved_contextlist($this->student2, 'mod_workshop', [ 137 \context_module::instance($this->workshop11->cmid)->id, 138 ]); 139 140 \mod_workshop\privacy\provider::export_user_data($contextlist); 141 142 $writer = writer::with_context(\context_module::instance($this->workshop11->cmid)); 143 144 $form = $writer->get_data([ 145 get_string('myassessments', 'mod_workshop'), 146 $this->assessment1112, 147 get_string('assessmentform', 'mod_workshop'), 148 get_string('pluginname', 'workshopform_rubric'), 149 ]); 150 151 $this->assertEquals('Criterion 1 description', $form->criteria[0]->description); 152 $this->assertEquals(3, count($form->criteria[0]->levels)); 153 $this->assertEquals(2, count($form->criteria[1]->levels)); 154 $this->assertEquals(5, $form->criteria[1]->grade); 155 } 156 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body