From: David Mudrak Date: Mon, 4 Jan 2010 18:09:18 +0000 (+0000) Subject: Workshop planner tool now correctly counts the submissions and allocations X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=a3610b08f4c02cb819d8707e58b585bd18876aab;p=moodle.git Workshop planner tool now correctly counts the submissions and allocations --- diff --git a/mod/workshop/lang/en_utf8/workshop.php b/mod/workshop/lang/en_utf8/workshop.php index 50d6d2f8ef..4ef0e98ea0 100644 --- a/mod/workshop/lang/en_utf8/workshop.php +++ b/mod/workshop/lang/en_utf8/workshop.php @@ -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
submitted: $a->submitted
allocated: $a->allocated'; +$string['allocatedetails'] = 'expected: $a->expected
submitted: $a->submitted
to allocate: $a->allocate'; $string['allocationdone'] = 'Allocation done'; $string['allocationerror'] = 'Allocation error'; $string['allocation'] = 'Submission allocation'; diff --git a/mod/workshop/locallib.php b/mod/workshop/locallib.php index 52adaf57e7..8ec9d595ed 100644 --- a/mod/workshop/locallib.php +++ b/mod/workshop/locallib.php @@ -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; diff --git a/mod/workshop/view.php b/mod/workshop/view.php index a8cfc14177..2c6b97a2db 100644 --- a/mod/workshop/view.php +++ b/mod/workshop/view.php @@ -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);