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

Public Member Functions

 assignment_base ($cmid='staticonly', $assignment=NULL, $cm=NULL, $course=NULL)
 view ()
 view_header ($subpage='')
 view_intro ()
 view_dates ()
 view_footer ()
 view_feedback ($submission=NULL)
 submittedlink ($allgroups=false)
 setup_elements (&$mform)
 form_data_preprocessing (&$default_values, $form)
 form_validation ($data, $files)
 add_instance ($assignment)
 delete_instance ($assignment)
 update_instance ($assignment)
 update_grade ($submission)
 submissions ($mode)
 quickgrade_mode_allowed ()
 update_main_listing ($submission)
 display_grade ($grade)
 display_submission ($offset=-1, $userid=-1, $display=true)
 preprocess_submission (&$submission)
 display_submissions ($message='')
 process_feedback ($formdata=null)
 process_outcomes ($userid)
 get_submission ($userid=0, $createnew=false, $teachermodified=false)
 is_submitted_with_required_data ($submission)
 prepare_new_submission ($userid, $teachermodified=false)
 get_submissions ($sort='', $dir='DESC')
 count_real_submissions ($groupid=0)
 email_teachers ($submission)
 send_file ($filearea, $args)
 get_graders ($user)
 email_teachers_text ($info)
 email_teachers_html ($info)
 print_user_files ($userid=0, $return=false)
 count_user_files ($itemid)
 isopen ()
 description_is_hidden ()
 user_outline ($grade)
 user_complete ($user, $grade=null)
 display_lateness ($timesubmitted)
 delete ()
 custom_feedbackform ($submission, $return=false)
 get_coursemodule_info ($coursemodule)
 cron ()
 reset_userdata ($data)
 portfolio_exportable ()

Static Public Member Functions

static backup_one_mod ($bf, $preferences, $assignment)
static backup_one_submission ($bf, $preferences, $assignment, $submission)
static restore_one_mod ($info, $restore, $assignment)
static restore_one_submission ($info, $restore, $assignment, $submission)

Data Fields

const FILTER_ALL = 0
const FILTER_SUBMITTED = 1
const FILTER_REQUIRE_GRADING = 2
 $cm
 $course
 $coursecontext
 $assignment
 $strassignment
 $strassignments
 $strsubmissions
 $strlastmodified
 $pagetitle
 $usehtmleditor
 $defaultformat
 $context
 $type

Protected Member Functions

 validate_and_preprocess_feedback ()

Detailed Description

Definition at line 47 of file lib.php.


Member Function Documentation

add_instance ( assignment)

Create a new assignment activity

Given an object containing all the necessary data, (defined by the form in mod_form.php) this function will create a new instance and return the id number of the new instance. The due data is added to the calendar This is common to all assignment types.

object object

Parameters:
object$assignmentThe data from the form on mod_form.php
Returns:
int The id of the assignment

Definition at line 463 of file lib.php.

Here is the call graph for this function:

assignment_base ( cmid = 'staticonly',
assignment = NULL,
cm = NULL,
course = NULL 
)

Constructor for the base assignment class

Constructor for the base assignment class. If cmid is set create the cm, course, assignment objects. If the assignment is hidden and the user is not a teacher then this prints a page header and notice.

object object

Parameters:
int$cmidthe current course module id - not set for new assignments
object$assignmentusually null, but if we have it we pass it to save db access
object$cmusually null, but if we have it we pass it to save db access
object$courseusually null, but if we have it we pass it to save db access

Set up things for a HTML editor if it's needed

Definition at line 99 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static backup_one_mod ( bf,
preferences,
assignment 
) [static]

base implementation for backing up subtype specific information for one single module

Parameters:
filehandle$bffile handle for xml file to write to
mixed$preferencesthe complete backup preference object
Returns:
boolean

Definition at line 2326 of file lib.php.

static backup_one_submission ( bf,
preferences,
assignment,
submission 
) [static]

base implementation for backing up subtype specific information for one single submission

Parameters:
filehandle$bffile handle for xml file to write to
mixed$preferencesthe complete backup preference object
object$submissionthe assignment submission db record
Returns:
boolean

Definition at line 2342 of file lib.php.

count_real_submissions ( groupid = 0)

Counts all real assignment submissions by ENROLLED students (not empty ones)

Parameters:
int$groupidoptional If nonzero then count is restricted to this group
Returns:
int The number of submissions

Definition at line 1888 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

count_user_files ( itemid)

Count the files uploaded by a given user

Parameters:
$itemidint The submission's id as the file's itemid.
Returns:
int

Definition at line 2109 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

cron ( )

Plugin cron method - do not use $this here, create new assignment instances if needed.

Returns:
void

Definition at line 2249 of file lib.php.

custom_feedbackform ( submission,
return = false 
)

