Skip to content

Commit

Permalink
Exercise: Fix delete question when it was imported from other exercis…
Browse files Browse the repository at this point in the history
…e in different course - refs GH#4555
  • Loading branch information
BorjaSanchezBeezNest committed Feb 6, 2023
1 parent 31635d1 commit fdb5df8
Showing 1 changed file with 23 additions and 29 deletions.
52 changes: 23 additions & 29 deletions main/exercise/question_list_admin.inc.php
Expand Up @@ -327,43 +327,37 @@ function loadEditor(button, questionId) {
['class' => 'btn btn-default btn-sm']
);
$delete_link = null;
if ($objExercise->edit_exercise_in_lp == true) {
$delete = false;
if ($objExercise->edit_exercise_in_lp) {
$delete = true;
$questionInOtherQuizs = true;
$results = Question::countQuizzesUsingQuestion($id);

if ($results > 1) {
$masterExerciseId = Question::getMasterQuizForQuestion($id);
if ($masterExerciseId == $exerciseId) {
$delete = true;
$questionInOtherQuizs = true;
} else {
if ($masterExerciseId !== $exerciseId) {
$questionInOtherQuizs = false;
}
} else {
$delete = true;
}

if ($delete) {
$delete_link = Display::url(
Display::return_icon(
'delete.png',
get_lang('RemoveFromTest'),
[],
ICON_SIZE_TINY
),
api_get_self().'?'.api_get_cidreq().'&'
.http_build_query([
'exerciseId' => $exerciseId,
'deleteQuestion' => $id,
'page' => $page,
]),
[
'id' => "delete_$id",
'class' => 'opener btn btn-default btn-sm',
'data-otherquizs' => $questionInOtherQuizs,
]
);
}
$delete_link = Display::url(
Display::return_icon(
'delete.png',
get_lang('RemoveFromTest'),
[],
ICON_SIZE_TINY
),
api_get_self().'?'.api_get_cidreq().'&'
.http_build_query([
'exerciseId' => $exerciseId,
'deleteQuestion' => $id,
'page' => $page,
]),
[
'id' => "delete_$id",
'class' => 'opener btn btn-default btn-sm',
'data-otherquizs' => $questionInOtherQuizs,
]
);
}

if ($limitTeacherAccess && !api_is_platform_admin()) {
Expand Down

0 comments on commit fdb5df8

Please sign in to comment.