Esempio n. 1
0
 /**
  * Output a notification (that is, a status message about something that has just happened).
  *
  * Note: \core\notification::add() may be more suitable for your usage.
  *
  * @param string $message The message to print out.
  * @param string $type    The type of notification. See constants on \core\output\notification.
  * @return string the HTML to output.
  */
 public function notification($message, $type = null)
 {
     $typemappings = ['success' => \core\output\notification::NOTIFY_SUCCESS, 'info' => \core\output\notification::NOTIFY_INFO, 'warning' => \core\output\notification::NOTIFY_WARNING, 'error' => \core\output\notification::NOTIFY_ERROR, 'notifyproblem' => \core\output\notification::NOTIFY_ERROR, 'notifytiny' => \core\output\notification::NOTIFY_ERROR, 'notifyerror' => \core\output\notification::NOTIFY_ERROR, 'notifysuccess' => \core\output\notification::NOTIFY_SUCCESS, 'notifymessage' => \core\output\notification::NOTIFY_INFO, 'notifyredirect' => \core\output\notification::NOTIFY_INFO, 'redirectmessage' => \core\output\notification::NOTIFY_INFO];
     $extraclasses = [];
     if ($type) {
         if (strpos($type, ' ') === false) {
             // No spaces in the list of classes, therefore no need to loop over and determine the class.
             if (isset($typemappings[$type])) {
                 $type = $typemappings[$type];
             } else {
                 // The value provided did not match a known type. It must be an extra class.
                 $extraclasses = [$type];
             }
         } else {
             // Identify what type of notification this is.
             $classarray = explode(' ', self::prepare_classes($type));
             // Separate out the type of notification from the extra classes.
             foreach ($classarray as $class) {
                 if (isset($typemappings[$class])) {
                     $type = $typemappings[$class];
                 } else {
                     $extraclasses[] = $class;
                 }
             }
         }
     }
     $notification = new \core\output\notification($message, $type);
     if (count($extraclasses)) {
         $notification->set_extra_classes($extraclasses);
     }
     // Return the rendered template.
     return $this->render_from_template($notification->get_template_name(), $notification->export_for_template($this));
 }
Esempio n. 2
0
}
print_grade_page_head($courseid, 'settings', 'setup', get_string('gradebooksetup', 'grades'));
// Print Table of categories and items
echo $OUTPUT->box_start('gradetreebox generalbox');
//did we update something in the db and thus invalidate $grade_edit_tree?
if ($recreatetree) {
    $grade_edit_tree = new grade_edit_tree($gtree, $movingeid, $gpr);
}
$bulkmoveoptions = ['' => get_string('choosedots')] + $grade_edit_tree->categories;
$tpldata = (object) ['actionurl' => $returnurl, 'sesskey' => sesskey(), 'showsave' => !$moving, 'showbulkmove' => !$moving && count($grade_edit_tree->categories) > 1, 'bulkmoveoptions' => array_map(function ($option) use($bulkmoveoptions) {
    return ['name' => $bulkmoveoptions[$option], 'value' => $option];
}, array_keys($bulkmoveoptions))];
// Check to see if we have a normalisation message to send.
if ($weightsadjusted) {
    $notification = new \core\output\notification(get_string('weightsadjusted', 'grades'), \core\output\notification::NOTIFY_INFO);
    $tpldata->notification = $notification->export_for_template($OUTPUT);
}
$tpldata->table = html_writer::table($grade_edit_tree->table);
echo $OUTPUT->render_from_template('core_grades/edit_tree', $tpldata);
echo $OUTPUT->box_end();
// Print action buttons
echo $OUTPUT->container_start('buttons mdl-align');
if ($moving) {
    echo $OUTPUT->single_button(new moodle_url('index.php', array('id' => $course->id)), get_string('cancel'), 'get');
} else {
    echo $OUTPUT->single_button(new moodle_url('category.php', array('courseid' => $course->id)), get_string('addcategory', 'grades'), 'get');
    echo $OUTPUT->single_button(new moodle_url('item.php', array('courseid' => $course->id)), get_string('additem', 'grades'), 'get');
    if (!empty($CFG->enableoutcomes)) {
        echo $OUTPUT->single_button(new moodle_url('outcomeitem.php', array('courseid' => $course->id)), get_string('addoutcomeitem', 'grades'), 'get');
    }
    //echo $OUTPUT->(new moodle_url('index.php', array('id'=>$course->id, 'action'=>'autosort')), get_string('autosort', 'grades'), 'get');