]> git.mjollnir.org Git - moodle.git/commitdiff
Workshop planner tool now correctly counts the submissions and allocations
authorDavid Mudrak <david.mudrak@gmail.com>
Mon, 4 Jan 2010 18:09:18 +0000 (18:09 +0000)
committerDavid Mudrak <david.mudrak@gmail.com>
Mon, 4 Jan 2010 18:09:18 +0000 (18:09 +0000)
mod/workshop/lang/en_utf8/workshop.php
mod/workshop/locallib.php
mod/workshop/view.php

index 50d6d2f8ef0e8ccb03e67bcd4545367f1026b478..4ef0e98ea08d8bb89cf9743a506477bb819bd67a 100644 (file)
@@ -35,7 +35,7 @@ $string['accesscontrol'] = 'Access control';
 $string['agreeassessments'] = 'Assessments must be agreed';
 $string['agreeassessmentsdesc'] = 'Authors may comment assessments of their work and agree/disagree with it';
 $string['allocate'] = 'Allocate submissions';
-$string['allocatedetails'] = 'expected: $a->expected<br />submitted: $a->submitted<br />allocated: $a->allocated';
+$string['allocatedetails'] = 'expected: $a->expected<br />submitted: $a->submitted<br />to allocate: $a->allocate';
 $string['allocationdone'] = 'Allocation done';
 $string['allocationerror'] = 'Allocation error';
 $string['allocation'] = 'Submission allocation';
index 52adaf57e757781dd7c99173d976fd2fe6881200..8ec9d595ed48a30a4f787918e85ea8c094864cc7 100644 (file)
@@ -417,6 +417,7 @@ class workshop {
         $assessment->reviewerid     = $reviewerid;
         $assessment->timecreated    = $now;
         $assessment->timemodified   = $now;
+        $assessment->weight         = 1;    // todo better handling of the weight value/default
 
         return $DB->insert_record('workshop_assessments', $assessment, true, $bulk);
     }
@@ -700,7 +701,7 @@ class workshop {
             }
             $phase->tasks['instructreviewers'] = $task;
         }
-        if (has_capability('mod/workshop:submit', $context, $userid)) {
+        if (has_capability('mod/workshop:submit', $context, $userid, false)) {
             $task = new stdClass();
             $task->title = get_string('tasksubmit', 'workshop');
             $task->link = $this->submission_url();
@@ -718,28 +719,18 @@ class workshop {
             $task = new stdClass();
             $task->title = get_string('allocate', 'workshop');
             $task->link = $this->allocation_url();
-            $authors     = array();
-            $allocations = array(); // 'submissionid' => isallocated
-            $records = $this->get_allocations();
-            foreach ($records as $allocation) {
-                if (!isset($authors[$allocation->authorid])) {
-                    $authors[$allocation->authorid] = true;
-                }
-                if (isset($allocation->submissionid)) {
-                    if (!isset($allocations[$allocation->submissionid])) {
-                        $allocations[$allocation->submissionid] = false;
-                    }
-                    if (!empty($allocation->reviewerid)) {
-                        $allocations[$allocation->submissionid] = true;
-                    }
-                }
-            }
-            $numofauthors     = count($authors);
-            $numofsubmissions = count($allocations);
-            $numofallocated   = count(array_filter($allocations));
+            $numofauthors = count(get_users_by_capability($context, 'mod/workshop:submit', 'u.id', '', '', '',
+                    '', '', false, true));
+            $numofsubmissions = $DB->count_records('workshop_submissions', array('workshopid'=>$this->id, 'example'=>0));
+            $sql = 'SELECT COUNT(s.id) AS nonallocated
+                      FROM {workshop_submissions} s
+                 LEFT JOIN {workshop_assessments} a ON (a.submissionid=s.id)
+                     WHERE s.workshopid = :workshopid AND s.example=0 AND a.submissionid IS NULL';
+            $params['workshopid'] = $this->id;
+            $numnonallocated = $DB->count_records_sql($sql, $params);
             if ($numofsubmissions == 0) {
                 $task->completed = null;
-            } elseif ($numofsubmissions == $numofallocated) {
+            } elseif ($numnonallocated == 0) {
                 $task->completed = true;
             } elseif ($this->phase > self::PHASE_SUBMISSION) {
                 $task->completed = false;
@@ -749,7 +740,7 @@ class workshop {
             $a = new stdClass();
             $a->expected    = $numofauthors;
             $a->submitted   = $numofsubmissions;
-            $a->allocated   = $numofallocated;
+            $a->allocate    = $numnonallocated;
             $task->details  = get_string('allocatedetails', 'workshop', $a);
             unset($a);
             $phase->tasks['allocate'] = $task;
index a8cfc1417709e97bdfdc0c1ca9fe2e2b26d97dbb..2c6b97a2db3c5120c05bb5d8dde7dbd779dc8149 100644 (file)
@@ -45,7 +45,7 @@ if ($id) {
 
 require_login($course, true, $cm);
 require_capability('mod/workshop:view', $PAGE->context);
-add_to_log($course->id, 'workshop', 'view', 'view.php?id='.$cm->id, $workshop->id);
+add_to_log($course->id, 'workshop', 'view', 'view.php?id=' . $cm->id, $workshop->name, $cm->id);
 
 $workshop = new workshop($workshop, $cm, $course);