Moodle  2.2.1
http://www.collinsharper.com
workshop_random_allocator Class Reference
Inheritance diagram for workshop_random_allocator:
Collaboration diagram for workshop_random_allocator:

Public Member Functions

 __construct (workshop $workshop)
 init ()
 ui ()

Static Public Member Functions

static delete_instance ($workshopid)
static available_numofreviews_list ()

Data Fields

const MSG_SUCCESS = 1
const USERTYPE_AUTHOR = 1
const USERTYPE_REVIEWER = 2

Protected Member Functions

 self_allocation ($authors=array(), $reviewers=array(), $assessments=array())
 add_new_allocations (array $newallocations, array $dataauthors, array $datareviewers)
 index_submissions_by_authors ($submissions)
 get_author_ids ($newallocations)
 get_unique_allocations ($newallocations)
 get_unkept_assessments ($assessments, $newallocations, $keepselfassessments)
 random_allocation ($authors, $reviewers, $assessments, &$o, array $options)
 convert_assessments_to_links ($assessments)
 get_element_with_lowest_workload ($workload)
 shuffle_assoc (&$array)
 filter_current_assessments (&$newallocations, $assessments)

Protected Attributes

 $workshop
 $mform

Detailed Description

Allocates the submissions randomly

Definition at line 38 of file lib.php.


Constructor & Destructor Documentation

__construct ( workshop workshop)
Parameters:
workshop$workshopWorkshop API object

Definition at line 56 of file lib.php.


Member Function Documentation

add_new_allocations ( array newallocations,
array dataauthors,
array datareviewers 
) [protected]

Creates new assessment records

Parameters:
array$newallocationspairs 'reviewerid' => 'authorid'
array$dataauthorsauthors by group, group [0] contains all authors
array$datareviewersreviewers by group, group [0] contains all reviewers
Returns:
bool

Definition at line 318 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static available_numofreviews_list ( ) [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

Returns:
array of integers

Definition at line 263 of file lib.php.

Here is the caller graph for this function:

convert_assessments_to_links ( assessments) [protected]

Extracts the information about reviews from the authors' and reviewers' perspectives

Parameters:
array$assessmentsarray of assessments as returned by workshop::get_all_assessments()
Returns:
array of two arrays

Reimplemented in testable_workshop_random_allocator.

Definition at line 627 of file lib.php.

Here is the caller graph for this function:

static delete_instance ( workshopid) [static]

Delete all data related to a given workshop module instance

This plugin does not store any data.

See also:
workshop_delete_instance()
Parameters:
int$workshopidid of the workshop module instance being deleted
Returns:
void

Implements workshop_allocator.

Definition at line 252 of file lib.php.

filter_current_assessments ( &$  newallocations,
assessments 
) [protected]

Filter new allocations so that they do not contain an already existing assessment

Parameters:
mixed$newallocationsarray of ('reviewerid' => 'authorid') tuples
array$assessmentsarray of assessment records
Returns:
void

Reimplemented in testable_workshop_random_allocator.

Definition at line 694 of file lib.php.

Here is the caller graph for this function:

get_author_ids ( newallocations) [protected]

Extracts unique list of authors' IDs from the structure of new allocations

Parameters:
array$newallocationsof pairs 'reviewerid' => 'authorid'
Returns:
array of authorids

Reimplemented in testable_workshop_random_allocator.

Definition at line 366 of file lib.php.

Here is the caller graph for this function:

get_element_with_lowest_workload ( workload) [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.

Parameters:
array$workload[groupid] => (int)workload
Returns:
mixed int|bool id of the selected element or false if it is impossible to choose

Reimplemented in testable_workshop_random_allocator.

Definition at line 652 of file lib.php.

Here is the caller graph for this function:

get_unique_allocations ( newallocations) [protected]

Removes duplicate allocations

Parameters:
mixed$newallocationsarray of 'reviewerid' => 'authorid' pairs
Returns:
array

Reimplemented in testable_workshop_random_allocator.

Definition at line 383 of file lib.php.

Here is the caller graph for this function:

get_unkept_assessments ( assessments,
newallocations,
keepselfassessments 
) [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.

Parameters:
array$assessmentslist of current assessments
mixed$newallocationsarray of 'reviewerid' => 'authorid' pairs
bool$keepselfassessmentsdo not remove already allocated self assessments
Returns:
array of assessments ids to be removed

Reimplemented in testable_workshop_random_allocator.

Definition at line 400 of file lib.php.

Here is the caller graph for this function:

index_submissions_by_authors ( submissions) [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.

Parameters:
string$submissionsarray indexed by submission id
Returns:
array indexed by author id

Reimplemented in testable_workshop_random_allocator.

Definition at line 347 of file lib.php.

Here is the caller graph for this function:

init ( )

Allocate submissions as requested by user

Implements workshop_allocator.

Definition at line 63 of file lib.php.

Here is the call graph for this function:

random_allocation ( authors,
reviewers,
assessments,
&$  o,
array options 
) [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

Parameters:
array$authorsstructure of grouped authors
array$reviewersstructure of grouped reviewers
array$assessmentscurrently assigned assessments to be kept
array$oreference to an array of log messages
array$optionsallocation options
Returns:
array array of (reviewerid => authorid) pairs

Definition at line 441 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

self_allocation ( authors = array(),
reviewers = array(),
assessments = array() 
) [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.

Parameters:
array$authorsgrouped of {
See also:
workshop::get_potential_authors()}
Parameters:
array$reviewersgrouped by {
See also:
workshop::get_potential_reviewers()}
Parameters:
array$assessmentsas returned by {
See also:
workshop::get_all_assessments()}
Returns:
array of new allocations to be created, array of array(reviewerid => authorid)

Reimplemented in testable_workshop_random_allocator.

Definition at line 285 of file lib.php.

Here is the caller graph for this function:

shuffle_assoc ( &$  array) [protected]

Shuffle the order of array elements preserving the key=>values

Parameters:
array$arrayto be shuffled
Returns:
true

Definition at line 674 of file lib.php.

Here is the caller graph for this function:

ui ( )

Returns the HTML code to print the user interface

Implements workshop_allocator.

Definition at line 189 of file lib.php.

Here is the call graph for this function:


Field Documentation

$mform [protected]

mform with settings

Definition at line 51 of file lib.php.

$workshop [protected]

workshop instance

Definition at line 48 of file lib.php.

const MSG_SUCCESS = 1

constants used to pass status messages between init() and ui()

Definition at line 41 of file lib.php.

const USERTYPE_AUTHOR = 1

constants used in allocation settings form

Definition at line 44 of file lib.php.

const USERTYPE_REVIEWER = 2

Definition at line 45 of file lib.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations