[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
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 25 defined('MOODLE_INTERNAL') || die(); 26 27 require_once($CFG->dirroot . '/mod/assign/locallib.php'); 28 29 use \mod_assign\output\grading_app; 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 */ 38 class 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 = html_writer::random_id('assign_files_tree'); 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 89 /** 90 * Render a grading message notification 91 * @param assign_gradingmessage $result The result to render 92 * @return string 93 */ 94 public function render_assign_gradingmessage(assign_gradingmessage $result) { 95 $urlparams = array('id' => $result->coursemoduleid, 'action'=>'grading'); 96 if (!empty($result->page)) { 97 $urlparams['page'] = $result->page; 98 } 99 $url = new moodle_url('/mod/assign/view.php', $urlparams); 100 $classes = $result->gradingerror ? 'notifyproblem' : 'notifysuccess'; 101 102 $o = ''; 103 $o .= $this->output->heading($result->heading, 4); 104 $o .= $this->output->notification($result->message, $classes); 105 $o .= $this->output->continue_button($url); 106 return $o; 107 } 108 109 /** 110 * Render the generic form 111 * @param assign_form $form The form to render 112 * @return string 113 */ 114 public function render_assign_form(assign_form $form) { 115 $o = ''; 116 if ($form->jsinitfunction) { 117 $this->page->requires->js_init_call($form->jsinitfunction, array()); 118 } 119 $o .= $this->output->box_start('boxaligncenter ' . $form->classname); 120 $o .= $this->moodleform($form->form); 121 $o .= $this->output->box_end(); 122 return $o; 123 } 124 125 /** 126 * Render the user summary 127 * 128 * @param assign_user_summary $summary The user summary to render 129 * @return string 130 */ 131 public function render_assign_user_summary(assign_user_summary $summary) { 132 $o = ''; 133 $supendedclass = ''; 134 $suspendedicon = ''; 135 136 if (!$summary->user) { 137 return; 138 } 139 140 if ($summary->suspendeduser) { 141 $supendedclass = ' usersuspended'; 142 $suspendedstring = get_string('userenrolmentsuspended', 'grades'); 143 $suspendedicon = ' ' . html_writer::empty_tag('img', array('src' => $this->pix_url('i/enrolmentsuspended'), 144 'title' => $suspendedstring, 'alt' => $suspendedstring, 'class' => 'usersuspendedicon')); 145 } 146 $o .= $this->output->container_start('usersummary'); 147 $o .= $this->output->box_start('boxaligncenter usersummarysection'.$supendedclass); 148 if ($summary->blindmarking) { 149 $o .= get_string('hiddenuser', 'assign') . $summary->uniqueidforuser.$suspendedicon; 150 } else { 151 $o .= $this->output->user_picture($summary->user); 152 $o .= $this->output->spacer(array('width'=>30)); 153 $urlparams = array('id' => $summary->user->id, 'course'=>$summary->courseid); 154 $url = new moodle_url('/user/view.php', $urlparams); 155 $fullname = fullname($summary->user, $summary->viewfullnames); 156 $extrainfo = array(); 157 foreach ($summary->extrauserfields as $extrafield) { 158 $extrainfo[] = $summary->user->$extrafield; 159 } 160 if (count($extrainfo)) { 161 $fullname .= ' (' . implode(', ', $extrainfo) . ')'; 162 } 163 $fullname .= $suspendedicon; 164 $o .= $this->output->action_link($url, $fullname); 165 } 166 $o .= $this->output->box_end(); 167 $o .= $this->output->container_end(); 168 169 return $o; 170 } 171 172 /** 173 * Render the submit for grading page 174 * 175 * @param assign_submit_for_grading_page $page 176 * @return string 177 */ 178 public function render_assign_submit_for_grading_page($page) { 179 $o = ''; 180 181 $o .= $this->output->container_start('submitforgrading'); 182 $o .= $this->output->heading(get_string('submitassignment', 'assign'), 3); 183 $o .= $this->output->spacer(array('height'=>30)); 184 185 $cancelurl = new moodle_url('/mod/assign/view.php', array('id' => $page->coursemoduleid)); 186 if (count($page->notifications)) { 187 // At least one of the submission plugins is not ready for submission. 188 189 $o .= $this->output->heading(get_string('submissionnotready', 'assign'), 4); 190 191 foreach ($page->notifications as $notification) { 192 $o .= $this->output->notification($notification); 193 } 194 195 $o .= $this->output->continue_button($cancelurl); 196 } else { 197 // All submission plugins ready - show the confirmation form. 198 $o .= $this->output->box_start('generalbox submitconfirm'); 199 $o .= $this->moodleform($page->confirmform); 200 $o .= $this->output->box_end(); 201 } 202 $o .= $this->output->container_end(); 203 204 return $o; 205 } 206 207 /** 208 * Page is done - render the footer. 209 * 210 * @return void 211 */ 212 public function render_footer() { 213 return $this->output->footer(); 214 } 215 216 /** 217 * Render the header. 218 * 219 * @param assign_header $header 220 * @return string 221 */ 222 public function render_assign_header(assign_header $header) { 223 $o = ''; 224 225 if ($header->subpage) { 226 $this->page->navbar->add($header->subpage); 227 } 228 229 $this->page->set_title(get_string('pluginname', 'assign')); 230 $this->page->set_heading($this->page->course->fullname); 231 232 $o .= $this->output->header(); 233 $heading = format_string($header->assign->name, false, array('context' => $header->context)); 234 $o .= $this->output->heading($heading); 235 if ($header->preface) { 236 $o .= $header->preface; 237 } 238 239 if ($header->showintro) { 240 $o .= $this->output->box_start('generalbox boxaligncenter', 'intro'); 241 $o .= format_module_intro('assign', $header->assign, $header->coursemoduleid); 242 $o .= $header->postfix; 243 $o .= $this->output->box_end(); 244 } 245 246 return $o; 247 } 248 249 /** 250 * Render the header for an individual plugin. 251 * 252 * @param assign_plugin_header $header 253 * @return string 254 */ 255 public function render_assign_plugin_header(assign_plugin_header $header) { 256 $o = $header->plugin->view_header(); 257 return $o; 258 } 259 260 /** 261 * Render a table containing the current status of the grading process. 262 * 263 * @param assign_grading_summary $summary 264 * @return string 265 */ 266 public function render_assign_grading_summary(assign_grading_summary $summary) { 267 // Create a table for the data. 268 $o = ''; 269 $o .= $this->output->container_start('gradingsummary'); 270 $o .= $this->output->heading(get_string('gradingsummary', 'assign'), 3); 271 $o .= $this->output->box_start('boxaligncenter gradingsummarytable'); 272 $t = new html_table(); 273 274 // Status. 275 if ($summary->teamsubmission) { 276 if ($summary->warnofungroupedusers) { 277 $o .= $this->output->notification(get_string('ungroupedusers', 'assign')); 278 } 279 280 $this->add_table_row_tuple($t, get_string('numberofteams', 'assign'), 281 $summary->participantcount); 282 } else { 283 $this->add_table_row_tuple($t, get_string('numberofparticipants', 'assign'), 284 $summary->participantcount); 285 } 286 287 // Drafts count and dont show drafts count when using offline assignment. 288 if ($summary->submissiondraftsenabled && $summary->submissionsenabled) { 289 $this->add_table_row_tuple($t, get_string('numberofdraftsubmissions', 'assign'), 290 $summary->submissiondraftscount); 291 } 292 293 // Submitted for grading. 294 if ($summary->submissionsenabled) { 295 $this->add_table_row_tuple($t, get_string('numberofsubmittedassignments', 'assign'), 296 $summary->submissionssubmittedcount); 297 if (!$summary->teamsubmission) { 298 $this->add_table_row_tuple($t, get_string('numberofsubmissionsneedgrading', 'assign'), 299 $summary->submissionsneedgradingcount); 300 } 301 } 302 303 $time = time(); 304 if ($summary->duedate) { 305 // Due date. 306 $duedate = $summary->duedate; 307 $this->add_table_row_tuple($t, get_string('duedate', 'assign'), 308 userdate($duedate)); 309 310 // Time remaining. 311 $due = ''; 312 if ($duedate - $time <= 0) { 313 $due = get_string('assignmentisdue', 'assign'); 314 } else { 315 $due = format_time($duedate - $time); 316 } 317 $this->add_table_row_tuple($t, get_string('timeremaining', 'assign'), $due); 318 319 if ($duedate < $time) { 320 $cutoffdate = $summary->cutoffdate; 321 if ($cutoffdate) { 322 if ($cutoffdate > $time) { 323 $late = get_string('latesubmissionsaccepted', 'assign', userdate($summary->cutoffdate)); 324 } else { 325 $late = get_string('nomoresubmissionsaccepted', 'assign'); 326 } 327 $this->add_table_row_tuple($t, get_string('latesubmissions', 'assign'), $late); 328 } 329 } 330 331 } 332 333 // All done - write the table. 334 $o .= html_writer::table($t); 335 $o .= $this->output->box_end(); 336 337 // Link to the grading page. 338 $o .= '<center>'; 339 $o .= $this->output->container_start('submissionlinks'); 340 $urlparams = array('id' => $summary->coursemoduleid, 'action' => 'grading'); 341 $url = new moodle_url('/mod/assign/view.php', $urlparams); 342 $o .= '<a href="' . $url . '" class="btn">' . get_string('viewgrading', 'mod_assign') . '</a> '; 343 $urlparams = array('id' => $summary->coursemoduleid, 'action' => 'grader'); 344 $url = new moodle_url('/mod/assign/view.php', $urlparams); 345 $o .= '<a href="' . $url . '" class="btn btn-primary">' . get_string('grade') . '</a>'; 346 $o .= $this->output->container_end(); 347 348 // Close the container and insert a spacer. 349 $o .= $this->output->container_end(); 350 $o .= '</center>'; 351 352 return $o; 353 } 354 355 /** 356 * Render a table containing all the current grades and feedback. 357 * 358 * @param assign_feedback_status $status 359 * @return string 360 */ 361 public function render_assign_feedback_status(assign_feedback_status $status) { 362 global $DB, $CFG; 363 $o = ''; 364 365 $o .= $this->output->container_start('feedback'); 366 $o .= $this->output->heading(get_string('feedback', 'assign'), 3); 367 $o .= $this->output->box_start('boxaligncenter feedbacktable'); 368 $t = new html_table(); 369 370 // Grade. 371 if (isset($status->gradefordisplay)) { 372 $row = new html_table_row(); 373 $cell1 = new html_table_cell(get_string('grade')); 374 $cell2 = new html_table_cell($status->gradefordisplay); 375 $row->cells = array($cell1, $cell2); 376 $t->data[] = $row; 377 378 // Grade date. 379 $row = new html_table_row(); 380 $cell1 = new html_table_cell(get_string('gradedon', 'assign')); 381 $cell2 = new html_table_cell(userdate($status->gradeddate)); 382 $row->cells = array($cell1, $cell2); 383 $t->data[] = $row; 384 } 385 386 if ($status->grader) { 387 // Grader. 388 $row = new html_table_row(); 389 $cell1 = new html_table_cell(get_string('gradedby', 'assign')); 390 $userdescription = $this->output->user_picture($status->grader) . 391 $this->output->spacer(array('width'=>30)) . 392 fullname($status->grader); 393 $cell2 = new html_table_cell($userdescription); 394 $row->cells = array($cell1, $cell2); 395 $t->data[] = $row; 396 } 397 398 foreach ($status->feedbackplugins as $plugin) { 399 if ($plugin->is_enabled() && 400 $plugin->is_visible() && 401 $plugin->has_user_summary() && 402 !empty($status->grade) && 403 !$plugin->is_empty($status->grade)) { 404 405 $row = new html_table_row(); 406 $cell1 = new html_table_cell($plugin->get_name()); 407 $displaymode = assign_feedback_plugin_feedback::SUMMARY; 408 $pluginfeedback = new assign_feedback_plugin_feedback($plugin, 409 $status->grade, 410 $displaymode, 411 $status->coursemoduleid, 412 $status->returnaction, 413 $status->returnparams); 414 $cell2 = new html_table_cell($this->render($pluginfeedback)); 415 $row->cells = array($cell1, $cell2); 416 $t->data[] = $row; 417 } 418 } 419 420 $o .= html_writer::table($t); 421 $o .= $this->output->box_end(); 422 423 $o .= $this->output->container_end(); 424 return $o; 425 } 426 427 /** 428 * Render a compact view of the current status of the submission. 429 * 430 * @param assign_submission_status_compact $status 431 * @return string 432 */ 433 public function render_assign_submission_status_compact(assign_submission_status_compact $status) { 434 $o = ''; 435 $o .= $this->output->container_start('submissionstatustable'); 436 $o .= $this->output->heading(get_string('submission', 'assign'), 3); 437 $time = time(); 438 439 if ($status->teamsubmissionenabled) { 440 $group = $status->submissiongroup; 441 if ($group) { 442 $team = format_string($group->name, false, $status->context); 443 } else if ($status->preventsubmissionnotingroup) { 444 if (count($status->usergroups) == 0) { 445 $team = '<span class="alert alert-error">' . get_string('noteam', 'assign') . '</span>'; 446 } else if (count($status->usergroups) > 1) { 447 $team = '<span class="alert alert-error">' . get_string('multipleteams', 'assign') . '</span>'; 448 } 449 } else { 450 $team = get_string('defaultteam', 'assign'); 451 } 452 $o .= $this->output->container(get_string('teamname', 'assign', $team), 'teamname'); 453 } 454 455 if (!$status->teamsubmissionenabled) { 456 if ($status->submission && $status->submission->status != ASSIGN_SUBMISSION_STATUS_NEW) { 457 $statusstr = get_string('submissionstatus_' . $status->submission->status, 'assign'); 458 $o .= $this->output->container($statusstr, 'submissionstatus' . $status->submission->status); 459 } else { 460 if (!$status->submissionsenabled) { 461 $o .= $this->output->container(get_string('noonlinesubmissions', 'assign'), 'submissionstatus'); 462 } else { 463 $o .= $this->output->container(get_string('noattempt', 'assign'), 'submissionstatus'); 464 } 465 } 466 } else { 467 $group = $status->submissiongroup; 468 if (!$group && $status->preventsubmissionnotingroup) { 469 $o .= $this->output->container(get_string('nosubmission', 'assign'), 'submissionstatus'); 470 } else if ($status->teamsubmission && $status->teamsubmission->status != ASSIGN_SUBMISSION_STATUS_NEW) { 471 $teamstatus = $status->teamsubmission->status; 472 $submissionsummary = get_string('submissionstatus_' . $teamstatus, 'assign'); 473 $groupid = 0; 474 if ($status->submissiongroup) { 475 $groupid = $status->submissiongroup->id; 476 } 477 478 $members = $status->submissiongroupmemberswhoneedtosubmit; 479 $userslist = array(); 480 foreach ($members as $member) { 481 $urlparams = array('id' => $member->id, 'course' => $status->courseid); 482 $url = new moodle_url('/user/view.php', $urlparams); 483 if ($status->view == assign_submission_status::GRADER_VIEW && $status->blindmarking) { 484 $userslist[] = $member->alias; 485 } else { 486 $fullname = fullname($member, $status->canviewfullnames); 487 $userslist[] = $this->output->action_link($url, $fullname); 488 } 489 } 490 if (count($userslist) > 0) { 491 $userstr = join(', ', $userslist); 492 $formatteduserstr = get_string('userswhoneedtosubmit', 'assign', $userstr); 493 $submissionsummary .= $this->output->container($formatteduserstr); 494 } 495 $o .= $this->output->container($submissionsummary, 'submissionstatus' . $status->teamsubmission->status); 496 } else { 497 if (!$status->submissionsenabled) { 498 $o .= $this->output->container(get_string('noonlinesubmissions', 'assign'), 'submissionstatus'); 499 } else { 500 $o .= $this->output->container(get_string('nosubmission', 'assign'), 'submissionstatus'); 501 } 502 } 503 } 504 505 // Is locked? 506 if ($status->locked) { 507 $o .= $this->output->container(get_string('submissionslocked', 'assign'), 'submissionlocked'); 508 } 509 510 // Grading status. 511 $statusstr = ''; 512 $classname = 'gradingstatus'; 513 if ($status->gradingstatus == ASSIGN_GRADING_STATUS_GRADED || 514 $status->gradingstatus == ASSIGN_GRADING_STATUS_NOT_GRADED) { 515 $statusstr = get_string($status->gradingstatus, 'assign'); 516 } else { 517 $gradingstatus = 'markingworkflowstate' . $status->gradingstatus; 518 $statusstr = get_string($gradingstatus, 'assign'); 519 } 520 if ($status->gradingstatus == ASSIGN_GRADING_STATUS_GRADED || 521 $status->gradingstatus == ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) { 522 $classname = 'submissiongraded'; 523 } else { 524 $classname = 'submissionnotgraded'; 525 } 526 $o .= $this->output->container($statusstr, $classname); 527 528 $submission = $status->teamsubmission ? $status->teamsubmission : $status->submission; 529 $duedate = $status->duedate; 530 if ($duedate > 0) { 531 532 if ($status->extensionduedate) { 533 // Extension date. 534 $duedate = $status->extensionduedate; 535 } 536 537 // Time remaining. 538 $classname = 'timeremaining'; 539 if ($duedate - $time <= 0) { 540 if (!$submission || 541 $submission->status != ASSIGN_SUBMISSION_STATUS_SUBMITTED) { 542 if ($status->submissionsenabled) { 543 $remaining = get_string('overdue', 'assign', format_time($time - $duedate)); 544 $classname = 'overdue'; 545 } else { 546 $remaining = get_string('duedatereached', 'assign'); 547 } 548 } else { 549 if ($submission->timemodified > $duedate) { 550 $remaining = get_string('submittedlate', 551 'assign', 552 format_time($submission->timemodified - $duedate)); 553 $classname = 'latesubmission'; 554 } else { 555 $remaining = get_string('submittedearly', 556 'assign', 557 format_time($submission->timemodified - $duedate)); 558 $classname = 'earlysubmission'; 559 } 560 } 561 } else { 562 $remaining = get_string('paramtimeremaining', 'assign', format_time($duedate - $time)); 563 } 564 $o .= $this->output->container($remaining, $classname); 565 } 566 567 // Show graders whether this submission is editable by students. 568 if ($status->view == assign_submission_status::GRADER_VIEW) { 569 if ($status->canedit) { 570 $o .= $this->output->container(get_string('submissioneditable', 'assign'), 'submissioneditable'); 571 } else { 572 $o .= $this->output->container(get_string('submissionnoteditable', 'assign'), 'submissionnoteditable'); 573 } 574 } 575 576 // Grading criteria preview. 577 if (!empty($status->gradingcontrollerpreview)) { 578 $o .= $this->output->container($status->gradingcontrollerpreview, 'gradingmethodpreview'); 579 } 580 581 if ($submission) { 582 583 if (!$status->teamsubmission || $status->submissiongroup != false || !$status->preventsubmissionnotingroup) { 584 foreach ($status->submissionplugins as $plugin) { 585 $pluginshowsummary = !$plugin->is_empty($submission) || !$plugin->allow_submissions(); 586 if ($plugin->is_enabled() && 587 $plugin->is_visible() && 588 $plugin->has_user_summary() && 589 $pluginshowsummary 590 ) { 591 592 $displaymode = assign_submission_plugin_submission::SUMMARY; 593 $pluginsubmission = new assign_submission_plugin_submission($plugin, 594 $submission, 595 $displaymode, 596 $status->coursemoduleid, 597 $status->returnaction, 598 $status->returnparams); 599 $plugincomponent = $plugin->get_subtype() . '_' . $plugin->get_type(); 600 $o .= $this->output->container($this->render($pluginsubmission), 'assignsubmission ' . $plugincomponent); 601 } 602 } 603 } 604 } 605 606 $o .= $this->output->container_end(); 607 return $o; 608 } 609 610 /** 611 * Render a table containing the current status of the submission. 612 * 613 * @param assign_submission_status $status 614 * @return string 615 */ 616 public function render_assign_submission_status(assign_submission_status $status) { 617 $o = ''; 618 $o .= $this->output->container_start('submissionstatustable'); 619 $o .= $this->output->heading(get_string('submissionstatusheading', 'assign'), 3); 620 $time = time(); 621 622 if ($status->allowsubmissionsfromdate && 623 $time <= $status->allowsubmissionsfromdate) { 624 $o .= $this->output->box_start('generalbox boxaligncenter submissionsalloweddates'); 625 if ($status->alwaysshowdescription) { 626 $date = userdate($status->allowsubmissionsfromdate); 627 $o .= get_string('allowsubmissionsfromdatesummary', 'assign', $date); 628 } else { 629 $date = userdate($status->allowsubmissionsfromdate); 630 $o .= get_string('allowsubmissionsanddescriptionfromdatesummary', 'assign', $date); 631 } 632 $o .= $this->output->box_end(); 633 } 634 $o .= $this->output->box_start('boxaligncenter submissionsummarytable'); 635 636 $t = new html_table(); 637 638 if ($status->teamsubmissionenabled) { 639 $row = new html_table_row(); 640 $cell1 = new html_table_cell(get_string('submissionteam', 'assign')); 641 $group = $status->submissiongroup; 642 if ($group) { 643 $cell2 = new html_table_cell(format_string($group->name, false, $status->context)); 644 } else if ($status->preventsubmissionnotingroup) { 645 if (count($status->usergroups) == 0) { 646 $cell2 = new html_table_cell( 647 html_writer::span(get_string('noteam', 'assign'), 'alert alert-error') 648 ); 649 } else if (count($status->usergroups) > 1) { 650 $cell2 = new html_table_cell( 651 html_writer::span(get_string('multipleteams', 'assign'), 'alert alert-error') 652 ); 653 } 654 } else { 655 $cell2 = new html_table_cell(get_string('defaultteam', 'assign')); 656 } 657 $row->cells = array($cell1, $cell2); 658 $t->data[] = $row; 659 } 660 661 if ($status->attemptreopenmethod != ASSIGN_ATTEMPT_REOPEN_METHOD_NONE) { 662 $currentattempt = 1; 663 if (!$status->teamsubmissionenabled) { 664 if ($status->submission) { 665 $currentattempt = $status->submission->attemptnumber + 1; 666 } 667 } else { 668 if ($status->teamsubmission) { 669 $currentattempt = $status->teamsubmission->attemptnumber + 1; 670 } 671 } 672 673 $row = new html_table_row(); 674 $cell1 = new html_table_cell(get_string('attemptnumber', 'assign')); 675 $maxattempts = $status->maxattempts; 676 if ($maxattempts == ASSIGN_UNLIMITED_ATTEMPTS) { 677 $message = get_string('currentattempt', 'assign', $currentattempt); 678 } else { 679 $message = get_string('currentattemptof', 'assign', array('attemptnumber'=>$currentattempt, 680 'maxattempts'=>$maxattempts)); 681 } 682 $cell2 = new html_table_cell($message); 683 $row->cells = array($cell1, $cell2); 684 $t->data[] = $row; 685 } 686 687 $row = new html_table_row(); 688 $cell1 = new html_table_cell(get_string('submissionstatus', 'assign')); 689 if (!$status->teamsubmissionenabled) { 690 if ($status->submission && $status->submission->status != ASSIGN_SUBMISSION_STATUS_NEW) { 691 $statusstr = get_string('submissionstatus_' . $status->submission->status, 'assign'); 692 $cell2 = new html_table_cell($statusstr); 693 $cell2->attributes = array('class'=>'submissionstatus' . $status->submission->status); 694 } else { 695 if (!$status->submissionsenabled) { 696 $cell2 = new html_table_cell(get_string('noonlinesubmissions', 'assign')); 697 } else { 698 $cell2 = new html_table_cell(get_string('noattempt', 'assign')); 699 } 700 } 701 $row->cells = array($cell1, $cell2); 702 $t->data[] = $row; 703 } else { 704 $row = new html_table_row(); 705 $cell1 = new html_table_cell(get_string('submissionstatus', 'assign')); 706 $group = $status->submissiongroup; 707 if (!$group && $status->preventsubmissionnotingroup) { 708 $cell2 = new html_table_cell(get_string('nosubmission', 'assign')); 709 } else if ($status->teamsubmission && $status->teamsubmission->status != ASSIGN_SUBMISSION_STATUS_NEW) { 710 $teamstatus = $status->teamsubmission->status; 711 $submissionsummary = get_string('submissionstatus_' . $teamstatus, 'assign'); 712 $groupid = 0; 713 if ($status->submissiongroup) { 714 $groupid = $status->submissiongroup->id; 715 } 716 717 $members = $status->submissiongroupmemberswhoneedtosubmit; 718 $userslist = array(); 719 foreach ($members as $member) { 720 $urlparams = array('id' => $member->id, 'course'=>$status->courseid); 721 $url = new moodle_url('/user/view.php', $urlparams); 722 if ($status->view == assign_submission_status::GRADER_VIEW && $status->blindmarking) { 723 $userslist[] = $member->alias; 724 } else { 725 $fullname = fullname($member, $status->canviewfullnames); 726 $userslist[] = $this->output->action_link($url, $fullname); 727 } 728 } 729 if (count($userslist) > 0) { 730 $userstr = join(', ', $userslist); 731 $formatteduserstr = get_string('userswhoneedtosubmit', 'assign', $userstr); 732 $submissionsummary .= $this->output->container($formatteduserstr); 733 } 734 735 $cell2 = new html_table_cell($submissionsummary); 736 $cell2->attributes = array('class'=>'submissionstatus' . $status->teamsubmission->status); 737 } else { 738 $cell2 = new html_table_cell(get_string('nosubmission', 'assign')); 739 if (!$status->submissionsenabled) { 740 $cell2 = new html_table_cell(get_string('noonlinesubmissions', 'assign')); 741 } else { 742 $cell2 = new html_table_cell(get_string('nosubmission', 'assign')); 743 } 744 } 745 $row->cells = array($cell1, $cell2); 746 $t->data[] = $row; 747 } 748 749 // Is locked? 750 if ($status->locked) { 751 $row = new html_table_row(); 752 $cell1 = new html_table_cell(); 753 $cell2 = new html_table_cell(get_string('submissionslocked', 'assign')); 754 $cell2->attributes = array('class'=>'submissionlocked'); 755 $row->cells = array($cell1, $cell2); 756 $t->data[] = $row; 757 } 758 759 // Grading status. 760 $row = new html_table_row(); 761 $cell1 = new html_table_cell(get_string('gradingstatus', 'assign')); 762 763 if ($status->gradingstatus == ASSIGN_GRADING_STATUS_GRADED || 764 $status->gradingstatus == ASSIGN_GRADING_STATUS_NOT_GRADED) { 765 $cell2 = new html_table_cell(get_string($status->gradingstatus, 'assign')); 766 } else { 767 $gradingstatus = 'markingworkflowstate' . $status->gradingstatus; 768 $cell2 = new html_table_cell(get_string($gradingstatus, 'assign')); 769 } 770 if ($status->gradingstatus == ASSIGN_GRADING_STATUS_GRADED || 771 $status->gradingstatus == ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) { 772 $cell2->attributes = array('class' => 'submissiongraded'); 773 } else { 774 $cell2->attributes = array('class' => 'submissionnotgraded'); 775 } 776 $row->cells = array($cell1, $cell2); 777 $t->data[] = $row; 778 779 $submission = $status->teamsubmission ? $status->teamsubmission : $status->submission; 780 $duedate = $status->duedate; 781 if ($duedate > 0) { 782 // Due date. 783 $row = new html_table_row(); 784 $cell1 = new html_table_cell(get_string('duedate', 'assign')); 785 $cell2 = new html_table_cell(userdate($duedate)); 786 $row->cells = array($cell1, $cell2); 787 $t->data[] = $row; 788 789 if ($status->view == assign_submission_status::GRADER_VIEW) { 790 if ($status->cutoffdate) { 791 // Cut off date. 792 $row = new html_table_row(); 793 $cell1 = new html_table_cell(get_string('cutoffdate', 'assign')); 794 $cell2 = new html_table_cell(userdate($status->cutoffdate)); 795 $row->cells = array($cell1, $cell2); 796 $t->data[] = $row; 797 } 798 } 799 800 if ($status->extensionduedate) { 801 // Extension date. 802 $row = new html_table_row(); 803 $cell1 = new html_table_cell(get_string('extensionduedate', 'assign')); 804 $cell2 = new html_table_cell(userdate($status->extensionduedate)); 805 $row->cells = array($cell1, $cell2); 806 $t->data[] = $row; 807 $duedate = $status->extensionduedate; 808 } 809 810 // Time remaining. 811 $row = new html_table_row(); 812 $cell1 = new html_table_cell(get_string('timeremaining', 'assign')); 813 if ($duedate - $time <= 0) { 814 if (!$submission || 815 $submission->status != ASSIGN_SUBMISSION_STATUS_SUBMITTED) { 816 if ($status->submissionsenabled) { 817 $overduestr = get_string('overdue', 'assign', format_time($time - $duedate)); 818 $cell2 = new html_table_cell($overduestr); 819 $cell2->attributes = array('class'=>'overdue'); 820 } else { 821 $cell2 = new html_table_cell(get_string('duedatereached', 'assign')); 822 } 823 } else { 824 if ($submission->timemodified > $duedate) { 825 $latestr = get_string('submittedlate', 826 'assign', 827 format_time($submission->timemodified - $duedate)); 828 $cell2 = new html_table_cell($latestr); 829 $cell2->attributes = array('class'=>'latesubmission'); 830 } else { 831 $earlystr = get_string('submittedearly', 832 'assign', 833 format_time($submission->timemodified - $duedate)); 834 $cell2 = new html_table_cell($earlystr); 835 $cell2->attributes = array('class'=>'earlysubmission'); 836 } 837 } 838 } else { 839 $cell2 = new html_table_cell(format_time($duedate - $time)); 840 } 841 $row->cells = array($cell1, $cell2); 842 $t->data[] = $row; 843 } 844 845 // Show graders whether this submission is editable by students. 846 if ($status->view == assign_submission_status::GRADER_VIEW) { 847 $row = new html_table_row(); 848 $cell1 = new html_table_cell(get_string('editingstatus', 'assign')); 849 if ($status->canedit) { 850 $cell2 = new html_table_cell(get_string('submissioneditable', 'assign')); 851 $cell2->attributes = array('class'=>'submissioneditable'); 852 } else { 853 $cell2 = new html_table_cell(get_string('submissionnoteditable', 'assign')); 854 $cell2->attributes = array('class'=>'submissionnoteditable'); 855 } 856 $row->cells = array($cell1, $cell2); 857 $t->data[] = $row; 858 } 859 860 // Grading criteria preview. 861 if (!empty($status->gradingcontrollerpreview)) { 862 $row = new html_table_row(); 863 $cell1 = new html_table_cell(get_string('gradingmethodpreview', 'assign')); 864 $cell2 = new html_table_cell($status->gradingcontrollerpreview); 865 $row->cells = array($cell1, $cell2); 866 $t->data[] = $row; 867 } 868 869 // Last modified. 870 if ($submission) { 871 $row = new html_table_row(); 872 $cell1 = new html_table_cell(get_string('timemodified', 'assign')); 873 874 if ($submission->status != ASSIGN_SUBMISSION_STATUS_NEW) { 875 $cell2 = new html_table_cell(userdate($submission->timemodified)); 876 } else { 877 $cell2 = new html_table_cell('-'); 878 } 879 880 $row->cells = array($cell1, $cell2); 881 $t->data[] = $row; 882 883 if (!$status->teamsubmission || $status->submissiongroup != false || !$status->preventsubmissionnotingroup) { 884 foreach ($status->submissionplugins as $plugin) { 885 $pluginshowsummary = !$plugin->is_empty($submission) || !$plugin->allow_submissions(); 886 if ($plugin->is_enabled() && 887 $plugin->is_visible() && 888 $plugin->has_user_summary() && 889 $pluginshowsummary 890 ) { 891 892 $row = new html_table_row(); 893 $cell1 = new html_table_cell($plugin->get_name()); 894 $displaymode = assign_submission_plugin_submission::SUMMARY; 895 $pluginsubmission = new assign_submission_plugin_submission($plugin, 896 $submission, 897 $displaymode, 898 $status->coursemoduleid, 899 $status->returnaction, 900 $status->returnparams); 901 $cell2 = new html_table_cell($this->render($pluginsubmission)); 902 $row->cells = array($cell1, $cell2); 903 $t->data[] = $row; 904 } 905 } 906 } 907 } 908 909 $o .= html_writer::table($t); 910 $o .= $this->output->box_end(); 911 912 // Links. 913 if ($status->view == assign_submission_status::STUDENT_VIEW) { 914 if ($status->canedit) { 915 if (!$submission || $submission->status == ASSIGN_SUBMISSION_STATUS_NEW) { 916 $o .= $this->output->box_start('generalbox submissionaction'); 917 $urlparams = array('id' => $status->coursemoduleid, 'action' => 'editsubmission'); 918 $o .= $this->output->single_button(new moodle_url('/mod/assign/view.php', $urlparams), 919 get_string('addsubmission', 'assign'), 'get'); 920 $o .= $this->output->box_start('boxaligncenter submithelp'); 921 $o .= get_string('editsubmission_help', 'assign'); 922 $o .= $this->output->box_end(); 923 $o .= $this->output->box_end(); 924 } else if ($submission->status == ASSIGN_SUBMISSION_STATUS_REOPENED) { 925 $o .= $this->output->box_start('generalbox submissionaction'); 926 $urlparams = array('id' => $status->coursemoduleid, 927 'action' => 'editprevioussubmission', 928 'sesskey'=>sesskey()); 929 $o .= $this->output->single_button(new moodle_url('/mod/assign/view.php', $urlparams), 930 get_string('addnewattemptfromprevious', 'assign'), 'get'); 931 $o .= $this->output->box_start('boxaligncenter submithelp'); 932 $o .= get_string('addnewattemptfromprevious_help', 'assign'); 933 $o .= $this->output->box_end(); 934 $o .= $this->output->box_end(); 935 $o .= $this->output->box_start('generalbox submissionaction'); 936 $urlparams = array('id' => $status->coursemoduleid, 'action' => 'editsubmission'); 937 $o .= $this->output->single_button(new moodle_url('/mod/assign/view.php', $urlparams), 938 get_string('addnewattempt', 'assign'), 'get'); 939 $o .= $this->output->box_start('boxaligncenter submithelp'); 940 $o .= get_string('addnewattempt_help', 'assign'); 941 $o .= $this->output->box_end(); 942 $o .= $this->output->box_end(); 943 } else { 944 $o .= $this->output->box_start('generalbox submissionaction'); 945 $urlparams = array('id' => $status->coursemoduleid, 'action' => 'editsubmission'); 946 $o .= $this->output->single_button(new moodle_url('/mod/assign/view.php', $urlparams), 947 get_string('editsubmission', 'assign'), 'get'); 948 $o .= $this->output->box_start('boxaligncenter submithelp'); 949 $o .= get_string('editsubmission_help', 'assign'); 950 $o .= $this->output->box_end(); 951 $o .= $this->output->box_end(); 952 } 953 } 954 955 if ($status->cansubmit) { 956 $urlparams = array('id' => $status->coursemoduleid, 'action'=>'submit'); 957 $o .= $this->output->box_start('generalbox submissionaction'); 958 $o .= $this->output->single_button(new moodle_url('/mod/assign/view.php', $urlparams), 959 get_string('submitassignment', 'assign'), 'get'); 960 $o .= $this->output->box_start('boxaligncenter submithelp'); 961 $o .= get_string('submitassignment_help', 'assign'); 962 $o .= $this->output->box_end(); 963 $o .= $this->output->box_end(); 964 } 965 } 966 967 $o .= $this->output->container_end(); 968 return $o; 969 } 970 971 /** 972 * Output the attempt history chooser for this assignment 973 * 974 * @param assign_attempt_history_chooser $history 975 * @return string 976 */ 977 public function render_assign_attempt_history_chooser(assign_attempt_history_chooser $history) { 978 $o = ''; 979 980 $context = $history->export_for_template($this); 981 $o .= $this->render_from_template('mod_assign/attempt_history_chooser', $context); 982 983 return $o; 984 } 985 986 /** 987 * Output the attempt history for this assignment 988 * 989 * @param assign_attempt_history $history 990 * @return string 991 */ 992 public function render_assign_attempt_history(assign_attempt_history $history) { 993 $o = ''; 994 995 $submittedstr = get_string('submitted', 'assign'); 996 $gradestr = get_string('grade'); 997 $gradedonstr = get_string('gradedon', 'assign'); 998 $gradedbystr = get_string('gradedby', 'assign'); 999 1000 // Don't show the last one because it is the current submission. 1001 array_pop($history->submissions); 1002 1003 // Show newest to oldest. 1004 $history->submissions = array_reverse($history->submissions); 1005 1006 if (empty($history->submissions)) { 1007 return ''; 1008 } 1009 1010 $containerid = 'attempthistory' . uniqid(); 1011 $o .= $this->output->heading(get_string('attempthistory', 'assign'), 3); 1012 $o .= $this->box_start('attempthistory', $containerid); 1013 1014 foreach ($history->submissions as $i => $submission) { 1015 $grade = null; 1016 foreach ($history->grades as $onegrade) { 1017 if ($onegrade->attemptnumber == $submission->attemptnumber) { 1018 $grade = $onegrade; 1019 break; 1020 } 1021 } 1022 1023 $editbtn = ''; 1024 1025 if ($submission) { 1026 $submissionsummary = userdate($submission->timemodified); 1027 } else { 1028 $submissionsummary = get_string('nosubmission', 'assign'); 1029 } 1030 1031 $attemptsummaryparams = array('attemptnumber'=>$submission->attemptnumber+1, 1032 'submissionsummary'=>$submissionsummary); 1033 $o .= $this->heading(get_string('attemptheading', 'assign', $attemptsummaryparams), 4); 1034 1035 $t = new html_table(); 1036 1037 if ($submission) { 1038 $cell1 = new html_table_cell(get_string('submissionstatus', 'assign')); 1039 $cell2 = new html_table_cell(get_string('submissionstatus_' . $submission->status, 'assign')); 1040 $t->data[] = new html_table_row(array($cell1, $cell2)); 1041 1042 foreach ($history->submissionplugins as $plugin) { 1043 $pluginshowsummary = !$plugin->is_empty($submission) || !$plugin->allow_submissions(); 1044 if ($plugin->is_enabled() && 1045 $plugin->is_visible() && 1046 $plugin->has_user_summary() && 1047 $pluginshowsummary) { 1048 1049 $cell1 = new html_table_cell($plugin->get_name()); 1050 $pluginsubmission = new assign_submission_plugin_submission($plugin, 1051 $submission, 1052 assign_submission_plugin_submission::SUMMARY, 1053 $history->coursemoduleid, 1054 $history->returnaction, 1055 $history->returnparams); 1056 $cell2 = new html_table_cell($this->render($pluginsubmission)); 1057 1058 $t->data[] = new html_table_row(array($cell1, $cell2)); 1059 } 1060 } 1061 } 1062 1063 if ($grade) { 1064 // Heading 'feedback'. 1065 $title = get_string('feedback', 'assign', $i); 1066 $title .= $this->output->spacer(array('width'=>10)); 1067 if ($history->cangrade) { 1068 // Edit previous feedback. 1069 $returnparams = http_build_query($history->returnparams); 1070 $urlparams = array('id' => $history->coursemoduleid, 1071 'rownum'=>$history->rownum, 1072 'useridlistid'=>$history->useridlistid, 1073 'attemptnumber'=>$grade->attemptnumber, 1074 'action'=>'grade', 1075 'returnaction'=>$history->returnaction, 1076 'returnparams'=>$returnparams); 1077 $url = new moodle_url('/mod/assign/view.php', $urlparams); 1078 $icon = new pix_icon('gradefeedback', 1079 get_string('editattemptfeedback', 'assign', $grade->attemptnumber+1), 1080 'mod_assign'); 1081 $title .= $this->output->action_icon($url, $icon); 1082 } 1083 $cell = new html_table_cell($title); 1084 $cell->attributes['class'] = 'feedbacktitle'; 1085 $cell->colspan = 2; 1086 $t->data[] = new html_table_row(array($cell)); 1087 1088 // Grade. 1089 $cell1 = new html_table_cell($gradestr); 1090 $cell2 = $grade->gradefordisplay; 1091 $t->data[] = new html_table_row(array($cell1, $cell2)); 1092 1093 // Graded on. 1094 $cell1 = new html_table_cell($gradedonstr); 1095 $cell2 = new html_table_cell(userdate($grade->timemodified)); 1096 $t->data[] = new html_table_row(array($cell1, $cell2)); 1097 1098 // Graded by. 1099 $cell1 = new html_table_cell($gradedbystr); 1100 $cell2 = new html_table_cell($this->output->user_picture($grade->grader) . 1101 $this->output->spacer(array('width'=>30)) . fullname($grade->grader)); 1102 $t->data[] = new html_table_row(array($cell1, $cell2)); 1103 1104 // Feedback from plugins. 1105 foreach ($history->feedbackplugins as $plugin) { 1106 if ($plugin->is_enabled() && 1107 $plugin->is_visible() && 1108 $plugin->has_user_summary() && 1109 !$plugin->is_empty($grade)) { 1110 1111 $cell1 = new html_table_cell($plugin->get_name()); 1112 $pluginfeedback = new assign_feedback_plugin_feedback( 1113 $plugin, $grade, assign_feedback_plugin_feedback::SUMMARY, $history->coursemoduleid, 1114 $history->returnaction, $history->returnparams 1115 ); 1116 $cell2 = new html_table_cell($this->render($pluginfeedback)); 1117 $t->data[] = new html_table_row(array($cell1, $cell2)); 1118 } 1119 1120 } 1121 1122 } 1123 1124 $o .= html_writer::table($t); 1125 } 1126 $o .= $this->box_end(); 1127 $jsparams = array($containerid); 1128 1129 $this->page->requires->yui_module('moodle-mod_assign-history', 'Y.one("#' . $containerid . '").history'); 1130 1131 return $o; 1132 } 1133 1134 /** 1135 * Render a submission plugin submission 1136 * 1137 * @param assign_submission_plugin_submission $submissionplugin 1138 * @return string 1139 */ 1140 public function render_assign_submission_plugin_submission(assign_submission_plugin_submission $submissionplugin) { 1141 $o = ''; 1142 1143 if ($submissionplugin->view == assign_submission_plugin_submission::SUMMARY) { 1144 $showviewlink = false; 1145 $summary = $submissionplugin->plugin->view_summary($submissionplugin->submission, 1146 $showviewlink); 1147 1148 $classsuffix = $submissionplugin->plugin->get_subtype() . 1149 '_' . 1150 $submissionplugin->plugin->get_type() . 1151 '_' . 1152 $submissionplugin->submission->id; 1153 1154 $o .= $this->output->box_start('boxaligncenter plugincontentsummary summary_' . $classsuffix); 1155 1156 $link = ''; 1157 if ($showviewlink) { 1158 $previewstr = get_string('viewsubmission', 'assign'); 1159 $icon = $this->output->pix_icon('t/preview', $previewstr); 1160 1161 $expandstr = get_string('viewfull', 'assign'); 1162 $options = array('class'=>'expandsummaryicon expand_' . $classsuffix); 1163 $o .= $this->output->pix_icon('t/switch_plus', $expandstr, null, $options); 1164 1165 $jsparams = array($submissionplugin->plugin->get_subtype(), 1166 $submissionplugin->plugin->get_type(), 1167 $submissionplugin->submission->id); 1168 1169 $this->page->requires->js_init_call('M.mod_assign.init_plugin_summary', $jsparams); 1170 1171 $action = 'viewplugin' . $submissionplugin->plugin->get_subtype(); 1172 $returnparams = http_build_query($submissionplugin->returnparams); 1173 $link .= '<noscript>'; 1174 $urlparams = array('id' => $submissionplugin->coursemoduleid, 1175 'sid'=>$submissionplugin->submission->id, 1176 'plugin'=>$submissionplugin->plugin->get_type(), 1177 'action'=>$action, 1178 'returnaction'=>$submissionplugin->returnaction, 1179 'returnparams'=>$returnparams); 1180 $url = new moodle_url('/mod/assign/view.php', $urlparams); 1181 $link .= $this->output->action_link($url, $icon); 1182 $link .= '</noscript>'; 1183 1184 $link .= $this->output->spacer(array('width'=>15)); 1185 } 1186 1187 $o .= $link . $summary; 1188 $o .= $this->output->box_end(); 1189 if ($showviewlink) { 1190 $o .= $this->output->box_start('boxaligncenter hidefull full_' . $classsuffix); 1191 $classes = 'expandsummaryicon contract_' . $classsuffix; 1192 $o .= $this->output->pix_icon('t/switch_minus', 1193 get_string('viewsummary', 'assign'), 1194 null, 1195 array('class'=>$classes)); 1196 $o .= $submissionplugin->plugin->view($submissionplugin->submission); 1197 $o .= $this->output->box_end(); 1198 } 1199 } else if ($submissionplugin->view == assign_submission_plugin_submission::FULL) { 1200 $o .= $this->output->box_start('boxaligncenter submissionfull'); 1201 $o .= $submissionplugin->plugin->view($submissionplugin->submission); 1202 $o .= $this->output->box_end(); 1203 } 1204 1205 return $o; 1206 } 1207 1208 /** 1209 * Render the grading table. 1210 * 1211 * @param assign_grading_table $table 1212 * @return string 1213 */ 1214 public function render_assign_grading_table(assign_grading_table $table) { 1215 $o = ''; 1216 $o .= $this->output->box_start('boxaligncenter gradingtable'); 1217 1218 $this->page->requires->js_init_call('M.mod_assign.init_grading_table', array()); 1219 $this->page->requires->string_for_js('nousersselected', 'assign'); 1220 $this->page->requires->string_for_js('batchoperationconfirmgrantextension', 'assign'); 1221 $this->page->requires->string_for_js('batchoperationconfirmlock', 'assign'); 1222 $this->page->requires->string_for_js('batchoperationconfirmreverttodraft', 'assign'); 1223 $this->page->requires->string_for_js('batchoperationconfirmunlock', 'assign'); 1224 $this->page->requires->string_for_js('batchoperationconfirmaddattempt', 'assign'); 1225 $this->page->requires->string_for_js('batchoperationconfirmdownloadselected', 'assign'); 1226 $this->page->requires->string_for_js('batchoperationconfirmsetmarkingworkflowstate', 'assign'); 1227 $this->page->requires->string_for_js('batchoperationconfirmsetmarkingallocation', 'assign'); 1228 $this->page->requires->string_for_js('editaction', 'assign'); 1229 foreach ($table->plugingradingbatchoperations as $plugin => $operations) { 1230 foreach ($operations as $operation => $description) { 1231 $this->page->requires->string_for_js('batchoperationconfirm' . $operation, 1232 'assignfeedback_' . $plugin); 1233 } 1234 } 1235 $o .= $this->flexible_table($table, $table->get_rows_per_page(), true); 1236 $o .= $this->output->box_end(); 1237 1238 return $o; 1239 } 1240 1241 /** 1242 * Render a feedback plugin feedback 1243 * 1244 * @param assign_feedback_plugin_feedback $feedbackplugin 1245 * @return string 1246 */ 1247 public function render_assign_feedback_plugin_feedback(assign_feedback_plugin_feedback $feedbackplugin) { 1248 $o = ''; 1249 1250 if ($feedbackplugin->view == assign_feedback_plugin_feedback::SUMMARY) { 1251 $showviewlink = false; 1252 $summary = $feedbackplugin->plugin->view_summary($feedbackplugin->grade, $showviewlink); 1253 1254 $classsuffix = $feedbackplugin->plugin->get_subtype() . 1255 '_' . 1256 $feedbackplugin->plugin->get_type() . 1257 '_' . 1258 $feedbackplugin->grade->id; 1259 $o .= $this->output->box_start('boxaligncenter plugincontentsummary summary_' . $classsuffix); 1260 1261 $link = ''; 1262 if ($showviewlink) { 1263 $previewstr = get_string('viewfeedback', 'assign'); 1264 $icon = $this->output->pix_icon('t/preview', $previewstr); 1265 1266 $expandstr = get_string('viewfull', 'assign'); 1267 $options = array('class'=>'expandsummaryicon expand_' . $classsuffix); 1268 $o .= $this->output->pix_icon('t/switch_plus', $expandstr, null, $options); 1269 1270 $jsparams = array($feedbackplugin->plugin->get_subtype(), 1271 $feedbackplugin->plugin->get_type(), 1272 $feedbackplugin->grade->id); 1273 $this->page->requires->js_init_call('M.mod_assign.init_plugin_summary', $jsparams); 1274 1275 $urlparams = array('id' => $feedbackplugin->coursemoduleid, 1276 'gid'=>$feedbackplugin->grade->id, 1277 'plugin'=>$feedbackplugin->plugin->get_type(), 1278 'action'=>'viewplugin' . $feedbackplugin->plugin->get_subtype(), 1279 'returnaction'=>$feedbackplugin->returnaction, 1280 'returnparams'=>http_build_query($feedbackplugin->returnparams)); 1281 $url = new moodle_url('/mod/assign/view.php', $urlparams); 1282 $link .= '<noscript>'; 1283 $link .= $this->output->action_link($url, $icon); 1284 $link .= '</noscript>'; 1285 1286 $link .= $this->output->spacer(array('width'=>15)); 1287 } 1288 1289 $o .= $link . $summary; 1290 $o .= $this->output->box_end(); 1291 if ($showviewlink) { 1292 $o .= $this->output->box_start('boxaligncenter hidefull full_' . $classsuffix); 1293 $classes = 'expandsummaryicon contract_' . $classsuffix; 1294 $o .= $this->output->pix_icon('t/switch_minus', 1295 get_string('viewsummary', 'assign'), 1296 null, 1297 array('class'=>$classes)); 1298 $o .= $feedbackplugin->plugin->view($feedbackplugin->grade); 1299 $o .= $this->output->box_end(); 1300 } 1301 } else if ($feedbackplugin->view == assign_feedback_plugin_feedback::FULL) { 1302 $o .= $this->output->box_start('boxaligncenter feedbackfull'); 1303 $o .= $feedbackplugin->plugin->view($feedbackplugin->grade); 1304 $o .= $this->output->box_end(); 1305 } 1306 1307 return $o; 1308 } 1309 1310 /** 1311 * Render a course index summary 1312 * 1313 * @param assign_course_index_summary $indexsummary 1314 * @return string 1315 */ 1316 public function render_assign_course_index_summary(assign_course_index_summary $indexsummary) { 1317 $o = ''; 1318 1319 $strplural = get_string('modulenameplural', 'assign'); 1320 $strsectionname = $indexsummary->courseformatname; 1321 $strduedate = get_string('duedate', 'assign'); 1322 $strsubmission = get_string('submission', 'assign'); 1323 $strgrade = get_string('grade'); 1324 1325 $table = new html_table(); 1326 if ($indexsummary->usesections) { 1327 $table->head = array ($strsectionname, $strplural, $strduedate, $strsubmission, $strgrade); 1328 $table->align = array ('left', 'left', 'center', 'right', 'right'); 1329 } else { 1330 $table->head = array ($strplural, $strduedate, $strsubmission, $strgrade); 1331 $table->align = array ('left', 'left', 'center', 'right'); 1332 } 1333 $table->data = array(); 1334 1335 $currentsection = ''; 1336 foreach ($indexsummary->assignments as $info) { 1337 $params = array('id' => $info['cmid']); 1338 $link = html_writer::link(new moodle_url('/mod/assign/view.php', $params), 1339 $info['cmname']); 1340 $due = $info['timedue'] ? userdate($info['timedue']) : '-'; 1341 1342 $printsection = ''; 1343 if ($indexsummary->usesections) { 1344 if ($info['sectionname'] !== $currentsection) { 1345 if ($info['sectionname']) { 1346 $printsection = $info['sectionname']; 1347 } 1348 if ($currentsection !== '') { 1349 $table->data[] = 'hr'; 1350 } 1351 $currentsection = $info['sectionname']; 1352 } 1353 } 1354 1355 if ($indexsummary->usesections) { 1356 $row = array($printsection, $link, $due, $info['submissioninfo'], $info['gradeinfo']); 1357 } else { 1358 $row = array($link, $due, $info['submissioninfo'], $info['gradeinfo']); 1359 } 1360 $table->data[] = $row; 1361 } 1362 1363 $o .= html_writer::table($table); 1364 1365 return $o; 1366 } 1367 1368 1369 1370 /** 1371 * Internal function - creates htmls structure suitable for YUI tree. 1372 * 1373 * @param assign_files $tree 1374 * @param array $dir 1375 * @return string 1376 */ 1377 protected function htmllize_tree(assign_files $tree, $dir) { 1378 global $CFG; 1379 $yuiconfig = array(); 1380 $yuiconfig['type'] = 'html'; 1381 1382 if (empty($dir['subdirs']) and empty($dir['files'])) { 1383 return ''; 1384 } 1385 1386 $result = '<ul>'; 1387 foreach ($dir['subdirs'] as $subdir) { 1388 $image = $this->output->pix_icon(file_folder_icon(), 1389 $subdir['dirname'], 1390 'moodle', 1391 array('class'=>'icon')); 1392 $result .= '<li yuiConfig=\'' . json_encode($yuiconfig) . '\'>' . 1393 '<div>' . $image . ' ' . s($subdir['dirname']) . '</div> ' . 1394 $this->htmllize_tree($tree, $subdir) . 1395 '</li>'; 1396 } 1397 1398 foreach ($dir['files'] as $file) { 1399 $filename = $file->get_filename(); 1400 if ($CFG->enableplagiarism) { 1401 require_once($CFG->libdir.'/plagiarismlib.php'); 1402 $plagiarismlinks = plagiarism_get_links(array('userid'=>$file->get_userid(), 1403 'file'=>$file, 1404 'cmid'=>$tree->cm->id, 1405 'course'=>$tree->course)); 1406 } else { 1407 $plagiarismlinks = ''; 1408 } 1409 $image = $this->output->pix_icon(file_file_icon($file), 1410 $filename, 1411 'moodle', 1412 array('class'=>'icon')); 1413 $result .= '<li yuiConfig=\'' . json_encode($yuiconfig) . '\'>' . 1414 '<div>' . $image . ' ' . 1415 $file->fileurl . ' ' . 1416 $plagiarismlinks . 1417 $file->portfoliobutton . '</div>' . 1418 '</li>'; 1419 } 1420 1421 $result .= '</ul>'; 1422 1423 return $result; 1424 } 1425 1426 /** 1427 * Helper method dealing with the fact we can not just fetch the output of flexible_table 1428 * 1429 * @param flexible_table $table The table to render 1430 * @param int $rowsperpage How many assignments to render in a page 1431 * @param bool $displaylinks - Whether to render links in the table 1432 * (e.g. downloads would not enable this) 1433 * @return string HTML 1434 */ 1435 protected function flexible_table(flexible_table $table, $rowsperpage, $displaylinks) { 1436 1437 $o = ''; 1438 ob_start(); 1439 $table->out($rowsperpage, $displaylinks); 1440 $o = ob_get_contents(); 1441 ob_end_clean(); 1442 1443 return $o; 1444 } 1445 1446 /** 1447 * Helper method dealing with the fact we can not just fetch the output of moodleforms 1448 * 1449 * @param moodleform $mform 1450 * @return string HTML 1451 */ 1452 protected function moodleform(moodleform $mform) { 1453 1454 $o = ''; 1455 ob_start(); 1456 $mform->display(); 1457 $o = ob_get_contents(); 1458 ob_end_clean(); 1459 1460 return $o; 1461 } 1462 1463 /** 1464 * Defer to template.. 1465 * 1466 * @param grading_app $app - All the data to render the grading app. 1467 */ 1468 public function render_grading_app(grading_app $app) { 1469 $context = $app->export_for_template($this); 1470 return $this->render_from_template('mod_assign/grading_app', $context); 1471 } 1472 } 1473
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |