|
Moodle
2.2.1
http://www.collinsharper.com
|

Full-featured workshop API
This wraps the workshop database record with a set of methods that are called from the module itself. The class should be initialized right after you get $workshop, $cm and $course records at the begining of the script.
Definition at line 45 of file locallib.php.
| __construct | ( | stdclass $ | dbrecord, |
| stdclass $ | cm, | ||
| stdclass $ | course, | ||
| stdclass $ | context = null |
||
| ) |
Initializes the workshop API instance using the data from DB
Makes deep copy of all passed records properties. Replaces integer $course attribute with a full database record (course should not be stored in instances table anyway).
| stdClass | $dbrecord | Workshop instance data from {workshop} table |
| stdClass | $cm | Course module record as returned by get_coursemodule_from_id() |
| stdClass | $course | Course record from {course} table |
| stdClass | $context | The context of the workshop instance |
Definition at line 173 of file locallib.php.

| add_allocation | ( | stdclass $ | submission, |
| $ | reviewerid, | ||
| $ | weight = 1, |
||
| $ | bulk = false |
||
| ) |
Allocate a submission to a user for review
| stdClass | $submission | Submission object with at least id property |
| int | $reviewerid | User ID |
| int | $weight | of the new assessment, from 0 to 16 |
| bool | $bulk | repeated inserts into DB expected |
Definition at line 970 of file locallib.php.


| aggregate_grading_grades | ( | $ | restrict = null | ) |
Calculates grades for assessment for the given participant(s)
Grade for assessment is calculated as a simple mean of all grading grades calculated by the grading evaluator. The assessment weight is not taken into account here.
| null | int | array | $restrict | If null, update all reviewers, otherwise update just grades for the given reviewer(s) |
Definition at line 1837 of file locallib.php.
| aggregate_grading_grades_process | ( | array $ | assessments, |
| $ | timegraded = null |
||
| ) | [protected] |
Given an array of all assessments done by a single reviewer, calculates the final grading grade
This calculates the simple mean of the passed grading grades. If, however, the grading grade was overridden by a teacher, the gradinggradeover value is returned and the rest of grades are ignored.
| array | $assessments | of stdclass(->reviewerid ->gradinggrade ->gradinggradeover ->aggregationid ->aggregatedgrade) |
| null | int | $timegraded | explicit timestamp of the aggregation, defaults to the current time |
Reimplemented in testable_workshop.
Definition at line 2024 of file locallib.php.


| aggregate_submission_grades | ( | $ | restrict = null | ) |
Calculates grades for submission for the given participant(s) and updates it in the database
| null | int | array | $restrict | If null, update all authors, otherwise update just grades for the given author(s) |
Definition at line 1755 of file locallib.php.
| aggregate_submission_grades_process | ( | array $ | assessments | ) | [protected] |
Given an array of all assessments of a single submission, calculates the final grade for this submission
This calculates the weighted mean of the passed assessment grades. If, however, the submission grade was overridden by a teacher, the gradeover value is returned and the rest of grades are ignored.
| array | $assessments | of stdclass(->submissionid ->submissiongrade ->gradeover ->weight ->grade) |
Reimplemented in testable_workshop.
Definition at line 1971 of file locallib.php.


| aggregate_url | ( | ) |
Definition at line 1204 of file locallib.php.
| allocation_url | ( | $ | method = null | ) |
| string | $method | allocation method |
Definition at line 1182 of file locallib.php.

| allocator_instance | ( | $ | method | ) |
Returns instance of submissions allocator
| string | $method | The name of the allocation method, must be PARAM_ALPHA |
Definition at line 1069 of file locallib.php.
| assess_url | ( | $ | assessmentid | ) |
| int | $assessmentid | The ID of assessment record |
Definition at line 1110 of file locallib.php.

| assessing_allowed | ( | $ | userid | ) |
Is the given reviewer allowed to create/edit their assessments?
| int | $userid |
Definition at line 1309 of file locallib.php.

Are reviewers allowed to create/edit their assessments of the example submissions?
Returns null if example submissions are not enabled in this workshop. Otherwise returns true or false. Note this does not check other conditions like the number of already assessed examples, examples mode etc.
Definition at line 1340 of file locallib.php.
Are the peer-reviews available to the authors?
Definition at line 1361 of file locallib.php.
| static available_assessment_weights_list | ( | ) | [static] |
Return an array of possible values of assessment weight
Note there is no real reason why the maximum value here is 16. It used to be 10 in workshop 1.x and I just decided to use the same number as in the maximum weight of a single assessment dimension. The value looks reasonable, though. Teachers who would want to assign themselves higher weight probably do not want peer assessment really...
Definition at line 308 of file locallib.php.

| static available_dimension_weights_list | ( | ) | [static] |
Return an array of possible values of assessment dimension weight
Definition at line 289 of file locallib.php.

| static available_example_modes_list | ( | ) | [static] |
Returns the localized list of supported examples modes
Definition at line 260 of file locallib.php.

| static available_maxgrades_list | ( | ) | [static] |
Returns an array of numeric values that can be used as maximum grades
Definition at line 247 of file locallib.php.

| available_phases_list | ( | ) | [protected] |
Definition at line 2118 of file locallib.php.
| static available_strategies_list | ( | ) | [static] |
Returns the list of available grading strategy methods
Definition at line 273 of file locallib.php.


Sets the given grades and received grading grades to null
This does not clear the information about how the peers filled the assessment forms, but clears the calculated grades in workshop_assessments. Therefore reviewers have to re-assess the allocated submissions.
Definition at line 1709 of file locallib.php.
| clear_grading_grades | ( | $ | restrict = null | ) |
Sets the aggregated grades for assessment to null
| null | int | array | $restrict | If null, update all reviewers, otherwise update just grades for the given reviewer(s) |
Definition at line 1809 of file locallib.php.
| clear_submission_grades | ( | $ | restrict = null | ) |
Sets the grades for submission to null
| null | int | array | $restrict | If null, update all authors, otherwise update just grades for the given author(s) |
Definition at line 1730 of file locallib.php.
| compare_url | ( | $ | sid, |
| array $ | aids | ||
| ) |
| int | $sid | submission id |
| array | $aid | of int assessment ids |
Definition at line 1148 of file locallib.php.
| creating_submission_allowed | ( | $ | userid | ) |
Is the given user allowed to create their submission?
| int | $userid |
Definition at line 1244 of file locallib.php.

| delete_assessment | ( | $ | id | ) |
Delete assessment record or records
| mixed | $id | int|array assessment id or array of assessments ids |
Definition at line 1003 of file locallib.php.

| delete_submission | ( | stdclass $ | submission | ) |
Removes the submission and all relevant data
| stdClass | $submission | record to delete |
Definition at line 825 of file locallib.php.
| editform_url | ( | ) |
Definition at line 1093 of file locallib.php.

| exassess_url | ( | $ | assessmentid | ) |
| int | $assessmentid | The ID of assessment record |
Definition at line 1120 of file locallib.php.

| excompare_url | ( | $ | sid, |
| $ | aid | ||
| ) |
| int | $sid | submission id |
| int | $aid | assessment id |
Definition at line 1165 of file locallib.php.
| exsubmission_url | ( | $ | id | ) |
| int | $id | example submission id |
Definition at line 1138 of file locallib.php.
| static gcd | ( | $ | a, |
| $ | b | ||
| ) | [static] |
Helper function returning the greatest common divisor
| int | $a | |
| int | $b |
Definition at line 323 of file locallib.php.
Returns the list of all assessments in the workshop with some data added
Fetches data from {workshop_assessments} and adds some useful information from other tables. The returned object does not contain textual fields (i.e. comments) to prevent memory lack issues.
Definition at line 841 of file locallib.php.


| get_allocations | ( | ) |
Returns the list of all allocations (i.e. assigned assessments) in the workshop
Assessments of example submissions are ignored
Definition at line 468 of file locallib.php.
| get_assessment_by_id | ( | $ | id | ) |
Get the complete information about the given assessment
| int | $id | Assessment ID |
Definition at line 869 of file locallib.php.


| get_assessment_of_submission_by_user | ( | $ | submissionid, |
| $ | reviewerid | ||
| ) |
Get the complete information about the user's assessment of the given submission
| int | $sid | submission ID |
| int | $uid | user ID of the reviewer |
Definition at line 894 of file locallib.php.

| get_assessments_by_reviewer | ( | $ | reviewerid | ) |
Get the complete information about all assessments allocated to the given reviewer
| int | $reviewerid |
Definition at line 941 of file locallib.php.


| get_assessments_of_submission | ( | $ | submissionid | ) |
Get the complete information about all assessments of the given submission
| int | $submissionid |
Definition at line 918 of file locallib.php.

| get_example_by_id | ( | $ | id | ) |
Returns full record of the given example submission
| int | $id | example submission od |
Definition at line 589 of file locallib.php.
Returns the list of example submissions in this workshop with reference assessments attached
Definition at line 601 of file locallib.php.
| get_examples_for_reviewer | ( | $ | reviewerid | ) |
Returns the list of all example submissions in this workshop with the information of assessments done by the given user
| int | $reviewerid | user id |
Definition at line 620 of file locallib.php.

