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); ?> '; $token = Security::get_token(); //deletes a session when using don't know question type (ugly fix) Session::erase('less_answer'); // If we are in a test $inATest = isset($exerciseId) && $exerciseId > 0; if (!$inATest) { echo Display::return_message(get_lang('ChoiceQuestionType'), 'warning'); } else { if ($nbrQuestions) { // In the building exercise mode show question list ordered as is. $objExercise->setCategoriesGrouping(false); // In building mode show all questions not render by teacher order. $objExercise->questionSelectionType = EX_Q_SELECTION_ORDERED; $allowQuestionOrdering = true; $showPagination = api_get_configuration_value('show_question_pagination'); if (!empty($showPagination) && $nbrQuestions > $showPagination) { $length = api_get_configuration_value('question_pagination_length'); $url = api_get_self().'?'.api_get_cidreq(); // Use pagination for exercise with more than 200 questions. $allowQuestionOrdering = false; $start = ($page - 1) * $length; $questionList = $objExercise->getQuestionForTeacher($start, $length); $paginator = new Knp\Component\Pager\Paginator(); $pagination = $paginator->paginate([]); $pagination->setTotalItemCount($nbrQuestions); $pagination->setItemNumberPerPage($length); $pagination->setCurrentPageNumber($page); $pagination->renderer = function ($data) use ($url) { $render = ''; return $render; }; echo $pagination; } else { // Classic order $questionList = $objExercise->selectQuestionList(true, true); } echo '
'; $category_list = TestCategory::getListOfCategoriesNameForTest($objExercise->id, 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; } $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_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', ] ); } if ($limitTeacherAccess && !api_is_platform_admin()) { $delete_link = ''; } $btnActions = implode( PHP_EOL, [$edit_link, $clone_link, $delete_link] ); $title = Security::remove_XSS($objQuestionTmp->selectTitle()); $title = strip_tags($title); $move = ' '; if ($allowQuestionOrdering) { $move = Display::returnFontAwesomeIcon('arrows moved', 1, true); } // Question name $questionName = ' '.$move.' '.cut($title, 42).' '; // Question type list($typeImg, $typeExpl) = $objQuestionTmp->get_type_icon_html(); $questionType = Display::return_icon($typeImg, $typeExpl); // Question category $txtQuestionCat = Security::remove_XSS( TestCategory::getCategoryNameForQuestion($objQuestionTmp->id) ); if (empty($txtQuestionCat)) { $txtQuestionCat = '-'; } // Question level $txtQuestionLevel = $objQuestionTmp->getLevel(); if (empty($objQuestionTmp->level)) { $txtQuestionLevel = '-'; } $questionLevel = $txtQuestionLevel; // Question score $questionScore = $objQuestionTmp->selectWeighting(); echo '
' .$questionName.'
'.get_lang('Type').' ' .$questionType.'
'.get_lang('Category').' ' .cut($txtQuestionCat, 42).'
'.get_lang('Difficulty').' ' .$questionLevel.'
'.get_lang('Score').' ' .$questionScore.'
'.$btnActions.'
'; unset($objQuestionTmp); } } echo '
'; //question list div } else { echo Display::return_message(get_lang('NoQuestion'), 'warning'); } }