iid);
if ($masterExerciseId != $exerciseId) {
$objQuestionTmp->delete($exerciseId);
} else {
$objQuestionTmp->delete();
}
} else {
$objQuestionTmp->delete($exerciseId);
}
// if the question has been removed from the exercise
if ($objExercise->removeFromList($deleteQuestion)) {
$nbrQuestions--;
}
}
// destruction of the Question object
unset($objQuestionTmp);
}
$ajax_url = api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?'.api_get_cidreq().'&exercise_id='.intval($exerciseId);
$addImageUrl = api_get_path(WEB_CODE_PATH).'inc/lib/elfinder/filemanager.php?add_image=1&'.api_get_cidreq();
?>
';
$category_list = TestCategory::getListOfCategoriesNameForTest($objExercise->iid, false);
if (is_array($questionList)) {
foreach ($questionList as $id) {
// To avoid warning messages.
if (!is_numeric($id)) {
continue;
}
/** @var Question $objQuestionTmp */
$objQuestionTmp = Question::read($id);
if (empty($objQuestionTmp)) {
continue;
}
$addImageLink = '';
if (api_get_configuration_value('allow_quick_question_description_popup')) {
$addImageLink = Display::url(
Display::return_icon(
'image.png',
get_lang('AddImage'),
[],
ICON_SIZE_TINY
),
'javascript:void(0);',
['class' => 'btn btn-default btn-sm ajax', 'onclick' => 'loadEditor(this, '.$id.')']
);
}
$clone_link = null;
if ($objExercise->edit_exercise_in_lp == true) {
$clone_link = Display::url(
Display::return_icon(
'cd.png',
get_lang('Copy'),
[],
ICON_SIZE_TINY
),
api_get_self().'?'.api_get_cidreq().'&clone_question='.$id.'&page='.$page,
['class' => 'btn btn-default btn-sm']
);
}
$edit_link = $objQuestionTmp->selectType() == CALCULATED_ANSWER && $objQuestionTmp->isAnswered()
? Display::span(
Display::return_icon(
'edit_na.png',
get_lang(
'QuestionEditionNotAvailableBecauseItIsAlreadyAnsweredHoweverYouCanCopyItAndModifyTheCopy'
),
[],
ICON_SIZE_TINY
),
['class' => 'btn btn-default btn-sm']
)
: Display::url(
Display::return_icon(
'edit.png',
get_lang('Modify'),
[],
ICON_SIZE_TINY
),
api_get_self().'?'.api_get_cidreq().'&'
.http_build_query([
'type' => $objQuestionTmp->selectType(),
'editQuestion' => $id,
'page' => $page,
]),
['class' => 'btn btn-default btn-sm']
);
$delete_link = null;
if ($objExercise->edit_exercise_in_lp == true) {
$delete = false;
$questionInOtherQuizs = true;
$results = Question::countQuizzesUsingQuestion($id);
if ($results > 1) {
$masterExerciseId = Question::getMasterQuizForQuestion($id);
if ($masterExerciseId == $exerciseId) {
$delete = true;
$questionInOtherQuizs = true;
} else {
$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,
]
);
}
}
if ($limitTeacherAccess && !api_is_platform_admin()) {
$delete_link = '';
}
$btnActions = implode(
PHP_EOL,
[$edit_link, $clone_link, $addImageLink, $delete_link]
);
$title = Security::remove_XSS(strip_tags($objQuestionTmp->selectTitle()));
$move = ' ';
if ($allowQuestionOrdering) {
$move = Display::returnFontAwesomeIcon('arrows moved', 1, true);
}
// Question name
$questionName =
'
'.$move.' '.cut($title, 42).'
';
// Question type
$typeImg = $objQuestionTmp->getTypePicture();
$typeExpl = $objQuestionTmp->getExplanation();
$questionType = Display::return_icon($typeImg, $typeExpl);
// Question category
$txtQuestionCat = Security::remove_XSS(
TestCategory::getCategoryNameForQuestion($objQuestionTmp->iid)
);
if (empty($txtQuestionCat)) {
$txtQuestionCat = '-';
}
// Question level
$txtQuestionLevel = $objQuestionTmp->getLevel();
if (empty($objQuestionTmp->level)) {
$txtQuestionLevel = '-';
}
$questionLevel = $txtQuestionLevel;
// Question score
$questionScore = $objQuestionTmp->selectWeighting();
echo '
';
unset($objQuestionTmp);
}
}
echo '
'; //question list div
} else {
echo Display::return_message(get_lang('NoQuestion'), 'warning');
}
}