Browse Source

Some refactoring for better using from attendance block

MOODLE_23_STABLE
Artem Andreev 14 years ago
parent
commit
163c4c1805
  1. 21
      lib.php
  2. 4
      locallib.php
  3. 27
      renderhelpers.php
  4. 2
      styles.css

21
lib.php

@ -198,26 +198,7 @@ function attforblock_user_complete($course, $user, $mod, $attforblock) {
require_once($CFG->libdir.'/gradelib.php');
if (has_capability('mod/attforblock:canbelisted', $mod->context, $user->id)) {
$gradeable = $attforblock->grade > 0;
$statuses = get_statuses($attforblock->id);
$userstatusesstat = get_user_statuses_stat($attforblock->id, $course->startdate, $user->id);
$stat['completed'] = get_user_taken_sessions_count($attforblock->id, $course->startdate, $user->id);
$stat['statuses'] = $userstatusesstat;
if ($gradeable) {
$grade = get_user_grade($userstatusesstat, $statuses);
$maxgrade = get_user_max_grade(get_user_taken_sessions_count($attforblock->id, $course->startdate, $user->id), $statuses);
if (!$decimalpoints = grade_get_setting($course->id, 'decimalpoints')) {
$decimalpoints = $CFG->grade_decimalpoints;
}
}
else {
$grade = 0;
$maxgrade = 0;
$decimalpoints = 0;
}
echo construct_user_data_stat($stat, $statuses,
$gradeable, $grade, $maxgrade, $decimalpoints);
echo construct_full_user_stat_html_table($attforblock, $course, $user);
}
//return true;

4
locallib.php

@ -657,8 +657,8 @@ class attforblock {
/**
* @return moodle_url of manage.php for attendance instance
*/
public function url_manage() {
$params = array('id' => $this->cm->id);
public function url_manage($params=array()) {
$params = array_merge(array('id' => $this->cm->id), $params);
return new moodle_url('/mod/attforblock/manage.php', $params);
}

27
renderhelpers.php

@ -170,7 +170,7 @@ function construct_session_full_date_time($datetime, $duration) {
function construct_user_data_stat($stat, $statuses, $gradable, $grade, $maxgrade, $decimalpoints) {
$stattable = new html_table();
$stattable->attributes['class'] = 'list';
$stattable->attributes['class'] = 'attlist';
$row = new html_table_row();
$row->cells[] = get_string('sessionscompleted','attforblock').':';
$row->cells[] = $stat['completed'];
@ -204,5 +204,30 @@ function construct_user_data_stat($stat, $statuses, $gradable, $grade, $maxgrade
return html_writer::table($stattable);
}
function construct_full_user_stat_html_table($attforblock, $course, $user) {
global $CFG;
$gradeable = $attforblock->grade > 0;
$statuses = get_statuses($attforblock->id);
$userstatusesstat = get_user_statuses_stat($attforblock->id, $course->startdate, $user->id);
$stat['completed'] = get_user_taken_sessions_count($attforblock->id, $course->startdate, $user->id);
$stat['statuses'] = $userstatusesstat;
if ($gradeable) {
$grade = get_user_grade($userstatusesstat, $statuses);
$maxgrade = get_user_max_grade(get_user_taken_sessions_count($attforblock->id, $course->startdate, $user->id), $statuses);
if (!$decimalpoints = grade_get_setting($course->id, 'decimalpoints')) {
$decimalpoints = $CFG->grade_decimalpoints;
}
}
else {
$grade = 0;
$maxgrade = 0;
$decimalpoints = 0;
}
return construct_user_data_stat($stat, $statuses,
$gradeable, $grade, $maxgrade, $decimalpoints);
}
?>

2
styles.css

@ -112,7 +112,7 @@
background-color: #EEEEEE;
padding: 30px 10px;
}
.path-mod-attforblock table.list td.c0 {
.path-mod-attforblock table.attlist td.c0 {
text-align: right;
}

Loading…
Cancel
Save