/** * Creates the blocks main content * * @return string */ public function get_content() { // Access to settings needed global $USER, $COURSE, $CFG, $DB, $OUTPUT; // If content has already been generated, don't waste time generating it again if ($this->content !== null) { return $this->content; } $this->content = new stdClass(); $this->content->text = ''; $this->content->footer = ''; // Check if any activities/resources have been created $modules = modules_in_use(); if (empty($modules)) { if (has_capability('moodle/block:edit', $this->context)) { $this->content->text .= get_string('no_events_config_message', 'block_progress'); } return $this->content; } // Check if activities/resources have been selected in config $events = event_information($this->config, $modules); $attempts = get_attempts($modules, $this->config, $events, $USER->id, $this->instance->id); $this->content->text = progress_bar($modules, $this->config, $events, $USER->id, $this->instance->id, $attempts); // Organise access to JS $jsmodule = array('name' => 'block_progress', 'fullpath' => '/blocks/progress/module.js', 'requires' => array(), 'strings' => array(array('time_expected', 'block_progress'))); $displaydate = !isset($this->config->displayNow) || $this->config->displayNow == 1; $arguments = array($CFG->wwwroot, array_keys($modules), $displaydate); $this->page->requires->js_init_call('M.block_progress.init', $arguments, false, $jsmodule); return $this->content; }
echo $OUTPUT->header(); echo $OUTPUT->heading($strheading); $currenttab = "edit"; print_towntabs($currenttab, $id); $course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST); $activity_types = activities_inuse($id); echo HTML_WRITER::start_tag('div', array('class' => 'selfilterpos', 'id' => 'townhall')); $select = new single_select(new moodle_url('/local/townhall/index.php?id=' . $id . ''), 'type', $activity_types, $type, null, 'switchcategory'); $select->set_label(get_string('activitytype', 'local_townhall') . ':'); echo $OUTPUT->render($select); echo HTML_WRITER::end_tag('div'); if ($type == null) $activity_names = array(0 => array()); else $activity_names = event_information($type, $id); echo HTML_WRITER::start_tag('div', array('class' => 'selfilterpos', 'id' => 'townhall', style => 'float:none')); $select = new single_select(new moodle_url('/local/townhall/index.php?id=' . $id . ' &type=' . $type . ''), 'typnid', $activity_names[0], $typnid, null, 'switchcategory'); $select->set_label(get_string('activityname', 'local_townhall') . ':'); echo $OUTPUT->render($select); echo HTML_WRITER::end_tag('div'); echo '<div class="town_button"><a href="../../local/townhall/index.php?id=' . $id . ' &cmid=' . $typnid . '&name=' . $type . '&button=1"><button >Submit</button></a></div>'; $data = new stdclass(); $data->courseid = $id; $data->cmid = $cmid; $data->modname = $name; $data->userid = $USER->id; if ($button == 1) { if (empty($name) and $cmid < 0) echo '<h4>' . get_string('error', 'local_townhall') . '</h4>';
/** * Creates the blocks main content * * @return string */ public function get_content() { // Access to settings needed global $USER, $COURSE, $CFG, $DB, $OUTPUT; // If content has already been generated, don't waste time generating it again if ($this->content !== null) { return $this->content; } $this->content = new stdClass(); $this->content->text = ''; $this->content->footer = ''; // Check if any activities/resources have been created $modules = modules_in_use(); if (empty($modules)) { if (has_capability('moodle/block:edit', $this->context)) { $this->content->text .= get_string('no_events_config_message', 'block_progress'); } return $this->content; } // Check if activities/resources have been selected in config $events = event_information($this->config, $modules); if ($events === null || $events === 0) { if (has_capability('moodle/block:edit', $this->context)) { $this->content->text .= get_string('no_events_message', 'block_progress'); if ($USER->editing) { $parameters = array('id' => $COURSE->id, 'sesskey' => sesskey(), 'bui_editid' => $this->instance->id); $url = new moodle_url('/course/view.php', $parameters); $label = get_string('selectitemstobeadded', 'block_progress'); $this->content->text .= $OUTPUT->single_button($url, $label); if ($events === 0) { $url->param('turnallon', '1'); $label = get_string('addallcurrentitems', 'block_progress'); $this->content->text .= $OUTPUT->single_button($url, $label); } } } return $this->content; } else { if (empty($events)) { if (has_capability('moodle/block:edit', $this->context)) { $this->content->text .= get_string('no_visible_events_message', 'block_progress'); } return $this->content; } else { $attempts = get_attempts($modules, $this->config, $events, $USER->id, $this->instance->id); $this->content->text = progress_bar($modules, $this->config, $events, $USER->id, $this->instance->id, $attempts); } } // Organise access to JS $jsmodule = array('name' => 'block_progress', 'fullpath' => '/blocks/progress/module.js', 'requires' => array(), 'strings' => array(array('time_expected', 'block_progress'))); $displaydate = !isset($this->config->displayNow) || $this->config->displayNow == 1; $arguments = array($CFG->wwwroot, array_keys($modules), $displaydate); $this->page->requires->js_init_call('M.block_progress.init', $arguments, false, $jsmodule); // Allow teachers to access the overview page if (has_capability('block/progress:overview', $this->context)) { $parameters = array('id' => $this->instance->id, 'courseid' => $COURSE->id); $url = new moodle_url('/blocks/progress/overview.php', $parameters); $label = get_string('overview', 'block_progress'); $this->content->text .= $OUTPUT->single_button($url, $label); } return $this->content; }
// Get specific block config $block = $DB->get_record('block_instances', array('id' => $id)); $config = unserialize(base64_decode($block->configdata)); // Start page output echo $OUTPUT->header(); echo $OUTPUT->heading($title, 2); echo $OUTPUT->container_start('block_progress'); // Get the modules to check progress on $modules = modules_in_use(); if (empty($modules)) { echo get_string('no_events_config_message', 'block_progress'); echo $OUTPUT->footer(); die; } // Check if activities/resources have been selected in config $events = event_information($config, $modules); if ($events == null) { echo get_string('no_events_message', 'block_progress'); echo $OUTPUT->footer(); die; } if (empty($events)) { echo get_string('no_visible_events_message', 'block_progress'); echo $OUTPUT->footer(); die; } $numevents = count($events); // Determine if a role has been selected $sql = "SELECT DISTINCT r.id, r.name\n FROM {role} r, {role_assignments} a\n WHERE a.contextid = :contextid\n AND r.id = a.roleid\n AND r.shortname = :shortname"; $params = array('contextid' => $context->id, 'shortname' => 'student'); $studentrole = $DB->get_record_sql($sql, $params);