diff --git a/mod/quiz/attempt.php b/mod/quiz/attempt.php index efb7dd14e75..28bc9e5f500 100644 --- a/mod/quiz/attempt.php +++ b/mod/quiz/attempt.php @@ -138,7 +138,7 @@ /// Print all the questions foreach ($attemptobj->get_question_ids($page) as $id) { - $attemptobj->print_question($id); + $attemptobj->print_question($id, false, $attemptobj->attempt_url($id, $page)); } /// Print a link to the next page. diff --git a/mod/quiz/attemptlib.php b/mod/quiz/attemptlib.php index aaf94cb1d58..9a04eb040c8 100644 --- a/mod/quiz/attemptlib.php +++ b/mod/quiz/attemptlib.php @@ -470,7 +470,7 @@ class quiz_attempt extends quiz { return $this->attempt->userid; } - /** @return boolean whether this attemp has been finished (true) or is still in progress (false). */ + /** @return boolean whether this attempt has been finished (true) or is still in progress (false). */ public function is_finished() { return $this->attempt->timefinish != 0; } @@ -641,6 +641,10 @@ class quiz_attempt extends quiz { $this->page_and_question_fragment($questionid, $page, $showall); } + public function set_this_page_url($url) { + $this->quiz->thispageurl = $url; + } + // Bits of content ===================================================================== public function get_html_head_contributions($page = 'all') { return get_html_head_contributions($this->get_question_ids($page), @@ -660,12 +664,24 @@ class quiz_attempt extends quiz { echo ''; } - public function print_question($id) { - if ($this->is_finished()) { + /** + * Wrapper round print_question from lib/questionlib.php. + * + * @param integer $id the id of a question in this quiz attempt. + * @param boolean $reviewing is the being printed on an attempt or a review page. + * @param string $thispageurl the URL of the page this question is being printed on. + */ + public function print_question($id, $reviewing, $thispageurl = '') { + if ($reviewing) { $options = $this->get_review_options(); } else { $options = $this->get_render_options($this->states[$id]); } + if ($thispageurl) { + $this->quiz->thispageurl = $thispageurl; + } else { + unset($thispageurl); + } print_question($this->questions[$id], $this->states[$id], $this->questions[$id]->_number, $this->quiz, $options); } diff --git a/mod/quiz/report/grading/report.php b/mod/quiz/report/grading/report.php index f18673dec1e..da9be0362fb 100644 --- a/mod/quiz/report/grading/report.php +++ b/mod/quiz/report/grading/report.php @@ -408,6 +408,7 @@ class quiz_grading_report extends quiz_default_report { // Print the question, without showing any previous comment. $copy = $state->manualcomment; $state->manualcomment = ''; + $options->noeditlink = true; print_question($question, $state, '', $quiz, $options); // The print the comment and grade fields, putting back the previous comment. diff --git a/mod/quiz/review.php b/mod/quiz/review.php index 130f79ec751..7c619274dd5 100644 --- a/mod/quiz/review.php +++ b/mod/quiz/review.php @@ -224,7 +224,7 @@ $lastpage = $attemptobj->is_last_page($page); } foreach ($attemptobj->get_question_ids($thispage) as $id) { - $attemptobj->print_question($id); + $attemptobj->print_question($id, true, $attemptobj->review_url($id, $page, $showall)); } /// Close form if we opened it. diff --git a/mod/quiz/reviewquestion.php b/mod/quiz/reviewquestion.php index 12b5c07daa5..7f0bdebfa58 100644 --- a/mod/quiz/reviewquestion.php +++ b/mod/quiz/reviewquestion.php @@ -50,6 +50,10 @@ $attemptobj->load_specific_question_state($questionid, $stateid); } +/// Work out the base URL of this page. + $baseurl = $CFG->wwwroot . '/mod/quiz/reviewquestion.php?attempt=' . + $attemptobj->get_attemptid() . '&question=' . $questionid; + /// Log this review. add_to_log($attemptobj->get_courseid(), 'quiz', 'review', 'reviewquestion.php?attempt=' . $attemptobj->get_attemptid() . '&question=' . $questionid . @@ -86,9 +90,7 @@ /// Other attempts at the quiz. if ($attemptobj->has_capability('mod/quiz:viewreports')) { - $attemptlist = $attemptobj->links_to_other_attempts( - 'reviewquestion.php?attempt=' . $attemptobj->get_attemptid() . - '&question=' . $questionid); + $attemptlist = $attemptobj->links_to_other_attempts($baseurl); if ($attemptlist) { $rows[] = '
';
- $editlink = link_to_popup_window('/question/question.php?inpopup=1&id=' .
- $question->id . $cmorcourseid, 'editquestion',
- $linktext, false, false, $stredit, '', true);
- }
+ $editlink = $this->get_question_edit_link($question, $cmoptions, $options);
$questiontext = $this->format_text($question->questiontext, $question->questiontextformat, $cmoptions);
$image = get_question_image($question);
diff --git a/question/type/question.html b/question/type/question.html
index 12154dc84e5..13e19ab160f 100644
--- a/question/type/question.html
+++ b/question/type/question.html
@@ -3,7 +3,7 @@
* print_question() method.
*/
?>
-
';
- $editlink = link_to_popup_window('/question/question.php?inpopup=1&id=' .
- $question->id . $cmorcourseid, 'editquestion',
- $linktext, false, false, $stredit, '', true);
- }
+ $editlink = $this->get_question_edit_link($question, $cmoptions, $options);
$generalfeedback = '';
if ($isgraded && $options->generalfeedback) {
@@ -936,11 +931,12 @@ class default_questiontype {
$comment = $state->manualcomment;
$commentlink = '';
- if (isset($options->questioncommentlink) && $context && has_capability('mod/quiz:grade', $context)) {
+ if (!empty($options->questioncommentlink)) {
$strcomment = get_string('commentorgrade', 'quiz');
- $question_to_comment = isset($question->randomquestionid) ? $question->randomquestionid : $question->id;
- $commentlink = '
';
+
+ if (!empty($cmoptions->thispageurl)) {
+ /// The module allow editing in the same window, print an ordinary link.
+ return '' . $linktext . '';
+ } else {
+ /// We have to edit in a pop-up.
+ return link_to_popup_window($linkurl . '&inpopup=1', 'editquestion',
+ $linktext, false, false, $stredit, '', true);
+ }
+ }
+
/**
* Print history of responses
*