From bdac1544e2e2704bb882b9886fdc418f612465de Mon Sep 17 00:00:00 2001 From: christianbeeznest <84335353+christianbeeznest@users.noreply.github.com> Date: Tue, 7 Feb 2023 10:59:59 -0500 Subject: [PATCH 1/2] Exercise: AI helper plugin: default visibility now hidden, default results display is now to show answers, default score is now number of questions - refs GH#4589 Author: @christianbeeznest --- .../export/aiken/aiken_import.inc.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/main/exercise/export/aiken/aiken_import.inc.php b/main/exercise/export/aiken/aiken_import.inc.php index ea0d5c0a39..1f90bbacbe 100755 --- a/main/exercise/export/aiken/aiken_import.inc.php +++ b/main/exercise/export/aiken/aiken_import.inc.php @@ -89,6 +89,7 @@ function generateAikenForm() var nroQ = parseInt($("[name=\'nro_questions\']").val()); var qType = $("[name=\'question_type\']").val(); var valid = (quizName != \'\' && nroQ > 0); + var qWeight = 1; if (valid) { btnGenerate.attr("disabled", true); @@ -106,6 +107,7 @@ function generateAikenForm() if (data.success && data.success == true) { $("#aiken-area").show(); $("#textarea-aiken").text(data.text); + $("input[name=\'ai_total_weight\']").val(nroQ * qWeight); $("#textarea-aiken").focus(); } else { alert("'.get_lang('NoSearchResults').'. '.get_lang('PleaseTryAgain').'"); @@ -136,7 +138,7 @@ function generateAikenForm() 'style' => 'width: 100%; height: 250px;', ] ); - $form->addElement('number', 'total_weight', get_lang('TotalWeight')); + $form->addElement('number', 'ai_total_weight', get_lang('TotalWeight')); $form->addButtonImport(get_lang('Import'), 'submit_aiken_generated'); $form->addHtml(''); @@ -230,6 +232,7 @@ function aikenImportExercise($file = null, $request = []) // set some default values for the new exercise $exerciseInfo['name'] = preg_replace('/.(zip|txt)$/i', '', $file); + $exerciseInfo['total_weight'] = !empty($_POST['total_weight']) ? (int) ($_POST['total_weight']) : 20; $exerciseInfo['question'] = []; // if file is not a .zip, then we cancel all @@ -282,6 +285,7 @@ function aikenImportExercise($file = null, $request = []) } elseif (!empty($request)) { // The import is from aiken generated in textarea. $exerciseInfo['name'] = $request['quiz_name']; + $exerciseInfo['total_weight'] = !empty($_POST['ai_total_weight']) ? (int) ($_POST['ai_total_weight']) : 20; $exerciseInfo['question'] = []; setExerciseInfoFromAikenText($request['aiken_format'], $exerciseInfo); } @@ -290,6 +294,8 @@ function aikenImportExercise($file = null, $request = []) if (!empty($exerciseInfo)) { $exercise = new Exercise(); $exercise->exercise = $exerciseInfo['name']; + $exercise->disable(); // Invisible by default + $exercise->updateResultsDisabled(0); // Auto-evaluation mode: show score and expected answers $exercise->save(); $lastExerciseId = $exercise->selectId(); $tableQuestion = Database::get_course_table(TABLE_QUIZ_QUESTION); @@ -385,6 +391,15 @@ function aikenImportExercise($file = null, $request = []) my_delete($baseWorkDir.$uploadPath); } + // Invisible by default + api_item_property_update( + api_get_course_info(), + TOOL_QUIZ, + $lastExerciseId, + 'invisible', + api_get_user_id() + ); + return $lastExerciseId; } } @@ -496,7 +511,7 @@ function setExerciseInfoFromAikenText($aikenText, &$exerciseInfo) } $totalQuestions = count($exerciseInfo['question']); - $totalWeight = !empty($_POST['total_weight']) ? (int) ($_POST['total_weight']) : 20; + $totalWeight = (int) $exerciseInfo['total_weight']; foreach ($exerciseInfo['question'] as $key => $question) { if (!isset($exerciseInfo['question'][$key]['weighting'])) { continue; From 2d887e8b985e71712052297de3ac4284671a3080 Mon Sep 17 00:00:00 2001 From: christianbeeznest <84335353+christianbeeznest@users.noreply.github.com> Date: Tue, 7 Feb 2023 11:01:32 -0500 Subject: [PATCH 2/2] Maintenance: Fix missing learning paths when importing course - refs GH#4584 Author: @christianbeeznest --- .../CourseBundle/Component/CourseCopy/CourseRestorer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Chamilo/CourseBundle/Component/CourseCopy/CourseRestorer.php b/src/Chamilo/CourseBundle/Component/CourseCopy/CourseRestorer.php index b0887ad2a8..49ce0c28a6 100644 --- a/src/Chamilo/CourseBundle/Component/CourseCopy/CourseRestorer.php +++ b/src/Chamilo/CourseBundle/Component/CourseCopy/CourseRestorer.php @@ -2949,7 +2949,7 @@ class CourseRestorer 'debug' => self::DBUTF8($lp->debug), 'theme' => '', 'session_id' => $session_id, - 'prerequisite' => $lp->prerequisite, + 'prerequisite' => (int) $lp->prerequisite, 'hide_toc_frame' => self::DBUTF8(isset($lp->hideTableOfContents) ? $lp->hideTableOfContents : 0), 'subscribe_users' => self::DBUTF8(isset($lp->subscribeUsers) ? $lp->subscribeUsers : 0), 'seriousgame_mode' => 0,