]> git.mjollnir.org Git - moodle.git/commitdiff
Uses tabs for all actions, removed temporary links
authorDavid Mudrak <david.mudrak@gmail.com>
Mon, 4 Jan 2010 18:01:15 +0000 (18:01 +0000)
committerDavid Mudrak <david.mudrak@gmail.com>
Mon, 4 Jan 2010 18:01:15 +0000 (18:01 +0000)
mod/workshop/allocation.php
mod/workshop/allocation/manual/renderer.php
mod/workshop/allocation/random/allocator.php
mod/workshop/allocation/random/settings_form.php
mod/workshop/develtools.php
mod/workshop/lang/en_utf8/workshop.php
mod/workshop/locallib.php
mod/workshop/tabs.php
mod/workshop/view.php

index cb03276a17cd8068e048dc894232b72a613eb25d..e476637705d471e0e91f598b472b5a49b231eb9c 100644 (file)
@@ -58,11 +58,8 @@ $wsoutput = $PAGE->theme->get_renderer('mod_workshop', $PAGE);
 echo $OUTPUT->header();
 
 $allocators = $workshop->installed_allocators();
-$tabrow = array();
-foreach ($allocators as $methodid => $methodname) {
-    $tabrow[] = new tabobject($methodid, "allocation.php?cmid={$cmid}&amp;method={$methodid}", $methodname);
-}
-print_tabs(array($tabrow), $method);    // todo use $output call
+$currenttab = 'allocation';
+include(dirname(__FILE__) . '/tabs.php');
 
 if (!empty($initresult)) {
     echo $OUTPUT->container_start('allocator-init-results');
index 4f9edb98799460f7ed88c8db4334b33f0020bc36..a7b2ec6d7e721e6cab11045d764e13789cd3eddb 100644 (file)
@@ -180,6 +180,7 @@ class moodle_workshopallocation_manual_renderer extends moodle_renderer_base  {
         $exclude = array();
         if (!$workshop->useselfassessment) {
             $exclude[$user->id] = true;
+            $o .= $this->output->container(get_string('selfassessmentdisabled', 'workshop'), 'info');
         }
         // todo add an option to exclude users without own submission
         // todo nice to have number of current allocations for every user plus ordering by it
index a4e10108e5716d3aaf59d8bdf74e7799b5610450..07ec9f670bed8d2ce84750659da6e357208c18fc 100644 (file)
@@ -78,7 +78,7 @@ class workshop_random_allocator implements workshop_allocator {
             $removecurrent      = required_param('removecurrent', PARAM_INT);
             $assesswosubmission = required_param('assesswosubmission', PARAM_INT);
             $musthavesubmission = empty($assesswosubmission);
-            $addselfassessment  = required_param('addselfassessment', PARAM_INT);
+            $addselfassessment  = optional_param('addselfassessment', false, PARAM_INT); // may be frozen in the form
 
             $authors            = $this->workshop->get_peer_authors();
             $authors            = $this->workshop->get_grouped($authors);
index c2585f16a2e7472931e11b9e1e80776a6c2af7a7..da35a5a4c965668d3c378fec29ca1f4bae7a49b9 100644 (file)
@@ -78,8 +78,17 @@ class workshop_random_allocator_form extends moodleform {
         $mform->addElement('advcheckbox', 'assesswosubmission', get_string('assesswosubmission', 'workshopallocation_random'));
         $mform->setDefault('assesswosubmission', 0);
 
-        $mform->addElement('advcheckbox', 'addselfassessment', get_string('addselfassessment', 'workshopallocation_random'));
+        $grpselfassessment = array();
+        $grpselfassessment[] = $mform->createElement('advcheckbox', 'addselfassessment');
         $mform->setDefault('addselfassessment', 0);
+        if (!$workshop->useselfassessment) {
+            $grpselfassessment[] = $mform->createElement('static', 'selfassessmentcheck', '',
+                                                        get_string('selfassessmentdisabled', 'workshop'));
+        }
+        $mform->addGroup($grpselfassessment, 'grpselfassessment', get_string('addselfassessment', 'workshopallocation_random'));
+        if (!$workshop->useselfassessment) {
+            $mform->freeze(array('grpselfassessment'));
+        }
 
         $this->add_action_buttons();
     }
index 623a5e89b76146ed805c38f7d497dacfe5e5cede..c0725355bae46acc8853ca60cfca6e8aca5f2688 100644 (file)
@@ -101,6 +101,8 @@ case 'menu':
     // no break, skip to default
 default:
     echo $OUTPUT->header();
+    $currenttab = 'develtools';
+    include(dirname(__FILE__) . '/tabs.php');
     echo $OUTPUT->heading('Workshop development tools', 1);
     echo '<ul>';
     echo '<li><a href="' . $PAGE->url->out(false, array('tool' => 'mksubmissions')) . '">Fake submissions</a></li>';
index ae56e68fadc9ee0b5125f36e49aa29a4cfda4b4a..d6a7cadb306c79dc4f39b0f4a205601a30950858 100644 (file)
@@ -28,25 +28,11 @@ defined('MOODLE_INTERNAL') || die();
 $string[''] = '';
 $string[''] = '';
 $string[''] = '';
-$string['info'] = 'Info';
-$string['undersetup'] = 'The workshop is currently under setup. Please wait until it is switched to the next phase.';
-$string['taskinstructreviewers'] = 'Provide instructions for grading';
-$string['taskinstructauthors'] = 'Provide instructions for submitting';
-$string['taskintro'] = 'Set the workshop introduction';
-$string['phaseclosed'] = 'Closed';
-$string['phaseevaluation'] = 'Grading evaluation phase';
-$string['phaseassessment'] = 'Assessment phase';
-$string['phasesubmission'] = 'Submission phase';
-$string['phasesetup'] = 'Setup phase';
-$string['taskassessself'] = 'Assess yourself';
-$string['taskassesspeers'] = 'Assess peers';
-$string['allocatedetails'] = 'submissions: $a->total<br />allocated: $a->done';
-$string['taskassesspeersdetails'] = 'total: $a->total<br />pending: $a->todo';
-$string['tasksubmit'] = 'Submit your work';
 $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['allocationdone'] = 'Allocation done';
 $string['allocationerror'] = 'Allocation error';
 $string['allocation'] = 'Submission allocation';
@@ -93,6 +79,7 @@ $string['gradeforsubmission'] = 'Grade for submission';
 $string['gradingsettings'] = 'Grading settings';
 $string['chooseuser'] = 'Choose user...';
 $string['iamsure'] = 'Yes, I am sure';
+$string['info'] = 'Info';
 $string['introduction'] = 'Introduction';
 $string['latesubmissionsdesc'] = 'Allow submitting the work after the deadline';
 $string['latesubmissions'] = 'Late submissions';
@@ -113,11 +100,17 @@ $string['numofreviews'] = 'Number of reviews';
 $string['participant'] = 'Participant';
 $string['participantrevierof'] = 'Participant is reviewer of';
 $string['participantreviewedby'] = 'Participant is reviewed by';
+$string['phaseassessment'] = 'Assessment phase';
+$string['phaseclosed'] = 'Closed';
+$string['phaseevaluation'] = 'Grading evaluation phase';
+$string['phasesetup'] = 'Setup phase';
+$string['phasesubmission'] = 'Submission phase';
 $string['previewassessmentform'] = 'Preview';
 $string['releasegrades'] = 'Push final grades into the gradebook';
 $string['saveandclose'] = 'Save and close';
 $string['saveandcontinue'] = 'Save and continue editing';
 $string['saveandpreview'] = 'Save and preview';
+$string['selfassessmentdisabled'] = 'Self-assessment disabled';
 $string['strategyaccumulative'] = 'Accumulative grading';
 $string['strategydummy'] = 'Dummy strategy';
 $string['strategy'] = 'Grading strategy';
@@ -131,7 +124,15 @@ $string['submissionsettings'] = 'Submission settings';
 $string['submissionstart'] = 'Start of submission phase';
 $string['submission'] = 'Submission';
 $string['submissiontitle'] = 'Title';
+$string['taskassesspeers'] = 'Assess peers';
+$string['taskassesspeersdetails'] = 'total: $a->total<br />pending: $a->todo';
+$string['taskassessself'] = 'Assess yourself';
+$string['taskinstructauthors'] = 'Provide instructions for submitting';
+$string['taskinstructreviewers'] = 'Provide instructions for grading';
+$string['taskintro'] = 'Set the workshop introduction';
+$string['tasksubmit'] = 'Submit your work';
 $string['teacherweight'] = 'Weight of the teacher\'s assessments';
+$string['undersetup'] = 'The workshop is currently under setup. Please wait until it is switched to the next phase.';
 $string['useexamplesdesc'] = 'Users practise evaluating on example submissions';
 $string['useexamples'] = 'Use examples';
 $string['usepeerassessmentdesc'] = 'Users perform peer assessment of others\' work';
index 84b4cb929a558ed7bafc62454eadccf54c3d5bb0..80f7d8cedada949b1ae183a47473fbe0d5db4abf 100644 (file)
@@ -414,7 +414,7 @@ class workshop {
      * This returns the list of all users who can submit their work or review submissions (or both
      * which is the common case). So basically this is to return list of all students participating
      * in the workshop. For every participant, it adds information about their submission and their
-     * reviews.
+     * reviews, if such information is available (null elsewhere).
      *
      * The returned structure is recordset of objects with following properties:
      * [authorid] [authorfirstname] [authorlastname] [authorpicture] [authorimagealt]
@@ -448,9 +448,9 @@ class workshop {
              LEFT JOIN {workshop_submissions} s ON (s.userid = author.id)
              LEFT JOIN {workshop_assessments} a ON (s.id = a.submissionid)
              LEFT JOIN {user} reviewer ON (a.userid = reviewer.id)
-                 WHERE author.id $usql AND s.workshopid = :workshopid
+                 WHERE author.id $usql AND (s.id IS NULL OR s.workshopid = :workshopid)
               ORDER BY author.lastname,author.firstname,reviewer.lastname,reviewer.firstname";
-        
+
         return $DB->get_recordset_sql($sql, $params);
     }
 
@@ -740,21 +740,28 @@ class workshop {
             $task->title = get_string('allocate', 'workshop');
             $task->link = $this->allocation_url();
             $rs = $this->get_allocations_recordset();
+            $authors     = array();
             $allocations = array(); // 'submissionid' => isallocated
             foreach ($rs as $allocation) {
-                if (!isset($allocations[$allocation->submissionid])) {
-                    $allocations[$allocation->submissionid] = false;
+                if (!isset($authors[$allocation->authorid])) {
+                    $authors[$allocation->authorid] = true;
                 }
-                if (!empty($allocation->reviewerid)) {
-                    $allocations[$allocation->submissionid] = 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));
             $rs->close();
             if ($numofsubmissions == 0) {
                 $task->completed = null;
-            } elseif ($numofsubmissions == $numofallocated) {
+            } elseif ($numofauthors == $numofallocated) {
                 $task->completed = true;
             } elseif ($this->phase > self::PHASE_SUBMISSION) {
                 $task->completed = false;
@@ -762,11 +769,12 @@ class workshop {
                 $task->completed = null;    // still has a chance to allocate
             }
             $a = new stdClass();
-            $a->total = $numofsubmissions;
-            $a->done  = $numofallocated;
-            $task->details = get_string('allocatedetails', 'workshop', $a);
+            $a->expected    = $numofauthors;
+            $a->submitted   = $numofsubmissions;
+            $a->allocated   = $numofallocated;
+            $task->details  = get_string('allocatedetails', 'workshop', $a);
             unset($a);
-            $phase->tasks['submit'] = $task;
+            $phase->tasks['allocate'] = $task;
         }
 
         // Prepare tasks for the peer-assessment phase (includes eventual self-assessments)
index 4678158f45ff969806377e0f42f306150450590b..6c18792613d84d3b09bedfd63f5cc2b09b4ef6f6 100644 (file)
@@ -49,6 +49,27 @@ if (has_capability('mod/workshop:editdimensions', $workshop->context)) {
 if (has_capability('mod/workshop:submit', $workshop->context)) {
     $row[] = new tabobject('submission', $workshop->submission_url()->out(), get_string('editsubmission', 'workshop'));
 }
+if (has_capability('mod/workshop:allocate', $workshop->context)) {
+    $row[] = new tabobject('allocation', $workshop->allocation_url()->out(), get_string('allocate', 'workshop'));
+}
+if (has_capability('moodle/site:config', get_system_context())) {
+    // todo remove these tools from a production release
+    $row[] = new tabobject('develtools', "develtools.php?cmid={$cm->id}", 'Development tools');
+}
 $tabs[] = $row;
 
+if ($currenttab == 'allocation' and !empty($allocators)) {
+    // this is included from allocation.php so we rely of some variables defined there
+    $activated[] = 'allocation';
+    $row = array();
+    foreach ($allocators as $methodid => $methodname) {
+        $row[] = new tabobject($methodid, "allocation.php?cmid={$cmid}&amp;method={$methodid}", $methodname);
+        if ($methodid == $method) {
+            $currenttab = $methodid;
+        }
+    }
+    $tabs[] = $row;
+}
+
+
 print_tabs($tabs, $currenttab, $inactive, $activated);
index 5b545051e277987eac14695c529ed092f00f6067..2fbdcddd5fbbae8ab1e703900115cf565986c197 100644 (file)
@@ -96,25 +96,4 @@ case workshop::PHASE_CLOSED:
 default:
 }
 
-
-/// Print the main part of the page - todo these are just links to help during development
-echo $OUTPUT->box_start();
-echo $OUTPUT->heading('Workshop testing', 1);
-echo "<ol>\n";
-echo '<li><a href="' . $workshop->editform_url()->out()  . '">Edit grading form (' . get_string('pluginname', 'workshopgrading_' . $workshop->strategy) . ')</a></li>' . "\n";
-echo "<li><a href=\"submission.php?cmid={$cm->id}\">View/edit your own submission</a></li>\n";
-echo "<li><a href=\"develtools.php?tool=mksubmissions&amp;cmid={$cm->id}\">Fake others' submissions</a></li>\n";
-echo "<li><a href=\"allocation.php?cmid={$cm->id}\">Allocate submissions</a></li>\n";
-
-$assessments = $workshop->get_assessments($USER->id);
-echo "<li>Assess submissions\n";
-echo "<ol>\n";
-foreach ($assessments as $assessment) {
-    echo "<li><a href=\"assessment.php?asid={$assessment->id}\">Assessment of '{$assessment->title}' by {$assessment->authorid}</a></li>" . "\n";
-}
-echo "</ol></li>" . "\n";
-echo "</ol>\n";
-echo "<p><a href=\"develtools.php?cmid={$cm->id}\">Workshop development tools</a></p>\n";
-echo $OUTPUT->box_end();
-
 echo $OUTPUT->footer();