Skip to content

Commit

Permalink
feature: Debug info + delete all variants button
Browse files Browse the repository at this point in the history
  • Loading branch information
Saaweel committed Jul 31, 2024
1 parent 944ca23 commit 02d39d1
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 3 deletions.
47 changes: 46 additions & 1 deletion classes/class.assStackQuestionGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,9 @@ public function getPreview($show_question_only = false, $showInlineFeedback = fa
$question_preview = $this->getILIASPage($question_preview);
}

return assStackQuestionUtils::_getLatex($question_preview);
$question_preview .= StackRenderIlias::renderQuestionVariables(StackRandomisationIlias::getRandomisationData($this->object, $this->object->getSeed()));

return assStackQuestionUtils::_getLatex($question_preview);
}

/**
Expand Down Expand Up @@ -1152,6 +1154,8 @@ public function setQuestionTabs():void
'runAllTestsForAllVariants',
'addCustomTestForm',
'addStandardTest',
'confirmDeleteAllVariants',
'deleteAllVariants',
'editTestcases',
'deleteUnitTest',
'checkPrtPlaceholders'
Expand Down Expand Up @@ -1240,6 +1244,8 @@ public function getLearningModuleTabs()
'runAllTestsForAllVariants',
'addCustomTestForm',
'addStandardTest',
'confirmDeleteAllVariants',
'deleteAllVariants',
'editTestcases',
'deleteUnitTest',
'checkPrtPlaceholders'
Expand Down Expand Up @@ -2018,6 +2024,45 @@ public function addStandardTest(): void
$this->randomisationAndSecurity();
}

/**
* Called to delete all seeds
*/
public function confirmDeleteAllVariants(): void
{
global $DIC, $tpl;
$tabs = $DIC->tabs();

$tabs->activateTab('edit_properties');
$tabs->activateSubTab('randomisation_and_security');

$content = $DIC->ui()->renderer()->render($DIC->ui()->factory()->messageBox()->confirmation($this->object->getPlugin()->txt('ui_author_randomisation_confirm_delete_all_seeds')));

$content .= $DIC->ui()->renderer()->render($DIC->ui()->factory()->button()->standard($DIC->language()->txt("yes"), $this->ctrl->getLinkTarget($this, "deleteAllVariants")));
$content .= $DIC->ui()->renderer()->render($DIC->ui()->factory()->button()->standard($DIC->language()->txt("no"), $this->ctrl->getLinkTarget($this, "randomisationAndSecurity")));

$tpl->setContent($content);
}

/**
* Called to delete all seeds
*/
public function deleteAllVariants(): void
{
global $DIC, $tpl;
$tabs = $DIC->tabs();

$tabs->activateTab('edit_properties');
$tabs->activateSubTab('randomisation_and_security');

assStackQuestionDB::_deleteStackSeeds($this->object->getId());

$tpl->setOnScreenMessage('success',
$this->object->getPlugin()->txt('ui_author_randomisation_all_seeds_deleted'),
true);

$this->randomisationAndSecurity();
}

