[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/mod/assignment/ -> lib.php (summary)

assignment_base is the base class for assignment types This class provides all the functionality for an assignment

File Size: 3063 lines (121 kb)
Included or required: 7 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

assignment_base:: (77 methods):
  assignment_base()
  view()
  view_header()
  view_intro()
  view_dates()
  view_footer()
  view_feedback()
  submittedlink()
  setup_elements()
  add_instance()
  delete_instance()
  update_instance()
  update_grade()
  submissions()
  update_main_listing()
  display_grade()
  display_submission()
  preprocess_submission()
  display_submissions()
  process_feedback()
  process_outcomes()
  get_submission()
  prepare_new_submission()
  get_submissions()
  count_real_submissions()
  email_teachers()
  get_graders()
  email_teachers_text()
  email_teachers_html()
  print_user_files()
  count_user_files()
  file_area_name()
  file_area()
  isopen()
  description_is_hidden()
  user_outline()
  user_complete()
  display_lateness()
  delete()
  custom_feedbackform()
  get_coursemodule_info()
  cron()
  reset_userdata()
  assignment_delete_instance()
  assignment_update_instance()
  assignment_add_instance()
  assignment_user_outline()
  assignment_user_complete()
  assignment_cron()
  assignment_get_user_grades()
  assignment_update_grades()
  assignment_grade_item_update()
  assignment_grade_item_delete()
  assignment_get_participants()
  assignment_scale_used()
  assignment_scale_used_anywhere()
  assignment_refresh_events()
  assignment_print_recent_activity()
  assignment_get_recent_mod_activity()
  assignment_print_recent_mod_activity()
  assignment_log_info()
  assignment_get_unmailed_submissions()
  assignment_count_real_submissions()
  assignment_get_all_submissions()
  assignment_get_coursemodule_info()
  assignment_types()
  assignment_upgrade_submodules()
  assignment_print_overview()
  assignment_display_lateness()
  assignment_get_view_actions()
  assignment_get_post_actions()
  assignment_get_types()
  assignment_reset_gradebook()
  assignment_reset_userdata()
  assignment_reset_course_form_definition()
  assignment_reset_course_form_defaults()
  assignment_get_extra_capabilities()


Class: assignment_base  - X-Ref

Standard base class for all assignment submodules (assignment types).

assignment_base($cmid='staticonly', $assignment=NULL, $cm=NULL, $course=NULL)   X-Ref
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.

param: cmid   integer, the current course module id - not set for new assignments
param: assignment   object, usually null, but if we have it we pass it to save db access
param: cm   object, usually null, but if we have it we pass it to save db access
param: course   object, usually null, but if we have it we pass it to save db access

view()   X-Ref
Display the assignment, used by view.php

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

view_header($subpage='')   X-Ref
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

param: $subpage string Description of subpage to be used in navigation trail

view_intro()   X-Ref
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

view_dates()   X-Ref
Display the assignment dates

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

view_footer()   X-Ref
Display the bottom and footer of a page

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

view_feedback($submission=NULL)   X-Ref
Display the feedback to the student

This default method prints the teacher picture and name, date when marked,
grade and teacher submissioncomment.

param: $submission object The submission object or NULL in which case it will be loaded

submittedlink($allgroups=false)   X-Ref
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.
param: bool $allgroup print all groups info if user can access all groups, suitable for index.php
return: string

setup_elements(&$mform)   X-Ref
No description

add_instance($assignment)   X-Ref
Create a new assignment activity

Given an object containing all the necessary data,
(defined by the form in mod.html) 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.

param: $assignment object The data from the form on mod.html
return: int The id of the assignment

delete_instance($assignment)   X-Ref
Deletes an assignment activity

Deletes all database records, files and calendar events for this assignment.
param: $assignment object The assignment to be deleted
return: boolean False indicates error

update_instance($assignment)   X-Ref
Updates a new assignment activity

Given an object containing all the necessary data,
(defined by the form in mod.html) 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.

param: $assignment object The data from the form on mod.html
return: int The assignment id

update_grade($submission)   X-Ref
Update grade item for this submission.


submissions($mode)   X-Ref
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.

param: $mode string Specifies the kind of teacher interaction taking place

update_main_listing($submission)   X-Ref
Helper method updating the listing on the main script from popup using javascript

param: $submission object The submission whose data is to be updated on the main page

display_grade($grade)   X-Ref
Return a grade in user-friendly form, whether it's a scale or not

param: $grade
return: string User-friendly representation of grade

display_submission($extra_javascript = '')   X-Ref
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

preprocess_submission(&$submission)   X-Ref
Preprocess submission before grading

Called by display_submission()
The default type does nothing here.
param: $submission object The submission object

display_submissions($message='')   X-Ref
Display all the submissions ready for grading


process_feedback()   X-Ref
Process teacher feedback submission

This is called by submissions() when a grading even has taken place.
It gets its data from the submitted form.
return: object The updated submission object

process_outcomes($userid)   X-Ref
No description

get_submission($userid=0, $createnew=false, $teachermodified=false)   X-Ref
Load the submission object for a particular user

param: $userid int The id of the user whose submission we want or 0 in which case USER->id is used
param: $createnew boolean optional Defaults to false. If set to true a new submission object will be created in the database
param: bool $teachermodified student submission set if false
return: object The submission

prepare_new_submission($userid, $teachermodified=false)   X-Ref
Instantiates a new submission object for a given user

Sets the assignment, userid and times, everything else is set to default values.
param: $userid int The userid for which we want a submission object
param: bool $teachermodified student submission set if false
return: object The submission

get_submissions($sort='', $dir='DESC')   X-Ref
Return all assignment submissions by ENROLLED students (even empty)

param: $sort string optional field names for the ORDER BY in the sql query
param: $dir string optional specifying the sort direction, defaults to DESC
return: array The submission objects indexed by id

count_real_submissions($groupid=0)   X-Ref
Counts all real assignment submissions by ENROLLED students (not empty ones)

param: $groupid int optional If nonzero then count is restricted to this group
return: int The number of submissions

email_teachers($submission)   X-Ref
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.
param: $submission object The submission that has changed

get_graders($user)   X-Ref
Returns a list of teachers that should be grading given submission


email_teachers_text($info)   X-Ref
Creates the text content for emails to teachers

param: $info object The info used by the 'emailteachermail' language string
return: string

email_teachers_html($info)   X-Ref
Creates the html content for emails to teachers

param: $info object The info used by the 'emailteachermailhtml' language string
return: string

print_user_files($userid=0, $return=false)   X-Ref
Produces a list of links to the files uploaded by a user

param: $userid int optional id of the user. If 0 then $USER->id is used.
param: $return boolean optional defaults to false. If true the list is returned rather than printed
return: string optional

count_user_files($userid)   X-Ref
Count the files uploaded by a given user

param: $userid int The user id
return: int

file_area_name($userid)   X-Ref
Creates a directory file name, suitable for make_upload_directory()

param: $userid int The user id
return: string path to file area

file_area($userid)   X-Ref
Makes an upload directory

param: $userid int The user id
return: string path to file area.

isopen()   X-Ref
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.
return: boolean

description_is_hidden()   X-Ref
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
return: boolen

user_outline($user)   X-Ref
Return an outline of the user's interaction with the assignment

The default method prints the grade and timemodified
param: $user object
return: object with properties ->info and ->time

user_complete($user)   X-Ref
Print complete information about the user's interaction with the assignment

param: $user object

display_lateness($timesubmitted)   X-Ref
Return a string indicating how late a submission is

param: $timesubmitted int
return: string

delete()   X-Ref
Empty method stub for all delete actions.


custom_feedbackform($submission, $return=false)   X-Ref
Empty custom feedback grading form.


get_coursemodule_info($coursemodule)   X-Ref
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.

param: $coursemodule object The coursemodule object (record).
return: object An object on information that the coures will know about (most noticeably, an icon).

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

return: void

reset_userdata($data)   X-Ref
Reset all submissions


assignment_delete_instance($id)   X-Ref
Deletes an assignment instance

This is done by calling the delete_instance() method of the assignment type class

assignment_update_instance($assignment)   X-Ref
Updates an assignment instance

This is done by calling the update_instance() method of the assignment type class

assignment_add_instance($assignment)   X-Ref
Adds an assignment instance

This is done by calling the add_instance() method of the assignment type class

assignment_user_outline($course, $user, $mod, $assignment)   X-Ref
Returns an outline of a user interaction with an assignment

This is done by calling the user_outline() method of the assignment type class

assignment_user_complete($course, $user, $mod, $assignment)   X-Ref
Prints the complete info about a user's interaction with an assignment

This is done by calling the user_complete() method of the assignment type class

assignment_cron()   X-Ref
Function to be run periodically according to the moodle cron

Finds all assignment notifications that have yet to be mailed out, and mails them

assignment_get_user_grades($assignment, $userid=0)   X-Ref
Return grade for given user or all users.

param: int $assignmentid id of assignment
param: int $userid optional user id, 0 means all users
return: array array of grades, false if none

assignment_update_grades($assignment=null, $userid=0, $nullifnone=true)   X-Ref
Update grades by firing grade_updated event

param: object $assignment null means all assignments
param: int $userid specific user only, 0 mean all

assignment_grade_item_update($assignment, $grades=NULL)   X-Ref
Create grade item for given assignment

param: object $assignment object with extra cmidnumber
param: mixed optional array/object of grade(s); 'reset' means reset grades in gradebook
return: int 0 if ok, error code otherwise

assignment_grade_item_delete($assignment)   X-Ref
Delete grade item for given assignment

param: object $assignment object
return: object assignment

assignment_get_participants($assignmentid)   X-Ref
Returns the users with data in one assignment (students and teachers)

param: $assignmentid int
return: array of user objects

assignment_scale_used($assignmentid, $scaleid)   X-Ref
Checks if a scale is being used by an assignment

This is used by the backup code to decide whether to back up a scale
param: $assignmentid int
param: $scaleid int
return: boolean True if the scale is used by the assignment

assignment_scale_used_anywhere($scaleid)   X-Ref
Checks if scale is being used by any instance of assignment

This is used to find out if scale used anywhere
param: $scaleid int
return: boolean True if the scale is used by any assignment

assignment_refresh_events($courseid = 0)   X-Ref
Make sure up-to-date events are created for all assignment instances

This standard function will check all instances of this module
and make sure there are up-to-date events created for each of them.
If courseid = 0, then every assignment event in the site is checked, else
only assignment events belonging to the course specified are checked.
This function is used, in its new format, by restore_refresh_events()

param: $courseid int optional If zero then all assignments for all courses are covered
return: boolean Always returns true

assignment_print_recent_activity($course, $viewfullnames, $timestart)   X-Ref
Print recent activity from all assignments in a given course

This is used by the recent activity block

assignment_get_recent_mod_activity(&$activities, &$index, $timestart, $courseid, $cmid, $userid=0, $groupid=0)   X-Ref
Returns all assignments since a given time in specified forum.


assignment_print_recent_mod_activity($activity, $courseid, $detail, $modnames)   X-Ref
Print recent activity from all assignments in a given course

This is used by course/recent.php

assignment_log_info($log)   X-Ref
Fetch info from logs

param: $log object with properties ->info (the assignment id) and ->userid
return: array with assignment name and user firstname and lastname

assignment_get_unmailed_submissions($starttime, $endtime)   X-Ref
Return list of marked submissions that have not been mailed out for currently enrolled students

return: array

assignment_count_real_submissions($cm, $groupid=0)   X-Ref
Counts all real assignment submissions by ENROLLED students (not empty ones)

There are also assignment type methods count_real_submissions() wich in the default
implementation simply call this function.
param: $groupid int optional If nonzero then count is restricted to this group
return: int The number of submissions

assignment_get_all_submissions($assignment, $sort="", $dir="DESC")   X-Ref
Return all assignment submissions by ENROLLED students (even empty)

There are also assignment type methods get_submissions() wich in the default
implementation simply call this function.
param: $sort string optional field names for the ORDER BY in the sql query
param: $dir string optional specifying the sort direction, defaults to DESC
return: array The submission objects indexed by id

assignment_get_coursemodule_info($coursemodule)   X-Ref
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.

param: $coursemodule object The coursemodule object (record).
return: object An object on information that the coures will know about (most noticeably, an icon).

assignment_types()   X-Ref
Returns an array of installed assignment types indexed and sorted by name

return: array The index is the name of the assignment type, the value its full name from the language strings

assignment_upgrade_submodules()   X-Ref
Executes upgrade scripts for assignment types when necessary


assignment_print_overview($courses, &$htmlarray)   X-Ref
No description

assignment_display_lateness($timesubmitted, $timedue)   X-Ref
No description

assignment_get_view_actions()   X-Ref
No description

assignment_get_post_actions()   X-Ref
No description

assignment_get_types()   X-Ref
No description

assignment_reset_gradebook($courseid, $type='')   X-Ref
Removes all grades from gradebook

param: int $courseid
param: string optional type

assignment_reset_userdata($data)   X-Ref
This function is used by the reset_course_userdata function in moodlelib.
This function will remove all posts from the specified assignment
and clean up any related data.

param: $data the data submitted from the reset course.
return: array status array

assignment_reset_course_form_definition(&$mform)   X-Ref
Implementation of the function for printing the form elements that control
whether the course reset functionality affects the assignment.

param: $mform form passed by reference

assignment_reset_course_form_defaults($course)   X-Ref
Course reset form defaults.


assignment_get_extra_capabilities()   X-Ref
Returns all other caps used in module




Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7