Exercise: Fix error when quiz is created - refs BT#21013

pull/4874/head
christian 2 years ago
parent a1dee8b0a5
commit 205d898043
  1. 2
      public/main/exercise/admin.php
  2. 2
      public/main/exercise/exercise_reminder.php
  3. 2
      public/main/exercise/exercise_submit.php
  4. 8
      public/main/exercise/multiple_answer.class.php
  5. 5
      public/main/exercise/oral_expression.class.php
  6. 4
      public/main/exercise/question_admin.inc.php
  7. 2
      public/main/exercise/result.php
  8. 14
      public/main/inc/lib/exercise.lib.php
  9. 1
      src/CourseBundle/Entity/CQuiz.php

@ -275,7 +275,7 @@ if ('thisExercise' === $modifyIn) {
}
}
$htmlHeadXtra[] = api_get_build_js('exercise.js');
$htmlHeadXtra[] = api_get_build_js('legacy_exercise.js');
$template = new Template();
$templateName = $template->get_template('exercise/submit.js.tpl');

@ -58,7 +58,7 @@ if ($time_control) {
$htmlHeadXtra[] = $objExercise->showTimeControlJS($time_left);
}
$htmlHeadXtra[] = api_get_build_js('exercise.js');
$htmlHeadXtra[] = api_get_build_js('legacy_exercise.js');
$htmlHeadXtra[] = api_get_css_asset('pretty-checkbox/dist/pretty-checkbox.min.css');
$exe_id = 0;

@ -68,7 +68,7 @@ if ($showGlossary) {
//$htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.dateformat.min.js');
//$htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.epiclock.min.js');
//$htmlHeadXtra[] = api_get_js('epiclock/renderers/minute/epiclock.minute.js');
$htmlHeadXtra[] = api_get_build_js('exercise.js');
$htmlHeadXtra[] = api_get_build_js('legacy_exercise.js');
$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/css/hotspot.css">';
//$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js"></script>';
if ('true' === api_get_setting('exercise.quiz_prevent_copy_paste')) {

@ -75,10 +75,10 @@ class MultipleAnswer extends Question
for ($i = 1; $i <= $nb_answers; $i++) {
$form->addHtml('<tr>');
if (is_object($answer)) {
$defaults['answer['.$i.']'] = $answer->answer[$i];
$defaults['comment['.$i.']'] = $answer->comment[$i];
$defaults['weighting['.$i.']'] = float_format($answer->weighting[$i], 1);
$defaults['correct['.$i.']'] = $answer->correct[$i];
$defaults['answer['.$i.']'] = $answer->answer[$i] ?? '';
$defaults['comment['.$i.']'] = $answer->comment[$i] ?? '';
$defaults['weighting['.$i.']'] = isset($answer->weighting[$i]) ? float_format($answer->weighting[$i], 1) : 0;
$defaults['correct['.$i.']'] = $answer->correct[$i] ?? '';
} else {
$defaults['answer[1]'] = get_lang('Lack of Vitamin A');
$defaults['comment[1]'] = get_lang('The Vitamin A is responsible for...');

@ -97,8 +97,11 @@ class OralExpression extends Question
$variable = 'oral_expression_asset_'.$attempt->getQuestionId();
$asset = null;
$assetId = ChamiloSession::read($variable);
$asset = Container::getAssetRepository()->find(Uuid::fromRfc4122($assetId));
if (!empty($assetId)) {
$asset = Container::getAssetRepository()->find(Uuid::fromRfc4122($assetId));
}
if (null === $asset) {
return;

@ -75,8 +75,8 @@ if (is_object($objQuestion)) {
} else {
// New question
$page = 1;
$length = api_get_setting('exercise.question_pagination_length');
if (!empty($length)) {
$length = (int) api_get_setting('exercise.question_pagination_length');
if ($length > 0) {
$page = round($objExercise->getQuestionCount() / $length);
}
Display::addFlash(Display::return_message(get_lang('Item added')));

@ -68,7 +68,7 @@ if ($student_id === $current_user_id && ExerciseSignaturePlugin::exerciseHasSign
}
$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/css/hotspot.css">';
$htmlHeadXtra[] = api_get_build_js('exercise.js');
$htmlHeadXtra[] = api_get_build_js('legacy_exercise.js');
if ($show_headers) {
$interbreadcrumb[] = [

@ -5169,12 +5169,14 @@ EOT;
$additionalActions = api_get_setting('exercise.exercise_additional_teacher_modify_actions', true) ?: [];
$actions = [];
foreach ($additionalActions as $additionalAction) {
$actions[] = call_user_func(
$additionalAction,
$exerciseId,
$iconSize
);
if (is_array($additionalActions)) {
foreach ($additionalActions as $additionalAction) {
$actions[] = call_user_func(
$additionalAction,
$exerciseId,
$iconSize
);
}
}
return implode(PHP_EOL, $actions);

@ -171,6 +171,7 @@ class CQuiz extends AbstractResource implements ResourceInterface, ResourceShowC
$this->reviewAnswers = 0;
$this->randomByCategory = 0;
$this->displayCategoryName = 0;
$this->hideAttemptsTable = false;
$this->pageResultConfiguration = [];
$this->attempts = new ArrayCollection();
}

Loading…
Cancel
Save