Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 400 and 402] [Versions 400 and 403]

Contains logic class and interface for the grading evaluation plugin "Comparison with the best assessment".

Copyright: 2009 David Mudrak <david.mudrak@gmail.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 443 lines (18 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 1 file
 mod/workshop/eval/lib.php

Defines 2 classes

workshop_best_evaluation:: (10 methods):
  __construct()
  update_grading_grades()
  get_settings_form()
  delete_instance()
  process_assessments()
  prepare_data_from_recordset()
  normalize_grades()
  average_assessment()
  weighted_variance()
  assessments_distance()

workshop_best_evaluation_settings_form:: (1 method):
  definition_sub()


Class: workshop_best_evaluation  - X-Ref

Defines the computation login of the grading evaluation subplugin

__construct(workshop $workshop)   X-Ref
Constructor

return: void
param: workshop $workshop The workshop api instance

update_grading_grades(stdclass $settings, $restrict=null)   X-Ref
Calculates the grades for assessment and updates 'gradinggrade' fields in 'workshop_assessments' table

This function relies on the grading strategy subplugin providing get_assessments_recordset() method.
{@see self::process_assessments()} for the required structure of the recordset.

return: void
param: stdClass $settings       The settings for this round of evaluation
param: null|int|array $restrict If null, update all reviewers, otherwise update just grades for the given reviewers(s)

get_settings_form(moodle_url $actionurl=null)   X-Ref
Returns an instance of the form to provide evaluation settings.

return: workshop_best_evaluation_settings_form

delete_instance($workshopid)   X-Ref
Delete all data related to a given workshop module instance

return: void
param: int $workshopid id of the workshop module instance being deleted

process_assessments(array $assessments, array $diminfo, stdclass $settings)   X-Ref
Given a list of all assessments of a single submission, updates the grading grades in database

return: void
param: array $assessments of stdclass (->assessmentid ->assessmentweight ->reviewerid ->gradinggrade ->submissionid ->dimensionid ->grade)
param: array $diminfo of stdclass (->id ->weight ->max ->min)
param: stdClass grading evaluation settings

prepare_data_from_recordset($assessments)   X-Ref
Prepares a structure of assessments and given grades

return: array
param: array $assessments batch of recordset items as returned by the grading strategy

normalize_grades(array $assessments, array $diminfo)   X-Ref
Normalizes the dimension grades to the interval 0.00000 - 100.00000

Note: this heavily relies on PHP5 way of handling references in array of stdclasses. Hopefully
it will not change again soon.

return: array of stdclass with the same structure as $assessments
param: array $assessments of stdclass as returned by {@see self::prepare_data_from_recordset()}
param: array $diminfo of stdclass

average_assessment(array $assessments)   X-Ref
Given a set of a submission's assessments, returns a hypothetical average assessment

The passed structure must be array of assessments objects with ->weight and ->dimgrades properties.
Returns null if all passed assessments have zero weight as there is nothing to choose
from then.

return: null|stdClass
param: array $assessments as prepared by {@link self::prepare_data_from_recordset()}

weighted_variance(array $assessments)   X-Ref
Given a set of a submission's assessments, returns standard deviations of all their dimensions

The passed structure must be array of assessments objects with at least ->weight
and ->dimgrades properties. This implementation uses weighted incremental algorithm as
suggested in "D. H. D. West (1979). Communications of the ACM, 22, 9, 532-535:
Updating Mean and Variance Estimates: An Improved Method"
{@link http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Weighted_incremental_algorithm}

return: null|array indexed by dimension id
param: array $assessments as prepared by {@link self::prepare_data_from_recordset()}

assessments_distance(stdclass $assessment, stdclass $referential, array $diminfo, stdclass $settings)   X-Ref
Measures the distance of the assessment from a referential one

The passed data structures must contain ->dimgrades property. The referential
assessment is supposed to be close to the average assessment. All dimension grades are supposed to be
normalized to the interval 0 - 100.
Returned value is rounded to 4 valid decimals to prevent some rounding issues - see the unit test
for an example.

return: float|null rounded to 4 valid decimals
param: stdClass $assessment the assessment being measured
param: stdClass $referential assessment
param: array $diminfo of stdclass(->weight ->min ->max ->variance) indexed by dimension id
param: stdClass $settings

Class: workshop_best_evaluation_settings_form  - X-Ref

Represents the settings form for this plugin.

definition_sub()   X-Ref
Defines specific fields for this evaluation method.