mirrored from git://git.moodle.org/moodle.git
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-47494 ddwtos: work-in-progress converting the ddwtos and gapselec…
…t qtypes.
- Loading branch information
0 parents
commit 61381e5
Showing
15 changed files
with
2,778 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<XMLDB PATH="question/type/ddwtos/db" VERSION="20080909" COMMENT="XMLDB file for Moodle question/type/ddwtos" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd" | ||
> | ||
<TABLES> | ||
<TABLE NAME="question_ddwtos" COMMENT="Defines drag and drop (words into sentences) questions"> | ||
<FIELDS> | ||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="questionid"/> | ||
<FIELD NAME="questionid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="shuffleanswers"/> | ||
<FIELD NAME="shuffleanswers" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="questionid" NEXT="correctfeedback"/> | ||
<FIELD NAME="correctfeedback" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="shuffleanswers" NEXT="partiallycorrectfeedback"/> | ||
<FIELD NAME="partiallycorrectfeedback" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="correctfeedback" NEXT="incorrectfeedback"/> | ||
<FIELD NAME="incorrectfeedback" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="partiallycorrectfeedback" NEXT="shownumcorrect"/> | ||
<FIELD NAME="shownumcorrect" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="incorrectfeedback"/> | ||
</FIELDS> | ||
<KEYS> | ||
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="questionid"/> | ||
<KEY NAME="questionid" TYPE="foreign" FIELDS="questionid" REFTABLE="questions" REFFIELDS="id" PREVIOUS="primary"/> | ||
</KEYS> | ||
</TABLE> | ||
</TABLES> | ||
</XMLDB> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php // $Id$ | ||
|
||
// This file keeps track of upgrades to | ||
// the ddwtos qtype plugin | ||
// | ||
// Sometimes, changes between versions involve | ||
// alterations to database structures and other | ||
// major things that may break installations. | ||
// | ||
// The upgrade function in this file will attempt | ||
// to perform all the necessary actions to upgrade | ||
// your older installtion to the current version. | ||
// | ||
// If there's something it cannot do itself, it | ||
// will tell you what you need to do. | ||
// | ||
// The commands in here will all be database-neutral, | ||
// using the functions defined in lib/ddllib.php | ||
|
||
function xmldb_qtype_ddwtos_upgrade($oldversion=0) { | ||
|
||
global $CFG, $THEME, $db; | ||
|
||
$result = true; | ||
|
||
// Rename question_ddwtos table to question_ddwtos | ||
// as it is too long for Oracle | ||
if ($result && $oldversion < 2008121900) { | ||
|
||
/// Define table course_extended_meta to be created | ||
$table = new XMLDBTable('question_ddwordsintosentences'); | ||
|
||
/// Do nothing if table already exists (probably created from xml file) | ||
if (table_exists($table)) { | ||
|
||
/// Define table question_ddwtos to be renamed to NEWNAMEGOESHERE | ||
$table = new XMLDBTable('question_ddwordsintosentences'); | ||
|
||
/// Launch rename table for question_ddwtos | ||
$result = $result && rename_table($table, 'question_ddwtos'); | ||
} | ||
} | ||
|
||
if ($oldversion < 2009052000) { | ||
|
||
$table = new XMLDBTable('question_ddanswers'); | ||
if (table_exists($table) && ($ddanswers = get_records('question_ddanswers'))) { | ||
foreach($ddanswers as $ddanswer){ | ||
$answer = new stdClass; | ||
|
||
$answer->question = $ddanswer->questionid; | ||
$answer->answer = addslashes($ddanswer->answer); | ||
$answer->fraction = 1; | ||
|
||
$feedback = new stdClass; | ||
$feedback->draggroup = $ddanswer->draggroup; | ||
$feedback->infinite = $ddanswer->infinite; | ||
$answer->feedback = serialize($feedback); | ||
|
||
if(!insert_record('question_answers', $answer)){ | ||
notify('move_question_ddanswers_to_question_answers(): cannot insert row into question_answer table.'); | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
// Drop table | ||
$result = $result && drop_table($table); | ||
} | ||
|
||
if ($result && $oldversion < 2010042800) { | ||
|
||
/// Rename field correctresponsesfeedback on table question_ddwtos to shownumcorrect | ||
$table = new XMLDBTable('question_ddwtos'); | ||
$field = new XMLDBField('correctresponsesfeedback'); | ||
$field->setAttributes(XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'incorrectfeedback'); | ||
|
||
/// Launch rename field correctresponsesfeedback | ||
$result = $result && rename_field($table, $field, 'shownumcorrect'); | ||
} | ||
|
||
return $result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?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 editing form for the drag-and-drop words into sentences question type. | ||
* | ||
* @package qtype_ddwtos | ||
* @copyright 2009 The Open University | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
require_once($CFG->dirroot . '/question/type/sddl/edit_form_base.php'); | ||
|
||
|
||
/** | ||
* Drag-and-drop words into sentences editing form definition. | ||
* | ||
* @copyright 2009 The Open University | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class qtype_ddwtos_edit_form extends qtype_gapselect_edit_form_base { | ||
|
||
function qtype() { | ||
return 'ddwtos'; | ||
} | ||
|
||
protected function default_values_from_feedback_field($feedback, $key){ | ||
$feedback = unserialize($feedback); | ||
$draggroup = $feedback->draggroup; | ||
$infinite = $feedback->infinite; | ||
|
||
$default_values = array(); | ||
$default_values['choices['.$key.'][draggroup]'] = $draggroup; | ||
$default_values['choices['.$key.'][infinite]'] = $infinite; | ||
return $default_values; | ||
} | ||
|
||
protected function repeated_options(){ | ||
$repeatedoptions = array(); | ||
$repeatedoptions['draggroup']['default'] = '1'; | ||
$repeatedoptions['infinite']['default'] = 0; | ||
return $repeatedoptions; | ||
} | ||
|
||
protected function choice_group(&$mform, $grouparray){ | ||
$options = array(); | ||
for ($i = 1; $i <= 8; $i += 1) { | ||
$options[$i] = $i; | ||
} | ||
$grouparray[] =& $mform->createElement('select', 'draggroup', get_string('group', 'qtype_ddwtos'), $options); | ||
$grouparray[] =& $mform->createElement('checkbox', 'infinite', ' ', get_string('infinite', 'qtype_ddwtos'), null, array('size'=>1, 'class'=>'tweakcss')); | ||
return $grouparray; | ||
} | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
|
||
$string['addingddwtos'] = 'Adding drag and drop: words in text'; | ||
$string['addmorechoiceblanks'] = 'Blanks for {no} More Choices'; | ||
$string['answer'] = 'Answer'; | ||
$string['correctansweris'] = 'The correct answer is: $a'; | ||
$string['ddwtos'] = 'Drag and drop: words in text'; | ||
$string['ddwtos_help'] = 'Type in some question text like "The [[1]] jumped over the [[2]]", then enter the possible words to go in gaps 1 and 2 underneath.'; | ||
$string['ddwtossummary'] = 'Missing words in some text are filled in using drag-and-drop.'; | ||
$string['editingddwtos'] = 'Editing drag and drop: words in text'; | ||
$string['infinite'] = 'Infinite'; | ||
$string['pleaseputananswerineachbox'] = 'Please put an answer in each box.'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?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/>. | ||
|
||
|
||
/** | ||
* Drag-and-drop words into sentences question definition class. | ||
* | ||
* @package qtype_ddwtos | ||
* @copyright 2009 The Open University | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
require_once($CFG->dirroot . '/question/type/gapselect/questionbase.php'); | ||
|
||
/** | ||
* Represents a drag-and-drop words into sentences question. | ||
* | ||
* @copyright 2009 The Open University | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class qtype_ddwtos_question extends qtype_gapselect_question_base { | ||
//is actually exactly the same. | ||
} | ||
|
||
|
||
/** | ||
* Represents one of the choices (draggable boxes). | ||
* | ||
* @copyright 2009 The Open University | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class qtype_ddwtos_choice { | ||
public $text; | ||
public $draggroup; | ||
public $isinfinite; | ||
|
||
public function __construct($text, $draggroup = 1, $isinfinite = false) { | ||
$this->text = $text; | ||
$this->draggroup = $draggroup; | ||
$this->isinfinite = $isinfinite; | ||
} | ||
public function choice_group(){ | ||
return $this->draggroup; | ||
} | ||
} |
Oops, something went wrong.