Commit 6df08cac authored by Aparup Banerjee's avatar Aparup Banerjee
Browse files

Merge branch 'MDL-31288-POST23' of git://github.com/netspotau/moodle-mod_assign

parents a8b8f472 94f26900
......@@ -20,7 +20,8 @@
<FIELD NAME="duedate" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The due date for the assignment. Displayed to students." PREVIOUS="sendlatenotifications" NEXT="allowsubmissionsfromdate"/>
<FIELD NAME="allowsubmissionsfromdate" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="If set, submissions will only be accepted after this date." PREVIOUS="duedate" NEXT="grade"/>
<FIELD NAME="grade" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The maximum grade for this assignment. Can be negative to indicate the use of a scale." PREVIOUS="allowsubmissionsfromdate" NEXT="timemodified"/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The time the settings for this assign module instance were last modified." PREVIOUS="grade"/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="The time the settings for this assign module instance were last modified." PREVIOUS="grade" NEXT="requiresubmissionstatement"/>
<FIELD NAME="requiresubmissionstatement" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Forces the student to accept a submission statement when submitting an assignment" PREVIOUS="timemodified"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="The unique id for this assignment instance."/>
......
......@@ -25,22 +25,24 @@
defined('MOODLE_INTERNAL') || die();
$logs = array(
array('module'=>'assign', 'action'=>'view', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'add', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'delete mod', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'download all submissions', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'grade submission', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'lock submission', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'revert submission to draft', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'submission statement accepted', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'submit', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'submit for grading', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'unlock submission', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'update', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'view submission', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'view feedback', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'upload', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'download all submissions', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'view', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'view all', 'mtable'=>'course', 'field'=>'fullname'),
array('module'=>'assign', 'action'=>'view confirm submit assignment form', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'view grading form', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'delete mod', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'view submission', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'view submission grading table', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'view submit assignment form', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'submit for grading', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'submit', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'revert submission to draft', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'lock submission', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'unlock submission', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'grade submission', 'mtable'=>'assign', 'field'=>'name'),
array('module'=>'assign', 'action'=>'view all', 'mtable'=>'course', 'field'=>'fullname'),
array('module'=>'assign', 'action'=>'view feedback', 'mtable'=>'assign', 'field'=>'name'),
);
......@@ -46,6 +46,20 @@ function xmldb_assign_upgrade($oldversion) {
// Assign savepoint reached.
upgrade_mod_savepoint(true, 2012051700, 'assign');
}
if ($oldversion < 2012071800) {
// Define field requiresubmissionstatement to be added to assign
$table = new xmldb_table('assign');
$field = new xmldb_field('requiresubmissionstatement', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'timemodified');
// Conditionally launch add field requiresubmissionstatement
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
// Assign savepoint reached.
upgrade_mod_savepoint(true, 2012071800, 'assign');
}
// Moodle v2.3.0 release upgrade line
// Put any upgrade step following this
......
......@@ -191,6 +191,8 @@ $string['quickgrading'] = 'Quick grading';
$string['quickgradingresult'] = 'Quick grading';
$string['quickgradingchangessaved'] = 'The grade changes were saved';
$string['quickgrading_help'] = 'Quick grading allows you to assign grades (and outcomes) directly in the submissions table. Quick grading is not compatible with advanced grading and is not recommended when there are multiple markers.';
$string['requiresubmissionstatement'] = 'Require that students accept the submission statement';
$string['requiresubmissionstatement_help'] = 'Require that students accept the submission statement for all assignment submissions for this entire Moodle installation. If this setting is not enabled, then submission statements can be enabled or disabled in the settings for each assignment.';
$string['reverttodraftforstudent'] = 'Revert submission to draft for student: (id={$a->id}, fullname={$a->fullname}).';
$string['reverttodraft'] = 'Revert the submission to draft status.';
$string['reverttodraftshort'] = 'Revert the submission to draft';
......@@ -228,6 +230,9 @@ $string['submissions'] = 'Submissions';
$string['submissionsnotgraded'] = 'Submissions not graded: {$a}';
$string['submissionsclosed'] = 'Submissions closed';
$string['submissionsettings'] = 'Submission settings';
$string['submissionstatement'] = 'Submission statement';
$string['submissionstatement_help'] = 'Assignment submission confirmation statement';
$string['submissionstatementacceptedlog'] = 'Submission statement accepted by user {$a}';
$string['submissionstatus_draft'] = 'Draft (not submitted)';
$string['submissionstatusheading'] = 'Submission status';
$string['submissionstatus_marked'] = 'Graded';
......
......@@ -313,7 +313,10 @@ class assign {
$this->process_unlock();
$action = 'grading';
} else if ($action == 'confirmsubmit') {
$this->process_submit_for_grading();
$action = 'submit';
if ($this->process_submit_for_grading($mform)) {
$action = 'view';
}
// save and show next button
} else if ($action == 'batchgradingoperation') {
$this->process_batch_grading_operation();
......@@ -374,7 +377,7 @@ class assign {
} else if ($action == 'downloadall') {
$o .= $this->download_submissions();
} else if ($action == 'submit') {
$o .= $this->check_submit_for_grading();
$o .= $this->check_submit_for_grading($mform);
} else {
$o .= $this->view_submission_page();
}
......@@ -408,6 +411,7 @@ class assign {
$update->alwaysshowdescription = $formdata->alwaysshowdescription;
$update->preventlatesubmissions = $formdata->preventlatesubmissions;
$update->submissiondrafts = $formdata->submissiondrafts;
$update->requiresubmissionstatement = $formdata->requiresubmissionstatement;
$update->sendnotifications = $formdata->sendnotifications;
$update->sendlatenotifications = $formdata->sendlatenotifications;
$update->duedate = $formdata->duedate;
......@@ -626,6 +630,7 @@ class assign {
$update->alwaysshowdescription = $formdata->alwaysshowdescription;
$update->preventlatesubmissions = $formdata->preventlatesubmissions;
$update->submissiondrafts = $formdata->submissiondrafts;
$update->requiresubmissionstatement = $formdata->requiresubmissionstatement;
$update->sendnotifications = $formdata->sendnotifications;
$update->sendlatenotifications = $formdata->sendlatenotifications;
$update->duedate = $formdata->duedate;
......@@ -1973,10 +1978,14 @@ class assign {
/**
* Ask the user to confirm they want to submit their work for grading
* @param $mform moodleform - null unless form validation has failed
* @return string
*/
private function check_submit_for_grading() {
global $USER;
private function check_submit_for_grading($mform) {
global $USER, $CFG;
require_once($CFG->dirroot . '/mod/assign/submissionconfirmform.php');
// Check that all of the submission plugins are ready for this submission
$notifications = array();
$submission = $this->get_user_submission($USER->id, false);
......@@ -1990,10 +1999,29 @@ class assign {
}
}
$data = new stdClass();
$adminconfig = $this->get_admin_config();
$requiresubmissionstatement = !empty($adminconfig->requiresubmissionstatement) ||
$this->get_instance()->requiresubmissionstatement;
$submissionstatement = '';
if (!empty($adminconfig->submissionstatement)) {
$submissionstatement = $adminconfig->submissionstatement;
}
if ($mform == null) {
$mform = new mod_assign_confirm_submission_form(null, array($requiresubmissionstatement,
$submissionstatement,
$this->get_course_module()->id,
$data));
}
$o = '';
$o .= $this->output->header();
$o .= $this->output->render(new assign_submit_for_grading_page($notifications, $this->get_course_module()->id));
$o .= $this->output->render(new assign_submit_for_grading_page($notifications, $this->get_course_module()->id, $mform));
$o .= $this->view_footer();
$this->add_to_log('view confirm submit assignment form', get_string('viewownsubmissionform', 'assign'));
return $o;
}
......@@ -2455,7 +2483,7 @@ class assign {
global $DB;
$adminconfig = $this->get_admin_config();
if (!$adminconfig->submissionreceipts) {
if (empty($adminconfig->submissionreceipts)) {
// No need to do anything
return;
}
......@@ -2490,15 +2518,39 @@ class assign {
/**
* assignment submission is processed before grading
*
* @return void
* @param $mform If validation failed when submitting this form - this is the moodleform - it can be null
* @return bool Return false if the validation fails. This affects which page is displayed next.
*/
private function process_submit_for_grading() {
global $USER;
private function process_submit_for_grading($mform) {
global $USER, $CFG;
// Need submit permission to submit an assignment
require_capability('mod/assign:submit', $this->context);
require_once($CFG->dirroot . '/mod/assign/submissionconfirmform.php');
require_sesskey();
$data = new stdClass();
$adminconfig = $this->get_admin_config();
$requiresubmissionstatement = !empty($adminconfig->requiresubmissionstatement) ||
$this->get_instance()->requiresubmissionstatement;
$submissionstatement = '';
if (!empty($adminconfig->submissionstatement)) {
$submissionstatement = $adminconfig->submissionstatement;
}
if ($mform == null) {
$mform = new mod_assign_confirm_submission_form(null, array($requiresubmissionstatement,
$submissionstatement,
$this->get_course_module()->id,
$data));
}
$data = $mform->get_data();
if (!$mform->is_cancelled()) {
if ($mform->get_data() == false) {
return false;
}
$submission = $this->get_user_submission($USER->id,true);
if ($submission->status != ASSIGN_SUBMISSION_STATUS_SUBMITTED) {
// Give each submission plugin a chance to process the submission
......@@ -2509,11 +2561,16 @@ class assign {
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
$this->update_submission($submission);
if (isset($data->submissionstatement)) {
$this->add_to_log('submission statement accepted', get_string('submissionstatementacceptedlog', 'mod_assign', fullname($USER)));
}
$this->add_to_log('submit for grading', $this->format_submission_for_log($submission));
$this->notify_graders($submission);
$this->notify_student_submission_receipt($submission);
}
}
return true;
}
/**
* save quick grades
......@@ -2776,6 +2833,9 @@ class assign {
$this->update_submission($submission);
// Logging
if (isset($data->submissionstatement)) {
$this->add_to_log('submission statement accepted', get_string('submissionstatementacceptedlog', 'mod_assign', fullname($USER)));
}
$this->add_to_log('submit', $this->format_submission_for_log($submission));
if (!$this->get_instance()->submissiondrafts) {
......@@ -3040,10 +3100,26 @@ class assign {
public function add_submission_form_elements(MoodleQuickForm $mform, stdClass $data) {
global $USER;
// online text submissions
$submission = $this->get_user_submission($USER->id, false);
// submission statement
$adminconfig = $this->get_admin_config();
$requiresubmissionstatement = !empty($adminconfig->requiresubmissionstatement) ||
$this->get_instance()->requiresubmissionstatement;
$draftsenabled = $this->get_instance()->submissiondrafts;
if ($requiresubmissionstatement && !$draftsenabled) {
$submissionstatement = '';
if (!empty($adminconfig->submissionstatement)) {
$submissionstatement = $adminconfig->submissionstatement;
}
$mform->addElement('checkbox', 'submissionstatement', '', '&nbsp;' . $submissionstatement);
$mform->addRule('submissionstatement', get_string('required'), 'required', null, 'client');
}
$this->add_plugin_submission_elements($submission, $mform, $data);
// hidden params
......
......@@ -73,6 +73,8 @@ class mod_assign_mod_form extends moodleform_mod {
$assignment->set_course($DB->get_record('course', array('id'=>$this->current->course), '*', MUST_EXIST));
}
$config = get_config('assign');
$mform->addElement('header', 'general', get_string('settings', 'assign'));
$mform->addElement('date_time_selector', 'allowsubmissionsfromdate', get_string('allowsubmissionsfromdate', 'assign'), array('optional'=>true));
$mform->addHelpButton('allowsubmissionsfromdate', 'allowsubmissionsfromdate', 'assign');
......@@ -89,6 +91,15 @@ class mod_assign_mod_form extends moodleform_mod {
$mform->addElement('selectyesno', 'submissiondrafts', get_string('submissiondrafts', 'assign'));
$mform->addHelpButton('submissiondrafts', 'submissiondrafts', 'assign');
$mform->setDefault('submissiondrafts', 0);
// submission statement
if (!empty($config->requiresubmissionstatement)) {
$mform->addElement('selectyesno', 'requiresubmissionstatement', get_string('requiresubmissionstatement', 'assign'));
$mform->setDefault('requiresubmissionstatement', !empty($config->submissionstatement));
$mform->addHelpButton('requiresubmissionstatement', 'requiresubmissionstatement', 'assign');
} else {
$mform->addElement('hidden', 'requiresubmissionstatement', 1);
}
$mform->addElement('selectyesno', 'sendnotifications', get_string('sendnotifications', 'assign'));
$mform->addHelpButton('sendnotifications', 'sendnotifications', 'assign');
$mform->setDefault('sendnotifications', 1);
......
......@@ -35,15 +35,18 @@ class assign_submit_for_grading_page implements renderable {
var $notifications = array();
/** @var int $coursemoduleid */
var $coursemoduleid = 0;
/** @var moodleform $confirmform */
var $confirmform = null;
/**
* Constructor
* @param string $notifications - Any mesages to display
* @param int $coursemoduleid
*/
public function __construct($notifications, $coursemoduleid) {
public function __construct($notifications, $coursemoduleid, $confirmform) {
$this->notifications = $notifications;
$this->coursemoduleid = $coursemoduleid;
$this->confirmform = $confirmform;
}
}
......
......@@ -168,11 +168,8 @@ class mod_assign_renderer extends plugin_renderer_base {
$o .= $this->output->continue_button($cancelurl);
} else {
// All submission plugins ready - confirm the student really does want to submit for marking
$continueurl = new moodle_url('/mod/assign/view.php', array('id' => $page->coursemoduleid,
'action' => 'confirmsubmit',
'sesskey' => sesskey()));
$o .= $this->output->confirm(get_string('confirmsubmission', 'mod_assign'), $continueurl, $cancelurl);
// All submission plugins ready - show the confirmation form (may contain submission statement)
$o .= $this->moodleform($page->confirmform);
}
$o .= $this->output->container_end();
......
......@@ -53,8 +53,16 @@ if ($ADMIN->fulltree) {
new lang_string('feedbackplugin', 'mod_assign'),
new lang_string('feedbackpluginforgradebook', 'mod_assign'), 'assignfeedback_comments', $menu));
$settings->add(new admin_setting_configcheckbox('assign/showrecentsubmissions',
new lang_string('showrecentsubmissions', 'assign'),
new lang_string('configshowrecentsubmissions', 'assign'), 0));
new lang_string('showrecentsubmissions', 'mod_assign'),
new lang_string('configshowrecentsubmissions', 'mod_assign'), 0));
$settings->add(new admin_setting_configcheckbox('assign/submissionreceipts',
get_string('sendsubmissionreceipts', 'mod_assign'), get_string('sendsubmissionreceipts_help', 'mod_assign'), 1));
new lang_string('sendsubmissionreceipts', 'mod_assign'),
new lang_string('sendsubmissionreceipts_help', 'mod_assign'), 1));
$settings->add(new admin_setting_configtextarea('assign/submissionstatement',
new lang_string('submissionstatement', 'mod_assign'),
new lang_string('submissionstatement_help', 'mod_assign'), ''));
$settings->add(new admin_setting_configcheckbox('assign/requiresubmissionstatement',
new lang_string('requiresubmissionstatement', 'mod_assign'),
new lang_string('requiresubmissionstatement_help', 'mod_assign'), 0));
}
<?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/>.
/**
* This file contains the submission confirmation form
*
* @package mod_assign
* @copyright 2012 NetSpot {@link http://www.netspot.com.au}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
/** Include formslib.php */
require_once ($CFG->libdir.'/formslib.php');
/** Include locallib.php */
require_once($CFG->dirroot . '/mod/assign/locallib.php');
/**
* Assignment submission confirmation form
*
* @package mod_assign
* @copyright 2012 NetSpot {@link http://www.netspot.com.au}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_assign_confirm_submission_form extends moodleform {
/**
* Define the form - called by parent constructor
*/
function definition() {
$mform = $this->_form;
list($requiresubmissionstatement, $submissionstatement, $coursemoduleid, $data) = $this->_customdata;
if ($requiresubmissionstatement) {
$mform->addElement('checkbox', 'submissionstatement', '', '&nbsp;' . $submissionstatement);
$mform->addRule('submissionstatement', get_string('required'), 'required', null, 'client');
}
$mform->addElement('static', 'confirmmessage', '', get_string('confirmsubmission', 'mod_assign'));
$mform->addElement('hidden', 'id', $coursemoduleid);
$mform->setType('id', PARAM_INT);
$mform->addElement('hidden', 'action', 'confirmsubmit');
$mform->setType('action', PARAM_ALPHA);
$this->add_action_buttons(true, get_string('continue'));
if ($data) {
$this->set_data($data);
}
}
}
......@@ -90,6 +90,7 @@ class assign_upgrade_manager {
$data->grade = $oldassignment->grade;
$data->submissiondrafts = $oldassignment->resubmit;
$data->preventlatesubmissions = $oldassignment->preventlate;
$data->requiresubmissionstatement = 0;
$newassignment = new assign(null, null, null);
......
......@@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();
$module->component = 'mod_assign'; // Full name of the plugin (used for diagnostics)
$module->version = 2012061700; // The current module version (Date: YYYYMMDDXX)
$module->version = 2012071800; // The current module version (Date: YYYYMMDDXX)
$module->requires = 2012061700; // Requires this Moodle version
$module->cron = 60;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment