Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'MDL-27734-workshop-example-weight' of git://github.com/…

…mudrd8mz/moodle
  • Loading branch information...
commit e0f18a37c933d78df87bf210adde69b6dc1e2a5a 2 parents 656bb67 + b34b969
@samhemelryk samhemelryk authored
Showing with 21 additions and 5 deletions.
  1. +21 −5 mod/workshop/db/upgradelib.php
View
26 mod/workshop/db/upgradelib.php
@@ -339,6 +339,9 @@ function workshop_upgrade_assessments() {
// list of teachers in every workshop: array of (int)workshopid => array of (int)userid => notused
$workshopteachers = array();
+ // get the list of ids of the new example submissions
+ $examplesubmissions = $DB->get_records('workshop_submissions', array('example' => 1), '', 'id');
+
$rs = $DB->get_recordset_select('workshop_assessments_old', 'newid IS NULL');
foreach ($rs as $old) {
if (!isset($workshopteachers[$old->workshopid])) {
@@ -346,8 +349,9 @@ function workshop_upgrade_assessments() {
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$workshopteachers[$old->workshopid] = get_users_by_capability($context, 'mod/workshop:manage', 'u.id');
}
+ $ofexample = isset($examplesubmissions[$newsubmissionids[$old->submissionid]]);
$new = workshop_upgrade_transform_assessment($old, $newsubmissionids[$old->submissionid],
- $workshopteachers[$old->workshopid], $teacherweights[$old->workshopid]);
+ $workshopteachers[$old->workshopid], $teacherweights[$old->workshopid], $ofexample);
$newid = $DB->insert_record('workshop_assessments', $new, true, true);
$DB->set_field('workshop_assessments_old', 'newplugin', 'assessments', array('id' => $old->id));
$DB->set_field('workshop_assessments_old', 'newid', $newid, array('id' => $old->id));
@@ -362,9 +366,10 @@ function workshop_upgrade_assessments() {
* @param int $newsubmissionid new submission id
* @param array $legacyteachers (int)userid => notused the list of legacy workshop teachers for the submission's workshop
* @param int $legacyteacherweight weight of teacher's assessment in legacy workshop
+ * @param bool $ofexample is this the assessment of an example submission?
* @return stdClass
*/
-function workshop_upgrade_transform_assessment(stdClass $old, $newsubmissionid, array $legacyteachers, $legacyteacherweight) {
+function workshop_upgrade_transform_assessment(stdClass $old, $newsubmissionid, array $legacyteachers, $legacyteacherweight, $ofexample) {
global $CFG;
require_once($CFG->libdir . '/gradelib.php');
@@ -372,10 +377,21 @@ function workshop_upgrade_transform_assessment(stdClass $old, $newsubmissionid,
$new->submissionid = $newsubmissionid;
$new->reviewerid = $old->userid;
- if (isset($legacyteachers[$old->userid])) {
- $new->weight = $legacyteacherweight;
+ if ($ofexample) {
+ // this is the assessment of an example submission
+ if (isset($legacyteachers[$old->userid])) {
+ // this is probably the reference assessment of the example submission
+ $new->weight = 1;
+ } else {
+ $new->weight = 0;
+ }
+
} else {
- $new->weight = 1;
+ if (isset($legacyteachers[$old->userid])) {
+ $new->weight = $legacyteacherweight;
+ } else {
+ $new->weight = 1;
+ }
}
if ($old->grade < 0) {
Please sign in to comment.
Something went wrong with that request. Please try again.