/**
* @throws stack_exception
* @throws StackException
Expand Down
44 changes: 44 additions & 0 deletions classes/platform/ilias/StackRenderIlias.php
Original file line number Diff line number Diff line change
Expand Up @@ -462,5 +462,49 @@ public static function _renderValidationButton(int $question_id, string $input_n
return "<button class=\"xqcas btn btn-default\" name=\"cmd[xqcas_" . $question_id . '_' . $input_name . "]\"><span class=\"glyphicon glyphicon-ok\" aria-hidden=\"true\"></span></button>";
}

public static function renderQuestionVariables(array $randomisation_data): string
{
global $DIC;
$factory = $DIC->ui()->factory();
$renderer = $DIC->ui()->renderer();
$language = $DIC->language();

$active_variant_question_variables = "Not found";
$active_variant_feedback_variables = "Not found";

if (isset($randomisation_data[""])) {
$active_variant_question_variables = $randomisation_data[""]["question_variables"];
$active_variant_feedback_variables = $randomisation_data[""]["feedback_variables"];
}

$randomisation = "";

if (trim($active_variant_question_variables) != "") {
$randomisation = "<strong>" . $language->txt("qpl_qst_xqcas_debug_info_question_variables") . "</strong>";
$randomisation .= assStackQuestionUtils::parseToHTMLWithoutLatex($active_variant_question_variables);
}

if (trim($active_variant_feedback_variables) != "") {
if ($randomisation != "") {
$randomisation .= $renderer->render($factory->divider()->horizontal());
}

$randomisation .= "<strong>" . $language->txt("qpl_qst_xqcas_debug_info_feedback_variables") . "</strong>";
$randomisation .= assStackQuestionUtils::parseToHTMLWithoutLatex($active_variant_feedback_variables);
}

if ($randomisation != "") {
if (isset($randomisation_data[""]["seed"])) {
$randomisation .= $renderer->render($factory->divider()->horizontal()) . "<strong>Seed: </strong>" . $randomisation_data[""]["seed"];
}

$panel = $factory->panel()->standard($language->txt("qpl_qst_xqcas_debug_info_message"), $factory->legacy(
$randomisation
));

return $renderer->render($panel);
} else {
return "";
}
}
}
3 changes: 3 additions & 0 deletions classes/ui/author/class.RandomisationAndSecurityUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ private function getCurrentActiveVariantPanelUIComponent(bool $uses_randomisatio
$array_of_actions[] = $this->factory->button()->shy(
$this->language->txt("qpl_qst_xqcas_ui_author_randomisation_add_standard_test_button_text"),
$this->control->getLinkTargetByClass("assstackquestiongui", "addStandardTest"));
$array_of_actions[] = $this->factory->button()->shy(
$this->language->txt("qpl_qst_xqcas_ui_author_randomisation_delete_all_variants_action_text"),
$this->control->getLinkTargetByClass("assstackquestiongui", "confirmDeleteAllVariants"));

//Actions for the currently active variant
$current_active_variant_panel_actions = $this->factory->dropdown()->standard($array_of_actions);
Expand Down
8 changes: 7 additions & 1 deletion lang/ilias_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ ui_author_randomisation_no_variants_generate_new_variants_action_text#:#10 neue
ui_author_randomisation_add_standard_test_title#:#Automatisch-Testfall (Überprüft, ob die Musterantwort als korrekt bewertet wird)
ui_author_randomisation_add_standard_test_description#:#Einen Automatisch-Testfall hinzufügen
ui_author_randomisation_add_standard_test_button_text#:#Automatisch-Testfall hinzufügen
ui_author_randomisation_delete_all_variants_action_text#:#Alle Varianten löschen
ui_author_randomisation_all_seeds_deleted#:#Alle Seeds wurden gelöscht
ui_author_randomisation_confirm_delete_all_seeds#:#Möchten Sie wirklich alle Seeds löschen?
ui_author_randomisation_standard_unit_test_case_added#:#Standard-Einheitstestfall hinzugefügt
ui_author_randomisation_active_variant_panel_title#:#Aktive Variante für Autoren bei Vorschau und Einheitstests
ui_author_randomisation_deployed_variants_panel_title#:#Varianten der Frage für Studenten in Tests
Expand Down Expand Up @@ -682,4 +685,7 @@ page_editor_compatibility_info#:#Bitte beachten Sie, dass Änderungen, die über
matrix_syntax_error#:#Ihre Antwort enthält Syntaxfehler.
placeholder#:#Platzhalter
value#:#Wert
hint_mode#:#Hinweis-Modus
hint_mode#:#Hinweis-Modus
debug_info_message#:#Debug-Informationen (wird in Tests nicht angezeigt)
debug_info_question_variables#:#Fragevariablen
debug_info_feedback_variables#:#Feedback-Variablen
8 changes: 7 additions & 1 deletion lang/ilias_en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ ui_author_randomisation_no_variants_generate_new_variants_action_text#:#Generate
ui_author_randomisation_add_standard_test_title#:#Standard testcase (Checks that model answer is evaluated as correct)
ui_author_randomisation_add_standard_test_description#:#Add a standard testcase
ui_author_randomisation_add_standard_test_button_text#:#Add standard testcase
ui_author_randomisation_delete_all_variants_action_text#:#Delete all variants
ui_author_randomisation_all_seeds_deleted#:#All seeds have been deleted
ui_author_randomisation_confirm_delete_all_seeds#:#Are you sure you want to delete all seeds?
ui_author_randomisation_standard_unit_test_case_added#:#Standard unit test case added
ui_author_randomisation_active_variant_panel_title#:#Active variant for authors at preview and unit tests
ui_author_randomisation_deployed_variants_panel_title#:#Question's variants for students in tests
Expand Down Expand Up @@ -671,4 +674,7 @@ page_editor_compatibility_info#:#Please be aware that any edits made via the ILI
matrix_syntax_error#:#Your answer contains syntax errors.
placeholder#:#Placeholder
value#:#Value
hint_mode#:#Hint mode
hint_mode#:#Hint mode
debug_info_message#:#Debug information (not shown to the students in Tests)
debug_info_question_variables#:#Question variables
debug_info_feedback_variables#:#Feedback variables

0 comments on commit 02d39d1

Please sign in to comment.