���ѧۧݧ�ӧ�� �ާ֧ߧ֧էا֧� - ���֧էѧܧ�ڧ��ӧѧ�� - /home3/cpr76684/public_html/informationitem.tar
���ѧ٧ѧ�
renderer.php 0000644 00000003244 15152167647 0007104 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/>. /** * Defines the renderer the information item behaviour. * * @package qbehaviour_informationitem * @copyright 2009 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); /** * Renderer for outputting parts of a question belonging to the information * item behaviour. * * @copyright 2009 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class qbehaviour_informationitem_renderer extends qbehaviour_renderer { public function controls(question_attempt $qa, question_display_options $options) { if ($options->readonly || $qa->get_state() != question_state::$todo) { return ''; } // Hidden input to move the question into the complete state. return html_writer::empty_tag('input', array( 'type' => 'hidden', 'name' => $qa->get_behaviour_field_name('seen'), 'value' => 1, )); } } tests/behaviour_type_test.php 0000644 00000004131 15152167647 0012520 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 qbehaviour_informationitem; use question_engine; defined('MOODLE_INTERNAL') || die(); global $CFG; require_once(__DIR__ . '/../../../engine/lib.php'); require_once(__DIR__ . '/../../../engine/tests/helpers.php'); /** * Unit tests for the information item behaviour type class. * * @package qbehaviour_informationitem * @category test * @copyright 2015 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class behaviour_type_test extends \basic_testcase { /** @var qbehaviour_informationitem_type */ protected $behaviourtype; public function setUp(): void { parent::setUp(); $this->behaviourtype = question_engine::get_behaviour_type('informationitem'); } public function test_is_archetypal() { $this->assertFalse($this->behaviourtype->is_archetypal()); } public function test_get_unused_display_options() { $this->assertEquals(array(), $this->behaviourtype->get_unused_display_options()); } public function test_can_questions_finish_during_the_attempt() { $this->assertFalse($this->behaviourtype->can_questions_finish_during_the_attempt()); } public function test_adjust_random_guess_score() { $this->assertEquals(0, $this->behaviourtype->adjust_random_guess_score(0)); $this->assertEquals(1, $this->behaviourtype->adjust_random_guess_score(1)); } } tests/walkthrough_test.php 0000644 00000013473 15152167647 0012043 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 qbehaviour_informationitem; use question_state; defined('MOODLE_INTERNAL') || die(); global $CFG; require_once(__DIR__ . '/../../../engine/lib.php'); require_once(__DIR__ . '/../../../engine/tests/helpers.php'); /** * Unit tests for the information item behaviour. * * @package qbehaviour_informationitem * @category test * @copyright 2009 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @covers \qbehaviour_informationitem */ class walkthrough_test extends \qbehaviour_walkthrough_test_base { public function test_informationitem_feedback_description() { // Create a true-false question with correct answer true. $description = \test_question_maker::make_question('description'); $this->start_attempt_at_question($description, 'deferredfeedback'); // Check the initial state. $this->check_current_state(question_state::$todo); $this->check_current_mark(null); $this->check_current_output($this->get_contains_question_text_expectation($description), $this->get_contains_hidden_expectation( $this->quba->get_field_prefix($this->slot) . '-seen', 1), $this->get_does_not_contain_feedback_expectation()); // Check no hidden input when read-only. $this->displayoptions->readonly = true; $this->check_current_output($this->get_contains_question_text_expectation($description), $this->get_does_not_contain_hidden_expectation( $this->quba->get_field_prefix($this->slot) . '-seen', 1)); $this->displayoptions->readonly = false; // Process a submission indicating this question has been seen. $this->process_submission(['-seen' => 1]); $this->check_current_state(question_state::$complete); $this->check_current_mark(null); $this->check_current_output($this->get_does_not_contain_correctness_expectation(), new \question_no_pattern_expectation( '/type=\"hidden\"[^>]*name=\"[^"]*seen\"|name=\"[^"]*seen\"[^>]*type=\"hidden\"/'), $this->get_does_not_contain_feedback_expectation()); // Finish the attempt. $this->quba->finish_all_questions(); // Verify. $this->check_current_state(question_state::$finished); $this->check_current_mark(null); $this->check_current_output( $this->get_contains_question_text_expectation($description), $this->get_contains_general_feedback_expectation($description)); // Process a manual comment. $this->manual_grade('Not good enough!', null, FORMAT_HTML); $this->check_current_state(question_state::$manfinished); $this->check_current_mark(null); $this->check_current_output( new \question_pattern_expectation('/' . preg_quote('Not good enough!', '/') . '/')); // Check that trying to process a manual comment with a grade causes an exception. $this->expectException('moodle_exception'); $this->manual_grade('Not good enough!', 1, FORMAT_HTML); } public function test_informationitem_regrade() { // Create a true-false question with correct answer true. $description = \test_question_maker::make_question('description'); $this->start_attempt_at_question($description, 'deferredfeedback'); // Check the initial state. $this->check_current_state(question_state::$todo); $this->check_current_mark(null); $this->check_current_output($this->get_contains_question_text_expectation($description), $this->get_contains_hidden_expectation( $this->quba->get_field_prefix($this->slot) . '-seen', 1), $this->get_does_not_contain_feedback_expectation()); // Process a submission indicating this question has been seen. $this->process_submission(['-seen' => 1]); $this->check_current_state(question_state::$complete); $this->check_current_mark(null); $this->check_current_output($this->get_does_not_contain_correctness_expectation(), new \question_no_pattern_expectation( '/type=\"hidden\"[^>]*name=\"[^"]*seen\"|name=\"[^"]*seen\"[^>]*type=\"hidden\"/'), $this->get_does_not_contain_feedback_expectation()); // Finish the attempt. $this->quba->finish_all_questions(); // Verify. $this->check_current_state(question_state::$finished); $this->check_current_mark(null); $this->check_step_count(3); $this->check_current_output( $this->get_contains_question_text_expectation($description), $this->get_contains_general_feedback_expectation($description)); // Regrade the attempt. $this->quba->regrade_all_questions(true); // Verify. $this->check_current_mark(null); $this->check_step_count(3); $this->check_current_output( $this->get_contains_question_text_expectation($description), $this->get_contains_general_feedback_expectation($description)); } } behaviourtype.php 0000644 00000002302 15152167647 0010156 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/>. /** * Question behaviour type for information item behaviour. * * @package qbehaviour_informationitem * @copyright 2012 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); /** * Question behaviour type information for informationitem items. * * @copyright 2012 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class qbehaviour_informationitem_type extends question_behaviour_type { } version.php 0000644 00000002143 15152167647 0006760 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 qbehaviour * @subpackage informationitem * @copyright 2011 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'qbehaviour_informationitem'; $plugin->version = 2022112800; $plugin->requires = 2022111800; $plugin->maturity = MATURITY_STABLE; classes/privacy/provider.php 0000644 00000003057 15152167647 0012244 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 qbehaviour_informationitem. * * @package qbehaviour_informationitem * @copyright 2018 Andrew Nicols <andrew@nicols.co.uk> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace qbehaviour_informationitem\privacy; defined('MOODLE_INTERNAL') || die(); /** * Privacy Subsystem for qbehaviour_informationitem 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'; } } behaviour.php 0000644 00000013361 15152167647 0007263 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/>. /** * This behaviour is for information items. * * @package qbehaviour * @subpackage informationitem * @copyright 2009 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); /** * Question behaviour informaiton items. * * For example for the 'Description' 'Question type'. There is no grade, * and the question type is marked complete the first time the user navigates * away from a page that contains that question. * * @copyright 2009 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class qbehaviour_informationitem extends question_behaviour { public function is_compatible_question(question_definition $question) { return true; } public function get_expected_data() { if ($this->qa->get_state() == question_state::$todo) { return array('seen' => PARAM_BOOL); } return parent::get_expected_data(); } public function get_correct_response() { if ($this->qa->get_state() == question_state::$todo) { return array('seen' => 1); } return array(); } public function adjust_display_options(question_display_options $options) { parent::adjust_display_options($options); $options->marks = question_display_options::HIDDEN; // At the moment, the code exists to process a manual comment on an // information item, but we don't display the UI unless there is already // a comment. if (!$this->qa->get_state()->is_commented()) { $options->manualcomment = question_display_options::HIDDEN; } } public function get_state_string($showcorrectness) { return ''; } public function process_action(question_attempt_pending_step $pendingstep) { if ($pendingstep->has_behaviour_var('comment')) { return $this->process_comment($pendingstep); } else if ($pendingstep->has_behaviour_var('finish')) { return $this->process_finish($pendingstep); } else if ($pendingstep->has_behaviour_var('seen')) { return $this->process_seen($pendingstep); } else { return question_attempt::DISCARD; } } public function summarise_action(question_attempt_step $step) { if ($step->has_behaviour_var('comment')) { return $this->summarise_manual_comment($step); } else if ($step->has_behaviour_var('finish')) { return $this->summarise_finish($step); } else if ($step->has_behaviour_var('seen')) { return get_string('seen', 'qbehaviour_informationitem'); } return $this->summarise_start($step); } public function process_comment(question_attempt_pending_step $pendingstep) { if ($pendingstep->has_behaviour_var('mark')) { throw new coding_exception('Information items cannot be graded.'); } return parent::process_comment($pendingstep); } /** * Handle the 'finish' case of {@see process_action()}. * * @param question_attempt_pending_step $pendingstep step representing the action. * @return bool either {@see question_attempt::KEEP} or {@see question_attempt::DISCARD}. */ public function process_finish(question_attempt_pending_step $pendingstep) { if ($this->qa->get_state()->is_finished()) { return question_attempt::DISCARD; } if (!$this->qa->get_state()->is_active()) { throw new coding_exception('It should be impossible for question_attempt ' . $this->qa->get_database_id() . ' using ' . get_class($this) . " to receive a 'finish' action while not active. " . 'Failing with an error, rather than continuing and doing undefined processing, ' . 'so the bug can be identified.'); } $pendingstep->set_state(question_state::$finished); return question_attempt::KEEP; } /** * Handle the 'seen' case of {@see process_action()}. * * @param question_attempt_pending_step $pendingstep step representing the action. * @return bool either {@see question_attempt::KEEP} or {@see question_attempt::DISCARD}. */ public function process_seen(question_attempt_pending_step $pendingstep) { if ($this->qa->get_state()->is_finished()) { return question_attempt::DISCARD; } // Assert so we get a clear error message if the assumptions on which this code relies is invalid. if (!$this->qa->get_state()->is_active()) { throw new coding_exception('It should be impossible for question_attempt ' . $this->qa->get_database_id() . ' using ' . get_class($this) . " to receive a 'seen' action while not active. " . 'Failing with an error, rather than continuing and doing undefined processing, ' . 'so the bug can be identified.'); } $pendingstep->set_state(question_state::$complete); return question_attempt::KEEP; } } lang/en/qbehaviour_informationitem.php 0000644 00000002165 15152167647 0014253 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 'qbehaviour_informationitem', language 'en'. * * @package qbehaviour * @subpackage informationitem * @copyright 2009 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ $string['pluginname'] = 'Behaviour for information items'; $string['privacy:metadata'] = 'The Information items question behaviour plugin does not store any personal data.'; $string['seen'] = 'Seen';
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | ���֧ߧ֧�ѧ�ڧ� ����ѧߧڧ��: 0 |
proxy
|
phpinfo
|
���ѧ����ۧܧ