Empty custom feedback grading form.

Definition at line 2226 of file lib.php.

Here is the caller graph for this function:

delete ( )

Empty method stub for all delete actions.

Reimplemented in assignment_upload.

Definition at line 2218 of file lib.php.

Here is the call graph for this function:

delete_instance ( assignment)

Deletes an assignment activity

Deletes all database records, files and calendar events for this assignment.

object object

Parameters:
object$assignmentThe assignment to be deleted
Returns:
boolean False indicates error

Definition at line 503 of file lib.php.

Here is the call graph for this function:

Return true if is set description is hidden till available date

This is needed by calendar so that hidden descriptions do not come up in upcoming events.

Check that description is hidden till available date By default return false Assignments types should implement this method if needed

Returns:
boolen

Reimplemented in assignment_upload.

Definition at line 2143 of file lib.php.

display_grade ( grade)

Return a grade in user-friendly form, whether it's a scale or not

object

Parameters:
mixed$grade
Returns:
string User-friendly representation of grade

Definition at line 916 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

display_lateness ( timesubmitted)

Return a string indicating how late a submission is

Parameters:
$timesubmittedint
Returns:
string

Reimplemented in assignment_offline.

Definition at line 2211 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

display_submission ( offset = -1,
userid = -1,
display = true 
)

Display a single submission, ready for grading on a popup window

This default method prints the teacher info and submissioncomment box at the top and the student info and submission at the bottom. This method also fetches the necessary data in order to be able to provide a "Next submission" button. Calls preprocess_submission() to give assignment type plug-ins a chance to process submissions before they are graded This method gets its arguments from the page parameters userid and offset

object object

Parameters:
string$extra_javascript

construct SQL, using current offset to find the data of the next student

Get all ppl that can submit assignments

Definition at line 958 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

display_submissions ( message = '')

Display all the submissions ready for grading

object object object object

Parameters:
string$message
Returns:
bool|void

Some shortcuts to make the code read better

Check to see if groups are being used in this assignment

find out current groups mode

Print quickgrade form around the table

Get all ppl that are allowed to submit assignments

Construct the SQL

offset used to calculate index of student in that particular query, needed for the pop up to know who's next

Prints student answer and student modified date attach file or print link to student answer, depending on the type of the assignment. Refer to print_student_answer in inherited classes.

Print grade, dropdown or text

Print Comment

Confirm we have exclusively 0 or 1

No more buttons, we use popups ;-).

Print the whole table

Print quickgrade form around the table

End of fast grading form

Mini form for setting user preference

Definition at line 1161 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

email_teachers ( submission)

Alerts teachers by email of new or changed assignments that need grading

First checks whether the option to email teachers is set for this assignment. Sends an email to ALL teachers in the course (or in the group if using separate groups). Uses the methods email_teachers_text() and email_teachers_html() to construct the content.

object object

Parameters:
$submissionobject The submission that has changed
Returns:
void

Definition at line 1904 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

email_teachers_html ( info)

Creates the html content for emails to teachers

Parameters:
$infoobject The info used by the 'emailteachermailhtml' language string
Returns:
string

Definition at line 2028 of file lib.php.

Here is the call graph for this function:

email_teachers_text ( info)

Creates the text content for emails to teachers

Parameters:
$infoobject The info used by the 'emailteachermail' language string
Returns:
string

Definition at line 2012 of file lib.php.

Here is the call graph for this function:

form_data_preprocessing ( &$  default_values,
form 
)

Any preprocessing needed for the settings form for this assignment type

Parameters:
array$default_values- array to fill in with the default values in the form 'formelement' => 'value'
object$form- the form that is to be displayed
Returns:
none

Definition at line 435 of file lib.php.

form_validation ( data,
files 
)

Any extra validation checks needed for the settings form for this assignment type

See lib/formslib.php, 'validation' function for details

Definition at line 444 of file lib.php.

get_coursemodule_info ( coursemodule)

Add a get_coursemodule_info function in case any assignment type wants to add 'extra' information for the course (see resource).

Given a course_module object, this function returns any "extra" information that may be needed when printing this activity in a course listing. See get_array_of_activities() in course/lib.php.

Parameters:
$coursemoduleobject The coursemodule object (record).
Returns:
cached_cm_info Object used to customise appearance on course page

Definition at line 2241 of file lib.php.

get_graders ( user)

Returns a list of teachers that should be grading given submission

Parameters:
object$user
Returns:
array

Definition at line 1967 of file lib.php.

Here is the call graph for this function:

get_submission ( userid = 0,
createnew = false,
teachermodified = false 
)

Load the submission object for a particular user

object object

