<?php

/**
 * 
 * @author Julia Tejerina, Oscar Sanchez, Javier Gonzalez 
 * @version $Id: editsubmissions.php, v 2.0 2009/25/04
 * @package webquestscorm
 **/
require_once "../../config.php";
require_once "locallib.php";
global $USER;
$cmid = optional_param('cmid', 0, PARAM_INT);
$element = optional_param('element', 0);
require_once "submissions.class.php";
$submissionsinstance = new submissions($cmid);
require_login($submissionsinstance->course->id);
webquestscorm_print_header($submissionsinstance->wqname, 'uploadTasks', $submissionsinstance->course, $submissionsinstance->cm);
switch ($element) {
    case 'uploadTasks':
        echo '<div class="reportlink">' . $submissionsinstance->submittedlink() . '</div>';
        require_once "uploadTasks.php";
        print_footer();
        break;
    case 'uploadedTasks':
        require_once "submissions.php";
        break;
}
<?php

/**
 * 
 * @author Julia Tejerina, Oscar Sanchez, Javier Gonzalez
 * @version $Id: upload.php, v 2.0 2009/25/04
 * @package webquestscorm
 **/
require_once "../../config.php";
require_once "locallib.php";
global $CFG, $USER;
require_once "submissions.class.php";
$cmid = required_param('cmid');
$submissionsinstance = new submissions($cmid);
require_login($submissionsinstance->course->id, false, $submissionsinstance->cm);
require_capability('mod/webquestscorm:submit', $submissionsinstance->context);
webquestscorm_print_header($submissionsinstance->wqname, 'uploadTasks', $submissionsinstance->course, $submissionsinstance->cm);
$filecount = $submissionsinstance->count_user_files($USER->id);
$submission = $submissionsinstance->get_submission($USER->id);
if ($submissionsinstance->isopen() && (!$filecount || $submissionsinstance->wqresubmit || !$submission->timemarked)) {
    if ($submission = $submissionsinstance->get_submission($USER->id)) {
        //TODO: change later to ">= 0", to prevent resubmission when graded 0
        if ($submission->grade > 0 and !$submissionsinstance->wqresubmit) {
            notify(get_string('alreadygraded', 'webquestscorm'));
        }
    }
    $dir = $submissionsinstance->file_area_name($USER->id);
    require_once $CFG->dirroot . '/lib/uploadlib.php';
    $um = new upload_manager('newfile', true, false, $submissionsinstance->course, false, $submissionsinstance->wqmaxbytes);
    if ($um->process_file_uploads($dir)) {
        $newfile_name = $um->get_new_filename();
/**
 * 
 * @author Julia Tejerina, Oscar Sanchez, Javier Gonzalez
 * @version $Id: submissions.php, v 2.0 2009/25/04
 * @package webquestscorm
 **/
require_once "../../config.php";
require_once "lib.php";
require_once "locallib.php";
global $CFG, $USER;
$cmid = optional_param('cmid', 0, PARAM_INT);
// Course module ID
if (!isset($submissionsinstance)) {
    require_once "submissions.class.php";
    $submissionsinstance = new submissions($cmid);
}
require_login($submissionsinstance->course->id, false, $submissionsinstance->cm);
require_capability('mod/webquestscorm:grade', $submissionsinstance->context);
$subelement = optional_param('subelement', 'all', PARAM_ALPHA);
// What mode are we in?
$mode = optional_param('mode', $subelement, PARAM_ALPHA);
// What mode are we in?
if ($form = data_submitted()) {
    if ($form->tabs == 'required') {
        webquestscorm_print_header($submissionsinstance->wqname, 'uploadTasks', $submissionsinstance->course, $submissionsinstance->cm);
    }
}
switch ($mode) {
    case 'grade':
        // We are in a popup window grading