| get_feedbackauthor_form | ( | moodle_url $ | actionurl, |
| stdclass $ | submission, | ||
| $ | options = array() |
||
| ) |
Returns the mform the teachers use to put a feedback for the author on their submission
| moodle_url | $actionurl | |
| stdClass | $submission | |
| array | $options | editable |
Definition at line 1930 of file locallib.php.

| get_feedbackreviewer_form | ( | moodle_url $ | actionurl, |
| stdclass $ | assessment, | ||
| $ | options = array() |
||
| ) |
Returns the mform the teachers use to put a feedback for the reviewer
| moodle_url | $actionurl | |
| stdClass | $assessment | |
| array | $options | editable, editableweight, overridablegradinggrade |
Definition at line 1894 of file locallib.php.

| get_grouped | ( | $ | users | ) |
Groups the given users by the group membership
This takes the module grouping settings into account. If "Available for group members only" is set, returns only groups withing the course module grouping. Always returns group [0] with all the given users.
| array | $users | array[userid] => stdclass{->id ->lastname ->firstname} |
Definition at line 427 of file locallib.php.


| get_potential_authors | ( | $ | musthavesubmission = true | ) |
Fetches all users with the capability mod/workshop:submit in the current context
The returned objects contain id, lastname and firstname properties and are ordered by lastname,firstname
| bool | $musthavesubmission | If true, return only users who have already submitted. All possible authors otherwise. |
Definition at line 389 of file locallib.php.


| get_potential_reviewers | ( | $ | musthavesubmission = false | ) |
Fetches all users with the capability mod/workshop:peerassess in the current context
The returned objects contain id, lastname and firstname properties and are ordered by lastname,firstname
| bool | $musthavesubmission | If true, return only users who have already submitted. All possible users otherwise. |
Definition at line 407 of file locallib.php.


| get_published_submissions | ( | $ | orderby = 'finalgrade DESC' | ) |
Returns published submissions with their authors data
Definition at line 568 of file locallib.php.

| get_submission_by_author | ( | $ | authorid | ) |
Returns a submission submitted by the given author
| int | $id | author id |
Definition at line 546 of file locallib.php.


| get_submission_by_id | ( | $ | id | ) |
Returns a submission record with the author's data
| int | $id | submission id |
Definition at line 524 of file locallib.php.

| get_submissions | ( | $ | authorid = 'all' | ) |
Returns submissions from this workshop
Fetches data from {workshop_submissions} and adds some useful information from other tables. Does not return textual fields to prevent possible memory lack issues.
| mixed | $authorid | int|array|'all' If set to [array of] integer, return submission[s] of the given user[s] only |
Definition at line 489 of file locallib.php.


Returns instance of grading evaluation class
Definition at line 1044 of file locallib.php.
Returns instance of grading strategy class
Definition at line 1020 of file locallib.php.

| static installed_allocators | ( | ) | [static] |
Return list of available allocation methods
Definition at line 198 of file locallib.php.

| static instruction_editors_options | ( | stdclass $ | context | ) | [static] |
Returns an array of options for the editors that are used for submitting and assessing instructions
| stdClass | $context | EDITOR_UNLIMITED_FILES hard-coded value for the 'maxfiles' option |
Definition at line 222 of file locallib.php.

| static lcm | ( | $ | a, |
| $ | b | ||
| ) | [static] |
Helper function returning the least common multiple
| int | $a | |
| int | $b |
Definition at line 334 of file locallib.php.

