Browse Source

submission form functional
has to insert feedbacks into DB

bernardo 5 years ago
parent
commit
62d6a18513
5 changed files with 91 additions and 45 deletions
  1. 3 5
      db/install.xml
  2. 15 4
      lang/en/gradeimporter.php
  3. 1 1
      locallib.php
  4. 6 6
      submission.php
  5. 66 29
      submission_form.php

+ 3 - 5
db/install.xml

@@ -30,7 +30,7 @@
               COMMENT="Which gradeimporter instance this submission is related to" PREVIOUS="id" NEXT="type"/>
         <FIELD NAME="type" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Type of the submission (exam, exercise list,"
                 PREVIOUS="gradeimporter" NEXT="gradebook"/>
-        <FIELD NAME="gradebook" TYPE="binary" NOTNULL="true" SEQUENCE="false" COMMENT="Register if the submission is going to the gradebook"
+        <FIELD NAME="gradebook" TYPE="boolean" NOTNULL="true" SEQUENCE="false" COMMENT="Register if the submission is going to the gradebook"
                 PREVIOUS="type" NEXT="timecreated"/>
         <FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"
                 PREVIOUS="gradebook" NEXT="timemodified"/>
@@ -42,19 +42,17 @@
                 PREVIOUS="usermodified" NEXT="info"/>
         <FIELD NAME="description" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="Description of the submission type ex: exam 1 given on day YYYY/MM/DD"
               PREVIOUS="name" NEXT="position"/>
-        <FIELD NAME="descriptionformat" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
-
         <!--<FIELD NAME="descriptionformat" TYPE="char" LENGTH="10" NOTNULL="false" DEFAULT="plaintext" SEQUENCE="false" COMMENT="Description text format (html, plaintext, etc)"/>-->
         <FIELD NAME="position" TYPE="int" LENGTH="3" NOTNULL="true" SEQUENCE="false" COMMENT="Position relative to other submissions"
                 PREVIOUS="info" NEXT="visibility"/>
-        <FIELD NAME="visibility" TYPE="binary" NOTNULL="true" SEQUENCE="false" COMMENT="Registers if students can see this submission."
+        <FIELD NAME="visibility" TYPE="boolean" NOTNULL="true" SEQUENCE="false" COMMENT="Registers if students can see this submission."
                 PREVIOUS="position"/>
       </FIELDS>
       <KEYS>
         <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
         <KEY NAME="usermodified" TYPE="foreign" FIELDS="usermodified" REFTABLE="user" REFFIELDS="id"/>
         <KEY NAME="type" TYPE="foreign" FIELDS="type" REFTABLE="gradeimporter_submissiontype" REFFIELDS="id"/>
-        <KEY NAME="gradeimporter" TYPE="foreign" FIELDS="gradeimporter" REFTABLE="gradeimporter" REFFIELDS="id"/>
+        <KEY NAME="gradeimporterid" TYPE="foreign" FIELDS="gradeimporterid" REFTABLE="gradeimporter" REFFIELDS="id"/>
       </KEYS>
     </TABLE>
     <TABLE NAME="gradeimporter_submissiontype" COMMENT="Submission types are recorded by this table, eg: exam, exercises list, etc." PREVIOUS="gradeimporter_submission" NEXT="gradeimporter_feedback">

+ 15 - 4
lang/en/gradeimporter.php

@@ -9,7 +9,7 @@ $string['gradeimportername'] = 'Grade Importer Name';
 $string['pluginadministration'] ='plugin administration string';
 $string['displayingview'] = 'Posted Grades';
 
-//submission.oho
+//submission.php
 $string['invalidgradeimporterid'] = 'Invalid Grade Importer ID';
 $string['submissionadded'] = "Submission added to DB";
 $string['newsubmission'] = "Add new submission";
@@ -20,6 +20,8 @@ $string['newsubmission'] = "Add new submission";
     $string['description'] = 'Description';
     $string['visibility'] = 'Can students see this?';
     $string['name'] = 'Name';
+    $string['yes'] = 'Yes';
+    $string['no'] = 'no';
 
     //Generic error Messages
     $string['error_nameField'] = 'Insert a name';
@@ -29,6 +31,12 @@ $string['newsubmission'] = "Add new submission";
     $string['general'] = 'General informations';
     $string['visibilityOn'] = 'Students can see this';
     $string['visibilityOff'] = 'Students can\'t see this';
+    $string['csvdelimiter'] = 'Choose the csv delimiter';
+    $string['filehandling'] = 'File handling';
+    $string['gradebookYN'] = 'Results go to gradebook';
+    //subtypes
+        $string['exam'] = 'Exam';
+        $string['activity'] = 'Activity';
 
     //gradeImporter form errors
 
@@ -38,16 +46,19 @@ $string['newsubmission'] = "Add new submission";
     $string['gradebookN'] = 'This submission goes to gradebook';
     $string['gradebookY'] = 'This submission does not go to gradebook';
     $string['submissionFiles'] = 'Choose the students feedback file';
-    $string[''] = '';
+    $string['submissionDescription'] = 'Submission description';
     $string[''] = '';
 
 
     //submission form help buttons
-    $string['helpsubmissionfiles'] = 'Must be only one file, either a .zip or a .csv';
-    $string['helpcsvdelimiter'] = 'CSV delimiter of the config.csv file';
+    $string['submissionfiles_help'] = 'Must be only one file, either a .zip or a .csv';
+    $string['csvdelimiter_help'] = 'CSV delimiter of the config.csv file';
+    $string['gradebook_help'] = 'Yes, results go to gradebook \n No, Results don\'t go to gradebook';
+    $string['visibility_help'] = 'Yes, this is available to students \n No, This is not available to students';
 
     //submission form errors
 
 
+
 //events string
     $string['eventmodelsubmissioncreated'] = 'Submission created';

+ 1 - 1
locallib.php

@@ -11,7 +11,7 @@ class feedback {
                gf.grade,
                gf.comment,
                gs.name gs_name,
-               gs.info gs_info,
+               gs.description gs_description,
                gst.name gst_name,
                gst.info gst_info,
                fileid

+ 6 - 6
submission.php

@@ -9,7 +9,7 @@ echo "pagina submission";
 
 
 $cmid = required_param('cmid', PARAM_INT);            // Course Module ID
-$id      = required_param('id', PARAM_INT);           //Gradeimporter id
+$id      = required_param('id' , PARAM_INT);           //Gradeimporter id
 //$delete  = optional_param('delete', 0, PARAM_INT);
 //$confirm = optional_param('confirm', 0, PARAM_INT);
 
@@ -38,7 +38,7 @@ $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));
+$submission = $DB->get_record('gradeimporter_submission', array('gradeimporterid'=>$gradeimporter->id));
 
 if($submission){
     if (isguestuser()){
@@ -46,11 +46,11 @@ if($submission){
     }
 } else{
     $submission = new stdClass();
-    $model->id = null;
+    $submission->id = null;
 }
 
 $maxfiles = 50;
-$maxbytes = $course->$maxbytes;
+$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);
@@ -83,8 +83,8 @@ if ($mform->is_cancelled()){
 
     $submission->description        = '';           //updated later
     $submission->descriptionformat  = FORMAT_HTML;  //updated later
-    //$submission->definitiontrust  = 0             //n sei oq faz
     $submission->timemodified       = $timenow;     
+    $submission->position           = -1;
 
     if ($isnewentry) {
         //add new entry
@@ -94,7 +94,7 @@ if ($mform->is_cancelled()){
         $DB->update_record('gradeimporter', $submission);
     }
 
-    $submission = file_postupdate_standard_editor($model, 'description', $descriptionoptions, $context, 'mod_gradeimporter', 'description', $submission->id);
+    $submission = file_postupdate_standard_editor($submission, '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);

+ 66 - 29
submission_form.php

@@ -3,60 +3,97 @@
         die('Direct access to this script is forbidden.');    ///  It must be included from a Moodle page
     }
 
-    require_once($CFG->dirroot.'/course/moodleform_mod.php');
-   // require_once($CFG->dirroot.'/mod/gradeimporter/lib.php');
+    require_once($CFG->dirroot.'/lib/formslib.php');
 
-    class mod_submission_form extends moodleform_mod{
+    //require_once($CFG->dirroot.'/course/moodleform_mod.php');
+    //require_once($CFG->dirroot.'/mod/gradeimporter/lib.php');
+
+    class mod_gradeimporter_submission_form extends moodleform{
         
         function definition(){
-            global $CFG, $DB, $OUTPUT;
+            global $CFG, $DB;
 
             $mform =& $this->_form;
-            $gradeimporter = $this->_customdata;
+            
+            $submission         = $this->_customdata['submission'];
+            $cm                 = $this->_customdata['cm'];
+            $descriptionoptions = $this->_customdata['descriptionoptions'];
+            $submissionoptions  = $this->_customdata['submissionoptions'];
+
+            $context = context_module::instance($cm->id);
+            $fmtoptions = array('context'=>$context);
 
+//----------------------------------------------------------------------
+//form elements start here
+            $mform->addElement('header', 'general', get_string('general', 'form'));
+
+            //submission name
             $mform->addElement('text', 'name', get_string('name', 'gradeimporter'), array('size'=>'64'));
             $mform->setType('name', PARAM_TEXT);
             $mform->addRule('name', get_string('error_nameField', 'gradeimporter'), 'required', null, 'client');
 
-            $this->standard_intro_elements(get_string('description', 'gradeimporter'));
+            //description
+            $mform->addElement('editor', 'description_editor', get_string('submissiondescription', 'gradeimporter'), null, $descriptionoptions);
+
+            //description format
+            //kill on the install.xml
+
+            $mform->addElement('header', 'filehandling', get_string('filehandling', 'gradeimporter'));
 
-            $mform->addElement('filemanager', 'submissionFiles', getString('submissionFiles', 'gradeimporter'), null,
-                                array('subdirs' => 1, 'maxbytes' => $maxbytes, 'areamaxbytes' => $maxbytes, 'maxfiles' => -1,
-                                'accepted_types' => array('*'),  'return_types' => FILE_INTERNAL | FILE_EXTERNAL)); 
-                                                                //restrict accepted types to compacted?
-            $mform->addHelpButton('submissionFiles', 'helpsubmissionfiles', 'gradeimporter');
+            //submission type
+            $submissiontype = array();
+            $submissiontype[0] = get_string('exam', 'gradeimporter');
+            $submissiontype[1] = get_string('activity', 'gradeimporter');
             
-            //csv delimiter
+   
+            $mform->addElement('select', 'type', get_string('submissiontype', 'gradeimporter'), $submissiontype, array('onChange' => 'config_type(this.value);'));
+            //$mform->setDefault('submissiontype', 0); // default submissiontype = 3
+            $mform->addHelpButton('submissiontype', 'subtype_help', 'gradeimporter');
+
+            //receive the files
+            $mform->addElement('filemanager', 'submission_filemanager', get_string('submissionFiles', 'gradeimporter'), null, $descriptionoptions);
+            $mform->addHelpButton('submission_filemanager', 'submissionfiles', 'gradeimporter');
 
+            //csv delimiter
             $csv_delimiter = array();
             $csv_delimiter[1] = ',';
             /*$csv_delimiter[2] = ';';
             $csv_delimiter[3] = ':';
             $csv_delimiter[4] = '\t';
-*/        
-            $mform->addElement('select', 'csv_delimiter', get_string('choose_type_activity', 'iassign'), $csv_delimiter, array('onChange' => 'config_type(this.value);'));
+            */
+   
+            $mform->addElement('select', 'csv_delimiter', get_string('csvdelimiter', 'gradeimporter'), $csv_delimiter, array('onChange' => 'config_type(this.value);'));
             $mform->setDefault('csv_delimiter', 1); // default csv_delimiter = 3
-            $mform->addHelpButton('csv_delimiter', 'helpcsvdelimiter', 'gradeimporter');
-
-            //submissionType
+            $mform->addHelpButton('csv_delimiter', 'csvdelimiter_help', 'gradeimporter');
 
+            
+            //gradebook Y/N Combobox
+            $ynarray = array();
+            $ynarray[0] = get_string('no', 'gradeimporter');
+            $ynarray[1] = get_string('yes', 'gradeimporter');
+            $mform->addElement('select', 'gradebook', get_string('gradebookYN', 'gradeimporter'), $ynarray);
+            //$mform->setDefault('gradebook', 0);
+            $mform->addHelpButton('gradebook', 'gradebook_help', 'gradeimporter');
 
-            //if the grades go into the gradebook or not
-            $radioarray = array();
-            $radioarray[] = $mform->createElement('radio', 'gradebook', '', get_string('gradebookY','gradeimporter'), 1, $attributes);
-            $radioarray[] = $mform->createElement('radio', 'gradebook', '', get_string('gradebookN', 'gradeimporter'), 0, $attributes);
-            $mform->addgroup($radioarray, 'radioar', '', array(' '), false);
-            $mform->setDefault('gradebook', 0);
 
+            //visibility Y/N Combobox
+            $mform->addElement('select', 'visibility', get_string('visibilityYN', 'gradeimporter'), $ynarray);
+            //$mform->setDefault('visibility', 0);
+            $mform->addHelpButton('visibility', 'visibility_help', 'gradeimporter');
 
-            //if students can se this submission or not
-            $visibilityar = array();
-            $visibilityar[] = $mform->createElement('radio', 'visibility', '', get_string('visibilityY','gradeimporter'), 1, $attributes);
-            $visibilityar[] = $mform->createElement('radio', 'visibility', '', get_string('visibilityN','gradeimporter'), 0, $attributes);
-            $mform->addgroup($visibilityar, 'radioar', '', array(' '), false);
-            $mform->setDefault('visibility', 1);
+        //-----------------------------
+        //hidden fields
+        $mform->addElement('hidden', 'id');
+        $mform->setType('id', PARAM_INT);
+        $mform->addElement('hidden', 'cmid');
+        $mform->setType('cmid', PARAM_INT);
+        //------------------------------
 
+            //--------------------------------------------------------------
             $this->add_action_buttons();
+
+            //--------------------------------------------------------------
+            $this->set_data($submission);
         }
     }