MDL-27550 workshop: assessments are now displayed via proper rendering subsystem
AMOS BEGIN MOV [assessmentbyknown,mod_workshop],[assessmentbyfullname,mod_workshop] AMOS END
This commit is contained in:
+23
-14
@@ -182,24 +182,33 @@ if (trim($workshop->instructreviewers)) {
|
||||
print_collapsible_region_end();
|
||||
}
|
||||
|
||||
// extend the current assessment record with user details
|
||||
$assessment = $workshop->get_assessment_by_id($assessment->id);
|
||||
|
||||
if ($isreviewer) {
|
||||
echo $output->heading(get_string('assessmentbyyourself', 'workshop'), 2);
|
||||
} elseif (has_capability('mod/workshop:viewreviewernames', $workshop->context)) {
|
||||
$assessment = $workshop->get_assessment_by_id($assessment->id); // extend the current record with user details
|
||||
$reviewer = new stdclass();
|
||||
$reviewer->firstname = $assessment->reviewerfirstname;
|
||||
$reviewer->lastname = $assessment->reviewerlastname;
|
||||
echo $output->heading(get_string('assessmentbyknown', 'workshop', fullname($reviewer)), 2);
|
||||
$options = array(
|
||||
'showreviewer' => true,
|
||||
'showauthor' => has_capability('mod/workshop:viewauthornames', $workshop->context),
|
||||
'showform' => $assessmenteditable or !is_null($assessment->grade),
|
||||
'showweight' => true,
|
||||
);
|
||||
$assessment = $workshop->prepare_assessment($assessment, $mform, $options);
|
||||
$assessment->title = get_string('assessmentbyyourself', 'workshop');
|
||||
echo $output->render($assessment);
|
||||
|
||||
} else {
|
||||
echo $output->heading(get_string('assessmentbyunknown', 'workshop'), 2);
|
||||
$options = array(
|
||||
'showreviewer' => has_capability('mod/workshop:viewreviewernames', $workshop->context),
|
||||
'showauthor' => has_capability('mod/workshop:viewauthornames', $workshop->context),
|
||||
'showform' => $assessmenteditable or !is_null($assessment->grade),
|
||||
'showweight' => true,
|
||||
);
|
||||
$assessment = $workshop->prepare_assessment($assessment, $mform, $options);
|
||||
echo $output->render($assessment);
|
||||
}
|
||||
|
||||
if ($mform) {
|
||||
$mform->display();
|
||||
} else {
|
||||
echo $output->heading(get_string('notassessed', 'workshop'));
|
||||
}
|
||||
if ($canoverridegrades) {
|
||||
if (!$assessmenteditable and $canoverridegrades) {
|
||||
$feedbackform->display();
|
||||
}
|
||||
|
||||
echo $output->footer();
|
||||
|
||||
@@ -56,7 +56,7 @@ if ($isreviewer or $canmanage) {
|
||||
}
|
||||
|
||||
// only the reviewer is allowed to modify the assessment
|
||||
if ($canmanage or ($isreviewer and $workshop->assessing_examples_allowed())) {
|
||||
if (($canmanage and $assessment->weight == 1) or ($isreviewer and $workshop->assessing_examples_allowed())) {
|
||||
$assessmenteditable = true;
|
||||
} else {
|
||||
$assessmenteditable = false;
|
||||
@@ -119,17 +119,40 @@ if (trim($workshop->instructreviewers)) {
|
||||
print_collapsible_region_end();
|
||||
}
|
||||
|
||||
if ($canmanage) {
|
||||
echo $output->heading(get_string('assessmentreference', 'workshop'), 2);
|
||||
} elseif ($isreviewer) {
|
||||
echo $output->heading(get_string('assessmentbyyourself', 'workshop'), 2);
|
||||
} else {
|
||||
$assessment = $workshop->get_assessment_by_id($assessment->id); // extend the current record with user details
|
||||
$reviewer = new stdclass();
|
||||
$reviewer->firstname = $assessment->reviewerfirstname;
|
||||
$reviewer->lastname = $assessment->reviewerlastname;
|
||||
echo $output->heading(get_string('assessmentbyknown', 'workshop', fullname($reviewer)), 2);
|
||||
// extend the current assessment record with user details
|
||||
$assessment = $workshop->get_assessment_by_id($assessment->id);
|
||||
|
||||
if ($canmanage and $assessment->weight == 1) {
|
||||
$options = array(
|
||||
'showreviewer' => false,
|
||||
'showauthor' => false,
|
||||
'showform' => true,
|
||||
'showweight' => false,
|
||||
);
|
||||
$assessment = $workshop->prepare_assessment($assessment, $mform, $options);
|
||||
$assessment->title = get_string('assessmentreference', 'workshop');
|
||||
echo $output->render($assessment);
|
||||
|
||||
} else if ($isreviewer) {
|
||||
$options = array(
|
||||
'showreviewer' => true,
|
||||
'showauthor' => false,
|
||||
'showform' => true,
|
||||
'showweight' => false,
|
||||
);
|
||||
$assessment = $workshop->prepare_assessment($assessment, $mform, $options);
|
||||
$assessment->title = get_string('assessmentbyyourself', 'workshop');
|
||||
echo $output->render($assessment);
|
||||
|
||||
} else if ($canmanage) {
|
||||
$options = array(
|
||||
'showreviewer' => true,
|
||||
'showauthor' => false,
|
||||
'showform' => true,
|
||||
'showweight' => false,
|
||||
);
|
||||
$assessment = $workshop->prepare_assessment($assessment, $mform, $options);
|
||||
echo $output->render($assessment);
|
||||
}
|
||||
|
||||
$mform->display();
|
||||
echo $output->footer();
|
||||
|
||||
+34
-22
@@ -78,33 +78,45 @@ echo $output->heading(get_string('assessedexample', 'workshop'), 2);
|
||||
|
||||
echo $output->render($workshop->prepare_example_submission($example));
|
||||
|
||||
// if the reference assessment is available, display it
|
||||
if (!empty($mformreference)) {
|
||||
echo $output->heading(get_string('assessmentreference', 'workshop'), 2);
|
||||
$a = new stdclass();
|
||||
$a->received = $workshop->real_grade($reference->grade);
|
||||
$a->max = $workshop->real_grade(100);
|
||||
echo $output->heading(get_string('gradeinfo', 'workshop' , $a), 3);
|
||||
$mformreference->display();
|
||||
$options = array(
|
||||
'showreviewer' => false,
|
||||
'showauthor' => false,
|
||||
'showform' => true,
|
||||
'showweight' => false,
|
||||
);
|
||||
$reference = $workshop->prepare_assessment($reference, $mformreference, $options);
|
||||
$reference->title = get_string('assessmentreference', 'workshop');
|
||||
echo $output->render($reference);
|
||||
}
|
||||
|
||||
if ($isreviewer) {
|
||||
echo $output->heading(get_string('assessmentbyyourself', 'workshop'), 2);
|
||||
$options = array(
|
||||
'showreviewer' => true,
|
||||
'showauthor' => false,
|
||||
'showform' => true,
|
||||
'showweight' => false,
|
||||
);
|
||||
$assessment = $workshop->prepare_assessment($assessment, $mformassessment, $options);
|
||||
$assessment->title = get_string('assessmentbyyourself', 'workshop');
|
||||
if ($workshop->assessing_examples_allowed()) {
|
||||
$assessment->add_action(
|
||||
new moodle_url($workshop->exsubmission_url($example->id), array('assess' => 'on', 'sesskey' => sesskey())),
|
||||
get_string('reassess', 'workshop')
|
||||
);
|
||||
}
|
||||
echo $output->render($assessment);
|
||||
|
||||
} elseif ($canmanage) {
|
||||
$reviewer = new stdclass();
|
||||
$reviewer->firstname = $assessment->reviewerfirstname;
|
||||
$reviewer->lastname = $assessment->reviewerlastname;
|
||||
echo $output->heading(get_string('assessmentbyknown', 'workshop', fullname($reviewer)), 2);
|
||||
$options = array(
|
||||
'showreviewer' => true,
|
||||
'showauthor' => false,
|
||||
'showform' => true,
|
||||
'showweight' => false,
|
||||
);
|
||||
$assessment = $workshop->prepare_assessment($assessment, $mformassessment, $options);
|
||||
echo $output->render($assessment);
|
||||
}
|
||||
$a = new stdclass();
|
||||
$a->received = $workshop->real_grade($assessment->grade);
|
||||
$a->max = $workshop->real_grade(100);
|
||||
echo $output->heading(get_string('gradeinfo', 'workshop' , $a), 3);
|
||||
$mformassessment->display();
|
||||
echo $output->container_start('buttonsbar');
|
||||
if ($isreviewer and $workshop->assessing_examples_allowed()) {
|
||||
$aurl = new moodle_url($workshop->exsubmission_url($example->id), array('assess' => 'on', 'sesskey' => sesskey()));
|
||||
echo $output->single_button($aurl, get_string('reassess', 'workshop'), 'get');
|
||||
}
|
||||
echo $output->container_end(); // buttonsbar
|
||||
|
||||
echo $output->footer();
|
||||
|
||||
@@ -43,9 +43,10 @@ $string['assessedexample'] = 'Assessed example submission';
|
||||
$string['assessedsubmission'] = 'Assessed submission';
|
||||
$string['assessingexample'] = 'Assessing example submission';
|
||||
$string['assessingsubmission'] = 'Assessing submission';
|
||||
$string['assessmentbyknown'] = 'Assessment by {$a}';
|
||||
$string['assessmentbyunknown'] = 'Assessment';
|
||||
$string['assessmentbyyourself'] = 'Assessment by yourself';
|
||||
$string['assessment'] = 'Assessment';
|
||||
$string['assessmentby'] = 'by <a href="{$a->url}">{$a->name}</a>';
|
||||
$string['assessmentbyfullname'] = 'Assessment by {$a}';
|
||||
$string['assessmentbyyourself'] = 'Your assessment';
|
||||
$string['assessmentdeleted'] = 'Assessment deallocated';
|
||||
$string['assessmentend'] = 'Deadline for assessment';
|
||||
$string['assessmentenddatetime'] = 'Assessment deadline: {$a->daydatetime} ({$a->distanceday})';
|
||||
|
||||
@@ -864,12 +864,12 @@ function workshop_print_recent_mod_activity($activity, $courseid, $detail, $modn
|
||||
$url = new moodle_url('/user/view.php', array('id'=>$activity->user->id, 'course'=>$courseid));
|
||||
$name = fullname($activity->user);
|
||||
$link = html_writer::link($url, $name);
|
||||
echo get_string('assessmentbyknown', 'workshop', $link);
|
||||
echo get_string('assessmentbyfullname', 'workshop', $link);
|
||||
echo ' - '.userdate($activity->timestamp);
|
||||
echo html_writer::end_tag('div');
|
||||
} else {
|
||||
echo html_writer::start_tag('div', array('class'=>'anonymous'));
|
||||
echo get_string('assessmentbyunknown', 'workshop');
|
||||
echo get_string('assessment', 'workshop');
|
||||
echo ' - '.userdate($activity->timestamp);
|
||||
echo html_writer::end_tag('div');
|
||||
}
|
||||
|
||||
+179
-24
@@ -706,6 +706,44 @@ class workshop {
|
||||
return $summary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares renderable assessment component
|
||||
*
|
||||
* The $options array supports the following keys:
|
||||
* showauthor - should the author user info be available for the renderer
|
||||
* showreviewer - should the reviewer user info be available for the renderer
|
||||
* showform - show the assessment form if it is available
|
||||
*
|
||||
* @param stdClass $record as returned by eg {@link self::get_assessment_by_id()}
|
||||
* @param workshop_assessment_form|null $form as returned by {@link workshop_strategy::get_assessment_form()}
|
||||
* @param array $options
|
||||
* @return workshop_assessment
|
||||
*/
|
||||
public function prepare_assessment(stdClass $record, $form, array $options = array()) {
|
||||
|
||||
$assessment = new workshop_assessment($record, $options);
|
||||
$assessment->url = $this->assess_url($record->id);
|
||||
$assessment->maxgrade = $this->real_grade(100);
|
||||
|
||||
if (!empty($options['showform']) and !($form instanceof workshop_assessment_form)) {
|
||||
debugging('Not a valid instance of workshop_assessment_form supplied', DEBUG_DEVELOPER);
|
||||
}
|
||||
|
||||
if (!empty($options['showform']) and ($form instanceof workshop_assessment_form)) {
|
||||
$assessment->form = $form;
|
||||
}
|
||||
|
||||
if (empty($options['showweight'])) {
|
||||
$assessment->weight = null;
|
||||
}
|
||||
|
||||
if (!is_null($record->grade)) {
|
||||
$assessment->realgrade = $this->real_grade($record->grade);
|
||||
}
|
||||
|
||||
return $assessment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the submission and all relevant data
|
||||
*
|
||||
@@ -731,17 +769,18 @@ class workshop {
|
||||
public function get_all_assessments() {
|
||||
global $DB;
|
||||
|
||||
$sql = 'SELECT a.id, a.submissionid, a.reviewerid, a.timecreated, a.timemodified,
|
||||
$reviewerfields = user_picture::fields('reviewer', null, 'revieweridx', 'reviewer');
|
||||
$authorfields = user_picture::fields('author', null, 'authorid', 'author');
|
||||
$sql = "SELECT a.id, a.submissionid, a.reviewerid, a.timecreated, a.timemodified,
|
||||
a.grade, a.gradinggrade, a.gradinggradeover, a.gradinggradeoverby,
|
||||
reviewer.id AS reviewerid,reviewer.firstname AS reviewerfirstname,reviewer.lastname as reviewerlastname,
|
||||
s.title,
|
||||
author.id AS authorid, author.firstname AS authorfirstname,author.lastname AS authorlastname
|
||||
$reviewerfields, $authorfields,
|
||||
s.title
|
||||
FROM {workshop_assessments} a
|
||||
INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id)
|
||||
INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id)
|
||||
INNER JOIN {user} author ON (s.authorid = author.id)
|
||||
WHERE s.workshopid = :workshopid AND s.example = 0
|
||||
ORDER BY reviewer.lastname, reviewer.firstname';
|
||||
ORDER BY reviewer.lastname, reviewer.firstname";
|
||||
$params = array('workshopid' => $this->id);
|
||||
|
||||
return $DB->get_records_sql($sql, $params);
|
||||
@@ -756,15 +795,14 @@ class workshop {
|
||||
public function get_assessment_by_id($id) {
|
||||
global $DB;
|
||||
|
||||
$sql = 'SELECT a.*,
|
||||
reviewer.id AS reviewerid,reviewer.firstname AS reviewerfirstname,reviewer.lastname as reviewerlastname,
|
||||
s.title,
|
||||
author.id AS authorid, author.firstname AS authorfirstname,author.lastname as authorlastname
|
||||
$reviewerfields = user_picture::fields('reviewer', null, 'revieweridx', 'reviewer');
|
||||
$authorfields = user_picture::fields('author', null, 'authorid', 'author');
|
||||
$sql = "SELECT a.*, s.title, $reviewerfields, $authorfields
|
||||
FROM {workshop_assessments} a
|
||||
INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id)
|
||||
INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id)
|
||||
INNER JOIN {user} author ON (s.authorid = author.id)
|
||||
WHERE a.id = :id AND s.workshopid = :workshopid';
|
||||
WHERE a.id = :id AND s.workshopid = :workshopid";
|
||||
$params = array('id' => $id, 'workshopid' => $this->id);
|
||||
|
||||
return $DB->get_record_sql($sql, $params, MUST_EXIST);
|
||||
@@ -780,15 +818,14 @@ class workshop {
|
||||
public function get_assessment_of_submission_by_user($submissionid, $reviewerid) {
|
||||
global $DB;
|
||||
|
||||
$sql = 'SELECT a.*,
|
||||
reviewer.id AS reviewerid,reviewer.firstname AS reviewerfirstname,reviewer.lastname as reviewerlastname,
|
||||
s.title,
|
||||
author.id AS authorid, author.firstname AS authorfirstname,author.lastname as authorlastname
|
||||
$reviewerfields = user_picture::fields('reviewer', null, 'revieweridx', 'reviewer');
|
||||
$authorfields = user_picture::fields('author', null, 'authorid', 'author');
|
||||
$sql = "SELECT a.*, s.title, $reviewerfields, $authorfields
|
||||
FROM {workshop_assessments} a
|
||||
INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id)
|
||||
INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id AND s.example = 0)
|
||||
INNER JOIN {user} author ON (s.authorid = author.id)
|
||||
WHERE s.id = :sid AND reviewer.id = :rid AND s.workshopid = :workshopid';
|
||||
WHERE s.id = :sid AND reviewer.id = :rid AND s.workshopid = :workshopid";
|
||||
$params = array('sid' => $submissionid, 'rid' => $reviewerid, 'workshopid' => $this->id);
|
||||
|
||||
return $DB->get_record_sql($sql, $params, IGNORE_MISSING);
|
||||
@@ -803,12 +840,13 @@ class workshop {
|
||||
public function get_assessments_of_submission($submissionid) {
|
||||
global $DB;
|
||||
|
||||
$sql = 'SELECT a.*,
|
||||
reviewer.id AS reviewerid,reviewer.firstname AS reviewerfirstname,reviewer.lastname AS reviewerlastname
|
||||
$reviewerfields = user_picture::fields('reviewer', null, 'revieweridx', 'reviewer');
|
||||
$sql = "SELECT a.*, s.title, $reviewerfields
|
||||
FROM {workshop_assessments} a
|
||||
INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id)
|
||||
INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id)
|
||||
WHERE s.example = 0 AND s.id = :submissionid AND s.workshopid = :workshopid';
|
||||
WHERE s.example = 0 AND s.id = :submissionid AND s.workshopid = :workshopid
|
||||
ORDER BY reviewer.lastname, reviewer.firstname, reviewer.id";
|
||||
$params = array('submissionid' => $submissionid, 'workshopid' => $this->id);
|
||||
|
||||
return $DB->get_records_sql($sql, $params);
|
||||
@@ -823,17 +861,16 @@ class workshop {
|
||||
public function get_assessments_by_reviewer($reviewerid) {
|
||||
global $DB;
|
||||
|
||||
$sql = 'SELECT a.*,
|
||||
reviewer.id AS reviewerid,reviewer.firstname AS reviewerfirstname,reviewer.lastname AS reviewerlastname,
|
||||
$reviewerfields = user_picture::fields('reviewer', null, 'revieweridx', 'reviewer');
|
||||
$authorfields = user_picture::fields('author', null, 'authorid', 'author');
|
||||
$sql = "SELECT a.*, $reviewerfields, $authorfields,
|
||||
s.id AS submissionid, s.title AS submissiontitle, s.timecreated AS submissioncreated,
|
||||
s.timemodified AS submissionmodified,
|
||||
author.id AS authorid, author.firstname AS authorfirstname,author.lastname AS authorlastname,
|
||||
author.picture AS authorpicture, author.imagealt AS authorimagealt, author.email AS authoremail
|
||||
s.timemodified AS submissionmodified
|
||||
FROM {workshop_assessments} a
|
||||
INNER JOIN {user} reviewer ON (a.reviewerid = reviewer.id)
|
||||
INNER JOIN {workshop_submissions} s ON (a.submissionid = s.id)
|
||||
INNER JOIN {user} author ON (s.authorid = author.id)
|
||||
WHERE s.example = 0 AND reviewer.id = :reviewerid AND s.workshopid = :workshopid';
|
||||
WHERE s.example = 0 AND reviewer.id = :reviewerid AND s.workshopid = :workshopid";
|
||||
$params = array('reviewerid' => $reviewerid, 'workshopid' => $this->id);
|
||||
|
||||
return $DB->get_records_sql($sql, $params);
|
||||
@@ -2620,6 +2657,124 @@ class workshop_example_submission extends workshop_example_submission_summary im
|
||||
protected $fields = array('id', 'title', 'content', 'contentformat', 'contenttrust', 'attachment');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Common base class for assessments rendering
|
||||
*
|
||||
* Subclasses of this class convert raw assessment record from
|
||||
* workshop_assessments table (as returned by {@see workshop::get_assessment_by_id()}
|
||||
* for example) into renderable objects.
|
||||
*/
|
||||
abstract class workshop_assessment_base {
|
||||
|
||||
/** @var string the optional title of the assessment */
|
||||
public $title = '';
|
||||
|
||||
/** @var workshop_assessment_form $form as returned by {@link workshop_strategy::get_assessment_form()} */
|
||||
public $form;
|
||||
|
||||
/** @var moodle_url */
|
||||
public $url;
|
||||
|
||||
/** @var float|null the real received grade */
|
||||
public $realgrade = null;
|
||||
|
||||
/** @var float the real maximum grade */
|
||||
public $maxgrade;
|
||||
|
||||
/** @var stdClass|null reviewer user info */
|
||||
public $reviewer = null;
|
||||
|
||||
/** @var stdClass|null assessed submission's author user info */
|
||||
public $author = null;
|
||||
|
||||
/** @var array of actions */
|
||||
public $actions = array();
|
||||
|
||||
/* @var array of columns that are assigned as properties */
|
||||
protected $fields = array();
|
||||
|
||||
/**
|
||||
* Copies the properties of the given database record into properties of $this instance
|
||||
*
|
||||
* The $options keys are: showreviewer, showauthor
|
||||
* @param stdClass $assessment full record
|
||||
* @param array $options additional properties
|
||||
*/
|
||||
public function __construct(stdClass $record, array $options = array()) {
|
||||
|
||||
foreach ($this->fields as $field) {
|
||||
if (!property_exists($record, $field)) {
|
||||
throw new coding_exception('Assessment record must provide public property ' . $field);
|
||||
}
|
||||
if (!property_exists($this, $field)) {
|
||||
throw new coding_exception('Renderable component must accept public property ' . $field);
|
||||
}
|
||||
$this->{$field} = $record->{$field};
|
||||
}
|
||||
|
||||
if (!empty($options['showreviewer'])) {
|
||||
$this->reviewer = user_picture::unalias($record, null, 'revieweridx', 'reviewer');
|
||||
}
|
||||
|
||||
if (!empty($options['showauthor'])) {
|
||||
$this->author = user_picture::unalias($record, null, 'authorid', 'author');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new action
|
||||
*
|
||||
* @param moodle_url $url action URL
|
||||
* @param string $label action label
|
||||
* @param string $method get|post
|
||||
*/
|
||||
public function add_action(moodle_url $url, $label, $method = 'get') {
|
||||
|
||||
$action = new stdClass();
|
||||
$action->url = $url;
|
||||
$action->label = $label;
|
||||
$action->method = $method;
|
||||
|
||||
$this->actions[] = $action;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Represents a rendarable full assessment
|
||||
*/
|
||||
class workshop_assessment extends workshop_assessment_base implements renderable {
|
||||
|
||||
/** @var int */
|
||||
public $id;
|
||||
|
||||
/** @var int */
|
||||
public $submissionid;
|
||||
|
||||
/** @var int */
|
||||
public $weight;
|
||||
|
||||
/** @var int */
|
||||
public $timecreated;
|
||||
|
||||
/** @var int */
|
||||
public $timemodified;
|
||||
|
||||
/** @var float */
|
||||
public $grade;
|
||||
|
||||
/** @var float */
|
||||
public $gradinggrade;
|
||||
|
||||
/** @var float */
|
||||
public $gradinggradeover;
|
||||
|
||||
/** @var array */
|
||||
protected $fields = array('id', 'submissionid', 'weight', 'timecreated',
|
||||
'timemodified', 'grade', 'gradinggrade', 'gradinggradeover');
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderable message to be displayed to the user
|
||||
*
|
||||
|
||||
@@ -515,6 +515,88 @@ class mod_workshop_renderer extends plugin_renderer_base {
|
||||
return $o;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the full assessment
|
||||
*
|
||||
* @param workshop_assessment $assessment
|
||||
* @return string HTML
|
||||
*/
|
||||
protected function render_workshop_assessment(workshop_assessment $assessment) {
|
||||
|
||||
$o = ''; // output HTML code
|
||||
$anonymous = is_null($assessment->reviewer);
|
||||
$classes = 'assessment-full';
|
||||
if ($anonymous) {
|
||||
$classes .= ' anonymous';
|
||||
}
|
||||
|
||||
$o .= $this->output->container_start($classes);
|
||||
$o .= $this->output->container_start('header');
|
||||
|
||||
if (!empty($assessment->title)) {
|
||||
$o .= $this->output->container(s($assessment->title), 'title');
|
||||
} else {
|
||||
$o .= $this->output->container(get_string('assessment', 'workshop'), 'title');
|
||||
}
|
||||
|
||||
if (!$anonymous) {
|
||||
$reviewer = $assessment->reviewer;
|
||||
$userpic = $this->output->user_picture($reviewer, array('courseid' => $this->page->course->id, 'size' => 32));
|
||||
|
||||
$userurl = new moodle_url('/user/view.php',
|
||||
array('id' => $reviewer->id, 'course' => $this->page->course->id));
|
||||
$a = new stdClass();
|
||||
$a->name = fullname($reviewer);
|
||||
$a->url = $userurl->out();
|
||||
$byfullname = get_string('assessmentby', 'workshop', $a);
|
||||
$oo = $this->output->container($userpic, 'picture');
|
||||
$oo .= $this->output->container($byfullname, 'fullname');
|
||||
|
||||
$o .= $this->output->container($oo, 'reviewer');
|
||||
}
|
||||
|
||||
if (is_null($assessment->realgrade)) {
|
||||
$o .= $this->output->container(
|
||||
get_string('notassessed', 'workshop'),
|
||||
'grade nograde'
|
||||
);
|
||||
} else {
|
||||
$a = new stdClass();
|
||||
$a->max = $assessment->maxgrade;
|
||||
$a->received = $assessment->realgrade;
|
||||
$o .= $this->output->container(
|
||||
get_string('gradeinfo', 'workshop', $a),
|
||||
'grade'
|
||||
);
|
||||
|
||||
if (!is_null($assessment->weight) and $assessment->weight != 1) {
|
||||
$o .= $this->output->container(
|
||||
get_string('weightinfo', 'workshop', $assessment->weight),
|
||||
'weight'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$o .= $this->output->container_start('actions');
|
||||
foreach ($assessment->actions as $action) {
|
||||
$o .= $this->output->single_button($action->url, $action->label, $action->method);
|
||||
}
|
||||
$o .= $this->output->container_end(); // actions
|
||||
|
||||
$o .= $this->output->container_end(); // header
|
||||
|
||||
if (!is_null($assessment->form)) {
|
||||
$o .= print_collapsible_region_start('assessment-form-wrapper', uniqid('workshop-assessment'),
|
||||
get_string('assessmentform', 'workshop'), '', false, true);
|
||||
$o .= $this->output->container(self::moodleform($assessment->form), 'assessment-form');
|
||||
$o .= print_collapsible_region_end(true);
|
||||
}
|
||||
|
||||
$o .= $this->output->container_end(); // main wrapper
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Internal rendering helper methods
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
@@ -750,6 +832,22 @@ class mod_workshop_renderer extends plugin_renderer_base {
|
||||
// Static helpers
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Helper method dealing with the fact we can not just fetch the output of moodleforms
|
||||
*
|
||||
* @param moodleform $mform
|
||||
* @return string HTML
|
||||
*/
|
||||
protected static function moodleform(moodleform $mform) {
|
||||
|
||||
ob_start();
|
||||
$mform->display();
|
||||
$o = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function returning the n-th item of the array
|
||||
*
|
||||
|
||||
+62
-3
@@ -310,16 +310,75 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Assessment
|
||||
* Assessment - full display
|
||||
*/
|
||||
.path-mod-workshop .assessment-summary.graded {
|
||||
.path-mod-workshop .assessment-full {
|
||||
border: 1px solid #ddd;
|
||||
margin: 0px auto 1em auto;
|
||||
}
|
||||
|
||||
.path-mod-workshop .assessment-full .header {
|
||||
position: relative;
|
||||
background-color: #ddd;
|
||||
padding: 3px;
|
||||
min-height: 35px;
|
||||
}
|
||||
|
||||
.path-mod-workshop .assessment-full .header .title {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.path-mod-workshop .assessment-full .header .title,
|
||||
.path-mod-workshop .assessment-full .header .reviewer,
|
||||
.path-mod-workshop .assessment-full .header .grade,
|
||||
.path-mod-workshop .assessment-full .header .weight {
|
||||
margin: 0px 0px 0px 40px;
|
||||
}
|
||||
|
||||
.path-mod-workshop .assessment-full.anonymous .header .title,
|
||||
.path-mod-workshop .assessment-full.anonymous .header .reviewer,
|
||||
.path-mod-workshop .assessment-full.anonymous .header .grade,
|
||||
.path-mod-workshop .assessment-full.anonymous .header .weight {
|
||||
margin: 0px 0px 0px 5px;
|
||||
}
|
||||
|
||||
.path-mod-workshop .assessment-full .header .reviewer .picture {
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
left: 3px;
|
||||
}
|
||||
|
||||
.path-mod-workshop .assessment-full .header .actions {
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
right: 5px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.path-mod-workshop .assessment-full .header .actions .singlebutton,
|
||||
.path-mod-workshop .assessment-full .header .actions .singlebutton form,
|
||||
.path-mod-workshop .assessment-full .header .actions .singlebutton form div {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.path-mod-workshop .assessment-full .assessment-form-wrapper {
|
||||
margin-top: 0.5em;
|
||||
padding: 0px 1em;
|
||||
}
|
||||
|
||||
.path-mod-workshop .assessment-summary.graded .singlebutton input[type="submit"],
|
||||
.path-mod-workshop .example-summary.graded .singlebutton input[type="submit"] {
|
||||
background-color: #e7f1c3;
|
||||
}
|
||||
|
||||
.path-mod-workshop .example-summary.notgraded {
|
||||
.path-mod-workshop .assessment-summary.notgraded .singlebutton input[type="submit"],
|
||||
.path-mod-workshop .example-summary.notgraded .singlebutton input[type="submit"] {
|
||||
background-color: #ffd3d9;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assessment form
|
||||
*/
|
||||
.path-mod-workshop .assessmentform .description {
|
||||
margin: 0px 1em;
|
||||
}
|
||||
|
||||
+37
-49
@@ -281,66 +281,54 @@ if (($workshop->phase == workshop::PHASE_CLOSED) and ($ownsubmission or $canview
|
||||
// and possibly display the submission's review(s)
|
||||
|
||||
if ($isreviewer) {
|
||||
$strategy = $workshop->grading_strategy_instance();
|
||||
$mform = $strategy->get_assessment_form($PAGE->url, 'assessment', $userassessment, false);
|
||||
echo $output->heading(get_string('assessmentbyyourself', 'workshop'), 2);
|
||||
// reviewers can always see the grades they gave even they are not available yet
|
||||
if (is_null($userassessment->grade)) {
|
||||
echo $output->heading(get_string('notassessed', 'workshop'), 3);
|
||||
if ($workshop->assessing_allowed($USER->id)) {
|
||||
echo $output->container($output->single_button($workshop->assess_url($userassessment->id), get_string('assess', 'workshop'), 'get'),
|
||||
array('class' => 'buttonsbar'));
|
||||
// user's own assessment
|
||||
$strategy = $workshop->grading_strategy_instance();
|
||||
$mform = $strategy->get_assessment_form($PAGE->url, 'assessment', $userassessment, false);
|
||||
$options = array(
|
||||
'showreviewer' => true,
|
||||
'showauthor' => $showauthor,
|
||||
'showform' => !is_null($userassessment->grade),
|
||||
'showweight' => true,
|
||||
);
|
||||
$assessment = $workshop->prepare_assessment($userassessment, $mform, $options);
|
||||
$assessment->title = get_string('assessmentbyyourself', 'workshop');
|
||||
|
||||
if ($workshop->assessing_allowed($USER->id)) {
|
||||
if (is_null($userassessment->grade)) {
|
||||
$assessment->add_action($workshop->assess_url($assessment->id), get_string('assess', 'workshop'));
|
||||
} else {
|
||||
$assessment->add_action($workshop->assess_url($assessment->id), get_string('reassess', 'workshop'));
|
||||
}
|
||||
} else {
|
||||
$a = new stdclass();
|
||||
$a->max = $workshop->real_grade(100);
|
||||
$a->received = $workshop->real_grade($userassessment->grade);
|
||||
echo $output->heading(get_string('gradeinfo', 'workshop', $a), 3);
|
||||
if ($userassessment->weight != 1) {
|
||||
echo $output->heading(get_string('weightinfo', 'workshop', $userassessment->weight), 3);
|
||||
}
|
||||
if ($workshop->assessing_allowed($USER->id)) {
|
||||
echo $output->container($output->single_button($workshop->assess_url($userassessment->id), get_string('reassess', 'workshop'), 'get'),
|
||||
array('class' => 'buttonsbar'));
|
||||
}
|
||||
$mform->display();
|
||||
}
|
||||
if ($canoverride) {
|
||||
$assessment->add_action($workshop->assess_url($assessment->id), get_string('assessmentsettings', 'workshop'));
|
||||
}
|
||||
|
||||
echo $output->render($assessment);
|
||||
}
|
||||
|
||||
if (has_capability('mod/workshop:viewallassessments', $workshop->context) or ($ownsubmission and $workshop->assessments_available())) {
|
||||
$strategy = $workshop->grading_strategy_instance();
|
||||
$assessments = $workshop->get_assessments_of_submission($submission->id);
|
||||
$canviewreviewernames = has_capability('mod/workshop:viewreviewernames', $workshop->context);
|
||||
// other assessments
|
||||
$strategy = $workshop->grading_strategy_instance();
|
||||
$assessments = $workshop->get_assessments_of_submission($submission->id);
|
||||
$showreviewer = has_capability('mod/workshop:viewreviewernames', $workshop->context);
|
||||
foreach ($assessments as $assessment) {
|
||||
if ($assessment->reviewerid == $USER->id) {
|
||||
// own assessment has been displayed already
|
||||
continue;
|
||||
}
|
||||
if (is_null($assessment->grade)) {
|
||||
// not graded assessment are not displayed
|
||||
continue;
|
||||
$mform = $strategy->get_assessment_form($PAGE->url, 'assessment', $assessment, false);
|
||||
$options = array(
|
||||
'showreviewer' => $showreviewer,
|
||||
'showauthor' => $showauthor,
|
||||
'showform' => !is_null($assessment->grade),
|
||||
'showweight' => true,
|
||||
);
|
||||
$assessment = $workshop->prepare_assessment($assessment, $mform, $options);
|
||||
if ($canoverride) {
|
||||
$assessment->add_action($workshop->assess_url($assessment->id), get_string('assessmentsettings', 'workshop'));
|
||||
}
|
||||
if ($canviewreviewernames) {
|
||||
$reviewer = new stdclass();
|
||||
$reviewer->firstname = $assessment->reviewerfirstname;
|
||||
$reviewer->lastname = $assessment->reviewerlastname;
|
||||
echo $output->heading(get_string('assessmentbyknown', 'workshop', fullname($reviewer)), 2);
|
||||
} else {
|
||||
echo $output->heading(get_string('assessmentbyunknown', 'workshop'), 2);
|
||||
}
|
||||
$a = new stdclass();
|
||||
$a->max = $workshop->real_grade(100);
|
||||
$a->received = $workshop->real_grade($assessment->grade);
|
||||
echo $output->heading(get_string('gradeinfo', 'workshop', $a), 3);
|
||||
if ($assessment->weight != 1) {
|
||||
echo $output->heading(get_string('weightinfo', 'workshop', $assessment->weight), 3);
|
||||
}
|
||||
if (has_capability('mod/workshop:overridegrades', $workshop->context)) {
|
||||
echo $output->container($output->single_button($workshop->assess_url($assessment->id), get_string('assessmentsettings', 'workshop'), 'get'),
|
||||
array('class' => 'buttonsbar'));
|
||||
}
|
||||
$mform = $strategy->get_assessment_form($PAGE->url, 'assessment', $assessment, false);
|
||||
$mform->display();
|
||||
echo $output->render($assessment);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user