Skip to content

Commit

Permalink
MDL-19813 Upgraded calls to helpbutton, print_simple_box* and notify
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasconnault committed Aug 18, 2009
1 parent d68ccdb commit 825116f
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 44 deletions.
4 changes: 2 additions & 2 deletions mod/quiz/comment.php
Expand Up @@ -45,12 +45,12 @@

/// If success, notify and print a close button.
if (!is_string($error)) {
notify(get_string('changessaved'), 'notifysuccess');
echo $OUTPUT->notification(get_string('changessaved'), 'notifysuccess');
close_window(2, true);
}

/// Otherwise, display the error and fall throug to re-display the form.
notify($error);
echo $OUTPUT->notification($error);
}

/// Print the comment form.
Expand Down
6 changes: 2 additions & 4 deletions mod/quiz/edit.php
Expand Up @@ -106,8 +106,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo
$out .= '<input type="hidden" name="categoryid" value="' . $category->id . '" />';
$out .= ' <input type="submit" name="addrandom" value="'.
$straddtoquiz.'" '.$disabled.' />';
$out .= helpbutton('random', get_string('random', 'quiz'), 'quiz',
true, false, '', true);
$out .= $OUTPUT->help_icon(moodle_help_icon::make('random', get_string('random', 'quiz'), 'quiz'));
}
}
return $out;
Expand Down Expand Up @@ -521,8 +520,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo
echo '</div>';
}
echo $OUTPUT->heading($pagetitle.": ".$quiz->name, 2);
helpbutton('editconcepts', get_string('basicideasofquiz', 'quiz'), 'quiz',
true, get_string('basicideasofquiz', 'quiz'));
echo $OUTPUT->help_icon(moodle_help_icon::make('editconcepts', get_string('basicideasofquiz', 'quiz'), 'quiz', get_string('basicideasofquiz', 'quiz')));
quiz_print_status_bar($quiz);

