diff -Naur assign/backup/moodle2/backup_assign_stepslib.php assign23/backup/moodle2/backup_assign_stepslib.php --- assign/backup/moodle2/backup_assign_stepslib.php 2012-05-26 13:36:12.000000000 +0100 +++ assign23/backup/moodle2/backup_assign_stepslib.php 2012-06-25 21:42:18.000000000 +0100 @@ -74,7 +74,8 @@ 'grader', 'grade', 'locked', - 'mailed')); + 'mailed', + 'extensionduedate')); $pluginconfigs = new backup_nested_element('plugin_configs'); diff -Naur assign/db/install.xml assign23/db/install.xml --- assign/db/install.xml 2012-05-26 13:36:12.000000000 +0100 +++ assign23/db/install.xml 2012-06-25 18:59:37.000000000 +0100 @@ -56,7 +56,8 @@ - + + diff -Naur assign/extensionform.php assign23/extensionform.php --- assign/extensionform.php 1970-01-01 00:00:00.000000000 +0000 +++ assign23/extensionform.php 2012-06-25 20:09:00.000000000 +0100 @@ -0,0 +1,95 @@ +. + +/** +* This file contains the extension date form used by the assign module. +* +* @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 locallib.php */ +require_once($CFG->libdir . '/formslib.php'); +require_once($CFG->dirroot . '/mod/assign/locallib.php'); + +/** +* Assignment extension 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_extension_form extends moodleform implements renderable { + + /** @var assign $assignment The current instance of the assign class */ + var $assignment; + /** @var stdClass $user The user who is being granted an extension */ + var $user; + + /** +* Define this moodleform. Called by the parent constructor +*/ + function definition() { + $mform = $this->_form; + + list($assignment, $user, $data) = $this->_customdata; + $this->assignment = $assignment; + $this->user = $user; + + if ($this->assignment->get_instance()->allowsubmissionsfromdate) { + $mform->addElement('static', 'allowsubmissionsfromdate', get_string('allowsubmissionsfromdate', 'assign'), userdate($this->assignment->get_instance()->allowsubmissionsfromdate)); + } + if ($this->assignment->get_instance()->duedate) { + $mform->addElement('static', 'duedate', get_string('duedate', 'assign'), userdate($this->assignment->get_instance()->duedate)); + } + $mform->addElement('date_time_selector', 'extensionduedate', get_string('extensionduedate', 'assign'), array('optional'=>true)); + $mform->setDefault('extensionduedate', NULL); + $mform->addElement('hidden', 'id', $assignment->get_course_module()->id); + $mform->addElement('hidden', 'userid', $user->id); + $mform->addElement('hidden', 'action', 'saveextension'); + $this->add_action_buttons(true, get_string('savechanges', 'assign')); + if ($data) { + $this->set_data($data); + } + } + + /** +* Perform minimal validation on the extension form +* @param array $data +* @param array $files +* @return array $errors - a list of validation errors keyed by the element name +*/ + function validation($data, $files) { + $errors = parent::validation($data, $files); + if ($this->assignment->get_instance()->duedate && $data['extensionduedate']) { + if ($this->assignment->get_instance()->duedate > $data['extensionduedate']) { + $errors['extensionduedate'] = get_string('extensionnotafterduedate', 'assign'); + } + } + if ($this->assignment->get_instance()->allowsubmissionsfromdate && $data['extensionduedate']) { + if ($this->assignment->get_instance()->allowsubmissionsfromdate > $data['extensionduedate']) { + $errors['extensionduedate'] = get_string('extensionnotafterfromdate', 'assign'); + } + } + + return $errors; + } +} \ No hay ningún carácter de nueva línea al final del archivo diff -Naur assign/gradingtable.php assign23/gradingtable.php --- assign/gradingtable.php 2012-06-24 21:33:37.000000000 +0100 +++ assign23/gradingtable.php 2012-06-25 19:07:27.000000000 +0100 @@ -90,7 +90,7 @@ $fields = user_picture::fields('u') . ', u.id as userid, u.firstname as firstname, u.lastname as lastname, '; $fields .= 's.status as status, s.id as submissionid, s.timecreated as firstsubmission, s.timemodified as timesubmitted, '; - $fields .= 'g.id as gradeid, g.grade as grade, g.timemodified as timemarked, g.timecreated as firstmarked, g.mailed as mailed, g.locked as locked'; + $fields .= 'g.id as gradeid, g.grade as grade, g.timemodified as timemarked, g.timecreated as firstmarked, g.mailed as mailed, g.locked as locked, g.extensionduedate as extensionduedate'; $from = '{user} u LEFT JOIN {assign_submission} s ON u.id = s.userid AND s.assignment = :assignmentid1' . ' LEFT JOIN {assign_grades} g ON u.id = g.userid AND g.assignment = :assignmentid2'; @@ -409,7 +409,28 @@ $o .= $this->output->container(get_string('submissionstatus_' . $row->status, 'assign'), array('class'=>'submissionstatus' .$row->status)); if ($this->assignment->get_instance()->duedate && $row->timesubmitted > $this->assignment->get_instance()->duedate) { + /// TODO test if get_duedate before is better + // past standard duedate - check for extension date + if (!$row->extensionduedate || $row->timesubmitted > $row->extensionduedate) { $o .= $this->output->container(get_string('submittedlateshort', 'assign', format_time($row->timesubmitted - $this->assignment->get_instance()->duedate)), 'latesubmission'); + } + } + /// TODO test what is this + if (!$row->timesubmitted) { + $now = time(); + $due = $this->assignment->get_instance()->duedate; + // check for extension date + if ($row->extensionduedate) { + $due = $row->extensionduedate; + } + if ($due && ($now > $due)) { + // no submission and it is late + $o .= $this->output->container(get_string('overdue', 'assign', format_time($now - $due)), 'overduesubmission'); + } + } + // print any current extension date + if ($row->extensionduedate) { + $o .= $this->output->container(get_string('userextensiondate', 'assign', userdate($row->extensionduedate)), 'extensiondate'); } if ($row->locked) { $o .= $this->output->container(get_string('submissionslockedshort', 'assign'), 'lockedsubmission'); @@ -448,6 +469,7 @@ } $actions[$url->out(false)] = $description; + if ($this->assignment->is_any_submission_plugin_enabled()) { if (!$row->status || $row->status == ASSIGN_SUBMISSION_STATUS_DRAFT || !$this->assignment->get_instance()->submissiondrafts) { if (!$row->locked) { $url = new moodle_url('/mod/assign/view.php', array('id' => $this->assignment->get_course_module()->id, @@ -476,7 +498,15 @@ $description = get_string('reverttodraftshort', 'assign'); $actions[$url->out(false)] = $description; } + $url = new moodle_url('/mod/assign/view.php', array('id' => $this->assignment->get_course_module()->id, + 'userid'=>$row->id, + 'action'=>'grantextension', + 'sesskey'=>sesskey(), + 'page'=>$this->currpage)); + $description = get_string('grantextension', 'assign'); + $actions[$url->out(false)] = $description; + } $edit .= $this->output->container_start(array('yui3-menu', 'actionmenu'), 'actionselect' . $row->id); $edit .= $this->output->container_start(array('yui3-menu-content')); $edit .= html_writer::start_tag('ul'); diff -Naur assign/lang/en/assign.php assign23/lang/en/assign.php --- assign/lang/en/assign.php 2012-06-24 21:33:37.000000000 +0100 +++ assign23/lang/en/assign.php 2012-06-25 19:52:48.000000000 +0100 @@ -89,6 +89,10 @@ $string['duedatevalidation'] = 'Due date must be after the allow submissions from date.'; $string['editsubmission'] = 'Edit my submission'; $string['editaction'] = 'Actions...'; +$string['extensionscount'] = '{$a} users allowed extended due date'; +$string['extensionduedate'] = 'Extension due date'; +$string['extensionnotafterduedate'] = 'Extension date must be after the due date'; +$string['extensionnotafterfromdate'] = 'Extension date must be after the allow submissions from date'; $string['gradersubmissionupdatedtext'] = '{$a->username} has updated their assignment submission for \'{$a->assignment}\' at {$a->timeupdated} @@ -138,10 +142,12 @@ $string['gradingstatus'] = 'Grading status'; $string['gradingstudentprogress'] = 'Grading student {$a->index} of {$a->count}'; $string['gradingsummary'] = 'Grading summary'; +$string['grantextension'] = 'Grant extension'; $string['hideshow'] = 'Hide/Show'; $string['instructionfiles'] = 'Instruction files'; $string['invalidgradeforscale'] = 'The grade supplied was not valid for the current scale'; $string['invalidfloatforgrade'] = 'The grade provided could not be understood: {$a}'; +$string['latesubmissions'] = 'Late submissions'; $string['lastmodifiedsubmission'] = 'Last modified (submission)'; $string['lastmodifiedgrade'] = 'Last modified (grade)'; $string['locksubmissionforstudent'] = 'Prevent any more submissions for student: (id={$a->id}, fullname={$a->fullname}).'; @@ -164,6 +170,8 @@ $string['noonlinesubmissions'] = 'This assignment does not require you to submit anything online'; $string['nosavebutnext'] = 'Next'; $string['nosubmission'] = 'Nothing has been submitted for this assignment'; +$string['nosubmissionsaccepted'] = 'No more submissions accepted'; +$string['nomoresubmissionsaccepted'] = 'No more submissions accepted without an extension'; $string['notgraded'] = 'Not graded'; $string['notgradedyet'] = 'Not graded yet'; $string['notsubmittedyet'] = 'Not submitted yet'; @@ -173,6 +181,7 @@ $string['numberofparticipants'] = 'Participants'; $string['numberofsubmittedassignments'] = 'Submitted'; $string['offline'] = 'No online submissions required'; +$string['open'] = 'Open'; $string['overdue'] = 'Assignment is overdue by: {$a}'; $string['outlinegrade'] = 'Grade: {$a}'; $string['page-mod-assign-x'] = 'Any assignment module page'; @@ -248,6 +257,7 @@ $string['updategrade'] = 'Update grade'; $string['updatetable'] = 'Save and update table'; $string['upgradenotimplemented'] = 'Upgrade not implemented in plugin ({$a->type} {$a->subtype})'; +$string['userextensiondate'] = 'Extension granted until: {$a}'; $string['viewfeedback'] = 'View feedback'; $string['viewfeedbackforuser'] = 'View feedback for user: {$a}'; $string['viewfullgradingpage'] = 'Open the full grading page to provide feedback'; diff -Naur assign/locallib.php assign23/locallib.php --- assign/locallib.php 2012-06-24 21:33:37.000000000 +0100 +++ assign23/locallib.php 2012-06-25 20:36:29.000000000 +0100 @@ -346,6 +346,11 @@ }else if ($action == 'saveoptions') { $this->process_save_grading_options(); $action = 'grading'; + } else if ($action == 'saveextension') { + $action = 'grantextension'; + if ($this->process_save_extension($mform)) { + $action = 'grading'; + } } $returnparams = array('rownum'=>optional_param('rownum', 0, PARAM_INT)); @@ -361,6 +366,8 @@ } else if ($action == 'nextgrade') { $mform = null; $o .= $this->view_single_grade_page($mform, 1); + } else if ($action == 'grantextension') { + $o .= $this->view_grant_extension($mform); } else if ($action == 'grade') { $o .= $this->view_single_grade_page($mform); } else if ($action == 'viewpluginassignfeedback') { @@ -981,6 +988,21 @@ status = ?", array($this->get_course_module()->instance, $status)); } + + /** + * Load a count of users enrolled in the current course with the specified permission and group (optional) + * + * @param string $status The submission status - should match one of the constants + * @return int number of matching submissions + */ + public function count_extended_submissions() { + global $DB; + + return $DB->count_records_select('assign_grades', ' assignment = ? AND extensionduedate > ? ', + array($this->get_course_module()->instance, time())); + } + + /** * Utility function to get the userid for every row in the grading table * so the order can be frozen while we iterate it @@ -1243,6 +1265,51 @@ } /** + * view the grant extension date page + * + * Uses url parameters 'userid' + * @global moodle_database $DB + * @global stdClass $CFG + * @return string + */ + private function view_grant_extension($mform) { + global $DB, $CFG; + + $o = ''; + + $userid = required_param('userid', PARAM_INT); + require_once($CFG->dirroot . '/mod/assign/extensionform.php'); + + $grade = $this->get_user_grade($userid, false); + + $user = $DB->get_record('user', array('id'=>$userid), '*', MUST_EXIST); + + $data = new stdClass(); + + if ($grade) { + $data->extensionduedate = $grade->extensionduedate; + } else { + $data->extensionduedate = null; + } + $data->userid = $userid; + + $o .= $this->output->render(new assign_header($this->get_instance(), + $this->get_context(), + $this->show_intro(), + $this->get_course_module()->id, + get_string('grantextension', 'assign'))); + if (!$mform) { + $mform = new mod_assign_extension_form(null, array($this, $user, $data)); + } + + $o .= $this->output->render(new assign_user_summary($user, $this->get_course()->id, has_capability('moodle/site:viewfullnames', $this->get_course_context()))); + $o .= $this->output->render($mform); + + $o .= $this->view_footer(); + return $o; + } + + /** * display the submission that is used by a plugin * Uses url parameters 'sid', 'gid' and 'plugin' * @param string $pluginsubtype @@ -1623,7 +1690,15 @@ // get the current grade $grade = $this->get_user_grade($userid, false); if ($this->can_view_submission($userid)) { + $showedit = has_capability('mod/assign:submit', $this->context) && + $this->submissions_open($userid) && ($this->is_any_submission_plugin_enabled()); + + $showsubmit = $showedit && $submission && ($submission->status == ASSIGN_SUBMISSION_STATUS_DRAFT); $gradelocked = ($grade && $grade->locked) || $this->grading_disabled($userid); + $extensionduedate = null; + if ($grade) { + $extensionduedate = $grade->extensionduedate; + } $o .= $this->output->render(new assign_submission_status($this->get_instance()->allowsubmissionsfromdate, $this->get_instance()->alwaysshowdescription, $submission, @@ -1636,8 +1711,9 @@ $this->get_return_params(), $this->get_course_module()->id, assign_submission_status::GRADER_VIEW, - false, - false)); + $showedit, + $showsubmit, + $extensionduedate)); } if ($grade) { $data = new stdClass(); @@ -1999,6 +2075,11 @@ $showsubmit = $submission && ($submission->status == ASSIGN_SUBMISSION_STATUS_DRAFT) && $showlinks; $gradelocked = ($grade && $grade->locked) || $this->grading_disabled($user->id); + $extensionduedate = null; + + if ($grade) { + $extensionduedate = $grade->extensionduedate; + } $o .= $this->output->render(new assign_submission_status($this->get_instance()->allowsubmissionsfromdate, $this->get_instance()->alwaysshowdescription, $submission, @@ -2012,7 +2093,8 @@ $this->get_course_module()->id, assign_submission_status::STUDENT_VIEW, $showedit, - $showsubmit)); + $showsubmit, + $extensionduedate)); require_once($CFG->libdir.'/gradelib.php'); require_once($CFG->dirroot.'/grade/grading/lib.php'); @@ -2094,7 +2176,8 @@ $this->is_any_submission_plugin_enabled(), $this->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_SUBMITTED), $this->get_instance()->duedate, - $this->get_course_module()->id + $this->get_course_module()->id, + $this->count_extended_submissions() )); } $grade = $this->get_user_grade($USER->id, false); @@ -2199,33 +2282,88 @@ return $result; } + + /** + * Calculates submission due date for a particular user (taking xtensions + * (taking extensions into account) + * + * @param int $userID number + * @return int duedate timestamp + */ + private function get_user_duedate($userid = null) { + global $DB; + + if (!$userid) { + $userid = $USER->id; + } + + $duedate = $this->get_instance()->duedate; + $extension = 0; + if($grade = $DB->get_record('assign_grades', array('assignment'=>$this->get_instance()->id, 'userid'=>$userid)) ) { + } + return max($duedate, $extension); + } + + /** * Is this assignment open for submissions? * - * Check the due date, + * Check the due date for this user, * prevent late submissions, * has this person already submitted, * is the assignment locked? * + * @param int $userID number * @return bool */ - private function submissions_open() { + private function submissions_open($userid = null) { global $USER; + if (!$userid) { + $userid = $USER->id; + } + +////////////////////////////// +//// old + $time = time(); + $duedate = $this->get_user_duedate($userid); $dateopen = true; - if ($this->get_instance()->preventlatesubmissions && $this->get_instance()->duedate) { - $dateopen = ($this->get_instance()->allowsubmissionsfromdate <= $time && $time <= $this->get_instance()->duedate); + if ($this->get_instance()->preventlatesubmissions && $duedate) { + $dateopen = ($this->get_instance()->allowsubmissionsfromdate <= $time && $time <= $duedate); + } else { + $dateopen = ($this->get_instance()->allowsubmissionsfromdate <= $time); + } + +//////////////////////////////////// +///// new extension +/* + if ($this->get_instance()->duedate) { + if ($this->get_instance()->cutoffdate) { + $dateopen = ($this->get_instance()->allowsubmissionsfromdate <= $time && $time <= $this->get_instance()->cutoffdate); + } else { + $dateopen = ($this->get_instance()->allowsubmissionsfromdate <= $time && $time <= $this->get_instance()->duedate); + } + if (!$dateopen) { + $grade = $this->get_user_grade($userid, false); + if ($grade && $grade->extensionduedate) { + $dateopen = ($this->get_instance()->allowsubmissionsfromdate <= $time) && + ($time <= $grade->extensionduedate); + } + } } else { $dateopen = ($this->get_instance()->allowsubmissionsfromdate <= $time); } +*/ +///////////////////////// + if (!$dateopen) { return false; } // now check if this user has already submitted etc. - if (!is_enrolled($this->get_course_context(), $USER)) { + if (!is_enrolled($this->get_course_context(), $userid)) { return false; } if ($submission = $this->get_user_submission($USER->id, false)) { @@ -2240,7 +2378,7 @@ } } - if ($this->grading_disabled($USER->id)) { + if ($this->grading_disabled($userid)) { return false; } @@ -2495,6 +2633,44 @@ } } + + /** + * save extension date for a single student + * + * @param moodleform $mform The submitted form + * @return boolean - if false - next page will be the extension form again + */ + private function process_save_extension(&$mform) { + global $DB, $CFG; + + // Include extension form + require_once($CFG->dirroot . '/mod/assign/extensionform.php'); + require_sesskey(); + + // Need grade permission to grant extensions + require_capability('mod/assign:grade', $this->context); + + $userid = required_param('userid', PARAM_INT); + + $user = $DB->get_record('user', array('id'=>$userid), '*', MUST_EXIST); + + $mform = new mod_assign_extension_form(null, array($this, $user, null)); + + if ($mform->is_cancelled()) { + return true; + } + + if ($formdata = $mform->get_data()) { + $grade = $this->get_user_grade($userid, true); + $grade->extensionduedate = $formdata->extensionduedate; + $grade->timemodified = time(); + + return $DB->update_record('assign_grades', $grade); + } + return false; + } + + /** * save quick grades * diff -Naur assign/renderable.php assign23/renderable.php --- assign/renderable.php 2012-06-18 14:27:52.000000000 +0100 +++ assign23/renderable.php 2012-06-25 19:42:14.000000000 +0100 @@ -308,6 +308,8 @@ var $canedit = false; /** @var bool cansubmit */ var $cansubmit = false; + /** @var int extensionduedate */ + var $extensionduedate = 0; /** * constructor @@ -326,10 +328,11 @@ * @param string $view * @param bool $canedit * @param bool $cansubmit + * @param int $extensionduedate */ public function __construct($allowsubmissionsfromdate, $alwaysshowdescription, $submission, $submissionsenabled, $locked, $graded, $duedate, $submissionplugins, $returnaction, $returnparams, - $coursemoduleid, $view, $canedit, $cansubmit) { + $coursemoduleid, $view, $canedit, $cansubmit, $extensionduedate) { $this->allowsubmissionsfromdate = $allowsubmissionsfromdate; $this->alwaysshowdescription = $alwaysshowdescription; $this->submission = $submission; @@ -344,6 +347,7 @@ $this->view = $view; $this->canedit = $canedit; $this->cansubmit = $cansubmit; + $this->extensionduedate = $extensionduedate; } } @@ -401,6 +405,8 @@ var $submissiondraftsenabled = false; /** @var int submissiondraftscount - The number of submissions in draft status */ var $submissiondraftscount = 0; + /** @var int extensionscount - The number of due date extensions in this assignment */ + var $extensionscount = 0; /** @var bool submissionsenabled - Allow submissions */ var $submissionsenabled = false; /** @var int submissionssubmittedcount - The number of submissions in submitted status */ @@ -410,6 +416,7 @@ /** @var int coursemoduleid - The assignment course module id */ var $coursemoduleid = 0; + /** * constructor * @@ -421,7 +428,7 @@ * @param int $duedate * @param int $coursemoduleid */ - public function __construct($participantcount, $submissiondraftsenabled, $submissiondraftscount, $submissionsenabled, $submissionssubmittedcount, $duedate, $coursemoduleid) { + public function __construct($participantcount, $submissiondraftsenabled, $submissiondraftscount, $submissionsenabled, $submissionssubmittedcount, $duedate, $coursemoduleid, $extensionscount = 0) { $this->participantcount = $participantcount; $this->submissiondraftsenabled = $submissiondraftsenabled; $this->submissiondraftscount = $submissiondraftscount; @@ -429,6 +436,7 @@ $this->submissionssubmittedcount = $submissionssubmittedcount; $this->duedate = $duedate; $this->coursemoduleid = $coursemoduleid; + $this->extensionscount = $extensionscount; } diff -Naur assign/renderer.php assign23/renderer.php --- assign/renderer.php 2012-06-24 21:33:37.000000000 +0100 +++ assign23/renderer.php 2012-06-25 20:47:57.000000000 +0100 @@ -87,6 +87,21 @@ } /** +* Render the grant extension form +* @param mod_assign_extension_form $form The extension date form to render +* @return string +*/ + public function render_mod_assign_extension_form(mod_assign_extension_form $form) { + $o = ''; + + $o .= $this->output->box_start('boxaligncenter grantextension'); + $o .= $this->moodleform($form); + $o .= $this->output->box_end(); + return $o; + } + + + /** * Render a grading error notification * @param assign_quickgrading_result $result The result to render * @return string @@ -260,12 +275,18 @@ // time remaining $due = ''; - if ($duedate - $time <= 0) { + /// TODO checj if get_duedate is betetr ecastro ULPGC + if ($duedate < $time) { // extension $due = get_string('assignmentisdue', 'assign'); } else { $due = format_time($duedate - $time); } $this->add_table_row_tuple($t, get_string('timeremaining', 'assign'), $due); + if ($duedate < $time) { + if ($summary->extensionscount) { + $this->add_table_row_tuple($t, get_string('latesubmissions', 'assign'), get_string('extensionscount', 'assign', $summary->extensionscount)); + } + } } // all done - write the table @@ -407,13 +428,21 @@ $duedate = $status->duedate; - if ($duedate >= 1) { + if ($duedate > 0) { $row = new html_table_row(); $cell1 = new html_table_cell(get_string('duedate', 'assign')); $cell2 = new html_table_cell(userdate($duedate)); $row->cells = array($cell1, $cell2); $t->data[] = $row; + if ($status->extensionduedate) { + $row = new html_table_row(); + $cell1 = new html_table_cell(get_string('extensionduedate', 'assign')); + $cell2 = new html_table_cell(userdate($status->extensionduedate)); + $row->cells = array($cell1, $cell2); + $t->data[] = $row; + $duedate = $status->extensionduedate; + } // time remaining $row = new html_table_row(); $cell1 = new html_table_cell(get_string('timeremaining', 'assign')); @@ -440,7 +469,22 @@ $row->cells = array($cell1, $cell2); $t->data[] = $row; } - +/* + /// extensions ????? + if ($status->view == assign_submission_status::GRADER_VIEW) { + $row = new html_table_row(); + $cell1 = new html_table_cell(get_string('open', 'assign')); + if ($status->canedit) { + $cell2 = new html_table_cell(get_string('submissioneditable', 'assign')); + $cell2->attributes = array('class'=>'submissioneditable'); + } else { + $cell2 = new html_table_cell(get_string('submissionnoteditable', 'assign')); + $cell2->attributes = array('class'=>'submissionnoteditable'); + } + $row->cells = array($cell1, $cell2); + $t->data[] = $row; + } +*/ // last modified if ($status->submission) { $row = new html_table_row(); diff -Naur assign/submission/resubmission/db/access.php assign23/submission/resubmission/db/access.php --- assign/submission/resubmission/db/access.php 1970-01-01 00:00:00.000000000 +0000 +++ assign23/submission/resubmission/db/access.php 2012-06-03 09:55:42.000000000 +0100 @@ -0,0 +1,30 @@ +. + +/** + * Capability definitions for this module. + * + * @package assignsubmission_resubmission + * @copyright 2012 Enrique Castro, ULPGC + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + + +$capabilities = array( + + + +); diff -Naur assign/submission/resubmission/db/install.php assign23/submission/resubmission/db/install.php --- assign/submission/resubmission/db/install.php 1970-01-01 00:00:00.000000000 +0000 +++ assign23/submission/resubmission/db/install.php 2012-06-03 09:58:22.000000000 +0100 @@ -0,0 +1,51 @@ +. + +/** + * Post-install code for the submission_comments module. + * + * @package assignsubmission_resubmission + * @copyright 2012 Enrique Castro, ULPGC + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + + +defined('MOODLE_INTERNAL') || die(); + + +/** + * Code run after the module database tables have been created. + * Moves the comments plugin to the bottom + * @return bool + */ +function xmldb_assignsubmission_resubmission_install() { + global $CFG; + + // do the install + + require_once($CFG->dirroot . '/mod/assign/adminlib.php'); + // set the correct initial order for the plugins + $pluginmanager = new assign_plugin_manager('assignsubmission'); + + $pluginmanager->move_plugin('resubmission', 'down'); + $pluginmanager->move_plugin('resubmission', 'down'); + $pluginmanager->move_plugin('resubmission', 'down'); + + // do the upgrades + return true; + + +} diff -Naur assign/submission/resubmission/db/upgrade.php assign23/submission/resubmission/db/upgrade.php --- assign/submission/resubmission/db/upgrade.php 1970-01-01 00:00:00.000000000 +0000 +++ assign23/submission/resubmission/db/upgrade.php 2012-06-03 09:58:57.000000000 +0100 @@ -0,0 +1,34 @@ +. + +/** + * Upgrade code for install + * + * @package assignsubmission_resubmission + * @copyright 2012 Enrique Castro, ULPGC + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +/** + * Stub for upgrade code + * @param int $oldversion + * @return bool + */ +function xmldb_submission_resubmission_upgrade($oldversion) { + return true; +} + + diff -Naur assign/submission/resubmission/lang/en/assignsubmission_resubmission.php assign23/submission/resubmission/lang/en/assignsubmission_resubmission.php --- assign/submission/resubmission/lang/en/assignsubmission_resubmission.php 1970-01-01 00:00:00.000000000 +0000 +++ assign23/submission/resubmission/lang/en/assignsubmission_resubmission.php 2012-06-03 11:24:33.000000000 +0100 @@ -0,0 +1,49 @@ +. + +/** + * Strings for component 'submission_resubmission', language 'en' + * + * @package assignsubmission_resubmission + * @copyright 2012 Enrique Castro, ULPGC + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['default'] = 'Enabled by default'; +$string['default_help'] = 'If set, this submission method will be enabled by default for all new assignments.'; +$string['enabled'] = 'Resubmissions policy'; +$string['enabled_help'] = ' +If enabled, students will be able to re-submit their assignment (within the submision time window) according to some rules. +'; +$string['pluginname'] = 'Resubmissions'; + +$string['limitbymode'] = 'Allow resubmissions'; +$string['limitbymode_help'] = ' +This option determine when are resubmissions allowed to a given student. +The possible options are: + +* Graded: students that are graded can submit (either exists a previous submision or not). Students without previous submissions can still submit. +* Submitted and graded: only students that have already submitted and assignment can resubmit. That is, students that have not submitted previouslu cannot submit, even when assignment time window is open. +* Always: students can resubmit freely while submission time window is open. + +'; +$string['limitbyfinal'] = 'after submission and grading'; +$string['limitbygrade'] = 'after grading'; +$string['limitbytime'] = 'always'; + +$string['viewresubmissionno'] = 'Resubmissions allowed {$a} '; + + diff -Naur assign/submission/resubmission/lib.php assign23/submission/resubmission/lib.php --- assign/submission/resubmission/lib.php 1970-01-01 00:00:00.000000000 +0000 +++ assign23/submission/resubmission/lib.php 2012-06-03 09:43:13.000000000 +0100 @@ -0,0 +1,67 @@ +. + +/** + * This file contains the moodle hooks for the submission resubmission plugin + * + * @package assignsubmission_resubmission + * @copyright 2012 Enrique Castro, ULPGC + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +defined('MOODLE_INTERNAL') || die(); + +/** + * + * Callback method for data validation---- required method for AJAXmoodle based comment API + * + * @param stdClass $options + * @return bool + */ +function assignsubmission_resubmission_comment_validate(stdClass $options) { + + return true; +} + +/** + * Permission control method for submission plugin ---- required method for AJAXmoodle based comment API + * + * @param stdClass $options + * @return array + */ +function assignsubmission_resubmission_comment_permissions(stdClass $options) { + + return array('post' => true, 'view' => true); +} + +// /** +// * Callback to force the userid for all comments to be the userid of the submission and NOT the global $USER->id. This +// * is required by the upgrade code. Note the comment area is used to identify upgrades. +// * +// * @param stdClass $comment +// * @param stdClass $param +// */ +// function assignsubmission_resubmission_comment_add(stdClass $comment, stdClass $param) { +// +// global $DB; +// if ($comment->commentarea == 'submission_resubmission_upgrade') { +// $submissionid = $comment->itemid; +// $submission = $DB->get_record('assign_submission', array('id' => $submissionid)); +// +// $comment->userid = $submission->userid; +// $comment->commentarea = 'submission_resubmission'; +// } +// } + diff -Naur assign/submission/resubmission/locallib.php assign23/submission/resubmission/locallib.php --- assign/submission/resubmission/locallib.php 1970-01-01 00:00:00.000000000 +0000 +++ assign23/submission/resubmission/locallib.php 2012-06-03 14:57:17.000000000 +0100 @@ -0,0 +1,166 @@ +. + +/** + * This file contains the definition for the library class for view resubmission submission plugin + * + * @package assignsubmission_resubmission + * @copyright 2012 Enrique Castro, ULPGC + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + + defined('MOODLE_INTERNAL') || die(); + + /** Include submissionplugin.php */ + require_once($CFG->dirroot . '/mod/assign/submissionplugin.php'); + +/** + * This file contains the definition for the library class for view resubmission submission plugin + * + * @package assignsubmission_resubmission + * @copyright 2012 Enrique Castro, ULPGC + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class assign_submission_resubmission extends assign_submission_plugin { + + /** + * get the name of the view resubmission submission plugin + * @return string + */ + public function get_name() { + return get_string('pluginname', 'assignsubmission_resubmission'); + } + + + /** + * Get the default setting for peer submission plugin + * + * @param MoodleQuickForm $mform The form to add elements to + * @return void + */ + public function get_settings(MoodleQuickForm $mform) { + global $CFG, $COURSE; + + $defaultlimitmode = $this->get_config('resubmissioncontrol'); + /* + if(!$defaultlimitmode) { + $defaultlimitmode = get_config('assignsubmission_resubmission', 'resubmissioncontrol'); + } + */ + + $options = array('grade'=>get_string('limitbygrade', 'assignsubmission_resubmission'), + 'final'=>get_string('limitbyfinal', 'assignsubmission_resubmission'), + 'time'=>get_string('limitbytime', 'assignsubmission_resubmission') + ); + $mform->addElement('select', 'assignsubmission_resubmission_resubmissioncontrol', get_string('limitbymode', 'assignsubmission_resubmission'), $options); + $mform->addHelpButton('assignsubmission_resubmission_resubmissioncontrol', 'limitbymode', 'assignsubmission_resubmission'); + $mform->setDefault('assignsubmission_resubmission_resubmissioncontrol', $defaultlimitmode); + $mform->disabledIf('assignsubmission_resubmission_resubmissioncontrol', 'assignsubmission_resubmission_enabled', 'eq', 0); + } + + /** + * Save the settings for peer submission plugin + * + * @param stdClass $data + * @return bool + */ + public function save_settings(stdClass $data) { + $this->set_config('resubmissioncontrol', $data->assignsubmission_resubmission_resubmissioncontrol); + return true; + } + + /** + * display AJAX based comment in the submission status table + * + * @param stdClass $submission + * @param bool $showviewlink - If the comments are long this is set to true so they can be shown in a separate page + * @return string + */ + public function view_summary(stdClass $submission, & $showviewlink) { + global $CFG, $DB, $USER, $OUTPUT; + // never show a link to view full submission + $showviewlink = false; + $instance = $this->assignment->get_instance(); + $link = ''; + + if ($this->assignment->is_any_submission_plugin_enabled()) { + $is_open = false; + $mode = $this->get_config('resubmissioncontrol'); + switch ($mode) { + case 'grade' : //$is_open = !$this->assignment->is_graded($USER->id); + $link= get_string('viewresubmissionno', 'assignsubmission_resubmission', get_string('limitbygrade', 'assignsubmission_resubmission')); + break; + case 'final': //$is_open = $this->assignment->submissions_open(); + $link= get_string('viewresubmissionno', 'assignsubmission_resubmission', get_string('limitbyfinal', 'assignsubmission_resubmission')); + break; + case 'time' : //$is_open = ($time <= $instance()->duedate); + $link= get_string('viewresubmissionno', 'assignsubmission_resubmission', get_string('limitbytime', 'assignsubmission_resubmission')); + break; + } + } + return format_string($link); + + } + + /** + * Always return false because only active if exist submission + * @param stdClass $submission + * @return bool + */ + public function is_empty(stdClass $submission) { + return false; + } + + /** + * The submission view resubmission plugin has no submission component per se so should not be counted + * when determining whether to show the edit submission link. + * @return boolean + */ + public function allow_submissions() { + return false; + } + + /** + * Check if the submission plugin is open for submissions by a user + * @param int $userid user ID + * @return bool|string 'true' if OK to proceed with submission, otherwise a + * a message to display to the user + */ + public function is_open($userid=0) { + global $DB, $USER; + + $instance = $this->assignment->get_instance(); + $instance->submissiondrafts = 0; + $this->assignment->set_instance($instance); + $is_open = true; + if ($this->assignment->is_any_submission_plugin_enabled()) { + $mode = $this->get_config('resubmissioncontrol'); + $grade = $DB->get_record('assign_grades', array('assignment'=>$instance->id, 'userid'=>$USER->id)); + $submission = $DB->get_record('assign_submission', array('assignment'=>$instance->id, 'userid'=>$USER->id)); + $grade = (bool)($grade AND ($grade->timemodified > $submission->timemodified)); + switch ($mode) { + case 'grade' : $is_open = (bool)(!$submission OR $grade); + break; + case 'final': $is_open = (bool)($submission AND $grade); + break; + case 'time' : + break; + } + } + return $is_open; + } + +} diff -Naur assign/submission/resubmission/version.php assign23/submission/resubmission/version.php --- assign/submission/resubmission/version.php 1970-01-01 00:00:00.000000000 +0000 +++ assign23/submission/resubmission/version.php 2012-06-03 11:19:49.000000000 +0100 @@ -0,0 +1,28 @@ +. + +/** + * This file contains the version information for the resubmission submission plugin + * + * @package assignsubmission_resubmission + * @copyright 2012 Enrique Castro, ULPGC + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$plugin->version = 2012060100; +$plugin->requires = 2012060100; + +$plugin->component = 'assignsubmission_resubmission';