Added a CSS class to centre the download button and report table to stop the use of deprecated attributes and also added full-stops to comments

This commit is contained in:
Mark Nelson 2013-06-05 15:37:52 +08:00
parent 35851b204c
commit 4a185540e2
3 changed files with 15 additions and 10 deletions

10
lib.php
View file

@ -877,13 +877,13 @@ function customcert_generate_report_file($customcert, $users, $type) {
$filename = clean_filename($COURSE->shortname . ' ' . rtrim($customcert->name, '.') . '.' . $type); $filename = clean_filename($COURSE->shortname . ' ' . rtrim($customcert->name, '.') . '.' . $type);
// Send HTTP headers // Send HTTP headers.
$workbook->send($filename); $workbook->send($filename);
// Creating the first worksheet // Creating the first worksheet.
$myxls = $workbook->add_worksheet(get_string('report', 'customcert')); $myxls = $workbook->add_worksheet(get_string('report', 'customcert'));
// Print names of all the fields // Print names of all the fields.
$myxls->write_string(0, 0, get_string('lastname')); $myxls->write_string(0, 0, get_string('lastname'));
$myxls->write_string(0, 1, get_string('firstname')); $myxls->write_string(0, 1, get_string('firstname'));
$myxls->write_string(0, 2, get_string('idnumber')); $myxls->write_string(0, 2, get_string('idnumber'));
@ -891,7 +891,7 @@ function customcert_generate_report_file($customcert, $users, $type) {
$myxls->write_string(0, 4, get_string('receiveddate', 'customcert')); $myxls->write_string(0, 4, get_string('receiveddate', 'customcert'));
$myxls->write_string(0, 5, get_string('code', 'customcert')); $myxls->write_string(0, 5, get_string('code', 'customcert'));
// Generate the data for the body of the spreadsheet // Generate the data for the body of the spreadsheet.
$i = 0; $i = 0;
$row = 1; $row = 1;
if ($users) { if ($users) {
@ -912,6 +912,6 @@ function customcert_generate_report_file($customcert, $users, $type) {
$row++; $row++;
} }
} }
// Close the workbook // Close the workbook.
$workbook->close(); $workbook->close();
} }

View file

@ -16,7 +16,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/** /**
* Handles viewing a customcert. * Handles viewing a report that shows who has received a customcert.
* *
* @package mod_customcert * @package mod_customcert
* @copyright Mark Nelson <markn@moodle.com> * @copyright Mark Nelson <markn@moodle.com>
@ -62,10 +62,10 @@ if ($download) {
// Create the table for the users. // Create the table for the users.
$table = new html_table(); $table = new html_table();
$table->width = '95%'; $table->attributes['class'] = 'generaltable centre';
$table->tablealign = 'center'; $table->attributes['style'] = 'width: 95%;';
$table->head = array(get_string('awardedto', 'customcert'), get_string('receiveddate', 'customcert'), get_string('code', 'customcert')); $table->head = array(get_string('awardedto', 'customcert'), get_string('receiveddate', 'customcert'), get_string('code', 'customcert'));
$table->align = array('left', 'left', 'center', 'center'); $table->align = array('left', 'left', 'center');
foreach ($users as $user) { foreach ($users as $user) {
$name = $OUTPUT->user_picture($user) . fullname($user); $name = $OUTPUT->user_picture($user) . fullname($user);
$date = userdate($user->timecreated); $date = userdate($user->timecreated);
@ -75,7 +75,7 @@ foreach ($users as $user) {
// Create table to store buttons. // Create table to store buttons.
$tablebutton = new html_table(); $tablebutton = new html_table();
$tablebutton->attributes['class'] = 'downloadreport'; $tablebutton->attributes['class'] = 'centre';
$btndownloadods = $OUTPUT->single_button(new moodle_url('report.php', array('id' => $cm->id, 'download' => 'ods')), get_string("downloadods")); $btndownloadods = $OUTPUT->single_button(new moodle_url('report.php', array('id' => $cm->id, 'download' => 'ods')), get_string("downloadods"));
$btndownloadxls = $OUTPUT->single_button(new moodle_url('report.php', array('id' => $cm->id, 'download' => 'xls')), get_string("downloadexcel")); $btndownloadxls = $OUTPUT->single_button(new moodle_url('report.php', array('id' => $cm->id, 'download' => 'xls')), get_string("downloadexcel"));
$tablebutton->data[] = array($btndownloadods, $btndownloadxls); $tablebutton->data[] = array($btndownloadods, $btndownloadxls);

View file

@ -1,3 +1,8 @@
#page-mod-customcert-edit .deletebutton { #page-mod-customcert-edit .deletebutton {
text-align:right; text-align:right;
} }
#page-mod-customcert-report .centre {
margin-left: auto;
margin-right: auto;
}