From: nicolasconnault Date: Thu, 20 Aug 2009 08:45:47 +0000 (+0000) Subject: MDL-19813 upgraded calls to print_table, print_single_button, print_user_picture... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=39e3701904b34b3a9abf315df9a26a4891632355;p=moodle.git MDL-19813 upgraded calls to print_table, print_single_button, print_user_picture, print_container* and notice_yesno --- diff --git a/mod/quiz/accessrules.php b/mod/quiz/accessrules.php index c7f7d07d58..0d5c3aa155 100644 --- a/mod/quiz/accessrules.php +++ b/mod/quiz/accessrules.php @@ -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 "\n"; } diff --git a/mod/quiz/attemptlib.php b/mod/quiz/attemptlib.php index 75b0c41faf..f04ce3a0cf 100644 --- a/mod/quiz/attemptlib.php +++ b/mod/quiz/attemptlib.php @@ -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 '
'; - print_single_button($this->start_attempt_url(), array('cmid' => $this->cm->id, - 'forcenew' => true, 'sesskey' => sesskey()), get_string('startagain', 'quiz'), 'post'); - echo '
'; + 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 .= '
'; - $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 .= '
'; return $output; diff --git a/mod/quiz/editlib.php b/mod/quiz/editlib.php index eeeafb748f..999356cf16 100644 --- a/mod/quiz/editlib.php +++ b/mod/quiz/editlib.php @@ -602,19 +602,17 @@ function quiz_print_question_list($quiz, $pageurl, $allowdelete = true, echo ""; if (!$reordertool && !$quiz->shufflequestions) { - echo "
"; - 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 "
"; + 'get'); + $form->button->disabled = $hasattempts; + echo $OUTPUT->button($form); + echo $OUTPUT->container_end(); } $pageopen = false; $count++; diff --git a/mod/quiz/index.php b/mod/quiz/index.php index c9ee3287fd..82fce37da3 100644 --- a/mod/quiz/index.php +++ b/mod/quiz/index.php @@ -87,6 +87,7 @@ $showing = 'scores'; // default } + $table = new html_table(); $table->head = $headings; $table->align = $align; @@ -161,7 +162,7 @@ // Display the table. echo '
'; - print_table($table); + echo $OUTPUT->table($table); // Finish the page echo $OUTPUT->footer(); diff --git a/mod/quiz/lib.php b/mod/quiz/lib.php index 88577b52d3..379a960a94 100644 --- a/mod/quiz/lib.php +++ b/mod/quiz/lib.php @@ -540,10 +540,10 @@ function quiz_grade_item_update($quiz, $grades=NULL) { $regrade_link = qualified_me() . '&confirm_regrade=1'; echo $OUTPUT->box_start('generalbox', 'notice'); echo '

'. $message .'

'; - echo '
'; - 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 '
'; + 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 ''; echo "'; diff --git a/mod/quiz/reviewquestion.php b/mod/quiz/reviewquestion.php index fd126ae636..8c5181284d 100644 --- a/mod/quiz/reviewquestion.php +++ b/mod/quiz/reviewquestion.php @@ -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[] = ''; diff --git a/mod/quiz/summary.php b/mod/quiz/summary.php index 59db7c3554..3c63566a4c 100644 --- a/mod/quiz/summary.php +++ b/mod/quiz/summary.php @@ -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 "
\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 "
\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()); diff --git a/mod/quiz/view.php b/mod/quiz/view.php index 4f7c5da837..8b082b9a60 100644 --- a/mod/quiz/view.php +++ b/mod/quiz/view.php @@ -115,7 +115,7 @@ /// Guests can't do a quiz, so offer them a choice of logging in or going back. if (isguestuser()) { - notice_yesno('

' . get_string('guestsno', 'quiz') . "

\n\n

" . + echo $OUTPUT->confirm('

' . get_string('guestsno', 'quiz') . "

\n\n

" . get_string('liketologin') . "

\n", get_login_url(), get_referer(false)); echo $OUTPUT->footer(); exit; @@ -178,6 +178,7 @@ $feedbackcolumn = quiz_has_feedback($quiz) && $alloptions->overallfeedback; // Prepare table header + $table = new html_table(); $table->class = 'generaltable quizattemptsummary'; $table->head = array(); $table->align = array(); @@ -295,7 +296,7 @@ $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.
"; - print_user_picture($activity->user->userid, $courseid, $activity->user->picture); + echo $OUTPUT->user_picture(moodle_user_picture::make($activity->user, $courseid)); echo ""; if ($detail) { diff --git a/mod/quiz/report/grading/report.php b/mod/quiz/report/grading/report.php index c3b29f379a..5e2ce45000 100644 --- a/mod/quiz/report/grading/report.php +++ b/mod/quiz/report/grading/report.php @@ -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 = "wwwroot/user/view.php?id=$attempt->userid&course=$quiz->course\">". diff --git a/mod/quiz/report/overview/overview_table.php b/mod/quiz/report/overview/overview_table.php index 4240a17ad0..5f28958a57 100644 --- a/mod/quiz/report/overview/overview_table.php +++ b/mod/quiz/report/overview/overview_table.php @@ -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)); } diff --git a/mod/quiz/report/responses/responses_table.php b/mod/quiz/report/responses/responses_table.php index a1bba64ee0..e89d08ea5f 100644 --- a/mod/quiz/report/responses/responses_table.php +++ b/mod/quiz/report/responses/responses_table.php @@ -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 +?> diff --git a/mod/quiz/report/statistics/report.php b/mod/quiz/report/statistics/report.php index e39bbd0de8..954ea542d3 100644 --- a/mod/quiz/report/statistics/report.php +++ b/mod/quiz/report/statistics/report.php @@ -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'].' '.get_string($question->qtype,'quiz').' '.$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 .= ''; } - $quizinformationtablehtml .= print_table($quizinformationtable, true); + $quizinformationtablehtml .= $OUTPUT->table($quizinformationtable); if (!$this->table->is_downloading()){ echo $quizinformationtablehtml; } elseif ($everything) { diff --git a/mod/quiz/review.php b/mod/quiz/review.php index e2ed53a061..f0bb4b8581 100644 --- a/mod/quiz/review.php +++ b/mod/quiz/review.php @@ -131,7 +131,7 @@ 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[] = '
' . $picture . '' . fullname($student, true) . '
' . $picture . '' . fullname($student, true) . '