MDL-37635 Assign: Prevent errors when viewing a feedback when there is no grade_item...
[moodle.git] / mod / assign / renderer.php
CommitLineData
bbd0e548
DW
1<?php
2// This file is part of Moodle - http://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
17/**
18 * This file contains a renderer for the assignment class
19 *
20 * @package mod_assign
21 * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24
25defined('MOODLE_INTERNAL') || die();
26
27/** Include locallib.php */
28require_once($CFG->dirroot . '/mod/assign/locallib.php');
29
30
31/**
32 * A custom renderer class that extends the plugin_renderer_base and is used by the assign module.
33 *
34 * @package mod_assign
35 * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37 */
38class mod_assign_renderer extends plugin_renderer_base {
39
40 /**
41 * rendering assignment files
42 *
43 * @param context $context
44 * @param int $userid
45 * @param string $filearea
46 * @param string $component
47 * @return string
48 */
49 public function assign_files(context $context, $userid, $filearea, $component) {
50 return $this->render(new assign_files($context, $userid, $filearea, $component));
51 }
52
53 /**
54 * rendering assignment files
55 *
56 * @param assign_files $tree
57 * @return string
58 */
59 public function render_assign_files(assign_files $tree) {
60 $this->htmlid = 'assign_files_tree_'.uniqid();
61 $this->page->requires->js_init_call('M.mod_assign.init_tree', array(true, $this->htmlid));
62 $html = '<div id="'.$this->htmlid.'">';
63 $html .= $this->htmllize_tree($tree, $tree->dir);
64 $html .= '</div>';
65
66 if ($tree->portfolioform) {
67 $html .= $tree->portfolioform;
68 }
69 return $html;
70 }
71
72 /**
73 * Utility function to add a row of data to a table with 2 columns. Modified
74 * the table param and does not return a value
75 *
76 * @param html_table $table The table to append the row of data to
77 * @param string $first The first column text
78 * @param string $second The second column text
79 * @return void
80 */
81 private function add_table_row_tuple(html_table $table, $first, $second) {
82 $row = new html_table_row();
83 $cell1 = new html_table_cell($first);
84 $cell2 = new html_table_cell($second);
85 $row->cells = array($cell1, $cell2);
86 $table->data[] = $row;
87 }
88
bf78ebd6
DW
89 /**
90 * Render a grading error notification
91 * @param assign_quickgrading_result $result The result to render
92 * @return string
93 */
94 public function render_assign_quickgrading_result(assign_quickgrading_result $result) {
2a4fbc32
SH
95 $url = new moodle_url('/mod/assign/view.php', array('id' => $result->coursemoduleid, 'action'=>'grading'));
96
bf78ebd6
DW
97 $o = '';
98 $o .= $this->output->heading(get_string('quickgradingresult', 'assign'), 4);
bf78ebd6 99 $o .= $this->output->notification($result->message);
2a4fbc32 100 $o .= $this->output->continue_button($url);
bf78ebd6
DW
101 return $o;
102 }
103
bbd0e548
DW
104 /**
105 * Render the generic form
106 * @param assign_form $form The form to render
107 * @return string
108 */
109 public function render_assign_form(assign_form $form) {
110 $o = '';
bf78ebd6
DW
111 if ($form->jsinitfunction) {
112 $this->page->requires->js_init_call($form->jsinitfunction, array());
113 }
bbd0e548
DW
114 $o .= $this->output->box_start('boxaligncenter ' . $form->classname);
115 $o .= $this->moodleform($form->form);
116 $o .= $this->output->box_end();
117 return $o;
118 }
119
120 /**
121 * Render the user summary
122 *
123 * @param assign_user_summary $summary The user summary to render
124 * @return string
125 */
126 public function render_assign_user_summary(assign_user_summary $summary) {
127 $o = '';
128
129 if (!$summary->user) {
130 return;
131 }
132 $o .= $this->output->container_start('usersummary');
133 $o .= $this->output->box_start('boxaligncenter usersummarysection');
134 $o .= $this->output->user_picture($summary->user);
135 $o .= $this->output->spacer(array('width'=>30));
136 $o .= $this->output->action_link(new moodle_url('/user/view.php',
137 array('id' => $summary->user->id,
138 'course'=>$summary->courseid)),
139 fullname($summary->user, $summary->viewfullnames));
140 $o .= $this->output->box_end();
141 $o .= $this->output->container_end();
142
143 return $o;
144 }
145
146 /**
147 * Render the submit for grading page
148 *
149 * @param assign_submit_for_grading_page $page
150 * @return string
151 */
152 public function render_assign_submit_for_grading_page($page) {
153 $o = '';
154
155 $o .= $this->output->container_start('submitforgrading');
156 $o .= $this->output->heading(get_string('submitassignment', 'assign'), 3);
157 $o .= $this->output->spacer(array('height'=>30));
158
159 $cancelurl = new moodle_url('/mod/assign/view.php', array('id' => $page->coursemoduleid));
160 if (count($page->notifications)) {
161 // At least one of the submission plugins is not ready for submission
162
163 $o .= $this->output->heading(get_string('submissionnotready', 'assign'), 4);
164
165 foreach ($page->notifications as $notification) {
166 $o .= $this->output->notification($notification);
167 }
168
169 $o .= $this->output->continue_button($cancelurl);
170 } else {
171 // All submission plugins ready - confirm the student really does want to submit for marking
172 $continueurl = new moodle_url('/mod/assign/view.php', array('id' => $page->coursemoduleid,
173 'action' => 'confirmsubmit',
174 'sesskey' => sesskey()));
175 $o .= $this->output->confirm(get_string('confirmsubmission', 'mod_assign'), $continueurl, $cancelurl);
176 }
177 $o .= $this->output->container_end();
178
179
180 return $o;
181 }
182
183 /**
184 * Page is done - render the footer
185 *
186 * @return void
187 */
188 public function render_footer() {
189 return $this->output->footer();
190 }
191
192 /**
193 * render the header
194 *
195 * @param assign_header $header
196 * @return string
197 */
198 public function render_assign_header(assign_header $header) {
199 $o = '';
200
201 if ($header->subpage) {
202 $this->page->navbar->add($header->subpage);
203 }
204
205 $this->page->set_title(get_string('pluginname', 'assign'));
206 $this->page->set_heading($header->assign->name);
207
208 $o .= $this->output->header();
a1e54f4d
DW
209 if ($header->preface) {
210 $o .= $header->preface;
211 }
bbd0e548
DW
212 $o .= $this->output->heading(format_string($header->assign->name,false, array('context' => $header->context)));
213
214 if ($header->showintro) {
215 $o .= $this->output->box_start('generalbox boxaligncenter', 'intro');
216 $o .= format_module_intro('assign', $header->assign, $header->coursemoduleid);
217 $o .= $this->output->box_end();
218 }
219
220 return $o;
221 }
222
223 /**
224 * render a table containing the current status of the grading process
225 *
226 * @param assign_grading_summary $summary
227 * @return string
228 */
229 public function render_assign_grading_summary(assign_grading_summary $summary) {
230 // create a table for the data
231 $o = '';
232 $o .= $this->output->container_start('gradingsummary');
233 $o .= $this->output->heading(get_string('gradingsummary', 'assign'), 3);
234 $o .= $this->output->box_start('boxaligncenter gradingsummarytable');
235 $t = new html_table();
236
237 // status
238 $this->add_table_row_tuple($t, get_string('numberofparticipants', 'assign'),
239 $summary->participantcount);
240
241 // drafts
242 if ($summary->submissiondraftsenabled) {
243 $this->add_table_row_tuple($t, get_string('numberofdraftsubmissions', 'assign'),
244 $summary->submissiondraftscount);
245 }
246
247 // submitted for grading
248 if ($summary->submissionsenabled) {
249 $this->add_table_row_tuple($t, get_string('numberofsubmittedassignments', 'assign'),
250 $summary->submissionssubmittedcount);
392ee02d
DW
251 $this->add_table_row_tuple($t, get_string('numberofsubmissionsneedgrading', 'assign'),
252 $summary->submissionsneedgradingcount);
bbd0e548
DW
253 }
254
255 $time = time();
256 if ($summary->duedate) {
257 // due date
258 // submitted for grading
259 $duedate = $summary->duedate;
260 $this->add_table_row_tuple($t, get_string('duedate', 'assign'),
261 userdate($duedate));
262
263 // time remaining
264 $due = '';
265 if ($duedate - $time <= 0) {
266 $due = get_string('assignmentisdue', 'assign');
267 } else {
268 $due = format_time($duedate - $time);
269 }
270 $this->add_table_row_tuple($t, get_string('timeremaining', 'assign'), $due);
271 }
272
273 // all done - write the table
274 $o .= html_writer::table($t);
275 $o .= $this->output->box_end();
276
277 // link to the grading page
d9a88f42
DW
278 $o .= $this->output->container_start('submissionlinks');
279 $o .= $this->output->action_link(new moodle_url('/mod/assign/view.php',
bbd0e548
DW
280 array('id' => $summary->coursemoduleid,
281 'action'=>'grading')),
d9a88f42
DW
282 get_string('viewgrading', 'assign'));
283 $o .= $this->output->container_end();
bbd0e548
DW
284
285 // close the container and insert a spacer
286 $o .= $this->output->container_end();
287
288 return $o;
289 }
290
291 /**
292 * render a table containing all the current grades and feedback
293 *
294 * @param assign_feedback_status $status
295 * @return string
296 */
297 public function render_assign_feedback_status(assign_feedback_status $status) {
298 global $DB, $CFG;
299 $o = '';
300
301 $o .= $this->output->container_start('feedback');
302 $o .= $this->output->heading(get_string('feedback', 'assign'), 3);
303 $o .= $this->output->box_start('boxaligncenter feedbacktable');
304 $t = new html_table();
305
7d054079
DW
306 if (isset($status->gradefordisplay)) {
307 $row = new html_table_row();
308 $cell1 = new html_table_cell(get_string('grade'));
309 $cell2 = new html_table_cell($status->gradefordisplay);
310 $row->cells = array($cell1, $cell2);
311 $t->data[] = $row;
bbd0e548 312
7d054079
DW
313 $row = new html_table_row();
314 $cell1 = new html_table_cell(get_string('gradedon', 'assign'));
315 $cell2 = new html_table_cell(userdate($status->gradeddate));
316 $row->cells = array($cell1, $cell2);
317 $t->data[] = $row;
318 }
bbd0e548
DW
319
320 if ($status->grader) {
321 $row = new html_table_row();
322 $cell1 = new html_table_cell(get_string('gradedby', 'assign'));
323 $cell2 = new html_table_cell($this->output->user_picture($status->grader) . $this->output->spacer(array('width'=>30)) . fullname($status->grader));
324 $row->cells = array($cell1, $cell2);
325 $t->data[] = $row;
326 }
327
328 foreach ($status->feedbackplugins as $plugin) {
2a5378d2 329 if ($plugin->is_enabled() && $plugin->is_visible() && !empty($status->grade) && !$plugin->is_empty($status->grade)) {
bbd0e548
DW
330 $row = new html_table_row();
331 $cell1 = new html_table_cell($plugin->get_name());
332 $pluginfeedback = new assign_feedback_plugin_feedback($plugin, $status->grade, assign_feedback_plugin_feedback::SUMMARY, $status->coursemoduleid, $status->returnaction, $status->returnparams);
333 $cell2 = new html_table_cell($this->render($pluginfeedback));
334 $row->cells = array($cell1, $cell2);
335 $t->data[] = $row;
336 }
337 }
338
339
340 $o .= html_writer::table($t);
341 $o .= $this->output->box_end();
342
343 $o .= $this->output->container_end();
344 return $o;
345 }
346
347 /**
348 * render a table containing the current status of the submission
349 *
350 * @param assign_submission_status $status
351 * @return string
352 */
353 public function render_assign_submission_status(assign_submission_status $status) {
354 $o = '';
355 $o .= $this->output->container_start('submissionstatustable');
356 $o .= $this->output->heading(get_string('submissionstatusheading', 'assign'), 3);
357 $time = time();
358
359 if ($status->allowsubmissionsfromdate &&
360 $time <= $status->allowsubmissionsfromdate) {
361 $o .= $this->output->box_start('generalbox boxaligncenter submissionsalloweddates');
362 if ($status->alwaysshowdescription) {
363 $o .= get_string('allowsubmissionsfromdatesummary', 'assign', userdate($status->allowsubmissionsfromdate));
364 } else {
365 $o .= get_string('allowsubmissionsanddescriptionfromdatesummary', 'assign', userdate($status->allowsubmissionsfromdate));
366 }
367 $o .= $this->output->box_end();
368 }
369 $o .= $this->output->box_start('boxaligncenter submissionsummarytable');
370
371 $t = new html_table();
372
373 $row = new html_table_row();
374 $cell1 = new html_table_cell(get_string('submissionstatus', 'assign'));
375 if ($status->submission) {
376 $cell2 = new html_table_cell(get_string('submissionstatus_' . $status->submission->status, 'assign'));
377 $cell2->attributes = array('class'=>'submissionstatus' . $status->submission->status);
378 } else {
379 if (!$status->submissionsenabled) {
380 $cell2 = new html_table_cell(get_string('noonlinesubmissions', 'assign'));
381 } else {
382 $cell2 = new html_table_cell(get_string('nosubmission', 'assign'));
383 }
384 }
385 $row->cells = array($cell1, $cell2);
386 $t->data[] = $row;
387
388 // status
389 if ($status->locked) {
390 $row = new html_table_row();
391 $cell1 = new html_table_cell();
392 $cell2 = new html_table_cell(get_string('submissionslocked', 'assign'));
393 $cell2->attributes = array('class'=>'submissionlocked');
394 $row->cells = array($cell1, $cell2);
395 $t->data[] = $row;
396 }
397
398 // grading status
399 $row = new html_table_row();
400 $cell1 = new html_table_cell(get_string('gradingstatus', 'assign'));
401
402 if ($status->graded) {
403 $cell2 = new html_table_cell(get_string('graded', 'assign'));
404 $cell2->attributes = array('class'=>'submissiongraded');
405 } else {
406 $cell2 = new html_table_cell(get_string('notgraded', 'assign'));
407 $cell2->attributes = array('class'=>'submissionnotgraded');
408 }
409 $row->cells = array($cell1, $cell2);
410 $t->data[] = $row;
411
412
413 $duedate = $status->duedate;
414 if ($duedate >= 1) {
415 $row = new html_table_row();
416 $cell1 = new html_table_cell(get_string('duedate', 'assign'));
417 $cell2 = new html_table_cell(userdate($duedate));
418 $row->cells = array($cell1, $cell2);
419 $t->data[] = $row;
420
421 // time remaining
422 $row = new html_table_row();
423 $cell1 = new html_table_cell(get_string('timeremaining', 'assign'));
424 if ($duedate - $time <= 0) {
8b9416de 425 if (!$status->submission || $status->submission->status != ASSIGN_SUBMISSION_STATUS_SUBMITTED) {
bbd0e548
DW
426 if ($status->submissionsenabled) {
427 $cell2 = new html_table_cell(get_string('overdue', 'assign', format_time($time - $duedate)));
428 $cell2->attributes = array('class'=>'overdue');
429 } else {
430 $cell2 = new html_table_cell(get_string('duedatereached', 'assign'));
431 }
432 } else {
433 if ($status->submission->timemodified > $duedate) {
434 $cell2 = new html_table_cell(get_string('submittedlate', 'assign', format_time($status->submission->timemodified - $duedate)));
435 $cell2->attributes = array('class'=>'latesubmission');
436 } else {
437 $cell2 = new html_table_cell(get_string('submittedearly', 'assign', format_time($status->submission->timemodified - $duedate)));
438 $cell2->attributes = array('class'=>'earlysubmission');
439 }
440 }
441 } else {
442 $cell2 = new html_table_cell(format_time($duedate - $time));
443 }
444 $row->cells = array($cell1, $cell2);
445 $t->data[] = $row;
446 }
447
448 // last modified
449 if ($status->submission) {
450 $row = new html_table_row();
451 $cell1 = new html_table_cell(get_string('timemodified', 'assign'));
452 $cell2 = new html_table_cell(userdate($status->submission->timemodified));
453 $row->cells = array($cell1, $cell2);
454 $t->data[] = $row;
455
456 foreach ($status->submissionplugins as $plugin) {
46c678ab
DW
457 $pluginshowsummary = !$plugin->is_empty($status->submission) || !$plugin->allow_submissions();
458 if ($plugin->is_enabled() &&
459 $plugin->is_visible() &&
460 $pluginshowsummary) {
461
bbd0e548
DW
462 $row = new html_table_row();
463 $cell1 = new html_table_cell($plugin->get_name());
464 $pluginsubmission = new assign_submission_plugin_submission($plugin, $status->submission, assign_submission_plugin_submission::SUMMARY, $status->coursemoduleid, $status->returnaction, $status->returnparams);
465 $cell2 = new html_table_cell($this->render($pluginsubmission));
466 $row->cells = array($cell1, $cell2);
467 $t->data[] = $row;
468 }
469 }
470 }
471
472
473 $o .= html_writer::table($t);
474 $o .= $this->output->box_end();
475
476 // links
477 if ($status->canedit) {
caff10a0
DW
478 if (!$status->submission) {
479 $o .= $this->output->single_button(new moodle_url('/mod/assign/view.php',
480 array('id' => $status->coursemoduleid, 'action' => 'editsubmission')), get_string('addsubmission', 'assign'), 'get');
481 } else {
482 $o .= $this->output->single_button(new moodle_url('/mod/assign/view.php',
483 array('id' => $status->coursemoduleid, 'action' => 'editsubmission')), get_string('editsubmission', 'assign'), 'get');
484 }
bbd0e548
DW
485 }
486
487 if ($status->cansubmit) {
488 // submission.php
489 $o .= $this->output->single_button(new moodle_url('/mod/assign/view.php',
490 array('id' => $status->coursemoduleid, 'action'=>'submit')), get_string('submitassignment', 'assign'), 'get');
491 $o .= $this->output->box_start('boxaligncenter submithelp');
492 $o .= get_string('submitassignment_help', 'assign');
493 $o .= $this->output->box_end();
494 }
495
496 $o .= $this->output->container_end();
497 return $o;
498 }
499
500 /**
501 * render a submission plugin submission
502 *
503 * @param assign_submission_plugin_submission $submissionplugin
504 * @return string
505 */
506 public function render_assign_submission_plugin_submission(assign_submission_plugin_submission $submissionplugin) {
507 $o = '';
508
509 if ($submissionplugin->view == assign_submission_plugin_submission::SUMMARY) {
510 $icon = $this->output->pix_icon('t/preview', get_string('view' . substr($submissionplugin->plugin->get_subtype(), strlen('assign')), 'mod_assign'));
511 $link = '';
512 $showviewlink = false;
513 $summary = $submissionplugin->plugin->view_summary($submissionplugin->submission, $showviewlink);
514 if ($showviewlink) {
515 $link = $this->output->action_link(
516 new moodle_url('/mod/assign/view.php',
517 array('id' => $submissionplugin->coursemoduleid,
518 'sid'=>$submissionplugin->submission->id,
519 'plugin'=>$submissionplugin->plugin->get_type(),
520 'action'=>'viewplugin' . $submissionplugin->plugin->get_subtype(),
521 'returnaction'=>$submissionplugin->returnaction,
522 'returnparams'=>http_build_query($submissionplugin->returnparams))),
523 $icon);
524
525 $link .= $this->output->spacer(array('width'=>15));
526 }
527
528 $o .= $link . $summary;
529 } else if ($submissionplugin->view == assign_submission_plugin_submission::FULL) {
530 $o .= $this->output->box_start('boxaligncenter submissionfull');
531 $o .= $submissionplugin->plugin->view($submissionplugin->submission);
532 $o .= $this->output->box_end();
533 }
534
535 return $o;
536 }
537
538 /**
539 * render the grading table
540 *
541 * @param assign_grading_table $table
542 * @return string
543 */
544 public function render_assign_grading_table(assign_grading_table $table) {
545 $o = '';
546 $o .= $this->output->box_start('boxaligncenter gradingtable');
547 $this->page->requires->js_init_call('M.mod_assign.init_grading_table', array());
548 $this->page->requires->string_for_js('nousersselected', 'assign');
549 $this->page->requires->string_for_js('batchoperationconfirmlock', 'assign');
550 $this->page->requires->string_for_js('batchoperationconfirmunlock', 'assign');
551 $this->page->requires->string_for_js('batchoperationconfirmreverttodraft', 'assign');
552 $this->page->requires->string_for_js('editaction', 'assign');
553 // need to get from prefs
554 $o .= $this->flexible_table($table, $table->get_rows_per_page(), true);
555 $o .= $this->output->box_end();
556
557 return $o;
558 }
559
560 /**
561 * Render a feedback plugin feedback
562 *
563 * @param assign_feedback_plugin_feedback $feedbackplugin
564 * @return string
565 */
566 public function render_assign_feedback_plugin_feedback(assign_feedback_plugin_feedback $feedbackplugin) {
567 $o = '';
568
569 if ($feedbackplugin->view == assign_feedback_plugin_feedback::SUMMARY) {
570 $icon = $this->output->pix_icon('t/preview', get_string('view' . substr($feedbackplugin->plugin->get_subtype(), strlen('assign')), 'mod_assign'));
571 $link = '';
572 $showviewlink = false;
573 $summary = $feedbackplugin->plugin->view_summary($feedbackplugin->grade, $showviewlink);
574 if ($showviewlink) {
575 $link = $this->output->action_link(
576 new moodle_url('/mod/assign/view.php',
577 array('id' => $feedbackplugin->coursemoduleid,
578 'gid'=>$feedbackplugin->grade->id,
579 'plugin'=>$feedbackplugin->plugin->get_type(),
580 'action'=>'viewplugin' . $feedbackplugin->plugin->get_subtype(),
581 'returnaction'=>$feedbackplugin->returnaction,
582 'returnparams'=>http_build_query($feedbackplugin->returnparams))),
583 $icon);
584 $link .= $this->output->spacer(array('width'=>15));
585 }
586
587 $o .= $link . $summary;
588 } else if ($feedbackplugin->view == assign_feedback_plugin_feedback::FULL) {
589 $o .= $this->output->box_start('boxaligncenter feedbackfull');
590 $o .= $feedbackplugin->plugin->view($feedbackplugin->grade);
591 $o .= $this->output->box_end();
592 }
593
594 return $o;
595 }
596
597
598
599 /**
600 * Internal function - creates htmls structure suitable for YUI tree.
601 *
602 * @param assign_files $tree
603 * @param array $dir
604 * @return string
605 */
606 protected function htmllize_tree(assign_files $tree, $dir) {
607 global $CFG;
608 $yuiconfig = array();
609 $yuiconfig['type'] = 'html';
610
611 if (empty($dir['subdirs']) and empty($dir['files'])) {
612 return '';
613 }
614
615 $result = '<ul>';
616 foreach ($dir['subdirs'] as $subdir) {
559276b1 617 $image = $this->output->pix_icon(file_folder_icon(), $subdir['dirname'], 'moodle', array('class'=>'icon'));
bbd0e548
DW
618 $result .= '<li yuiConfig=\''.json_encode($yuiconfig).'\'><div>'.$image.' '.s($subdir['dirname']).'</div> '.$this->htmllize_tree($tree, $subdir).'</li>';
619 }
620
621 foreach ($dir['files'] as $file) {
622 $filename = $file->get_filename();
bbd0e548
DW
623 if ($CFG->enableplagiarism) {
624 require_once($CFG->libdir.'/plagiarismlib.php');
625 $plagiarsmlinks = plagiarism_get_links(array('userid'=>$file->get_userid(), 'file'=>$file, 'cmid'=>$tree->cm->id, 'course'=>$tree->course));
626 } else {
627 $plagiarsmlinks = '';
628 }
559276b1 629 $image = $this->output->pix_icon(file_file_icon($file), $filename, 'moodle', array('class'=>'icon'));
bbd0e548
DW
630 $result .= '<li yuiConfig=\''.json_encode($yuiconfig).'\'><div>'.$image.' '.$file->fileurl.' '.$plagiarsmlinks.$file->portfoliobutton.'</div></li>';
631 }
632
633 $result .= '</ul>';
634
635 return $result;
636 }
637
638 /**
639 * Helper method dealing with the fact we can not just fetch the output of flexible_table
640 *
641 * @param flexible_table $table The table to render
642 * @param int $rowsperpage How many assignments to render in a page
643 * @param bool $displaylinks - Whether to render links in the table (e.g. downloads would not enable this)
644 * @return string HTML
645 */
646 protected function flexible_table(flexible_table $table, $rowsperpage, $displaylinks) {
647
648 $o = '';
649 ob_start();
650 $table->out($rowsperpage, $displaylinks);
651 $o = ob_get_contents();
652 ob_end_clean();
653
654 return $o;
655 }
656
657 /**
658 * Helper method dealing with the fact we can not just fetch the output of moodleforms
659 *
660 * @param moodleform $mform
661 * @return string HTML
662 */
663 protected function moodleform(moodleform $mform) {
664
665 $o = '';
666 ob_start();
667 $mform->display();
668 $o = ob_get_contents();
669 ob_end_clean();
670
671 return $o;
672 }
673
674}
675