Exercices: Fix loading quizzes of course on first time - refs BT#19279

pull/4105/head
Christian 4 years ago
parent 84f53a6a95
commit 868b12e3a0
  1. 62
      main/exercise/pending.php

@ -132,7 +132,40 @@ $htmlHeadXtra[] = '<script>
} }
$("#pending").submit(); $("#pending").submit();
}); });
$("select#course_id").on("change", function () {
var courseId = parseInt(this.value, 10);
updateExerciseList(courseId);
});
});
function updateExerciseList(courseId) {
if (courseId == 0) {
return;
}
var $selectExercise = $("select#exercise_id");
$selectExercise.empty();
$.get("'.api_get_self().'", {
a: "get_exercise_by_course",
course_id: courseId,
}, function (exerciseList) {
$("<option>", {
value: 0,
text: "'.get_lang('All').'"
}).appendTo($selectExercise);
if (exerciseList.length > 0) {
$.each(exerciseList, function (index, exercise) {
$("<option>", {
value: exercise.id,
text: exercise.text
}).appendTo($selectExercise);
}); });
$selectExercise.find("option[value=\''.$exerciseId.'\']").attr("selected",true);
}
$selectExercise.selectpicker("refresh");
}, "json");
}
</script>'; </script>';
if ($exportXls) { if ($exportXls) {
@ -404,35 +437,6 @@ $gridJs = Display::grid_js(
?> ?>
<script> <script>
function updateExerciseList(courseId) {
if (courseId == 0) {
return;
}
var $selectExercise = $("select#exercise_id");
$selectExercise.empty();
$.get("<?php echo api_get_self(); ?>", {
a: "get_exercise_by_course",
course_id: courseId,
}, function (exerciseList) {
$("<option>", {
value: 0,
text: "<?php echo get_lang('All'); ?>"
}).appendTo($selectExercise);
if (exerciseList.length > 0) {
$.each(exerciseList, function (index, exercise) {
$("<option>", {
value: exercise.id,
text: exercise.text
}).appendTo($selectExercise);
});
$selectExercise.find("option[value=\'<?php echo $exerciseId; ?>\']").attr("selected",true);
}
$selectExercise.selectpicker("refresh");
}, "json");
}
function exportExcel() function exportExcel()
{ {
var mya = $("#results").getDataIDs(); // Get All IDs var mya = $("#results").getDataIDs(); // Get All IDs

Loading…
Cancel
Save