ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ILIAS\Test\Presentation\WorkingTime Class Reference
+ Collaboration diagram for ILIAS\Test\Presentation\WorkingTime:

Public Member Functions

 __construct (private readonly ilLanguage $lng, private readonly Factory $ui_factory, private readonly Renderer $ui_renderer, private readonly int $starting_time, private readonly int $processing_time)
 
 prepareWorkingTimeJsTemplate (ilObjTest $object, array $date, string $check_url, string $redirect_url)
 
 getMessageBox (bool $verbose)
 

Private Member Functions

 getUserProcessingTimeMinutesAndSeconds ()
 
 getUserProcessingTimeString ()
 
 getUserRemainingTimeString ()
 

Detailed Description

Definition at line 31 of file WorkingTime.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Test\Presentation\WorkingTime::__construct ( private readonly ilLanguage  $lng,
private readonly Factory  $ui_factory,
private readonly Renderer  $ui_renderer,
private readonly int  $starting_time,
private readonly int  $processing_time 
)

Definition at line 33 of file WorkingTime.php.

39  {
40  }

Member Function Documentation

◆ getMessageBox()

ILIAS\Test\Presentation\WorkingTime::getMessageBox ( bool  $verbose)

Definition at line 90 of file WorkingTime.php.

References ILIAS\Test\Presentation\WorkingTime\getUserProcessingTimeString(), and ILIAS\Test\Presentation\WorkingTime\getUserRemainingTimeString().

Referenced by ilTestSubmissionReviewGUI\show().

