���ѧۧݧ�ӧ�� �ާ֧ߧ֧էا֧� - ���֧էѧܧ�ڧ��ӧѧ�� - /home3/cpr76684/public_html/multianswer.tar
���ѧ٧ѧ�
format.php 0000644 00000006225 15152206224 0006551 0 ustar 00 <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Embedded answer (Cloze) question importer. * * @package qformat_multianswer * @copyright 2003 Henrik Kaipe * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); /** * Importer that imports a text file containing a single Multianswer question * from a text file. * * @copyright 2003 Henrik Kaipe * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class qformat_multianswer extends qformat_default { public function provide_import() { return true; } /** * Validate the given file. * * For more expensive or detailed integrity checks. * * @param stored_file $file the file to check * @return string the error message that occurred while validating the given file */ public function validate_file(stored_file $file): string { return $this->validate_is_utf8_file($file); } public function readquestions($lines) { question_bank::get_qtype('multianswer'); // Ensure the multianswer code is loaded. // For this class the method has been simplified as // there can never be more than one question for a // multianswer import. $questions = array(); $questiontext = array(); $questiontext['text'] = implode('', $lines); $questiontext['format'] = FORMAT_MOODLE; $questiontext['itemid'] = ''; $question = qtype_multianswer_extract_question($questiontext); $errors = qtype_multianswer_validate_question($question); if ($errors) { $this->error(get_string('invalidmultianswerquestion', 'qtype_multianswer', implode(' ', $errors))); return array(); } $question->questiontext = $question->questiontext['text']; $question->questiontextformat = 0; $question->qtype = 'multianswer'; $question->generalfeedback = ''; $question->generalfeedbackformat = FORMAT_MOODLE; $question->length = 1; $question->penalty = 0.3333333; $question->status = \core_question\local\bank\question_version_status::QUESTION_STATUS_READY; $question->version = 1; $question->versionid = 0; $question->questionbankentryid = 0; if (!empty($question)) { $question->name = $this->create_default_question_name($question->questiontext, get_string('questionname', 'question')); $questions[] = $question; } return $questions; } } tests/fixtures/questions.multianswer.txt 0000644 00000000760 15152206224 0014725 0 ustar 00 Match the following cities with the correct state: * San Francisco: {1:MULTICHOICE:=California#OK~Arizona#Wrong} * Tucson: {1:MULTICHOICE:California#Wrong~%100%Arizona#OK} * Los Angeles: {1:MULTICHOICE:=California#OK~Arizona#Wrong} * Phoenix: {1:MULTICHOICE:%0%California#Wrong~=Arizona#OK} The capital of France is {1:SHORTANSWER:%100%Paris#Congratulations! ~%50%Marseille#No, that is the second largest city in France (after Paris).~*#Wrong answer. The capital of France is Paris, of course.}. tests/fixtures/broken_multianswer_4.txt 0000644 00000000031 15152206224 0014446 0 ustar 00 Please select the fruits. tests/fixtures/broken_multianswer_2.txt 0000644 00000000111 15152206224 0014443 0 ustar 00 Please select the fruits {1:MULTICHOICE:Pear#Incorrect~%50%Apple#Correct} tests/fixtures/broken_multianswer_3.txt 0000644 00000000061 15152206224 0014450 0 ustar 00 What grade would you give it? {3:NUMERICAL:=zero} tests/fixtures/broken_multianswer_1.txt 0000644 00000000067 15152206224 0014454 0 ustar 00 Please select the fruits {1:MULTICHOICE:=Apple#Correct} tests/multianswerformat_test.php 0000644 00000013744 15152206224 0013251 0 ustar 00 <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. namespace qformat_multianswer; use qformat_multianswer; use question_check_specified_fields_expectation; defined('MOODLE_INTERNAL') || die(); global $CFG; require_once($CFG->libdir . '/questionlib.php'); require_once($CFG->dirroot . '/question/format.php'); require_once($CFG->dirroot . '/question/format/multianswer/format.php'); require_once($CFG->dirroot . '/question/engine/tests/helpers.php'); /** * Unit tests for the Embedded answer (Cloze) question importer. * * @package qformat_multianswer * @copyright 2012 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class multianswerformat_test extends \question_testcase { public function test_import() { $lines = file(__DIR__ . '/fixtures/questions.multianswer.txt'); $importer = new qformat_multianswer(); $qs = $importer->readquestions($lines); $expectedq = (object) array( 'name' => 'Match the following cities with the correct state: * San Francisco: {#1} * ...', 'questiontext' => 'Match the following cities with the correct state: * San Francisco: {#1} * Tucson: {#2} * Los Angeles: {#3} * Phoenix: {#4} The capital of France is {#5}. ', 'questiontextformat' => FORMAT_MOODLE, 'generalfeedback' => '', 'generalfeedbackformat' => FORMAT_MOODLE, 'qtype' => 'multianswer', 'defaultmark' => 5, 'penalty' => 0.3333333, 'length' => 1, ); $this->assertEquals(1, count($qs)); $this->assert(new question_check_specified_fields_expectation($expectedq), $qs[0]); $this->assertEquals('multichoice', $qs[0]->options->questions[1]->qtype); $this->assertEquals('multichoice', $qs[0]->options->questions[2]->qtype); $this->assertEquals('multichoice', $qs[0]->options->questions[3]->qtype); $this->assertEquals('multichoice', $qs[0]->options->questions[4]->qtype); $this->assertEquals('shortanswer', $qs[0]->options->questions[5]->qtype); } public function test_read_brokencloze_1() { $lines = file(__DIR__ . '/fixtures/broken_multianswer_1.txt'); $importer = new qformat_multianswer(); // The importer echoes some errors, so we need to capture and check that. ob_start(); $questions = $importer->readquestions($lines); $output = ob_get_contents(); ob_end_clean(); // Check that there were some expected errors. $this->assertStringContainsString('Error importing question', $output); $this->assertStringContainsString('Invalid embedded answers (Cloze) question', $output); $this->assertStringContainsString('This type of question requires at least 2 choices', $output); // No question have been imported. $this->assertCount(0, $questions); } public function test_read_brokencloze_2() { $lines = file(__DIR__ . '/fixtures/broken_multianswer_2.txt'); $importer = new qformat_multianswer(); // The importer echoes some errors, so we need to capture and check that. ob_start(); $questions = $importer->readquestions($lines); $output = ob_get_contents(); ob_end_clean(); // Check that there were some expected errors. $this->assertStringContainsString('Error importing question', $output); $this->assertStringContainsString('Invalid embedded answers (Cloze) question', $output); $this->assertStringContainsString('One of the answers should have a score of 100% so it is possible to get full marks for this question.', $output); // No question have been imported. $this->assertCount(0, $questions); } public function test_read_brokencloze_3() { $lines = file(__DIR__ . '/fixtures/broken_multianswer_3.txt'); $importer = new qformat_multianswer(); // The importer echoes some errors, so we need to capture and check that. ob_start(); $questions = $importer->readquestions($lines); $output = ob_get_contents(); ob_end_clean(); // Check that there were some expected errors. $this->assertStringContainsString('Error importing question', $output); $this->assertStringContainsString('Invalid embedded answers (Cloze) question', $output); $this->assertStringContainsString('The answer must be a number, for example -1.234 or 3e8, or \'*\'.', $output); // No question have been imported. $this->assertCount(0, $questions); } public function test_read_brokencloze_4() { $lines = file(__DIR__ . '/fixtures/broken_multianswer_4.txt'); $importer = new qformat_multianswer(); // The importer echoes some errors, so we need to capture and check that. ob_start(); $questions = $importer->readquestions($lines); $output = ob_get_contents(); ob_end_clean(); // Check that there were some expected errors. $this->assertStringContainsString('Error importing question', $output); $this->assertStringContainsString('Invalid embedded answers (Cloze) question', $output); $this->assertStringContainsString('The question text must include at least one embedded answer.', $output); // No question have been imported. $this->assertCount(0, $questions); } } version.php 0000644 00000002106 15152206224 0006740 0 ustar 00 <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Version information for the calculated question type. * * @package qformat_multianswer * @copyright 2011 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qformat_multianswer'; $plugin->version = 2022112800; $plugin->requires = 2022111800; $plugin->maturity = MATURITY_STABLE; classes/privacy/provider.php 0000644 00000003023 15152206224 0012216 0 ustar 00 <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Privacy Subsystem implementation for qformat_multianswer. * * @package qformat_multianswer * @copyright 2018 Andrew Nicols <andrew@nicols.co.uk> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace qformat_multianswer\privacy; defined('MOODLE_INTERNAL') || die(); /** * Privacy Subsystem for qformat_multianswer implementing null_provider. * * @copyright 2018 Andrew Nicols <andrew@nicols.co.uk> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class provider implements \core_privacy\local\metadata\null_provider { /** * Get the language string identifier with the component's language * file to explain why this plugin stores no data. * * @return string */ public static function get_reason() : string { return 'privacy:metadata'; } } lang/en/qformat_multianswer.php 0000644 00000002455 15152206224 0012710 0 ustar 00 <?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Strings for component 'qformat_multianswer', language 'en', branch 'MOODLE_20_STABLE' * * @package qformat_multianswer * @copyright 2010 Helen Foster * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ $string['pluginname'] = 'Embedded answers (Cloze)'; $string['pluginname_help'] = 'Embedded answers (Cloze) format enables the import of a passage of text with questions such as multiple-choice and short answer embedded within it.'; $string['pluginname_link'] = 'question/type/multianswer'; $string['privacy:metadata'] = 'The Embedded answers question plugin does not store any personal data.';
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | ���֧ߧ֧�ѧ�ڧ� ����ѧߧڧ��: 0 |
proxy
|
phpinfo
|
���ѧ����ۧܧ