Skip to content
Permalink
Browse files

CONTRIB-5575 - Playing with renderers.

  • Loading branch information...
mchurchward committed May 11, 2016
1 parent 6bb211f commit fd69fc1ccd9735c86283dc9bfe5eb0ede4341d8f
Showing with 51 additions and 7 deletions.
  1. +7 −7 index.php
  2. +44 −0 renderer.php
@@ -45,7 +45,9 @@
$PAGE->navbar->add($strquestionnaires);
$PAGE->set_title("$course->shortname: $strquestionnaires");
$PAGE->set_heading(format_string($course->fullname));
echo $OUTPUT->header();
$output = $PAGE->get_renderer('mod_questionnaire');
echo $output->header();
// Get all the appropriate data.
if (!$questionnaires = get_all_instances_in_course("questionnaire", $course)) {
@@ -92,9 +94,7 @@
$showing = 'responses';
}
$table = new html_table();
$table->head = $headings;
$table->align = $align;
$content = array();
// Populate the table with the list of instances.
$currentsection = '';
@@ -208,10 +208,10 @@
}
}
}
$table->data[] = $data;
$content[] = $data;
} // End of loop over questionnaire instances.
echo html_writer::table($table);
echo $output->render_index($headings, $align, $content);
// Finish the page.
echo $OUTPUT->footer();
echo $output->footer();
@@ -0,0 +1,44 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Moodle renderer used to display special elements of the lesson module
*
* @package mod_questionnaire
* @copyright 2016 Mike Churchward (mike.churchward@poetgroup.org)
* @author Mike Churchward
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
**/
class mod_questionnaire_renderer extends plugin_renderer_base {
/**
* Renders the HTML for the index page.
* @param array $headings Headings for the display columns.
* @param array $align Alignment for each column.
* @param array $data All of the table data.
* @return string
*/
public function render_index($headings, $align, $data) {
$table = new html_table();
$table->head = $headings;
$table->align = $align;
$table->data = $data;
return html_writer::table($table);
}
}

0 comments on commit fd69fc1

Please sign in to comment.
You can’t perform that action at this time.