mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
Initial draft of submission support
This commit is contained in:
parent
6d86051250
commit
33e4dea627
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="mod/workshop/db" VERSION="20090601" COMMENT="XMLDB file for Moodle mod/workshop"
|
||||
<XMLDB PATH="mod/workshop/db" VERSION="20090605" COMMENT="XMLDB file for Moodle mod/workshop"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
@ -50,8 +50,13 @@
|
||||
<FIELD NAME="example" TYPE="int" LENGTH="2" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Is this submission an example from teacher" PREVIOUS="workshopid" NEXT="userid"/>
|
||||
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="The author of the submission" PREVIOUS="example" NEXT="timecreated"/>
|
||||
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="Timestamp when the work was submitted for the first time" PREVIOUS="userid" NEXT="timemodified"/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="Timestamp when the submission has been updated" PREVIOUS="timecreated" NEXT="grade"/>
|
||||
<FIELD NAME="grade" TYPE="number" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" DECIMALS="5" COMMENT="Grade for the submission calculated as average of the peer-assessments. The grade is a number from interval 0..100. If NULL then the grade for submission has not been aggregated yet." PREVIOUS="timemodified" NEXT="gradeover"/>
|
||||
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="Timestamp when the submission has been updated" PREVIOUS="timecreated" NEXT="title"/>
|
||||
<FIELD NAME="title" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="The submission title" PREVIOUS="timemodified" NEXT="data"/>
|
||||
<FIELD NAME="data" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false" COMMENT="Submission text" PREVIOUS="title" NEXT="dataformat"/>
|
||||
<FIELD NAME="dataformat" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="The format of submission text" PREVIOUS="data" NEXT="datatrust"/>
|
||||
<FIELD NAME="datatrust" TYPE="int" LENGTH="3" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="The trust mode of the data" PREVIOUS="dataformat" NEXT="attachment"/>
|
||||
<FIELD NAME="attachment" TYPE="int" LENGTH="2" NOTNULL="false" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Used by File API file_postupdate_standard_filemanager" PREVIOUS="datatrust" NEXT="grade"/>
|
||||
<FIELD NAME="grade" TYPE="number" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" DECIMALS="5" COMMENT="Grade for the submission calculated as average of the peer-assessments. The grade is a number from interval 0..100. If NULL then the grade for submission has not been aggregated yet." PREVIOUS="attachment" NEXT="gradeover"/>
|
||||
<FIELD NAME="gradeover" TYPE="number" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" DECIMALS="5" COMMENT="Grade for the submission manually overridden by a teacher. Grade is always from interval 0..100. If NULL then the grade is not overriden." PREVIOUS="grade" NEXT="gradeoverby"/>
|
||||
<FIELD NAME="gradeoverby" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" COMMENT="The id of the user who has overridden the grade for submission." PREVIOUS="gradeover" NEXT="gradinggrade"/>
|
||||
<FIELD NAME="gradinggrade" TYPE="number" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" DECIMALS="5" COMMENT="Grade for the assessment calculated by the module. The grade is a number from interval 0..100. If NULL then the grade for assessment has not been aggregated yet." PREVIOUS="gradeoverby" NEXT="teachercomment"/>
|
||||
|
@ -27,45 +27,32 @@
|
||||
require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
|
||||
require_once(dirname(__FILE__).'/lib.php');
|
||||
|
||||
$id = optional_param('id', 0, PARAM_INT); // course_module ID, or
|
||||
$a = optional_param('a', 0, PARAM_INT); // workshop instance ID
|
||||
$cmid = required_param('cmid', PARAM_INT); // course module id
|
||||
|
||||
if (!$cm = get_coursemodule_from_id('workshop', $cmid)) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (!$course = $DB->get_record('course', array('id' => $cm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
if (! $cm = get_coursemodule_from_id('workshop', $id)) {
|
||||
error('Course Module ID was incorrect');
|
||||
}
|
||||
require_login($course, false, $cm);
|
||||
|
||||
if (! $course = $DB->get_record('course', array('id' => $cm->course))) {
|
||||
error('Course is misconfigured');
|
||||
}
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
if (! $workshop = $DB->get_record('workshop', array('id' => $cm->instance))) {
|
||||
error('Course module is incorrect');
|
||||
}
|
||||
|
||||
} else if ($a) {
|
||||
if (! $workshop = $DB->get_record('workshop', array('id' => $a))) {
|
||||
error('Course module is incorrect');
|
||||
}
|
||||
if (! $course = $DB->get_record('course', array('id' => $workshop->course))) {
|
||||
error('Course is misconfigured');
|
||||
}
|
||||
if (! $cm = get_coursemodule_from_instance('workshop', $workshop->id, $course->id)) {
|
||||
error('Course Module ID was incorrect');
|
||||
}
|
||||
|
||||
} else {
|
||||
error('You must specify a course_module ID or an instance ID');
|
||||
if (isguestuser()) {
|
||||
print_error('guestnoedit', 'workshop', "$CFG->wwwroot/mod/workshop/view.php?id=$cmid");
|
||||
}
|
||||
|
||||
require_login($course, true, $cm);
|
||||
|
||||
add_to_log($course->id, "workshop", "editgradingform", "editgradingform.php?id=$cm->id", "$workshop->id");
|
||||
if (!$workshop = $DB->get_record('workshop', array('id' => $cm->instance))) {
|
||||
print_error('invalidid', 'workshop');
|
||||
}
|
||||
|
||||
// where should the user be sent after closing the editing form
|
||||
$returnurl = "{$CFG->wwwroot}/mod/workshop/view.php?id={$cm->id}";
|
||||
// the URL of this editing form
|
||||
$selfurl = "{$CFG->wwwroot}/mod/workshop/editgradingform.php?id={$cm->id}";
|
||||
$selfurl = "{$CFG->wwwroot}/mod/workshop/editgradingform.php?cmid={$cm->id}";
|
||||
|
||||
// load the grading strategy logic
|
||||
$strategylib = dirname(__FILE__) . '/grading/' . $workshop->strategy . '/strategy.php';
|
||||
|
@ -95,7 +95,7 @@ $string['nsassessments'] = 'Number of required assessments of other users\' work
|
||||
$string['releasegrades'] = 'Push final grades into the gradebook';
|
||||
$string['requirepassword'] = 'Require password';
|
||||
$string['saveandclose'] = 'Save and close';
|
||||
$string['saveandcontinue'] = 'Save and continue';
|
||||
$string['saveandcontinue'] = 'Save and continue editing';
|
||||
$string['strategyaccumulative'] = 'Accumulative grading';
|
||||
$string['strategyerrorbanded'] = 'Error banded grading';
|
||||
$string['strategy'] = 'Grading strategy';
|
||||
|
136
mod/workshop/submission.php
Normal file
136
mod/workshop/submission.php
Normal file
@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
/**
|
||||
* Submit an assignment or edit the already submitted work
|
||||
*
|
||||
* @package mod-workshop
|
||||
* @copyright 2009 David Mudrak <david.mudrak@gmail.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
|
||||
require_once(dirname(__FILE__).'/lib.php');
|
||||
require_once(dirname(__FILE__).'/submission_form.php');
|
||||
|
||||
$cmid = required_param('cmid', PARAM_INT); // course module id
|
||||
$id = optional_param('id', 0, PARAM_INT); // submission id
|
||||
|
||||
if (!$cm = get_coursemodule_from_id('workshop', $cmid)) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (!$course = $DB->get_record('course', array('id' => $cm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
|
||||
require_login($course, false, $cm);
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
if (isguestuser()) {
|
||||
print_error('guestnoedit', 'workshop', "$CFG->wwwroot/mod/workshop/view.php?id=$cmid");
|
||||
}
|
||||
|
||||
if (!$workshop = $DB->get_record('workshop', array('id' => $cm->instance))) {
|
||||
print_error('invalidid', 'workshop');
|
||||
}
|
||||
|
||||
if ($id) { // if submission is specified
|
||||
if (!$submission = $DB->get_record('workshop_submissions', array('id' => $id, 'workshopid' => $workshop->id))) {
|
||||
print_error('invalidsubmissionid', 'workshop');
|
||||
}
|
||||
// todo check access rights
|
||||
|
||||
} else { // new submission
|
||||
//require_capability('mod/workshop:submit', $context);
|
||||
$submission = new object();
|
||||
$submission->id = null;
|
||||
}
|
||||
|
||||
$maxfiles = $workshop->nattachments;
|
||||
$maxbytes = $workshop->maxbytes;
|
||||
|
||||
$dataoptions = array('trusttext' => true, 'subdirs' => false, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes);
|
||||
$attachmentoptions = array('subdirs' => false, 'maxfiles'=>$maxfiles, 'maxbytes'=>$maxbytes);
|
||||
|
||||
$submission = file_prepare_standard_editor($submission, 'data', $dataoptions, $context, 'workshop_submission', $submission->id);
|
||||
$submission = file_prepare_standard_filemanager($submission, 'attachment', $attachmentoptions, $context,
|
||||
'workshop_attachment', $submission->id);
|
||||
|
||||
$submission->cmid = $cm->id;
|
||||
|
||||
// create form and set initial data
|
||||
$mform = new workshop_submission_form(null, array('current' => $submission, 'cm' => $cm, 'workshop'=>$workshop,
|
||||
'dataoptions' => $dataoptions, 'attachmentoptions'=>$attachmentoptions));
|
||||
|
||||
if ($mform->is_cancelled()){
|
||||
if ($id){
|
||||
redirect("view.php?id=$cm->id");
|
||||
} else {
|
||||
redirect("view.php?id=$cm->id");
|
||||
}
|
||||
|
||||
} else if ($submission = $mform->get_data()) {
|
||||
|
||||
$timenow = time();
|
||||
|
||||
if (empty($submission->id)) {
|
||||
$submission->workshopid = $workshop->id;
|
||||
$submission->example = 0; // todo add examples support
|
||||
$submission->userid = $USER->id;
|
||||
$submission->timecreated = $timenow;
|
||||
}
|
||||
|
||||
$submission->timemodified = $timenow;
|
||||
$submission->title = trim($submission->title);
|
||||
$submission->data = ''; // updated later
|
||||
$submission->dataformat = FORMAT_HTML; // updated later
|
||||
$submission->datatrust = 0; // updated later
|
||||
|
||||
if (empty($submission->id)) {
|
||||
//new submission
|
||||
$submission->id = $DB->insert_record('workshop_submissions', $submission);
|
||||
// todo add to log
|
||||
|
||||
} else {
|
||||
//existing submission
|
||||
$DB->update_record('workshop_submissions', $submission);
|
||||
// todo add to log
|
||||
}
|
||||
|
||||
// save and relink embedded images and save attachments
|
||||
$submission = file_postupdate_standard_editor($submission, 'data', $dataoptions, $context, 'workshop_submission', $submission->id);
|
||||
$submission = file_postupdate_standard_filemanager($submission, 'attachment', $attachmentoptions, $context, 'workshop_attachment', $submission->id);
|
||||
|
||||
// store the updated value values
|
||||
$DB->update_record('workshop_submissions', $submission);
|
||||
|
||||
redirect("view.php?id=$cm->id");
|
||||
}
|
||||
|
||||
$stredit = empty($submission->id) ? get_string('addsubmission', 'workshop') : get_string('edit');
|
||||
|
||||
$navigation = build_navigation($stredit, $cm);
|
||||
print_header_simple(format_string($workshop->name), "", $navigation, "", "", true, "", navmenu($course, $cm));
|
||||
|
||||
print_heading(format_string($workshop->name));
|
||||
|
||||
$mform->display();
|
||||
|
||||
print_footer($course);
|
70
mod/workshop/submission_form.php
Normal file
70
mod/workshop/submission_form.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
/**
|
||||
* Submit an assignment or edit the already submitted work
|
||||
*
|
||||
* @package mod-workshop
|
||||
* @copyright 2009 David Mudrak <david.mudrak@gmail.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once ($CFG->dirroot.'/lib/formslib.php');
|
||||
|
||||
class workshop_submission_form extends moodleform {
|
||||
|
||||
function definition() {
|
||||
|
||||
$mform = $this->_form;
|
||||
|
||||
$current = $this->_customdata['current'];
|
||||
$workshop = $this->_customdata['workshop'];
|
||||
$cm = $this->_customdata['cm'];
|
||||
$dataoptions = $this->_customdata['dataoptions'];
|
||||
$attachmentoptions = $this->_customdata['attachmentoptions'];
|
||||
|
||||
$mform->addElement('header', 'general', get_string('submission', 'workshop'));
|
||||
|
||||
$mform->addElement('text', 'title', get_string('submissiontitle', 'workshop'));
|
||||
$mform->setType('title', PARAM_TEXT);
|
||||
$mform->addRule('title', null, 'required', null, 'client');
|
||||
|
||||
$mform->addElement('editor', 'data_editor', get_string('submissiondata', 'workshop'), null, $dataoptions);
|
||||
$mform->setType('data_editor', PARAM_RAW);
|
||||
|
||||
$mform->addElement('filemanager', 'attachment_filemanager', get_string('submissionattachment', 'workshop'),
|
||||
null, $attachmentoptions);
|
||||
|
||||
$mform->addElement('hidden', 'id');
|
||||
$mform->addElement('hidden', 'cmid');
|
||||
|
||||
$this->add_action_buttons();
|
||||
|
||||
$this->set_data($current);
|
||||
}
|
||||
|
||||
|
||||
function validation($data, $files) {
|
||||
global $CFG, $USER, $DB;
|
||||
|
||||
$errors = parent::validation($data, $files);
|
||||
return $errors;
|
||||
}
|
||||
}
|
@ -82,7 +82,9 @@ print_header_simple(format_string($workshop->name), '', $navigation, '', '', tru
|
||||
|
||||
/// Print the main part of the page
|
||||
|
||||
echo "<a href=\"editgradingform.php?id={$cm->id}\">Edit grading form</a>";
|
||||
echo "<a href=\"editgradingform.php?cmid={$cm->id}\">Edit grading form</a>";
|
||||
echo " | ";
|
||||
echo "<a href=\"submission.php?cmid={$cm->id}\">My submission</a>";
|
||||
|
||||
/// Finish the page
|
||||
print_footer($course);
|
||||
|
Loading…
x
Reference in New Issue
Block a user