From ca4b4f8f7cf3e65dacd2e2ff4d592921f448adc8 Mon Sep 17 00:00:00 2001 From: nicolasconnault Date: Thu, 20 Aug 2009 13:17:07 +0000 Subject: [PATCH] MDL-19813 Upgraded calls to link_to_popup_window() --- mod/quiz/locallib.php | 13 ++++++++++--- mod/quiz/report/overview/overview_table.php | 14 ++++++++------ mod/quiz/report/responses/responses_table.php | 14 +++++++------- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/mod/quiz/locallib.php b/mod/quiz/locallib.php index eafe14f008..8166e8d848 100644 --- a/mod/quiz/locallib.php +++ b/mod/quiz/locallib.php @@ -821,9 +821,16 @@ function quiz_question_preview_button($quiz, $question, $label = false) { } // Build the icon. - return link_to_popup_window('/question/preview.php?id=' . $question->id . '&quizid=' . $quiz->id, 'questionpreview', - "old_icon_url('t/preview') . "\" class=\"iconsmall\" alt=\"$strpreviewquestion\" /> $strpreviewlabel", - 0, 0, $strpreviewquestion, QUESTION_PREVIEW_POPUP_OPTIONS, true); + $image = new html_image(); + $image->src = $OUTPUT->old_icon_url('t/preview'); + $image->add_class('iconsmall'); + $image->alt = $strpreviewquestion; + + $link = html_link::make("/question/preview.php?id=$question->id&quizid=$quiz->id", $strpreviewlabel); + parse_str(QUESTION_PREVIEW_POPUP_OPTIONS, $options); + $link->add_action(new popup_action('click', $link->url, 'questionpreview', $options)); + $link->title = $strpreviewquestion; + return $OUTPUT->link_to_popup($link, $image); } /** diff --git a/mod/quiz/report/overview/overview_table.php b/mod/quiz/report/overview/overview_table.php index 5f28958a57..7917f10edc 100644 --- a/mod/quiz/report/overview/overview_table.php +++ b/mod/quiz/report/overview/overview_table.php @@ -206,6 +206,7 @@ class quiz_report_overview_table extends table_sql { * @return string the contents of the cell. */ function other_cols($colname, $attempt){ + global $OUTPUT; if (preg_match('/^qsgrade([0-9]+)$/', $colname, $matches)){ $questionid = $matches[1]; @@ -226,11 +227,12 @@ class quiz_report_overview_table extends table_sql { $grade = ''.$oldgrade.'
'. $newgrade; } - $linktopopup = link_to_popup_window('/mod/quiz/reviewquestion.php?attempt=' . - $attempt->attempt . '&question=' . $question->id, - 'reviewquestion', $grade, 450, 650, - get_string('reviewresponsetoq', 'quiz', $question->formattedname), - 'none', true); + + $link = html_link::make("/mod/quiz/reviewquestion.php?attempt=$attempt->attempt&question=$question->id", $grade); + $link->add_action(new popup_action('click', $link->url, 'reviewquestion', array('height' => 450, 'width' => 650))); + $link->title = get_string('reviewresponsetoq', 'quiz', $question->formattedname); + $linktopopup = $OUTPUT->link($link); + if (($this->questions[$questionid]->maxgrade != 0)){ $fractionofgrade = $stateforqinattempt->grade / $this->questions[$questionid]->maxgrade; @@ -241,7 +243,7 @@ class quiz_report_overview_table extends table_sql { } else { return $linktopopup; } - + } else { return $grade; } diff --git a/mod/quiz/report/responses/responses_table.php b/mod/quiz/report/responses/responses_table.php index e89d08ea5f..2f968b4ba8 100644 --- a/mod/quiz/report/responses/responses_table.php +++ b/mod/quiz/report/responses/responses_table.php @@ -137,7 +137,7 @@ class quiz_report_responses_table extends table_sql { } } function other_cols($colname, $attempt){ - global $QTYPES; + global $QTYPES, $OUTPUT; static $states =array(); if (preg_match('/^qsanswer([0-9]+)$/', $colname, $matches)){ if ($attempt->uniqueid == 0) { @@ -158,16 +158,16 @@ class quiz_report_responses_table extends table_sql { } else { $formathtml = false; } - + $summary = $QTYPES[$question->qtype]->response_summary($question, $stateforqinattempt, QUIZ_REPORT_RESPONSES_MAX_LEN_TO_DISPLAY, $formathtml); if (!$this->is_downloading()) { if ($summary){ - $summary = link_to_popup_window('/mod/quiz/reviewquestion.php?attempt=' . - $attempt->attempt . '&question=' . $question->id, - 'reviewquestion', $summary, 450, 650, - get_string('reviewresponsetoq', 'quiz', $question->formattedname), - 'none', true); + $link = html_link::make("/mod/quiz/reviewquestion.php?attempt=$attempt->attempt&question=$question->id", $summary); + $link->add_action(new popup_action('click', $link->url, 'reviewquestion', array('height' => 450, 'width' => 650))); + $link->title = $question->formattedname; + $summary = $OUTPUT->link($link); + if (question_state_is_graded($stateforqinattempt) && ($question->maxgrade > 0)){ $grade = $stateforqinattempt->grade -- 2.39.5