mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
Merge branch 'wip-MDL-35608-master' of git://github.com/phalacee/moodle
This commit is contained in:
commit
9adb30759f
7 changed files with 184 additions and 153 deletions
|
@ -29,8 +29,8 @@ defined('MOODLE_INTERNAL') || die();
|
||||||
require_once("{$CFG->libdir}/completionlib.php");
|
require_once("{$CFG->libdir}/completionlib.php");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Course completion status
|
* Course completion status.
|
||||||
* Displays overall, and individual criteria status for logged in user
|
* Displays overall, and individual criteria status for logged in user.
|
||||||
*/
|
*/
|
||||||
class block_completionstatus extends block_base {
|
class block_completionstatus extends block_base {
|
||||||
|
|
||||||
|
@ -38,28 +38,31 @@ class block_completionstatus extends block_base {
|
||||||
$this->title = get_string('pluginname', 'block_completionstatus');
|
$this->title = get_string('pluginname', 'block_completionstatus');
|
||||||
}
|
}
|
||||||
|
|
||||||
function applicable_formats() {
|
public function applicable_formats() {
|
||||||
return array('all' => true, 'mod' => false, 'tag' => false, 'my' => false);
|
return array('all' => true, 'mod' => false, 'tag' => false, 'my' => false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_content() {
|
public function get_content() {
|
||||||
global $USER;
|
global $USER;
|
||||||
|
|
||||||
// If content is cached
|
$rows = array();
|
||||||
if ($this->content !== NULL) {
|
$srows = array();
|
||||||
|
$prows = array();
|
||||||
|
// If content is cached.
|
||||||
|
if ($this->content !== null) {
|
||||||
return $this->content;
|
return $this->content;
|
||||||
}
|
}
|
||||||
|
|
||||||
$course = $this->page->course;
|
$course = $this->page->course;
|
||||||
$context = context_course::instance($course->id);
|
$context = context_course::instance($course->id);
|
||||||
|
|
||||||
// Create empty content
|
// Create empty content.
|
||||||
$this->content = new stdClass();
|
$this->content = new stdClass();
|
||||||
|
|
||||||
// Can edit settings?
|
// Can edit settings?
|
||||||
$can_edit = has_capability('moodle/course:update', $context);
|
$can_edit = has_capability('moodle/course:update', $context);
|
||||||
|
|
||||||
// Get course completion data
|
// Get course completion data.
|
||||||
$info = new completion_info($course);
|
$info = new completion_info($course);
|
||||||
|
|
||||||
// Don't display if completion isn't enabled!
|
// Don't display if completion isn't enabled!
|
||||||
|
@ -76,10 +79,10 @@ class block_completionstatus extends block_base {
|
||||||
return $this->content;
|
return $this->content;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load criteria to display
|
// Load criteria to display.
|
||||||
$completions = $info->get_completions($USER->id);
|
$completions = $info->get_completions($USER->id);
|
||||||
|
|
||||||
// Check if this course has any criteria
|
// Check if this course has any criteria.
|
||||||
if (empty($completions)) {
|
if (empty($completions)) {
|
||||||
if ($can_edit) {
|
if ($can_edit) {
|
||||||
$this->content->text = get_string('nocriteriaset', 'completion');
|
$this->content->text = get_string('nocriteriaset', 'completion');
|
||||||
|
@ -87,27 +90,25 @@ class block_completionstatus extends block_base {
|
||||||
return $this->content;
|
return $this->content;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check this user is enroled
|
// Check this user is enroled.
|
||||||
if ($info->is_tracked_user($USER->id)) {
|
if ($info->is_tracked_user($USER->id)) {
|
||||||
|
|
||||||
// Generate markup for criteria statuses
|
// Generate markup for criteria statuses.
|
||||||
$shtml = '';
|
$data = '';
|
||||||
|
|
||||||
// For aggregating activity completion
|
// For aggregating activity completion.
|
||||||
$activities = array();
|
$activities = array();
|
||||||
$activities_complete = 0;
|
$activities_complete = 0;
|
||||||
|
|
||||||
// For aggregating course prerequisites
|
// For aggregating course prerequisites.
|
||||||
$prerequisites = array();
|
$prerequisites = array();
|
||||||
$prerequisites_complete = 0;
|
$prerequisites_complete = 0;
|
||||||
|
|
||||||
// Flag to set if current completion data is inconsistent with
|
// Flag to set if current completion data is inconsistent with what is stored in the database.
|
||||||
// what is stored in the database
|
|
||||||
$pending_update = false;
|
$pending_update = false;
|
||||||
|
|
||||||
// Loop through course criteria
|
// Loop through course criteria.
|
||||||
foreach ($completions as $completion) {
|
foreach ($completions as $completion) {
|
||||||
|
|
||||||
$criteria = $completion->get_criteria();
|
$criteria = $completion->get_criteria();
|
||||||
$complete = $completion->is_complete();
|
$complete = $completion->is_complete();
|
||||||
|
|
||||||
|
@ -115,7 +116,7 @@ class block_completionstatus extends block_base {
|
||||||
$pending_update = true;
|
$pending_update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Activities are a special case, so cache them and leave them till last
|
// Activities are a special case, so cache them and leave them till last.
|
||||||
if ($criteria->criteriatype == COMPLETION_CRITERIA_TYPE_ACTIVITY) {
|
if ($criteria->criteriatype == COMPLETION_CRITERIA_TYPE_ACTIVITY) {
|
||||||
$activities[$criteria->moduleinstance] = $complete;
|
$activities[$criteria->moduleinstance] = $complete;
|
||||||
|
|
||||||
|
@ -126,7 +127,7 @@ class block_completionstatus extends block_base {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prerequisites are also a special case, so cache them and leave them till last
|
// Prerequisites are also a special case, so cache them and leave them till last.
|
||||||
if ($criteria->criteriatype == COMPLETION_CRITERIA_TYPE_COURSE) {
|
if ($criteria->criteriatype == COMPLETION_CRITERIA_TYPE_COURSE) {
|
||||||
$prerequisites[$criteria->courseinstance] = $complete;
|
$prerequisites[$criteria->courseinstance] = $complete;
|
||||||
|
|
||||||
|
@ -136,50 +137,53 @@ class block_completionstatus extends block_base {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
$row = new html_table_row();
|
||||||
$shtml .= '<tr><td>';
|
$row->cells[0] = new html_table_cell($criteria->get_title());
|
||||||
$shtml .= $criteria->get_title();
|
$row->cells[1] = new html_table_cell($completion->get_status());
|
||||||
$shtml .= '</td><td style="text-align: right">';
|
$row->cells[1]->style = 'text-align: right;';
|
||||||
$shtml .= $completion->get_status();
|
$srows[] = $row;
|
||||||
$shtml .= '</td></tr>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Aggregate activities
|
// Aggregate activities.
|
||||||
if (!empty($activities)) {
|
if (!empty($activities)) {
|
||||||
|
|
||||||
$shtml .= '<tr><td>';
|
|
||||||
$shtml .= get_string('activitiescompleted', 'completion');
|
|
||||||
$shtml .= '</td><td style="text-align: right">';
|
|
||||||
$a = new stdClass();
|
$a = new stdClass();
|
||||||
$a->first = $activities_complete;
|
$a->first = $activities_complete;
|
||||||
$a->second = count($activities);
|
$a->second = count($activities);
|
||||||
$shtml .= get_string('firstofsecond', 'block_completionstatus', $a);
|
|
||||||
$shtml .= '</td></tr>';
|
$row = new html_table_row();
|
||||||
|
$row->cells[0] = new html_table_cell(get_string('activitiescompleted', 'completion'));
|
||||||
|
$row->cells[1] = new html_table_cell(get_string('firstofsecond', 'block_completionstatus', $a));
|
||||||
|
$row->cells[1]->style = 'text-align: right;';
|
||||||
|
$srows[] = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Aggregate prerequisites
|
// Aggregate prerequisites.
|
||||||
if (!empty($prerequisites)) {
|
if (!empty($prerequisites)) {
|
||||||
|
|
||||||
$phtml = '<tr><td>';
|
|
||||||
$phtml .= get_string('dependenciescompleted', 'completion');
|
|
||||||
$phtml .= '</td><td style="text-align: right">';
|
|
||||||
$a = new stdClass();
|
$a = new stdClass();
|
||||||
$a->first = $prerequisites_complete;
|
$a->first = $prerequisites_complete;
|
||||||
$a->second = count($prerequisites);
|
$a->second = count($prerequisites);
|
||||||
$phtml .= get_string('firstofsecond', 'block_completionstatus', $a);
|
|
||||||
$phtml .= '</td></tr>';
|
|
||||||
|
|
||||||
$shtml = $phtml . $shtml;
|
$row = new html_table_row();
|
||||||
|
$row->cells[0] = new html_table_cell(get_string('dependenciescompleted', 'completion'));
|
||||||
|
$row->cells[1] = new html_table_cell(get_string('firstofsecond', 'block_completionstatus', $a));
|
||||||
|
$row->cells[1]->style = 'text-align: right;';
|
||||||
|
$prows[] = $row;
|
||||||
|
|
||||||
|
$srows = array_merge($prows, $srows);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display completion status
|
// Display completion status.
|
||||||
$this->content->text = '<table width="100%" style="font-size: 90%;"><tbody>';
|
$table = new html_table();
|
||||||
$this->content->text .= '<tr><td colspan="2"><b>'.get_string('status').':</b> ';
|
$table->width = '100%';
|
||||||
|
$table->attributes = array('style'=>'font-size: 90%;', 'class'=>'');
|
||||||
|
|
||||||
|
$row = new html_table_row();
|
||||||
|
$content = html_writer::tag('b', get_string('status').': ');
|
||||||
|
|
||||||
// Is course complete?
|
// Is course complete?
|
||||||
$coursecomplete = $info->is_course_complete($USER->id);
|
$coursecomplete = $info->is_course_complete($USER->id);
|
||||||
|
|
||||||
// Load course completion
|
// Load course completion.
|
||||||
$params = array(
|
$params = array(
|
||||||
'userid' => $USER->id,
|
'userid' => $USER->id,
|
||||||
'course' => $course->id
|
'course' => $course->id
|
||||||
|
@ -190,45 +194,61 @@ class block_completionstatus extends block_base {
|
||||||
$criteriacomplete = $info->count_course_user_data($USER->id);
|
$criteriacomplete = $info->count_course_user_data($USER->id);
|
||||||
|
|
||||||
if ($pending_update) {
|
if ($pending_update) {
|
||||||
$this->content->text .= '<i>'.get_string('pending', 'completion').'</i>';
|
$content .= html_writer::tag('i', get_string('pending', 'completion'));
|
||||||
} else if ($coursecomplete) {
|
} else if ($coursecomplete) {
|
||||||
$this->content->text .= get_string('complete');
|
$content .= get_string('complete');
|
||||||
} else if (!$criteriacomplete && !$ccompletion->timestarted) {
|
} else if (!$criteriacomplete && !$ccompletion->timestarted) {
|
||||||
$this->content->text .= '<i>'.get_string('notyetstarted', 'completion').'</i>';
|
$content .= html_writer::tag('i', get_string('notyetstarted', 'completion'));
|
||||||
} else {
|
} else {
|
||||||
$this->content->text .= '<i>'.get_string('inprogress','completion').'</i>';
|
$content .= html_writer::tag('i', get_string('inprogress', 'completion'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->content->text .= '</td></tr>';
|
$row->cells[0] = new html_table_cell($content);
|
||||||
$this->content->text .= '<tr><td colspan="2">';
|
$row->cells[0]->colspan = '2';
|
||||||
|
|
||||||
// Get overall aggregation method
|
$rows[] = $row;
|
||||||
|
$row = new html_table_row();
|
||||||
|
$content = "";
|
||||||
|
// Get overall aggregation method.
|
||||||
$overall = $info->get_aggregation_method();
|
$overall = $info->get_aggregation_method();
|
||||||
|
|
||||||
if ($overall == COMPLETION_AGGREGATION_ALL) {
|
if ($overall == COMPLETION_AGGREGATION_ALL) {
|
||||||
$this->content->text .= get_string('criteriarequiredall', 'completion');
|
$content .= get_string('criteriarequiredall', 'completion');
|
||||||
} else {
|
} else {
|
||||||
$this->content->text .= get_string('criteriarequiredany', 'completion');
|
$content .= get_string('criteriarequiredany', 'completion');
|
||||||
}
|
}
|
||||||
|
$content .= ':';
|
||||||
|
$row->cells[0] = new html_table_cell($content);
|
||||||
|
$row->cells[0]->colspan = '2';
|
||||||
|
$rows[] = $row;
|
||||||
|
|
||||||
$this->content->text .= ':</td></tr>';
|
$row = new html_table_row();
|
||||||
$this->content->text .= '<tr><td><b>'.get_string('requiredcriteria', 'completion').'</b></td><td style="text-align: right"><b>'.get_string('status').'</b></td></tr>';
|
$row->cells[0] = new html_table_cell(html_writer::tag('b', get_string('requiredcriteria', 'completion')));
|
||||||
$this->content->text .= $shtml.'</tbody></table>';
|
$row->cells[1] = new html_table_cell(html_writer::tag('b', get_string('status')));
|
||||||
|
$row->cells[1]->style = 'text-align: right;';
|
||||||
|
$rows[] = $row;
|
||||||
|
|
||||||
// Display link to detailed view
|
// Array merge $rows and $data here.
|
||||||
|
$rows = array_merge($rows, $srows);
|
||||||
|
|
||||||
|
$table->data = $rows;
|
||||||
|
$this->content->text = html_writer::table($table);
|
||||||
|
|
||||||
|
// Display link to detailed view.
|
||||||
$details = new moodle_url('/blocks/completionstatus/details.php', array('course' => $course->id));
|
$details = new moodle_url('/blocks/completionstatus/details.php', array('course' => $course->id));
|
||||||
$this->content->footer = '<br><a href="'.$details->out().'">'.get_string('moredetails', 'completion').'</a>';
|
$this->content->footer = html_writer::empty_tag('br');
|
||||||
|
$this->content->footer = html_writer::tag('a', get_string('moredetails', 'completion'), array('href'=>$details->out()));
|
||||||
} else {
|
} else {
|
||||||
// If user is not enrolled, show error
|
// If user is not enrolled, show error.
|
||||||
$this->content->text = get_string('nottracked', 'completion');
|
$this->content->text = get_string('nottracked', 'completion');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_capability('report/completion:view', $context)) {
|
if (has_capability('report/completion:view', $context)) {
|
||||||
$report = new moodle_url('/report/completion/index.php', array('course' => $course->id));
|
$report = new moodle_url('/report/completion/index.php', array('course' => $course->id));
|
||||||
$this->content->footer .= '<br /><a href="'.$report->out().'">'.get_string('viewcoursereport', 'completion').'</a>';
|
$this->content->footer .= html_writer::empty_tag('br');
|
||||||
|
$this->content->footer .= html_writer::tag('a', get_string('viewcoursereport', 'completion'),
|
||||||
|
array('href'=>$report->out()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $this->content;
|
return $this->content;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// This file is part of Moodle - http://moodle.org/
|
// This file is part of Moodle - http://moodle.org/
|
||||||
//
|
//
|
||||||
// Moodle is free software: you can redistribute it and/or modify
|
// Moodle is free software: you can redistribute it and/or modify
|
||||||
|
@ -57,13 +56,9 @@ function xmldb_block_completionstatus_upgrade($oldversion, $block) {
|
||||||
foreach ($blocks as $block) {
|
foreach ($blocks as $block) {
|
||||||
blocks_delete_instance($block);
|
blocks_delete_instance($block);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Savepoint reached.
|
// Savepoint reached.
|
||||||
upgrade_block_savepoint(true, 2012112901, 'completionstatus');
|
upgrade_block_savepoint(true, 2012112901, 'completionstatus');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
|
@ -15,7 +15,7 @@
|
||||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Block for displayed logged in user's course completion status
|
* Block for displaying logged in user's course completion status
|
||||||
*
|
*
|
||||||
* @package block
|
* @package block
|
||||||
* @subpackage completion
|
* @subpackage completion
|
||||||
|
@ -27,43 +27,38 @@
|
||||||
require_once(dirname(__FILE__).'/../../config.php');
|
require_once(dirname(__FILE__).'/../../config.php');
|
||||||
require_once("{$CFG->libdir}/completionlib.php");
|
require_once("{$CFG->libdir}/completionlib.php");
|
||||||
|
|
||||||
|
// Load data.
|
||||||
///
|
|
||||||
/// Load data
|
|
||||||
///
|
|
||||||
$id = required_param('course', PARAM_INT);
|
$id = required_param('course', PARAM_INT);
|
||||||
$userid = optional_param('user', 0, PARAM_INT);
|
$userid = optional_param('user', 0, PARAM_INT);
|
||||||
|
|
||||||
// Load course
|
// Load course.
|
||||||
$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
|
$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
|
||||||
|
|
||||||
// Load user
|
// Load user.
|
||||||
if ($userid) {
|
if ($userid) {
|
||||||
$user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
|
$user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
|
||||||
} else {
|
} else {
|
||||||
$user = $USER;
|
$user = $USER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check permissions.
|
||||||
// Check permissions
|
|
||||||
require_login();
|
require_login();
|
||||||
|
|
||||||
if (!completion_can_view_data($user->id, $course)) {
|
if (!completion_can_view_data($user->id, $course)) {
|
||||||
print_error('cannotviewreport');
|
print_error('cannotviewreport');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load completion data.
|
||||||
// Load completion data
|
|
||||||
$info = new completion_info($course);
|
$info = new completion_info($course);
|
||||||
|
|
||||||
$returnurl = new moodle_url('/course/view.php', array('id' => $id));
|
$returnurl = new moodle_url('/course/view.php', array('id' => $id));
|
||||||
|
|
||||||
// Don't display if completion isn't enabled!
|
// Don't display if completion isn't enabled.
|
||||||
if (!$info->is_enabled()) {
|
if (!$info->is_enabled()) {
|
||||||
print_error('completionnotenabled', 'completion', $returnurl);
|
print_error('completionnotenabled', 'completion', $returnurl);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check this user is enroled
|
// Check this user is enroled.
|
||||||
if (!$info->is_tracked_user($user->id)) {
|
if (!$info->is_tracked_user($user->id)) {
|
||||||
if ($USER->id == $user->id) {
|
if ($USER->id == $user->id) {
|
||||||
print_error('notenroled', 'completion', $returnurl);
|
print_error('notenroled', 'completion', $returnurl);
|
||||||
|
@ -72,13 +67,11 @@ if (!$info->is_tracked_user($user->id)) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Display page.
|
||||||
|
|
||||||
///
|
|
||||||
/// Display page
|
|
||||||
///
|
|
||||||
$PAGE->set_context(context_course::instance($course->id));
|
$PAGE->set_context(context_course::instance($course->id));
|
||||||
|
|
||||||
// Print header
|
// Print header.
|
||||||
$page = get_string('completionprogressdetails', 'block_completionstatus');
|
$page = get_string('completionprogressdetails', 'block_completionstatus');
|
||||||
$title = format_string($course->fullname) . ': ' . $page;
|
$title = format_string($course->fullname) . ': ' . $page;
|
||||||
|
|
||||||
|
@ -90,17 +83,24 @@ $PAGE->set_heading($title);
|
||||||
echo $OUTPUT->header();
|
echo $OUTPUT->header();
|
||||||
|
|
||||||
|
|
||||||
// Display completion status
|
// Display completion status.
|
||||||
echo '<table class="generaltable boxaligncenter"><tbody>';
|
echo html_writer::start_tag('table', array('class' => 'generalbox boxaligncenter'));
|
||||||
|
echo html_writer::start_tag('tbody');
|
||||||
|
|
||||||
// If not display logged in user, show user name
|
// If not display logged in user, show user name.
|
||||||
if ($USER->id != $user->id) {
|
if ($USER->id != $user->id) {
|
||||||
echo '<tr><td colspan="2"><b>'.get_string('showinguser', 'completion').'</b>: ';
|
echo html_writer::start_tag('tr');
|
||||||
echo '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.$course->id.'">'.fullname($user).'</a>';
|
echo html_writer::start_tag('td', array('colspan' => '2'));
|
||||||
echo '</td></tr>';
|
echo html_writer::tag('b', get_string('showinguser', 'completion'));
|
||||||
|
$url = new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $course->id));
|
||||||
|
echo html_writer::link($url, fullname($user));
|
||||||
|
echo html_writer::end_tag('td');
|
||||||
|
echo html_writer::end_tag('tr');
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '<tr><td colspan="2"><b>'.get_string('status').':</b> ';
|
echo html_writer::start_tag('tr');
|
||||||
|
echo html_writer::start_tag('td', array('colspan' => '2'));
|
||||||
|
echo html_writer::tag('b', get_string('status'));
|
||||||
|
|
||||||
// Is course complete?
|
// Is course complete?
|
||||||
$coursecomplete = $info->is_course_complete($user->id);
|
$coursecomplete = $info->is_course_complete($user->id);
|
||||||
|
@ -108,7 +108,7 @@ $coursecomplete = $info->is_course_complete($user->id);
|
||||||
// Has this user completed any criteria?
|
// Has this user completed any criteria?
|
||||||
$criteriacomplete = $info->count_course_user_data($user->id);
|
$criteriacomplete = $info->count_course_user_data($user->id);
|
||||||
|
|
||||||
// Load course completion
|
// Load course completion.
|
||||||
$params = array(
|
$params = array(
|
||||||
'userid' => $user->id,
|
'userid' => $user->id,
|
||||||
'course' => $course->id,
|
'course' => $course->id,
|
||||||
|
@ -118,25 +118,33 @@ $ccompletion = new completion_completion($params);
|
||||||
if ($coursecomplete) {
|
if ($coursecomplete) {
|
||||||
echo get_string('complete');
|
echo get_string('complete');
|
||||||
} else if (!$criteriacomplete && !$ccompletion->timestarted) {
|
} else if (!$criteriacomplete && !$ccompletion->timestarted) {
|
||||||
echo '<i>'.get_string('notyetstarted', 'completion').'</i>';
|
echo html_writer::tag('i', get_string('notyetstarted', 'completion'));
|
||||||
} else {
|
} else {
|
||||||
echo '<i>'.get_string('inprogress','completion').'</i>';
|
echo html_writer::tag('i', get_string('inprogress', 'completion'));
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</td></tr>';
|
echo html_writer::end_tag('td');
|
||||||
|
echo html_writer::end_tag('tr');
|
||||||
|
|
||||||
// Load criteria to display
|
// Load criteria to display.
|
||||||
$completions = $info->get_completions($user->id);
|
$completions = $info->get_completions($user->id);
|
||||||
|
|
||||||
// Check if this course has any criteria
|
// Check if this course has any criteria.
|
||||||
if (empty($completions)) {
|
if (empty($completions)) {
|
||||||
echo '<tr><td colspan="2"><br />';
|
echo html_writer::start_tag('tr');
|
||||||
|
echo html_writer::start_tag('td', array('colspan' => '2'));
|
||||||
|
echo html_writer::start_tag('br');
|
||||||
echo $OUTPUT->box(get_string('err_nocriteria', 'completion'), 'noticebox');
|
echo $OUTPUT->box(get_string('err_nocriteria', 'completion'), 'noticebox');
|
||||||
echo '</td></tr></tbody></table>';
|
echo html_writer::end_tag('td');
|
||||||
|
echo html_writer::end_tag('tr');
|
||||||
|
echo html_writer::end_tag('tbody');
|
||||||
|
echo html_writer::end_tag('table');
|
||||||
} else {
|
} else {
|
||||||
echo '<tr><td colspan="2"><b>'.get_string('required').':</b> ';
|
echo html_writer::start_tag('tr');
|
||||||
|
echo html_writer::start_tag('td', array('colspan' => '2'));
|
||||||
|
echo html_writer::tag('b', get_string('required'));
|
||||||
|
|
||||||
// Get overall aggregation method
|
// Get overall aggregation method.
|
||||||
$overall = $info->get_aggregation_method();
|
$overall = $info->get_aggregation_method();
|
||||||
|
|
||||||
if ($overall == COMPLETION_AGGREGATION_ALL) {
|
if ($overall == COMPLETION_AGGREGATION_ALL) {
|
||||||
|
@ -145,23 +153,28 @@ if (empty($completions)) {
|
||||||
echo get_string('criteriarequiredany', 'completion');
|
echo get_string('criteriarequiredany', 'completion');
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</td></tr></tbody></table>';
|
echo html_writer::end_tag('td');
|
||||||
|
echo html_writer::end_tag('tr');
|
||||||
|
echo html_writer::end_tag('tbody');
|
||||||
|
echo html_writer::end_tag('table');
|
||||||
|
|
||||||
// Generate markup for criteria statuses
|
// Generate markup for criteria statuses.
|
||||||
echo '<table class="generaltable logtable boxaligncenter" id="criteriastatus" width="100%"><tbody>';
|
echo html_writer::start_tag('table',
|
||||||
echo '<tr class="ccheader">';
|
array('class' => 'generalbox logtable boxaligncenter', 'id' => 'criteriastatus', 'width' => '100%'));
|
||||||
echo '<th class="c0 header" scope="col">'.get_string('criteriagroup', 'block_completionstatus').'</th>';
|
echo html_writer::start_tag('tbody');
|
||||||
echo '<th class="c1 header" scope="col">'.get_string('criteria', 'completion').'</th>';
|
echo html_writer::start_tag('tr', array('class' => 'ccheader'));
|
||||||
echo '<th class="c2 header" scope="col">'.get_string('requirement', 'block_completionstatus').'</th>';
|
echo html_writer::tag('th', get_string('criteriagroup', 'block_completionstatus'), array('class' => 'c0 header', 'scope' => 'col'));
|
||||||
echo '<th class="c3 header" scope="col">'.get_string('status').'</th>';
|
echo html_writer::tag('th', get_string('criteria', 'completion'), array('class' => 'c1 header', 'scope' => 'col'));
|
||||||
echo '<th class="c4 header" scope="col">'.get_string('complete').'</th>';
|
echo html_writer::tag('th', get_string('requirement', 'block_completionstatus'), array('class' => 'c2 header', 'scope' => 'col'));
|
||||||
echo '<th class="c5 header" scope="col">'.get_string('completiondate', 'report_completion').'</th>';
|
echo html_writer::tag('th', get_string('status'), array('class' => 'c3 header', 'scope' => 'col'));
|
||||||
echo '</tr>';
|
echo html_writer::tag('th', get_string('complete'), array('class' => 'c4 header', 'scope' => 'col'));
|
||||||
|
echo html_writer::tag('th', get_string('completiondate', 'report_completion'), array('class' => 'c5 header', 'scope' => 'col'));
|
||||||
|
echo html_writer::end_tag('tr');
|
||||||
|
|
||||||
// Save row data
|
// Save row data.
|
||||||
$rows = array();
|
$rows = array();
|
||||||
|
|
||||||
// Loop through course criteria
|
// Loop through course criteria.
|
||||||
foreach ($completions as $completion) {
|
foreach ($completions as $completion) {
|
||||||
$criteria = $completion->get_criteria();
|
$criteria = $completion->get_criteria();
|
||||||
|
|
||||||
|
@ -175,81 +188,77 @@ if (empty($completions)) {
|
||||||
$rows[] = $row;
|
$rows[] = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print table
|
// Print table.
|
||||||
$last_type = '';
|
$last_type = '';
|
||||||
$agg_type = false;
|
$agg_type = false;
|
||||||
$oddeven = 0;
|
$oddeven = 0;
|
||||||
|
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
|
|
||||||
echo '<tr class="r' . $oddeven . '">';
|
echo html_writer::start_tag('tr', array('class' => 'r' . $oddeven));
|
||||||
|
// Criteria group.
|
||||||
// Criteria group
|
echo html_writer::start_tag('td', array('class' => 'cell c0'));
|
||||||
echo '<td class="cell c0">';
|
|
||||||
if ($last_type !== $row['details']['type']) {
|
if ($last_type !== $row['details']['type']) {
|
||||||
$last_type = $row['details']['type'];
|
$last_type = $row['details']['type'];
|
||||||
echo $last_type;
|
echo $last_type;
|
||||||
|
|
||||||
// Reset agg type
|
// Reset agg type.
|
||||||
$agg_type = true;
|
$agg_type = true;
|
||||||
} else {
|
} else {
|
||||||
// Display aggregation type
|
// Display aggregation type.
|
||||||
if ($agg_type) {
|
if ($agg_type) {
|
||||||
$agg = $info->get_aggregation_method($row['type']);
|
$agg = $info->get_aggregation_method($row['type']);
|
||||||
|
echo '('. html_writer::start_tag('i');
|
||||||
echo '(<i>';
|
|
||||||
|
|
||||||
if ($agg == COMPLETION_AGGREGATION_ALL) {
|
if ($agg == COMPLETION_AGGREGATION_ALL) {
|
||||||
echo strtolower(get_string('aggregateall', 'completion'));
|
echo strtolower(get_string('aggregateall', 'completion'));
|
||||||
} else {
|
} else {
|
||||||
echo strtolower(get_string('aggregateany', 'completion'));
|
echo strtolower(get_string('aggregateany', 'completion'));
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</i> '.strtolower(get_string('required')).')';
|
echo html_writer::end_tag('i') .strtolower(get_string('required')).')';
|
||||||
$agg_type = false;
|
$agg_type = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo '</td>';
|
echo html_writer::end_tag('td');
|
||||||
|
|
||||||
// Criteria title
|
// Criteria title.
|
||||||
echo '<td class="cell c1">';
|
echo html_writer::start_tag('td', array('class' => 'cell c1'));
|
||||||
echo $row['details']['criteria'];
|
echo $row['details']['criteria'];
|
||||||
echo '</td>';
|
echo html_writer::end_tag('td');
|
||||||
|
|
||||||
// Requirement
|
// Requirement.
|
||||||
echo '<td class="cell c2">';
|
echo html_writer::start_tag('td', array('class' => 'cell c2'));
|
||||||
echo $row['details']['requirement'];
|
echo $row['details']['requirement'];
|
||||||
echo '</td>';
|
echo html_writer::end_tag('td');
|
||||||
|
|
||||||
// Status
|
// Status.
|
||||||
echo '<td class="cell c3">';
|
echo html_writer::start_tag('td', array('class' => 'cell c3'));
|
||||||
echo $row['details']['status'];
|
echo $row['details']['status'];
|
||||||
echo '</td>';
|
echo html_writer::end_tag('td');
|
||||||
|
|
||||||
// Is complete
|
// Is complete.
|
||||||
echo '<td class="cell c4">';
|
echo html_writer::start_tag('td', array('class' => 'cell c4'));
|
||||||
echo $row['complete'] ? get_string('yes') : get_string('no');
|
echo $row['complete'] ? get_string('yes') : get_string('no');
|
||||||
echo '</td>';
|
echo html_writer::end_tag('td');
|
||||||
|
|
||||||
// Completion data
|
// Completion data.
|
||||||
echo '<td class="cell c5">';
|
echo html_writer::start_tag('td', array('class' => 'cell c5'));
|
||||||
if ($row['timecompleted']) {
|
if ($row['timecompleted']) {
|
||||||
echo userdate($row['timecompleted'], get_string('strftimedate', 'langconfig'));
|
echo userdate($row['timecompleted'], get_string('strftimedate', 'langconfig'));
|
||||||
} else {
|
} else {
|
||||||
echo '-';
|
echo '-';
|
||||||
}
|
}
|
||||||
echo '</td>';
|
echo html_writer::end_tag('td');
|
||||||
echo '</tr>';
|
echo html_writer::end_tag('tr');
|
||||||
// for row striping
|
// For row striping.
|
||||||
$oddeven = $oddeven ? 0 : 1;
|
$oddeven = $oddeven ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</tbody></table>';
|
echo html_writer::end_tag('tbody');
|
||||||
|
echo html_writer::end_tag('table');
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '<div class="buttons">';
|
|
||||||
$courseurl = new moodle_url("/course/view.php", array('id' => $course->id));
|
$courseurl = new moodle_url("/course/view.php", array('id' => $course->id));
|
||||||
|
echo html_writer::start_tag('div', array('class' => 'buttons'));
|
||||||
echo $OUTPUT->single_button($courseurl, get_string('returntocourse', 'block_completionstatus'), 'get');
|
echo $OUTPUT->single_button($courseurl, get_string('returntocourse', 'block_completionstatus'), 'get');
|
||||||
echo '</div>';
|
echo html_writer::end_tag('div');
|
||||||
|
|
||||||
echo $OUTPUT->footer();
|
echo $OUTPUT->footer();
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// This file is part of Moodle - http://moodle.org/
|
// This file is part of Moodle - http://moodle.org/
|
||||||
//
|
//
|
||||||
// Moodle is free software: you can redistribute it and/or modify
|
// Moodle is free software: you can redistribute it and/or modify
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
defined('MOODLE_INTERNAL') || die();
|
defined('MOODLE_INTERNAL') || die();
|
||||||
|
|
||||||
$plugin->version = 2012112901; // The current plugin version (Date: YYYYMMDDXX)
|
$plugin->version = 2012112901; // The current plugin version (Date: YYYYMMDDXX).
|
||||||
$plugin->requires = 2012112900; // Requires this Moodle version
|
$plugin->requires = 2012112900; // Requires this Moodle version.
|
||||||
$plugin->component = 'block_completionstatus';
|
$plugin->component = 'block_completionstatus';
|
||||||
$plugin->dependencies = array('report_completion' => 2012112900);
|
$plugin->dependencies = array('report_completion' => 2012112900);
|
||||||
|
|
|
@ -32,6 +32,9 @@
|
||||||
.block.hidden .block-hider-hide {display:none;}
|
.block.hidden .block-hider-hide {display:none;}
|
||||||
.block.hidden .block-hider-show {display:inline;}
|
.block.hidden .block-hider-show {display:inline;}
|
||||||
|
|
||||||
|
.block_completionstatus .generaltable { border: 0px; }
|
||||||
|
.block_completionstatus .generaltable .cell { border: 0px; }
|
||||||
|
|
||||||
/** Overide for RTL layout **/
|
/** Overide for RTL layout **/
|
||||||
.dir-rtl .block .header,
|
.dir-rtl .block .header,
|
||||||
.dir-rtl .block h2.header {text-align:right;}
|
.dir-rtl .block h2.header {text-align:right;}
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
This files describes API changes in /theme/* themes,
|
This files describes API changes in /theme/* themes,
|
||||||
information provided here is intended especially for theme designer.
|
information provided here is intended especially for theme designer.
|
||||||
|
|
||||||
|
=== 2.6 ===
|
||||||
|
* re-wrote the table for the course completion status block to use html_table - added some CSS classes to the table in the process.
|
||||||
|
MDL-35608 - Blocks - Updating the Completion Status block to use HTML Writer
|
||||||
|
|
||||||
|
|
||||||
=== 2.5 ===
|
=== 2.5 ===
|
||||||
|
|
||||||
required changes:
|
required changes:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue