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 403]

This file defines a class with "Number of errors" grading strategy logic

Copyright: 2009 David Mudrak <david.mudrak@gmail.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 620 lines (25 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 3 files
 mod/workshop/form/lib.php
 mod/workshop/form/numerrors/edit_form.php
 mod/workshop/form/numerrors/assessment_form.php

Defines 1 class

Defines 19 functions


Class: workshop_numerrors_strategy  - X-Ref

"Number of errors" grading strategy logic.

__construct(workshop $workshop)   X-Ref
Constructor

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

get_edit_strategy_form($actionurl=null)   X-Ref
Factory method returning an instance of an assessment form editor class

param: $actionurl URL of form handler, defaults to auto detect the current url

save_edit_strategy_form(stdclass $data)   X-Ref
Save the assessment dimensions into database

Saves data into the main strategy form table. If the record->id is null or zero,
new record is created. If the record->id is not empty, the existing record is updated. Records with
empty 'description' field are removed from database.
The passed data object are the raw data returned by the get_data().

return: void
param: stdClass $data Raw data returned by the dimension editor form

get_assessment_form(moodle_url $actionurl=null, $mode='preview', stdclass $assessment=null, $editable=true, $options=array()   X-Ref
Factory method returning an instance of an assessment form

param: moodle_url $actionurl URL of form handler, defaults to auto detect the current url
param: string $mode          Mode to open the form in: preview/assessment
param: stdClass $assessment
param: bool $editable
param: array $options

save_assessment(stdclass $assessment, stdclass $data)   X-Ref
Saves the filled assessment

This method processes data submitted using the form returned by {@link get_assessment_form()}

return: float|null          Raw grade (from 0.00000 to 100.00000) for submission as suggested by the peer
param: stdClass $assessment Assessment being filled
param: stdClass $data       Raw data as returned by the assessment form

form_ready()   X-Ref
Has the assessment form been defined and is ready to be used by the reviewers?

return: boolean

get_assessments_recordset($restrict=null)   X-Ref


get_dimensions_info()   X-Ref


scale_used($scaleid, $workshopid=null)   X-Ref
Is a given scale used by the instance of workshop?

This grading strategy does not use scales.

return: bool
param: int $scaleid id of the scale to check
param: int|null $workshopid id of workshop instance to check, checks all in case of null

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

load_fields()   X-Ref
Loads the fields of the assessment form currently used in this workshop

return: array definition of assessment dimensions

load_mappings()   X-Ref
Loads the mappings of the number of errors to the grade

return: array of records

prepare_form_fields(array $dims, array $maps)   X-Ref
Prepares the database data to be used by the mform

return: array Array of fields data to be used by the mform set_data
param: array $dims Array of raw dimension records as returned by {@link load_fields()}
param: array $maps Array of raw mapping records as returned by {@link load_mappings()}

delete_dimensions(array $ids)   X-Ref
Deletes dimensions and removes embedded media from its descriptions

todo we may check that there are no assessments done using these dimensions and probably remove them

return: void
param: array $ids list to delete

prepare_database_fields(stdclass $raw)   X-Ref
Prepares data returned by {@link workshop_edit_numerrors_strategy_form} so they can be saved into database

It automatically adds some columns into every record. The sorting is
done by the order of the returned array and starts with 1.
Called internally from {@link save_edit_strategy_form()} only. Could be private but
keeping protected for unit testing purposes.

return: array Array of objects to be inserted/updated in DB
param: stdClass $raw Raw data returned by mform

get_current_assessment_data(stdclass $assessment)   X-Ref
Returns the list of current grades filled by the reviewer

return: array of filtered records from the table workshop_grades
param: stdClass $assessment Assessment record

update_peer_grade(stdclass $assessment)   X-Ref
Aggregates the assessment form data and sets the grade for the submission given by the peer

return: float|null          Raw grade (0.00000 to 100.00000) for submission as suggested by the peer
param: stdClass $assessment Assessment record

calculate_peer_grade(array $grades)   X-Ref
Calculates the aggregated grade given by the reviewer

return: float|null   Raw grade (0.00000 to 100.00000) for submission as suggested by the peer
param: array $grades Grade records as returned by {@link get_current_assessment_data}

errors_to_grade($numerrors)   X-Ref
Returns a grade 0.00000 to 100.00000 for the given number of errors

This is where we use the mapping table defined by the teacher. If a grade for the given
number of errors (negative assertions) is not defined, the most recently defined one is used.
Example of the defined mapping:
Number of errors | Grade
0 | 100%  (always)
1 | -     (not defined)
2 | 80%
3 | 60%
4 | -
5 | 30%
6 | 0%
With this mapping, one error is mapped to 100% grade and 4 errors is mapped to 60%.

return: float          Raw grade (0.00000 to 100.00000) for the given number of negative assertions
param: mixed $numerrors Number of errors

Functions that are not part of a class:

workshopform_numerrors_pluginfile($course, $cm, $context, $filearea, array $args, $forcedownload, array $options=array()   X-Ref
Server workshop files

return: bool
param: stdClass $course course object
param: stdClass $cm course module object
param: stdClass $context context object
param: string $filearea file area
param: array $args extra arguments
param: bool $forcedownload whether or not force download
param: array $options additional options affecting the file serving