/** * @see parent::validate_raw_record() */ protected function validate_raw_record(stdClass $record) { if ($record->weight != 1) { throw new coding_exception('Invalid weight of the reference example submission assessment'); } parent::validate_raw_record($record); }
/** * Renders the overall feedback for the author of the submission * * @param workshop_assessment $assessment * @return string HTML */ protected function overall_feedback(workshop_assessment $assessment) { $content = $assessment->get_overall_feedback_content(); if ($content === false) { return ''; } $o = ''; if (!is_null($content)) { $o .= $this->output->container($content, 'content'); } $attachments = $assessment->get_overall_feedback_attachments(); if (!empty($attachments)) { $o .= $this->output->container_start('attachments'); $images = ''; $files = ''; foreach ($attachments as $attachment) { $icon = $this->output->pix_icon(file_file_icon($attachment), get_mimetype_description($attachment), 'moodle', array('class' => 'icon')); $link = html_writer::link($attachment->fileurl, $icon . ' ' . substr($attachment->filepath . $attachment->filename, 1)); if (file_mimetype_in_typegroup($attachment->mimetype, 'web_image')) { $preview = html_writer::empty_tag('img', array('src' => $attachment->previewurl, 'alt' => '', 'class' => 'preview')); $preview = html_writer::tag('a', $preview, array('href' => $attachment->fileurl)); $images .= $this->output->container($preview); } else { $files .= html_writer::tag('li', $link, array('class' => $attachment->mimetype)); } } if ($images) { $images = $this->output->container($images, 'images'); } if ($files) { $files = html_writer::tag('ul', $files, array('class' => 'files')); } $o .= $images . $files; $o .= $this->output->container_end(); } if ($o === '') { return ''; } $o = $this->output->box($o, 'overallfeedback'); $o = print_collapsible_region($o, 'overall-feedback-wrapper', uniqid('workshop-overall-feedback'), get_string('overallfeedback', 'workshop'), '', false, true); return $o; }