mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
Merge branch 'MDL-31341' of git://github.com/netspotau/moodle-mod_assign
This commit is contained in:
commit
94fb9f9fae
@ -55,7 +55,8 @@ class backup_assign_activity_structure_step extends backup_activity_structure_st
|
||||
'duedate',
|
||||
'allowsubmissionsfromdate',
|
||||
'grade',
|
||||
'timemodified'));
|
||||
'timemodified',
|
||||
'completionsubmit'));
|
||||
|
||||
$submissions = new backup_nested_element('submissions');
|
||||
|
||||
|
@ -21,7 +21,8 @@
|
||||
<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" 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"/>
|
||||
<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" NEXT="completionsubmit"/>
|
||||
<FIELD NAME="completionsubmit" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="If this field is set to 1, then the activity will be automatically marked as 'complete' once the user submits their assignment." PREVIOUS="requiresubmissionstatement"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="The unique id for this assignment instance."/>
|
||||
|
@ -64,6 +64,20 @@ function xmldb_assign_upgrade($oldversion) {
|
||||
// Assign savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2012071800, 'assign');
|
||||
}
|
||||
if ($oldversion < 2012081600) {
|
||||
|
||||
// Define field sendlatenotifications to be added to assign
|
||||
$table = new xmldb_table('assign');
|
||||
$field = new xmldb_field('completionsubmit', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '0', 'timemodified');
|
||||
|
||||
// Conditionally launch add field sendlatenotifications
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Assign savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2012081600, 'assign');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -66,6 +66,7 @@ $string['batchoperationlock'] = 'lock submissions';
|
||||
$string['batchoperationunlock'] = 'unlock submissions';
|
||||
$string['batchoperationreverttodraft'] = 'revert submissions to draft';
|
||||
$string['comment'] = 'Comment';
|
||||
$string['completionsubmit'] = 'Student must submit to this activity to complete it';
|
||||
$string['conversionexception'] = 'Could not convert assignment. Exception was: {$a}.';
|
||||
$string['configshowrecentsubmissions'] = 'Everyone can see notifications of submissions in recent activity reports.';
|
||||
$string['confirmsubmission'] = 'Are you sure you want to submit your work for grading? You will not be able to make any more changes';
|
||||
|
@ -83,6 +83,7 @@ function assign_supports($feature) {
|
||||
case FEATURE_GROUPMEMBERSONLY: return true;
|
||||
case FEATURE_MOD_INTRO: return true;
|
||||
case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
|
||||
case FEATURE_COMPLETION_HAS_RULES: return true;
|
||||
case FEATURE_GRADE_HAS_GRADE: return true;
|
||||
case FEATURE_GRADE_OUTCOMES: return true;
|
||||
case FEATURE_BACKUP_MOODLE2: return true;
|
||||
@ -937,3 +938,29 @@ function assign_user_outline($course, $user, $coursemodule, $assignment) {
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the automatic completion state for this module based on any conditions
|
||||
* in assign settings.
|
||||
*
|
||||
* @param object $course Course
|
||||
* @param object $cm Course-module
|
||||
* @param int $userid User ID
|
||||
* @param bool $type Type of comparison (or/and; can be used as return value if no conditions)
|
||||
* @return bool True if completed, false if not, $type if conditions not set.
|
||||
*/
|
||||
function assign_get_completion_state($course,$cm,$userid,$type) {
|
||||
global $CFG,$DB;
|
||||
require_once($CFG->dirroot . '/mod/assign/locallib.php');
|
||||
|
||||
$assign = new assign(null, $cm, $course);
|
||||
|
||||
// If completion option is enabled, evaluate it and return true/false
|
||||
if($assign->get_instance()->completionsubmit) {
|
||||
$submission = $DB->get_record('assign_submission', array('assignment'=>$assign->get_instance()->id, 'userid'=>$userid), '*', IGNORE_MISSING);
|
||||
return $submission && $submission->status == ASSIGN_SUBMISSION_STATUS_SUBMITTED;
|
||||
} else {
|
||||
// Completion option is not enabled so just return $type
|
||||
return $type;
|
||||
}
|
||||
}
|
||||
|
@ -417,6 +417,7 @@ class assign {
|
||||
$update->duedate = $formdata->duedate;
|
||||
$update->allowsubmissionsfromdate = $formdata->allowsubmissionsfromdate;
|
||||
$update->grade = $formdata->grade;
|
||||
$update->completionsubmit = $formdata->completionsubmit;
|
||||
$returnid = $DB->insert_record('assign', $update);
|
||||
$this->instance = $DB->get_record('assign', array('id'=>$returnid), '*', MUST_EXIST);
|
||||
// cache the course record
|
||||
@ -636,6 +637,7 @@ class assign {
|
||||
$update->duedate = $formdata->duedate;
|
||||
$update->allowsubmissionsfromdate = $formdata->allowsubmissionsfromdate;
|
||||
$update->grade = $formdata->grade;
|
||||
$update->completionsubmit = $formdata->completionsubmit;
|
||||
|
||||
$result = $DB->update_record('assign', $update);
|
||||
$this->instance = $DB->get_record('assign', array('id'=>$update->id), '*', MUST_EXIST);
|
||||
@ -2561,6 +2563,11 @@ class assign {
|
||||
|
||||
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
|
||||
$this->update_submission($submission);
|
||||
$completion = new completion_info($this->get_course());
|
||||
if ($completion->is_enabled($this->get_course_module()) && $this->get_instance()->completionsubmit) {
|
||||
$completion->update_state($this->get_course_module(), COMPLETION_COMPLETE, $USER->id);
|
||||
}
|
||||
|
||||
if (isset($data->submissionstatement)) {
|
||||
$this->add_to_log('submission statement accepted', get_string('submissionstatementacceptedlog', 'mod_assign', fullname($USER)));
|
||||
}
|
||||
@ -2838,6 +2845,15 @@ class assign {
|
||||
}
|
||||
$this->add_to_log('submit', $this->format_submission_for_log($submission));
|
||||
|
||||
$complete = COMPLETION_INCOMPLETE;
|
||||
if ($submission->status == ASSIGN_SUBMISSION_STATUS_SUBMITTED) {
|
||||
$complete = COMPLETION_COMPLETE;
|
||||
}
|
||||
$completion = new completion_info($this->get_course());
|
||||
if ($completion->is_enabled($this->get_course_module()) && $this->get_instance()->completionsubmit) {
|
||||
$completion->update_state($this->get_course_module(), $complete, $USER->id);
|
||||
}
|
||||
|
||||
if (!$this->get_instance()->submissiondrafts) {
|
||||
$this->notify_student_submission_receipt($submission);
|
||||
$this->notify_graders($submission);
|
||||
@ -3140,7 +3156,7 @@ class assign {
|
||||
* @return void
|
||||
*/
|
||||
private function process_revert_to_draft($userid = 0) {
|
||||
global $USER, $DB;
|
||||
global $DB;
|
||||
|
||||
// Need grade permission
|
||||
require_capability('mod/assign:grade', $this->context);
|
||||
@ -3163,6 +3179,10 @@ class assign {
|
||||
|
||||
$user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
|
||||
|
||||
$completion = new completion_info($this->get_course());
|
||||
if ($completion->is_enabled($this->get_course_module()) && $this->get_instance()->completionsubmit) {
|
||||
$completion->update_state($this->get_course_module(), COMPLETION_INCOMPLETE, $userid);
|
||||
}
|
||||
$this->add_to_log('revert submission to draft', get_string('reverttodraftforstudent', 'assign', array('id'=>$user->id, 'fullname'=>fullname($user))));
|
||||
|
||||
}
|
||||
|
@ -161,5 +161,15 @@ class mod_assign_mod_form extends moodleform_mod {
|
||||
$assignment->plugin_data_preprocessing($defaultvalues);
|
||||
}
|
||||
|
||||
function add_completion_rules() {
|
||||
$mform =& $this->_form;
|
||||
|
||||
$mform->addElement('checkbox', 'completionsubmit', '', get_string('completionsubmit', 'assign'));
|
||||
return array('completionsubmit');
|
||||
}
|
||||
|
||||
function completion_rule_enabled($data) {
|
||||
return !empty($data['completionsubmit']);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$module->component = 'mod_assign'; // Full name of the plugin (used for diagnostics)
|
||||
$module->version = 2012071800; // The current module version (Date: YYYYMMDDXX)
|
||||
$module->version = 2012081600; // The current module version (Date: YYYYMMDDXX)
|
||||
$module->requires = 2012061700; // Requires this Moodle version
|
||||
$module->cron = 60;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user