Parameters:
$useridint The id of the user whose submission we want or 0 in which case USER->id is used
$createnewboolean optional Defaults to false. If set to true a new submission object will be created in the database
bool$teachermodifiedstudent submission set if false
Returns:
object The submission

Definition at line 1809 of file lib.php.

Here is the caller graph for this function:

get_submissions ( sort = '',
dir = 'DESC' 
)

Return all assignment submissions by ENROLLED students (even empty)

Parameters:
string$sortoptional field names for the ORDER BY in the sql query
string$diroptional specifying the sort direction, defaults to DESC
Returns:
array The submission objects indexed by id

Definition at line 1878 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Check the given submission is complete. Preliminary rows are often created in the assignment_submissions table before a submission actually takes place. This function checks to see if the given submission has actually been submitted.

Parameters:
stdClass$submissionThe submission we want to check for completion
Returns:
bool Indicates if the submission was found to be complete

Reimplemented in assignment_upload, and assignment_uploadsingle.

Definition at line 1835 of file lib.php.

Here is the caller graph for this function:

isopen ( )

Returns true if the student is allowed to submit

Checks that the assignment has started and, if the option to prevent late submissions is set, also checks that the assignment has not yet closed.

Returns:
boolean

Definition at line 2122 of file lib.php.

Here is the caller graph for this function:

Reimplemented in assignment_upload, assignment_online, and assignment_uploadsingle.

Definition at line 2311 of file lib.php.

prepare_new_submission ( userid,
teachermodified = false 
)

Instantiates a new submission object for a given user

Sets the assignment, userid and times, everything else is set to default values.

Parameters:
int$useridThe userid for which we want a submission object
bool$teachermodifiedstudent submission set if false
Returns:
object The submission

Definition at line 1848 of file lib.php.

Here is the caller graph for this function:

preprocess_submission ( &$  submission)

Preprocess submission before grading

Called by display_submission() The default type does nothing here.

Parameters:
object$submissionThe submission object

Reimplemented in assignment_online.

Definition at line 1148 of file lib.php.

Here is the caller graph for this function:

print_user_files ( userid = 0,
return = false 
)

Produces a list of links to the files uploaded by a user

Parameters:
$useridint optional id of the user. If 0 then $USER->id is used.
$returnboolean optional defaults to false. If true the list is returned rather than printed
Returns:
string optional

Reimplemented in assignment_upload, and assignment_online.

Definition at line 2047 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

process_feedback ( formdata = null)

Process teacher feedback submission

This is called by submissions() when a grading even has taken place. It gets its data from the submitted form.

object object object

Returns:
object|bool The updated submission object or false

For save and next, we need to know the userid to save, and the userid to go We use a new hidden field in the form, and set it to -1. If it's set, we use this as the userid to store

Definition at line 1703 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

process_outcomes ( userid)

Definition at line 1769 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Checks if grading method allows quickgrade mode. At the moment it is hardcoded that advanced grading methods do not allow quickgrade.

Assignment type plugins are not allowed to override this method

Returns:
boolean

Definition at line 803 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

reset_userdata ( data)

Reset all submissions

updating dates - shift may be negative too

Definition at line 2256 of file lib.php.

Here is the call graph for this function:

static restore_one_mod ( info,
restore,
assignment 
) [static]

base implementation for restoring subtype specific information for one single module

Parameters:
array$infothe array representing the xml
object$restorethe restore preferences
Returns:
boolean

Definition at line 2357 of file lib.php.

static restore_one_submission ( info,
restore,
assignment,
submission 
) [static]

base implementation for restoring subtype specific information for one single submission

Parameters:
object$submissionthe newly created submission
array$infothe array representing the xml
object$restorethe restore preferences
Returns:
boolean

Definition at line 2373 of file lib.php.

send_file ( filearea,
args 
)
Parameters:
string$filearea
array$args
Returns:
bool

Reimplemented in assignment_upload, assignment_online, and assignment_uploadsingle.

Definition at line 1956 of file lib.php.

Here is the call graph for this function:

setup_elements ( &$  mform)
Todo:
Document this function

Reimplemented in assignment_upload, assignment_online, and assignment_uploadsingle.

Definition at line 422 of file lib.php.

submissions ( mode)

Top-level function for handling of submissions called by submissions.php

This is for handling the teacher interaction with the grading interface This should be suitable for most assignment types.

object

Parameters:
string$modeSpecifies the kind of teacher interaction taking place

The main switch is changed to facilitate 1) Batch fast grading 2) Skip to the next one on the popup 3) Save and Skip to the next one on the popup

do the fast grading stuff - this process should work for all 3 subclasses

We are in pop up. save the current one and go to the next one.

We are currently in pop up, but we want to skip to next one without saving. This turns out to be similar to a single case The URL used is for the next submission.

Reimplemented in assignment_upload.

Definition at line 611 of file lib.php.