| log | ( | $ | action, |
| moodle_url $ | url = null, |
||
| $ | info = null |
||
| ) |
Workshop wrapper around {
| string | $action | to be logged |
| moodle_url | $url | absolute url as returned by { |
| mixed | $info | additional info, usually id in a table |
Definition at line 1224 of file locallib.php.

| log_convert_url | ( | moodle_url $ | fullurl | ) | [protected] |
Converts absolute URL to relative URL needed by {
| moodle_url | $url | absolute URL |
Definition at line 2134 of file locallib.php.

| modifying_submission_allowed | ( | $ | userid | ) |
Is the given user allowed to modify their existing submission?
| int | $userid |
Definition at line 1283 of file locallib.php.

| static percent_to_value | ( | $ | percent, |
| $ | total | ||
| ) | [static] |
Given the percent and the total, returns the number
| float | $percent | from 0 to 100 |
| float | $total | the 100% value |
Definition at line 234 of file locallib.php.

| prepare_assessment | ( | stdClass $ | record, |
| $ | form, | ||
| array $ | options = array() |
||
| ) |
Prepares renderable assessment component
The $options array supports the following keys: showauthor - should the author user info be available for the renderer showreviewer - should the reviewer user info be available for the renderer showform - show the assessment form if it is available showweight - should the assessment weight be available for the renderer
| stdClass | $record | as returned by eg self::get_assessment_by_id() |
| workshop_assessment_form | null | $form | as returned by workshop_strategy::get_assessment_form() |
| array | $options |
Definition at line 723 of file locallib.php.

| prepare_example_assessment | ( | stdClass $ | record, |
| $ | form = null, |
||
| array $ | options = array() |
||
| ) |
Prepares renderable example submission's assessment component
The $options array supports the following keys: showauthor - should the author user info be available for the renderer showreviewer - should the reviewer user info be available for the renderer showform - show the assessment form if it is available
| stdClass | $record | as returned by eg self::get_assessment_by_id() |
| workshop_assessment_form | null | $form | as returned by workshop_strategy::get_assessment_form() |
| array | $options |
Definition at line 761 of file locallib.php.


| prepare_example_reference_assessment | ( | stdClass $ | record, |
| $ | form = null, |
||
| array $ | options = array() |
||
| ) |
Prepares renderable example submission's reference assessment component
The $options array supports the following keys: showauthor - should the author user info be available for the renderer showreviewer - should the reviewer user info be available for the renderer showform - show the assessment form if it is available
| stdClass | $record | as returned by eg self::get_assessment_by_id() |
| workshop_assessment_form | null | $form | as returned by workshop_strategy::get_assessment_form() |
| array | $options |
Definition at line 797 of file locallib.php.


| prepare_example_submission | ( | stdClass $ | record | ) |
Prepares renderable example submission component
| stdClass | $record | required by { |
Definition at line 671 of file locallib.php.
| prepare_example_summary | ( | stdClass $ | example | ) |
Prepares renderable example submission summary component
If the example is editable, the caller must set the 'editable' flag explicitly.
| stdClass | $example | as returned by workshop::get_examples_for_manager() or workshop::get_examples_for_reviewer() |
Definition at line 686 of file locallib.php.

| prepare_grading_report_data | ( | $ | userid, |
| $ | groups, | ||
| $ | page, | ||
| $ | perpage, | ||
| $ | sortby, | ||
| $ | sorthow | ||
| ) |
Prepares data object with all workshop grades to be rendered
| int | $userid | the user we are preparing the report for |
| mixed | $groups | single group or array of groups - only show users who are in one of these group(s). Defaults to all |
| int | $page | the current page (for the pagination) |
| int | $perpage | participants per page (for the pagination) |
| string | $sortby | lastname|firstname|submissiontitle|submissiongrade|gradinggrade |
| string | $sorthow | ASC|DESC |
Definition at line 1429 of file locallib.php.

| prepare_submission | ( | stdClass $ | record, |
| $ | showauthor = false |
||
| ) |
Prepares renderable submission component
| stdClass | $record | required by { |
| bool | $showauthor | show the author-related information |
Definition at line 642 of file locallib.php.
| prepare_submission_summary | ( | stdClass $ | record, |
| $ | showauthor = false |
||
| ) |
Prepares renderable submission summary component
| stdClass | $record | required by { |
| bool | $showauthor | show the author-related information |
Definition at line 657 of file locallib.php.
| previewform_url | ( | ) |
Definition at line 1101 of file locallib.php.
| raw_grade_value | ( | $ | value, |
| $ | max | ||
| ) |
Calculates the raw (percentual) value from a real grade
This is used in cases when a user wants to give a grade such as 12 of 20 and we need to save this value in a raw percentual form into DB
| float | $value | given grade |
| float | $max | the maximal grade |
Definition at line 1666 of file locallib.php.

| real_grade | ( | $ | value | ) |
Calculates the real value of grade for submission
| float | $value | percentual value from 0 to 100 |
Definition at line 1686 of file locallib.php.
| real_grade_value | ( | $ | value, |
| $ | max | ||
| ) |
Calculates the real value of a grade
| float | $value | percentual value from 0 to 100 |
| float | $max | the maximal grade |
Definition at line 1646 of file locallib.php.

| real_grading_grade | ( | $ | value | ) |
Calculates the real value of grade for assessment
| float | $value | percentual value from 0 to 100 |
Definition at line 1696 of file locallib.php.
| set_peer_grade | ( | $ | assessmentid, |
| $ | grade | ||
| ) |
Saves a raw grade for submission as calculated from the assessment form fields
| array | $assessmentid | assessment record id, must exists |
| mixed | $grade | raw percentual grade from 0.00000 to 100.00000 |
Definition at line 1404 of file locallib.php.

| submission_url | ( | $ | id = null | ) |
Definition at line 1129 of file locallib.php.

| switch_phase | ( | $ | newphase | ) |
Switch to a new workshop phase
Modifies the underlying database record. You should terminate the script shortly after calling this.
| int | $newphase | new phase code |
Definition at line 1373 of file locallib.php.

| switchphase_url | ( | $ | phasecode | ) |
| int | $phasecode | The internal phase code |
Definition at line 1195 of file locallib.php.


| static timestamp_formats | ( | $ | timestamp | ) | [static] |
Returns an object suitable for strings containing dates/times
The returned object contains properties date, datefullshort, datetime, ... containing the given timestamp formatted using strftimedate, strftimedatefullshort, strftimedatetime, ... from the current lang's langconfig.php This allows translators and administrators customize the date/time format.
| int | $timestamp | the timestamp in UTC |
Definition at line 349 of file locallib.php.


| toolbox_url | ( | $ | tool | ) |
Definition at line 1212 of file locallib.php.
| updatemod_url | ( | ) |
Definition at line 1173 of file locallib.php.

| users_with_submission | ( | array $ | userids | ) | [protected] |
Given a list of user ids, returns the filtered one containing just ids of users with own submission
Example submissions are ignored.
| array | $userids |
Definition at line 2094 of file locallib.php.
| view_url | ( | ) |
Definition at line 1085 of file locallib.php.
| $assessmentend |
Definition at line 148 of file locallib.php.
| $assessmentstart |
Definition at line 145 of file locallib.php.
| $cm |
Definition at line 64 of file locallib.php.
Definition at line 70 of file locallib.php.
Definition at line 67 of file locallib.php.
| $evaluation |
Definition at line 121 of file locallib.php.
$evaluationinstance = null [protected] |
Definition at line 160 of file locallib.php.
| $examplesmode |
Definition at line 136 of file locallib.php.
| $grade |
Definition at line 112 of file locallib.php.
| $gradedecimals |
Definition at line 124 of file locallib.php.
| $gradinggrade |
Definition at line 115 of file locallib.php.
| $id |
Definition at line 73 of file locallib.php.
| $instructauthors |
Definition at line 85 of file locallib.php.
| $instructauthorsformat |
Definition at line 88 of file locallib.php.
| $instructreviewers |
Definition at line 91 of file locallib.php.
| $instructreviewersformat |
Definition at line 94 of file locallib.php.
| $intro |
Definition at line 79 of file locallib.php.
| $introformat |
Definition at line 82 of file locallib.php.
| $latesubmissions |
Definition at line 130 of file locallib.php.
| $maxbytes |
Definition at line 133 of file locallib.php.
| $name |
Definition at line 76 of file locallib.php.
| $nattachments |
Definition at line 127 of file locallib.php.
| $phase |
Definition at line 100 of file locallib.php.
| $strategy |
Definition at line 118 of file locallib.php.
$strategyinstance = null [protected] |
Definition at line 154 of file locallib.php.
| $submissionend |
Definition at line 142 of file locallib.php.
| $submissionstart |
Definition at line 139 of file locallib.php.
| $timemodified |
Definition at line 97 of file locallib.php.
| $useexamples |
Definition at line 103 of file locallib.php.
| $usepeerassessment |
Definition at line 106 of file locallib.php.
| $useselfassessment |
Definition at line 109 of file locallib.php.
| const ALLOCATION_ERROR = -9998 |
Definition at line 49 of file locallib.php.
| const ALLOCATION_EXISTS = -9999 |
return statuses of add_allocation to be passed to a workshop renderer method
Definition at line 48 of file locallib.php.
| const EXAMPLES_BEFORE_ASSESSMENT = 2 |
Definition at line 61 of file locallib.php.
| const EXAMPLES_BEFORE_SUBMISSION = 1 |
Definition at line 60 of file locallib.php.
| const EXAMPLES_VOLUNTARY = 0 |
the internal code of the examples modes as are stored in the database
Definition at line 59 of file locallib.php.
| const PHASE_ASSESSMENT = 30 |
Definition at line 54 of file locallib.php.
| const PHASE_CLOSED = 50 |
Definition at line 56 of file locallib.php.
| const PHASE_EVALUATION = 40 |
Definition at line 55 of file locallib.php.
| const PHASE_SETUP = 10 |
the internal code of the workshop phases as are stored in the database
Definition at line 52 of file locallib.php.
| const PHASE_SUBMISSION = 20 |
Definition at line 53 of file locallib.php.