$tabindex = 0;
Expand Down
16 changes: 8 additions & 8 deletions mod/quiz/editlib.php
Expand Up @@ -640,7 +640,7 @@ function quiz_print_question_list($quiz, $pageurl, $allowdelete = true,
* @param unknown_type $hasattempts
*/
function quiz_print_pagecontrols($quiz, $pageurl, $page, $hasattempts) {
global $CFG;
global $CFG, $OUTPUT;
static $randombuttoncount = 0;
$randombuttoncount++;
echo '<div class="pagecontrols">';
Expand Down Expand Up @@ -678,7 +678,7 @@ function quiz_print_pagecontrols($quiz, $pageurl, $page, $hasattempts) {
</div>
</form>
</div>
<?php helpbutton('random', get_string('random', 'quiz'), 'quiz', true, false, ''); ?>
<?php echo $OUTPUT->help_icon(moodle_help_icon::make('random', get_string('random', 'quiz'), 'quiz')); ?>
<?php
echo "\n</div>";
}
Expand Down Expand Up @@ -750,12 +750,12 @@ function quiz_print_singlequestion($question, $returnurl, $quiz) {
* @param boolean $quiz_qbanktool Indicate to this function if the question bank window open
*/
function quiz_print_randomquestion(&$question, &$pageurl, &$quiz, $quiz_qbanktool) {
global $DB, $QTYPES, $THEME;
global $DB, $QTYPES, $THEME, $OUTPUT;
check_theme_arrows();
echo '<div class="quiz_randomquestion">';

if (!$category = $DB->get_record('question_categories', array('id' => $question->category))) {
notify('Random question category not found!');
echo $OUTPUT->notification('Random question category not found!');
return;
}

Expand Down Expand Up @@ -859,11 +859,11 @@ function quiz_print_singlequestion_reordertool($question, $returnurl, $quiz) {
* @param object $quiz The quiz in the context of which the question is being displayed
*/
function quiz_print_randomquestion_reordertool(&$question, &$pageurl, &$quiz) {
global $DB, $QTYPES;
global $DB, $QTYPES, $OUTPUT;

// Load the category, and the number of available questions in it.
if (!$category = $DB->get_record('question_categories', array('id' => $question->category))) {
notify('Random question category not found!');
echo $OUTPUT->notification('Random question category not found!');
return;
}
$questioncount = count($QTYPES['random']->get_usable_questions_from_category(
Expand Down Expand Up @@ -1136,7 +1136,7 @@ protected function display_options($recurse = 1, $showhidden = false, $showquest
* the last value used +1.
*/
function quiz_print_grading_form($quiz, $pageurl, $tabindex) {
global $USER;
global $USER, $OUTPUT;
$strsave = get_string('save', 'quiz');
echo "<form method=\"post\" action=\"edit.php\"><div>";
echo '<fieldset class="invisiblefieldset" style="display: block;">';
Expand All @@ -1147,7 +1147,7 @@ function quiz_print_grading_form($quiz, $pageurl, $tabindex) {
echo '<label for="inputmaxgrade">' . get_string('maximumgradex', '', $a) . "</label>";
echo '<input type="hidden" name="savechanges" value="save" />';
echo '<input type="submit" value="' . $strsave . '" />';
helpbutton('maxgrade', get_string('maximumgrade'), 'quiz');
echo $OUTPUT->help_icon(moodle_help_icon::make('maxgrade', get_string('maximumgrade'), 'quiz'));
echo '</fieldset>';
echo "</div></form>\n";
return $tabindex + 1;
Expand Down
4 changes: 2 additions & 2 deletions mod/quiz/locallib.php
Expand Up @@ -559,7 +559,7 @@ function quiz_set_grade($newgrade, &$quiz) {
*/
function quiz_save_best_grade($quiz, $userid = null, $attempts = array()) {
global $DB;
global $USER;
global $USER, $OUTPUT;

if (empty($userid)) {
$userid = $USER->id;
Expand All @@ -568,7 +568,7 @@ function quiz_save_best_grade($quiz, $userid = null, $attempts = array()) {
if (!$attempts){
// Get all the attempts made by the user
if (!$attempts = quiz_get_user_attempts($quiz->id, $userid)) {
notify('Could not find any user attempts');
echo $OUTPUT->notification('Could not find any user attempts');
return false;
}
}
Expand Down
20 changes: 10 additions & 10 deletions mod/quiz/report/grading/report.php
Expand Up @@ -61,7 +61,7 @@ function display($quiz, $cm, $course) {
// Check permissions
$this->context = get_context_instance(CONTEXT_MODULE, $cm->id);
if (!has_capability('mod/quiz:grade', $this->context)) {
notify(get_string('gradingnotallowed', 'quiz_grading'));
echo $OUTPUT->notification(get_string('gradingnotallowed', 'quiz_grading'));
return true;
}

Expand Down Expand Up @@ -135,7 +135,7 @@ function display($quiz, $cm, $course) {
// the following will update the state and attempt
$error = question_process_comment($question, $state, $attempt, $response['comment'], $response['grade']);
if (is_string($error)) {
notify($error);
echo $OUTPUT->notification($error);
$allok = false;
} else if ($state->changed) {
// If the state has changed save it and update the quiz grade
Expand All @@ -145,9 +145,9 @@ function display($quiz, $cm, $course) {
}

if ($allok) {
notify(get_string('changessaved', 'quiz'), 'notifysuccess');
echo $OUTPUT->notification(get_string('changessaved', 'quiz'), 'notifysuccess');
} else {
notify(get_string('changessavedwitherrors', 'quiz'), 'notifysuccess');
echo $OUTPUT->notification(get_string('changessavedwitherrors', 'quiz'), 'notifysuccess');
}
}
}
Expand All @@ -160,15 +160,15 @@ function display($quiz, $cm, $course) {

if(empty($this->users)) {
if ($currentgroup){
notify(get_string('nostudentsingroup'));
echo $OUTPUT->notification(get_string('nostudentsingroup'));
} else {
notify(get_string('nostudentsyet'));
echo $OUTPUT->notification(get_string('nostudentsyet'));
}
return true;
}
$qattempts = quiz_get_total_qas_graded_and_ungraded($quiz, array_keys($gradeableqs), array_keys($this->users));
if(empty($qattempts)) {
notify(get_string('noattemptstoshow', 'quiz'));
echo $OUTPUT->notification(get_string('noattemptstoshow', 'quiz'));
return true;
}
$qmenu = array();
Expand Down Expand Up @@ -226,7 +226,7 @@ function display($quiz, $cm, $course) {
* Finnish documenting
**/
function view_question($quiz, $question, $totalattempts, $ungraded) {
global $CFG, $DB;
global $CFG, $DB, $OUTPUT;

$usercount = count($this->users);

Expand Down Expand Up @@ -319,7 +319,7 @@ function view_question($quiz, $question, $totalattempts, $ungraded) {
$table->print_html();
echo '</div>';
} else {
notify(get_string('noattemptstoshow', 'quiz'));
echo $OUTPUT->notification(get_string('noattemptstoshow', 'quiz'));
}
}

Expand Down Expand Up @@ -416,7 +416,7 @@ function print_questions_and_form($quiz, $question, $userid, $attemptid, $gradeu
echo '<div class="boxaligncenter"><input type="submit" value="'.get_string('savechanges').'" /></div>'.
'</form>';
} else {
notify(get_string('noattemptstoshow', 'quiz'));
echo $OUTPUT->notification(get_string('noattemptstoshow', 'quiz'));
}
}

Expand Down
8 changes: 4 additions & 4 deletions mod/quiz/report/overview/report.php
Expand Up @@ -189,10 +189,10 @@ function display($quiz, $cm, $course) {
}
$nostudents = false;
if (!$students){
notify(get_string('nostudentsyet'));
echo $OUTPUT->notification(get_string('nostudentsyet'));
$nostudents = true;
}else if ($currentgroup && !$groupstudents){
notify(get_string('nostudentsingroup'));
echo $OUTPUT->notification(get_string('nostudentsingroup'));
$nostudents = true;
}
if (!$table->is_downloading()) {
Expand Down Expand Up @@ -426,7 +426,7 @@ function display($quiz, $cm, $course) {
function regrade_all($dry, $quiz, $groupstudents){
global $DB, $OUTPUT;
if (!has_capability('mod/quiz:regrade', $this->context)) {
notify(get_string('regradenotallowed', 'quiz'));
echo $OUTPUT->notification(get_string('regradenotallowed', 'quiz'));
return true;
}
// Fetch all attempts
Expand Down Expand Up @@ -509,7 +509,7 @@ function count_regrade_all_needed($quiz, $groupstudents){
function regrade_all_needed($quiz, $groupstudents){
global $DB, $OUTPUT;
if (!has_capability('mod/quiz:regrade', $this->context)) {
notify(get_string('regradenotallowed', 'quiz'));
echo $OUTPUT->notification(get_string('regradenotallowed', 'quiz'));
return;
}
// Fetch all attempts that need regrading
Expand Down
6 changes: 3 additions & 3 deletions mod/quiz/report/responses/report.php
Expand Up @@ -17,7 +17,7 @@ class quiz_responses_report extends quiz_default_report {
* Display the report.
*/
function display($quiz, $cm, $course) {
global $CFG, $COURSE, $DB, $PAGE;
global $CFG, $COURSE, $DB, $PAGE, $OUTPUT;

$context = get_context_instance(CONTEXT_MODULE, $cm->id);

Expand Down Expand Up @@ -150,10 +150,10 @@ function display($quiz, $cm, $course) {
}
$nostudents = false;
if (!$students){
notify(get_string('nostudentsyet'));
echo $OUTPUT->notification(get_string('nostudentsyet'));
$nostudents = true;
}else if ($currentgroup && !$groupstudents){
notify(get_string('nostudentsingroup'));
echo $OUTPUT->notification(get_string('nostudentsingroup'));
$nostudents = true;
}
if (!$table->is_downloading()) {
Expand Down
6 changes: 3 additions & 3 deletions mod/quiz/report/statistics/qstats.php
Expand Up @@ -172,7 +172,7 @@ function _secondary_question_walker(&$stats){
}

function process_states(){
global $DB;
global $DB, $OUTPUT;
set_time_limit(0);
$subquestionstats = array();
foreach ($this->states as $state){
Expand Down Expand Up @@ -210,7 +210,7 @@ function process_states(){
$this->subquestions[$qid]->maxgrade = $this->subquestions[$qid]->_stats->maxgrade;
$this->_initial_question_walker($this->subquestions[$qid]->_stats);
if ($subquestionstats[$qid]->differentweights){
notify(get_string('erroritemappearsmorethanoncewithdifferentweight', 'quiz_statistics', $this->subquestions[$qid]->name));
echo $OUTPUT->notification(get_string('erroritemappearsmorethanoncewithdifferentweight', 'quiz_statistics', $this->subquestions[$qid]->name));
}
if ($this->subquestions[$qid]->_stats->usedin){
sort($this->subquestions[$qid]->_stats->usedin, SORT_NUMERIC);
Expand Down Expand Up @@ -296,4 +296,4 @@ function sum_of_grade_variance(){
return $this->sumofgradevariance;
}
}
?>
?>
4 changes: 2 additions & 2 deletions mod/quiz/report/statistics/report.php
Expand Up @@ -103,7 +103,7 @@ function display($quiz, $cm, $course) {
groups_print_activity_menu($cm, $reporturl->out());
echo '<br />';
if ($currentgroup && !$groupstudents){
notify(get_string('nostudentsingroup', 'quiz_statistics'));
echo $OUTPUT->notification(get_string('nostudentsingroup', 'quiz_statistics'));
}
}
}
Expand Down Expand Up @@ -422,7 +422,7 @@ function output_quiz_info_table($course, $cm, $quiz, $quizstats, $usingattemptss
$select = html_select::make($downloadoptions, 'download', $this->table->defaultdownloadformat, false);
$select->nothingvalue = '';
$quizinformationtablehtml .= $OUTPUT->select($select);;
$quizinformationtablehtml .= helpbutton('tableexportformats', get_string('tableexportformats', 'table'), 'moodle', true, false, '', true);
$quizinformationtablehtml .= $OUTPUT->help_icon(moodle_help_icon::make('tableexportformats', get_string('tableexportformats', 'table')));
$quizinformationtablehtml .= '</div></form>';
}
$quizinformationtablehtml .= print_table($quizinformationtable, true);
Expand Down
3 changes: 2 additions & 1 deletion mod/quiz/report/statistics/statistics_table.php
Expand Up @@ -141,11 +141,12 @@ function col_intended_weight($question){
return quiz_report_scale_sumgrades_as_percentage($question->_stats->maxgrade, $this->quiz);
}
function col_effective_weight($question){
global $OUTPUT;
if (!$question->_stats->subquestion){
if ($question->_stats->negcovar){
$negcovar = get_string('negcovar', 'quiz_statistics');
if (!$this->is_downloading()){
$negcovar .= helpbutton('negcovar', $negcovar, 'quiz_statistics', true, false, '', true);
$negcovar .= $OUTPUT->help_icon(moodle_help_icon::make('negcovar', $negcovar, 'quiz_statistics'));
return '<div class="negcovar">'.$negcovar.'</div>';
} else {
return $negcovar;
Expand Down
6 changes: 3 additions & 3 deletions mod/quiz/reviewquestion.php
Expand Up @@ -25,18 +25,18 @@
if (!$attemptobj->has_capability('mod/quiz:viewreports')) {
/// Can't review during the attempt - send them back to the attempt page.
if (!$attemptobj->is_finished()) {
notify(get_string('cannotreviewopen', 'quiz'));
echo $OUTPUT->notification(get_string('cannotreviewopen', 'quiz'));
echo $OUTPUT->close_window_button();
}
/// Can't review other users' attempts.
if (!$attemptobj->is_own_attempt()) {
notify(get_string('notyourattempt', 'quiz'));
echo $OUTPUT->notification(get_string('notyourattempt', 'quiz'));
echo $OUTPUT->close_window_button();
}
/// Can't review unless Students may review -> Responses option is turned on.
if (!$options->responses) {
$accessmanager = $attemptobj->get_access_manager(time());
notify($accessmanager->cannot_review_message($attemptobj->get_review_options()));
echo $OUTPUT->notification($accessmanager->cannot_review_message($attemptobj->get_review_options()));
echo $OUTPUT->close_window_button();
}
}
Expand Down
4 changes: 2 additions & 2 deletions mod/quiz/view.php
Expand Up @@ -124,7 +124,7 @@
/// If they are not enrolled in this course in a good enough role, tell them to enrol.
if (!($canattempt || $canpreview || $canreviewmine)) {
echo $OUTPUT->box('<p>' . get_string('youneedtoenrol', 'quiz') . "</p>\n\n<p>" .
print_continue($CFG->wwwroot . '/course/view.php?id=' . $course->id, true) .
$OUTPUT->continue_button($CFG->wwwroot . '/course/view.php?id=' . $course->id) .
"</p>\n", 'generalbox', 'notice');
echo $OUTPUT->footer();
exit;
Expand Down Expand Up @@ -380,7 +380,7 @@
if ($buttontext) {
$accessmanager->print_start_attempt_button($canpreview, $buttontext, $unfinished);
} else {
print_continue($CFG->wwwroot . '/course/view.php?id=' . $course->id);
echo $OUTPUT->continue_button($CFG->wwwroot . '/course/view.php?id=' . $course->id);
}
echo $OUTPUT->box_end();

Expand Down

0 comments on commit 825116f

Please sign in to comment.