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

Public Member Functions

 __construct (ilObjTest $testObj)
 
 getTestObj ()
 
 setTestObj (ilObjTest $testObj)
 
 executeCommand ()
 
 showListCmd ()
 

Data Fields

const CMD_SHOW_LIST = 'showList'
 Command Constants. More...
 
const CMD_SHOW_FORM = 'showForm'
 
const CMD_SET_TIMING = 'setTiming'
 

Protected Member Functions

 isExtraTimeFeatureAvailable ()
 
 showFormCmd ()
 
 buildTimingForm ()
 
 setTimingCmd ()
 

Protected Attributes

ilObjTest $testObj
 
ilCtrl $ctrl
 
illanguage $lng
 

Private Attributes

ilGlobalTemplateInterface $main_tpl
 

Detailed Description

Definition at line 29 of file class.ilTestParticipantsTimeExtensionGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestParticipantsTimeExtensionGUI::__construct ( ilObjTest  $testObj)

Definition at line 43 of file class.ilTestParticipantsTimeExtensionGUI.php.

References $DIC, $testObj, ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

44  {
45  global $DIC;
46  $this->ctrl = $DIC['ilCtrl'];
47  $this->lng = $DIC['lng'];
48  $this->main_tpl = $DIC->ui()->mainTemplate();
49  $this->testObj = $testObj;
50  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ buildTimingForm()

ilTestParticipantsTimeExtensionGUI::buildTimingForm ( )
protected

Definition at line 140 of file class.ilTestParticipantsTimeExtensionGUI.php.

References $name, ILIAS\Repository\ctrl(), ilDatePresentation\formatDate(), ilTestParticipantAccessFilter\getManageParticipantsUserFilter(), getTestObj(), IL_CAL_UNIX, ILIAS\Repository\lng(), and ilFormPropertyGUI\setInfo().

Referenced by setTimingCmd(), and showFormCmd().

141  {
142  $form = new ilPropertyFormGUI();
143  $form->setFormAction($this->ctrl->getFormAction($this));
144  $form->setTableWidth("100%");
145  $form->setId("tst_change_workingtime");
146  $form->setTitle($this->lng->txt("tst_change_workingtime"));
147 
148  // test users
149  require_once 'Modules/Test/classes/class.ilTestParticipantList.php';
150  $participantList = new ilTestParticipantList($this->getTestObj());
151  $participantList->initializeFromDbRows($this->getTestObj()->getTestParticipants());
152 
153  $participantList = $participantList->getAccessFilteredList(
155  );
156 
157  $addons = $this->getTestObj()->getTimeExtensionsOfParticipants();
158 
159  $participantslist = new ilSelectInputGUI($this->lng->txt('participants'), "participant");
160 
161  $options = array(
162  '' => $this->lng->txt('please_select'),
163  '0' => $this->lng->txt('all_participants')
164  );
165 
166  foreach ($participantList as $participant) {
167  $started = "";
168 
169  if ($this->getTestObj()->getAnonymity()) {
170  $name = $this->lng->txt("anonymous");
171  } else {
172  $name = $participant->getLastname() . ', ' . $participant->getFirstname();
173  }
174 
175  $time = $this->getTestObj()->getStartingTimeOfUser($participant->getActiveId());
176  if ($time) {
177  $started = ", " . $this->lng->txt('tst_started') . ': ' . ilDatePresentation::formatDate(new ilDateTime($time, IL_CAL_UNIX));
178  }
179 
180  $participant_id = $participant->getActiveId();
181  if (array_key_exists($participant_id, $addons) && $addons[$participant_id] > 0) {
182  $started .= ", " . $this->lng->txt('extratime') . ': ' . $addons[$participant_id] . ' ' . $this->lng->txt('minutes');
183  }
184 
185  $options[$participant->getActiveId()] = $participant->getLogin() . ' (' . $name . ')' . $started;
186  }
187 
188  $participantslist->setRequired(true);
189  $participantslist->setOptions($options);
190  $form->addItem($participantslist);
191 
192  // extra time
193  $extratime = new ilNumberInputGUI($this->lng->txt("extratime"), "extratime");
194  $extratime->setInfo($this->lng->txt('tst_extratime_info'));
195  $extratime->setRequired(true);
196  $extratime->setMinValue(0);
197  $extratime->setMinvalueShouldBeGreater(false);
198  $extratime->setSuffix($this->lng->txt('minutes'));
199  $extratime->setSize(5);
200  $form->addItem($extratime);
201 
202  if (is_array($_POST) && isset($_POST['cmd']['timing']) && $_POST['cmd']['timing'] != '') {
203  $form->setValuesByArray($_POST);
204  }
205 
206  $form->addCommandButton(self::CMD_SET_TIMING, $this->lng->txt("save"));
207  $form->addCommandButton(self::CMD_SHOW_LIST, $this->lng->txt("cancel"));
208 
209  return $form;
210  }
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
const IL_CAL_UNIX
if($format !==null) $name
Definition: metadata.php:247
This class represents a number property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilTestParticipantsTimeExtensionGUI::executeCommand ( )

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

References ilObjTestGUI\accessViolationRedirect(), ILIAS\Repository\ctrl(), and isExtraTimeFeatureAvailable().

71  {
72  if (!$this->isExtraTimeFeatureAvailable()) {
74  }
75 
76  switch ($this->ctrl->getNextClass($this)) {
77  default:
78 
79  $command = $this->ctrl->getCmd(self::CMD_SHOW_LIST) . 'Cmd';
80 
81  $this->{$command}();
82  }
83  }
static accessViolationRedirect()
+ Here is the call graph for this function:

◆ getTestObj()

ilTestParticipantsTimeExtensionGUI::getTestObj ( )

Definition at line 52 of file class.ilTestParticipantsTimeExtensionGUI.php.

References $testObj.

Referenced by buildTimingForm(), isExtraTimeFeatureAvailable(), setTimingCmd(), and showListCmd().

+ Here is the caller graph for this function:

◆ isExtraTimeFeatureAvailable()

ilTestParticipantsTimeExtensionGUI::isExtraTimeFeatureAvailable ( )
protected

Definition at line 62 of file class.ilTestParticipantsTimeExtensionGUI.php.

References getTestObj().

Referenced by executeCommand().

62  : bool
63  {
64  return (
65  $this->getTestObj()->getProcessingTimeInSeconds() > 0
66  && $this->getTestObj()->getNrOfTries() == 1
67  );
68  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTestObj()

ilTestParticipantsTimeExtensionGUI::setTestObj ( ilObjTest  $testObj)

Definition at line 57 of file class.ilTestParticipantsTimeExtensionGUI.php.

References $testObj.

58  {
59  $this->testObj = $testObj;
60  }

◆ setTimingCmd()

ilTestParticipantsTimeExtensionGUI::setTimingCmd ( )
protected

Definition at line 212 of file class.ilTestParticipantsTimeExtensionGUI.php.

References buildTimingForm(), ILIAS\Repository\ctrl(), getTestObj(), and ILIAS\Repository\lng().

213  {
214  $form = $this->buildTimingForm();
215 
216  if ($form->checkInput()) {
217  $this->getTestObj()->addExtraTime(
218  $form->getInput('participant'),
219  $form->getInput('extratime')
220  );
221 
222  $this->main_tpl->setOnScreenMessage('success', sprintf($this->lng->txt('tst_extratime_added'), $form->getInput('extratime')), true);
223  $this->ctrl->redirect($this, self::CMD_SHOW_LIST);
224  }
225 
226  $this->main_tpl->setVariable("ADM_CONTENT", $form->getHTML());
227  }
+ Here is the call graph for this function:

◆ showFormCmd()

ilTestParticipantsTimeExtensionGUI::showFormCmd ( )
protected

Definition at line 134 of file class.ilTestParticipantsTimeExtensionGUI.php.

References buildTimingForm().

135  {
136  $this->main_tpl->setContent($this->buildTimingForm()->getHTML());
137  }
+ Here is the call graph for this function:

◆ showListCmd()

ilTestParticipantsTimeExtensionGUI::showListCmd ( )

Definition at line 85 of file class.ilTestParticipantsTimeExtensionGUI.php.

References ILIAS\Repository\ctrl(), ilDatePresentation\formatDate(), ilTestParticipantAccessFilter\getManageParticipantsUserFilter(), getTestObj(), IL_CAL_UNIX, and ILIAS\Repository\lng().

86  {
87  $tableGUI = new ilTimingOverviewTableGUI($this, self::CMD_SHOW_LIST);
88  $tableGUI->addCommandButton(self::CMD_SHOW_FORM, $this->lng->txt('timing'));
89 
90  $participantList = new ilTestParticipantList($this->getTestObj());
91  $participantList->initializeFromDbRows($this->getTestObj()->getTestParticipants());
92 
93  $participantList = $participantList->getAccessFilteredList(
95  );
96 
97  $addons = $this->getTestObj()->getTimeExtensionsOfParticipants();
98 
99  $tableData = array();
100  foreach ($participantList as $participant) {
101  $tblRow = [
102  'started' => '',
103  'extratime' => 0,
104  'login' => $participant->getLogin(),
105  'name' => $this->lng->txt("anonymous")
106  ];
107 
108  $time = $this->getTestObj()->getStartingTimeOfUser($participant->getActiveId());
109  if ($time) {
110  $started = $this->lng->txt('tst_started') . ': ' . ilDatePresentation::formatDate(
111  new ilDateTime($time, IL_CAL_UNIX)
112  );
113 
114  $tblRow['started'] = $started;
115  }
116 
117  $participant_id = $participant->getActiveId();
118  if (array_key_exists($participant_id, $addons) && $addons[$participant_id] > 0) {
119  $tblRow['extratime'] = $addons[$participant_id];
120  }
121 
122  if (! $this->getTestObj()->getAnonymity()) {
123  $tblRow['name'] = $participant->getLastname() . ', ' . $participant->getFirstname();
124  }
125 
126  $tableData[] = $tblRow;
127  }
128 
129  $tableGUI->setData($tableData);
130 
131  $this->main_tpl->setContent($this->ctrl->getHTML($tableGUI));
132  }
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
const IL_CAL_UNIX
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilTestParticipantsTimeExtensionGUI::$ctrl
protected

Definition at line 39 of file class.ilTestParticipantsTimeExtensionGUI.php.

◆ $lng

illanguage ilTestParticipantsTimeExtensionGUI::$lng
protected

Definition at line 40 of file class.ilTestParticipantsTimeExtensionGUI.php.

◆ $main_tpl

ilGlobalTemplateInterface ilTestParticipantsTimeExtensionGUI::$main_tpl
private

Definition at line 41 of file class.ilTestParticipantsTimeExtensionGUI.php.

◆ $testObj

ilObjTest ilTestParticipantsTimeExtensionGUI::$testObj
protected

◆ CMD_SET_TIMING

const ilTestParticipantsTimeExtensionGUI::CMD_SET_TIMING = 'setTiming'

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

◆ CMD_SHOW_FORM

const ilTestParticipantsTimeExtensionGUI::CMD_SHOW_FORM = 'showForm'

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

◆ CMD_SHOW_LIST

const ilTestParticipantsTimeExtensionGUI::CMD_SHOW_LIST = 'showList'

Command Constants.

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


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