ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilLOTestAssignmentForm.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
5
14{
15 const TEST_NEW = 1;
16 const TEST_ASSIGN = 2;
17
18 private $lng = null;
19 private $ctrl = null;
20
21 private $container = null;
22 private $gui = null;
23 private $settings = null;
24
25 private $type = 0;
26
30 public function __construct($gui, ilObject $a_container_obj, $a_type)
31 {
32 $this->lng = $GLOBALS['lng'];
33 $this->ctrl = $GLOBALS['ilCtrl'];
34
35 $this->gui = $gui;
36 $this->container = $a_container_obj;
37 $this->settings = ilLOSettings::getInstanceByObjId($this->getContainer()->getId());
38
39 $this->type = $a_type;
40
41 }
42
46 public function getContainer()
47 {
48 return $this->container;
49 }
50
51 public function getGUI()
52 {
53 return $this->gui;
54 }
55
60 public function getSettings()
61 {
62 return $this->settings;
63 }
64
65 public function getTestType()
66 {
67 return $this->type;
68 }
69
70 public function initForm($a_as_multi_assignment = FALSE)
71 {
72 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
73 $form = new ilPropertyFormGUI();
74 $form->setTitle($this->lng->txt('crs_loc_tst_assignment'));
75 $form->setFormAction($this->ctrl->getFormAction($this->getGUI()));
76
77 if($a_as_multi_assignment)
78 {
79 $form->addCommandButton('saveMultiTestAssignment', $this->lng->txt('save'));
80 }
81 else
82 {
83 $form->addCommandButton('saveTest', $this->lng->txt('save'));
84 }
85
86 switch($this->getTestType())
87 {
89 $form->setTitle($this->lng->txt('crs_loc_settings_itest_tbl'));
90 break;
91
93 $form->setTitle($this->lng->txt('crs_loc_settings_qtest_tbl'));
94 break;
95
96 }
97
98 $assignable = $this->getAssignableTests();
99
100 $cr_mode = new ilRadioGroupInputGUI($this->lng->txt('crs_loc_form_assign_it'),'mode');
101 $cr_mode->setRequired(true);
102 $cr_mode->setValue(self::TEST_NEW);
103
104 $new = new ilRadioOption($this->lng->txt('crs_loc_form_tst_new'),self::TEST_NEW);
105
106 switch($this->getTestType())
107 {
109 $new->setInfo($this->lng->txt("crs_loc_form_tst_new_initial_info"));
110 break;
111
113 $new->setInfo($this->lng->txt("crs_loc_form_tst_new_qualified_info"));
114 break;
115 }
116
117 // title
118 $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
119 $ti->setMaxLength(128);
120 $ti->setSize(40);
121 $ti->setRequired(true);
122 $new->addSubItem($ti);
123
124 // description
125 $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
126 $ta->setCols(40);
127 $ta->setRows(2);
128 $new->addSubItem($ta);
129
130 // Question assignment type
131 include_once './Modules/Test/classes/class.ilObjTest.php';
132 $this->lng->loadLanguageModule('assessment');
133 $qst = new ilRadioGroupInputGUI($this->lng->txt('tst_question_set_type'),'qtype');
134 $qst->setRequired(true);
135
136 $random = new ilRadioOption(
137 $this->lng->txt('tst_question_set_type_random'),
139 );
140 $qst->addOption($random);
141
142 $fixed = new ilRadioOption(
143 $this->lng->txt('tst_question_set_type_fixed'),
145 );
146 $qst->addOption($fixed);
147 $new->addSubItem($qst);
148 $cr_mode->addOption($new);
149
150 // assign existing
151 $existing = new ilRadioOption($this->lng->txt('crs_loc_form_assign'),self::TEST_ASSIGN);
152
153 switch($this->getTestType())
154 {
156 $existing->setInfo($this->lng->txt("crs_loc_form_assign_initial_info"));
157 break;
158
160 $existing->setInfo($this->lng->txt("crs_loc_form_assign_qualified_info"));
161 break;
162 }
163
164 if(!$assignable)
165 {
166 $existing->setDisabled(true);
167 }
168 $cr_mode->addOption($existing);
169
170 $options = array();
171 $options[''] = $this->lng->txt('select_one');
172 foreach((array) $assignable as $tst_ref_id)
173 {
174 $tst_obj_id = ilObject::_lookupObjId($tst_ref_id);
175 $options[$tst_ref_id] = ilObject::_lookupTitle($tst_obj_id);
176 }
177 $selectable = new ilSelectInputGUI($this->lng->txt('crs_loc_form_available_tsts'),'tst');
178 $selectable->setRequired(true);
179 $selectable->setOptions($options);
180 $existing->addSubItem($selectable);
181
182 $form->addItem($cr_mode);
183
184
185 if($a_as_multi_assignment)
186 {
187 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php';
188 $assignments = ilLOTestAssignments::getInstance($this->getContainer()->getId());
189
190 include_once './Modules/Course/classes/class.ilCourseObjective.php';
191 $objective_ids = ilCourseObjective::_getObjectiveIds($this->getContainer()->getId(), FALSE);
192
193 $options = array();
194 $options[''] = $this->lng->txt('select_one');
195 foreach($objective_ids as $oid)
196 {
197 $already_assigned_tst = $assignments->getTestByObjective($oid, $this->getTestType());
198 if(!$already_assigned_tst)
199 {
201 }
202 }
203
204 $objective = new ilSelectInputGUI($this->lng->txt('crs_objectives'),'objective');
205 $objective->setRequired(TRUE);
206 $objective->setOptions($options);
207 $form->addItem($objective);
208 }
209
210 return $form;
211
212 }
213
218 protected function getAssignableTests()
219 {
220 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php';
221 $assignments = ilLOTestAssignments::getInstance($this->getContainer()->getId());
222
223 $tests = array();
224 foreach($GLOBALS['tree']->getChildsByType($this->getContainer()->getRefId(),'tst') as $tree_node)
225 {
226 if(!in_array($tree_node['child'], $assignments->getTests()))
227 {
228 $tests[] = $tree_node['child'];
229 }
230 }
231 return $tests;
232 }
233
234
235}
236
237?>
static lookupObjectiveTitle($a_objective_id, $a_add_description=false)
static _getObjectiveIds($course_id, $a_activated_only=false)
static getInstanceByObjId($a_obj_id)
get singleton instance
getAssignableTests()
Get assignable tests.
initForm($a_as_multi_assignment=FALSE)
__construct($gui, ilObject $a_container_obj, $a_type)
Constructor.
static getInstance($a_container_id)
Get instance by container id.
const QUESTION_SET_TYPE_RANDOM
type setting value for random question set
const QUESTION_SET_TYPE_FIXED
type setting value for fixed question set
Class ilObject Basic functions for all objects.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a selection list property in a property form.
This class represents a text area property in a property form.
This class represents a text property in a property form.
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
if(!is_array($argv)) $options