예제 #1
0
 /**
  * Return array of rows where each row is an array of tab objects
  * taking into account permissions of current user
  */
 public function get_tabs()
 {
     $toprow = array();
     if ($this->att->perm->can_manage() or $this->att->perm->can_take() or $this->att->perm->can_change()) {
         $toprow[] = new tabobject(self::TAB_SESSIONS, $this->att->url_manage()->out(), get_string('sessions', 'attforblock'));
     }
     if ($this->att->perm->can_manage()) {
         $toprow[] = new tabobject(self::TAB_ADD, $this->att->url_sessions()->out(true, array('action' => att_sessions_page_params::ACTION_ADD)), get_string('add', 'attforblock'));
     }
     if ($this->att->perm->can_view_reports()) {
         $toprow[] = new tabobject(self::TAB_REPORT, $this->att->url_report()->out(), get_string('report', 'attforblock'));
     }
     if ($this->att->perm->can_export()) {
         $toprow[] = new tabobject(self::TAB_EXPORT, $this->att->url_export()->out(), get_string('export', 'quiz'));
     }
     if ($this->att->perm->can_change_preferences()) {
         $toprow[] = new tabobject(self::TAB_PREFERENCES, $this->att->url_preferences()->out(), get_string('settings', 'attforblock'));
     }
     return array($toprow);
 }
예제 #2
0
 * @subpackage attforblock
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once dirname(__FILE__) . '/../../config.php';
require_once dirname(__FILE__) . '/locallib.php';
$pageparams = new att_preferences_page_params();
$id = required_param('id', PARAM_INT);
$pageparams->action = optional_param('action', NULL, PARAM_INT);
$pageparams->statusid = optional_param('statusid', NULL, PARAM_INT);
$cm = get_coursemodule_from_id('attforblock', $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$att = $DB->get_record('attforblock', array('id' => $cm->instance), '*', MUST_EXIST);
require_login($course, true, $cm);
$att = new attforblock($att, $cm, $course, $PAGE->context, $pageparams);
$att->perm->require_change_preferences_capability();
$PAGE->set_url($att->url_preferences());
$PAGE->set_title($course->shortname . ": " . $att->name . ' - ' . get_string('settings', 'attforblock'));
$PAGE->set_heading($course->fullname);
$PAGE->set_cacheable(true);
$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'attforblock'));
$PAGE->navbar->add(get_string('settings', 'attforblock'));
switch ($att->pageparams->action) {
    case att_preferences_page_params::ACTION_ADD:
        $newacronym = optional_param('newacronym', null, PARAM_MULTILANG);
        $newdescription = optional_param('newdescription', null, PARAM_MULTILANG);
        $newgrade = optional_param('newgrade', 0, PARAM_INT);
        $att->add_status($newacronym, $newdescription, $newgrade);
        break;
    case att_preferences_page_params::ACTION_DELETE:
        if (att_has_logs_for_status($att->pageparams->statusid)) {
            print_error('cantdeletestatus', 'attforblock', "attsettings.php?id={$id}");