Source for file assignment.class.php
Documentation is available at assignment.class.php
// This file is part of the Sloodle project (www.sloodle.org)
* This file defines the "Sloodle Object" assignment sub-type.
* It allows students to submit 3d objects in Second Life as Moodle assignments.
* @copyright Copyright (c) 2008 Sloodle (various contributors)
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU GPL v3
* @contributor (various Moodle guys!)
* @contributor Peter R. Bloomfield
/** Attempt to include the Sloodle configuration. */
require_once($CFG->dirroot.
'/mod/sloodle/sl_config.php');
/** Include the general Sloodle functions. */
require_once($CFG->dirroot.
'/mod/sloodle/lib/general.php');
/** Include the base assignment class, if necessary. */
require_once($CFG->dirroot.
'/mod/assignment/lib.php');
* Extend the base assignment class for assignments where you submit an SL object in-world.
* This has been modified from the "assignment_online" type.
parent::assignment_base($cmid, $assignment, $cm, $course);
$this->type =
'sloodleobject';
// Bring in the global user data
// Check that this user can view assignments
$context =
get_context_instance(CONTEXT_MODULE, $this->cm->id);
require_capability('mod/assignment:view', $context);
// Fetch the submission data
$submission =
$this->get_submission();
$sloodle_submission->load_submission($submission);
// Display a texture summary of the submission
print_simple_box_start('center', '70%', '', 0, 'generalbox', 'online');
$sloodle_submission->text_summary(false);
* Display the assignment dates
// Bring in the global user and configuration data
// Make sure the time available and time due dates are set
if (!$this->assignment->timeavailable &&
!$this->assignment->timedue) {
print_simple_box_start('center', '', '', 0, 'generalbox', 'dates');
// Display the time the assignment is available from
if ($this->assignment->timeavailable) {
echo
'<tr><td class="c0">'.
get_string('availabledate','assignment').
':</td>';
echo
' <td class="c1">'.
userdate($this->assignment->timeavailable).
'</td></tr>';
// Display the time the assignment is due by
if ($this->assignment->timedue) {
echo
'<tr><td class="c0">'.
get_string('duedate','assignment').
':</td>';
echo
' <td class="c1">'.
userdate($this->assignment->timedue).
'</td></tr>';
// Is there a submission by this user?
$submission =
$this->get_submission($USER->id);
// Convert the submission to a Sloodle assignment object
$sloodle_submission->load_submission($submission);
// Display the date it was last updated
echo
'<tr><td class="c0">'.
get_string('lastedited').
':</td>';
echo
' <td class="c1">'.
userdate($submission->timemodified);
// Display the number of prims in the submission
echo
' ('.
get_string('numprims', 'sloodle', $sloodle_submission->num_prims).
')</td></tr>';
* Update the submission with the provided data.
* @param int $userid Integer ID of the user making the submission
* @param assignment_sloodleobject_submission $data A structure containing data about the Sloodle assignment submission
* @return bool True if successful, or false otherwise.
$submission =
$this->get_submission($userid, true);
$update->id =
$submission->id;
$update->data1 =
"{
$data->obj_name}|{$data->num_prims}";
$update->data2 =
"{
$data->primdrop_name}|{$data->primdrop_uuid}|{$data->primdrop_region}|{$data->primdrop_pos}";
$update->timemodified =
time();
return update_record('assignment_submissions', $update);
if (!($submission =
$this->get_submission($userid))) {
// Output the Submission data
$sloodle_submission->load_submission($submission);
//$text = '<b>'.shorten_text(trim(strip_tags($sloodle_submission->obj_name)), 20).'</b><br>';
$text =
'<div class="files">'.
'<img src="'.
$CFG->pixpath.
'/f/html.gif" class="icon" alt="html" />'.
link_to_popup_window ('/mod/assignment/type/sloodleobject/file.php?id='.
$this->cm->id.
'&userid='.
$submission->userid, 'file'.
$userid, shorten_text(trim(strip_tags($sloodle_submission->obj_name)), 20), 450, 580,
get_string('submission', 'assignment'), 'none', true).
if ($return) return $text;
if (!$submission =
$this->get_submission($userid)) {
// Construct a Sloodle submission object
$sloodle_submission->load_submission($submission);
// Display the number of prims
print_simple_box_start('center', '', '', 0, 'generalbox', 'wordcount');
echo
' ('.
get_string('numprims', 'sloodle', $sloodle_submission->num_prims).
')';
// Display the text summary of this submission
print_simple_box($sloodle_submission->text_summary(), 'center', '100%');
$ynoptions =
array( 0 =>
get_string('no'), 1 =>
get_string('yes'));
$mform->addElement('select', 'resubmit', get_string("allowresubmit", "assignment"), $ynoptions);
$mform->setHelpButton('resubmit', array('resubmit', get_string('allowresubmit', 'assignment'), 'assignment'));
$mform->setDefault('resubmit', 0);
$mform->addElement('select', 'emailteachers', get_string("emailteachers", "assignment"), $ynoptions);
$mform->setHelpButton('emailteachers', array('emailteachers', get_string('emailteachers', 'assignment'), 'assignment'));
$mform->setDefault('emailteachers', 0);
* Defines a submission for a Sloodle assignment.
* Indicates whether or not a submission is loaded
* Name of the object which has been submitted.
* Number of prims in the object which has been submitted
* Name of the PrimDrop object into which this object was submitted.
* UUID of the PrimDrop object into which this object was submitted.
* Name of the region where this object was submitted
* Position where this object was submitted (as a vector, "<x,y,z>")
* Parses the data from a Submission database record object.
* @var object $submission The submission database record object.
// Make sure the submission is valid
if ($submission ==
false ||
$submission ==
null) return;
$object_data =
explode('|', $submission->data1);
$primdrop_data =
explode('|', $submission->data2);
// Make sure there's enough data in both
if (count($object_data) <
2 ||
count($primdrop_data) <
4) return;
// Extract the data items
* Sets the position as 3 components.
* @param float x The X coordinate
* @param float y The Y coordinate
* @param float z The Z coordinate
* Gets the X coordinate of the position
* @return float The X coordinate of the position
* Gets the Y coordinate of the position
* @return float The Y coordinate of the position
* Gets the Z coordinate of the position
* @return float The Z coordinate of the position
* Construct a text summary of this submission.
* @param bool $return If TRUE (default) then the text will be submitted instead of printed.
* @return string If parameter $return was TRUE, then it returns the string. Otherwise, an empty string.
// Make sure something is loaded
$text =
get_string('emptysubmission', 'assignment');
$text =
"Object name: <b>{$this->obj_name}</b><br><br>
";
if (!$arr) $arr =
array('x'=>
0, 'y'=>
0, 'z'=>
0);
$loc =
"secondlife://{
$this->primdrop_region}/{
$arr['x']}/{
$arr['y']}/{
$arr['z']}";
$text .= "<b><a href=\"$loc\">$loc</a></b><br>";
if ($return) return $text;
Documentation generated on Mon, 16 Jun 2008 15:56:06 +0100 by phpDocumentor 1.4.0