Browse Source

On manage.php implemented session types selector. Code of renderable components moved from locallib.php into renderables.php

MOODLE_23_STABLE
Artem Andreev 14 years ago
parent
commit
3c5459f8ac
  1. 328
      locallib.php
  2. 7
      manage.php
  3. 266
      renderables.php
  4. 106
      renderer.php

328
locallib.php

@ -4,14 +4,15 @@ global $CFG;
require_once($CFG->libdir . '/gradelib.php'); require_once($CFG->libdir . '/gradelib.php');
class attforblock_permissions { class attforblock_permissions {
private $canview = null; private $canview;
private $canviewreports = null; private $canviewreports;
private $cantake = null; private $cantake;
private $canchange = null; private $canchange;
private $canmanage = null; private $canmanage;
private $canchangepreferences = null; private $canchangepreferences;
private $canexport = null; private $canexport;
private $canbelisted = null; private $canbelisted;
private $canaccessallgroups;
private $context; private $context;
@ -74,6 +75,13 @@ class attforblock_permissions {
return $this->canbelisted; return $this->canbelisted;
} }
public function can_access_all_groups() {
if (is_null($this->canaccessallgroups))
$this->canaccessallgroups = has_capability('moodle/site:accessallgroups', $this->context);
return $this->canaccessallgroups;
}
} }
class attforblock_view_params { class attforblock_view_params {
@ -224,8 +232,12 @@ class attforblock_view_params {
} }
class attforblock { class attforblock {
const SESSION_COMMON = 1; const SESSION_COMMON = 0;
const SESSION_GROUP = 2; const SESSION_GROUP = 1;
const SELECTOR_COMMON = 0;
const SELECTOR_ALL = -1;
const SELECTOR_NOT_EXISTS = -2;
/** @var stdclass course module record */ /** @var stdclass course module record */
public $cm; public $cm;
@ -250,6 +262,13 @@ class attforblock {
/** @var attforblock_permissions permission of current user for attendance instance*/ /** @var attforblock_permissions permission of current user for attendance instance*/
public $perm; public $perm;
private $groupmode;
private $sessgroupslist;
private $currentgroup;
/** /**
* Initializes the attendance API instance using the data from DB * Initializes the attendance API instance using the data from DB
* *
@ -374,242 +393,107 @@ class attforblock {
$params = array('id' => $this->cm->id); $params = array('id' => $this->cm->id);
return new moodle_url('/mod/attforblock/attendances.php', $params); return new moodle_url('/mod/attforblock/attendances.php', $params);
} }
}
private function calc_groupmode_sessgroupslist_currentgroup(){
global $USER, $SESSION;
/** $cm = $this->cm;
* Represents info about attendance tabs. $this->groupmode = groups_get_activity_groupmode($cm);
*
* Proxy class for security reasons (renderers must not have access to all attforblock methods)
*
*/
class attforblock_tabs implements renderable {
const TAB_SESSIONS = 'sessions';
const TAB_ADD = 'add';
const TAB_REPORT = 'report';
const TAB_EXPORT = 'export';
const TAB_SETTINGS = 'settings';
public $currenttab; if ($this->groupmode == NOGROUPS)
return;
/** @var attforblock */ if ($this->groupmode == VISIBLEGROUPS or $this->perm->can_access_all_groups()) {
private $att; $allowedgroups = groups_get_all_groups($cm->course, 0, $cm->groupingid); // any group in grouping (all if groupings not used)
// detect changes related to groups and fix active group
/** if (!empty($SESSION->activegroup[$cm->course][VISIBLEGROUPS][$cm->groupingid])) {
* Prepare info about sessions for attendance taking into account view parameters. if (!array_key_exists($SESSION->activegroup[$cm->course][VISIBLEGROUPS][$cm->groupingid], $allowedgroups)) {
* // active group does not exist anymore
* @param attforblock $att instance unset($SESSION->activegroup[$cm->course][VISIBLEGROUPS][$cm->groupingid]);
* @param $currenttab - one of attforblock_tabs constants }
*/ }
public function __construct(attforblock $att, $currenttab=self::TAB_SESSIONS) { if (!empty($SESSION->activegroup[$cm->course]['aag'][$cm->groupingid])) {
$this->att = $att; if (!array_key_exists($SESSION->activegroup[$cm->course]['aag'][$cm->groupingid], $allowedgroups)) {
$this->currenttab = $currenttab; // active group does not exist anymore
} unset($SESSION->activegroup[$cm->course]['aag'][$cm->groupingid]);
}
}
/** } else {
* Return array of rows where each row is an array of tab objects $allowedgroups = groups_get_all_groups($cm->course, $USER->id, $cm->groupingid); // only assigned groups
* taking into account permissions of current user // detect changes related to groups and fix active group
*/ if (isset($SESSION->activegroup[$cm->course][SEPARATEGROUPS][$cm->groupingid])) {
public function get_tabs() { if ($SESSION->activegroup[$cm->course][SEPARATEGROUPS][$cm->groupingid] == 0) {
$toprow = array(); if ($allowedgroups) {
if ($this->att->perm->can_manage() or // somebody must have assigned at least one group, we can select it now - yay!
$this->att->perm->can_take() or unset($SESSION->activegroup[$cm->course][SEPARATEGROUPS][$cm->groupingid]);
$this->att->perm->can_change()) { }
$toprow[] = new tabobject(self::TAB_SESSIONS, $this->att->url_sessions()->out(), } else {
get_string('sessions','attforblock')); if (!array_key_exists($SESSION->activegroup[$cm->course][SEPARATEGROUPS][$cm->groupingid], $allowedgroups)) {
// active group not allowed or does not exist anymore
unset($SESSION->activegroup[$cm->course][SEPARATEGROUPS][$cm->groupingid]);
}
}
}
} }
if ($this->att->perm->can_manage()) { $group = optional_param('group', self::SELECTOR_NOT_EXISTS, PARAM_INT);
$toprow[] = new tabobject(self::TAB_ADD, $this->att->url_sessions()->out(true, array('action' => 'add')), if (!array_key_exists('attsessiontype', $SESSION)) {
get_string('add','attforblock')); $SESSION->attsessiontype = array();
} }
if ($group > self::SELECTOR_NOT_EXISTS) {
if ($this->att->perm->can_viewreports()) { $SESSION->attsessiontype[$cm->course] = $group;
$toprow[] = new tabobject(self::TAB_REPORT, $this->att->url_report()->out(), } elseif (!array_key_exists($cm->course, $SESSION->attsessiontype)) {
get_string('report','attforblock')); $SESSION->attsessiontype[$cm->course] = self::SELECTOR_ALL;
} }
if ($this->att->perm->can_export()) { if ($group == self::SELECTOR_ALL) {
$toprow[] = new tabobject(self::TAB_EXPORT, $this->att->url_export()->out(), $this->currentgroup = $group;
get_string('export','quiz')); unset($SESSION->activegroup[$cm->course][VISIBLEGROUPS][$cm->groupingid]);
unset($SESSION->activegroup[$cm->course]['aag'][$cm->groupingid]);
unset($SESSION->activegroup[$cm->course][SEPARATEGROUPS][$cm->groupingid]);
} else {
$this->currentgroup = groups_get_activity_group($cm, true);
if ($this->currentgroup == 0 and $SESSION->attsessiontype[$cm->course] == self::SELECTOR_ALL) {
$this->currentgroup = self::SELECTOR_ALL;
}
} }
if ($this->att->perm->can_change_preferences()) { $this->sessgroupslist = array();
$toprow[] = new tabobject(self::TAB_SETTINGS, $this->att->url_settings()->out(), if ($allowedgroups or $this->groupmode == VISIBLEGROUPS or $this->perm->can_access_all_groups()) {
get_string('settings','attforblock')); $this->sessgroupslist[self::SELECTOR_ALL] = get_string('all', 'attforblock');
} }
if ($this->groupmode == VISIBLEGROUPS) {
return array($toprow); $this->sessgroupslist[self::SELECTOR_COMMON] = get_string('commonsessions', 'attforblock');
}
}
class attforblock_filter_controls implements renderable {
/** @var int current view mode */
public $view;
public $curdate;
public $prevcur;
public $nextcur;
public $curdatetxt;
private $url_path;
private $url_params;
private $att;
public function __construct(attforblock $att) {
global $PAGE;
$this->view = $att->view_params->view;
$this->curdate = $att->view_params->curdate;
$date = usergetdate($att->view_params->curdate);
$mday = $date['mday'];
$wday = $date['wday'];
$mon = $date['mon'];
$year = $date['year'];
switch ($this->view) {
case attforblock_view_params::VIEW_DAYS:
$format = get_string('strftimedm', 'attforblock');
$this->prevcur = make_timestamp($year, $mon, $mday - 1);
$this->nextcur = make_timestamp($year, $mon, $mday + 1);
$this->curdatetxt = userdate($att->view_params->startdate, $format);
break;
case attforblock_view_params::VIEW_WEEKS:
$format = get_string('strftimedm', 'attforblock');
$this->prevcur = $att->view_params->startdate - WEEKSECS;
$this->nextcur = $att->view_params->startdate + WEEKSECS;
$this->curdatetxt = userdate($att->view_params->startdate, $format)." - ".userdate($att->view_params->enddate, $format);
break;
case attforblock_view_params::VIEW_MONTHS:
$format = '%B';
$this->prevcur = make_timestamp($year, $mon - 1);
$this->nextcur = make_timestamp($year, $mon + 1);
$this->curdatetxt = userdate($att->view_params->startdate, $format);
break;
} }
if ($allowedgroups) {
$this->url_path = $PAGE->url->out_omit_querystring(); foreach ($allowedgroups as $group) {
$params = array('id' => $att->cm->id); $this->sessgroupslist[$group->id] = format_string($group->name);
if (isset($att->view_params->students_sort)) $params['sort'] = $att->view_params->students_sort; }
if (isset($att->view_params->student_id)) $params['studentid'] = $att->view_params->student_id;
$this->url_params = $params;
$this->att = $att;
}
public function url($params=array()) {
$params = array_merge($this->url_params, $params);
return new moodle_url($this->url_path, $params);
}
public function url_path() {
return $this->url_path;
}
public function url_params($params=array()) {
$params = array_merge($this->url_params, $params);
return $params;
}
}
/**
* Represents info about attendance sessions taking into account view parameters.
*
*/
class attforblock_sessions_manage_data implements renderable {
/** @var int start date of displayed date range */
public $startdate;
/** @var int end date of displayed date range */
public $enddate;
/** @var array of sessions*/
public $sessions;
/** @var int number of hidden sessions (sessions before $course->startdate)*/
public $hiddensessionscount;
/** @var attforblock_permissions permission of current user for attendance instance*/
public $perm;
/** @var int whether sessions end time will be displayed */
public $showendtime;
public $groups;
public $hiddensesscount;
/** @var attforblock */
private $att;
/**
* Prepare info about attendance sessions taking into account view parameters.
*
* @param attforblock $att instance
*/
public function __construct(attforblock $att) {
global $DB;
$this->perm = $att->perm;
$this->showendtime = $att->view_params->show_endtime;
$this->startdate = $att->view_params->startdate;
$this->enddate = $att->view_params->enddate;
if ($this->startdate && $this->enddate) {
$where = "courseid=:cid AND attendanceid = :aid AND sessdate >= :csdate AND sessdate >= :sdate AND sessdate < :edate";
} else {
$where = "courseid=:cid AND attendanceid = :aid AND sessdate >= :csdate";
} }
$params = array( }
'cid' => $att->course->id,
'aid' => $att->id,
'csdate' => $att->course->startdate,
'sdate' => $this->startdate,
'edate' => $this->enddate/*,
'cgroup' => $currentgroup*/);
$this->sessions = $DB->get_records_select('attendance_sessions', $where, $params, 'sessdate asc');
$where = "courseid = :cid AND attendanceid = :aid AND sessdate < :csdate";
$params = array(
'cid' => $att->course->id,
'aid' => $att->id,
'csdate' => $att->course->startdate);
$this->hiddensessionscount = $DB->count_records_select('attendance_sessions', $where, $params);
$this->groups = groups_get_all_groups($att->course->id);
$this->hiddensessionscount = $att->get_hidden_sessions_count(); public function get_group_mode() {
if (is_null($this->groupmode))
$this->calc_groupmode_sessgroupslist_currentgroup();
$this->att = $att; return $this->groupmode;
} }
public function url_take($sessionid, $grouptype=NULL) { public function get_sess_groups_list() {
$params = array('sessionid' => $sessionid); if (is_null($this->sessgroupslist))
$url = new moodle_url($this->att->url_take(), $params); $this->calc_groupmode_sessgroupslist_currentgroup();
if (isset($grouptype))
$url->param('grouptype', $grouptype);
return $url; return $this->sessgroupslist;
} }
/** public function get_current_group() {
* Must be called without or with both parameters if (is_null($this->currentgroup))
*/ $this->calc_groupmode_sessgroupslist_currentgroup();
public function url_sessions($sessionid=NULL, $action=NULL) {
$url = new moodle_url($this->att->url_sessions());
if (isset($sessionid) && isset($action))
$url->params(array('sessionid' => $sessionid, 'action' => $action));
return $url; return $this->currentgroup;
} }
} }
?> ?>

