Skip to content

Commit

Permalink
update 2.4
Browse files Browse the repository at this point in the history
fixed Imposr - Export errors
code cleaned
  • Loading branch information
kundandualcube committed Mar 17, 2023
1 parent 580d92f commit ee74a08
Show file tree
Hide file tree
Showing 24 changed files with 118 additions and 42 deletions.
4 changes: 3 additions & 1 deletion backup/moodle1/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

/**
* @package qtype_ddmatch
* @copyright 2011 David Mudrak <[email protected]>
*
* @author DualCube <[email protected]>
* @copyright 2007 DualCube (https://dualcube.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

Expand Down
4 changes: 3 additions & 1 deletion backup/moodle2/backup_qtype_ddmatch_plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

/**
* @package qtype_ddmatch
* @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
*
* @author DualCube <[email protected]>
* @copyright 2007 DualCube (https://dualcube.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

Expand Down
4 changes: 3 additions & 1 deletion backup/moodle2/restore_qtype_ddmatch_plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

/**
* @package qtype_ddmatch
* @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
*
* @author DualCube <[email protected]>
* @copyright 2007 DualCube (https://dualcube.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

Expand Down
4 changes: 3 additions & 1 deletion classes/privacy/privacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
* Privacy Subsystem implementation for format_tabtopics.
*
* @package qtype_ddmatch
* @copyright 2019 Amr Hourani <[email protected]>
*
* @author DualCube <[email protected]>
* @copyright 2007 DualCube (https://dualcube.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

Expand Down
4 changes: 3 additions & 1 deletion db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
* Drag and drop matching question type upgrade code.
*
* @package qtype_ddmatch
* @copyright 2007 Adriane Boyd ([email protected])
*
* @author DualCube <[email protected]>
* @copyright 2007 DualCube (https://dualcube.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

Expand Down
4 changes: 3 additions & 1 deletion db/upgradelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
* Upgrade library code for the match question type.
*
* @package qtype_ddmatch
* @copyright 2010 The Open University
*
* @author DualCube <[email protected]>
* @copyright 2007 DualCube (https://dualcube.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

Expand Down
4 changes: 3 additions & 1 deletion edit_ddmatch_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
* Defines the editing form for the drag&drop match question type.
*
* @package qtype_ddmatch
* @copyright 2007 Adriane Boyd ([email protected])
*
* @author DualCube <[email protected]>
* @copyright 2007 DualCube (https://dualcube.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

Expand Down
7 changes: 5 additions & 2 deletions lang/en/qtype_ddmatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
* The language strings for the match question type.
*
* @package qtype_ddmatch
* @copyright Adriane Boyd ([email protected])
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*
* @author DualCube <[email protected]>
* @copyright 2007 DualCube (https://dualcube.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$string['pluginname'] = 'Drag-and-Drop Matching';
Expand All @@ -31,3 +33,4 @@
$string['pluginnameadding'] = 'Adding Drag-and-Drop Matching Question';
$string['pluginnameediting'] = 'Editing Drag-and-Drop Matching Question';
$string['pluginnamesummary'] = 'An extension of the matching question that allows the user to drag and drop items to match answers to subquestions.';
$string['privacy:metadata'] = 'The question type ddmatch plugin does not store any personal data';
6 changes: 4 additions & 2 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
* Serve question type files
*
* @package qtype_ddmatch
* @author Dongsheng Cai <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*
* @author DualCube <[email protected]>
* @copyright 2007 DualCube (https://dualcube.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();
Expand Down
4 changes: 3 additions & 1 deletion question.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
* Drag-and-drop matching question type classe.
*
* @package qtype_ddmatch
* @copyright 2007 Adriane Boyd ([email protected])
*
* @author DualCube <[email protected]>
* @copyright 2007 DualCube (https://dualcube.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

Expand Down
4 changes: 3 additions & 1 deletion questiontype.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
* Question type class for the drag&drop matching question type.
*
* @package qtype_ddmatch
* @copyright 2007 Adriane Boyd ([email protected])
*
* @author DualCube <[email protected]>
* @copyright 2007 DualCube (https://dualcube.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

Expand Down
8 changes: 8 additions & 0 deletions README.txt → readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Installation:-
Go to [ Site administration > Plugins(Plugins) > Install plugins ] and just upload or drag & drop downloaed ZIP file.
To install, place all downloaded files in /question/type/ddmatch and visit /admin/index.php in your browser.

Setup:-
-----
On Course > Create new Quiz > Add Question > Drag-and-Drop Matching

Overview:-
--------
The drag-and-drop question is adapted from the existing matching question.
Expand All @@ -27,6 +31,10 @@ Grading:-
-------
The grading is identical to the original matching question.

Requirements
------------
* Moodle 2.4.1 - 4.1

Uninstall
---------
Admin can uninstall this admin tool from- Administration > Site Administration > Plugins > Plugins overview [Roshni Lite] > uninstall
3 changes: 3 additions & 0 deletions renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
* Drag&drop matching question renderer class.
*
* @package qtype_ddmatch
*
* @author DualCube <[email protected]>
* @copyright 2007 DualCube (https://dualcube.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

Expand Down
2 changes: 1 addition & 1 deletion tests/behat/add.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Feature: Test creating a drag and drop matching question
| teacher1 | C1 | editingteacher |
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "Question bank" node in "Course administration"
And I navigate to "Question bank" in current page administration

Scenario: Create a drag and drop matching question
When I add a "Drag-and-Drop Matching" question filling the form with:
Expand Down
4 changes: 2 additions & 2 deletions tests/behat/backup_and_restore.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ Feature: Test duplicating a quiz containing a Drag and drop matching question
| Confirmation | Filename | test_backup.mbz |
And I restore "test_backup.mbz" backup into a new course using this options:
| Schema | Course name | Course 2 |
And I navigate to "Question bank" node in "Course administration"
And I click on "Edit" "link" in the "ddmatch-001" "table_row"
And I navigate to "Question bank" in current page administration
When I choose "Edit question" action for "ddmatch-001" in the question bank
Then the following fields match these values:
| Question name | ddmatch-001 |
| Question text | Classify the animals. |
Expand Down
8 changes: 4 additions & 4 deletions tests/behat/edit.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ Feature: Test editing a Drag and drop matching question
| Test questions | ddmatch | Ddmatching for editing | foursubq |
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "Question bank" node in "Course administration"
And I navigate to "Question bank" in current page administration

@javascript @_switch_window
Scenario: Edit a Drag and drop matching question
When I click on "Edit" "link" in the "Ddmatching for editing" "table_row"
When I choose "Edit question" action for "Ddmatching for editing" in the question bank
And I set the following fields to these values:
| Question name | |
And I press "id_submitbutton"
Expand All @@ -35,14 +35,14 @@ Feature: Test editing a Drag and drop matching question
| Question name | Edited Ddmatching name |
And I press "id_submitbutton"
Then I should see "Edited Ddmatching name"
When I click on "Edit" "link" in the "Edited Ddmatching name" "table_row"
When I choose "Edit question" action for "Edited Ddmatching name" in the question bank
And I set the following fields to these values:
| Shuffle | 0 |
| Question 2 | dog |
| Question 4 | fly |
And I press "id_submitbutton"
Then I should see "Edited Ddmatching name"
When I click on "Preview" "link" in the "Edited Ddmatching name" "table_row"
When I choose "Preview" action for "Edited Ddmatching name" in the question bank
And I switch to "questionpreview" window
Then I should see "frog"
And I should see "dog"
Expand Down
5 changes: 3 additions & 2 deletions tests/behat/export.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ Feature: Test exporting Drag and drop matching questions
And I am on "Course 1" course homepage

Scenario: Export a Drag and drop matching question
When I navigate to "Export" node in "Course administration > Question bank"
When I navigate to "Question bank > Export" in current page administration
And I click on "Export" "link"
And I set the field "id_format_xml" to "1"
And I press "Export questions to file"
Then following "click here" should download between "1600" and "1700" bytes
Then following "click here" should download between "1000" and "5000" bytes
# If the download step is the last in the scenario then we can sometimes run
# into the situation where the download page causes a http redirect but behat
# has already conducted its reset (generating an error). By putting a logout
Expand Down
3 changes: 2 additions & 1 deletion tests/behat/import.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ Feature: Test importing Drag and drop matching questions

@javascript @_file_upload
Scenario: import Drag and drop matching question.
When I navigate to "Import" node in "Course administration > Question bank"
When I navigate to "Question bank > Import" in current page administration
And I click on "Import" "link"
And I set the field "id_format_xml" to "1"
And I upload "question/type/ddmatch/tests/fixtures/qtype_sample_ddmatch.xml" file to "Import" filemanager
And I press "id_submitbutton"
Expand Down
5 changes: 4 additions & 1 deletion tests/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
* Contains the helper class for the select missing words question type tests.
*
* @package qtype_ddmatch
* @copyright 2018 Jean-Michel Vedrine
*
* @author DualCube <[email protected]>
* @copyright 2007 DualCube (https://dualcube.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

Expand Down Expand Up @@ -90,6 +92,7 @@ public function get_ddmatch_question_data_foursubq() {
$q->penalty = 0.3333333;
$q->length = 1;
$q->hidden = 0;
$q->idnumber = null;
$q->createdby = $USER->id;
$q->modifiedby = $USER->id;

Expand Down
19 changes: 14 additions & 5 deletions tests/question_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,19 @@
*
* @package qtype
* @subpackage ddmatch
* @copyright 2009 The Open University
*
* @author DualCube <[email protected]>
* @copyright 2007 DualCube (https://dualcube.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace qtype_ddmatch;

use advanced_testcase;
use qtype_ddmatch_test_helper;
use question_attempt_step;
use question_classified_response;
use question_state;

defined('MOODLE_INTERNAL') || die();

Expand All @@ -37,7 +46,7 @@
* @copyright 2009 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class qtype_ddmatch_question_test extends advanced_testcase {
class question_test extends advanced_testcase {

public function test_get_expected_data() {
$question = qtype_ddmatch_test_helper::make_a_ddmatching_question();
Expand Down Expand Up @@ -135,9 +144,9 @@ public function test_get_question_summary() {
$ddmatch = qtype_ddmatch_test_helper::make_a_ddmatching_question();
$ddmatch->start_attempt(new question_attempt_step(), 1);
$qsummary = $ddmatch->get_question_summary();
$this->assertRegExp('/' . preg_quote($ddmatch->questiontext) . '/', $qsummary);
$this->assertMatchesRegularExpression('/' . preg_quote($ddmatch->questiontext, '/') . '/', $qsummary);
foreach ($ddmatch->stems as $stem) {
$this->assertRegExp('/' . preg_quote($stem) . '/', $qsummary);
$this->assertMatchesRegularExpression('/' . preg_quote($stem, '/') . '/', $qsummary);
}
foreach ($ddmatch->choices as $choice) {
$this->assertRegExp('/' . preg_quote($choice) . '/', $qsummary);
Expand All @@ -151,7 +160,7 @@ public function test_summarise_response() {

$summary = $ddmatch->summarise_response(array('sub0' => 2, 'sub1' => 1));

$this->assertRegExp('/Dog -> \w+; Frog -> \w+/', $summary);
$this->assertMatchesRegularExpression('/Dog -> \w+; Frog -> \w+/', $summary);
}

public function test_classify_response() {
Expand Down
21 changes: 16 additions & 5 deletions tests/questiontype_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,19 @@
*
* @package qtype
* @subpackage ddmatch
* @copyright 2009 The Open University
*
* @author DualCube <[email protected]>
* @copyright 2007 DualCube (https://dualcube.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace qtype_ddmatch;

use advanced_testcase;
use qtype_ddmatch;
use question_possible_response;
use stdClass;
use test_question_maker;

defined('MOODLE_INTERNAL') || die();

Expand All @@ -37,15 +46,15 @@
* @copyright 2009 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class qtype_ddmatch_test extends advanced_testcase {
class questiontype_test extends advanced_testcase {
/** @var qtype_ddmatch instance of the question type class to test. */
protected $qtype;

