Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
|
Allocates the submissions randomly. More...
Public Member Functions | |
__construct (workshop $workshop) | |
execute (workshop_random_allocator_setting $settings, workshop_allocation_result $result) | |
Executes the allocation based on the given settings. More... | |
init () | |
Allocate submissions as requested by user. More... | |
ui () | |
Returns the HTML code to print the user interface. More... | |
Static Public Member Functions | |
static | available_numofreviews_list () |
Return an array of possible numbers of reviews to be done. More... | |
static | delete_instance ($workshopid) |
Delete all data related to a given workshop module instance. More... | |
Public Attributes | |
const | MSG_SUCCESS = 1 |
constants used to pass status messages between init() and ui() | |
Protected Member Functions | |
add_new_allocations (array $newallocations, array $dataauthors, array $datareviewers) | |
Creates new assessment records. More... | |
convert_assessments_to_links ($assessments) | |
Extracts the information about reviews from the authors' and reviewers' perspectives. More... | |
filter_current_assessments (&$newallocations, $assessments) | |
Filter new allocations so that they do not contain an already existing assessment. More... | |
get_author_ids ($newallocations) | |
Extracts unique list of authors' IDs from the structure of new allocations. More... | |
get_element_with_lowest_workload ($workload) | |
Selects an element with the lowest workload. More... | |
get_unique_allocations ($newallocations) | |
Removes duplicate allocations. More... | |
get_unkept_assessments ($assessments, $newallocations, $keepselfassessments) | |
Returns the list of assessments to remove. More... | |
index_submissions_by_authors ($submissions) | |
Flips the structure of submission so it is indexed by authorid attribute. More... | |
random_allocation ($authors, $reviewers, $assessments, $result, array $options) | |
Allocates submission reviews randomly. More... | |
self_allocation ($authors=array(), $reviewers=array(), $assessments=array()) | |
Allocates submissions to their authors for review. More... | |
shuffle_assoc (&$array) | |
Shuffle the order of array elements preserving the key=>values. More... | |
Protected Attributes | |
$mform | |
mform with settings | |
$workshop | |
workshop instance | |
Allocates the submissions randomly.
workshop_random_allocator::__construct | ( | workshop | $workshop | ) |
workshop | $workshop | Workshop API object |
|
protected |
Creates new assessment records.
array | $newallocations | pairs 'reviewerid' => 'authorid' |
array | $dataauthors | authors by group, group [0] contains all authors |
array | $datareviewers | reviewers by group, group [0] contains all reviewers |
bool |
|
static |
Return an array of possible numbers of reviews to be done.
Should contain numbers 1, 2, 3, ... 10 and possibly others up to a reasonable value
array | of integers |
|
protected |
Extracts the information about reviews from the authors' and reviewers' perspectives.
array | $assessments | array of assessments as returned by workshop::get_all_assessments() |
array | of two arrays |
|
static |
Delete all data related to a given workshop module instance.
This plugin does not store any data.
int | $workshopid | id of the workshop module instance being deleted |
void |
Implements workshop_allocator.
workshop_random_allocator::execute | ( | workshop_random_allocator_setting | $settings, |
workshop_allocation_result | $result | ||
) |
Executes the allocation based on the given settings.
workshop_random_allocator_setting | $setting | |
workshop_allocation_result | allocation result logger |
|
protected |
Filter new allocations so that they do not contain an already existing assessment.
mixed | $newallocations | array of ('reviewerid' => 'authorid') tuples |
array | $assessments | array of assessment records |
void |
|
protected |
Extracts unique list of authors' IDs from the structure of new allocations.
array | $newallocations | of pairs 'reviewerid' => 'authorid' |
array | of authorids |
|
protected |
Selects an element with the lowest workload.
If there are more elements with the same workload, choose one of them randomly. This may be used to select a group or user.
array | $workload | [groupid] => (int)workload |
mixed | int|bool id of the selected element or false if it is impossible to choose |
|
protected |
Removes duplicate allocations.
mixed | $newallocations | array of 'reviewerid' => 'authorid' pairs |
array |
|
protected |
Returns the list of assessments to remove.
If user selects "removecurrentallocations", we should remove all current assessment records and insert new ones. But this would needlessly waste table ids. Instead, let us find only those assessments that have not been re-allocated in this run of allocation. So, the once-allocated submissions are kept with their original id.
array | $assessments | list of current assessments |
mixed | $newallocations | array of 'reviewerid' => 'authorid' pairs |
bool | $keepselfassessments | do not remove already allocated self assessments |
array | of assessments ids to be removed |
|
protected |
Flips the structure of submission so it is indexed by authorid attribute.
It is the caller's responsibility to make sure the submissions are not teacher examples so no user is the author of more submissions.
string | $submissions | array indexed by submission id |
array | indexed by author id |
workshop_random_allocator::init | ( | ) |
Allocate submissions as requested by user.
workshop_allocation_result |
Implements workshop_allocator.
|
protected |
Allocates submission reviews randomly.
The algorithm of this function has been described at http://moodle.org/mod/forum/discuss.php?d=128473 Please see the PDF attached to the post before you study the implementation. The goal of the function is to connect each "circle" (circles are representing either authors or reviewers) with a required number of "squares" (the other type than circles are).
The passed $options array must provide keys: (int)numofreviews - number of reviews to be allocated to each circle (int)numper - what user type the circles represent. (bool)excludesamegroup - whether to prevent peer submissions from the same group in visible group mode
array | $authors | structure of grouped authors |
array | $reviewers | structure of grouped reviewers |
array | $assessments | currently assigned assessments to be kept |
workshop_allocation_result | $result | allocation result logger |
array | $options | allocation options |
array | array of (reviewerid => authorid) pairs |
|
protected |
Allocates submissions to their authors for review.
If the submission has already been allocated, it is skipped. If the author is not found among reviewers, the submission is not assigned.
array | $authors | grouped of { |
array | $reviewers | grouped by { |
array | $assessments | as returned by { |
array | of new allocations to be created, array of array(reviewerid => authorid) |
|
protected |
Shuffle the order of array elements preserving the key=>values.
array | $array | to be shuffled |
true |
workshop_random_allocator::ui | ( | ) |
Returns the HTML code to print the user interface.
Implements workshop_allocator.