forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'wip-MDL-46547-master' of git://github.com/abgreeve/moodle
- Loading branch information
Showing
18 changed files
with
1,726 additions
and
378 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?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/>. | ||
|
||
/** | ||
* Renderers for the import of CSV files into the gradebook. | ||
* | ||
* @package gradeimport_csv | ||
* @copyright 2014 Adrian Greeve <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
/** | ||
* Renderers for the import of CSV files into the gradebook. | ||
* | ||
* @package gradeimport_csv | ||
* @copyright 2014 Adrian Greeve <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class gradeimport_csv_renderer extends plugin_renderer_base { | ||
|
||
/** | ||
* A renderer for the standard upload file form. | ||
* | ||
* @param object $course The course we are doing all of this action in. | ||
* @param object $mform The mform for uploading CSV files. | ||
* @return string html to be displayed. | ||
*/ | ||
public function standard_upload_file_form($course, $mform) { | ||
|
||
$output = groups_print_course_menu($course, 'index.php?id=' . $course->id, true); | ||
$output .= html_writer::start_tag('div', array('class' => 'clearer')); | ||
$output .= html_writer::end_tag('div'); | ||
|
||
// Form. | ||
ob_start(); | ||
$mform->display(); | ||
$output .= ob_get_contents(); | ||
ob_end_clean(); | ||
|
||
return $output; | ||
} | ||
|
||
/** | ||
* A renderer for the CSV file preview. | ||
* | ||
* @param array $header Column headers from the CSV file. | ||
* @param array $data The rest of the data from the CSV file. | ||
* @return string html to be displayed. | ||
*/ | ||
public function import_preview_page($header, $data) { | ||
|
||
$html = $this->output->heading(get_string('importpreview', 'grades')); | ||
|
||
$table = new html_table(); | ||
$table->head = $header; | ||
$table->data = $data; | ||
$html .= html_writer::table($table); | ||
|
||
return $html; | ||
} | ||
|
||
/** | ||
* A renderer for errors generated trying to import the CSV file. | ||
* | ||
* @param array $errors Display import errors. | ||
* @return string errors as html to be displayed. | ||
*/ | ||
public function errors($errors) { | ||
$html = ''; | ||
foreach ($errors as $error) { | ||
$html .= $this->output->notification($error); | ||
} | ||
return $html; | ||
} | ||
} |
Oops, something went wrong.