]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-19813 upgraded calls to print_table, print_single_button, print_user_picture...
authornicolasconnault <nicolasconnault>
Thu, 20 Aug 2009 08:45:47 +0000 (08:45 +0000)
committernicolasconnault <nicolasconnault>
Thu, 20 Aug 2009 08:45:47 +0000 (08:45 +0000)
13 files changed:
mod/quiz/accessrules.php
mod/quiz/attemptlib.php
mod/quiz/editlib.php
mod/quiz/index.php
mod/quiz/lib.php
mod/quiz/report/grading/report.php
mod/quiz/report/overview/overview_table.php
mod/quiz/report/responses/responses_table.php
mod/quiz/report/statistics/report.php
mod/quiz/review.php
mod/quiz/reviewquestion.php
mod/quiz/summary.php
mod/quiz/view.php

index c7f7d07d585687746c83c0dc0293b725acbf6dd0..0d5c3aa15508376664e3926c9f34f33baa8b7bcd 100644 (file)
@@ -195,6 +195,7 @@ class quiz_access_manager {
      */
     public function print_start_attempt_button($canpreview, $buttontext, $unfinished) {
     /// Do we need a confirm javascript alert?
+        global $OUTPUT;
         if ($unfinished) {
             $strconfirmstartattempt = '';
         } else {
@@ -206,9 +207,11 @@ class quiz_access_manager {
         if ($this->securewindow_required($canpreview)) {
             $this->_securewindowrule->print_start_attempt_button($buttontext, $strconfirmstartattempt);
         } else {
-            print_single_button($this->_quizobj->start_attempt_url(),
-                    array('cmid' => $this->_quizobj->get_cmid(), 'sesskey' => sesskey()),
-                    $buttontext, 'post', '', false, '', false, $strconfirmstartattempt);
+            $form = html_form::make_button($this->_quizobj->start_attempt_url(), array('cmid' => $this->_quizobj->get_cmid()), $buttontext);
+            if ($strconfirmstartattempt) {
+                $form->button->add_confirm_action($strconfirmstartattempt);
+            }
+            echo $OUTPUT->button($form);
         }
         echo "</div>\n";
     }
index 75b0c41faf6ff21e963c1c4fa459e97b9d42e506..f04ce3a0cf0d9baf63670ecccc72d1bef63ea2d5 100644 (file)
@@ -750,11 +750,11 @@ class quiz_attempt extends quiz {
      * Print the HTML for the start new preview button.
      */
     public function print_restart_preview_button() {
-        global $CFG;
-        echo '<div class="controls">';
-        print_single_button($this->start_attempt_url(), array('cmid' => $this->cm->id,
-                'forcenew' => true, 'sesskey' => sesskey()), get_string('startagain', 'quiz'), 'post');
-        echo '</div>';
+        global $CFG, $OUTPUT;
+        echo $OUTPUT->container_start('controls');
+        $options = array('cmid' => $this->cm->id, 'forcenew' => true);
+        echo $OUTPUT->button(html_form::make_button($this->start_attempt_url(), $options, get_string('startagain', 'quiz')));
+        echo $OUTPUT->container_end();
     }
 
     /**
@@ -1068,11 +1068,11 @@ abstract class quiz_nav_panel_base {
     abstract protected function get_question_url($question);
 
     protected function get_user_picture() {
-        global $DB;
+        global $DB, $OUTPUT;
         $user = $DB->get_record('user', array('id' => $this->attemptobj->get_userid()));
         $output = '';
         $output .= '<div id="user-picture" class="clearfix">';
-        $output .= print_user_picture($user, $this->attemptobj->get_courseid(), NULL, 0, true, false);
+        $output .= $OUTPUT->user_picture(moodle_user_picture::make($user, $this->attemptobj->get_courseid()));
         $output .= ' ' . fullname($user);
         $output .= '</div>';
         return $output;
index eeeafb748ff1f2d0391e061540dc403f633b1913..999356cf16b6beb3637e4419ff0deaeec99334b1 100644 (file)
@@ -602,19 +602,17 @@ function quiz_print_question_list($quiz, $pageurl, $allowdelete = true,
                 echo "</div></div>";
 
                 if (!$reordertool && !$quiz->shufflequestions) {
-                    echo "<div class=\"addpage\">";
-                    print_single_button($pageurl->out(true),
+                    echo $OUTPUT->container_start('addpage');
+                    $form = html_form::make_button($pageurl->out(true),
                             array('cmid' => $quiz->cmid,
                                     'courseid' => $quiz->course,
                                     'addpage' => $count,
                                     'sesskey' => sesskey()),
                             get_string('addpagehere', 'quiz'),
-                             'get',
-                             '_self',
-                            false,
-                            '',
-                            $hasattempts);
-                    echo "</div>";
+                             'get');
+                    $form->button->disabled = $hasattempts;
+                    echo $OUTPUT->button($form);
+                    echo $OUTPUT->container_end();
                 }
                 $pageopen = false;
                 $count++;
index c9ee3287fdb58cc9a8d4e9e0cde141c665487233..82fce37da3f470c3dec7879eec70e70b354f5368 100644 (file)
@@ -87,6 +87,7 @@
         $showing = 'scores';  // default
     }
 
+    $table = new html_table();
     $table->head = $headings;
     $table->align = $align;
 
 
 // Display the table.
     echo '<br />';
-    print_table($table);
+    echo $OUTPUT->table($table);
 
 // Finish the page
     echo $OUTPUT->footer();
index 88577b52d3625e95110d99bd6db525377c6eb86d..379a960a94e14b75128e1182feb8b98377570b45 100644 (file)
@@ -540,10 +540,10 @@ function quiz_grade_item_update($quiz, $grades=NULL) {
                 $regrade_link = qualified_me() . '&amp;confirm_regrade=1';
                 echo $OUTPUT->box_start('generalbox', 'notice');
                 echo '<p>'. $message .'</p>';
-                echo '<div class="buttons">';
-                print_single_button($regrade_link, null, get_string('regradeanyway', 'grades'), 'post', $CFG->framename);
-                print_single_button($back_link,  null,  get_string('cancel'),  'post',  $CFG->framename);
-                echo '</div>';
+                echo $OUTPUT->container_start('buttons');
+                echo $OUTPUT->button(html_form::make_button($regrade_link, null, get_string('regradeanyway', 'grades')));
+                echo $OUTPUT->button(html_form::make_button($back_link,  null,  get_string('cancel')));
+                echo $OUTPUT->container_end();
                 echo $OUTPUT->box_end();
 
                 return GRADE_UPDATE_ITEM_LOCKED;
@@ -822,7 +822,7 @@ function quiz_print_recent_mod_activity($activity, $courseid, $detail, $modnames
     echo '<table border="0" cellpadding="3" cellspacing="0" class="forum-recent">';
 
     echo "<tr><td class=\"userpicture\" valign=\"top\">";
-    print_user_picture($activity->user->userid, $courseid, $activity->user->picture);
+    echo $OUTPUT->user_picture(moodle_user_picture::make($activity->user, $courseid));
     echo "</td><td>";
 
     if ($detail) {
index c3b29f379ad95b90dd14737b51e54a6a4284a66b..5e2ce45000fe2d99dbf1c17f82dfbf876919ffef 100644 (file)
@@ -293,7 +293,7 @@ class quiz_grading_report extends quiz_default_report {
             $table->add_separator();
             foreach($attempts as $attempt) {
 
-                $picture = print_user_picture($attempt->userid, $quiz->course, $attempt->picture, false, true);
+                $picture = $OUTPUT->user_picture(moodle_user_picture::make($attempt->userid, $quiz->course));
 
                 // link to student profile
                 $userlink = "<a href=\"$CFG->wwwroot/user/view.php?id=$attempt->userid&amp;course=$quiz->course\">".
index 4240a17ad03a87b8620d26632542263503703412..5f28958a57808bc0b9cbbd2b54b5ba197362dd09 100644 (file)
@@ -116,14 +116,14 @@ class quiz_report_overview_table extends table_sql {
     }
 
     function col_picture($attempt){
-        global $COURSE;
+        global $COURSE, $OUTPUT;
         $user = new object();
         $user->id = $attempt->userid;
         $user->lastname = $attempt->lastname;
         $user->firstname = $attempt->firstname;
         $user->imagealt = $attempt->imagealt;
         $user->picture = $attempt->picture;
-        return print_user_picture($user, $COURSE->id, $attempt->picture, false, true);
+        return $OUTPUT->user_picture(moodle_user_picture::make($user, $COURSE->id));
     }
 
 
index a1bba64ee065e03bb36b6d19d52ad965d9676d4c..e89d08ea5f680f0e233d103ee0dfffb6d477126e 100644 (file)
@@ -71,14 +71,14 @@ class quiz_report_responses_table extends table_sql {
     }
 
     function col_picture($attempt){
-        global $COURSE;
+        global $COURSE, $OUTPUT;
         $user = new object();
         $user->id = $attempt->userid;
         $user->lastname = $attempt->lastname;
         $user->firstname = $attempt->firstname;
         $user->imagealt = $attempt->imagealt;
         $user->picture = $attempt->picture;
-        return print_user_picture($user, $COURSE->id, $attempt->picture, false, true);
+        return $OUTPUT->user_picture(moodle_user_picture::make($user, $COURSE->id));
     }
 
 
@@ -241,4 +241,4 @@ class quiz_report_responses_table extends table_sql {
         }
     }
 }
-?>
\ No newline at end of file
+?>
index e39bbd0de8afc02d0df82551783f411efaf3f844..954ea542d340623a48ad713db8310ec851082414 100644 (file)
@@ -193,10 +193,10 @@ class quiz_statistics_report extends quiz_default_report {
         if (!$this->table->is_downloading()){
             $datumfromtable = $this->table->format_row($question);
 
-            $questioninfotable = new object();
+            $questioninfotable = new html_table();
             $questioninfotable->align = array('center', 'center');
             $questioninfotable->width = '60%';
-            $questioninfotable->class = 'generaltable titlesleft';
+            $questioninfotable->add_class('generaltable titlesleft');
 
             $questioninfotable->data = array();
             $questioninfotable->data[] = array(get_string('modulename', 'quiz'), $quiz->name);
@@ -204,10 +204,10 @@ class quiz_statistics_report extends quiz_default_report {
             $questioninfotable->data[] = array(get_string('questiontype', 'quiz_statistics'), $datumfromtable['icon'].'&nbsp;'.get_string($question->qtype,'quiz').'&nbsp;'.$datumfromtable['icon']);
             $questioninfotable->data[] = array(get_string('positions', 'quiz_statistics'), $question->_stats->positions);
 
-            $questionstatstable = new object();
+            $questionstatstable = new html_table();
             $questionstatstable->align = array('center', 'center');
             $questionstatstable->width = '60%';
-            $questionstatstable->class = 'generaltable titlesleft';
+            $questionstatstable->add_class('generaltable titlesleft');
 
             unset($datumfromtable['number']);
             unset($datumfromtable['icon']);
@@ -226,12 +226,12 @@ class quiz_statistics_report extends quiz_default_report {
                 $questionstatstable->data[] = array($labels[$item], $value);
             }
             echo $OUTPUT->heading(get_string('questioninformation', 'quiz_statistics'));
-            print_table($questioninfotable);
+            echo $OUTPUT->table($questioninfotable);
 
             echo $OUTPUT->box(format_text($question->questiontext, $question->questiontextformat).$actions, 'boxaligncenter generalbox boxwidthnormal mdl-align');
 
             echo $OUTPUT->heading(get_string('questionstatistics', 'quiz_statistics'));
-            print_table($questionstatstable);
+            echo $OUTPUT->table($questionstatstable);
 
         } else {
             $this->qtable->export_class_instance($this->table->export_class_instance());
@@ -349,7 +349,7 @@ class quiz_statistics_report extends quiz_default_report {
         global $DB, $OUTPUT;
         // Print information on the number of existing attempts
         $quizinformationtablehtml = $OUTPUT->heading(get_string('quizinformation', 'quiz_statistics'), 2, 'main');
-        $quizinformationtable = new object();
+        $quizinformationtable = new html_table();
         $quizinformationtable->align = array('center', 'center');
         $quizinformationtable->width = '60%';
         $quizinformationtable->class = 'generaltable titlesleft';
@@ -410,8 +410,8 @@ class quiz_statistics_report extends quiz_default_report {
                 }
                 $quizinformationtablehtml .= $OUTPUT->box_start('boxaligncenter generalbox boxwidthnormal mdl-align');
                 $quizinformationtablehtml .= get_string('lastcalculated', 'quiz_statistics', $a);
-                $quizinformationtablehtml .= print_single_button($reporturl->out(true), $reporturl->params()+array('recalculate'=>1),
-                                    get_string('recalculatenow', 'quiz_statistics'), 'post', '', true);
+                $quizinformationtablehtml .= $OUTPUT->button(html_form::make_button($reporturl->out(true), $reporturl->params()+array('recalculate'=>1),
+                                    get_string('recalculatenow', 'quiz_statistics')));
                 $quizinformationtablehtml .= $OUTPUT->box_end();
             }
             $downloadoptions = $this->table->get_download_menu();
@@ -425,7 +425,7 @@ class quiz_statistics_report extends quiz_default_report {
             $quizinformationtablehtml .= $OUTPUT->help_icon(moodle_help_icon::make('tableexportformats', get_string('tableexportformats', 'table')));
             $quizinformationtablehtml .= '</div></form>';
         }
-        $quizinformationtablehtml .= print_table($quizinformationtable, true);
+        $quizinformationtablehtml .= $OUTPUT->table($quizinformationtable);
         if (!$this->table->is_downloading()){
             echo $quizinformationtablehtml;
         } elseif ($everything) {
index e2ed53a061b679d1fe36a10895cc76043bb177f0..f0bb4b858106af6f61d25b79fff697f9328fbbb5 100644 (file)
     if (!$attemptobj->get_quiz()->showuserpicture && $attemptobj->get_userid() <> $USER->id) {
     /// If showuserpicture is true, the picture is shown elsewhere, so don't repeat it.
         $student = $DB->get_record('user', array('id' => $attemptobj->get_userid()));
-        $picture = print_user_picture($student, $attemptobj->get_courseid(), $student->picture, false, true);
+        $picture = $OUTPUT->user_picture(moodle_user_picture::make($student, $attemptobj->get_courseid()));
         $rows[] = '<tr><th scope="row" class="cell">' . $picture . '</th><td class="cell"><a href="' .
                 $CFG->wwwroot . '/user/view.php?id=' . $student->id . '&amp;course=' . $attemptobj->get_courseid() . '">' .
                 fullname($student, true) . '</a></td></tr>';
index fd126ae6367de4b2fe8aeb2160aaca26150fe018..8c5181284da92de59d8449c009c164f1dab35ada 100644 (file)
@@ -74,7 +74,7 @@
     if ($attemptobj->get_userid() <> $USER->id) {
         // Print user picture and name
         $student = $DB->get_record('user', array('id' => $attemptobj->get_userid()));
-        $picture = print_user_picture($student, $attemptobj->get_courseid(), $student->picture, false, true);
+        $picture = $OUTPUT->user_picture(moodle_user_picture::make($student, $attemptobj->get_courseid()));
         $rows[] = '<tr><th scope="row" class="cell">' . $picture . '</th><td class="cell"><a href="' .
                 $CFG->wwwroot . '/user/view.php?id=' . $student->id . '&amp;course=' . $attemptobj->get_courseid() . '">' .
                 fullname($student, true) . '</a></td></tr>';
index 59db7c35548ad2cfb8319c2885df75ba76f98235..3c63566a4c6af4264a2c4e57b93933f6a2377227 100644 (file)
@@ -68,7 +68,8 @@ if ($attemptobj->is_preview_user()) {
 echo $OUTPUT->heading($title);
 
 /// Prepare the summary table header
-$table->class = 'generaltable quizsummaryofattempt boxaligncenter';
+$table = new html_table();
+$table->add_class('generaltable quizsummaryofattempt boxaligncenter');
 $table->head = array(get_string('question', 'quiz'), get_string('status', 'quiz'));
 $table->align = array('left', 'left');
 $table->size = array('', '');
@@ -100,13 +101,13 @@ foreach ($attemptobj->get_question_iterator() as $number => $question) {
 }
 
 /// Print the summary table.
-print_table($table);
+echo $OUTPUT->table($table);
 
 /// countdown timer
 echo $attemptobj->get_timer_html();
 
 /// Finish attempt button.
-echo "<div class=\"submitbtns mdl-align\">\n";
+echo $OUTPUT->container_start('submitbtns mdl-align');
 $options = array(
     'attempt' => $attemptobj->get_attemptid(),
     'finishattempt' => 1,
@@ -114,9 +115,13 @@ $options = array(
     'questionids' => '',
     'sesskey' => sesskey(),
 );
-print_single_button(s($attemptobj->processattempt_url()), $options, get_string('finishattempt', 'quiz'),
-        'post', '', false, '', false, get_string('confirmclose', 'quiz'), 'responseform');
-echo "</div>\n";
+
+$form = html_form::make_button($attemptobj->processattempt_url(), $options, get_string('finishattempt', 'quiz'));
+$form->id = 'responseform';
+$form->button->add_confirm_action(get_string('confirmclose', 'quiz'));
+
+echo $OUTPUT->button($form);
+echo $OUTPUT->container_end();
 
 /// Finish the page
 $accessmanager->show_attempt_timer_if_needed($attemptobj->get_attempt(), time());
index 4f7c5da837678224b9f88edfd00b52dbd2a3965a..8b082b9a60e506df8db124ee58f70be5581e8fdf 100644 (file)
 
 /// Guests can't do a quiz, so offer them a choice of logging in or going back.
     if (isguestuser()) {
-        notice_yesno('<p>' . get_string('guestsno', 'quiz') . "</p>\n\n<p>" .
+        echo $OUTPUT->confirm('<p>' . get_string('guestsno', 'quiz') . "</p>\n\n<p>" .
                 get_string('liketologin') . "</p>\n", get_login_url(), get_referer(false));
         echo $OUTPUT->footer();
         exit;
         $feedbackcolumn = quiz_has_feedback($quiz) && $alloptions->overallfeedback;
 
         // Prepare table header
+        $table = new html_table();
         $table->class = 'generaltable quizattemptsummary';
         $table->head = array();
         $table->align = array();
                 $table->data[$attempt->attempt] = $row;
             }
         } // End of loop over attempts.
-        print_table($table);
+        echo $OUTPUT->table($table);
     }
 
 /// Print information about the student's best score for this quiz if possible.