protected function setUp() {
protected function setUp(): void {
$this->qtype = new qtype_ddmatch();
}

protected function tearDown() {
protected function tearDown(): void {
$this->qtype = null;
}

Expand All @@ -67,11 +76,13 @@ protected function get_test_question_data() {
$q->stamp = make_unique_id_code();
$q->version = make_unique_id_code();
$q->hidden = 0;
$q->idnumber = null;
$q->timecreated = time();
$q->timemodified = time();
$q->createdby = $USER->id;
$q->modifiedby = $USER->id;

$q->idnumber = '';
$q->options = new stdClass();
$q->options->shuffleanswers = false;
test_question_maker::set_standard_combined_feedback_fields($q->options);
Expand Down Expand Up @@ -116,7 +127,7 @@ public function test_can_analyse_responses() {

public function test_get_random_guess_score() {
$q = $this->get_test_question_data();
$this->assertEquals(0.3333333, $this->qtype->get_random_guess_score($q), '', 0.0000001);
$this->assertEqualsWithDelta(0.3333333, $this->qtype->get_random_guess_score($q), 0.0000001);
}

public function test_get_possible_responses() {
Expand Down
9 changes: 7 additions & 2 deletions tests/upgradelibnewqe_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@
* ddmatch questions.
*
* @package qtype_ddmatch
* @copyright 2009 The Open University
*
* @author DualCube <[email protected]>
* @copyright 2007 DualCube (https://dualcube.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace qtype_ddmatch;

use question_attempt_upgrader_test_base;

defined('MOODLE_INTERNAL') || die();

Expand All @@ -36,7 +41,7 @@
* @copyright 2009 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class qtype_ddmatch_attempt_upgrader_test extends question_attempt_upgrader_test_base {
class upgradelibnewqe_test extends question_attempt_upgrader_test_base {

public function test_ddmatch_deferredfeedback_history6220() {
$quiz = (object) array(
Expand Down
Loading

0 comments on commit ee74a08

Please sign in to comment.