From bfde810a8b8682f2493ac053221546f78b9d0b72 Mon Sep 17 00:00:00 2001 From: M Kassaei Date: Tue, 23 Jun 2015 11:36:43 +0100 Subject: [PATCH 1/3] MDL-50673 workshop: Display all participants during submission phase This patch adds a new report to be displayed during the submission phase. The report displays all participants who are supposed to submit their work into the workshop and the status of their submission. --- mod/workshop/lang/en/workshop.php | 4 ++ mod/workshop/locallib.php | 5 +- mod/workshop/renderer.php | 42 ++++++++++++----- mod/workshop/styles.css | 9 ++++ .../tests/behat/workshop_assessment.feature | 10 ++-- mod/workshop/view.php | 47 ++++++++++++------- 6 files changed, 83 insertions(+), 34 deletions(-) diff --git a/mod/workshop/lang/en/workshop.php b/mod/workshop/lang/en/workshop.php index a3cda79cb4b..e327aab4cdb 100644 --- a/mod/workshop/lang/en/workshop.php +++ b/mod/workshop/lang/en/workshop.php @@ -196,6 +196,7 @@ $string['notassessed'] = 'Not assessed yet'; $string['notoverridden'] = 'Not overridden'; $string['noworkshops'] = 'There are no workshops in this course'; $string['noyoursubmission'] = 'You have not submitted your work yet'; +$string['nothingfound'] = 'Nothing to display'; $string['nullgrade'] = '-'; $string['overallfeedback'] = 'Overall feedback'; $string['overallfeedbackfiles'] = 'Maximum number of overall feedback attachments'; @@ -265,11 +266,14 @@ If you enable this feature, it is recommended to set up the scheduled allocation $string['submissiongrade'] = 'Grade for submission'; $string['submissiongrade_help'] = 'This setting specifies the maximum grade that may be obtained for submitted work.'; $string['submissiongradeof'] = 'Grade for submission (of {$a})'; +$string['submissionlastmodified'] = 'Last modified'; $string['submissionsettings'] = 'Submission settings'; $string['submissionstart'] = 'Open for submissions from'; $string['submissionstartevent'] = '{$a} (opens for submissions)'; $string['submissionstartdatetime'] = 'Open for submissions from {$a->daydatetime} ({$a->distanceday})'; $string['submissiontitle'] = 'Title'; +$string['submissionsreport'] = 'Workshop submissions report'; +$string['submittednotsubmitted'] = 'Submitted ({$a->submitted}) / not submitted ({$a->notsubmitted})'; $string['subplugintype_workshopallocation'] = 'Submissions allocation method'; $string['subplugintype_workshopallocation_plural'] = 'Submissions allocation methods'; $string['subplugintype_workshopeval'] = 'Grading evaluation method'; diff --git a/mod/workshop/locallib.php b/mod/workshop/locallib.php index 55fee5a9f50..aa08dd19090 100644 --- a/mod/workshop/locallib.php +++ b/mod/workshop/locallib.php @@ -1782,7 +1782,7 @@ class workshop { return array(); } - if (!in_array($sortby, array('lastname','firstname','submissiontitle','submissiongrade','gradinggrade'))) { + if (!in_array($sortby, array('lastname','firstname','submissiontitle', 'submissionmodified','submissiongrade','gradinggrade'))) { $sortby = 'lastname'; } @@ -1813,7 +1813,8 @@ class workshop { } $sqlsort = implode(',', $sqlsort); $picturefields = user_picture::fields('u', array(), 'userid'); - $sql = "SELECT $picturefields, s.title AS submissiontitle, s.grade AS submissiongrade, ag.gradinggrade + $sql = "SELECT $picturefields, s.title AS submissiontitle, s.timemodified AS submissionmodified, + s.grade AS submissiongrade, ag.gradinggrade FROM {user} u LEFT JOIN {workshop_submissions} s ON (s.authorid = u.id AND s.workshopid = :workshopid1 AND s.example = 0) LEFT JOIN {workshop_aggregations} ag ON (ag.userid = u.id AND ag.workshopid = :workshopid2) diff --git a/mod/workshop/renderer.php b/mod/workshop/renderer.php index e5cc7aca674..91ac7faeb48 100644 --- a/mod/workshop/renderer.php +++ b/mod/workshop/renderer.php @@ -420,21 +420,29 @@ class mod_workshop_renderer extends plugin_renderer_base { $sortbyname = $sortbyfirstname . ' / ' . $sortbylastname; } + $sortbysubmisstiontitle = $this->helper_sortable_heading(get_string('submission', 'workshop'), 'submissiontitle', + $options->sortby, $options->sorthow); + $sortbysubmisstionlastmodified = $this->helper_sortable_heading(get_string('submissionlastmodified', 'workshop'), + 'submissionmodified', $options->sortby, $options->sorthow); + $sortbysubmisstion = $sortbysubmisstiontitle . ' / ' . $sortbysubmisstionlastmodified; + $table->head = array(); $table->head[] = $sortbyname; - $table->head[] = $this->helper_sortable_heading(get_string('submission', 'workshop'), 'submissiontitle', - $options->sortby, $options->sorthow); - $table->head[] = $this->helper_sortable_heading(get_string('receivedgrades', 'workshop')); - if ($options->showsubmissiongrade) { - $table->head[] = $this->helper_sortable_heading(get_string('submissiongradeof', 'workshop', $data->maxgrade), - 'submissiongrade', $options->sortby, $options->sorthow); - } - $table->head[] = $this->helper_sortable_heading(get_string('givengrades', 'workshop')); - if ($options->showgradinggrade) { - $table->head[] = $this->helper_sortable_heading(get_string('gradinggradeof', 'workshop', $data->maxgradinggrade), - 'gradinggrade', $options->sortby, $options->sorthow); - } + $table->head[] = $sortbysubmisstion; + // If we are in submission phase ignore the following headers (columns). + if ($options->workshopphase != workshop::PHASE_SUBMISSION) { + $table->head[] = $this->helper_sortable_heading(get_string('receivedgrades', 'workshop')); + if ($options->showsubmissiongrade) { + $table->head[] = $this->helper_sortable_heading(get_string('submissiongradeof', 'workshop', $data->maxgrade), + 'submissiongrade', $options->sortby, $options->sorthow); + } + $table->head[] = $this->helper_sortable_heading(get_string('givengrades', 'workshop')); + if ($options->showgradinggrade) { + $table->head[] = $this->helper_sortable_heading(get_string('gradinggradeof', 'workshop', $data->maxgradinggrade), + 'gradinggrade', $options->sortby, $options->sorthow); + } + } $table->rowclasses = array(); $table->colclasses = array(); $table->data = array(); @@ -484,6 +492,13 @@ class mod_workshop_renderer extends plugin_renderer_base { $cell->attributes['class'] = 'submission'; $row->cells[] = $cell; } + + // If we are in submission phase ignore the following columns. + if ($options->workshopphase == workshop::PHASE_SUBMISSION) { + $table->data[] = $row; + continue; + } + // column #3 - received grades if ($tr % $spanreceived == 0) { $idx = intval($tr / $spanreceived); @@ -997,6 +1012,9 @@ class mod_workshop_renderer extends plugin_renderer_base { $url = new moodle_url('/mod/workshop/submission.php', array('cmid' => $this->page->context->instanceid, 'id' => $participant->submissionid)); $out = html_writer::link($url, format_string($participant->submissiontitle), array('class'=>'title')); + + $lastmodified = get_string('userdatemodified', 'workshop', userdate($participant->submissionmodified)); + $out .= html_writer::tag('div', $lastmodified, array('class' => 'lastmodified')); } return $out; diff --git a/mod/workshop/styles.css b/mod/workshop/styles.css index bca77adb0da..8a0787aa553 100644 --- a/mod/workshop/styles.css +++ b/mod/workshop/styles.css @@ -589,4 +589,13 @@ text-align: center; } +.path-mod-workshop .lastmodified { + line-height: 1.0em; +} + +.path-mod-workshop .nothingfound { + font-size: 150%; + color: #FF4500; +} + .path-mod-workshop .workshop-risk-dataloss { vertical-align: text-bottom; } diff --git a/mod/workshop/tests/behat/workshop_assessment.feature b/mod/workshop/tests/behat/workshop_assessment.feature index 53a8c0a5d7c..e8b99574218 100644 --- a/mod/workshop/tests/behat/workshop_assessment.feature +++ b/mod/workshop/tests/behat/workshop_assessment.feature @@ -64,10 +64,12 @@ Feature: Workshop submission and assessment And I follow "TestWorkshop" And I should see "to allocate: 3" And I should see "There is at least one author who has not yet submitted their work" - And I should see "All submissions (3)" - And I should see "Submission1" - And I should see "Submission2" - And I should see "Submission3" + Then I should see "Workshop submissions report" + And I should see "Submitted (3) / not submitted (1)" + And I should see "Submission1" in the "Sam1 Student1" "table_row" + And I should see "Submission2" in the "Sam2 Student2" "table_row" + And I should see "Submission3" in the "Sam3 Student3" "table_row" + And I should see "No submission found for this user" in the "Sam4 Student4" "table_row" And I allocate submissions in workshop "TestWorkshop" as:" | Participant | Reviewer | | Sam1 Student1 | Sam2 Student2 | diff --git a/mod/workshop/view.php b/mod/workshop/view.php index 10a26d8849e..f686bdf4641 100644 --- a/mod/workshop/view.php +++ b/mod/workshop/view.php @@ -224,32 +224,44 @@ case workshop::PHASE_SUBMISSION: } } - $countsubmissions = $workshop->count_submissions('all', $groupid); + print_collapsible_region_start('', 'workshop-viewlet-allsubmissions', get_string('submissionsreport', 'workshop')); + $perpage = get_user_preferences('workshop_perpage', 10); - $pagingbar = new paging_bar($countsubmissions, $page, $perpage, $PAGE->url, 'page'); + $data = $workshop->prepare_grading_report_data($USER->id, $groupid, $page, $perpage, $sortby, $sorthow); + if ($data) { + $countparticipants = $workshop->count_participants(); + $countsubmissions = $workshop->count_submissions('all', $groupid); + $a = new stdClass(); + $a->submitted = $countsubmissions; + $a->notsubmitted = $data->totalcount - $countsubmissions; - print_collapsible_region_start('', 'workshop-viewlet-allsubmissions', get_string('allsubmissions', 'workshop', $countsubmissions)); - echo $output->box_start('generalbox allsubmissions'); - echo $output->container(groups_print_activity_menu($workshop->cm, $PAGE->url, true), 'groupwidget'); + echo html_writer::tag('div', get_string('submittednotsubmitted', 'workshop', $a)); - if ($countsubmissions == 0) { - echo $output->container(get_string('nosubmissions', 'workshop'), 'nosubmissions'); + echo $output->container(groups_print_activity_menu($workshop->cm, $PAGE->url, true), 'groupwidget'); + + // prepare paging bar + $baseurl = new moodle_url($PAGE->url, array('sortby' => $sortby, 'sorthow' => $sorthow)); + $pagingbar = new paging_bar($data->totalcount, $page, $perpage, $baseurl, 'page'); + + // submissions report display options + $reportopts = new stdclass(); + $reportopts->showauthornames = has_capability('mod/workshop:viewauthornames', $workshop->context); + $reportopts->showreviewernames = has_capability('mod/workshop:viewreviewernames', $workshop->context); + $reportopts->sortby = $sortby; + $reportopts->sorthow = $sorthow; + $reportopts->showsubmissiongrade = false; + $reportopts->showgradinggrade = false; + $reportopts->workshopphase = $workshop->phase; - } else { - $submissions = $workshop->get_submissions('all', $groupid, $page * $perpage, $perpage); - $shownames = has_capability('mod/workshop:viewauthornames', $workshop->context); echo $output->render($pagingbar); - foreach ($submissions as $submission) { - echo $output->render($workshop->prepare_submission_summary($submission, $shownames)); - } + echo $output->render(new workshop_grading_report($data, $reportopts)); echo $output->render($pagingbar); echo $output->perpage_selector($perpage); + } else { + echo html_writer::tag('div', get_string('nothingfound', 'workshop'), array('class' => 'nothingfound')); } - - echo $output->box_end(); print_collapsible_region_end(); } - break; case workshop::PHASE_ASSESSMENT: @@ -298,6 +310,7 @@ case workshop::PHASE_ASSESSMENT: $reportopts->sorthow = $sorthow; $reportopts->showsubmissiongrade = false; $reportopts->showgradinggrade = false; + $reportopts->workshopphase = $workshop->phase; print_collapsible_region_start('', 'workshop-viewlet-gradereport', get_string('gradesreport', 'workshop')); echo $output->box_start('generalbox gradesreport'); @@ -447,6 +460,7 @@ case workshop::PHASE_EVALUATION: $reportopts->sorthow = $sorthow; $reportopts->showsubmissiongrade = true; $reportopts->showgradinggrade = true; + $reportopts->workshopphase = $workshop->phase; print_collapsible_region_start('', 'workshop-viewlet-gradereport', get_string('gradesreport', 'workshop')); echo $output->box_start('generalbox gradesreport'); @@ -565,6 +579,7 @@ case workshop::PHASE_CLOSED: $reportopts->sorthow = $sorthow; $reportopts->showsubmissiongrade = true; $reportopts->showgradinggrade = true; + $reportopts->workshopphase = $workshop->phase; print_collapsible_region_start('', 'workshop-viewlet-gradereport', get_string('gradesreport', 'workshop')); echo $output->box_start('generalbox gradesreport'); From 65ba4cdad27610ef033fe282c6405d0c03ba119f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mudr=C3=A1k?= Date: Thu, 16 Jul 2015 19:38:48 +0200 Subject: [PATCH 2/3] MDL-50673 workshop: Fix the way how submissions are counted The count_submissions() method does not take the actual enrolment into account. It is part of the API that looks on all existing data regardless the actual status of their owner. The author of the submission may be unenrolled or suspended, in which case they are not displayed in the report and we would get wrong figures. --- mod/workshop/view.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/workshop/view.php b/mod/workshop/view.php index f686bdf4641..b5e4211a6a4 100644 --- a/mod/workshop/view.php +++ b/mod/workshop/view.php @@ -230,7 +230,7 @@ case workshop::PHASE_SUBMISSION: $data = $workshop->prepare_grading_report_data($USER->id, $groupid, $page, $perpage, $sortby, $sorthow); if ($data) { $countparticipants = $workshop->count_participants(); - $countsubmissions = $workshop->count_submissions('all', $groupid); + $countsubmissions = $workshop->count_submissions(array_keys($data->grades), $groupid); $a = new stdClass(); $a->submitted = $countsubmissions; $a->notsubmitted = $data->totalcount - $countsubmissions; From a81b4cab2258d6bf86fb2ee61de983501a074772 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mudr=C3=A1k?= Date: Thu, 16 Jul 2015 19:37:01 +0200 Subject: [PATCH 3/3] MDL-50673 workshop: Fix some coding style violations --- mod/workshop/locallib.php | 5 +++-- mod/workshop/view.php | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/mod/workshop/locallib.php b/mod/workshop/locallib.php index aa08dd19090..4f98583aa54 100644 --- a/mod/workshop/locallib.php +++ b/mod/workshop/locallib.php @@ -1782,7 +1782,8 @@ class workshop { return array(); } - if (!in_array($sortby, array('lastname','firstname','submissiontitle', 'submissionmodified','submissiongrade','gradinggrade'))) { + if (!in_array($sortby, array('lastname', 'firstname', 'submissiontitle', 'submissionmodified', + 'submissiongrade', 'gradinggrade'))) { $sortby = 'lastname'; } @@ -1814,7 +1815,7 @@ class workshop { $sqlsort = implode(',', $sqlsort); $picturefields = user_picture::fields('u', array(), 'userid'); $sql = "SELECT $picturefields, s.title AS submissiontitle, s.timemodified AS submissionmodified, - s.grade AS submissiongrade, ag.gradinggrade + s.grade AS submissiongrade, ag.gradinggrade FROM {user} u LEFT JOIN {workshop_submissions} s ON (s.authorid = u.id AND s.workshopid = :workshopid1 AND s.example = 0) LEFT JOIN {workshop_aggregations} ag ON (ag.userid = u.id AND ag.workshopid = :workshopid2) diff --git a/mod/workshop/view.php b/mod/workshop/view.php index b5e4211a6a4..66adc1743d9 100644 --- a/mod/workshop/view.php +++ b/mod/workshop/view.php @@ -239,11 +239,11 @@ case workshop::PHASE_SUBMISSION: echo $output->container(groups_print_activity_menu($workshop->cm, $PAGE->url, true), 'groupwidget'); - // prepare paging bar + // Prepare the paging bar. $baseurl = new moodle_url($PAGE->url, array('sortby' => $sortby, 'sorthow' => $sorthow)); $pagingbar = new paging_bar($data->totalcount, $page, $perpage, $baseurl, 'page'); - // submissions report display options + // Populate the display options for the submissions report. $reportopts = new stdclass(); $reportopts->showauthornames = has_capability('mod/workshop:viewauthornames', $workshop->context); $reportopts->showreviewernames = has_capability('mod/workshop:viewreviewernames', $workshop->context);