ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilTestParticipantsTimeExtensionGUI Class Reference
+ Collaboration diagram for ilTestParticipantsTimeExtensionGUI:

Public Member Functions

 __construct (ilObjTest $testObj)
 ilTestParticipantsTimeExtensionGUI constructor. More...
 
 getTestObj ()
 
 setTestObj ($testObj)
 
 executeCommand ()
 Execute Command. More...
 
 showListCmd ()
 show list command More...
 

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 ()
 show form command More...
 
 buildTimingForm ()
 
 setTimingCmd ()
 set timing command More...
 

Protected Attributes

 $testObj
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilTestParticipantsTimeExtensionGUI::__construct ( ilObjTest  $testObj)

ilTestParticipantsTimeExtensionGUI constructor.

Parameters
ilObjTest$testObj

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

References $testObj.

Member Function Documentation

◆ buildTimingForm()

ilTestParticipantsTimeExtensionGUI::buildTimingForm ( )
protected
Returns
ilPropertyFormGUI

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

References $_POST, $DIC, $form, $name, PHPMailer\PHPMailer\$options, $time, ilDatePresentation\formatDate(), ilTestParticipantAccessFilter\getManageParticipantsUserFilter(), getTestObj(), IL_CAL_UNIX, and ilFormPropertyGUI\setInfo().

Referenced by setTimingCmd(), and showFormCmd().

161  {
162  global $DIC; /* @var ILIAS\DI\Container $DIC */
163 
164  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
165  $form = new ilPropertyFormGUI();
166  $form->setFormAction($DIC->ctrl()->getFormAction($this));
167  $form->setTableWidth("100%");
168  $form->setId("tst_change_workingtime");
169  $form->setTitle($DIC->language()->txt("tst_change_workingtime"));
170 
171  // test users
172  require_once 'Modules/Test/classes/class.ilTestParticipantList.php';
173  $participantList = new ilTestParticipantList($this->getTestObj());
174  $participantList->initializeFromDbRows($this->getTestObj()->getTestParticipants());
175 
176  $participantList = $participantList->getAccessFilteredList(
178  );
179 
180  $addons = $this->getTestObj()->getTimeExtensionsOfParticipants();
181 
182  $participantslist = new ilSelectInputGUI($DIC->language()->txt('participants'), "participant");
183 
184  $options = array(
185  '' => $DIC->language()->txt('please_select'),
186  '0' => $DIC->language()->txt('all_participants')
187  );
188 
189  foreach ($participantList as $participant) {
190  $started = "";
191 
192  if ($this->getTestObj()->getAnonymity()) {
193  $name = $DIC->language()->txt("anonymous");
194  } else {
195  $name = $participant->getLastname() . ', ' . $participant->getFirstname();
196  }
197 
198  $time = $this->getTestObj()->getStartingTimeOfUser($participant->getActiveId());
199  if ($time) {
200  $started = ", " . $DIC->language()->txt('tst_started') . ': ' . ilDatePresentation::formatDate(new ilDateTime($time, IL_CAL_UNIX));
201  }
202 
203  if ($addons[$participant->getActiveId()] > 0) {
204  $started .= ", " . $DIC->language()->txt('extratime') . ': ' . $addons[$participant->getActiveId()] . ' ' . $DIC->language()->txt('minutes');
205  }
206 
207  $options[$participant->getActiveId()] = $participant->getLogin() . ' (' . $name . ')' . $started;
208  }
209 
210  $participantslist->setRequired(true);
211  $participantslist->setOptions($options);
212  $form->addItem($participantslist);
213 
214  // extra time
215  $extratime = new ilNumberInputGUI($DIC->language()->txt("extratime"), "extratime");
216  $extratime->setInfo($DIC->language()->txt('tst_extratime_info'));
217  $extratime->setRequired(true);
218  $extratime->setMinValue(0);
219  $extratime->setMinvalueShouldBeGreater(false);
220  $extratime->setSuffix($DIC->language()->txt('minutes'));
221  $extratime->setSize(5);
222  $form->addItem($extratime);
223 
224  if (is_array($_POST) && strlen($_POST['cmd']['timing'])) {
225  $form->setValuesByArray($_POST);
226  }
227 
228  $form->addCommandButton(self::CMD_SET_TIMING, $DIC->language()->txt("save"));
229  $form->addCommandButton(self::CMD_SHOW_LIST, $DIC->language()->txt("cancel"));
230 
231  return $form;
232  }
This class represents a selection list property in a property form.
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
const IL_CAL_UNIX
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
setInfo($a_info)
Set Information Text.
$time
Definition: cron.php:21
if(isset($_POST['submit'])) $form
This class represents a number property in a property form.
Date and time handling
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilTestParticipantsTimeExtensionGUI::executeCommand ( )

Execute Command.

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

References $DIC, ilObjTestGUI\accessViolationRedirect(), and isExtraTimeFeatureAvailable().

74  {
75  global $DIC; /* @var ILIAS\DI\Container $DIC */
76 
77  if (!$this->isExtraTimeFeatureAvailable()) {
79  }
80 
81  switch ($DIC->ctrl()->getNextClass($this)) {
82  default:
83 
84  $command = $DIC->ctrl()->getCmd(self::CMD_SHOW_LIST) . 'Cmd';
85 
86  $this->{$command}();
87  }
88  }
global $DIC
Definition: saml.php:7
static accessViolationRedirect()
+ Here is the call graph for this function:

