Merge branch 'lcubas-3580' into 1.11.x

pull/3680/head
Yannick Warnier 5 years ago
commit 02f5ccf520
  1. 5
      main/exercise/admin.php
  2. 72
      main/inc/lib/exercise.lib.php
  3. 3
      main/lang/english/trad4all.inc.php
  4. 3
      main/lang/french/trad4all.inc.php
  5. 3
      main/lang/spanish/trad4all.inc.php

@ -49,6 +49,10 @@ require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_QUIZ;
$this_section = SECTION_COURSES;
if ($_GET['r'] == 1) {
Exercise::cleanSessionVariables();
}
// Access control
api_protect_course_script(true);
@ -422,6 +426,7 @@ if ($newQuestion || $editQuestion) {
echo '</div>';
} else {
require 'question_admin.inc.php';
ExerciseLib::showTestsWhereQuestionIsUsed($objQuestion->iid, $objExercise->selectId());
}
}
}

@ -1647,6 +1647,78 @@ HOTSPOT;
return $nbrAnswers;
}
/**
* Get an HTML string with the list of exercises where the given question
* is being used
* @param int $questionId The iid of the question being observed
* @param int $excludeTestId If defined, exclude this (current) test from the list of results
* @return string An HTML string containing a div and a table
*/
public static function showTestsWhereQuestionIsUsed(int $questionId, int $excludeTestId = 0)
{
$questionId = (int) $questionId;
$sql = "SELECT qz.title quiz_title,
c.title course_title,
s.name session_name,
qz.iid as quiz_id,
qz.c_id,
qz.session_id
FROM c_quiz qz,
c_quiz_rel_question qq,
course c,
session s
WHERE qz.c_id = c.id AND
(qz.session_id = s.id OR qz.session_id = 0) AND
qq.exercice_id = qz.iid AND ";
if (!empty($excludeTestId)) {
$excludeTestId = (int) $excludeTestId;
$sql .= " qz.iid != $excludeTestId AND ";
}
$sql .= " qq.question_id = $questionId
GROUP BY qq.iid";
$result = [];
$html = "";
$sqlResult = Database::query($sql);
if (Database::num_rows($sqlResult) != 0) {
while ($row = Database::fetch_array($sqlResult, 'ASSOC')) {
$tmp = [];
$tmp[0] = $row['course_title'];
$tmp[1] = $row['session_name'];
$tmp[2] = $row['quiz_title'];
// Send do other test with r=1 to reset current test session variables
$urlToQuiz = api_get_path(WEB_CODE_PATH).'exercise/admin.php?'.api_get_cidreq().'&exerciseId='.$row['quiz_id'].'&r=1';
$tmp[3] = '<a href="'.$urlToQuiz.'">'.Display::return_icon('quiz.png', get_lang('Edit')).'</a>';
if ((int) $row['session_id'] == 0) {
$tmp[1] = '-';
}
$result[] = $tmp;
}
$headers = [
get_lang('Course'),
get_lang('Session'),
get_lang('Quiz'),
get_lang('LinkToTestEdition')
];
$title = Display::div(
get_lang('QuestionAlsoUsedInTheFollowingTests'),
[
'class' => 'section-title',
'style' => 'margin-top: 25px; border-bottom: none'
]
);
$html = $title . Display::table($headers, $result);
}
echo $html;
}
/**
* @param int $exeId
*

@ -8710,4 +8710,7 @@ $PriceUpdated = "Price updated";
$RemoveSelected = "Remove selected authors";
$DeletedAuthors = "Authors have been removed";
$HideCategoryTable = "Hide category table";
$XQuestionsSelectedWithTotalScoreY = "Only %d questions will be selected based on the test configuration, for a total score of %s.";
$QuestionAlsoUsedInTheFollowingTests = "This question is also used in the following tests";
$LinkToTestEdition = "Link to test edition";
?>

@ -8642,4 +8642,7 @@ $PriceUpdated = "Prix mis à jour";
$RemoveSelected = "Retirer les auteurs sélectionnés";
$DeletedAuthors = "Les auteurs ont été retirés";
$HideCategoryTable = "Cacher le tableau de catégories";
$XQuestionsSelectedWithTotalScoreY = "Seules %d questions seront sélectionnées d'après la configuration de l'exercice, pour un score total de %s.";
$QuestionAlsoUsedInTheFollowingTests = "Question utilisée également dans les exercices suivants";
$LinkToTestEdition = "Lien vers l'édition de l'exercice";
?>

@ -8738,4 +8738,7 @@ $PriceUpdated = "Precio actualizado";
$RemoveSelected = "Eliminar autores seleccionados";
$DeletedAuthors = "Los autores han sido eliminados";
$HideCategoryTable = "Esconder la tabla de categorías";
$XQuestionsSelectedWithTotalScoreY = "Solo se seleccionarán %d preguntas según la configuración del ejercicio, para una puntuación total de %s.";
$QuestionAlsoUsedInTheFollowingTests = "Esta pregunta se usa también en los ejercicios siguientes";
$LinkToTestEdition = "Vínculo a la edición del ejercicio";
?>
Loading…
Cancel
Save