Here is the call graph for this function:

submittedlink ( allgroups = false)

Returns a link with info about the state of the assignment submissions

This is used by view_header to put this link at the top right of the page. For teachers it gives the number of submitted assignments with a link For students it gives the time of their submission. This will be suitable for most assignment types.

object object

Parameters:
bool$allgroupprint all groups info if user can access all groups, suitable for index.php
Returns:
string

Definition at line 376 of file lib.php.

Here is the call graph for this function:

update_grade ( submission)

Update grade item for this submission.

Definition at line 598 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

update_instance ( assignment)

Updates a new assignment activity

Given an object containing all the necessary data, (defined by the form in mod_form.php) this function will update the assignment instance and return the id number The due date is updated in the calendar This is common to all assignment types.

object object

Parameters:
object$assignmentThe data from the form on mod_form.php
Returns:
bool success

Definition at line 549 of file lib.php.

Here is the call graph for this function:

update_main_listing ( submission)

Helper method updating the listing on the main script from popup using javascript

object object

Parameters:
$submissionobject The submission whose data is to be updated on the main page

Run some Javascript to try and update the parent page

Definition at line 819 of file lib.php.

Here is the call graph for this function:

user_complete ( user,
grade = null 
)

Print complete information about the user's interaction with the assignment

Parameters:
$userobject

Definition at line 2167 of file lib.php.

Here is the call graph for this function:

user_outline ( grade)

Return an outline of the user's interaction with the assignment

The default method prints the grade and timemodified

Parameters:
$gradeobject
Returns:
object with properties ->info and ->time

Definition at line 2154 of file lib.php.

If the form was cancelled ('Cancel' or 'Next' was pressed), call cancel method from advanced grading (if applicable) and returns true If the form was submitted, validates it and returns false if validation did not pass. If validation passes, preprocess advanced grading (if applicable) and returns true.

Note to the developers: This is NOT the correct way to implement advanced grading in grading form. The assignment grading was written long time ago and unfortunately does not fully use the mforms. Usually function is_validated() is called to validate the form and get_data() is called to get the data from the form.

Here we have to push the calculated grade to $_POST['xgrade'] because further processing of the form gets the data not from form->get_data(), but from $_POST (using statement like $feedback = data_submitted() )

Definition at line 1655 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

view ( )

Display the assignment, used by view.php

This in turn calls the methods producing individual parts of the page

Reimplemented in assignment_uploadsingle, assignment_upload, and assignment_online.

Definition at line 154 of file lib.php.

Here is the call graph for this function:

Display the assignment dates

Prints the assignment start and end dates in a box. This will be suitable for most assignment types

Reimplemented in assignment_online.

Definition at line 223 of file lib.php.

Here is the caller graph for this function:

view_feedback ( submission = NULL)

Display the feedback to the student

This default method prints the teacher picture and name, date when marked, grade and teacher submissioncomment. If advanced grading is used the method render_grade from the advanced grading controller is called to display the grade.

object object object

Parameters:
object$submissionThe submission object or NULL in which case it will be loaded

Get submission for this assignment

Nothing to show yet

We need the teacher info

Print the feedback

Reimplemented in assignment_upload.

Definition at line 268 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Display the bottom and footer of a page

This default method just prints the footer. This will be suitable for most assignment types

Definition at line 250 of file lib.php.

Here is the caller graph for this function:

view_header ( subpage = '')

Display the header and top of a page

(this doesn't change much for assignment types) This is used by the view() method to print the header of view.php but it can be used on other pages in which case the string to denote the page in the navigation trail should be passed as an argument

object

Parameters:
string$subpageDescription of subpage to be used in navigation trail

Definition at line 184 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Display the assignment intro

This will most likely be extended by assignment type plug-ins The default implementation prints the assignment description in a box

Definition at line 209 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:


Field Documentation

$assignment

Definition at line 60 of file lib.php.

$cm

Definition at line 54 of file lib.php.

Todo:
document this var

Definition at line 80 of file lib.php.

Definition at line 56 of file lib.php.

$coursecontext

Definition at line 58 of file lib.php.

$defaultformat
Todo:
document this var

Definition at line 76 of file lib.php.

$pagetitle

Definition at line 70 of file lib.php.

$strassignment

Definition at line 62 of file lib.php.

$strassignments

Definition at line 64 of file lib.php.

$strlastmodified

Definition at line 68 of file lib.php.

$strsubmissions

Definition at line 66 of file lib.php.

$type

Definition at line 82 of file lib.php.

$usehtmleditor

Definition at line 72 of file lib.php.

const FILTER_ALL = 0

Definition at line 49 of file lib.php.

Definition at line 51 of file lib.php.

const FILTER_SUBMITTED = 1

Definition at line 50 of file lib.php.


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