Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
|
Full-featured workshop API. More...
Public Member Functions | |
__construct (stdclass $dbrecord, $cm, $course, stdclass $context=null) | |
Initializes the workshop API instance using the data from DB. More... | |
add_allocation (stdclass $submission, $reviewerid, $weight=1, $bulk=false) | |
Allocate a submission to a user for review. More... | |
aggregate_grading_grades ($restrict=null) | |
Calculates grades for assessment for the given participant(s) More... | |
aggregate_submission_grades ($restrict=null) | |
Calculates grades for submission for the given participant(s) and updates it in the database. More... | |
aggregate_url () | |
allocation_url ($method=null) | |
allocator_instance ($method) | |
Returns instance of submissions allocator. More... | |
assess_url ($assessmentid) | |
assessing_allowed ($userid) | |
Is the given reviewer allowed to create/edit their assessments? More... | |
assessing_examples_allowed () | |
Are reviewers allowed to create/edit their assessments of the example submissions? More... | |
assessments_available () | |
Are the peer-reviews available to the authors? More... | |
check_edit_assessment ($assessment, $submission) | |
Helper method for validating if the current user can edit the given assessment. More... | |
check_examples_assessed_before_assessment ($userid) | |
Check that all required examples have been assessed by the given user. More... | |
check_examples_assessed_before_submission ($userid) | |
Check whether the given user has assessed all his required examples before submission. More... | |
check_group_membership ($otheruserid) | |
Check if the current user can access the other user's group. More... | |
check_view_assessment ($assessment, $submission) | |
Helper method for validating if the current user can view the given assessment. More... | |
clear_assessments () | |
Sets the given grades and received grading grades to null. More... | |
clear_grading_grades ($restrict=null) | |
Sets the aggregated grades for assessment to null. More... | |
clear_submission_grades ($restrict=null) | |
Sets the grades for submission to null. More... | |
compare_url ($sid, array $aids) | |
count_participants ($musthavesubmission=false, $groupid=0) | |
Returns the total number of records that would be returned by self::get_participants(). More... | |
count_potential_authors ($musthavesubmission=true, $groupid=0) | |
Returns the total number of users that would be fetched by self::get_potential_authors(). More... | |
count_potential_reviewers ($musthavesubmission=false, $groupid=0) | |
Returns the total number of users that would be fetched by self::get_potential_reviewers(). More... | |
count_submissions ($authorid='all', $groupid=0) | |
Returns the total number of records that would be returned by self::get_submissions(). More... | |
creating_submission_allowed ($userid) | |
Is the given user allowed to create their submission? More... | |
delete_assessment ($id) | |
Delete assessment record or records. More... | |
delete_submission (stdclass $submission) | |
Removes the submission and all relevant data. More... | |
edit_assessment ($assessment, $submission, $data, $strategy) | |
Adds information to an allocated assessment (function used the first time a review is done or when updating an existing one). More... | |
edit_submission ($submission) | |
Adds or updates a submission. More... | |
editform_url () | |
evaluate_assessment ($assessment, $data, $cansetassessmentweight, $canoverridegrades) | |
Evaluates an assessment. More... | |
evaluate_submission ($submission, $data, $canpublish, $canoverride) | |
Evaluates a submission. More... | |
exassess_url ($assessmentid) | |
excompare_url ($sid, $aid) | |
exsubmission_url ($id) | |
get_all_assessments () | |
Returns the list of all assessments in the workshop with some data added. More... | |
get_allocations () | |
Returns the list of all allocations (i.e. More... | |
get_assessment_by_id ($id) | |
Get the complete information about the given assessment. More... | |
get_assessment_of_submission_by_user ($submissionid, $reviewerid) | |
Get the complete information about the user's assessment of the given submission. More... | |
get_assessments_by_reviewer ($reviewerid) | |
Get the complete information about all assessments allocated to the given reviewer. More... | |
get_assessments_of_submission ($submissionid) | |
Get the complete information about all assessments of the given submission. More... | |
get_example_by_id ($id) | |
Returns full record of the given example submission. More... | |
get_examples_for_manager () | |
Returns the list of example submissions in this workshop with reference assessments attached. More... | |
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. More... | |
get_feedbackauthor_form ($actionurl, stdclass $submission, $options=array()) | |
Returns the mform the teachers use to put a feedback for the author on their submission. More... | |
get_feedbackreviewer_form ($actionurl, stdclass $assessment, $options=array()) | |
Returns the mform the teachers use to put a feedback for the reviewer. More... | |
get_gradebook_grades ($userid) | |
Returns the information about the user's grades as they are stored in the gradebook. More... | |
get_grouped ($users) | |
Groups the given users by the group membership. More... | |
get_participants ($musthavesubmission=false, $groupid=0, $limitfrom=0, $limitnum=0) | |
Fetches all enrolled users that are authors or reviewers (or both) in the current workshop. More... | |
get_pending_assessments_by_reviewer ($reviewerid, $exclude=null) | |
Get allocated assessments not graded yet by the given reviewer. More... | |
get_potential_authors ($musthavesubmission=true, $groupid=0, $limitfrom=0, $limitnum=0) | |
Fetches all enrolled users with the capability mod/workshop:submit in the current workshop. More... | |
get_potential_reviewers ($musthavesubmission=false, $groupid=0, $limitfrom=0, $limitnum=0) | |
Fetches all enrolled users with the capability mod/workshop:peerassess in the current workshop. More... | |
get_published_submissions ($orderby='finalgrade DESC') | |
Returns published submissions with their authors data. More... | |
get_submission_by_author ($authorid) | |
Returns a submission submitted by the given author. More... | |
get_submission_by_id ($id) | |
Returns a submission record with the author's data. More... | |
get_submissions ($authorid='all', $groupid=0, $limitfrom=0, $limitnum=0) | |
Returns submissions from this workshop. More... | |
get_visible_submissions ($authorid=0, $groupid=0, $limitfrom=0, $limitnum=0) | |
Returns submissions from this workshop that are viewable by the current user (except example submissions). More... | |
grading_evaluation_instance () | |
Returns instance of grading evaluation class. More... | |
grading_strategy_instance () | |
Returns instance of grading strategy class. More... | |
is_participant ($userid=null) | |
Checks if the given user is an actively enrolled participant in the workshop. More... | |
log ($action, moodle_url $url=null, $info=null, $return=false) | |
Workshop wrapper around {. More... | |
modifying_submission_allowed ($userid) | |
Is the given user allowed to modify their existing submission? More... | |
overall_feedback_attachment_options () | |
Return the filemanager options for the overall feedback for the author. More... | |
overall_feedback_content_options () | |
Return the editor options for the overall feedback for the author. More... | |
prepare_assessment (stdClass $record, $form, array $options=array()) | |
Prepares renderable assessment component. More... | |
prepare_example_assessment (stdClass $record, $form=null, array $options=array()) | |
Prepares renderable example submission's assessment component. More... | |
prepare_example_reference_assessment (stdClass $record, $form=null, array $options=array()) | |
Prepares renderable example submission's reference assessment component. More... | |
prepare_example_submission (stdClass $record) | |
Prepares renderable example submission component. More... | |
prepare_example_summary (stdClass $example) | |
Prepares renderable example submission summary component. More... | |
prepare_grading_report_data ($userid, $groupid, $page, $perpage, $sortby, $sorthow) | |
Prepares data object with all workshop grades to be rendered. More... | |
prepare_submission (stdClass $record, $showauthor=false) | |
Prepares renderable submission component. More... | |
prepare_submission_summary (stdClass $record, $showauthor=false) | |
Prepares renderable submission summary component. More... | |
previewform_url () | |
raw_grade_value ($value, $max) | |
Calculates the raw (percentual) value from a real grade. More... | |
real_grade ($value) | |
Calculates the real value of grade for submission. More... | |
real_grade_value ($value, $max) | |
Calculates the real value of a grade. More... | |
real_grading_grade ($value) | |
Calculates the real value of grade for assessment. More... | |
reset_userdata (stdClass $data) | |
Performs the reset of this workshop instance. More... | |
set_grading_evaluation_method ($method) | |
Sets the current evaluation method to the given plugin. More... | |
set_module_viewed () | |
Trigger module viewed event and set the module viewed for completion. More... | |
set_peer_grade ($assessmentid, $grade) | |
Saves a raw grade for submission as calculated from the assessment form fields. More... | |
set_submission_viewed ($submission) | |
Trigger submission viewed event. More... | |
submission_attachment_options () | |
Return the filemanager options for the submission attachments field. More... | |
submission_content_options () | |
Return the editor options for the submission content field. More... | |
submission_url ($id=null) | |
switch_phase ($newphase) | |
Switch to a new workshop phase. More... | |
switchphase_url ($phasecode) | |
toolbox_url ($tool) | |
updatemod_url () | |
validate_submission_data ($data) | |
Validates the submission form or WS data. More... | |
view_url () | |
Static Public Member Functions | |
static | available_assessment_weights_list () |
Return an array of possible values of assessment weight. More... | |
static | available_dimension_weights_list () |
Return an array of possible values of assessment dimension weight. More... | |
static | available_evaluators_list () |
Returns the list of available grading evaluation methods. More... | |
static | available_example_modes_list () |
Returns the localized list of supported examples modes. More... | |
static | available_maxgrades_list () |
Returns an array of numeric values that can be used as maximum grades. More... | |
static | available_strategies_list () |
Returns the list of available grading strategy methods. More... | |
static | clean_file_extensions ($extensions) |
Cleans the user provided list of file extensions. More... | |
static | gcd ($a, $b) |
Helper function returning the greatest common divisor. More... | |
static | installed_allocators () |
Return list of available allocation methods. More... | |
static | instruction_editors_options (stdclass $context) |
Returns an array of options for the editors that are used for submitting and assessing instructions. More... | |
static | invalid_file_extensions ($extensions, $whitelist) |
Check given file types and return invalid/unknown ones. More... | |
static | is_allowed_file_type ($filename, $whitelist) |
Is the file have allowed to be uploaded to the workshop? More... | |
static | lcm ($a, $b) |
Helper function returning the least common multiple. More... | |
static | normalize_file_extensions ($extensions) |
Converts the argument into an array (list) of file extensions. More... | |
static | percent_to_value ($percent, $total) |
Given the percent and the total, returns the number. More... | |
static | timestamp_formats ($timestamp) |
Returns an object suitable for strings containing dates/times. More... | |
Public Attributes | |
int | $assessmentend |
if greater than 0 then the peer assessment is not allowed after this timestamp | |
int | $assessmentstart |
if greater than 0 then the peer assessment is not allowed before this timestamp | |
cm_info | $cm |
course module record | |
string | $conclusion |
conclusion text to be displayed at the end of the activity | |
int | $conclusionformat |
format of the conclusion text | |
stdclass | $context |
context object | |
stdclass | $course |
course record | |
stdclass | $dbrecord |
workshop record from database | |
string | $evaluation |
the name of the evaluation plugin to use for grading grades calculation | |
int | $examplesmode |
mode of example submissions support, for example workshop::EXAMPLES_VOLUNTARY | |
float | $grade |
number (10, 5) unsigned, the maximum grade for submission | |
int | $gradedecimals |
number of digits that should be shown after the decimal point when displaying grades | |
float | $gradinggrade |
number (10, 5) unsigned, the maximum grade for assessment | |
int | $id |
workshop instance identifier | |
string | $instructauthors |
instructions for the submission phase | |
int | $instructauthorsformat |
format of the $instructauthors | |
string | $instructreviewers |
instructions for the assessment phase | |
int | $instructreviewersformat |
format of the $instructreviewers | |
string | $intro |
introduction or description of the activity | |
int | $introformat |
format of the $intro | |
bool | $latesubmissions |
allow submitting the work after the deadline | |
int | $maxbytes |
maximum size of the one attached file in bytes | |
string | $name |
workshop activity name | |
int | $nattachments |
number of allowed submission attachments and the files embedded into submission | |
int | $overallfeedbackfiles |
maximum number of overall feedback attachments | |
string | $overallfeedbackfiletypes = null |
list of allowed file types that can be attached to the overall feedback | |
int | $overallfeedbackmaxbytes |
maximum size of one file attached to the overall feedback | |
int | $overallfeedbackmode |
the mode of the overall feedback | |
int | $phase |
current phase of workshop, for example workshop::PHASE_SETUP | |
bool | $phaseswitchassessment |
automatically switch to the assessment phase after the submissions deadline | |
string | $strategy |
type of the current grading strategy used in this workshop, for example 'accumulative' | |
int | $submissionend |
if greater than 0 then the submission is not allowed after this timestamp | |
string | $submissionfiletypes = null |
list of allowed file types that are allowed to be embedded into submission | |
int | $submissionstart |
if greater than 0 then the submission is not allowed before this timestamp | |
int | $submissiontypefile |
Should the submission form show the file attachment field? | |
int | $submissiontypetext |
Should the submission form show the text field? | |
int | $timemodified |
timestamp of when the module was modified | |
bool | $useexamples |
optional feature: students practise evaluating on example submissions from teacher | |
bool | $usepeerassessment |
optional feature: students perform peer assessment of others' work (deprecated, consider always enabled) | |
bool | $useselfassessment |
optional feature: students perform self assessment of their own work | |
const | ALLOCATION_EXISTS = -9999 |
error status of the self::add_allocation() | |
const | EXAMPLES_BEFORE_ASSESSMENT = 2 |
const | EXAMPLES_BEFORE_SUBMISSION = 1 |
const | EXAMPLES_VOLUNTARY = 0 |
the internal code of the examples modes as are stored in the database | |
const | PHASE_ASSESSMENT = 30 |
const | PHASE_CLOSED = 50 |
const | PHASE_EVALUATION = 40 |
const | PHASE_SETUP = 10 |
the internal code of the workshop phases as are stored in the database | |
const | PHASE_SUBMISSION = 20 |
Protected Member Functions | |
aggregate_grading_grades_process (array $assessments, $timegraded=null) | |
Given an array of all assessments done by a single reviewer, calculates the final grading grade. More... | |
aggregate_submission_grades_process (array $assessments) | |
Given an array of all assessments of a single submission, calculates the final grade for this submission. More... | |
available_phases_list () | |
get_participants_sql ($musthavesubmission=false, $groupid=0) | |
Returns SQL statement that can be used to fetch all actively enrolled participants in the workshop. More... | |
get_users_with_capability_sql ($capability, $musthavesubmission, $groupid) | |
Returns SQL to fetch all enrolled users with the given capability in the current workshop. More... | |
log_convert_url (moodle_url $fullurl) | |
Converts absolute URL to relative URL needed by {. More... | |
reset_phase () | |
Hard set the workshop phase to the setup one. | |
reset_userdata_assessments (stdClass $data) | |
Removes all user data related to assessments (including allocations). More... | |
reset_userdata_submissions (stdClass $data) | |
Removes all user data related to participants' submissions. More... | |
Protected Attributes | |
workshop_evaluation | $evaluationinstance = null |
grading evaluation instance Do not use directly, get the instance using workshop::grading_evaluation_instance() | |
workshop_strategy | $strategyinstance = null |
grading strategy instance Do not use directly, get the instance using workshop::grading_strategy_instance() | |
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.
workshop::__construct | ( | stdclass | $dbrecord, |
$cm, | |||
$course, | |||
stdclass | $context = null |
||
) |
Initializes the workshop API instance using the data from DB.
Makes deep copy of all passed records properties.
For unit testing only, $cm and $course may be set to null. This is so that you can test without having any real database objects if you like. Not all functions will work in this situation.
stdClass | $dbrecord | Workshop instance data from {workshop} table |
stdClass | cm_info | $cm | Course module record |
stdClass | $course | Course record from {course} table |
stdClass | $context | The context of the workshop instance |
workshop::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 |
int | ID of the new assessment or an error code self::ALLOCATION_EXISTS if the allocation already exists |
workshop::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) |
void |
|
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 |
void |
workshop::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) |
void |
|
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) |
void |
workshop::aggregate_url | ( | ) |
moodle_url | to the aggregation page |
workshop::allocation_url | ( | $method = null | ) |
string | $method | allocation method |
moodle_url | to the allocation page |
workshop::allocator_instance | ( | $method | ) |
Returns instance of submissions allocator.
string | $method | The name of the allocation method, must be PARAM_ALPHA |
stdclass | Instance of submissions allocator |
workshop::assess_url | ( | $assessmentid | ) |
int | $assessmentid | The ID of assessment record |
moodle_url | of the assessment page |
workshop::assessing_allowed | ( | $userid | ) |
Is the given reviewer allowed to create/edit their assessments?
int | $userid |
bool |
workshop::assessing_examples_allowed | ( | ) |
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.
null|bool |
workshop::assessments_available | ( | ) |
Are the peer-reviews available to the authors?
bool |
|
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...
array | of integers 0, 1, 2, ..., 16 |
|
static |
Return an array of possible values of assessment dimension weight.
array | of integers 0, 1, 2, ..., 16 |
|
static |
Returns the list of available grading evaluation methods.
array | of (string)name => (string)localized title |
|
static |
Returns the localized list of supported examples modes.
array |
|
static |
Returns an array of numeric values that can be used as maximum grades.
array | Array of integers |
|
protected |
array | of available workshop phases |
|
static |
Returns the list of available grading strategy methods.
array | ['string' => 'string'] |
workshop::check_edit_assessment | ( | $assessment, | |
$submission | |||
) |
Helper method for validating if the current user can edit the given assessment.
stdClass | $assessment | assessment object |
stdClass | $submission | submission object |
void |
moodle_exception |
workshop::check_examples_assessed_before_assessment | ( | $userid | ) |
Check that all required examples have been assessed by the given user.
stdClass | $userid | the user (reviewer) to check |
mixed | bool|state false and notice code if there are examples missing assessment, true otherwise. |
workshop::check_examples_assessed_before_submission | ( | $userid | ) |
Check whether the given user has assessed all his required examples before submission.
int | $userid | the user to check |
bool | false if there are examples missing assessment, true otherwise. |
workshop::check_group_membership | ( | $otheruserid | ) |
Check if the current user can access the other user's group.
This is typically used for teacher roles that have permissions like 'view all submissions'. Even with such a permission granted, we have to check the workshop activity group mode.
If the workshop is not in a group mode, or if it is in the visible group mode, this method returns true. This is consistent with how the groups_get_activity_allowed_groups() behaves.
If the workshop is in a separate group mode, the current user has to have the 'access all groups' permission, or share at least one accessible group with the other user.
int | $otheruserid | The ID of the other user, e.g. the author of a submission. |
bool | False if the current user cannot access the other user's group. |
workshop::check_view_assessment | ( | $assessment, | |
$submission | |||
) |
Helper method for validating if the current user can view the given assessment.
stdClass | $assessment | assessment object |
stdClass | $submission | submission object |
void |
moodle_exception |
|
static |
Cleans the user provided list of file extensions.
string | $extensions |
string |
workshop::clear_assessments | ( | ) |
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.
void |
workshop::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) |
void |
workshop::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) |
void |
workshop::compare_url | ( | $sid, | |
array | $aids | ||
) |
int | $sid | submission id |
array | $aid | of int assessment ids |
moodle_url | of the page to compare assessments of the given submission |
workshop::count_participants | ( | $musthavesubmission = false , |
|
$groupid = 0 |
|||
) |
Returns the total number of records that would be returned by self::get_participants().
bool | $musthavesubmission | if true, return only users who have already submitted |
int | $groupid | 0 means ignore groups, any other value limits the result by group id |
int |
workshop::count_potential_authors | ( | $musthavesubmission = true , |
|
$groupid = 0 |
|||
) |
Returns the total number of users that would be fetched by self::get_potential_authors().
bool | $musthavesubmission | if true, count only users who have already submitted |
int | $groupid | 0 means ignore groups, any other value limits the result by group id |
int |
workshop::count_potential_reviewers | ( | $musthavesubmission = false , |
|
$groupid = 0 |
|||
) |
Returns the total number of users that would be fetched by self::get_potential_reviewers().
bool | $musthavesubmission | if true, count only users who have already submitted |
int | $groupid | 0 means ignore groups, any other value limits the result by group id |
int |
workshop::count_submissions | ( | $authorid = 'all' , |
|
$groupid = 0 |
|||
) |
Returns the total number of records that would be returned by self::get_submissions().
mixed | $authorid | int|array|'all' If set to [array of] integer, return submission[s] of the given user[s] only |
int | $groupid | If non-zero, return only submissions by authors in the specified group |
int | number of records |
workshop::creating_submission_allowed | ( | $userid | ) |
Is the given user allowed to create their submission?
int | $userid |
bool |
workshop::delete_assessment | ( | $id | ) |
Delete assessment record or records.
Removes associated records from the workshop_grades table, too.
int | array | $id | assessment id or array of assessments ids |
bool | true |
workshop::delete_submission | ( | stdclass | $submission | ) |
Removes the submission and all relevant data.
stdClass | $submission | record to delete |
void |
workshop::edit_assessment | ( | $assessment, | |
$submission, | |||
$data, | |||
$strategy | |||
) |
Adds information to an allocated assessment (function used the first time a review is done or when updating an existing one).
stdClass | $assessment | the assessment |
stdClass | $submission | the submission |
stdClass | $data | the assessment data to be added or Updated |
stdClass | $strategy | the strategy instance |
float|null | Raw percentual grade (0.00000 to 100.00000) for submission |
workshop::edit_submission | ( | $submission | ) |
Adds or updates a submission.
stdClass | $submission | The submissin data (via form or via WS). |
the | new or updated submission id. |
workshop::editform_url | ( | ) |
moodle_url | of the page for editing this workshop's grading form |
workshop::evaluate_assessment | ( | $assessment, | |
$data, | |||
$cansetassessmentweight, | |||
$canoverridegrades | |||
) |
Evaluates an assessment.
stdClass | $assessment | the assessment |
stdClass | $data | the assessment data to be updated |
bool | $cansetassessmentweight | whether the user can change the assessment weight |
bool | $canoverridegrades | whether the user can override the assessment grades |
void |
workshop::evaluate_submission | ( | $submission, | |
$data, | |||
$canpublish, | |||
$canoverride | |||
) |
Evaluates a submission.
stdClass | $submission | the submission |
stdClass | $data | the submission data to be updated |
bool | $canpublish | whether the user can publish the submission |
bool | $canoverride | whether the user can override the submission grade |
void |
workshop::exassess_url | ( | $assessmentid | ) |
int | $assessmentid | The ID of assessment record |
moodle_url | of the example assessment page |
workshop::excompare_url | ( | $sid, | |
$aid | |||
) |
int | $sid | submission id |
int | $aid | assessment id |
moodle_url | of the page to compare the reference assessments of the given example submission |
workshop::exsubmission_url | ( | $id | ) |
int | $id | example submission id |
moodle_url | of the page to view an example submission |
|
static |
Helper function returning the greatest common divisor.
int | $a | |
int | $b |
int |
workshop::get_all_assessments | ( | ) |
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.
array | [assessmentid] => assessment stdclass |
workshop::get_allocations | ( | ) |
Returns the list of all allocations (i.e.
assigned assessments) in the workshop
Assessments of example submissions are ignored
array |
workshop::get_assessment_by_id | ( | $id | ) |
Get the complete information about the given assessment.
int | $id | Assessment ID |
stdclass |
workshop::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 |
false|stdclass | false if not found, stdclass otherwise |
workshop::get_assessments_by_reviewer | ( | $reviewerid | ) |
Get the complete information about all assessments allocated to the given reviewer.
int | $reviewerid |
array |
workshop::get_assessments_of_submission | ( | $submissionid | ) |
Get the complete information about all assessments of the given submission.
int | $submissionid |
array |
workshop::get_example_by_id | ( | $id | ) |
Returns full record of the given example submission.
int | $id | example submission od |
object |
workshop::get_examples_for_manager | ( | ) |
Returns the list of example submissions in this workshop with reference assessments attached.
array | of objects or an empty array |
workshop::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 |
array | of objects, indexed by example submission id |
workshop::get_feedbackauthor_form | ( | $actionurl, | |
stdclass | $submission, | ||
$options = array() |
|||
) |
Returns the mform the teachers use to put a feedback for the author on their submission.
@mixed moodle_url|null $actionurl
stdClass | $submission | |
array | $options | editable |
workshop_feedbackauthor_form |
workshop::get_feedbackreviewer_form | ( | $actionurl, | |
stdclass | $assessment, | ||
$options = array() |
|||
) |
Returns the mform the teachers use to put a feedback for the reviewer.
mixed | moodle_url|null $actionurl | |
stdClass | $assessment | |
array | $options | editable, editableweight, overridablegradinggrade |
workshop_feedbackreviewer_form |
workshop::get_gradebook_grades | ( | $userid | ) |
Returns the information about the user's grades as they are stored in the gradebook.
The submission grade is returned for users with the capability mod/workshop:submit and the assessment grade is returned for users with the capability mod/workshop:peerassess. Unless the user has the capability to view hidden grades, grades must be visible to be returned. Null grades are not returned. If none grade is to be returned, this method returns false.
int | $userid | the user's id |
workshop_final_grades|false |
workshop::get_grouped | ( | $users | ) |
Groups the given users by the group membership.
This takes the module grouping settings into account. If a grouping 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} |
array | array[groupid][userid] => stdclass{->id ->lastname ->firstname} |
workshop::get_participants | ( | $musthavesubmission = false , |
|
$groupid = 0 , |
|||
$limitfrom = 0 , |
|||
$limitnum = 0 |
|||
) |
Fetches all enrolled users that are authors or reviewers (or both) in the current workshop.
The returned objects contain properties required by user_picture and are ordered by lastname, firstname. Only users with the active enrolment are returned.
bool | $musthavesubmission | if true, return only users who have already submitted |
int | $groupid | 0 means ignore groups, any other value limits the result by group id |
int | $limitfrom | return a subset of records, starting at this point (optional, required if $limitnum is set) |
int | $limitnum | return a subset containing this number of records (optional, required if $limitfrom is set) |
array | array[userid] => stdClass |
|
protected |
Returns SQL statement that can be used to fetch all actively enrolled participants in the workshop.
bool | $musthavesubmission | if true, return only users who have already submitted |
int | $groupid | 0 means ignore groups, any other value limits the result by group id |
array | of (string)sql, (array)params |
workshop::get_pending_assessments_by_reviewer | ( | $reviewerid, | |
$exclude = null |
|||
) |
Get allocated assessments not graded yet by the given reviewer.
int | $reviewerid | the reviewer id |
null | int | array | $exclude | optional assessment id (or list of them) to be excluded |
array |
workshop::get_potential_authors | ( | $musthavesubmission = true , |
|
$groupid = 0 , |
|||
$limitfrom = 0 , |
|||
$limitnum = 0 |
|||
) |
Fetches all enrolled users with the capability mod/workshop:submit in the current workshop.
The returned objects contain properties required by user_picture and are ordered by lastname, firstname. Only users with the active enrolment are returned.
bool | $musthavesubmission | if true, return only users who have already submitted |
int | $groupid | 0 means ignore groups, any other value limits the result by group id |
int | $limitfrom | return a subset of records, starting at this point (optional, required if $limitnum is set) |
int | $limitnum | return a subset containing this number of records (optional, required if $limitfrom is set) |
array | array[userid] => stdClass |
workshop::get_potential_reviewers | ( | $musthavesubmission = false , |
|
$groupid = 0 , |
|||
$limitfrom = 0 , |
|||
$limitnum = 0 |
|||
) |
Fetches all enrolled users with the capability mod/workshop:peerassess in the current workshop.
The returned objects contain properties required by user_picture and are ordered by lastname, firstname. Only users with the active enrolment are returned.
bool | $musthavesubmission | if true, return only users who have already submitted |
int | $groupid | 0 means ignore groups, any other value limits the result by group id |
int | $limitfrom | return a subset of records, starting at this point (optional, required if $limitnum is set) |
int | $limitnum | return a subset containing this number of records (optional, required if $limitfrom is set) |
array | array[userid] => stdClass |
workshop::get_published_submissions | ( | $orderby = 'finalgrade DESC' | ) |
Returns published submissions with their authors data.
array | of stdclass |
workshop::get_submission_by_author | ( | $authorid | ) |
Returns a submission submitted by the given author.
int | $id | author id |
stdclass|false |
workshop::get_submission_by_id | ( | $id | ) |
Returns a submission record with the author's data.
int | $id | submission id |
stdclass |
workshop::get_submissions | ( | $authorid = 'all' , |
|
$groupid = 0 , |
|||
$limitfrom = 0 , |
|||
$limitnum = 0 |
|||
) |
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 |
int | $groupid | If non-zero, return only submissions by authors in the specified group |
int | $limitfrom | Return a subset of records, starting at this point (optional) |
int | $limitnum | Return a subset containing this many records in total (optional, required if $limitfrom is set) |
array | of records or an empty array |
|
protected |
Returns SQL to fetch all enrolled users with the given capability in the current workshop.
The returned array consists of string $sql and the $params array. Note that the $sql can be empty if a grouping is selected and it has no groups.
The list is automatically restricted according to any availability restrictions that apply to user lists (e.g. group, grouping restrictions).
string | $capability | the name of the capability |
bool | $musthavesubmission | ff true, return only users who have already submitted |
int | $groupid | 0 means ignore groups, any other value limits the result by group id |
array | of (string)sql, (array)params |
workshop::get_visible_submissions | ( | $authorid = 0 , |
|
$groupid = 0 , |
|||
$limitfrom = 0 , |
|||
$limitnum = 0 |
|||
) |
Returns submissions from this workshop that are viewable by the current user (except example submissions).
mixed | $authorid | int|array If set to [array of] integer, return submission[s] of the given user[s] only |
int | $groupid | If non-zero, return only submissions by authors in the specified group. 0 for all groups. |
int | $limitfrom | Return a subset of records, starting at this point (optional) |
int | $limitnum | Return a subset containing this many records in total (optional, required if $limitfrom is set) |
array | of records and the total submissions count |
workshop::grading_evaluation_instance | ( | ) |
Returns instance of grading evaluation class.
stdclass | Instance of a grading evaluation |
workshop::grading_strategy_instance | ( | ) |
Returns instance of grading strategy class.
stdclass | Instance of a grading strategy |
|
static |
Return list of available allocation methods.
array | Array ['string' => 'string'] of localized allocation method names |
|
static |
Returns an array of options for the editors that are used for submitting and assessing instructions.
stdClass | $context | @uses EDITOR_UNLIMITED_FILES hard-coded value for the 'maxfiles' option |
array |
|
static |
Check given file types and return invalid/unknown ones.
Empty whitelist is interpretted as "any extension is valid".
string | array | $extensions | list of file extensions |
string | array | $whitelist | list of valid extensions |
array | list of invalid extensions not found in the whitelist |
|
static |
Is the file have allowed to be uploaded to the workshop?
Empty whitelist is interpretted as "any file type is allowed" rather than "no file can be uploaded".
string | $filename | the file name |
string | array | $whitelist | list of allowed file extensions |
false |
workshop::is_participant | ( | $userid = null | ) |
Checks if the given user is an actively enrolled participant in the workshop.
int | $userid,defaults | to the current $USER |
boolean |
|
static |
Helper function returning the least common multiple.
int | $a | |
int | $b |
int |
workshop::log | ( | $action, | |
moodle_url | $url = null , |
||
$info = null , |
|||
$return = false |
|||
) |
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 |
bool | $return | true to return the arguments for add_to_log. |
void|array | array of arguments for add_to_log if $return is true |
|
protected |
Converts absolute URL to relative URL needed by {.
moodle_url | $url | absolute URL |
string |
workshop::modifying_submission_allowed | ( | $userid | ) |
Is the given user allowed to modify their existing submission?
int | $userid |
bool |
|
static |
Converts the argument into an array (list) of file extensions.
The list can be separated by whitespace, end of lines, commas colons and semicolons. Empty values are not returned. Values are converted to lowercase. Duplicates are removed. Glob evaluation is not supported.
string | array | $extensions | list of file extensions |
array | of strings |
workshop::overall_feedback_attachment_options | ( | ) |
Return the filemanager options for the overall feedback for the author.
array |
workshop::overall_feedback_content_options | ( | ) |
Return the editor options for the overall feedback for the author.
array |
|
static |
Given the percent and the total, returns the number.
float | $percent | from 0 to 100 |
float | $total | the 100% value |
float |
workshop::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 |
workshop_assessment |
workshop::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 |
workshop_example_assessment |
workshop::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 |
workshop_example_reference_assessment |
workshop::prepare_example_submission | ( | stdClass | $record | ) |
Prepares renderable example submission component.
stdClass | $record | required by { |
workshop_example_submission |
workshop::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() |
workshop_example_submission_summary | to be rendered |
workshop::prepare_grading_report_data | ( | $userid, | |
$groupid, | |||
$page, | |||
$perpage, | |||
$sortby, | |||
$sorthow | |||
) |
Prepares data object with all workshop grades to be rendered.
int | $userid | the user we are preparing the report for |
int | $groupid | if non-zero, prepare the report for the given group only |
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 |
stdclass | data for the renderer |
workshop::prepare_submission | ( | stdClass | $record, |
$showauthor = false |
|||
) |
Prepares renderable submission component.
stdClass | $record | required by { |
bool | $showauthor | show the author-related information |
workshop_submission |
workshop::prepare_submission_summary | ( | stdClass | $record, |
$showauthor = false |
|||
) |
Prepares renderable submission summary component.
stdClass | $record | required by { |
bool | $showauthor | show the author-related information |
workshop_submission_summary |
workshop::previewform_url | ( | ) |
moodle_url | of the page for previewing this workshop's grading form |
workshop::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 |
float | suitable to be stored as numeric(10,5) |
workshop::real_grade | ( | $value | ) |
Calculates the real value of grade for submission.
float | $value | percentual value from 0 to 100 |
string |
workshop::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 |
string |
workshop::real_grading_grade | ( | $value | ) |
Calculates the real value of grade for assessment.
float | $value | percentual value from 0 to 100 |
string |
workshop::reset_userdata | ( | stdClass | $data | ) |
Performs the reset of this workshop instance.
stdClass | $data | The actual course reset settings. |
array | List of results, each being array[(string)component, (string)item, (string)error] |
|
protected |
Removes all user data related to assessments (including allocations).
This includes assessments of example submissions as long as they are not referential assessments.
stdClass | $data | The actual course reset settings. |
bool|string | True on success, error message otherwise. |
|
protected |
Removes all user data related to participants' submissions.
stdClass | $data | The actual course reset settings. |
bool|string | True on success, error message otherwise. |
workshop::set_grading_evaluation_method | ( | $method | ) |
Sets the current evaluation method to the given plugin.
string | $method | the name of the workshopeval subplugin |
bool | true if successfully set |
coding_exception | if attempting to set a non-installed evaluation method |
workshop::set_module_viewed | ( | ) |
Trigger module viewed event and set the module viewed for completion.
workshop::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 |
false|float | the saved grade |
workshop::set_submission_viewed | ( | $submission | ) |
Trigger submission viewed event.
stdClass | $submission | submission object |
workshop::submission_attachment_options | ( | ) |
Return the filemanager options for the submission attachments field.
array |
workshop::submission_content_options | ( | ) |
Return the editor options for the submission content field.
array |
workshop::submission_url | ( | $id = null | ) |
moodle_url | of the page to view a submission, defaults to the own one |
workshop::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 |
bool | true if success, false otherwise |
workshop::switchphase_url | ( | $phasecode | ) |
int | $phasecode | The internal phase code |
moodle_url | of the script to change the current phase to $phasecode |
|
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 |
stdclass |
workshop::toolbox_url | ( | $tool | ) |
moodle_url | of this workshop's toolbox page |
workshop::updatemod_url | ( | ) |
moodle_url | of the mod_edit form |
workshop::validate_submission_data | ( | $data | ) |
Validates the submission form or WS data.
array | $data | the data to be validated |
array | the validation errors (if any) |
workshop::view_url | ( | ) |
moodle_url | of this workshop's view page |