Skip to content

Quiz: Add media question support (partial from very old code - requires review) - refs #2676 #6306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: 1.11.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions main/exercise/exercise.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -3514,7 +3514,15 @@ public function show_button(
int $lpItemId = 0,
int $lpItemViewId = 0
) {

$nbrQuestions = $this->countQuestionsInExercise();
$media_questions = $this->get_media_list();
$media_active = $this->media_is_activated($media_questions);

if ($media_active) {
$nbrQuestions = $this->get_count_questions_when_using_medias();
}

$buttonList = [];
$html = $label = '';
$hotspotGet = isset($_POST['hotspot']) ? Security::remove_XSS($_POST['hotspot']) : null;
Expand Down Expand Up @@ -7564,9 +7572,9 @@ public function get_validated_question_list()
return $questionList;
}

// Problem, random by category has been selected and
// Problem, random by category has been selected, and
// we have no $this->isRandom number of question selected
// Should not happened
// Should not happen

return [];
}
Expand Down Expand Up @@ -12245,8 +12253,6 @@ private function sendNotificationForOralQuestions(
private function setMediaList($questionList)
{
$mediaList = [];
/*
* Media feature is not activated in 1.11.x
if (!empty($questionList)) {
foreach ($questionList as $questionId) {
$objQuestionTmp = Question::read($questionId, $this->course_id);
Expand All @@ -12258,7 +12264,7 @@ private function setMediaList($questionList)
$mediaList[999][] = $objQuestionTmp->iid;
}
}
}*/
}

$this->mediaList = $mediaList;
}
Expand Down Expand Up @@ -12394,4 +12400,10 @@ private function setResultDisabledGroup(FormValidator $form)
get_lang('ShowResultsToStudents')
);
}
public function get_count_questions_when_using_medias() {
$media_questions = $this->getMediaList();
$questions_with_no_group = isset($media_questions[999]) ? count($media_questions[999]) : 0;

return count($media_questions) - 1 + $questions_with_no_group;
}
}
1 change: 1 addition & 0 deletions main/exercise/exercise.php
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ function showUserToSendNotificacion(element) {
$actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'exercise/question_pool.php?'.api_get_cidreq().'">';
$actionsLeft .= Display::return_icon('database.png', get_lang('QuestionPool'), '', ICON_SIZE_MEDIUM);
$actionsLeft .= '</a>';
//$actionsLeft .= Display::url(Display::return_icon('looknfeel.png', get_lang('Media')), 'media.php?' . api_get_cidreq());

// end question category
$actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'exercise/hotpotatoes.php?'.api_get_cidreq().'">'.
Expand Down
26 changes: 25 additions & 1 deletion main/exercise/exercise_show.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ function getFCK(vals, marksid) {
$counter = 1;
$exercise_content = '';
$category_list = [];
$mediaList = [];
$tempParentId = null;
$mediaCounter = 0;
$useAdvancedEditor = true;

if (!empty($maxEditors) && count($questionList) > $maxEditors) {
Expand Down Expand Up @@ -863,13 +866,34 @@ class="exercise_mark_select"

$contents = ob_get_clean();
$question_content = '<div class="question_row">';
$showMedia = false;

$counterToShow = $counter;

if ($objQuestionTmp->parent_id != 0) {

if (!in_array($objQuestionTmp->parent_id, $media_list)) {
$media_list[] = $objQuestionTmp->parent_id;
$show_media = true;
}
if ($tempParentId == $objQuestionTmp->parent_id) {
$mediaCounter++;
} else {
$mediaCounter = 0;
}
$counterToShow = chr(97 + $mediaCounter);
$tempParentId = $objQuestionTmp->parent_id;
}

if ($show_results && $objQuestionTmp) {
$objQuestionTmp->export = $action === 'export';
// Shows question title an description
$question_content .= $objQuestionTmp->return_header(
$objExercise,
$counter,
$score
$score,
$showMedia,
$mediaCounter
);
}
$counter++;
Expand Down
Loading
Loading