19 declare(strict_types=1);
21 require_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
74 protected function buildSubTabs($active_sub_tab =
'man_scoring_by_qst')
76 $this->
tabs->addSubTab(
'man_scoring_by_qst', $this->
lng->txt(
'tst_man_scoring_by_qst'), $this->
ctrl->getLinkTargetByClass(
'ilTestScoringByQuestionsGUI',
'showManScoringByQuestionParticipantsTable'));
77 $this->
tabs->addSubTab(
'man_scoring', $this->
lng->txt(
'tst_man_scoring_by_part'), $this->
ctrl->getLinkTargetByClass(
'ilTestScoringGUI',
'showManScoringParticipantsTable'));
78 $this->
tabs->setSubTabActive($active_sub_tab);
83 if (!$this->testrequest->isset(
'active_id') || $this->testrequest->int(
'active_id') === 0) {
84 $this->tpl->setOnScreenMessage(
'failure',
'no active id given!',
true);
85 $this->
ctrl->redirectByClass(
"ilobjtestgui",
"infoScreen");
88 return $this->testrequest->int(
'active_id');
93 $max_pass = $this->
object->_getMaxPass($active_id);
96 if ($this->testrequest->isset(
'pass')) {
97 $pass_from_request = $this->testrequest->int(
'pass');
98 if ($pass_from_request >= 0
99 && $pass_from_request <= $max_pass
101 return $pass_from_request;
109 return $this->
object->_getResultPass($active_id);
117 if (!$this->
getTestAccess()->checkScoreParticipantsAccess()) {
118 ilObjTestGUI::accessViolationRedirect();
123 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"manscoring_not_allowed"),
true);
124 $this->
ctrl->redirectByClass(
"ilobjtestgui",
"infoScreen");
130 $nextClass = $this->
ctrl->getNextClass($this);
133 switch ($nextClass) {
147 return 'man_scoring';
153 $this->tpl->setContent($table->getHTML());
159 $table->resetOffset();
160 $table->writeFilterToSession();
168 $table->resetOffset();
169 $table->resetFilter();
178 if (!$this->
getTestAccess()->checkScoreParticipantsAccessForActiveId($active_id)) {
179 ilObjTestGUI::accessViolationRedirect();
188 $user_id = $this->
object->_getUserIdFromActiveId($active_id);
189 $user_fullname = $this->
object->userLookupFullName($user_id,
false,
true);
190 $table_title = sprintf($this->
lng->txt(
'tst_pass_overview_for_participant'), $user_fullname);
191 $table->setTitle($table_title);
193 $passOverviewData = $this->service->getPassOverviewData($active_id);
194 $table->setData($passOverviewData[
'passes']);
196 $content_html .= $table->getHTML() .
'<br />';
198 if ($form === null) {
199 $question_gui_list = $this->service->getManScoringQuestionGuiList($active_id, $pass);
203 $content_html .= $form->getHTML();
205 $this->tpl->setContent($content_html);
212 if (!$this->
getTestAccess()->checkScoreParticipantsAccessForActiveId($active_id)) {
213 ilObjTestGUI::accessViolationRedirect();
218 $questionGuiList = $this->service->getManScoringQuestionGuiList($active_id, $pass);
221 $form->setValuesByPost();
223 if (!$form->checkInput()) {
224 $this->tpl->setOnScreenMessage(
'failure', sprintf($this->
lng->txt(
'tst_save_manscoring_failed'), $pass + 1));
229 $maxPointsByQuestionId = [];
230 $maxPointsExceeded =
false;
231 foreach ($questionGuiList as $questionId => $questionGui) {
232 $reachedPoints = $form->getItemByPostVar(
"question__{$questionId}__points")->getValue();
233 $maxPoints = $this->questioninfo->getMaximumPoints($questionId);
235 if ($reachedPoints > $maxPoints) {
236 $maxPointsExceeded =
true;
238 $form->getItemByPostVar(
"question__{$questionId}__points")->setAlert(sprintf(
239 $this->
lng->txt(
'tst_manscoring_maxpoints_exceeded_input_alert'),
244 $maxPointsByQuestionId[$questionId] = $maxPoints;
247 if ($maxPointsExceeded) {
248 $this->tpl->setOnScreenMessage(
'failure', sprintf($this->
lng->txt(
'tst_save_manscoring_failed'), $pass + 1));
253 foreach ($questionGuiList as $questionId => $questionGui) {
255 $reached_points = $this->
refinery->byTrying([
256 $this->
refinery->kindlyTo()->float(),
257 $this->
refinery->always($old_points)
258 ])->transform($form->getItemByPostVar(
"question__{$questionId}__points")?->getValue());
260 $finalized = (bool) $form->getItemByPostVar(
"{$questionId}__evaluated")?->getChecked();
263 if ($reached_points !== $old_points) {
268 $maxPointsByQuestionId[$questionId],
271 $this->
object->areObligationsEnabled(),
277 (
string) $form->getItemByPostVar(
"question__{$questionId}__feedback")->getValue(),
282 $this->
object->saveManualFeedback($active_id, (
int) $questionId, $pass, $feedback, $finalized,
true);
284 $notificationData[$questionId] = [
285 'points' => $reached_points,
'feedback' => $feedback
294 $manScoringDone = $form->getItemByPostVar(
"manscoring_done")->getChecked();
297 $manScoringNotify = $form->getItemByPostVar(
"manscoring_notify")->getChecked();
298 if ($manScoringNotify) {
300 $this->
object->_getUserIdFromActiveId($active_id),
301 $this->
object->getRefId()
305 'test_title' => $this->
object->getTitle(),
306 'test_pass' => $pass + 1,
307 'questions_gui_list' => $questionGuiList,
308 'questions_scoring_data' => $notificationData
311 $notification->send();
315 $scorer->setPreserveManualScores(
true);
316 $scorer->recalculateSolution($active_id, $pass);
318 if ($this->
object->getAnonymity() == 0) {
320 $name_real_or_anon = $user_name[
'firstname'] .
' ' . $user_name[
'lastname'];
322 $name_real_or_anon = $this->
lng->txt(
'anonymous');
324 $this->tpl->setOnScreenMessage(
'success', sprintf($this->
lng->txt(
'tst_saved_manscoring_successfully'), $pass + 1, $name_real_or_anon),
true);
325 if ($redirect ==
true) {
326 $this->
ctrl->redirect($this,
'showManScoringParticipantScreen');
340 if ($participant[
'active_id'] == $this->testrequest->raw(
'active_id')) {
341 $nextIndex = $index + 1;
348 $this->
ctrl->redirect($this,
'showManScoringParticipantScreen');
351 $this->
ctrl->redirectByClass(
"iltestscoringgui",
"showManScoringParticipantsTable");
358 $this->
ctrl->redirectByClass(
"iltestscoringgui",
"showManScoringParticipantsTable");
363 array $questionGuiList,
366 bool $initValues =
false 368 $this->
ctrl->setParameter($this,
'active_id', $active_id);
369 $this->
ctrl->setParameter($this,
'pass', $pass);
372 $form->setFormAction($this->
ctrl->getFormAction($this));
374 $form->setTitle(sprintf($this->
lng->txt(
'manscoring_results_pass'), $pass + 1));
375 $form->setTableWidth(
'100%');
377 $autosave_enabled = $this->
object->getAutosave();
378 $show_solutions_enabled = $this->
object->getShowSolutionFeedback();
379 foreach ($questionGuiList as $questionId => $questionGUI) {
380 $questionHeader = sprintf($this->
lng->txt(
'tst_manscoring_question_section_header'), $questionGUI->object->getTitleForHTMLOutput());
381 $questionSolution = $questionGUI->getSolutionOutput($active_id, $pass,
false,
false,
true,
false,
false,
true);
382 $bestSolution = $questionGUI->object->getSuggestedSolutionOutput();
384 $feedback = $this->
object->getSingleManualFeedback($active_id, $questionId, $pass);
387 if (isset($feedback[
'finalized_evaluation']) && $feedback[
'finalized_evaluation'] == 1) {
392 $sect->setTitle($questionHeader .
' [' . $this->
lng->txt(
'question_id_short') .
': ' . $questionGUI->object->getId() .
']');
393 $form->addItem($sect);
395 $cust =
new ilCustomInputGUI($this->
lng->txt(
'tst_manscoring_input_question_and_user_solution'));
396 $cust->setHtml($questionSolution);
397 $form->addItem($cust);
399 if ($autosave_enabled) {
400 $aresult_output = $questionGUI->getAutoSavedSolutionOutput(
406 $show_solutions_enabled,
411 if ($aresult_output) {
413 $cust->setHtml($aresult_output);
414 $form->addItem($cust);
418 $number_input_gui = new \ilNumberInputGUI($this->
lng->txt(
'tst_change_points_for_question'),
"question__{$questionId}__points");
419 $number_input_gui->allowDecimals(
true);
424 $number_input_gui->setDisabled($disabled);
426 $form->addItem($number_input_gui);
428 $nonedit =
new ilNonEditableValueGUI($this->
lng->txt(
'tst_manscoring_input_max_points_for_question'),
"question__{$questionId}__maxpoints");
430 $nonedit->setValue($this->questioninfo->getMaximumPoints($questionId));
432 $form->addItem($nonedit);
434 $area =
new ilTextAreaInputGUI($this->
lng->txt(
'set_manual_feedback'),
"question__{$questionId}__feedback");
435 $area->setUseRTE(
true);
440 $area->setDisabled($disabled);
442 $form->addItem($area);
450 if (strlen(trim($bestSolution))) {
452 $cust->setHtml($bestSolution);
453 $form->addItem($cust);
458 $sect->setTitle($this->
lng->txt(
'tst_participant'));
459 $form->addItem($sect);
470 $form->addCommandButton(
'saveManScoringParticipantScreen', $this->
lng->txt(
'save'));
471 $form->addCommandButton(
'saveReturnManScoringParticipantScreen', $this->
lng->txt(
'save_return'));
472 $form->addCommandButton(
'saveNextManScoringParticipantScreen', $this->
lng->txt(
'save_and_next'));
486 $participantStatusFilterValue = $table->getFilterItemByPostVar(
'participant_status')->getValue();
490 $participant_list->initializeFromDbRows(
491 $this->
object->getTestParticipantsForManualScoring($participantStatusFilterValue)
494 $filtered_participant_list = $participant_list->getAccessFilteredList(
495 $this->participant_access_filter->getScoreParticipantsUserFilter($this->ref_id)
498 $table->setData($filtered_participant_list->getParticipantsTableRows());
showManScoringParticipantScreen(ilPropertyFormGUI $form=null)
static _getParticipantId($active_id)
Get user id for active id.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
const TAB_ID_MANUAL_SCORING
buildSubTabs($active_sub_tab='man_scoring_by_qst')
static _lookupName(int $a_user_id)
lookup user name
applyManScoringParticipantsFilter()
__construct(ilObjTest $a_object)
ilTestScoringGUI constructor
static isManScoringDone(int $active_id)
buildManScoringParticipantForm(array $questionGuiList, int $active_id, int $pass, bool $initValues=false)
saveReturnManScoringParticipantScreen()
setTestAccess($testAccess)
executeCommand()
execute command
setValue(string $a_value)
const PART_FILTER_MANSCORING_NONE
static getSingleManualFeedback(int $active_id, int $question_id, int $pass)
static setManScoringDone(int $activeId, bool $manScoringDone)
static _getReachedPoints(int $active_id, int $question_id, int $pass)
static _mananuallyScoreableQuestionTypesExists()
Returns the fact wether manually scoreable question types exist or not.
showManScoringParticipantsTable()
static _getUsedHTMLTagsAsString(string $a_module="")
Returns a string of all allowed HTML tags for text editing.
saveManScoringParticipantScreen(bool $redirect=true)
const PART_FILTER_ALL_USERS
ilTestParticipantData $participantData
This class represents a text area property in a property form.
resetManScoringParticipantsFilter()
Service GUI class for tests.
sendManScoringParticipantNotification()
saveNextManScoringParticipantScreen()
static _setReachedPoints(int $active_id, int $question_id, float $points, float $maxpoints, int $pass, bool $manualscoring, bool $obligationsEnabled, ?int $test_id=null)
Sets the points, a learner has reached answering the question Additionally objective results are upda...
setAdditionalInformation(array $a_info)
buildManScoringParticipantsTable(bool $withData=false)
const PART_FILTER_MANSCORING_DONE
fetchPassParameter(int $active_id)
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)