|
@@ -1,14 +1,144 @@
|
|
<?php
|
|
<?php
|
|
|
|
|
|
-require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
|
|
|
|
-require_once(dirname(__FILE__).'/locallib.php');
|
|
|
|
-require_once(dirname(__FILE__).'/comment_form.php');
|
|
|
|
|
|
+require_once('../../config.php');
|
|
|
|
+require_once('locallib.php');
|
|
|
|
+require_once('lib.php');
|
|
|
|
+require_once('submission_form.php');
|
|
|
|
|
|
-$id = required_param('id', PARAM_INT);
|
|
|
|
-$delete = optional_param('delete', 0, PARAM_INT);
|
|
|
|
-$confirm = optional_param('confirm', 0, PARAM_INT);
|
|
|
|
|
|
+echo "pagina submission";
|
|
|
|
|
|
-if (!$gradeimporter = $DB->get_record('gradeimporter', array('id' => $id))) {
|
|
|
|
|
|
+
|
|
|
|
+$cmid = required_param('cmid', PARAM_INT); // Course Module ID
|
|
|
|
+$id = required_param('id', PARAM_INT); //Gradeimporter id
|
|
|
|
+//$delete = optional_param('delete', 0, PARAM_INT);
|
|
|
|
+//$confirm = optional_param('confirm', 0, PARAM_INT);
|
|
|
|
+
|
|
|
|
+if (!$cm = get_coursemodule_from_id('gradeimporter', $cmid)){
|
|
|
|
+ print_error('invalidcoursemodule');
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+if (!$course = $DB->get_record('course', array('id'=>$cm->course))){
|
|
|
|
+ print_error('coursemisconf');
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+$context = context_module::instance($cm->id);
|
|
|
|
+
|
|
|
|
+require_capability('mod/gradeimporter:edit', $context);
|
|
|
|
+
|
|
|
|
+if (!$gradeimporter = $DB->get_record('gradeimporter', array('id'=>$cm->instance))){
|
|
|
|
+ print_error('invalidid', 'gradeimporter');
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+$url = new moodle_url('/mod/gradeimporter/submission.php', array('cmid'=>$cm->id));
|
|
|
|
+if(!empty($id)){
|
|
|
|
+ $url->param('id', $id);
|
|
|
|
+}
|
|
|
|
+$PAGE->set_url($url);
|
|
|
|
+
|
|
|
|
+require_login($course, false, $cm);
|
|
|
|
+
|
|
|
|
+//attempt to get the correct submission
|
|
|
|
+$model = $DB->get_record('gradeimporter_submission', array('gradeimporterid'=>$gradeimporter->$id));
|
|
|
|
+
|
|
|
|
+if($submission){
|
|
|
|
+ if (isguestuser()){
|
|
|
|
+ print_error('guestnoedit', 'gradeimporter', "$CFG->wwwroot/mod/gradeimporter/view.php?id=$cmid");
|
|
|
|
+ }
|
|
|
|
+} else{
|
|
|
|
+ $submission = new stdClass();
|
|
|
|
+ $model->id = null;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+$maxfiles = 50;
|
|
|
|
+$maxbytes = $course->$maxbytes;
|
|
|
|
+
|
|
|
|
+$descriptionoptions = array('trusttext'=>true, 'maxfiles'=>$maxfiles, 'maxbytes'=>$maxbytes, 'context'=>$context, 'subdirs'=>file_area_contains_subdirs($context, 'mod_gradeimporter', 'submission', $submission->id));
|
|
|
|
+$submissionoptions = array('subdirs'=>false, 'maxfiles'=>$maxfiles, 'maxbytes'=>$maxbytes);
|
|
|
|
+
|
|
|
|
+$submission = file_prepare_standard_editor($submission, 'description', $descriptionoptions, $context, 'mod_gradeimporter', 'description', $submission->id);
|
|
|
|
+$submission = file_prepare_standard_filemanager($submission, 'submission', $submissionoptions, $context, 'mod_gradeimporter', 'submission', $submission->id);
|
|
|
|
+
|
|
|
|
+$submission->cmid = $cm->id;
|
|
|
|
+
|
|
|
|
+$mform = new mod_gradeimporter_submission_form(null, array('submission'=>$submission, 'cm'=>$cm, 'descriptionoptions'=>$descriptionoptions, 'submissionoptions'=>$submissionoptions));
|
|
|
|
+
|
|
|
|
+if ($mform->is_cancelled()){
|
|
|
|
+ if ($id){
|
|
|
|
+ redirect("view.php?id=$cm->id&mode=entry&hook=$id");
|
|
|
|
+ } else {
|
|
|
|
+ redirect("view.php?id=$cm->id");
|
|
|
|
+ }
|
|
|
|
+} else if ($submission = $mform->get_data()){
|
|
|
|
+ $timenow = time();
|
|
|
|
+
|
|
|
|
+ if (empty($submission->id)) {
|
|
|
|
+ $submission->gradeimporterid = $gradeimporter->id;
|
|
|
|
+ $submission->userid = $USER->id;
|
|
|
|
+ $submission->timecreated = $timenow;
|
|
|
|
+
|
|
|
|
+ $isnewentry = true;
|
|
|
|
+ } else {
|
|
|
|
+ $isnewentry = false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $submission->description = ''; //updated later
|
|
|
|
+ $submission->descriptionformat = FORMAT_HTML; //updated later
|
|
|
|
+ //$submission->definitiontrust = 0 //n sei oq faz
|
|
|
|
+ $submission->timemodified = $timenow;
|
|
|
|
+
|
|
|
|
+ if ($isnewentry) {
|
|
|
|
+ //add new entry
|
|
|
|
+ $submission->id = $DB->insert_record('gradeimporter_submission', $submission);
|
|
|
|
+ } else {
|
|
|
|
+ //update existing entry
|
|
|
|
+ $DB->update_record('gradeimporter', $submission);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $submission = file_postupdate_standard_editor($model, 'description', $descriptionoptions, $context, 'mod_gradeimporter', 'description', $submission->id);
|
|
|
|
+ $submission = file_postupdate_standard_filemanager($submission, 'submission', $submissionoptions, $context, 'mod_gradeimporter', 'submission', $submission->id);
|
|
|
|
+
|
|
|
|
+ gradeimporter_check_for_zips($context, $cm, $submission);
|
|
|
|
+
|
|
|
|
+ //store updated values
|
|
|
|
+ $DB->update_record('gradeimporter_submission', $submission);
|
|
|
|
+
|
|
|
|
+ //refetch complete entry
|
|
|
|
+ $submission = $DB->get_record('gradeimporter_submission', array('id'=>$submission->id));
|
|
|
|
+
|
|
|
|
+ //trigger event and update completion (if entry was created)
|
|
|
|
+ $eventparams = array(
|
|
|
|
+ 'context'=>context,
|
|
|
|
+ 'objectid'=>$submission->id,
|
|
|
|
+ );
|
|
|
|
+ if ($isnewentry){
|
|
|
|
+ //update completion state
|
|
|
|
+ $completion = new completion_info($course);
|
|
|
|
+ if ($completion->is_enabled($cm) == COMPLETION_TRACKING_AUTOMATIC && $gradeimporter->completionentries) {
|
|
|
|
+ $completion->update_state($cm, COMPLETION_COMPLETE);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ redirect("view.php?id=$cm->id&edition=1");
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+if(!empty($id)) {
|
|
|
|
+ $PAGE->navbar->add(get_string('edit'));
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+$PAGE->set_title($gradeimporter->name);
|
|
|
|
+$PAGE->set_heading($course->fullname);
|
|
|
|
+echo $OUTPUT->header();
|
|
|
|
+echo $OUTPUT->heading(format_string($gradeimporter->name), 2);
|
|
|
|
+if ($gradeimporter->intro){
|
|
|
|
+ echo $OUTPUT->box(format_module_intro('gradeimporter', $gradeimporter, $cm->id), 'generalbox', 'intro');
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+$mform->display();
|
|
|
|
+
|
|
|
|
+echo $OUTPUT->footer();
|
|
|
|
+
|
|
|
|
+//codigo antigo
|
|
|
|
+/*if (!$gradeimporter = $DB->get_record('gradeimporter', array('id' => $id))) {
|
|
print_error('invalidgradeimproterdid', 'gradeimporter');
|
|
print_error('invalidgradeimproterdid', 'gradeimporter');
|
|
}
|
|
}
|
|
|
|
|
|
@@ -67,7 +197,7 @@ if ($mform-is_cancelled()) {
|
|
$newsubmission->visibility = $formdata->visibility;
|
|
$newsubmission->visibility = $formdata->visibility;
|
|
|
|
|
|
if ($DB->insert_record('gradeimporter_submission', $newsubmission)) {
|
|
if ($DB->insert_record('gradeimporter_submission', $newsubmission)) {
|
|
- $params = array(
|
|
|
|
|
|
+ $params = array($cmid = required_param('cmid', PARAM_INT); // Course Module ID
|
|
'context' => $context,
|
|
'context' => $context,
|
|
'other' => array(
|
|
'other' => array(
|
|
'gradeimporterid' => $gradeimporter->id
|
|
'gradeimporterid' => $gradeimporter->id
|
|
@@ -85,4 +215,4 @@ echo $OUTPUT->header();
|
|
|
|
|
|
$mform->display();
|
|
$mform->display();
|
|
|
|
|
|
-echo $OUTPUT->footer();
|
|
|
|
|
|
+echo $OUTPUT->footer();*/
|