Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
|
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. | |
add_allocation (stdclass $submission, $reviewerid, $weight=1, $bulk=false) | |
Allocate a submission to a user for review. | |
aggregate_grading_grades ($restrict=null) | |
Calculates grades for assessment for the given participant(s) | |
aggregate_submission_grades ($restrict=null) | |
Calculates grades for submission for the given participant(s) and updates it in the database. | |
aggregate_url () | |
allocation_url ($method=null) | |
allocator_instance ($method) | |
Returns instance of submissions allocator. | |
assess_url ($assessmentid) | |
assessing_allowed ($userid) | |
Is the given reviewer allowed to create/edit their assessments? | |
assessing_examples_allowed () | |
Are reviewers allowed to create/edit their assessments of the example submissions? | |
assessments_available () | |
Are the peer-reviews available to the authors? | |
check_edit_assessment ($assessment, $submission) | |
Helper method for validating if the current user can edit the given assessment. | |
check_examples_assessed_before_assessment ($userid) | |
Check that all required examples have been assessed by the given user. | |
check_examples_assessed_before_submission ($userid) | |
Check whether the given user has assessed all his required examples before submission. | |
check_group_membership ($otheruserid) | |
Check if the current user can access the other user's group. | |
check_view_assessment ($assessment, $submission) | |
Helper method for validating if the current user can view the given assessment. | |
clear_assessments () | |
Sets the given grades and received grading grades to null. | |
clear_grading_grades ($restrict=null) | |
Sets the aggregated grades for assessment to null. | |
clear_submission_grades ($restrict=null) | |
Sets the grades for submission to null. | |
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(). | |
count_potential_authors ($musthavesubmission=true, $groupid=0) | |
Returns the total number of users that would be fetched by self::get_potential_authors(). | |
count_potential_reviewers ($musthavesubmission=false, $groupid=0) | |
Returns the total number of users that would be fetched by self::get_potential_reviewers(). | |
count_submissions ($authorid='all', $groupid=0) | |
Returns the total number of records that would be returned by self::get_submissions(). | |
creating_submission_allowed ($userid) | |
Is the given user allowed to create their submission? | |
delete_assessment ($id) | |
Delete assessment record or records. | |
delete_submission (stdclass $submission) | |
Removes the submission and all relevant data. | |
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). | |
edit_submission ($submission) | |
Adds or updates a submission. | |
editform_url () | |
evaluate_assessment ($assessment, $data, $cansetassessmentweight, $canoverridegrades) | |
Evaluates an assessment. | |
evaluate_submission ($submission, $data, $canpublish, $canoverride) | |
Evaluates a submission. | |
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. | |
get_allocations () | |
Returns the list of all allocations (i.e. | |
get_assessment_by_id ($id) | |
Get the complete information about the given assessment. | |
get_assessment_of_submission_by_user ($submissionid, $reviewerid) | |
Get the complete information about the user's assessment of the given submission. | |
get_assessments_by_reviewer ($reviewerid) | |
Get the complete information about all assessments allocated to the given reviewer. | |
get_assessments_of_submission ($submissionid) | |
Get the complete information about all assessments of the given submission. | |
get_example_by_id ($id) | |
Returns full record of the given example submission. | |
get_examples_for_manager () | |
Returns the list of example submissions in this workshop with reference assessments attached. | |
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. | |
get_feedbackauthor_form ($actionurl, stdclass $submission, $options=array()) | |
Returns the mform the teachers use to put a feedback for the author on their submission. | |
get_feedbackreviewer_form ($actionurl, stdclass $assessment, $options=array()) | |
Returns the mform the teachers use to put a feedback for the reviewer. | |
get_gradebook_grades ($userid) | |
Returns the information about the user's grades as they are stored in the gradebook. | |
get_grouped ($users) | |
Groups the given users by the group membership. | |
get_initial_first () | |
Get the initial first name. | |
get_initial_last () | |
Get the initial last name. | |
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. | |
get_pending_assessments_by_reviewer ($reviewerid, $exclude=null) | |
Get allocated assessments not graded yet by the given reviewer. | |
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. | |
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. | |
get_published_submissions ($orderby='finalgrade DESC') | |
Returns published submissions with their authors data. | |
get_submission_by_author ($authorid) | |
Returns a submission submitted by the given author. | |
get_submission_by_id ($id) | |
Returns a submission record with the author's data. | |
get_submissions ($authorid='all', $groupid=0, $limitfrom=0, $limitnum=0) | |
Returns submissions from this 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). | |
grading_evaluation_instance () | |
Returns instance of grading evaluation class. | |
grading_strategy_instance () | |
Returns instance of grading strategy class. | |
init_initial_bar () | |
Init method for initial bars. | |
is_participant ($userid=null) | |
Checks if the given user is an actively enrolled participant in the workshop. | |
log ($action, moodle_url $url=null, $info=null, $return=false) | |
Workshop wrapper around {. | |
modifying_submission_allowed ($userid) | |
Is the given user allowed to modify their existing submission? | |
overall_feedback_attachment_options () | |
Return the filemanager options for the overall feedback for the author. | |
overall_feedback_content_options () | |
Return the editor options for the overall feedback for the author. | |
prepare_assessment (stdClass $record, $form, array $options=array()) | |
Prepares renderable assessment component. | |
prepare_example_assessment (stdClass $record, $form=null, array $options=array()) | |
Prepares renderable example submission's assessment component. | |
prepare_example_reference_assessment (stdClass $record, $form=null, array $options=array()) | |
Prepares renderable example submission's reference assessment component. | |
prepare_example_submission (stdClass $record) | |
Prepares renderable example submission component. | |
prepare_example_summary (stdClass $example) | |
Prepares renderable example submission summary component. | |
prepare_grading_report_data ($userid, $groupid, $page, $perpage, $sortby, $sorthow) | |
Prepares data object with all workshop grades to be rendered. | |
prepare_submission (stdClass $record, $showauthor=false) | |
Prepares renderable submission component. | |
prepare_submission_summary (stdClass $record, $showauthor=false) | |
Prepares renderable submission summary component. | |
previewform_url () | |
raw_grade_value ($value, $max) | |
Calculates the raw (percentual) value from a real grade. | |
real_grade ($value) | |
Calculates the real value of grade for submission. | |
real_grade_value ($value, $max) | |
Calculates the real value of a grade. | |
real_grading_grade ($value) | |
Calculates the real value of grade for assessment. | |
reset_userdata (stdClass $data) | |
Performs the reset of this workshop instance. | |
set_grading_evaluation_method ($method) | |
Sets the current evaluation method to the given plugin. | |
set_module_viewed () | |
Trigger module viewed event and set the module viewed for completion. | |
set_peer_grade ($assessmentid, $grade) | |
Saves a raw grade for submission as calculated from the assessment form fields. | |
set_submission_viewed ($submission) | |
Trigger submission viewed event. | |
submission_attachment_options () | |
Return the filemanager options for the submission attachments field. | |
submission_content_options () | |
Return the editor options for the submission content field. | |
submission_url ($id=null) | |
switch_phase ($newphase) | |
Switch to a new workshop phase. | |
switchphase_url ($phasecode) | |
toolbox_url ($tool) | |
updatemod_url () | |
validate_submission_data ($data) | |
Validates the submission form or WS data. | |
view_url () | |
Static Public Member Functions | |
static | available_assessment_weights_list () |
Return an array of possible values of assessment weight. | |
static | available_dimension_weights_list () |
Return an array of possible values of assessment dimension weight. | |
static | available_evaluators_list () |
Returns the list of available grading evaluation methods. | |
static | available_example_modes_list () |
Returns the localized list of supported examples modes. | |
static | available_maxgrades_list () |
Returns an array of numeric values that can be used as maximum grades. | |
static | available_strategies_list () |
Returns the list of available grading strategy methods. | |
static | clean_file_extensions ($extensions) |
Cleans the user provided list of file extensions. | |
static | gcd ($a, $b) |
Helper function returning the greatest common divisor. | |
static | installed_allocators () |
Return list of available allocation methods. | |
static | instruction_editors_options (stdclass $context) |
Returns an array of options for the editors that are used for submitting and assessing instructions. | |
static | invalid_file_extensions ($extensions, $allowlist) |
Check given file types and return invalid/unknown ones. | |
static | is_allowed_file_type ($filename, $allowlist) |
Is the file have allowed to be uploaded to the workshop? | |
static | lcm ($a, $b) |
Helper function returning the least common multiple. | |
static | normalize_file_extensions ($extensions) |
Converts the argument into an array (list) of file extensions. | |
static | percent_to_value ($percent, $total) |
Given the percent and the total, returns the number. | |
static | timestamp_formats ($timestamp) |
Returns an object suitable for strings containing dates/times. | |
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. | |
aggregate_submission_grades_process (array $assessments) | |
Given an array of all assessments of a single submission, calculates the final grade for this submission. | |
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. | |
get_users_with_capability_sql ($capability, $musthavesubmission, $groupid) | |
Returns SQL to fetch all enrolled users with the given capability in the current workshop. | |
get_users_with_initial_filtering_sql_where () | |
Returns SQL to fetch all enrolled users with the first name or last name. | |
log_convert_url (moodle_url $fullurl) | |
Converts absolute URL to relative URL needed by {. | |
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). | |
reset_userdata_submissions (stdClass $data) | |
Removes all user data related to participants' submissions. | |
Protected Attributes | |
workshop_evaluation | $evaluationinstance = null |
grading evaluation instance Do not use directly, get the instance using workshop::grading_evaluation_instance() | |
array | $initialbarprefs = [] |
It gets initialised in init_initial_bar, and may have keys 'i_first' and 'i_last' depending on what is selected. | |
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_initial_first | ( | ) |
Get the initial first name.
string|null | initial of first name we are currently filtering by. |
workshop::get_initial_last | ( | ) |
Get the initial last name.
string|null | initial of last name we are currently filtering by. |
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 |
|
protected |
Returns SQL to fetch all enrolled users with the first name or last name.
array |
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 |
workshop::init_initial_bar | ( | ) |
Init method for initial bars.
void |
|
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 allowlist is interpretted as "any extension is valid".
string | array | $extensions | list of file extensions |
string | array | $allowlist | list of valid extensions |
array | list of invalid extensions not found in the allowlist |
|
static |
Is the file have allowed to be uploaded to the workshop?
Empty allowlist is interpretted as "any file type is allowed" rather than "no file can be uploaded".
string | $filename | the file name |
string | array | $allowlist | 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 | ) |
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 |