MDL-47494 ddimageortext: work-in-progress converting the ddwtos and gapselect qtypes.
[moodle.git] / question / type / ddimageortext / edit_ddwtos_form.php
CommitLineData
a2bb148a
TH
1<?php
2
3// This file is part of Moodle - http://moodle.org/
4//
5// Moodle is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// Moodle is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17
18
19/**
20 * Defines the editing form for the drag-and-drop words into sentences question type.
21 *
22 * @package qtype_ddwtos
23 * @copyright 2009 The Open University
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 */
26
27require_once($CFG->dirroot . '/question/type/sddl/edit_form_base.php');
28
29
30/**
31 * Drag-and-drop words into sentences editing form definition.
32 *
33 * @copyright 2009 The Open University
34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35 */
36class qtype_ddwtos_edit_form extends qtype_gapselect_edit_form_base {
37
38 function qtype() {
39 return 'ddwtos';
40 }
41
42 protected function default_values_from_feedback_field($feedback, $key){
43 $feedback = unserialize($feedback);
44 $draggroup = $feedback->draggroup;
45 $infinite = $feedback->infinite;
46
47 $default_values = array();
48 $default_values['choices['.$key.'][draggroup]'] = $draggroup;
49 $default_values['choices['.$key.'][infinite]'] = $infinite;
50 return $default_values;
51 }
52
53 protected function repeated_options(){
54 $repeatedoptions = array();
55 $repeatedoptions['draggroup']['default'] = '1';
56 $repeatedoptions['infinite']['default'] = 0;
57 return $repeatedoptions;
58 }
59
60 protected function choice_group(&$mform, $grouparray){
61 $options = array();
62 for ($i = 1; $i <= 8; $i += 1) {
63 $options[$i] = $i;
64 }
65 $grouparray[] =& $mform->createElement('select', 'draggroup', get_string('group', 'qtype_ddwtos'), $options);
66 $grouparray[] =& $mform->createElement('checkbox', 'infinite', ' ', get_string('infinite', 'qtype_ddwtos'), null, array('size'=>1, 'class'=>'tweakcss'));
67 return $grouparray;
68 }
69}