ILIAS  release_8 Revision v8.23
ilLOTestAssignmentForm Class Reference
+ Collaboration diagram for ilLOTestAssignmentForm:

Public Member Functions

 __construct (object $gui, ilObject $a_container_obj, int $a_type)
 Constructor. More...
 
 getContainer ()
 
 getGUI ()
 
 getSettings ()
 
 getTestType ()
 
 initForm (bool $a_as_multi_assignment=false)
 

Data Fields

const TEST_NEW = 1
 
const TEST_ASSIGN = 2
 

Protected Member Functions

 getAssignableTests ()
 

Private Attributes

ilLanguage $lng
 
ilCtrlInterface $ctrl
 
ilTree $tree
 
ilObject $container
 
object $gui
 
ilLOSettings $settings
 
int $type = 0
 

Detailed Description

Definition at line 25 of file class.ilLOTestAssignmentForm.php.

Constructor & Destructor Documentation

◆ __construct()

ilLOTestAssignmentForm::__construct ( object  $gui,
ilObject  $a_container_obj,
int  $a_type 
)

Constructor.

Definition at line 42 of file class.ilLOTestAssignmentForm.php.

References $DIC, $gui, ILIAS\Repository\ctrl(), getContainer(), ILIAS\Survey\Mode\getId(), ilLOSettings\getInstanceByObjId(), ILIAS\Repository\lng(), and ILIAS\Repository\settings().

43  {
44  global $DIC;
45 
46  $this->lng = $DIC->language();
47  $this->ctrl = $DIC->ctrl();
48  $this->tree = $DIC->repositoryTree();
49  $this->gui = $gui;
50  $this->container = $a_container_obj;
52  $this->type = $a_type;
53  }
global $DIC
Definition: feed.php:28
static getInstanceByObjId(int $a_obj_id)
+ Here is the call graph for this function:

Member Function Documentation

◆ getAssignableTests()

ilLOTestAssignmentForm::getAssignableTests ( )
protected

Definition at line 199 of file class.ilLOTestAssignmentForm.php.

References getContainer(), ILIAS\Survey\Mode\getId(), and ilLOTestAssignments\getInstance().

Referenced by initForm().