90  : string
91  {
92  $message_text = $verbose
93  ? $this->getUserProcessingTimeString() . ' <span id="timeleft">' . $this->getUserRemainingTimeString() . '</span>'
94  : '<div class="ilTstWorkingFormBlock_WorkingTime"><span id="timeleft" class="ilTstWorkingFormInfo_ProcessTimeLeft">' . $this->getUserRemainingTimeString() . '</span></div>';
95  return $this->ui_renderer->render($this->ui_factory->messageBox()->info($message_text));
96  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUserProcessingTimeMinutesAndSeconds()

ILIAS\Test\Presentation\WorkingTime::getUserProcessingTimeMinutesAndSeconds ( )
private

Definition at line 98 of file WorkingTime.php.

Referenced by ILIAS\Test\Presentation\WorkingTime\getUserProcessingTimeString(), and ILIAS\Test\Presentation\WorkingTime\prepareWorkingTimeJsTemplate().

98  : array
99  {
100  $processing_time_minutes = floor($this->processing_time / 60);
101  $processing_time_seconds = $this->processing_time - $processing_time_minutes * 60;
102 
103  return [$processing_time_minutes, $processing_time_seconds];
104  }
+ Here is the caller graph for this function:

◆ getUserProcessingTimeString()

ILIAS\Test\Presentation\WorkingTime::getUserProcessingTimeString ( )
private

Definition at line 106 of file WorkingTime.php.

References ilDatePresentation\formatDate(), ILIAS\Test\Presentation\WorkingTime\getUserProcessingTimeMinutesAndSeconds(), IL_CAL_FKT_GETDATE, and ILIAS\Repository\lng().

Referenced by ILIAS\Test\Presentation\WorkingTime\getMessageBox().

106  : string
107  {
108  [$processing_time_minutes, $processing_time_seconds] = $this->getUserProcessingTimeMinutesAndSeconds();
109 
110  $str_processing_time = '';
111  if ($processing_time_minutes > 0) {
112  $str_processing_time = "$processing_time_minutes {$this->lng->txt($processing_time_minutes === 1 ? 'minute' : 'minutes')}";
113  }
114 
115  if ($processing_time_seconds > 0) {
116  if ($str_processing_time !== '') {
117  $str_processing_time .= " {$this->lng->txt('and')} ";
118  }
119  $str_processing_time .= "$processing_time_seconds {$this->lng->txt($processing_time_seconds === 1 ? 'second' : 'seconds')}";
120  }
121 
122  return sprintf(
123  $this->lng->txt('tst_time_already_spent'),
124  ilDatePresentation::formatDate(new ilDateTime(getdate($this->starting_time), IL_CAL_FKT_GETDATE)),
125  $str_processing_time
126  );
127  }
const IL_CAL_FKT_GETDATE
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUserRemainingTimeString()

ILIAS\Test\Presentation\WorkingTime::getUserRemainingTimeString ( )
private

Definition at line 129 of file WorkingTime.php.

References ILIAS\Repository\lng().

Referenced by ILIAS\Test\Presentation\WorkingTime\getMessageBox().

129  : string
130  {
131  $time_left = $this->starting_time + $this->processing_time - time();
132  $time_left_minutes = floor($time_left / 60);
133  $time_left_seconds = $time_left - $time_left_minutes * 60;
134  $str_time_left = '';
135  if ($time_left_minutes > 0) {
136  $str_time_left = "$time_left_minutes {$this->lng->txt($time_left_minutes === 1 ? 'minute' : 'minutes')}";
137  }
138  if ($time_left < 300 && $time_left_seconds > 0) {
139  if ($str_time_left !== '') {
140  $str_time_left .= " {$this->lng->txt('and')} ";
141  }
142  $str_time_left .= "$time_left_seconds {$this->lng->txt($time_left_seconds === 1 ? 'second' : 'seconds')}";
143  }
144 
145  return sprintf($this->lng->txt('tst_time_already_spent_left'), $str_time_left);
146  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prepareWorkingTimeJsTemplate()

ILIAS\Test\Presentation\WorkingTime::prepareWorkingTimeJsTemplate ( ilObjTest  $object,
array  $date,
string  $check_url,
string  $redirect_url 
)

Definition at line 42 of file WorkingTime.php.

References ilObjTest\getEndingTime(), ILIAS\Test\Presentation\WorkingTime\getUserProcessingTimeMinutesAndSeconds(), IL_CAL_TIMESTAMP, IL_CAL_UNIX, ilObjTest\isEndingTimeEnabled(), and ILIAS\Repository\lng().

Referenced by ilTestPlayerAbstractGUI\outProcessingTime().

47  : ilTemplate {
48  [$processing_time_minutes, $processing_time_seconds] = $this->getUserProcessingTimeMinutesAndSeconds();
49  $template = new ilTemplate('tpl.workingtime.js', true, true, 'components/ILIAS/Test');
50  $template->setVariable('STRING_MINUTE', $this->lng->txt('minute'));
51  $template->setVariable('STRING_MINUTES', $this->lng->txt('minutes'));
52  $template->setVariable('STRING_SECOND', $this->lng->txt('second'));
53  $template->setVariable('STRING_SECONDS', $this->lng->txt('seconds'));
54  $template->setVariable('STRING_TIMELEFT', $this->lng->txt('tst_time_already_spent_left'));
55  $template->setVariable('AND', strtolower($this->lng->txt('and')));
56  $template->setVariable('YEAR', $date['year']);
57  $template->setVariable('MONTH', $date['mon'] - 1);
58  $template->setVariable('DAY', $date['mday']);
59  $template->setVariable('HOUR', $date['hours']);
60  $template->setVariable('MINUTE', $date['minutes']);
61  $template->setVariable('SECOND', $date['seconds']);
62  if ($object->isEndingTimeEnabled()) {
63  $date_time = new ilDateTime($object->getEndingTime(), IL_CAL_UNIX);
64  preg_match('/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/', $date_time->get(IL_CAL_TIMESTAMP), $matches);
65  if ($matches !== []) {
66  $template->setVariable('ENDYEAR', $matches[1]);
67  $template->setVariable('ENDMONTH', $matches[2] - 1);
68  $template->setVariable('ENDDAY', $matches[3]);
69  $template->setVariable('ENDHOUR', $matches[4]);
70  $template->setVariable('ENDMINUTE', $matches[5]);
71  $template->setVariable('ENDSECOND', $matches[6]);
72  }
73  }
74 
75  $datenow = getdate();
76  $template->setVariable('YEARNOW', $datenow['year']);
77  $template->setVariable('MONTHNOW', $datenow['mon'] - 1);
78  $template->setVariable('DAYNOW', $datenow['mday']);
79  $template->setVariable('HOURNOW', $datenow['hours']);
80  $template->setVariable('MINUTENOW', $datenow['minutes']);
81  $template->setVariable('SECONDNOW', $datenow['seconds']);
82  $template->setVariable('PTIME_M', $processing_time_minutes);
83  $template->setVariable('PTIME_S', $processing_time_seconds);
84  $template->setVariable('REDIRECT_URL', $redirect_url);
85  $template->setVariable('CHECK_URL', $check_url);
86 
87  return $template;
88  }
const IL_CAL_UNIX
const IL_CAL_TIMESTAMP
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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