Skip to content

Commit

Permalink
Merge branch 'MDL-47494' of git://github.com/timhunt/moodle
Browse files Browse the repository at this point in the history
Note: Fixed some minor grunt and EOF whitespace issues while merging.
  • Loading branch information
stronk7 committed Sep 22, 2015
2 parents 5c7c9ea + 8bc1d28 commit 201a26b
Show file tree
Hide file tree
Showing 143 changed files with 21,309 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/classes/plugin_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,8 @@ public static function standard_plugins_list($type) {

'qtype' => array(
'calculated', 'calculatedmulti', 'calculatedsimple',
'description', 'essay', 'match', 'missingtype', 'multianswer',
'ddimageortext', 'ddmarker', 'ddwtos', 'description',
'essay', 'gapselect', 'match', 'missingtype', 'multianswer',
'multichoice', 'numerical', 'random', 'randomsamatch',
'shortanswer', 'truefalse'
),
Expand Down
9 changes: 9 additions & 0 deletions lib/tests/behat/behat_general.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,15 @@ public function i_drag_and_i_drop_it_in($element, $selectortype, $containereleme
list($containerselector, $containerlocator) = $this->transform_selector($containerselectortype, $containerelement);
$destinationxpath = $this->getSession()->getSelectorsHandler()->selectorToXpath($containerselector, $containerlocator);

$node = $this->get_selected_node("xpath_element", $sourcexpath);
if (!$node->isVisible()) {
throw new ExpectationException('"' . $sourcexpath . '" "xpath_element" is not visible', $this->getSession());
}
$node = $this->get_selected_node("xpath_element", $destinationxpath);
if (!$node->isVisible()) {
throw new ExpectationException('"' . $destinationxpath . '" "xpath_element" is not visible', $this->getSession());
}

$this->getSession()->getDriver()->dragTo($sourcexpath, $destinationxpath);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?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/>.

/**
* Backup code for qtype_ddimageortext.
*
* @package qtype_ddimageortext
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();


/**
* Provides the information to backup ddimageortext questions.
*
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class backup_qtype_ddimageortext_plugin extends backup_qtype_plugin {
/**
* Returns the question type this is.
*
* @return string question type name, like 'ddimageortext'.
*/
protected static function qtype_name() {
return 'ddimageortext';
}

/**
* Returns the qtype information to attach to question element.
*/
protected function define_question_plugin_structure() {
$qtype = self::qtype_name();
$plugin = $this->get_plugin_element(null, '../../qtype', $qtype);

$pluginwrapper = new backup_nested_element($this->get_recommended_name());

$plugin->add_child($pluginwrapper);

$dds = new backup_nested_element($qtype, array('id'), array(
'shuffleanswers', 'correctfeedback', 'correctfeedbackformat',
'partiallycorrectfeedback', 'partiallycorrectfeedbackformat',
'incorrectfeedback', 'incorrectfeedbackformat', 'shownumcorrect'));

$pluginwrapper->add_child($dds);
$drags = new backup_nested_element('drags');

$drag = new backup_nested_element('drag', array('id'),
array('no', 'draggroup', 'infinite', 'label'));
$drops = new backup_nested_element('drops');

$drop = new backup_nested_element('drop', array('id'),
array('no', 'xleft', 'ytop', 'choice', 'label'));

$dds->set_source_table("qtype_{$qtype}",
array('questionid' => backup::VAR_PARENTID));

$pluginwrapper->add_child($drags);
$drags->add_child($drag);
$pluginwrapper->add_child($drops);
$drops->add_child($drop);

$drag->set_source_table("qtype_{$qtype}_drags",
array('questionid' => backup::VAR_PARENTID));

$drop->set_source_table("qtype_{$qtype}_drops",
array('questionid' => backup::VAR_PARENTID));

return $plugin;
}

/**
* Returns one array with filearea => mappingname elements for the qtype
*
* Used by {@link get_components_and_fileareas} to know about all the qtype
* files to be processed both in backup and restore.
*/
public static function get_qtype_fileareas() {
$qtype = self::qtype_name();
return array(
'correctfeedback' => 'question_created',
'partiallycorrectfeedback' => 'question_created',
'incorrectfeedback' => 'question_created',

'bgimage' => 'question_created',
'dragimage' => "qtype_{$qtype}_drags");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
<?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/>.

/**
* Restore code for qtype_ddimageortext.
* @package qtype_ddimageortext
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

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

/**
* Restore plugin class for the ddimageortext question type.
*
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class restore_qtype_ddimageortext_plugin extends restore_qtype_plugin {
/**
* Returns the qtype name.
*
* @return string The type name
*/
protected static function qtype_name() {
return 'ddimageortext';
}

/**
* Returns the paths to be handled by the plugin at question level.
*
* @return array
*/
protected function define_question_plugin_structure() {

$paths = array();

// Add own qtype stuff.
$elename = 'dds';
$elepath = $this->get_pathfor('/'.self::qtype_name());
$paths[] = new restore_path_element($elename, $elepath);

$elename = 'drag';
$elepath = $this->get_pathfor('/drags/drag');
$paths[] = new restore_path_element($elename, $elepath);

$elename = 'drop';
$elepath = $this->get_pathfor('/drops/drop');
$paths[] = new restore_path_element($elename, $elepath);

return $paths; // And we return the interesting paths.
}

/**
* Process the qtype/{qtypename} element.
*
* @param array|object $data Drag and drop data to work with.
*/
public function process_dds($data) {
global $DB;

$prefix = 'qtype_'.self::qtype_name();

$data = (object)$data;
$oldid = $data->id;

// Detect if the question is created or mapped.
$oldquestionid = $this->get_old_parentid('question');
$newquestionid = $this->get_new_parentid('question');
$questioncreated = $this->get_mappingid('question_created', $oldquestionid) ? true : false;

// If the question has been created by restore,
// we need to create its qtype_ddimageortext too.
if ($questioncreated) {
// Adjust some columns.
$data->questionid = $newquestionid;
// Insert record.
$newitemid = $DB->insert_record($prefix, $data);
// Create mapping (needed for decoding links).
$this->set_mapping($prefix, $oldid, $newitemid);
}
}

/**
* Process the qtype/drags/drag element.
*
* @param array|object $data Drag and drop drag data to work with.
*/
public function process_drag($data) {
global $DB;

$prefix = 'qtype_'.self::qtype_name();

$data = (object)$data;
$oldid = $data->id;

// Detect if the question is created or mapped.
$oldquestionid = $this->get_old_parentid('question');
$newquestionid = $this->get_new_parentid('question');
$questioncreated = $this->get_mappingid('question_created', $oldquestionid) ? true : false;

if ($questioncreated) {
$data->questionid = $newquestionid;
// Insert record.
$newitemid = $DB->insert_record("{$prefix}_drags", $data);
// Create mapping (there are files and states based on this).
$this->set_mapping("{$prefix}_drags", $oldid, $newitemid);

}
}

/**
* Process the qtype/drags/drop element.
*
* @param array|object $data Drad and drop drops data to work with.
*/
public function process_drop($data) {
global $DB;

$prefix = 'qtype_'.self::qtype_name();

$data = (object)$data;
$oldid = $data->id;

// Detect if the question is created or mapped.
$oldquestionid = $this->get_old_parentid('question');
$newquestionid = $this->get_new_parentid('question');
$questioncreated = $this->get_mappingid('question_created', $oldquestionid) ? true : false;

if ($questioncreated) {
$data->questionid = $newquestionid;
// Insert record.
$newitemid = $DB->insert_record("{$prefix}_drops", $data);
// Create mapping (there are files and states based on this).
$this->set_mapping("{$prefix}_drops", $oldid, $newitemid);
}
}

/**
* Return the contents of this qtype to be processed by the links decoder.
*
* @return array
*/
public static function define_decode_contents() {

$prefix = 'qtype_'.self::qtype_name();

$contents = array();

$fields = array('correctfeedback', 'partiallycorrectfeedback', 'incorrectfeedback');
$contents[] =
new restore_decode_content($prefix, $fields, $prefix);

return $contents;
}
}
55 changes: 55 additions & 0 deletions question/type/ddimageortext/db/install.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="question/type/ddimageortext/db" VERSION="20150914" COMMENT="XMLDB file for Moodle question/type/ddimageortext."
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<TABLE NAME="qtype_ddimageortext" COMMENT="Defines drag and drop (text or images onto a background image) questions">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="questionid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="shuffleanswers" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="1" SEQUENCE="false"/>
<FIELD NAME="correctfeedback" TYPE="text" NOTNULL="true" SEQUENCE="false" COMMENT="Feedback shown for any correct response."/>
<FIELD NAME="correctfeedbackformat" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="partiallycorrectfeedback" TYPE="text" NOTNULL="true" SEQUENCE="false" COMMENT="Feedback shown for any partially correct response."/>
<FIELD NAME="partiallycorrectfeedbackformat" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="incorrectfeedback" TYPE="text" NOTNULL="true" SEQUENCE="false" COMMENT="Feedback shown for any incorrect response."/>
<FIELD NAME="incorrectfeedbackformat" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="shownumcorrect" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="questionid" TYPE="foreign" FIELDS="questionid" REFTABLE="question" REFFIELDS="id"/>
</KEYS>
</TABLE>
<TABLE NAME="qtype_ddimageortext_drops" COMMENT="Drop boxes">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="questionid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="no" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="drop number"/>
<FIELD NAME="xleft" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="ytop" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="choice" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="label" TYPE="text" NOTNULL="true" SEQUENCE="false" COMMENT="Alt label for drop box"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="questionid" TYPE="foreign" FIELDS="questionid" REFTABLE="question" REFFIELDS="id"/>
</KEYS>
</TABLE>
<TABLE NAME="qtype_ddimageortext_drags" COMMENT="Images to drag. Actual file names are not stored here we use the file names as found in the file storage area.">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="questionid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="no" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="drag no"/>
<FIELD NAME="draggroup" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="infinite" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="label" TYPE="text" NOTNULL="true" SEQUENCE="false" COMMENT="Alt text label for drag-able image."/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="questionid" TYPE="foreign" FIELDS="questionid" REFTABLE="question" REFFIELDS="id"/>
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
Loading

0 comments on commit 201a26b

Please sign in to comment.