Merge branch 'MDL-70041-310' of git://github.com/mihailges/moodle into MOODLE_310_STABLE
[moodle.git] / question / type / ddwtos / edit_ddwtos_form.php
CommitLineData
61381e50 1<?php
61381e50
TH
2// This file is part of Moodle - http://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
61381e50
TH
17/**
18 * Defines the editing form for the drag-and-drop words into sentences question type.
19 *
8bc1d28b
EM
20 * @package qtype_ddwtos
21 * @copyright 2009 The Open University
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
61381e50
TH
23 */
24
3a4ac328 25
9d55f4a5
TH
26defined('MOODLE_INTERNAL') || die();
27
e9cd9902 28require_once($CFG->dirroot . '/question/type/gapselect/edit_form_base.php');
61381e50
TH
29
30
31/**
32 * Drag-and-drop words into sentences editing form definition.
33 *
3a4ac328
TH
34 * @copyright 2009 The Open University
35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
61381e50
TH
36 */
37class qtype_ddwtos_edit_form extends qtype_gapselect_edit_form_base {
092c416e 38 public function qtype() {
61381e50
TH
39 return 'ddwtos';
40 }
41
6c543542
TH
42 protected function data_preprocessing_choice($question, $answer, $key) {
43 $question = parent::data_preprocessing_choice($question, $answer, $key);
44 $options = unserialize($answer->feedback);
45 $question->choices[$key]['choicegroup'] = $options->draggroup;
46 $question->choices[$key]['infinite'] = $options->infinite;
47 return $question;
61381e50
TH
48 }
49
6c543542
TH
50 protected function choice_group($mform) {
51 $grouparray = parent::choice_group($mform);
29929b5b
TH
52 $grouparray[] = $mform->createElement('checkbox', 'infinite', ' ',
53 get_string('infinite', 'qtype_ddwtos'), null,
54 array('size' => 1, 'class' => 'tweakcss'));
61381e50
TH
55 return $grouparray;
56 }
57}