Skip to content

Commit

Permalink
Version 8.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Saaweel committed Aug 8, 2024
1 parent 02d39d1 commit 2f3d4a9
Show file tree
Hide file tree
Showing 12 changed files with 132 additions and 34 deletions.
4 changes: 3 additions & 1 deletion classes/class.assStackQuestion.php
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,9 @@ public function loadFromDb(int $question_id): void
$prt_data = $prt_from_db_array[$name];

$total_value += $prt_data->value;
$all_formative = false;
if ($prt_data->value > 0) {
$all_formative = false;
}
} else {
$this->loadStandardPRT($name);
}
Expand Down
66 changes: 59 additions & 7 deletions classes/class.assStackQuestionGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,6 @@ public function getPreview($show_question_only = false, $showInlineFeedback = fa

$question_preview = StackRenderIlias::renderQuestion($attempt_data, $display_options);

//Returns output (with page if needed)
if (!$show_question_only) {
// get page object output
$question_preview = $this->getILIASPage($question_preview);
}

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

return assStackQuestionUtils::_getLatex($question_preview);
Expand Down Expand Up @@ -645,7 +639,9 @@ public function writeQuestionSpecificPostData()

foreach ($prts_array as $name => $prt_data) {
$total_value += (float) $prt_data->value;
$all_formative = false;
if ((float) $prt_data->value > 0) {
$all_formative = false;
}
}

if ($prts_array && !$all_formative && $total_value < 0.0000001) {
Expand Down Expand Up @@ -888,6 +884,62 @@ public function questionCheck(): bool
assStackQuestionDB::_deleteStackPrts($this->object->getId(), $prt_name);

$tpl->setOnScreenMessage('success', "prt deleted", true);
return true;
}

if (isset($_POST['cmd']['save']['change_prt_name_' . $prt_name])) {
$new_prt_name = $_POST['prt_' . $prt_name . '_name'];

$new_prt_name = preg_replace('/[^A-Za-z0-9]/', '', $new_prt_name);

if ($prt_name != $new_prt_name && !isset($this->object->prts[$new_prt_name])) {
$new_prts = $this->object->prts;

$prt = $new_prts[$prt_name];

$new_prt_data = new stdClass();

$new_prt_data->name = $new_prt_name;
$new_prt_data->value = $prt->get_value();
$new_prt_data->autosimplify = $prt->isSimplify();
$new_prt_data->feedbackvariables = $prt->get_feedbackvariables_keyvals();
$new_prt_data->firstnodename = $prt->get_first_node();
$new_prt_data->nodes = $prt->get_nodes();

$new_prts[$new_prt_name] = new stack_potentialresponse_tree_lite($new_prt_data, $prt->get_value());

unset($new_prts[$prt_name]);

$current_question_text = $this->object->getQuestion();
$new_question_text = str_replace("[[feedback:" . $prt_name . "]]", "[[feedback:" . $new_prt_name . "]]", $current_question_text);
$this->specific_post_data["question_text"] = $new_question_text;

$current_specific_feedback = $this->object->specific_feedback;
$new_specific_feedback = str_replace("[[feedback:" . $prt_name . "]]", "[[feedback:" . $new_prt_name . "]]", $current_specific_feedback);
$this->specific_post_data["options_specific_feedback"] = $new_specific_feedback;

$this->object->prts = $new_prts;

assStackQuestionDB::_changePrtName($this->object->getId(), $prt_name, $new_prt_name);

foreach ($this->specific_post_data as $key => $value) {
if (strpos($key, 'prt_' . $prt_name) !== false) {
$new_key = str_replace('prt_' . $prt_name, 'prt_' . $new_prt_name, $key);

if (strpos($new_key, '_answernote') !== false) {
$this->specific_post_data[$new_key] = str_replace($prt_name, $new_prt_name, $value);
} else {
$this->specific_post_data[$new_key] = $value;
}

unset($this->specific_post_data[$key]);
}
}

$tpl->setOnScreenMessage('success', "prt name changed", true);
return true;
}

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,9 @@ public function loadFromMoodleXML(SimpleXMLElement $question): bool
$allformative = true;

foreach ($question->prt as $prt_data) {
if ($prt_data->feedbackstyle > 0) {
$totalvalue += $prt_data->value;
$totalvalue += $prt_data->value;

if ($prt_data->value > 0) {
$allformative = false;
}
}
Expand Down Expand Up @@ -388,11 +389,11 @@ public function loadFromMoodleXML(SimpleXMLElement $question): bool
$prt_data = $temp_prt_data;

$prtvalue = 0;

if (!$allformative) {
$prtvalue = $prt_data->value / $totalvalue;
}


$this->getQuestion()->prts[(string) $prt_data->name] = new stack_potentialresponse_tree_lite($prt_data, $prtvalue);
}

Expand Down
8 changes: 5 additions & 3 deletions classes/import/qti12/class.assStackQuestionImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,14 @@ public function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$ques
$node->truepenalty = $xml_node->getTruePenalty();
$node->trueanswernote = $xml_node->getTrueAnswerNote();
$node->truefeedback = $xml_node->getTrueFeedback();
$node->truefeedbackformat = $xml_node->getTrueFeedbackFormat();
$node->truefeedbackformat = 0;

$node->falsescore = $xml_node->getFalseScore();
$node->falsescoremode = $xml_node->getFalseScoreMode();
$node->falsepenalty = $xml_node->getFalsePenalty();
$node->falseanswernote = $xml_node->getFalseAnswerNote();
$node->falsefeedback = $xml_node->getFalseFeedback();
$node->falsefeedbackformat = $xml_node->getFalseFeedbackFormat();
$node->falsefeedbackformat = 0;

$prt_data->nodes[$node->nodename] = $node;
} catch (stack_exception $e) {
Expand All @@ -252,7 +252,9 @@ public function fromXML(&$item, $questionpool_id, &$tst_id, &$tst_object, &$ques

foreach ($prts_array as $name => $prt_data) {
$total_value += (float) $prt_data->value;
$all_formative = false;
if ((float) $prt_data->value > 0) {
$all_formative = false;
}
}

foreach ($prts_array as $name => $prt_data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ public function getInputPart(stack_input $input)
$input_type->setOptions(array("algebraic" => $this->getPlugin()->txt('input_type_algebraic'),
"boolean" => $this->getPlugin()->txt('input_type_boolean'),
"matrix" => $this->getPlugin()->txt('input_type_matrix'),
"varmatrix" => $this->getPlugin()->txt('input_type_varmatrix'),
"singlechar" => $this->getPlugin()->txt('input_type_singlechar'),
"textarea" => $this->getPlugin()->txt('input_type_textarea'),
"checkbox" => $this->getPlugin()->txt('input_type_checkbox'),
Expand Down Expand Up @@ -602,21 +603,29 @@ public function getPRTPart(stack_potentialresponse_tree_lite $prt)

//Add general settings
//Creation of properties of this part
if ($prt_name == 'new_prt') {
$prt_name_input = new ilTextInputGUI($this->getPlugin()->txt('prt_name'), 'prt_' . $prt_name . '_name');
} else {
$prt_name_input = new ilNonEditableValueGUI($this->getPlugin()->txt('prt_name'), 'prt_' . $prt_name . '_name');
}
$prt_name_input->setInfo($this->getPlugin()->txt('prt_name_info'));
$prt_name_input->setRequired(TRUE);

//If new question, name first prt directly as prt1
if ($this->new_question == TRUE) {
$prt_name_input->setValue("prt1");
} else {
$prt_name_input->setValue($prt_name);
}
$settings_column->addFormProperty($prt_name_input);
$prt_name_input = new ilTextInputGUI($this->getPlugin()->txt('prt_name'), 'prt_' . $prt_name . '_name');
$prt_name_input->setInfo($this->getPlugin()->txt('prt_name_info'));
$prt_name_input->setRequired(TRUE);
$prt_name_input->setMaxLength(20);

if ($this->new_question == TRUE) {
$prt_name_input->setValue("prt1");
} else {
$prt_name_input->setValue($prt_name);
}

$settings_column->addFormProperty($prt_name_input);

if ($prt_name != 'new_prt') {
$change_prt_name = new ilButtonFormProperty($this->getPlugin()->txt('change_prt_name'), 'change_prt_name_' . $prt_name);
$change_prt_name->setAction('change_prt_name_' . $prt_name);
$change_prt_name->setCommand('save');

$settings_column->addFormProperty($change_prt_name);
} else {
$settings_column->addFormProperty($prt_name_input);
}

$delete_prt = new ilButtonFormProperty($this->getPlugin()->txt('delete_prt'), 'delete_full_prt_' . $prt_name);
$delete_prt->setAction('delete_full_prt_' . $prt_name);
Expand Down
4 changes: 2 additions & 2 deletions classes/stack/cas/castext2/blocks/geogebra.block.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,9 @@ public function compile($format, $options): ?MP_Node {
$r->items[] = new MP_String('<div style="' . $style .
'"><div class="geogebrabox" id="geogebrabox" style="width:100%;height:100%;"></div></div><script type="module">');
// For binding we need to import the binding libraries.
$r->items[] = new MP_String("\nimport {stack_js} from '" . stack_cors_link('stackjsiframe.min.js') . "';\n");
$r->items[] = new MP_String("\nimport stack_js from '" . castext2_parser_utils::stack_cors_link('stackjsiframe.min.js') . "';\n");
// TODO: minify.
$r->items[] = new MP_String("import {stack_geogebra} from '" . stack_cors_link('stackgeogebra.js') . "';\n");
$r->items[] = new MP_String("import stack_geogebra from '" . castext2_parser_utils::stack_cors_link('stackgeogebra.js') . "';\n");

// Lets define the common bits of code.
$commonprecode = 'var presetparams = {"id":"applet","appName":"classic","width":800,"height": 600,' .
Expand Down
28 changes: 26 additions & 2 deletions classes/utils/class.assStackQuestionDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ private static function _saveStackPRTs(assStackQuestion $question, string $purpo
"id" => array("integer", $db->nextId('xqcas_prts')),
"question_id" => array("integer", $question_id),
"name" => array("text", $question->prts[$prt_name]->get_name()),
"value" => array("text", $question->prts[$prt_name]->get_value() == null ? "1.0" : $question->prts[$prt_name]->get_value()),
"value" => array("text", $question->prts[$prt_name]->get_value() === null ? "1.0" : $question->prts[$prt_name]->get_value()),
"auto_simplify" => array("integer", $question->prts[$prt_name]->isSimplify() == null ? 0 : $question->prts[$prt_name]->isSimplify()),
"feedback_variables" => array("clob", $question->prts[$prt_name]->get_feedbackvariables_keyvals() == null ? "" : $question->prts[$prt_name]->get_feedbackvariables_keyvals()),
"first_node_name" => array("text", $question->prts[$prt_name]->get_first_node() == null ? '-1' : $question->prts[$prt_name]->get_first_node()),
Expand All @@ -689,7 +689,7 @@ private static function _saveStackPRTs(assStackQuestion $question, string $purpo
array(
"question_id" => array("integer", $question_id),
"name" => array("text", $question->prts[$prt_name]->get_name()),
"value" => array("text", $question->prts[$prt_name]->get_value() == null ? "1.0" : $question->prts[$prt_name]->get_value()),
"value" => array("text", $question->prts[$prt_name]->get_value() === null ? "1.0" : $question->prts[$prt_name]->get_value()),
"auto_simplify" => array("integer", $question->prts[$prt_name]->isSimplify() == null ? 0 : $question->prts[$prt_name]->isSimplify()),
"feedback_variables" => array("clob", $question->prts[$prt_name]->get_feedbackvariables_keyvals() == null ? "" : $question->prts[$prt_name]->get_feedbackvariables_keyvals()),
"first_node_name" => array("text", $question->prts[$prt_name]->get_first_node() == null ? '-1' : $question->prts[$prt_name]->get_first_node()),
Expand Down Expand Up @@ -1198,6 +1198,30 @@ public static function _deleteStackPrts(int $question_id, string $prt_name = '')
}
}

/**
* @param int $question_id
* @param string $old_prt_name
* @param string $new_prt_name
* @return bool
*/
public static function _changePrtName(int $question_id, string $old_prt_name, string $new_prt_name): bool
{
global $DIC;
$db = $DIC->database();
$query = /** @lang text */
'UPDATE xqcas_prts SET name = ' . $db->quote($new_prt_name, 'text') . ' WHERE question_id = ' . $db->quote($question_id, 'integer') . ' AND name = ' . $db->quote($old_prt_name, 'text');

$query_nodes = /** @lang text */
'UPDATE xqcas_prt_nodes SET prt_name = ' . $db->quote($new_prt_name, 'text') . ' WHERE question_id = ' . $db->quote($question_id, 'integer') . ' AND prt_name = ' . $db->quote($old_prt_name, 'text');


if ($db->manipulate($query) && $db->manipulate($query_nodes)) {
return true;
} else {
return false;
}
}

/**
* @param int $question_id
* @param string $prt_name
Expand Down
2 changes: 2 additions & 0 deletions classes/utils/class.assStackQuestionInitialization.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ function get_config($section = 'qtype_stack')
$configs->stackmaximaversion = "2023121100";
$configs->version = "2023121100";

$configs->geogebrabaseurl = $saved_config['geogebra_base_url'] ?? '';

return $configs;
}
}
Expand Down
4 changes: 3 additions & 1 deletion classes/utils/class.assStackQuestionUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,9 @@ public static function _arrayToQuestion(array $array, assStackQuestion $question

foreach ($prt_from_array as $name => $prt_data) {
$total_value += $prt_data->value;
$all_formative = false;
if ($prt_data->value > 0) {
$all_formative = false;
}
}

if ($prt_from_array && !$all_formative && $total_value < 0.0000001) {
Expand Down
2 changes: 2 additions & 0 deletions lang/ilias_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ input_type_info#:#Typ des Eingabeelements, z.B. Formularfeld, Wahr/Falsch, mehrz
input_type_algebraic#:#Algebraische Eingabe
input_type_boolean#:#Wahr/Falsch
input_type_matrix#:#Matrix
input_type_varmatrix#:#Variable Matrix
input_type_singlechar#:#Einzelzeichen
input_type_textarea#:#Mehrzeilig
input_box_size#:#Eingabebreite
Expand Down Expand Up @@ -520,6 +521,7 @@ add_new_prt#:#Neuer Rückmeldebaum (PRT)
add_new_node#:#Neuer Knoten
delete_node#:#Lösche Knoten
delete_prt#:#Lösche Rückmeldebaum
change_prt_name#:#Ändere Rückmeldebaum-Namen
authoring_points_info#:#Die Gesamtpunktzahl der Frage können Sie unter "Bewertung" festlegen.
authoring_input_creation_info#:#Um ein neues Eingabefeld anzulegen, geben Sie im Fragetext die Platzhalter "[[input:Eingabename]]" und "[[validation:Eingabename]]" ein. Um es zu löschen, löschen Sie die Platzhalter im Fragentext.
input_hint#:#Hinweis
Expand Down
2 changes: 2 additions & 0 deletions lang/ilias_en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ input_type_info#:#This determines the type of the input element, e.g. form field
input_type_algebraic#:#Algebraic input
input_type_boolean#:#True/False
input_type_matrix#:#Matrix
input_type_varmatrix#:#Variable matrix
input_type_singlechar#:#Single character
input_type_textarea#:#Text area
input_box_size#:#Input box size
Expand Down Expand Up @@ -511,6 +512,7 @@ add_new_prt#:#New Potential response Tree
add_new_node#:#New Node
delete_node#:#Delete node
delete_prt#:#Delete Potential response Tree
change_prt_name#:#Change Potential response Tree name
authoring_points_info#:#To set the total points of the question, go to label Scoring.
authoring_input_creation_info#:#To create new inputs just type on the question text the placeholder: "[[input:your_input_name]]" and "[[validation:your_input_name]]", to delete an input just delete the input placeholder from question text.
input_hint#:#Hint
Expand Down
2 changes: 1 addition & 1 deletion plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

$id = "xqcas";

$version = "8.6.10";
$version = "8.7.0";

$ilias_min_version = "8.00";
$ilias_max_version = "8.999";
Expand Down

0 comments on commit 2f3d4a9

Please sign in to comment.