7
manage.php

@ -26,13 +26,10 @@ $att = $DB->get_record('attforblock', array('id' => $cm->instance), '
require_login($course, true, $cm); require_login($course, true, $cm);
$canmanage = !has_capability('mod/attforblock:manageattendances', $PAGE->context); $att = new attforblock($att, $cm, $course, $PAGE->context);
$cantake = !has_capability('mod/attforblock:takeattendances', $PAGE->context); if (!$att->perm->can_manage() && !$att->perm->can_take() && !$att->perm->can_change())
$canchange = !has_capability('mod/attforblock:changeattendances', $PAGE->context);
if ($canmanage && $cantake && $canchange)
redirect("view.php?id=$cm->id"); redirect("view.php?id=$cm->id");
$att = new attforblock($att, $cm, $course, $PAGE->context);
$att->view_params->init($view_params); $att->view_params->init($view_params);
// if teacher is coming from block, then check for a session exists for today // if teacher is coming from block, then check for a session exists for today

266
renderables.php

@ -0,0 +1,266 @@
<?php
/**
* Attendance module renderable components are defined here
*
* @package mod
* @subpackage attforblock
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once(dirname(__FILE__).'/locallib.php');
/**
* Represents info about attendance tabs.
*
* Proxy class for security reasons (renderers must not have access to all attforblock methods)
*
*/
class attforblock_tabs implements renderable {
const TAB_SESSIONS = 'sessions';
const TAB_ADD = 'add';
const TAB_REPORT = 'report';
const TAB_EXPORT = 'export';
const TAB_SETTINGS = 'settings';
public $currenttab;
/** @var attforblock */
private $att;
/**
* Prepare info about sessions for attendance taking into account view parameters.
*
* @param attforblock $att instance
* @param $currenttab - one of attforblock_tabs constants
*/
public function __construct(attforblock $att, $currenttab=self::TAB_SESSIONS) {
$this->att = $att;
$this->currenttab = $currenttab;
}
/**
* 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_sessions()->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' => 'add')),
get_string('add','attforblock'));
}
if ($this->att->perm->can_viewreports()) {
$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_SETTINGS, $this->att->url_settings()->out(),
get_string('settings','attforblock'));
}
return array($toprow);
}
}
class attforblock_filter_controls implements renderable {
/** @var int current view mode */
public $view;
public $curdate;
public $prevcur;
public $nextcur;
public $curdatetxt;
private $url_path;
private $url_params;
private $att;
public function __construct(attforblock $att) {
global $PAGE;
$this->view = $att->view_params->view;
$this->curdate = $att->view_params->curdate;
$date = usergetdate($att->view_params->curdate);
$mday = $date['mday'];
$wday = $date['wday'];
$mon = $date['mon'];
$year = $date['year'];
switch ($this->view) {
case attforblock_view_params::VIEW_DAYS:
$format = get_string('strftimedm', 'attforblock');
$this->prevcur = make_timestamp($year, $mon, $mday - 1);
$this->nextcur = make_timestamp($year, $mon, $mday + 1);
$this->curdatetxt = userdate($att->view_params->startdate, $format);
break;
case attforblock_view_params::VIEW_WEEKS:
$format = get_string('strftimedm', 'attforblock');
$this->prevcur = $att->view_params->startdate - WEEKSECS;
$this->nextcur = $att->view_params->startdate + WEEKSECS;
$this->curdatetxt = userdate($att->view_params->startdate, $format)." - ".userdate($att->view_params->enddate, $format);
break;
case attforblock_view_params::VIEW_MONTHS:
$format = '%B';
$this->prevcur = make_timestamp($year, $mon - 1);
$this->nextcur = make_timestamp($year, $mon + 1);
$this->curdatetxt = userdate($att->view_params->startdate, $format);
break;
}
$this->url_path = $PAGE->url->out_omit_querystring();
$params = array('id' => $att->cm->id);
if (isset($att->view_params->students_sort)) $params['sort'] = $att->view_params->students_sort;
if (isset($att->view_params->student_id)) $params['studentid'] = $att->view_params->student_id;
$this->url_params = $params;
$this->att = $att;
}
public function url($params=array()) {
$params = array_merge($this->url_params, $params);
return new moodle_url($this->url_path, $params);
}
public function url_path() {
return $this->url_path;
}
public function url_params($params=array()) {
$params = array_merge($this->url_params, $params);
return $params;
}
public function get_group_mode() {
return $this->att->get_group_mode();
}
public function get_sess_groups_list() {
return $this->att->get_sess_groups_list();
}
public function get_current_group() {
return $this->att->get_current_group();
}
}
/**
* Represents info about attendance sessions taking into account view parameters.
*
*/
class attforblock_sessions_manage_data implements renderable {
/** @var int start date of displayed date range */
public $startdate;
/** @var int end date of displayed date range */
public $enddate;
/** @var array of sessions*/
public $sessions;
/** @var int number of hidden sessions (sessions before $course->startdate)*/
public $hiddensessionscount;
/** @var attforblock_permissions permission of current user for attendance instance*/
public $perm;
/** @var int whether sessions end time will be displayed */
public $showendtime;
public $groups;
public $hiddensesscount;
/** @var attforblock */
private $att;
/**
* Prepare info about attendance sessions taking into account view parameters.
*
* @param attforblock $att instance
*/
public function __construct(attforblock $att) {
global $DB;
$this->perm = $att->perm;
$this->showendtime = $att->view_params->show_endtime;
$this->startdate = $att->view_params->startdate;
$this->enddate = $att->view_params->enddate;
if ($this->startdate && $this->enddate) {
$where = "courseid=:cid AND attendanceid = :aid AND sessdate >= :csdate AND sessdate >= :sdate AND sessdate < :edate";
} else {
$where = "courseid=:cid AND attendanceid = :aid AND sessdate >= :csdate";
}
if ($att->get_current_group() > attforblock::SELECTOR_ALL) {
$where .= " AND groupid=:cgroup";
}
$params = array(
'cid' => $att->course->id,
'aid' => $att->id,
'csdate' => $att->course->startdate,
'sdate' => $this->startdate,
'edate' => $this->enddate,
'cgroup' => $att->get_current_group());
$this->sessions = $DB->get_records_select('attendance_sessions', $where, $params, 'sessdate asc');
$where = "courseid = :cid AND attendanceid = :aid AND sessdate < :csdate";
$params = array(
'cid' => $att->course->id,
'aid' => $att->id,
'csdate' => $att->course->startdate);
$this->hiddensessionscount = $DB->count_records_select('attendance_sessions', $where, $params);
$this->groups = groups_get_all_groups($att->course->id);
$this->hiddensessionscount = $att->get_hidden_sessions_count();
$this->att = $att;
}
public function url_take($sessionid, $grouptype=NULL) {
$params = array('sessionid' => $sessionid);
$url = new moodle_url($this->att->url_take(), $params);
if (isset($grouptype))
$url->param('grouptype', $grouptype);
return $url;
}
/**
* Must be called without or with both parameters
*/
public function url_sessions($sessionid=NULL, $action=NULL) {
$url = new moodle_url($this->att->url_sessions());
if (isset($sessionid) && isset($action))
$url->params(array('sessionid' => $sessionid, 'action' => $action));
return $url;
}
}
?>

106
renderer.php

@ -11,6 +11,7 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
require_once(dirname(__FILE__).'/locallib.php'); require_once(dirname(__FILE__).'/locallib.php');
require_once(dirname(__FILE__).'/renderables.php');
/** /**
* Attendance module renderer class * Attendance module renderer class
@ -45,7 +46,7 @@ class mod_attforblock_renderer extends plugin_renderer_base {
$filtertable->width = '100%'; $filtertable->width = '100%';
$filtertable->align = array('left', 'center', 'right'); $filtertable->align = array('left', 'center', 'right');
$filtertable->data[0][] = ''; $filtertable->data[0][] = $this->render_sess_group_selector($fcontrols);
$filtertable->data[0][] = $this->render_curdate_controls($fcontrols); $filtertable->data[0][] = $this->render_curdate_controls($fcontrols);
@ -57,6 +58,109 @@ class mod_attforblock_renderer extends plugin_renderer_base {
return $o; return $o;
} }
private function render_sess_group_selector(attforblock_filter_controls $fcontrols) {
if ($fcontrols->get_group_mode() == NOGROUPS)
return '';
$select = new single_select($fcontrols->url(), 'group', $fcontrols->get_sess_groups_list(),
$fcontrols->get_current_group(), null, 'selectgroup');
$select->label = get_string('sessions', 'attforblock');
$output = $this->output->render($select);
return html_writer::tag('div', $output, array('class' => 'groupselector'));
/*$currentgroup = -1;
$sessiontypeselector = '';
if ($printselector === GROUP_SELECTOR) {
$groupmode = groups_get_activity_groupmode($cm);
$currentgroup = groups_get_activity_group($cm, true);
$groupselector = '';
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
if ($groupmode == VISIBLEGROUPS ||
($groupmode && has_capability('moodle/site:accessallgroups', $context))) {
$groupselector = groups_print_activity_menu($cm, $CFG->wwwroot . '/mod/attforblock/' . $link, true);
}
} elseif ($printselector === SESSION_TYPE_SELECTOR and $groupmode = groups_get_activity_groupmode($cm)) {
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
if ($groupmode == VISIBLEGROUPS or has_capability('moodle/site:accessallgroups', $context)) {
$allowedgroups = groups_get_all_groups($cm->course, 0, $cm->groupingid); // any group in grouping (all if groupings not used)
// detect changes related to groups and fix active group
if (!empty($SESSION->activegroup[$cm->course][VISIBLEGROUPS][$cm->groupingid])) {
if (!array_key_exists($SESSION->activegroup[$cm->course][VISIBLEGROUPS][$cm->groupingid], $allowedgroups)) {
// active group does not exist anymore
unset($SESSION->activegroup[$cm->course][VISIBLEGROUPS][$cm->groupingid]);
}
}
if (!empty($SESSION->activegroup[$cm->course]['aag'][$cm->groupingid])) {
if (!array_key_exists($SESSION->activegroup[$cm->course]['aag'][$cm->groupingid], $allowedgroups)) {
// active group does not exist anymore
unset($SESSION->activegroup[$cm->course]['aag'][$cm->groupingid]);
}
}
} else {
$allowedgroups = groups_get_all_groups($cm->course, $USER->id, $cm->groupingid); // only assigned groups
// detect changes related to groups and fix active group
if (isset($SESSION->activegroup[$cm->course][SEPARATEGROUPS][$cm->groupingid])) {
if ($SESSION->activegroup[$cm->course][SEPARATEGROUPS][$cm->groupingid] == 0) {
if ($allowedgroups) {
// somebody must have assigned at least one group, we can select it now - yay!
unset($SESSION->activegroup[$cm->course][SEPARATEGROUPS][$cm->groupingid]);
}
} else {
if (!array_key_exists($SESSION->activegroup[$cm->course][SEPARATEGROUPS][$cm->groupingid], $allowedgroups)) {
// active group not allowed or does not exist anymore
unset($SESSION->activegroup[$cm->course][SEPARATEGROUPS][$cm->groupingid]);
}
}
}
}
$group = optional_param('group', -2, PARAM_INT);
if (!array_key_exists('attsessiontype', $SESSION)) {
$SESSION->attsessiontype = array();
}
if ($group > -2) {
$SESSION->attsessiontype[$cm->course] = $group;
} elseif (!array_key_exists($cm->course, $SESSION->attsessiontype)) {
$SESSION->attsessiontype[$cm->course] = -1;
}
if ($group == -1) {
$currentgroup = $group;
unset($SESSION->activegroup[$cm->course][VISIBLEGROUPS][$cm->groupingid]);
unset($SESSION->activegroup[$cm->course]['aag'][$cm->groupingid]);
unset($SESSION->activegroup[$cm->course][SEPARATEGROUPS][$cm->groupingid]);
} else {
$currentgroup = groups_get_activity_group($cm, true);
if ($currentgroup == 0 and $SESSION->attsessiontype[$cm->course] == -1) {
$currentgroup = -1;
}
}
$selector = array();
if ($allowedgroups or $groupmode == VISIBLEGROUPS or
has_capability('moodle/site:accessallgroups', $context)) {
$selector[-1] = get_string('all', 'attforblock');
}
if ($groupmode == VISIBLEGROUPS) {
$selector[0] = get_string('commonsessions', 'attforblock');
}
if ($allowedgroups) {
foreach ($allowedgroups as $group) {
$selector[$group->id] = format_string($group->name);
}
}
if (count($selector) > 1) {
$sessiontypeselector = popup_form($url.'?id='.$cm->id.'&amp;group=', $selector, 'selectgroup', $currentgroup, '', '', '', true, 'self', get_string('sessions', 'attforblock'));
}
$sessiontypeselector = '<div class="groupselector">'.$sessiontypeselector.'</div>';
}*/
}
private function render_curdate_controls(attforblock_filter_controls $fcontrols) { private function render_curdate_controls(attforblock_filter_controls $fcontrols) {
global $CFG; global $CFG;

Loading…
Cancel
Save