mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
MDL-26349 Display the workshop final grades to participants when the activity is closed
This commit is contained in:
parent
092977fb0b
commit
3cb4ce45c7
@ -301,4 +301,5 @@ $string['workshop:viewauthorpublished'] = 'View authors of published submissions
|
||||
$string['workshop:viewpublishedsubmissions'] = 'View published submissions';
|
||||
$string['workshop:viewreviewernames'] = 'View reviewer names';
|
||||
$string['yourassessment'] = 'Your assessment';
|
||||
$string['yourgrades'] = 'Your grades';
|
||||
$string['yoursubmission'] = 'Your submission';
|
||||
|
@ -2200,6 +2200,59 @@ class workshop {
|
||||
'post', '', null, $editable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the information about the user's grades as they are stored in the gradebook
|
||||
*
|
||||
* The submission grade is returned for users with the capability mod/workshop:submit and the
|
||||
* assessment grade is returned for users with the capability mod/workshop:peerassess. Unless the
|
||||
* user has the capability to view hidden grades, grades must be visible to be returned. Null
|
||||
* grades are not returned. If none grade is to be returned, this method returns false.
|
||||
*
|
||||
* @param int $userid the user's id
|
||||
* @return workshop_final_grades|false
|
||||
*/
|
||||
public function get_gradebook_grades($userid) {
|
||||
global $CFG;
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
|
||||
if (empty($userid)) {
|
||||
throw new coding_exception('User id expected, empty value given.');
|
||||
}
|
||||
|
||||
// Read data via the Gradebook API
|
||||
$gradebook = grade_get_grades($this->course->id, 'mod', 'workshop', $this->id, $userid);
|
||||
|
||||
$grades = new workshop_final_grades();
|
||||
|
||||
if (has_capability('mod/workshop:submit', $this->context, $userid)) {
|
||||
if (!empty($gradebook->items[0]->grades)) {
|
||||
$submissiongrade = reset($gradebook->items[0]->grades);
|
||||
if (!is_null($submissiongrade->grade)) {
|
||||
if (!$submissiongrade->hidden or has_capability('moodle/grade:viewhidden', $this->context, $userid)) {
|
||||
$grades->submissiongrade = $submissiongrade;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->usepeerassessment and has_capability('mod/workshop:peerassess', $this->context, $userid)) {
|
||||
if (!empty($gradebook->items[1]->grades)) {
|
||||
$assessmentgrade = reset($gradebook->items[1]->grades);
|
||||
if (!is_null($assessmentgrade->grade)) {
|
||||
if (!$assessmentgrade->hidden or has_capability('moodle/grade:viewhidden', $this->context, $userid)) {
|
||||
$grades->assessmentgrade = $assessmentgrade;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_null($grades->submissiongrade) or !is_null($grades->assessmentgrade)) {
|
||||
return $grades;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Internal methods (implementation details) //
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -3471,3 +3524,16 @@ class workshop_feedback_reviewer extends workshop_feedback implements renderable
|
||||
$this->format = $assessment->feedbackreviewerformat;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Holds the final grades for the activity as are stored in the gradebook
|
||||
*/
|
||||
class workshop_final_grades implements renderable {
|
||||
|
||||
/** @var object the info from the gradebook about the grade for submission */
|
||||
public $submissiongrade = null;
|
||||
|
||||
/** @var object the infor from the gradebook about the grade for assessment */
|
||||
public $assessmentgrade = null;
|
||||
}
|
||||
|
@ -724,6 +724,47 @@ class mod_workshop_renderer extends plugin_renderer_base {
|
||||
return $this->output->container($this->output->render($select), 'perpagewidget');
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the user's final grades
|
||||
*
|
||||
* @param workshop_final_grades $grades with the info about grades in the gradebook
|
||||
* @return string HTML
|
||||
*/
|
||||
protected function render_workshop_final_grades(workshop_final_grades $grades) {
|
||||
|
||||
$out = html_writer::start_tag('div', array('class' => 'finalgrades'));
|
||||
|
||||
if (!empty($grades->submissiongrade)) {
|
||||
$cssclass = 'grade submissiongrade';
|
||||
if ($grades->submissiongrade->hidden) {
|
||||
$cssclass .= ' hiddengrade';
|
||||
}
|
||||
$out .= html_writer::tag(
|
||||
'div',
|
||||
html_writer::tag('div', get_string('submissiongrade', 'mod_workshop'), array('class' => 'gradetype')) .
|
||||
html_writer::tag('div', $grades->submissiongrade->str_long_grade, array('class' => 'gradevalue')),
|
||||
array('class' => $cssclass)
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($grades->assessmentgrade)) {
|
||||
$cssclass = 'grade assessmentgrade';
|
||||
if ($grades->assessmentgrade->hidden) {
|
||||
$cssclass .= ' hiddengrade';
|
||||
}
|
||||
$out .= html_writer::tag(
|
||||
'div',
|
||||
html_writer::tag('div', get_string('gradinggrade', 'mod_workshop'), array('class' => 'gradetype')) .
|
||||
html_writer::tag('div', $grades->assessmentgrade->str_long_grade, array('class' => 'gradevalue')),
|
||||
array('class' => $cssclass)
|
||||
);
|
||||
}
|
||||
|
||||
$out .= html_writer::end_tag('div');
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Internal rendering helper methods
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -458,6 +458,38 @@
|
||||
color: #ee0000;
|
||||
}
|
||||
|
||||
/**
|
||||
* Final grades
|
||||
*/
|
||||
.path-mod-workshop #workshop-viewlet-yourgrades .finalgrades {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.path-mod-workshop #workshop-viewlet-yourgrades .finalgrades .grade {
|
||||
border: 1px solid #ddd;
|
||||
margin: 1em;
|
||||
padding: 2em;
|
||||
display: inline-block;
|
||||
-webkit-border-radius: 15px;
|
||||
-moz-border-radius: 15px;
|
||||
border-radius: 15px;
|
||||
}
|
||||
|
||||
.path-mod-workshop #workshop-viewlet-yourgrades .finalgrades .grade.submissiongrade {
|
||||
background-color: #d2ebff;
|
||||
}
|
||||
|
||||
.path-mod-workshop #workshop-viewlet-yourgrades .finalgrades .grade.assessmentgrade {
|
||||
background-color: #eee;
|
||||
/*background-color: #e7f1c3;*/
|
||||
}
|
||||
|
||||
.path-mod-workshop #workshop-viewlet-yourgrades .finalgrades .grade .gradevalue {
|
||||
font-weight: bold;
|
||||
font-size: x-large;
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit assessment form
|
||||
*/
|
||||
|
@ -519,6 +519,14 @@ case workshop::PHASE_CLOSED:
|
||||
echo $output->box(format_text($conclusion, $workshop->conclusionformat, array('overflowdiv'=>true)), array('generalbox', 'conclusion'));
|
||||
print_collapsible_region_end();
|
||||
}
|
||||
$finalgrades = $workshop->get_gradebook_grades($USER->id);
|
||||
if (!empty($finalgrades)) {
|
||||
print_collapsible_region_start('', 'workshop-viewlet-yourgrades', get_string('yourgrades', 'workshop'));
|
||||
echo $output->box_start('generalbox grades-yourgrades');
|
||||
echo $output->render($finalgrades);
|
||||
echo $output->box_end();
|
||||
print_collapsible_region_end();
|
||||
}
|
||||
if (has_capability('mod/workshop:viewallassessments', $PAGE->context)) {
|
||||
$perpage = get_user_preferences('workshop_perpage', 10);
|
||||
$groupid = groups_get_activity_group($workshop->cm, true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user