2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * This file contains a renderer for the assignment class
21 * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') ||
die();
27 /** Include locallib.php */
28 require_once($CFG->dirroot
. '/mod/assign/locallib.php');
32 * A custom renderer class that extends the plugin_renderer_base and is used by the assign module.
35 * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38 class mod_assign_renderer
extends plugin_renderer_base
{
41 * rendering assignment files
43 * @param context $context
45 * @param string $filearea
46 * @param string $component
49 public function assign_files(context
$context, $userid, $filearea, $component) {
50 return $this->render(new assign_files($context, $userid, $filearea, $component));
54 * rendering assignment files
56 * @param assign_files $tree
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
);
66 if ($tree->portfolioform
) {
67 $html .= $tree->portfolioform
;
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
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
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;
90 * Render a grading error notification
91 * @param assign_quickgrading_result $result The result to render
94 public function render_assign_quickgrading_result(assign_quickgrading_result
$result) {
95 $url = new moodle_url('/mod/assign/view.php', array('id' => $result->coursemoduleid
, 'action'=>'grading'));
98 $o .= $this->output
->heading(get_string('quickgradingresult', 'assign'), 4);
99 $o .= $this->output
->notification($result->message
);
100 $o .= $this->output
->continue_button($url);
105 * Render the generic form
106 * @param assign_form $form The form to render
109 public function render_assign_form(assign_form
$form) {
111 if ($form->jsinitfunction
) {
112 $this->page
->requires
->js_init_call($form->jsinitfunction
, array());
114 $o .= $this->output
->box_start('boxaligncenter ' . $form->classname
);
115 $o .= $this->moodleform($form->form
);
116 $o .= $this->output
->box_end();
121 * Render the user summary
123 * @param assign_user_summary $summary The user summary to render
126 public function render_assign_user_summary(assign_user_summary
$summary) {
129 if (!$summary->user
) {
132 $o .= $this->output
->container_start('usersummary');
133 $o .= $this->output
->box_start('boxaligncenter usersummarysection');
134 if ($summary->blindmarking
) {
135 $o .= get_string('hiddenuser', 'assign') . $summary->uniqueidforuser
;
137 $o .= $this->output
->user_picture($summary->user
);
138 $o .= $this->output
->spacer(array('width'=>30));
139 $o .= $this->output
->action_link(new moodle_url('/user/view.php',
140 array('id' => $summary->user
->id
,
141 'course'=>$summary->courseid
)),
142 fullname($summary->user
, $summary->viewfullnames
));
144 $o .= $this->output
->box_end();
145 $o .= $this->output
->container_end();
151 * Render the submit for grading page
153 * @param assign_submit_for_grading_page $page
156 public function render_assign_submit_for_grading_page($page) {
159 $o .= $this->output
->container_start('submitforgrading');
160 $o .= $this->output
->heading(get_string('submitassignment', 'assign'), 3);
161 $o .= $this->output
->spacer(array('height'=>30));
163 $cancelurl = new moodle_url('/mod/assign/view.php', array('id' => $page->coursemoduleid
));
164 if (count($page->notifications
)) {
165 // At least one of the submission plugins is not ready for submission
167 $o .= $this->output
->heading(get_string('submissionnotready', 'assign'), 4);
169 foreach ($page->notifications
as $notification) {
170 $o .= $this->output
->notification($notification);
173 $o .= $this->output
->continue_button($cancelurl);
175 // All submission plugins ready - show the confirmation form (may contain submission statement)
176 $o .= $this->moodleform($page->confirmform
);
178 $o .= $this->output
->container_end();
185 * Page is done - render the footer
189 public function render_footer() {
190 return $this->output
->footer();
196 * @param assign_header $header
199 public function render_assign_header(assign_header
$header) {
202 if ($header->subpage
) {
203 $this->page
->navbar
->add($header->subpage
);
206 $this->page
->set_title(get_string('pluginname', 'assign'));
207 $this->page
->set_heading($header->assign
->name
);
209 $o .= $this->output
->header();
210 if ($header->preface
) {
211 $o .= $header->preface
;
213 $o .= $this->output
->heading(format_string($header->assign
->name
,false, array('context' => $header->context
)));
215 if ($header->showintro
) {
216 $o .= $this->output
->box_start('generalbox boxaligncenter', 'intro');
217 $o .= format_module_intro('assign', $header->assign
, $header->coursemoduleid
);
218 $o .= $this->output
->box_end();
225 * render a table containing the current status of the grading process
227 * @param assign_grading_summary $summary
230 public function render_assign_grading_summary(assign_grading_summary
$summary) {
231 // create a table for the data
233 $o .= $this->output
->container_start('gradingsummary');
234 $o .= $this->output
->heading(get_string('gradingsummary', 'assign'), 3);
235 $o .= $this->output
->box_start('boxaligncenter gradingsummarytable');
236 $t = new html_table();
239 if ($summary->teamsubmission
) {
240 $this->add_table_row_tuple($t, get_string('numberofteams', 'assign'),
241 $summary->participantcount
);
243 $this->add_table_row_tuple($t, get_string('numberofparticipants', 'assign'),
244 $summary->participantcount
);
248 if ($summary->submissiondraftsenabled
) {
249 $this->add_table_row_tuple($t, get_string('numberofdraftsubmissions', 'assign'),
250 $summary->submissiondraftscount
);
253 // submitted for grading
254 if ($summary->submissionsenabled
) {
255 $this->add_table_row_tuple($t, get_string('numberofsubmittedassignments', 'assign'),
256 $summary->submissionssubmittedcount
);
257 if (!$summary->teamsubmission
) {
258 $this->add_table_row_tuple($t, get_string('numberofsubmissionsneedgrading', 'assign'),
259 $summary->submissionsneedgradingcount
);
264 if ($summary->duedate
) {
266 // submitted for grading
267 $duedate = $summary->duedate
;
268 $this->add_table_row_tuple($t, get_string('duedate', 'assign'),
273 if ($duedate - $time <= 0) {
274 $due = get_string('assignmentisdue', 'assign');
276 $due = format_time($duedate - $time);
278 $this->add_table_row_tuple($t, get_string('timeremaining', 'assign'), $due);
280 if ($duedate < $time) {
281 $cutoffdate = $summary->cutoffdate
;
283 if ($cutoffdate > $time) {
284 $late = get_string('latesubmissionsaccepted', 'assign');
286 $late = get_string('nomoresubmissionsaccepted', 'assign');
288 $this->add_table_row_tuple($t, get_string('latesubmissions', 'assign'), $late);
294 // all done - write the table
295 $o .= html_writer
::table($t);
296 $o .= $this->output
->box_end();
298 // link to the grading page
299 $o .= $this->output
->container_start('submissionlinks');
300 $o .= $this->output
->action_link(new moodle_url('/mod/assign/view.php',
301 array('id' => $summary->coursemoduleid
,
302 'action'=>'grading')),
303 get_string('viewgrading', 'assign'));
304 $o .= $this->output
->container_end();
306 // close the container and insert a spacer
307 $o .= $this->output
->container_end();
313 * render a table containing all the current grades and feedback
315 * @param assign_feedback_status $status
318 public function render_assign_feedback_status(assign_feedback_status
$status) {
322 $o .= $this->output
->container_start('feedback');
323 $o .= $this->output
->heading(get_string('feedback', 'assign'), 3);
324 $o .= $this->output
->box_start('boxaligncenter feedbacktable');
325 $t = new html_table();
328 if (isset($status->gradefordisplay
)) {
329 $row = new html_table_row();
330 $cell1 = new html_table_cell(get_string('grade'));
331 $cell2 = new html_table_cell($status->gradefordisplay
);
332 $row->cells
= array($cell1, $cell2);
336 $row = new html_table_row();
337 $cell1 = new html_table_cell(get_string('gradedon', 'assign'));
338 $cell2 = new html_table_cell(userdate($status->gradeddate
));
339 $row->cells
= array($cell1, $cell2);
343 if ($status->grader
) {
344 $row = new html_table_row();
345 $cell1 = new html_table_cell(get_string('gradedby', 'assign'));
346 $cell2 = new html_table_cell($this->output
->user_picture($status->grader
) . $this->output
->spacer(array('width'=>30)) . fullname($status->grader
));
347 $row->cells
= array($cell1, $cell2);
351 foreach ($status->feedbackplugins
as $plugin) {
352 if ($plugin->is_enabled() &&
353 $plugin->is_visible() &&
354 $plugin->has_user_summary() &&
355 !empty($status->grade
) &&
356 !$plugin->is_empty($status->grade
)) {
358 $row = new html_table_row();
359 $cell1 = new html_table_cell($plugin->get_name());
360 $pluginfeedback = new assign_feedback_plugin_feedback($plugin, $status->grade
, assign_feedback_plugin_feedback
::SUMMARY
, $status->coursemoduleid
, $status->returnaction
, $status->returnparams
);
361 $cell2 = new html_table_cell($this->render($pluginfeedback));
362 $row->cells
= array($cell1, $cell2);
368 $o .= html_writer
::table($t);
369 $o .= $this->output
->box_end();
371 $o .= $this->output
->container_end();
376 * render a table containing the current status of the submission
378 * @param assign_submission_status $status
381 public function render_assign_submission_status(assign_submission_status
$status) {
383 $o .= $this->output
->container_start('submissionstatustable');
384 $o .= $this->output
->heading(get_string('submissionstatusheading', 'assign'), 3);
387 if ($status->allowsubmissionsfromdate
&&
388 $time <= $status->allowsubmissionsfromdate
) {
389 $o .= $this->output
->box_start('generalbox boxaligncenter submissionsalloweddates');
390 if ($status->alwaysshowdescription
) {
391 $o .= get_string('allowsubmissionsfromdatesummary', 'assign', userdate($status->allowsubmissionsfromdate
));
393 $o .= get_string('allowsubmissionsanddescriptionfromdatesummary', 'assign', userdate($status->allowsubmissionsfromdate
));
395 $o .= $this->output
->box_end();
397 $o .= $this->output
->box_start('boxaligncenter submissionsummarytable');
399 $t = new html_table();
401 if ($status->teamsubmissionenabled
) {
402 $row = new html_table_row();
403 $cell1 = new html_table_cell(get_string('submissionteam', 'assign'));
404 $group = $status->submissiongroup
;
406 $cell2 = new html_table_cell(format_string($group->name
, false, $status->context
));
408 $cell2 = new html_table_cell(get_string('defaultteam', 'assign'));
410 $row->cells
= array($cell1, $cell2);
414 $row = new html_table_row();
415 $cell1 = new html_table_cell(get_string('submissionstatus', 'assign'));
416 if (!$status->teamsubmissionenabled
) {
417 if ($status->submission
) {
418 $cell2 = new html_table_cell(get_string('submissionstatus_' . $status->submission
->status
, 'assign'));
419 $cell2->attributes
= array('class'=>'submissionstatus' . $status->submission
->status
);
421 if (!$status->submissionsenabled
) {
422 $cell2 = new html_table_cell(get_string('noonlinesubmissions', 'assign'));
424 $cell2 = new html_table_cell(get_string('nosubmission', 'assign'));
427 $row->cells
= array($cell1, $cell2);
430 $row = new html_table_row();
431 $cell1 = new html_table_cell(get_string('submissionstatus', 'assign'));
432 if ($status->teamsubmission
) {
433 $submissionsummary = get_string('submissionstatus_' . $status->teamsubmission
->status
, 'assign');
435 if ($status->submissiongroup
) {
436 $groupid = $status->submissiongroup
->id
;
439 $members = $status->submissiongroupmemberswhoneedtosubmit
;
440 $userslist = array();
441 foreach ($members as $member) {
442 $url = new moodle_url('/user/view.php', array('id' => $member->id
, 'course'=>$status->courseid
));
443 if ($status->view
== assign_submission_status
::GRADER_VIEW
&& $status->blindmarking
) {
444 $userslist[] = $member->alias
;
446 $userslist[] = $this->output
->action_link($url, fullname($member, $status->canviewfullnames
));
449 if (count($userslist) > 0) {
450 $userstr = join(', ', $userslist);
451 $submissionsummary .= $this->output
->container(get_string('userswhoneedtosubmit', 'assign', $userstr));
454 $cell2 = new html_table_cell($submissionsummary);
455 $cell2->attributes
= array('class'=>'submissionstatus' . $status->teamsubmission
->status
);
457 $cell2 = new html_table_cell(get_string('nosubmission', 'assign'));
458 if (!$status->submissionsenabled
) {
459 $cell2 = new html_table_cell(get_string('noonlinesubmissions', 'assign'));
461 $cell2 = new html_table_cell(get_string('nosubmission', 'assign'));
464 $row->cells
= array($cell1, $cell2);
469 if ($status->locked
) {
470 $row = new html_table_row();
471 $cell1 = new html_table_cell();
472 $cell2 = new html_table_cell(get_string('submissionslocked', 'assign'));
473 $cell2->attributes
= array('class'=>'submissionlocked');
474 $row->cells
= array($cell1, $cell2);
479 $row = new html_table_row();
480 $cell1 = new html_table_cell(get_string('gradingstatus', 'assign'));
482 if ($status->graded
) {
483 $cell2 = new html_table_cell(get_string('graded', 'assign'));
484 $cell2->attributes
= array('class'=>'submissiongraded');
486 $cell2 = new html_table_cell(get_string('notgraded', 'assign'));
487 $cell2->attributes
= array('class'=>'submissionnotgraded');
489 $row->cells
= array($cell1, $cell2);
493 $duedate = $status->duedate
;
495 $row = new html_table_row();
496 $cell1 = new html_table_cell(get_string('duedate', 'assign'));
497 $cell2 = new html_table_cell(userdate($duedate));
498 $row->cells
= array($cell1, $cell2);
501 if ($status->view
== assign_submission_status
::GRADER_VIEW
) {
502 if ($status->cutoffdate
) {
503 $row = new html_table_row();
504 $cell1 = new html_table_cell(get_string('cutoffdate', 'assign'));
505 $cell2 = new html_table_cell(userdate($status->cutoffdate
));
506 $row->cells
= array($cell1, $cell2);
511 if ($status->extensionduedate
) {
512 $row = new html_table_row();
513 $cell1 = new html_table_cell(get_string('extensionduedate', 'assign'));
514 $cell2 = new html_table_cell(userdate($status->extensionduedate
));
515 $row->cells
= array($cell1, $cell2);
517 $duedate = $status->extensionduedate
;
521 $row = new html_table_row();
522 $cell1 = new html_table_cell(get_string('timeremaining', 'assign'));
523 if ($duedate - $time <= 0) {
524 if (!$status->submission ||
$status->submission
->status
!= ASSIGN_SUBMISSION_STATUS_SUBMITTED
) {
525 if ($status->submissionsenabled
) {
526 $cell2 = new html_table_cell(get_string('overdue', 'assign', format_time($time - $duedate)));
527 $cell2->attributes
= array('class'=>'overdue');
529 $cell2 = new html_table_cell(get_string('duedatereached', 'assign'));
532 if ($status->submission
->timemodified
> $duedate) {
533 $cell2 = new html_table_cell(get_string('submittedlate', 'assign', format_time($status->submission
->timemodified
- $duedate)));
534 $cell2->attributes
= array('class'=>'latesubmission');
536 $cell2 = new html_table_cell(get_string('submittedearly', 'assign', format_time($status->submission
->timemodified
- $duedate)));
537 $cell2->attributes
= array('class'=>'earlysubmission');
541 $cell2 = new html_table_cell(format_time($duedate - $time));
543 $row->cells
= array($cell1, $cell2);
547 // Show graders whether this submission is editable by students.
548 if ($status->view
== assign_submission_status
::GRADER_VIEW
) {
549 $row = new html_table_row();
550 $cell1 = new html_table_cell(get_string('editingstatus', 'assign'));
551 if ($status->canedit
) {
552 $cell2 = new html_table_cell(get_string('submissioneditable', 'assign'));
553 $cell2->attributes
= array('class'=>'submissioneditable');
555 $cell2 = new html_table_cell(get_string('submissionnoteditable', 'assign'));
556 $cell2->attributes
= array('class'=>'submissionnoteditable');
558 $row->cells
= array($cell1, $cell2);
562 // Grading criteria preview.
563 if (!empty($status->gradingcontrollerpreview
)) {
564 $row = new html_table_row();
565 $cell1 = new html_table_cell(get_string('gradingmethodpreview', 'assign'));
566 $cell2 = new html_table_cell($status->gradingcontrollerpreview
);
567 $row->cells
= array($cell1, $cell2);
572 $submission = $status->teamsubmission ?
$status->teamsubmission
: $status->submission
;
574 $row = new html_table_row();
575 $cell1 = new html_table_cell(get_string('timemodified', 'assign'));
576 $cell2 = new html_table_cell(userdate($submission->timemodified
));
577 $row->cells
= array($cell1, $cell2);
580 foreach ($status->submissionplugins
as $plugin) {
581 $pluginshowsummary = !$plugin->is_empty($submission) ||
!$plugin->allow_submissions();
582 if ($plugin->is_enabled() &&
583 $plugin->is_visible() &&
584 $plugin->has_user_summary() &&
585 $pluginshowsummary) {
587 $row = new html_table_row();
588 $cell1 = new html_table_cell($plugin->get_name());
589 $pluginsubmission = new assign_submission_plugin_submission($plugin,
591 assign_submission_plugin_submission
::SUMMARY
,
592 $status->coursemoduleid
,
593 $status->returnaction
,
594 $status->returnparams
);
595 $cell2 = new html_table_cell($this->render($pluginsubmission));
596 $row->cells
= array($cell1, $cell2);
603 $o .= html_writer
::table($t);
604 $o .= $this->output
->box_end();
607 if ($status->view
== assign_submission_status
::STUDENT_VIEW
) {
608 if ($status->canedit
) {
610 $urlparams = array('id' => $status->coursemoduleid
, 'action' => 'editsubmission');
611 $o .= $this->output
->single_button(new moodle_url('/mod/assign/view.php', $urlparams),
612 get_string('addsubmission', 'assign'), 'get');
614 $urlparams = array('id' => $status->coursemoduleid
, 'action' => 'editsubmission');
615 $o .= $this->output
->single_button(new moodle_url('/mod/assign/view.php', $urlparams),
616 get_string('editsubmission', 'assign'), 'get');
620 if ($status->cansubmit
) {
621 $urlparams = array('id' => $status->coursemoduleid
, 'action'=>'submit');
622 $o .= $this->output
->single_button(new moodle_url('/mod/assign/view.php', $urlparams),
623 get_string('submitassignment', 'assign'), 'get');
624 $o .= $this->output
->box_start('boxaligncenter submithelp');
625 $o .= get_string('submitassignment_help', 'assign');
626 $o .= $this->output
->box_end();
630 $o .= $this->output
->container_end();
635 * render a submission plugin submission
637 * @param assign_submission_plugin_submission $submissionplugin
640 public function render_assign_submission_plugin_submission(assign_submission_plugin_submission
$submissionplugin) {
643 if ($submissionplugin->view
== assign_submission_plugin_submission
::SUMMARY
) {
644 $showviewlink = false;
645 $summary = $submissionplugin->plugin
->view_summary($submissionplugin->submission
, $showviewlink);
647 $classsuffix = $submissionplugin->plugin
->get_subtype() . '_' . $submissionplugin->plugin
->get_type() . '_' . $submissionplugin->submission
->id
;
648 $o .= $this->output
->box_start('boxaligncenter plugincontentsummary summary_' . $classsuffix);
652 $previewstr = get_string('viewsubmission', 'assign');
653 $icon = $this->output
->pix_icon('t/preview', $previewstr);
655 $expandstr = get_string('viewfull', 'assign');
656 $classes = 'expandsummaryicon expand_' . $classsuffix;
657 $o .= $this->output
->pix_icon('t/switch_plus', $expandstr, null, array('class'=>$classes));
659 $jsparams = array($submissionplugin->plugin
->get_subtype(),
660 $submissionplugin->plugin
->get_type(),
661 $submissionplugin->submission
->id
);
662 $this->page
->requires
->js_init_call('M.mod_assign.init_plugin_summary', $jsparams);
664 $link .= '<noscript>';
665 $link .= $this->output
->action_link(
666 new moodle_url('/mod/assign/view.php',
667 array('id' => $submissionplugin->coursemoduleid
,
668 'sid'=>$submissionplugin->submission
->id
,
669 'plugin'=>$submissionplugin->plugin
->get_type(),
670 'action'=>'viewplugin' . $submissionplugin->plugin
->get_subtype(),
671 'returnaction'=>$submissionplugin->returnaction
,
672 'returnparams'=>http_build_query($submissionplugin->returnparams
))),
674 $link .= '</noscript>';
676 $link .= $this->output
->spacer(array('width'=>15));
679 $o .= $link . $summary;
680 $o .= $this->output
->box_end();
682 $o .= $this->output
->box_start('boxaligncenter hidefull full_' . $classsuffix);
683 $classes = 'expandsummaryicon contract_' . $classsuffix;
684 $o .= $this->output
->pix_icon('t/switch_minus',
685 get_string('viewsummary', 'assign'),
687 array('class'=>$classes));
688 $o .= $submissionplugin->plugin
->view($submissionplugin->submission
);
689 $o .= $this->output
->box_end();
691 } else if ($submissionplugin->view
== assign_submission_plugin_submission
::FULL
) {
692 $o .= $this->output
->box_start('boxaligncenter submissionfull');
693 $o .= $submissionplugin->plugin
->view($submissionplugin->submission
);
694 $o .= $this->output
->box_end();
701 * render the grading table
703 * @param assign_grading_table $table
706 public function render_assign_grading_table(assign_grading_table
$table) {
708 $o .= $this->output
->box_start('boxaligncenter gradingtable');
710 $this->page
->requires
->js_init_call('M.mod_assign.init_grading_table', array());
711 $this->page
->requires
->string_for_js('nousersselected', 'assign');
712 $this->page
->requires
->string_for_js('batchoperationconfirmgrantextension', 'assign');
713 $this->page
->requires
->string_for_js('batchoperationconfirmlock', 'assign');
714 $this->page
->requires
->string_for_js('batchoperationconfirmreverttodraft', 'assign');
715 $this->page
->requires
->string_for_js('batchoperationconfirmunlock', 'assign');
716 $this->page
->requires
->string_for_js('editaction', 'assign');
717 foreach ($table->plugingradingbatchoperations
as $plugin => $operations) {
718 foreach ($operations as $operation => $description) {
719 $this->page
->requires
->string_for_js('batchoperationconfirm' . $operation, 'assignfeedback_' . $plugin);
722 // need to get from prefs
723 $o .= $this->flexible_table($table, $table->get_rows_per_page(), true);
724 $o .= $this->output
->box_end();
730 * Render a feedback plugin feedback
732 * @param assign_feedback_plugin_feedback $feedbackplugin
735 public function render_assign_feedback_plugin_feedback(assign_feedback_plugin_feedback
$feedbackplugin) {
738 if ($feedbackplugin->view
== assign_feedback_plugin_feedback
::SUMMARY
) {
739 $showviewlink = false;
740 $summary = $feedbackplugin->plugin
->view_summary($feedbackplugin->grade
, $showviewlink);
742 $classsuffix = $feedbackplugin->plugin
->get_subtype() . '_' . $feedbackplugin->plugin
->get_type() . '_' . $feedbackplugin->grade
->id
;
743 $o .= $this->output
->box_start('boxaligncenter plugincontentsummary summary_' . $classsuffix);
747 $previewstr = get_string('viewfeedback', 'assign');
748 $icon = $this->output
->pix_icon('t/preview', $previewstr);
750 $expandstr = get_string('viewfull', 'assign');
751 $classes = 'expandsummaryicon expand_' . $classsuffix;
752 $o .= $this->output
->pix_icon('t/switch_plus', $expandstr, null, array('class'=>$classes));
754 $jsparams = array($feedbackplugin->plugin
->get_subtype(),
755 $feedbackplugin->plugin
->get_type(),
756 $feedbackplugin->grade
->id
);
757 $this->page
->requires
->js_init_call('M.mod_assign.init_plugin_summary', $jsparams);
759 $link .= '<noscript>';
760 $link .= $this->output
->action_link(
761 new moodle_url('/mod/assign/view.php',
762 array('id' => $feedbackplugin->coursemoduleid
,
763 'gid'=>$feedbackplugin->grade
->id
,
764 'plugin'=>$feedbackplugin->plugin
->get_type(),
765 'action'=>'viewplugin' . $feedbackplugin->plugin
->get_subtype(),
766 'returnaction'=>$feedbackplugin->returnaction
,
767 'returnparams'=>http_build_query($feedbackplugin->returnparams
))),
769 $link .= '</noscript>';
771 $link .= $this->output
->spacer(array('width'=>15));
774 $o .= $link . $summary;
775 $o .= $this->output
->box_end();
777 $o .= $this->output
->box_start('boxaligncenter hidefull full_' . $classsuffix);
778 $classes = 'expandsummaryicon contract_' . $classsuffix;
779 $o .= $this->output
->pix_icon('t/switch_minus',
780 get_string('viewsummary', 'assign'),
782 array('class'=>$classes));
783 $o .= $feedbackplugin->plugin
->view($feedbackplugin->grade
);
784 $o .= $this->output
->box_end();
786 } else if ($feedbackplugin->view
== assign_feedback_plugin_feedback
::FULL
) {
787 $o .= $this->output
->box_start('boxaligncenter feedbackfull');
788 $o .= $feedbackplugin->plugin
->view($feedbackplugin->grade
);
789 $o .= $this->output
->box_end();
796 * Render a course index summary
798 * @param assign_course_index_summary $indexsummary
801 public function render_assign_course_index_summary(assign_course_index_summary
$indexsummary) {
804 $strplural = get_string('modulenameplural', 'assign');
805 $strsectionname = $indexsummary->courseformatname
;
806 $strduedate = get_string('duedate', 'assign');
807 $strsubmission = get_string('submission', 'assign');
808 $strgrade = get_string('grade');
810 $table = new html_table();
811 if ($indexsummary->usesections
) {
812 $table->head
= array ($strsectionname, $strplural, $strduedate, $strsubmission, $strgrade);
813 $table->align
= array ('left', 'left', 'center', 'right', 'right');
815 $table->head
= array ($strplural, $strduedate, $strsubmission, $strgrade);
816 $table->align
= array ('left', 'left', 'center', 'right');
818 $table->data
= array();
820 $currentsection = '';
821 foreach ($indexsummary->assignments
as $info) {
822 $params = array('id' => $info['cmid']);
823 $link = html_writer
::link(new moodle_url('/mod/assign/view.php', $params),
825 $due = $info['timedue'] ?
userdate($info['timedue']) : '-';
828 if ($indexsummary->usesections
) {
829 if ($info['sectionname'] !== $currentsection) {
830 if ($info['sectionname']) {
831 $printsection = $info['sectionname'];
833 if ($currentsection !== '') {
834 $table->data
[] = 'hr';
836 $currentsection = $info['sectionname'];
840 if ($indexsummary->usesections
) {
841 $row = array($printsection, $link, $due, $info['submissioninfo'], $info['gradeinfo']);
843 $row = array($link, $due, $info['submissioninfo'], $info['gradeinfo']);
845 $table->data
[] = $row;
848 $o .= html_writer
::table($table);
856 * Internal function - creates htmls structure suitable for YUI tree.
858 * @param assign_files $tree
862 protected function htmllize_tree(assign_files
$tree, $dir) {
864 $yuiconfig = array();
865 $yuiconfig['type'] = 'html';
867 if (empty($dir['subdirs']) and empty($dir['files'])) {
872 foreach ($dir['subdirs'] as $subdir) {
873 $image = $this->output
->pix_icon(file_folder_icon(), $subdir['dirname'], 'moodle', array('class'=>'icon'));
874 $result .= '<li yuiConfig=\''.json_encode($yuiconfig).'\'><div>'.$image.' '.s($subdir['dirname']).'</div> '.$this->htmllize_tree($tree, $subdir).'</li>';
877 foreach ($dir['files'] as $file) {
878 $filename = $file->get_filename();
879 if ($CFG->enableplagiarism
) {
880 require_once($CFG->libdir
.'/plagiarismlib.php');
881 $plagiarsmlinks = plagiarism_get_links(array('userid'=>$file->get_userid(), 'file'=>$file, 'cmid'=>$tree->cm
->id
, 'course'=>$tree->course
));
883 $plagiarsmlinks = '';
885 $image = $this->output
->pix_icon(file_file_icon($file), $filename, 'moodle', array('class'=>'icon'));
886 $result .= '<li yuiConfig=\''.json_encode($yuiconfig).'\'><div>'.$image.' '.$file->fileurl
.' '.$plagiarsmlinks.$file->portfoliobutton
.'</div></li>';
895 * Helper method dealing with the fact we can not just fetch the output of flexible_table
897 * @param flexible_table $table The table to render
898 * @param int $rowsperpage How many assignments to render in a page
899 * @param bool $displaylinks - Whether to render links in the table (e.g. downloads would not enable this)
900 * @return string HTML
902 protected function flexible_table(flexible_table
$table, $rowsperpage, $displaylinks) {
906 $table->out($rowsperpage, $displaylinks);
907 $o = ob_get_contents();
914 * Helper method dealing with the fact we can not just fetch the output of moodleforms
916 * @param moodleform $mform
917 * @return string HTML
919 protected function moodleform(moodleform
$mform) {
924 $o = ob_get_contents();