From af7225d387e6567edaa287f1be35ee34e3e91196 Mon Sep 17 00:00:00 2001 From: lcubas Date: Tue, 24 Nov 2020 01:23:11 -0500 Subject: [PATCH 1/2] Tests: Show list of courses where a question is used --- main/exercise/admin.php | 1 + main/inc/lib/exercise.lib.php | 59 +++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/main/exercise/admin.php b/main/exercise/admin.php index 92173137a6..95bafefa3c 100755 --- a/main/exercise/admin.php +++ b/main/exercise/admin.php @@ -422,6 +422,7 @@ if ($newQuestion || $editQuestion) { echo ''; } else { require 'question_admin.inc.php'; + ExerciseLib::showExtraInfoWhereQuestionUsed($objQuestion->iid); } } } diff --git a/main/inc/lib/exercise.lib.php b/main/inc/lib/exercise.lib.php index 04b93e8527..d72ce5f68e 100644 --- a/main/inc/lib/exercise.lib.php +++ b/main/inc/lib/exercise.lib.php @@ -1647,6 +1647,65 @@ HOTSPOT; return $nbrAnswers; } + public static function showExtraInfoWhereQuestionUsed($exerciseId) + { + $sql = "SELECT q.title quiz_title, + c.title course_title, + s.name session_name, + q.iid as quiz_id, + q.c_id, + q.session_id + FROM c_quiz q, + c_quiz_rel_question qq, + course c, + session s + WHERE q.c_id = c.id AND + (q.session_id = s.id OR q.session_id = 0) AND + qq.exercice_id = q.iid AND + qq.question_id = $exerciseId + GROUP BY qq.iid"; + + $result = []; + $html = ""; + + $sqlResult = Database::query($sql); + + if (Database::num_rows($sqlResult) >= 2) { + while ($row = Database::fetch_array($sqlResult, 'ASSOC')) { + $tmp = []; + $tmp[0] = $row['course_title']; + $tmp[1] = $row['session_name']; + $tmp[2] = $row['quiz_title']; + $urlToQuiz = api_get_path(WEB_CODE_PATH).'exercise/admin.php?'.api_get_cidreq().'&exerciseId='.$row['quiz_id']; + $tmp[3] = Display::url('Link to the questions list of that test', $urlToQuiz); + if ((int) $row['session_id'] == 0) { + $tmp[1] = '-'; + } + + $result[] = $tmp; + } + + $headers = [ + get_lang('Course'), + get_lang('Session'), + get_lang('Quiz'), + get_lang('Link') + ]; + + $title = Display::div( + 'This question is used in the following tests:', + [ + 'class' => 'section-title', + 'style' => 'margin-top: 25px; border-bottom: none' + ] + ); + + $html = $title . Display::table($headers, $result); + } + + echo $html; + } + /** * @param int $exeId * From af8c8b7515d0dd4499aaec430c43b2e6878046d4 Mon Sep 17 00:00:00 2001 From: lcubas Date: Tue, 24 Nov 2020 11:17:50 -0500 Subject: [PATCH 2/2] Tests: Create vlang var for the text of a list of test where a question is used --- main/inc/lib/exercise.lib.php | 4 ++-- main/lang/english/trad4all.inc.php | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/main/inc/lib/exercise.lib.php b/main/inc/lib/exercise.lib.php index d72ce5f68e..a99805e01e 100644 --- a/main/inc/lib/exercise.lib.php +++ b/main/inc/lib/exercise.lib.php @@ -1689,11 +1689,11 @@ HOTSPOT; get_lang('Course'), get_lang('Session'), get_lang('Quiz'), - get_lang('Link') + get_lang('LinkToTheQuestionListOfThatTest') ]; $title = Display::div( - 'This question is used in the following tests:', + get_lang('QuestionUsedInTheFollowingTests'), [ 'class' => 'section-title', 'style' => 'margin-top: 25px; border-bottom: none' diff --git a/main/lang/english/trad4all.inc.php b/main/lang/english/trad4all.inc.php index 2b6a2fde82..150fb7c7ea 100644 --- a/main/lang/english/trad4all.inc.php +++ b/main/lang/english/trad4all.inc.php @@ -5832,7 +5832,7 @@ $Item = "Item"; $ConfigureDashboardPlugin = "Configure Dashboard Plugin"; $EditBlocks = "Edit blocks"; $Never = "Never"; -$YourAccountIsActiveYouCanLoginAndCheckYourCourses = "Dear user, +$YourAccountIsActiveYouCanLoginAndCheckYourCourses = "Dear user, Your account has now been activated on the platform. Please login and enjoy your courses."; $SessionFields = "Session fields"; @@ -8006,11 +8006,11 @@ $SpecificDate = "Specific dispatch date"; $BaseDate = "Dispatch based on the session's start/end dates"; $AfterOrBefore = "After or before"; $Before = "Before"; -$ScheduleAnnouncementDescription = "This form allows scheduling announcements to be sent automatically to the students who are taking a course in a session. +$ScheduleAnnouncementDescription = "This form allows scheduling announcements to be sent automatically to the students who are taking a course in a session. -There are two types of announcements that can be sent: +There are two types of announcements that can be sent: -Specific date: In this case a specific day is selected to make the announcement. +Specific date: In this case a specific day is selected to make the announcement. Based on the start / end date of the session: in this case the number of days to pass before sending the announcement must be indicated. And those days can be associated to before or after the start / end date. For example: 3 days after the start date."; $MandatorySurveyNoAnswered = "A mandatory survey is waiting your answer. To enter the course, you must first complete the survey."; @@ -8703,4 +8703,6 @@ $ToInvoice = "To invoice"; $LearningPathItemByAuthor = "LP item by author"; $DeleteExerciseAttempts = "Delete also the exercise attempts. If not check then the exercise results will still be available in the exercise tool."; $ExerciseCategoriesRadarMode = "Only show a radar of scores by category, instead of a table of categories. Do not show individual scores or feedback."; -?> \ No newline at end of file +$QuestionUsedInTheFollowingTests = "This question is used in the following tests:"; +$LinkToTheQuestionListOfThatTest = "Link to the questions list of that test"; +?>