199  : array
200  {
201  $assignments = ilLOTestAssignments::getInstance($this->getContainer()->getId());
202 
203  $tests = array();
204  foreach ($this->tree->getChildsByType($this->getContainer()->getRefId(), 'tst') as $tree_node) {
205  if (!in_array($tree_node['child'], $assignments->getTests())) {
206  $tests[] = $tree_node['child'];
207  }
208  }
209  return $tests;
210  }
static getInstance(int $a_container_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getContainer()

ilLOTestAssignmentForm::getContainer ( )

Definition at line 55 of file class.ilLOTestAssignmentForm.php.

References $container.

Referenced by __construct(), getAssignableTests(), and initForm().

55  : ilObject
56  {
57  return $this->container;
58  }
+ Here is the caller graph for this function:

◆ getGUI()

ilLOTestAssignmentForm::getGUI ( )

Definition at line 60 of file class.ilLOTestAssignmentForm.php.

References $gui.

60  : object
61  {
62  return $this->gui;
63  }

◆ getSettings()

ilLOTestAssignmentForm::getSettings ( )

Definition at line 65 of file class.ilLOTestAssignmentForm.php.

References $settings.

65  : ilLOSettings
66  {
67  return $this->settings;
68  }
Settings for LO courses.

◆ getTestType()

ilLOTestAssignmentForm::getTestType ( )

Definition at line 70 of file class.ilLOTestAssignmentForm.php.

References $type.

Referenced by initForm().

70  : int
71  {
72  return $this->type;
73  }
+ Here is the caller graph for this function:

◆ initForm()

ilLOTestAssignmentForm::initForm ( bool  $a_as_multi_assignment = false)

Definition at line 75 of file class.ilLOTestAssignmentForm.php.

References ilCourseObjective\_getObjectiveIds(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), ilRadioOption\addSubItem(), ILIAS\Repository\ctrl(), getAssignableTests(), getContainer(), ILIAS\Survey\Mode\getId(), ilLOTestAssignments\getInstance(), getTestType(), ILIAS\Repository\lng(), ilCourseObjective\lookupObjectiveTitle(), ilObjTest\QUESTION_SET_TYPE_FIXED, ilObjTest\QUESTION_SET_TYPE_RANDOM, ilTextAreaInputGUI\setCols(), ilFormPropertyGUI\setRequired(), ilLOSettings\TYPE_TEST_INITIAL, and ilLOSettings\TYPE_TEST_QUALIFIED.

76  {
77  $form = new ilPropertyFormGUI();
78  $form->setTitle($this->lng->txt('crs_loc_tst_assignment'));
79  $form->setFormAction($this->ctrl->getFormAction($this->getGUI()));
80 
81  if ($a_as_multi_assignment) {
82  $form->addCommandButton('saveMultiTestAssignment', $this->lng->txt('save'));
83  } else {
84  $form->addCommandButton('saveTest', $this->lng->txt('save'));
85  }
86 
87  switch ($this->getTestType()) {
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((string) self::TEST_NEW);
103 
104  $new = new ilRadioOption($this->lng->txt('crs_loc_form_tst_new'), (string) self::TEST_NEW);
105 
106  switch ($this->getTestType()) {
108  $new->setInfo($this->lng->txt("crs_loc_form_tst_new_initial_info"));
109  break;
110 
112  $new->setInfo($this->lng->txt("crs_loc_form_tst_new_qualified_info"));
113  break;
114  }
115 
116  // title
117  $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
118  $ti->setMaxLength(128);
119  $ti->setSize(40);
120  $ti->setRequired(true);
121  $new->addSubItem($ti);
122 
123  // description
124  $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
125  $ta->setCols(40);
126  $ta->setRows(2);
127  $new->addSubItem($ta);
128 
129  // Question assignment type
130  $this->lng->loadLanguageModule('assessment');
131  $qst = new ilRadioGroupInputGUI($this->lng->txt('tst_question_set_type'), 'qtype');
132  $qst->setRequired(true);
133 
134  $random = new ilRadioOption(
135  $this->lng->txt('tst_question_set_type_random'),
137  );
138  $qst->addOption($random);
139 
140  $fixed = new ilRadioOption(
141  $this->lng->txt('tst_question_set_type_fixed'),
143  );
144  $qst->addOption($fixed);
145  $new->addSubItem($qst);
146  $cr_mode->addOption($new);
147 
148  // assign existing
149  $existing = new ilRadioOption($this->lng->txt('crs_loc_form_assign'), (string) self::TEST_ASSIGN);
150 
151  switch ($this->getTestType()) {
153  $existing->setInfo($this->lng->txt("crs_loc_form_assign_initial_info"));
154  break;
155 
157  $existing->setInfo($this->lng->txt("crs_loc_form_assign_qualified_info"));
158  break;
159  }
160 
161  if ($assignable === []) {
162  $existing->setDisabled(true);
163  }
164  $cr_mode->addOption($existing);
165 
166  $options = array();
167  $options[''] = $this->lng->txt('select_one');
168  foreach ($assignable as $tst_ref_id) {
169  $tst_obj_id = ilObject::_lookupObjId($tst_ref_id);
170  $options[$tst_ref_id] = ilObject::_lookupTitle($tst_obj_id);
171  }
172  $selectable = new ilSelectInputGUI($this->lng->txt('crs_loc_form_available_tsts'), 'tst');
173  $selectable->setRequired(true);
174  $selectable->setOptions($options);
175  $existing->addSubItem($selectable);
176  $form->addItem($cr_mode);
177  if ($a_as_multi_assignment) {
178  $assignments = ilLOTestAssignments::getInstance($this->getContainer()->getId());
179 
180  $objective_ids = ilCourseObjective::_getObjectiveIds($this->getContainer()->getId(), false);
181 
182  $options = array();
183  $options[''] = $this->lng->txt('select_one');
184  foreach ($objective_ids as $oid) {
185  $already_assigned_tst = $assignments->getTestByObjective($oid, $this->getTestType());
186  if (!$already_assigned_tst) {
187  $options[$oid] = ilCourseObjective::lookupObjectiveTitle($oid);
188  }
189  }
190 
191  $objective = new ilSelectInputGUI($this->lng->txt('crs_objectives'), 'objective');
192  $objective->setRequired(true);
193  $objective->setOptions($options);
194  $form->addItem($objective);
195  }
196  return $form;
197  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const QUESTION_SET_TYPE_RANDOM
static _getObjectiveIds(int $course_id, bool $a_activated_only=false)
static _lookupObjId(int $ref_id)
This class represents a property in a property form.
static _lookupTitle(int $obj_id)
static lookupObjectiveTitle(int $a_objective_id, bool $a_add_description=false)
setRequired(bool $a_required)
This class represents a text area property in a property form.
const QUESTION_SET_TYPE_FIXED
static getInstance(int $a_container_id)
+ Here is the call graph for this function:

Field Documentation

◆ $container

ilObject ilLOTestAssignmentForm::$container
private

Definition at line 34 of file class.ilLOTestAssignmentForm.php.

Referenced by getContainer().

◆ $ctrl

ilCtrlInterface ilLOTestAssignmentForm::$ctrl
private

Definition at line 31 of file class.ilLOTestAssignmentForm.php.

◆ $gui

object ilLOTestAssignmentForm::$gui
private

Definition at line 35 of file class.ilLOTestAssignmentForm.php.

Referenced by __construct(), and getGUI().

◆ $lng

ilLanguage ilLOTestAssignmentForm::$lng
private

Definition at line 30 of file class.ilLOTestAssignmentForm.php.

◆ $settings

ilLOSettings ilLOTestAssignmentForm::$settings
private

Definition at line 36 of file class.ilLOTestAssignmentForm.php.

Referenced by getSettings().

◆ $tree

ilTree ilLOTestAssignmentForm::$tree
private

Definition at line 32 of file class.ilLOTestAssignmentForm.php.

◆ $type

int ilLOTestAssignmentForm::$type = 0
private

Definition at line 37 of file class.ilLOTestAssignmentForm.php.

Referenced by getTestType().

◆ TEST_ASSIGN

const ilLOTestAssignmentForm::TEST_ASSIGN = 2

Definition at line 28 of file class.ilLOTestAssignmentForm.php.

◆ TEST_NEW

const ilLOTestAssignmentForm::TEST_NEW = 1

Definition at line 27 of file class.ilLOTestAssignmentForm.php.


The documentation for this class was generated from the following file: