Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 401 and 402] [Versions 401 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: 1 time
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

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

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.

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)
return: void

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

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

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

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
return: void

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

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

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.

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

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.

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

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}

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

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.

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
return: float|null rounded to 4 valid decimals

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.