Browse Source

Removed prefixes for attforblock methods. Fixed errors and notices.

MOODLE_23_STABLE
Artem Andreev 13 years ago
parent
commit
032c54637a
  1. 4
      export.php
  2. 22
      locallib.php
  3. 4
      preferences.php
  4. 30
      renderables.php
  5. 14
      renderer.php

4
export.php

@ -46,9 +46,9 @@ if ($mform->is_submitted()) {
$pageparams->set_current_sesstype($formdata->group ? $formdata->group : att_page_with_filter_controls::SESSTYPE_ALL); $pageparams->set_current_sesstype($formdata->group ? $formdata->group : att_page_with_filter_controls::SESSTYPE_ALL);
if (isset($formdata->includeallsessions)) { if (isset($formdata->includeallsessions)) {
if (isset($formdata->includenottaken)) { if (isset($formdata->includenottaken)) {
$pageparams->view = VIEW_ALL; $pageparams->view = ATT_VIEW_ALL;
} else { } else {
$pageparams->view = VIEW_ALLPAST; $pageparams->view = ATT_VIEW_ALLPAST;
$pageparams->curdate = time(); $pageparams->curdate = time();
} }
$pageparams->init_start_end_date(); $pageparams->init_start_end_date();

22
locallib.php

@ -759,7 +759,7 @@ class attforblock {
public function take_from_form_data($formdata) { public function take_from_form_data($formdata) {
global $DB, $USER; global $DB, $USER;
$statuses = implode(',', array_keys( (array)$this->att_get_statuses() )); $statuses = implode(',', array_keys( (array)$this->get_statuses() ));
$now = time(); $now = time();
$sesslog = array(); $sesslog = array();
$formdata = (array)$formdata; $formdata = (array)$formdata;
@ -870,7 +870,7 @@ class attforblock {
return $user; return $user;
} }
public function att_get_statuses($onlyvisible = true) { public function get_statuses($onlyvisible = true) {
global $DB; global $DB;
if (!isset($this->statuses)) { if (!isset($this->statuses)) {
@ -925,13 +925,13 @@ class attforblock {
global $DB; global $DB;
$ret = array(); $ret = array();
$ret['completed'] = $this->att_get_user_taken_sessions_count($userid); $ret['completed'] = $this->get_user_taken_sessions_count($userid);
$ret['statuses'] = $this->att_get_user_statuses_stat($userid); $ret['statuses'] = $this->get_user_statuses_stat($userid);
return $ret; return $ret;
} }
public function att_get_user_taken_sessions_count($userid) { public function get_user_taken_sessions_count($userid) {
global $DB; global $DB;
if (!array_key_exists($userid, $this->usertakensesscount)) if (!array_key_exists($userid, $this->usertakensesscount))
@ -940,7 +940,7 @@ class attforblock {
return $this->usertakensesscount[$userid]; return $this->usertakensesscount[$userid];
} }
public function att_get_user_statuses_stat($userid) { public function get_user_statuses_stat($userid) {
global $DB; global $DB;
if (!array_key_exists($userid, $this->userstatusesstat)) { if (!array_key_exists($userid, $this->userstatusesstat)) {
@ -963,8 +963,8 @@ class attforblock {
return $this->userstatusesstat[$userid]; return $this->userstatusesstat[$userid];
} }
public function att_get_user_grade($userid) { public function get_user_grade($userid) {
return att_get_user_grade($this->att_get_user_statuses_stat($userid), $this->att_get_statuses()); return att_get_user_grade($this->get_user_statuses_stat($userid), $this->get_statuses());
} }
// For getting sessions count implemented simplest method - taken sessions. // For getting sessions count implemented simplest method - taken sessions.
@ -974,8 +974,8 @@ class attforblock {
// * all sessions between user start and end enrolment date. // * all sessions between user start and end enrolment date.
// While implementing those methods we need recalculate grades of all users // While implementing those methods we need recalculate grades of all users
// on session adding // on session adding
public function att_get_user_max_grade($userid) { public function get_user_max_grade($userid) {
return att_get_user_max_grade($this->att_get_user_taken_sessions_count($userid), $this->att_get_statuses()); return att_get_user_max_grade($this->get_user_taken_sessions_count($userid), $this->get_statuses());
} }
public function update_users_grade($userids) { public function update_users_grade($userids) {
@ -983,7 +983,7 @@ class attforblock {
foreach ($userids as $userid) { foreach ($userids as $userid) {
$grades[$userid]->userid = $userid; $grades[$userid]->userid = $userid;
$grades[$userid]->rawgrade = att_calc_user_grade_percent($this->att_get_user_grade($userid), $this->att_get_user_max_grade($userid)); $grades[$userid]->rawgrade = att_calc_user_grade_percent($this->get_user_grade($userid), $this->get_user_max_grade($userid));
} }
return grade_update('mod/attforblock', $this->course->id, 'mod', 'attforblock', return grade_update('mod/attforblock', $this->course->id, 'mod', 'attforblock',

4
preferences.php

@ -44,7 +44,7 @@ switch ($att->pageparams->action) {
$att->add_status($newacronym, $newdescription, $newgrade); $att->add_status($newacronym, $newdescription, $newgrade);
break; break;
case att_preferences_page_params::ACTION_DELETE: case att_preferences_page_params::ACTION_DELETE:
if (has_logs_for_status($att->pageparams->statusid)) if (att_has_logs_for_status($att->pageparams->statusid))
print_error('cantdeletestatus', 'attforblock', "attsettings.php?id=$id"); print_error('cantdeletestatus', 'attforblock', "attsettings.php?id=$id");
$confirm = optional_param('confirm', NULL, PARAM_INT); $confirm = optional_param('confirm', NULL, PARAM_INT);
@ -53,7 +53,7 @@ switch ($att->pageparams->action) {
redirect($att->url_preferences(), get_string('statusdeleted','attforblock')); redirect($att->url_preferences(), get_string('statusdeleted','attforblock'));
} }
$statuses = $att->att_get_statuses(); $statuses = $att->get_statuses();
$status = $statuses[$att->pageparams->statusid]; $status = $statuses[$att->pageparams->statusid];
$message = get_string('deletecheckfull', '', get_string('variable', 'attforblock')); $message = get_string('deletecheckfull', '', get_string('variable', 'attforblock'));
$message .= str_repeat(html_writer::empty_tag('br'), 2); $message .= str_repeat(html_writer::empty_tag('br'), 2);

30
renderables.php

@ -119,13 +119,13 @@ class attforblock_filter_controls implements renderable {
$this->nextcur = make_timestamp($year, $mon, $mday + 1); $this->nextcur = make_timestamp($year, $mon, $mday + 1);
$this->curdatetxt = userdate($att->pageparams->startdate, $format); $this->curdatetxt = userdate($att->pageparams->startdate, $format);
break; break;
case VIEW_WEEKS: case ATT_VIEW_WEEKS:
$format = get_string('strftimedm', 'attforblock'); $format = get_string('strftimedm', 'attforblock');
$this->prevcur = $att->pageparams->startdate - WEEKSECS; $this->prevcur = $att->pageparams->startdate - WEEKSECS;
$this->nextcur = $att->pageparams->startdate + WEEKSECS; $this->nextcur = $att->pageparams->startdate + WEEKSECS;
$this->curdatetxt = userdate($att->pageparams->startdate, $format)." - ".userdate($att->pageparams->enddate, $format); $this->curdatetxt = userdate($att->pageparams->startdate, $format)." - ".userdate($att->pageparams->enddate, $format);
break; break;
case VIEW_MONTHS: case ATT_VIEW_MONTHS:
$format = '%B'; $format = '%B';
$this->prevcur = make_timestamp($year, $mon - 1); $this->prevcur = make_timestamp($year, $mon - 1);
$this->nextcur = make_timestamp($year, $mon + 1); $this->nextcur = make_timestamp($year, $mon + 1);
@ -256,7 +256,7 @@ class attforblock_take_data implements renderable {
$this->groupmode = $att->get_group_mode(); $this->groupmode = $att->get_group_mode();
$this->cm = $att->cm; $this->cm = $att->cm;
$this->statuses = $att->att_get_statuses(); $this->statuses = $att->get_statuses();
$this->sessioninfo = $att->get_session_info($att->pageparams->sessionid); $this->sessioninfo = $att->get_session_info($att->pageparams->sessionid);
$this->updatemode = $this->sessioninfo->lasttaken > 0; $this->updatemode = $this->sessioninfo->lasttaken > 0;
@ -336,14 +336,14 @@ class attforblock_user_data implements renderable {
} }
if ($this->pageparams->mode == att_view_page_params::MODE_THIS_COURSE) { if ($this->pageparams->mode == att_view_page_params::MODE_THIS_COURSE) {
$this->statuses = $att->att_get_statuses(); $this->statuses = $att->get_statuses();
$this->stat = $att->get_user_stat($userid); $this->stat = $att->get_user_stat($userid);
$this->gradable = $att->grade > 0; $this->gradable = $att->grade > 0;
if ($this->gradable) { if ($this->gradable) {
$this->grade = $att->att_get_user_grade($userid); $this->grade = $att->get_user_grade($userid);
$this->maxgrade = $att->att_get_user_max_grade($userid); $this->maxgrade = $att->get_user_max_grade($userid);
} }
@ -352,7 +352,7 @@ class attforblock_user_data implements renderable {
$this->sessionslog = $att->get_user_filtered_sessions_log_extended($userid); $this->sessionslog = $att->get_user_filtered_sessions_log_extended($userid);
} }
else { else {
$this->coursesatts = get_user_courses_attendances($userid); $this->coursesatts = att_get_user_courses_attendances($userid);
$this->statuses = array(); $this->statuses = array();
$this->stat = array(); $this->stat = array();
@ -361,8 +361,8 @@ class attforblock_user_data implements renderable {
$this->maxgrade = array(); $this->maxgrade = array();
foreach ($this->coursesatts as $ca) { foreach ($this->coursesatts as $ca) {
$statuses = att_get_statuses($ca->attid); $statuses = att_get_statuses($ca->attid);
$user_taken_sessions_count = get_user_taken_sessions_count($ca->attid, $ca->coursestartdate, $userid); $user_taken_sessions_count = att_get_user_taken_sessions_count($ca->attid, $ca->coursestartdate, $userid);
$user_statuses_stat = get_user_statuses_stat($ca->attid, $ca->coursestartdate, $userid); $user_statuses_stat = att_get_user_statuses_stat($ca->attid, $ca->coursestartdate, $userid);
$this->statuses[$ca->attid] = $statuses; $this->statuses[$ca->attid] = $statuses;
@ -441,8 +441,8 @@ class attforblock_report_data implements renderable {
$this->sessions = $att->get_filtered_sessions(); $this->sessions = $att->get_filtered_sessions();
$this->statuses = $att->att_get_statuses(); $this->statuses = $att->get_statuses();
$this->allstatuses = $att->att_get_statuses(false); $this->allstatuses = $att->get_statuses(false);
$this->gradable = $att->grade > 0; $this->gradable = $att->grade > 0;
@ -458,8 +458,8 @@ class attforblock_report_data implements renderable {
$this->usersstats[$user->id] = $att->get_user_statuses_stat($user->id); $this->usersstats[$user->id] = $att->get_user_statuses_stat($user->id);
if ($this->gradable) { if ($this->gradable) {
$this->grades[$user->id] = $att->att_get_user_grade($user->id); $this->grades[$user->id] = $att->get_user_grade($user->id);
$this->maxgrades[$user->id] = $att->att_get_user_max_grade($user->id); $this->maxgrades[$user->id] = $att->get_user_max_grade($user->id);
} }
} }
@ -488,9 +488,9 @@ class attforblock_preferences_data implements renderable {
private $att; private $att;
public function __construct(attforblock $att) { public function __construct(attforblock $att) {
$this->statuses = $att->att_get_statuses(false); $this->statuses = $att->get_statuses(false);
foreach ($this->statuses as $st) $st->haslogs = has_logs_for_status ($st->id); foreach ($this->statuses as $st) $st->haslogs = att_has_logs_for_status ($st->id);
$this->att = $att; $this->att = $att;
} }

14
renderer.php

@ -126,10 +126,10 @@ class mod_attforblock_renderer extends plugin_renderer_base {
} }
protected function render_view_controls(attforblock_filter_controls $fcontrols) { protected function render_view_controls(attforblock_filter_controls $fcontrols) {
$views[VIEW_ALL] = get_string('all', 'attforblock'); $views[ATT_VIEW_ALL] = get_string('all', 'attforblock');
$views[VIEW_ALLPAST] = get_string('allpast', 'attforblock'); $views[ATT_VIEW_ALLPAST] = get_string('allpast', 'attforblock');
$views[VIEW_MONTHS] = get_string('months', 'attforblock'); $views[ATT_VIEW_MONTHS] = get_string('months', 'attforblock');
$views[VIEW_WEEKS] = get_string('weeks', 'attforblock'); $views[ATT_VIEW_WEEKS] = get_string('weeks', 'attforblock');
$views[ATT_VIEW_DAYS] = get_string('days', 'attforblock'); $views[ATT_VIEW_DAYS] = get_string('days', 'attforblock');
$viewcontrols = ''; $viewcontrols = '';
foreach ($views as $key => $sview) { foreach ($views as $key => $sview) {
@ -444,12 +444,12 @@ class mod_attforblock_renderer extends plugin_renderer_base {
private function construct_fullname_head($data) { private function construct_fullname_head($data) {
global $CFG; global $CFG;
if ($data->pageparams->sort == SORT_LASTNAME) if ($data->pageparams->sort == ATT_SORT_LASTNAME)
$firstname = html_writer::link($data->url(array('sort' => SORT_FIRSTNAME)), get_string('firstname')); $firstname = html_writer::link($data->url(array('sort' => ATT_SORT_FIRSTNAME)), get_string('firstname'));
else else
$firstname = get_string('firstname'); $firstname = get_string('firstname');
if ($data->pageparams->sort == SORT_FIRSTNAME) if ($data->pageparams->sort == ATT_SORT_FIRSTNAME)
$lastname = html_writer::link($data->url(array('sort' => SORT_LASTNAME)), get_string('lastname')); $lastname = html_writer::link($data->url(array('sort' => SORT_LASTNAME)), get_string('lastname'));
else else
$lastname = get_string('lastname'); $lastname = get_string('lastname');

Loading…
Cancel
Save