diff --git a/classes/class.assStackQuestion.php b/classes/class.assStackQuestion.php index 1b041c98..b096b488 100644 --- a/classes/class.assStackQuestion.php +++ b/classes/class.assStackQuestion.php @@ -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); } diff --git a/classes/class.assStackQuestionGUI.php b/classes/class.assStackQuestionGUI.php index 51003fc7..ed4c3d42 100644 --- a/classes/class.assStackQuestionGUI.php +++ b/classes/class.assStackQuestionGUI.php @@ -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); @@ -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) { @@ -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; } diff --git a/classes/import/MoodleXML/class.assStackQuestionMoodleImport.php b/classes/import/MoodleXML/class.assStackQuestionMoodleImport.php index 06a2ad96..08db3d41 100644 --- a/classes/import/MoodleXML/class.assStackQuestionMoodleImport.php +++ b/classes/import/MoodleXML/class.assStackQuestionMoodleImport.php @@ -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; } } @@ -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); } diff --git a/classes/import/qti12/class.assStackQuestionImport.php b/classes/import/qti12/class.assStackQuestionImport.php index b4cd98bc..ce16fc35 100644 --- a/classes/import/qti12/class.assStackQuestionImport.php +++ b/classes/import/qti12/class.assStackQuestionImport.php @@ -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) { @@ -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) { diff --git a/classes/legacy/ui/question_authoring/class.assStackQuestionAuthoringGUI.php b/classes/legacy/ui/question_authoring/class.assStackQuestionAuthoringGUI.php index 31b9e8f3..3be8a59d 100644 --- a/classes/legacy/ui/question_authoring/class.assStackQuestionAuthoringGUI.php +++ b/classes/legacy/ui/question_authoring/class.assStackQuestionAuthoringGUI.php @@ -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'), @@ -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); diff --git a/classes/stack/cas/castext2/blocks/geogebra.block.php b/classes/stack/cas/castext2/blocks/geogebra.block.php index 6af6547d..14e14195 100644 --- a/classes/stack/cas/castext2/blocks/geogebra.block.php +++ b/classes/stack/cas/castext2/blocks/geogebra.block.php @@ -333,9 +333,9 @@ public function compile($format, $options): ?MP_Node { $r->items[] = new MP_String('