/**
  * Add a new submission (or replace an existing one).
  * Ignores all submission checks, such as permissions and time.
  * @param SloodleUser $user The user making the submission
  * @param string $obj_name Name of the object being submitted
  * @param int $num_prims Number of prims in the object being submitted
  * @param string $primdrop_name Name of the PrimDrop being submitted to
  * @param string $primdrop_uuid UUID of the PrimDrop being submitted to
  * @param string $primdrop_region Region of the PrimDrop being submitted to
  * @param string $primdrop_pos Position vector (<x,y,z>) of the PrimDrop being submitted to
  * @return bool True if successful, or false otherwise
  */
 function submit($user, $obj_name, $num_prims, $primdrop_name, $primdrop_uuid, $primdrop_region, $primdrop_pos)
 {
     // Make sure the user is loaded
     if (!$user->is_user_loaded()) {
         return false;
     }
     // Construct a submission object
     $sloodle_submission = new assignment_sloodleobject_submission();
     $sloodle_submission->obj_name = $obj_name;
     $sloodle_submission->num_prims = $num_prims;
     $sloodle_submission->primdrop_name = $primdrop_name;
     $sloodle_submission->primdrop_uuid = $primdrop_uuid;
     $sloodle_submission->primdrop_region = $primdrop_region;
     $sloodle_submission->primdrop_pos = $primdrop_pos;
     // Update the submission
     return $this->assignment->update_submission($user->get_user_id(), $sloodle_submission);
 }
예제 #2
0
    error("Assignment ID was incorrect");
}
if (!($course = get_record("course", "id", $assignment->course))) {
    error("Course is misconfigured");
}
if (!($user = get_record("user", "id", $userid))) {
    error("User is misconfigured");
}
require_login($course->id, false, $cm);
if ($USER->id != $user->id && !has_capability('mod/assignment:grade', get_context_instance(CONTEXT_MODULE, $cm->id))) {
    error("You can not view this assignment");
}
if ($assignment->assignmenttype != 'sloodleobject') {
    error("Incorrect assignment type");
}
$assignmentinstance = new assignment_sloodleobject($cm->id, $assignment, $cm, $course);
if ($submission = $assignmentinstance->get_submission($user->id)) {
    print_header(fullname($user, true) . ': ' . $assignment->name);
    // Get the Sloodle submission data
    $sloodle_submission = new assignment_sloodleobject_submission();
    $sloodle_submission->load_submission($submission);
    print_simple_box_start('center', '', '', '', 'generalbox', 'dates');
    echo '<table>';
    if ($assignment->timedue) {
        echo '<tr><td class="c0">' . get_string('duedate', 'assignment') . ':</td>';
        echo '    <td class="c1">' . userdate($assignment->timedue) . '</td></tr>';
    }
    echo '<tr><td class="c0">' . get_string('lastedited') . ':</td>';
    echo '    <td class="c1">' . userdate($submission->timemodified);
    // Show the number of prims
    $num_prims = $sloodle_submission->num_prims;