From f27b70fbbc0e32e58342606a4a828fa4c5d01589 Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Mon, 4 Jan 2010 18:24:03 +0000 Subject: [PATCH] MDL-20058 totalgrade stuff removed from workshop code --- mod/workshop/aggregate.php | 3 +- mod/workshop/db/install.xml | 12 +- mod/workshop/lang/en_utf8/workshop.php | 11 +- mod/workshop/locallib.php | 144 +++++------------------ mod/workshop/renderer.php | 20 +--- mod/workshop/simpletest/testlocallib.php | 120 ------------------- mod/workshop/styles.php | 7 +- mod/workshop/version.php | 2 +- mod/workshop/view.php | 2 - 9 files changed, 44 insertions(+), 277 deletions(-) diff --git a/mod/workshop/aggregate.php b/mod/workshop/aggregate.php index b24bb14a25..0ccb647811 100644 --- a/mod/workshop/aggregate.php +++ b/mod/workshop/aggregate.php @@ -16,7 +16,7 @@ // along with Moodle. If not, see . /** - * Aggregates the grades for submission and grades for assessments and calculates the total grade for workshop + * Aggregates the grades for submission and grades for assessments * * @package mod-workshop * @copyright 2009 David Mudrak @@ -55,7 +55,6 @@ if ($settingsform->is_cancelled()) { $workshop->aggregate_submission_grades(); // updates 'grade' in {workshop_submissions} $evaluator->update_grading_grades($settingsdata); // updates 'gradinggrade' in {workshop_assessments} $workshop->aggregate_grading_grades(); // updates 'gradinggrade' in {workshop_aggregations} - $workshop->aggregate_total_grades(); // updates 'totalgrade' in {workshop_aggregations} redirect(new moodle_url($workshop->view_url(), compact('page', 'sortby', 'sorthow'))); } diff --git a/mod/workshop/db/install.xml b/mod/workshop/db/install.xml index ea4bffa48a..8b2ab8a2af 100644 --- a/mod/workshop/db/install.xml +++ b/mod/workshop/db/install.xml @@ -1,5 +1,5 @@ - @@ -56,7 +56,8 @@ - + + @@ -105,14 +106,13 @@ - +
- - - + + diff --git a/mod/workshop/lang/en_utf8/workshop.php b/mod/workshop/lang/en_utf8/workshop.php index 698f208d05..821689b4f9 100644 --- a/mod/workshop/lang/en_utf8/workshop.php +++ b/mod/workshop/lang/en_utf8/workshop.php @@ -60,8 +60,10 @@ $string['assignedassessments'] = 'Assigned submissions to assess'; $string['assignedassessmentsnone'] = 'You have no assigned submission to assess'; $string['backtoeditform'] = 'Back to editing form'; $string['byfullname'] = 'by url}\">{$a->name}'; -$string['calculatetotalgrades'] = 'Calculate total grades'; -$string['calculatetotalgradesdetails'] = 'expected: $a->expected
calculated: $a->known'; +$string['calculategradinggrades'] = 'Calculate assessment grades'; +$string['calculategradinggradesdetails'] = 'expected: $a->expected
calculated: $a->calculated'; +$string['calculatesubmissiongrades'] = 'Calculate submission grades'; +$string['calculatesubmissiongradesdetails'] = 'expected: $a->expected
calculated: $a->calculated'; $string['configexamplesmode'] = 'Default mode of examples assessment in workshops'; $string['configgradedecimals'] = 'Default number of digits that should be shown after the decimal point when displaying grades.'; $string['configgrade'] = 'Default maximum grade for submission in workshops'; @@ -74,7 +76,7 @@ $string['editingassessmentform'] = 'Editing assessment form'; $string['editingsubmission'] = 'Editing submission'; $string['editsubmission'] = 'Edit submission'; $string['err_removegrademappings'] = 'Unable to remove the unused grade mappings'; -$string['evaluategradeswait'] = 'Please wait until the assessments are evaluated and total grades are calculated'; +$string['evaluategradeswait'] = 'Please wait until the assessments are evaluated and the grades are calculated'; $string['evaluation'] = 'Grading evaluation'; $string['evaluationmethod'] = 'Grading evaluation method'; $string['examplesbeforeassessment'] = 'Examples are available after own submission and must be assessed before assessment phase'; @@ -168,9 +170,6 @@ $string['taskinstructauthors'] = 'Provide instructions for submitting'; $string['taskinstructreviewers'] = 'Provide instructions for assessing'; $string['taskintro'] = 'Set the workshop introduction'; $string['tasksubmit'] = 'Submit your work'; -$string['totalgradeof'] = 'Total grade (of $a)'; -$string['totalgradesmissing'] = 'Unable to calculate some total grades - they will have to be set manually in Gradebook'; -$string['totalgrade'] = 'Total grade'; $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'; diff --git a/mod/workshop/locallib.php b/mod/workshop/locallib.php index f7dca6a6ba..96a39aa550 100644 --- a/mod/workshop/locallib.php +++ b/mod/workshop/locallib.php @@ -906,31 +906,38 @@ class workshop { $phase->title = get_string('phaseevaluation', 'workshop'); $phase->tasks = array(); if (has_capability('mod/workshop:overridegrades', $this->context)) { - $authors = $this->get_potential_authors(false); - $reviewers = $this->get_potential_reviewers(false); - $expected = count($authors + $reviewers); - unset($authors); - unset($reviewers); - $known = $DB->count_records_select('workshop_aggregations', 'workshopid = ? AND totalgrade IS NOT NULL', - array($this->id)); + $expected = count($this->get_potential_authors(false)); + $calculated = $DB->count_records_select('workshop_submissions', + 'workshopid = ? AND (grade IS NOT NULL OR gradeover IS NOT NULL)', array($this->id)); $task = new stdClass(); - $task->title = get_string('calculatetotalgrades', 'workshop'); + $task->title = get_string('calculategrades', 'workshop'); $a = new stdClass(); $a->expected = $expected; - $a->known = $known; - $task->details = get_string('calculatetotalgradesdetails', 'workshop', $a); - if ($known >= $expected) { + $a->calculated = $calculated; + $task->details = get_string('calculategradesdetails', 'workshop', $a); + if ($calculated >= $expected) { $task->completed = true; } elseif ($this->phase > self::PHASE_EVALUATION) { $task->completed = false; } - $phase->tasks['calculatetotalgrade'] = $task; - if ($known > 0 and $known < $expected) { - $task = new stdClass(); - $task->title = get_string('totalgradesmissing', 'workshop'); - $task->completed = 'info'; - $phase->tasks['totalgradesmissinginfo'] = $task; + $phase->tasks['calculategradinggrade'] = $task; + + $expected = count($this->get_potential_reviewers(false)); + $calculated = $DB->count_records_select('workshop_aggregations', + 'workshopid = ? AND gradinggrade IS NOT NULL', array($this->id)); + $task = new stdClass(); + $task->title = get_string('calculategradinggrades', 'workshop'); + $a = new stdClass(); + $a->expected = $expected; + $a->calculated = $calculated; + $task->details = get_string('calculategradinggradesdetails', 'workshop', $a); + if ($calculated >= $expected) { + $task->completed = true; + } elseif ($this->phase > self::PHASE_EVALUATION) { + $task->completed = false; } + $phase->tasks['calculategradinggrade'] = $task; + } elseif ($this->phase == self::PHASE_EVALUATION) { $task = new stdClass(); $task->title = get_string('evaluategradeswait', 'workshop'); @@ -998,7 +1005,7 @@ class workshop { } if (self::PHASE_CLOSED == $newphase) { - // push the total grades into the gradebook + // push the grades into the gradebook } @@ -1033,7 +1040,7 @@ class workshop { * @param mixed $groups single group or array of groups - only show users who are in one of these group(s). Defaults to all * @param int $page the current page (for the pagination) * @param int $perpage participants per page (for the pagination) - * @param string $sortby lastname|firstname|submissiontitle|submissiongrade|gradinggrade|totalgrade + * @param string $sortby lastname|firstname|submissiontitle|submissiongrade|gradinggrade * @param string $sorthow ASC|DESC * @return stdClass data for the renderer */ @@ -1048,7 +1055,7 @@ class workshop { return array(); } - if (!in_array($sortby, array('lastname','firstname','submissiontitle','submissiongrade','gradinggrade','totalgrade'))) { + if (!in_array($sortby, array('lastname','firstname','submissiontitle','submissiongrade','gradinggrade'))) { $sortby = 'lastname'; } @@ -1075,7 +1082,7 @@ class workshop { $params['workshopid2'] = $this->id; $sqlsort = $sortby . ' ' . $sorthow . ',u.lastname,u.firstname,u.id'; $sql = "SELECT u.id AS userid,u.firstname,u.lastname,u.picture,u.imagealt, - s.title AS submissiontitle, s.grade AS submissiongrade, ag.gradinggrade, ag.totalgrade + s.title AS submissiontitle, 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) @@ -1217,7 +1224,6 @@ class workshop { foreach ($grades as $grade) { $grade->gradinggrade = $this->real_grading_grade($grade->gradinggrade); - $grade->totalgrade = $this->format_total_grade($grade->totalgrade); } $data = new stdClass(); @@ -1226,7 +1232,6 @@ class workshop { $data->totalcount = $numofparticipants; $data->maxgrade = $this->real_grade(100); $data->maxgradinggrade = $this->real_grading_grade(100); - $data->maxtotalgrade = $this->format_total_grade($data->maxgrade + $data->maxgradinggrade); return $data; } @@ -1271,19 +1276,6 @@ class workshop { return grade_floatval($p); } - /** - * Rounds the value from DB to be displayed - * - * @param float $raw value from {workshop_aggregations} - * @return string - */ - public function format_total_grade($raw) { - if (is_null($raw) or $raw === '') { - return null; - } - return format_float($raw, $this->gradedecimals, true); - } - /** * Calculates the real value of grade for submission * @@ -1416,43 +1408,6 @@ class workshop { $rs->close(); } - /** - * Calculates the workshop total grades for the given participant(s) - * - * @param null|int|array $restrict If null, update all reviewers, otherwise update just grades for the given reviewer(s) - * @return void - */ - public function aggregate_total_grades($restrict=null) { - global $DB; - - // fetch a recordset with all assessments to process - $sql = 'SELECT s.grade, s.gradeover, s.authorid AS userid, - ag.id AS agid, ag.gradinggrade, ag.totalgrade - FROM {workshop_submissions} s - INNER JOIN {workshop_aggregations} ag ON (ag.userid = s.authorid) - WHERE s.example=0 AND s.workshopid=:workshopid'; // to be cont. - $params = array('workshopid' => $this->id); - - if (is_null($restrict)) { - // update all users - no more conditions - } elseif (!empty($restrict)) { - list($usql, $uparams) = $DB->get_in_or_equal($restrict, SQL_PARAMS_NAMED); - $sql .= " AND ag.userid $usql"; - $params = array_merge($params, $uparams); - } else { - throw new coding_exception('Empty value is not a valid parameter here'); - } - - $sql .= ' ORDER BY ag.userid'; // this is important for bulk processing - - $rs = $DB->get_recordset_sql($sql, $params); - - foreach ($rs as $current) { - $this->aggregate_total_grades_process($current); - } - $rs->close(); - } - /** * Returns the mform the teachers use to put a feedback for the reviewer * @@ -1621,49 +1576,6 @@ class workshop { } } - /** - * Given an object with final grade for submission and final grade for assessment, updates the total grade in DB - * - * @param stdClass $data - * @return void - */ - protected function aggregate_total_grades_process(stdClass $data) { - global $DB; - - if (!is_null($data->gradeover)) { - $submissiongrade = $data->gradeover; - } else { - $submissiongrade = $data->grade; - } - - // If we do not have enough information to update totalgrade, do not do - // anything. Please note there may be a lot of reasons why the workshop - // participant does not have one of these grades - maybe she was ill or - // just did not reach the deadlines. Teacher has to fix grades in - // gradebook manually. - - if (is_null($submissiongrade) or (!empty($this->gradinggrade) and is_null($this->gradinggrade))) { - return; - } - - $totalgrade = $this->grade * $submissiongrade / 100 + $this->gradinggrade * $data->gradinggrade / 100; - - // check if the new total grade differs from the one stored in the database - if (grade_floats_different($totalgrade, $data->totalgrade)) { - // we need to save new calculation into the database - if (is_null($data->agid)) { - // no aggregation record yet - $record = new stdClass(); - $record->workshopid = $this->id; - $record->userid = $data->userid; - $record->totalgrade = $totalgrade; - $DB->insert_record('workshop_aggregations', $record); - } else { - $DB->set_field('workshop_aggregations', 'totalgrade', $totalgrade, array('id' => $data->agid)); - } - } - } - /** * Given a list of user ids, returns the filtered one containing just ids of users with own submission * diff --git a/mod/workshop/renderer.php b/mod/workshop/renderer.php index 43be8cf148..ffbfbb39f4 100644 --- a/mod/workshop/renderer.php +++ b/mod/workshop/renderer.php @@ -402,7 +402,7 @@ class moodle_mod_workshop_renderer extends moodle_renderer_base { * * @param stdClass $data prepared by {@link workshop::prepare_grading_report()} * @param stdClass $options display options object with properties ->showauthornames ->showreviewernames ->sortby ->sorthow - * ->showsubmissiongrade ->showgradinggrade ->showtotalgrade + * ->showsubmissiongrade ->showgradinggrade * @return string html code */ public function grading_report(stdClass $data, stdClass $options) { @@ -438,10 +438,6 @@ class moodle_mod_workshop_renderer extends moodle_renderer_base { $table->head[] = $this->sortable_heading(get_string('gradinggradeof', 'workshop', $data->maxgradinggrade), 'gradinggrade', $options->sortby, $options->sorthow); } - if ($options->showtotalgrade) { - $table->head[] = $this->sortable_heading(get_string('totalgradeof', 'workshop', $data->maxtotalgrade), - 'totalgrade', $options->sortby, $options->sorthow); - } $table->rowclasses = array(); $table->colclasses = array(); @@ -536,19 +532,7 @@ class moodle_mod_workshop_renderer extends moodle_renderer_base { $cell->add_class('gradinggrade'); $row->cells[] = $cell; } - // column #7 - total grade for assessment - if ($options->showtotalgrade and $tr == 0) { - $cell = new html_table_cell(); - if (is_null($participant->totalgrade)) { - $cell->text = get_string('nullgrade', 'workshop'); - } else { - $cell->text = $participant->totalgrade; - } - $cell->text = $this->grading_report_grade($participant->totalgrade); - $cell->rowspan = $numoftrs; - $cell->add_class('totalgrade'); - $row->cells[] = $cell; - } + $table->data[] = $row; } } diff --git a/mod/workshop/simpletest/testlocallib.php b/mod/workshop/simpletest/testlocallib.php index cd7a92bbe4..dee410936e 100644 --- a/mod/workshop/simpletest/testlocallib.php +++ b/mod/workshop/simpletest/testlocallib.php @@ -50,9 +50,6 @@ class testable_workshop extends workshop { parent::aggregate_grading_grades_process($assessments); } - public function aggregate_total_grades_process(stdClass $data) { - parent::aggregate_total_grades_process($data); - } } /** @@ -327,123 +324,6 @@ class workshop_internal_api_test extends UnitTestCase { $this->workshop->aggregate_grading_grades_process($batch); } - public function test_aggregate_total_grades_process_normal_new() { - global $DB; - - // fixture set-up - $this->workshop->grade = 85; - $this->workshop->gradinggrade = 15; - - $data = new stdClass(); - $data->agid = 1; - $data->grade = 95.00000; - $data->gradeover = null; - $data->gradinggrade = 67.34500; - $data->totalgrade = null; - - $expected = grade_floatval(0.95 * 85 + 0.67345 * 15); - $DB->expectOnce('set_field', array('workshop_aggregations', 'totalgrade', $expected, array('id' => 1))); - // excercise SUT - $this->workshop->aggregate_total_grades_process($data); - } - - public function test_aggregate_total_grades_process_overriden_new() { - global $DB; - - // fixture set-up - $this->workshop->grade = 80; - $this->workshop->gradinggrade = 20; - - $data = new stdClass(); - $data->agid = 2; - $data->grade = 95.00000; - $data->gradeover = 87.5; - $data->gradinggrade = 67.34500; - $data->totalgrade = null; - - $expected = grade_floatval(0.875 * 80 + 0.67345 * 20); - $DB->expectOnce('set_field', array('workshop_aggregations', 'totalgrade', $expected, array('id' => 2))); - // excercise SUT - $this->workshop->aggregate_total_grades_process($data); - } - - public function test_aggregate_total_grades_process_uptodate() { - global $DB; - - // fixture set-up - $this->workshop->grade = 100; - $this->workshop->gradinggrade = 100; - - $data = new stdClass(); - $data->agid = 3; - $data->grade = 45.00000; - $data->gradeover = null; - $data->gradinggrade = 40.00000; - $data->totalgrade = 85.00000; - - $DB->expectNever('set_field'); - // excercise SUT - $this->workshop->aggregate_total_grades_process($data); - } - - public function test_aggregate_total_grades_process_null_grade() { - global $DB; - - // fixture set-up - $this->workshop->grade = 70; - $this->workshop->gradinggrade = 30; - - $data = new stdClass(); - $data->agid = 4; - $data->grade = null; - $data->gradeover = null; - $data->gradinggrade = 95.00000; - $data->totalgrade = null; - - $DB->expectNever('set_field'); - // excercise SUT - $this->workshop->aggregate_total_grades_process($data); - } - - /* - public function test_aggregate_total_grades_process_null_gradinggrade() { - global $DB; - - // fixture set-up - $this->workshop->grade = 70; - $this->workshop->gradinggrade = 30; - - $data = new stdClass(); - $data->agid = 5; - $data->grade = 12.12345; - $data->gradeover = null; - $data->gradinggrade = null; - $data->totalgrade = null; - - $DB->expectNever('set_field'); - // excercise SUT - $this->workshop->aggregate_total_grades_process($data); - } - - public function test_aggregate_total_grades_process_null_gradinggrade_of_zero() { - global $DB; - - // fixture set-up - $this->workshop->grade = 100; - $this->workshop->gradinggrade = 0; - - $data = new stdClass(); - $data->agid = 6; - $data->grade = 56.00000; - $data->gradeover = null; - $data->gradinggrade = null; - $data->totalgrade = null; - - $DB->expectOnce('set_field', array('workshop_aggregations', 'totalgrade', 56.00000, array('id' => 1))); - // excercise SUT - $this->workshop->aggregate_total_grades_process($data); - } - */ public function test_percent_to_value() { // fixture setup $total = 185; diff --git a/mod/workshop/styles.php b/mod/workshop/styles.php index 3aedbf7be0..1a13b10d26 100644 --- a/mod/workshop/styles.php +++ b/mod/workshop/styles.php @@ -446,7 +446,7 @@ .mod-workshop .grading-report .submissiongrade, .mod-workshop .grading-report .gradinggrade { text-align: center; - font-size: 160%; + font-size: 200%; white-space: nowrap; } @@ -455,11 +455,6 @@ color: #ee0000; } -.mod-workshop .grading-report .totalgrade { - text-align: center; - font-size: 220%; -} - /** * Edit assessment form */ diff --git a/mod/workshop/version.php b/mod/workshop/version.php index 883bc25d61..9337d37ce9 100644 --- a/mod/workshop/version.php +++ b/mod/workshop/version.php @@ -28,6 +28,6 @@ defined('MOODLE_INTERNAL') || die(); -$module->version = 2009101500; +$module->version = 2009102900; $module->requires = 2009090400; // Requires this Moodle version $module->cron = 60; diff --git a/mod/workshop/view.php b/mod/workshop/view.php index e2f1d44f3e..fbe071de8a 100644 --- a/mod/workshop/view.php +++ b/mod/workshop/view.php @@ -145,7 +145,6 @@ case workshop::PHASE_ASSESSMENT: $reportopts->sorthow = $sorthow; $reportopts->showsubmissiongrade = false; $reportopts->showgradinggrade = false; - $reportopts->showtotalgrade = false; echo $OUTPUT->paging_bar($pagingbar); echo $wsoutput->grading_report($data, $reportopts); @@ -232,7 +231,6 @@ case workshop::PHASE_EVALUATION: $reportopts->sorthow = $sorthow; $reportopts->showsubmissiongrade = true; $reportopts->showgradinggrade = true; - $reportopts->showtotalgrade = false; // todo totalgrade to be dropped completely echo $OUTPUT->paging_bar($pagingbar); echo $wsoutput->grading_report($data, $reportopts); -- 2.39.5