◆ getTestObj()

ilTestParticipantsTimeExtensionGUI::getTestObj ( )
Returns
ilObjTest

Definition at line 41 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
Returns
bool

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

References getTestObj().

Referenced by executeCommand().

58  {
59  if (!($this->getTestObj()->getProcessingTimeInSeconds() > 0)) {
60  return false;
61  }
62 
63  if ($this->getTestObj()->getNrOfTries() != 1) {
64  return false;
65  }
66 
67  return true;
68  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTestObj()

ilTestParticipantsTimeExtensionGUI::setTestObj (   $testObj)
Parameters
ilObjTest$testObj

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

References $testObj.

◆ setTimingCmd()

ilTestParticipantsTimeExtensionGUI::setTimingCmd ( )
protected

set timing command

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

References $DIC, $form, buildTimingForm(), and getTestObj().

238  {
239  global $DIC; /* @var ILIAS\DI\Container $DIC */
240 
241  $form = $this->buildTimingForm();
242 
243  if ($form->checkInput()) {
244  $this->getTestObj()->addExtraTime(
245  $form->getInput('participant'),
246  $form->getInput('extratime')
247  );
248 
249  ilUtil::sendSuccess(sprintf($DIC->language()->txt('tst_extratime_added'), $form->getInput('extratime')), true);
250  $DIC->ctrl()->redirect($this, self::CMD_SHOW_LIST);
251  }
252 
253  $DIC->ui()->mainTemplate()->setVariable("ADM_CONTENT", $form->getHTML());
254  }
global $DIC
Definition: saml.php:7
if(isset($_POST['submit'])) $form
+ Here is the call graph for this function:

◆ showFormCmd()

ilTestParticipantsTimeExtensionGUI::showFormCmd ( )
protected

show form command

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

References $DIC, and buildTimingForm().

151  {
152  global $DIC; /* @var ILIAS\DI\Container $DIC */
153 
154  $DIC->ui()->mainTemplate()->setContent($this->buildTimingForm()->getHTML());
155  }
global $DIC
Definition: saml.php:7
+ Here is the call graph for this function:

◆ showListCmd()

ilTestParticipantsTimeExtensionGUI::showListCmd ( )

show list command

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

References $DIC, $time, ilDatePresentation\formatDate(), ilTestParticipantAccessFilter\getManageParticipantsUserFilter(), getTestObj(), and IL_CAL_UNIX.

94  {
95  global $DIC; /* @var ILIAS\DI\Container $DIC */
96 
97  include_once "./Modules/Test/classes/tables/class.ilTimingOverviewTableGUI.php";
98  $tableGUI = new ilTimingOverviewTableGUI($this, self::CMD_SHOW_LIST);
99  $tableGUI->addCommandButton(self::CMD_SHOW_FORM, $DIC->language()->txt('timing'));
100 
101 
102  require_once 'Modules/Test/classes/class.ilTestParticipantList.php';
103  $participantList = new ilTestParticipantList($this->getTestObj());
104  $participantList->initializeFromDbRows($this->getTestObj()->getTestParticipants());
105 
106  $participantList = $participantList->getAccessFilteredList(
108  );
109 
110  $addons = $this->getTestObj()->getTimeExtensionsOfParticipants();
111 
112  $tableData = array();
113  foreach ($participantList as $participant) {
114  $tblRow = array();
115 
116  $time = $this->getTestObj()->getStartingTimeOfUser($participant->getActiveId());
117  if ($time) {
118  $started = $DIC->language()->txt('tst_started') . ': ' . ilDatePresentation::formatDate(
120  );
121 
122  $tblRow['started'] = $started;
123  } else {
124  $tblRow['started'] = '';
125  }
126 
127  if ($addons[$participant->getActiveId()] > 0) {
128  $tblRow['extratime'] = $addons[$participant->getActiveId()];
129  }
130 
131  $tblRow['login'] = $participant->getLogin();
132 
133  if ($this->getTestObj()->getAnonymity()) {
134  $tblRow['name'] = $DIC->language()->txt("anonymous");
135  } else {
136  $tblRow['name'] = $participant->getLastname() . ', ' . $participant->getFirstname();
137  }
138 
139  $tableData[] = $tblRow;
140  }
141 
142  $tableGUI->setData($tableData);
143 
144  $DIC->ui()->mainTemplate()->setContent($DIC->ctrl()->getHTML($tableGUI));
145  }
global $DIC
Definition: saml.php:7
const IL_CAL_UNIX
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
$time
Definition: cron.php:21
Class ilTimingOverviewTableGUI.
Date and time handling
+ Here is the call graph for this function:

Field Documentation

◆ $testObj

ilTestParticipantsTimeExtensionGUI::$testObj
protected

◆ CMD_SET_TIMING

const ilTestParticipantsTimeExtensionGUI::CMD_SET_TIMING = 'setTiming'

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

◆ CMD_SHOW_FORM

const ilTestParticipantsTimeExtensionGUI::CMD_SHOW_FORM = 'showForm'

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

◆ CMD_SHOW_LIST

const ilTestParticipantsTimeExtensionGUI::CMD_SHOW_LIST = 'showList'

Command Constants.

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


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