Igor пре 3 година
родитељ
комит
d7d15c8756
5 измењених фајлова са 123 додато и 91 уклоњено
  1. 11 1
      db/install.php
  2. 10 0
      db/upgrade.php
  3. 11 3
      iassign_form.php
  4. 90 86
      locallib.php
  5. 1 1
      version.php

+ 11 - 1
db/install.php

@@ -70,7 +70,7 @@ function xmldb_iassign_install () {
               'enable', 'evaluate', 'reevaluate', 'timemodified', 'author', 'timecreated',
               'editingbehavior', 'submissionbehavior', 'action_buttons'),
         array('iVProg', 'http://www.usp.br/line/ivprog/', '1.0.20200121', 'HTML5', '{"en":"Visual Interactive Programming on the Internet (HTML)","pt_br":"Programação visual interativa na Internet"}',
-              'ivph', 'ilm/iVProg/1.0.20190717/ivprog/', 'index.html', 800, 600,
+              'ivph', 'ilm/iVProg/1.0.20200221/ivprog/', 'index.html', 800, 600,
               1, 1, 1, time(), $USER->id, time(),
               1, 0, 1)),
       array_combine( // iHanoi 1.0.20200803 - HTML5
@@ -158,6 +158,16 @@ function xmldb_iassign_install () {
       print '</div' . "\n";;
       }
 
+    // Create $CFG->dataroot/temp/iassign_files
+    $tempfilespath = $CFG->dataroot . DIRECTORY_SEPARATOR . 'temp';
+    if (!file_exists($tempfilespath)) {
+      mkdir($tempfilespath, 0777, true);
+      }
+    $iassignfilespath = $tempfilespath . DIRECTORY_SEPARATOR . 'iassign_files';
+    if (!file_exists($iassignfilespath)) {
+      mkdir($iassignfilespath, 0777, true);
+      }
+
   // log event -----------------------------------------------------
   if (class_exists('plugin_manager'))
     $pluginman = plugin_manager::instance();

+ 10 - 0
db/upgrade.php

@@ -464,6 +464,16 @@ function xmldb_iassign_upgrade ($oldversion) {
       $DB->execute("ALTER TABLE {iassign_ilm} DROP INDEX {iassilm_fil_uix}");
     } catch (Exception $ex) {}
 
+    // Create $CFG->dataroot/temp/iassign_files
+    $tempfilespath = $CFG->dataroot . DIRECTORY_SEPARATOR . 'temp';
+    if (!file_exists($tempfilespath)) {
+      mkdir($tempfilespath, 0777, true);
+      }
+    $iassignfilespath = $tempfilespath . DIRECTORY_SEPARATOR . 'iassign_files';
+    if (!file_exists($iassignfilespath)) {
+      mkdir($iassignfilespath, 0777, true);
+      }
+
     } // if ($oldversion < 2020122900)
 
   // log event -----------------------------------------------------

+ 11 - 3
iassign_form.php

@@ -44,7 +44,7 @@ require_once($CFG->dirroot . '/mod/iassign/lib.php');
 
 
 /// This class create form based moodleform.
-//  @see moodleform
+//  @see /lib/formslib.php: __construct($action=null, $customdata=null, $method='post', $target='', $attributes=null, $editable=true, $ajaxformdata=null)
 class mod_iassign_form extends moodleform {
 
   /// Add elements to form
@@ -53,6 +53,8 @@ class mod_iassign_form extends moodleform {
     $mform = $this->_form;
     $instance = $this->_customdata;
 
+    //D echo "<br/><br/><br/><br/>iassign_form.php: this->_customdata="; print_r($this->_customdata); echo "<br/>";
+      
     // iGeom has special parameter 'script'
     $params = array('name' => '%iGeom%', 'parent' => 0);
     $igeom = $DB->get_records_sql(
@@ -329,7 +331,8 @@ class mod_iassign_form extends moodleform {
     if ($result_recent && isset($result_recent->iassign_ilmid)) { // try the last iLM used...
       $code_javascript .= ' <script>  document.forms[0].iassign_ilmid.value = ' . $result_recent->iassign_ilmid . '</script>' . "\n";
       }
- 
+
+
     //TODO Adaptives to use API of MoodleForm
     // addOption($optgroup, $text, $value, $attributes=null)
     // $allOptions = array(); $ilmHtml = array(); $ilmJava = array();
@@ -375,11 +378,16 @@ class mod_iassign_form extends moodleform {
     $html_div .= '</div>';
     $mform->addElement('html', $html_div);
 
-
     $mform->addElement('selectyesno', 'store_all_submissions', get_string('store_all_submissions', 'iassign'));
     $mform->setDefault('store_all_submissions', 1);
     $mform->addHelpButton('store_all_submissions', 'store_all_submissions_help', 'iassign');
 
+    //-----------------------------------------------------------------------------
+    // Applies only iLM iGeom
+    $mform->addElement('selectyesno', 'special_param1', get_string('special_param', 'iassign')); //$ynoptions
+    $mform->setDefault('special_param1', 0);
+    $mform->addHelpButton('special_param1', 'helpspecial_param', 'iassign');     
+
     //-----------------------------------------------------------------------------
     //Applies only when the iLM is automatic evaluate.
     $mform->addElement('header', 'id_automatic_evaluate', get_string('only_automatic_evaluate', 'iassign'));

+ 90 - 86
locallib.php

@@ -406,12 +406,12 @@ class iassign {
     $ilm_list = $DB->get_records("iassign_ilm");
 
     // Get list of enrolled students:
-    $params = array('shortname' => 'student');
-    $role = $DB->get_record_sql("SELECT s.id, s.shortname FROM {role} s WHERE s.shortname = :shortname", $params);
+    $params_temp = array('shortname' => 'student');
+    $role = $DB->get_record_sql("SELECT s.id, s.shortname FROM {role} s WHERE s.shortname = :shortname", $params_temp);
     $context = context_course::instance($this->course->id);
-    $params = array('contextid' => $context->id, 'roleid' => $role->id);
+    $params_temp = array('contextid' => $context->id, 'roleid' => $role->id);
     $students_list = $DB->get_records_sql(
-        "SELECT s.userid, a.firstname, a.lastname FROM {role_assignments} s, {user} a " .  " WHERE s.contextid = :contextid AND s.userid = a.id AND s.roleid = :roleid " . " ORDER BY a.firstname ASC,a.lastname ASC", $params);
+        "SELECT s.userid, a.firstname, a.lastname FROM {role_assignments} s, {user} a " .  " WHERE s.contextid = :contextid AND s.userid = a.id AND s.roleid = :roleid " . " ORDER BY a.firstname ASC,a.lastname ASC", $params_temp);
 
     $json_obj = new stdclass();
     $json_obj->submissions = [];
@@ -449,7 +449,10 @@ class iassign {
         }
       }
 
-    $diretorio = $CFG->dataroot . DIRECTORY_SEPARATOR . 'temp' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR;
+    //2021 $diretorio = $CFG->dataroot . DIRECTORY_SEPARATOR . 'temp' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR;
+    //TODO: tem que criar moodledata/temp/iassign_files
+    $diretorio = $CFG->dataroot . DIRECTORY_SEPARATOR . 'temp' 
+     . DIRECTORY_SEPARATOR . 'iassign_files' . DIRECTORY_SEPARATOR;
 
     $zip_filename = $diretorio . 'package_iassign_'.time().'.zip';
 
@@ -482,7 +485,7 @@ class iassign {
             $date = new DateTime();
             $date->setTimestamp($item->timecreated);
 
-            $new_file = $individual_dir . DIRECTORY_SEPARATOR . iassign_utils::format_filename('submission_' . ($i++) . '_' . date_format($date, 'Y-m-d_H-i-s') . '.' . $extension_ilm);
+            $new_file = $individual_dir . DIRECTORY_SEPARATOR . iassign_utils::format_filename('submission_' . ($i++) . '_' . date_format($date, 'Y-m-d_H-i-s')) . '.' . $extension_ilm;
 
             $zip->add_file_from_string($new_file, $item->answer);
 
@@ -605,8 +608,6 @@ class iassign {
 
     $atual_submission = $DB->get_record('iassign_allsubmissions', array('id' => $submissionid));
 
-    //print_r($atual_submission);
-
     $all_submissions = $DB->get_records('iassign_allsubmissions', 
         array('iassign_statementid' => $atual_submission->iassign_statementid, 'userid' => $atual_submission->userid));
 
@@ -645,7 +646,9 @@ class iassign {
       }
     $statement = $DB->get_record('iassign_statement', array('id' => $atual_submission->iassign_statementid));
 
-    print ilm_settings::build_ilm_tags($statement->iassign_ilmid, ['type' => "view", 'Proposition' => $url]);
+    print 
+    //array("type" => "editor_new", "notSEND" => "true")
+    ilm_settings::build_ilm_tags($statement->iassign_ilmid, ['type' => "activity", 'Proposition' => $url, "notSEND" => "false"]);
     print '</center>';
     }
 
@@ -727,12 +730,12 @@ class iassign {
     print '<i onclick="download_submission(\'block\', 0, 0, '.$iassignid.')" class="fa fa-download" style="float: right; color: #1fa67a; font-size: 1.5rem; cursor: pointer; margin-left: 1rem; margin-top: .2rem;" aria-hidden="true"></i> </h2>';
 
     // Get list of enrolled students:
-    $params = array('shortname' => 'student');
-    $role = $DB->get_record_sql("SELECT s.id, s.shortname FROM {role} s WHERE s.shortname = :shortname", $params);
+    $params_temp = array('shortname' => 'student');
+    $role = $DB->get_record_sql("SELECT s.id, s.shortname FROM {role} s WHERE s.shortname = :shortname", $params_temp);
     $context = context_course::instance($this->course->id);
-    $params = array('contextid' => $context->id, 'roleid' => $role->id);
+    $params_temp = array('contextid' => $context->id, 'roleid' => $role->id);
     $students_list = $DB->get_records_sql(
-      "SELECT s.userid, a.firstname, a.lastname FROM {role_assignments} s, {user} a " .  " WHERE s.contextid = :contextid AND s.userid = a.id AND s.roleid = :roleid " . " ORDER BY a.firstname ASC,a.lastname ASC", $params);
+      "SELECT s.userid, a.firstname, a.lastname FROM {role_assignments} s, {user} a " .  " WHERE s.contextid = :contextid AND s.userid = a.id AND s.roleid = :roleid " . " ORDER BY a.firstname ASC,a.lastname ASC", $params_temp);
 
     print '<div>';
     foreach ($exercises_list as $exercise) {
@@ -827,14 +830,14 @@ class iassign {
     $exercises_list = $DB->get_records("iassign_statement", array("iassignid" => $iassignid));
 
     // Get list of enrolled students:
-    $params = array('shortname' => 'student');
-    $role = $DB->get_record_sql("SELECT s.id, s.shortname FROM {role} s WHERE s.shortname = :shortname", $params);
+    $params_temp = array('shortname' => 'student');
+    $role = $DB->get_record_sql("SELECT s.id, s.shortname FROM {role} s WHERE s.shortname = :shortname", $params_temp);
     $context = context_course::instance($this->course->id);
-    $params = array('contextid' => $context->id, 'roleid' => $role->id);
+    $params_temp = array('contextid' => $context->id, 'roleid' => $role->id);
     $students_list = $DB->get_records_sql(
         "SELECT s.userid, a.firstname, a.lastname FROM {role_assignments} s, {user} a " .
         " WHERE s.contextid = :contextid AND s.userid = a.id AND s.roleid = :roleid " .
-        " ORDER BY a.firstname ASC,a.lastname ASC", $params);
+        " ORDER BY a.firstname ASC,a.lastname ASC", $params_temp);
 
     print $OUTPUT->header();
 
@@ -890,10 +893,10 @@ class iassign {
           "ilm": "' . $CFG->wwwroot . '/mod/iassign/' . $iassign_ilm->file_jar . $iassign_ilm->file_class . '",
           "submited": ['; // "
 
-      $params = array('iassign_statementid' => $exercise->id);
+      $params_temp = array('iassign_statementid' => $exercise->id);
       $submited = $DB->get_records_sql( // Get userid and his grade
         "SELECT s.userid, s.grade FROM {iassign_submission} s " .
-        " WHERE s.iassign_statementid = :iassign_statementid", $params);
+        " WHERE s.iassign_statementid = :iassign_statementid", $params_temp);
 
       foreach ($submited as $ss) {
         print($ss->userid . ',');
@@ -1286,7 +1289,7 @@ var exercises = [ '; // '
 
       print '  <tr data-student="' . $student->userid . '">
     <td>' . $OUTPUT->render($avatar) . ' <span class="student-name">' . $user->firstname . ' ' . $user->lastname . '</span></td>
-    </tr>' . "\n";
+    </tr>' . "\n"; // "
       }
 
     print " </tbody>
@@ -1904,6 +1907,7 @@ var exercises = [ '; // '
 
 
   /// Add or Edit interactive activities
+  //  Get here when editing form and and submitted form data
   //  @calledby $this->action()
   function add_edit_iassign () {
     global $USER, $CFG, $COURSE, $DB, $OUTPUT;
@@ -1915,13 +1919,13 @@ var exercises = [ '; // '
     $param = new stdClass(); // parameters to build data to the form - see bellow "$mform = new mod_iassign_form(...); $mform->set_data($param);
 
     $param->action = $this->action; // hidden
-
     $param->id = $id; // hidden
+
+$param->special_param1 = 0; // 'special_param1 == 1' => script of iGeom
+
     $COURSE->cm = $id;
     $COURSE->iassignid = $iassignid;
     $COURSE->iassign_file_id = NULL;
-// echo "<br/><br/><br/>locallib.php: add_edit_iassign(): id=$id, iassignid=$iassignid, action=" . $this->action . "<br/>\n";
-// locallib.php: add_edit_iassign(): id=18612, iassignid=1355, action=edit
 
     $context = context_module::instance($this->cm->id);
 
@@ -1940,10 +1944,10 @@ var exercises = [ '; // '
     if ($this->action == 'add') {
       $iassign_data = $DB->get_record("iassign", array('id' => $iassignid));
 
-      $params = array('iassignid' => $iassignid);
+      $params_temp = array('iassignid' => $iassignid);
 
       $query_str = "SELECT s.id, s.name, s.dependency FROM {iassign_statement} s WHERE s.iassignid = :iassignid ORDER BY s.position ASC";
-      $iassign_statement = $DB->get_records_sql($query_str, $params); //
+      $iassign_statement = $DB->get_records_sql($query_str, $params_temp); //
       $total_of_activities = count($iassign_statement);
 
       $param->iassignid = $iassignid;
@@ -1992,8 +1996,7 @@ var exercises = [ '; // '
 
       $this_activity = $this->activity->get_activity();
 
-      if ($this_activity != null) {
-        //2019 $iassign_statement_current = $DB->get_record("iassign_statement", array("id" => $this_activity->id));
+      if ($this_activity != null) { // first enter here: fill form data
         $iassign_statement_current = $this_activity; // $DB->get_record("iassign_statement", array("id" => $this_activity->id));
 
         $param->iassign_id = $iassign_statement_current->id; // oculto
@@ -2003,8 +2006,6 @@ var exercises = [ '; // '
         $param->type_iassign = $iassign_statement_current->type_iassign;
         $param->store_all_submissions = $iassign_statement_current->store_all_submissions;
 
-        //2019: Moodle 3 uses proposition in 'textarea' as "('text' => <text>, 'format' => '')
-        //2019  $param->proposition = $iassign_statement_current->proposition;
         $param->proposition = array('text' => $iassign_statement_current->proposition, ''); //'format' => $instance->introformat
 
         $param->author_name = $iassign_statement_current->author_name; // oculto
@@ -2036,11 +2037,6 @@ var exercises = [ '; // '
         // Get all activities in the same iAssigment block:
         $str_query = "SELECT id, name FROM {iassign_statement} WHERE iassignid = '" . $iassignid . "' AND id!='" . $iassign_statement_current->id . "' ORDER BY position ASC";
         $all_others_iassign_statement = $DB->get_records_sql($str_query);
-//echo "<br/><br/><br/>1. all_others_iassign_statement="; print_r($all_others_iassign_statement); echo "<br/>";
-// [5426] => stdClass Object ( [id] => 5426 [name] => 1. iHanói: com 3 discos )
-// [5428] => stdClass Object ( [id] => 5428 [name] => 1. iFrações: trator 1, fase 1 )
-// [5427] => stdClass Object ( [id] => 5427 [name] => 1. iFrações: trator 1, fase 2 )
-// [5429] => stdClass Object ( [id] => 5429 [name] => 1. iVProg. Ler e imprimir inteiro. ) ) 
 
         $total_of_activities = count($all_others_iassign_statement) + 1;
 
@@ -2068,7 +2064,7 @@ var exercises = [ '; // '
             else
               $COURSE->iassign_list[$iassignid]->enable = 1;
             } // foreach ($all_others_iassign_statement as $iassign)
-          }
+          } // if ($all_others_iassign_statement)
 
         $param->iassign_ilmid = $iassign_statement_current->iassign_ilmid; // define iLM ID to be used to define 'select' on 'iassign_form.php'
 
@@ -2077,13 +2073,13 @@ var exercises = [ '; // '
         $param->file = 0; //TODO Criar campo 'iassign_statement.filesid' para registar 'files.id' - abaixo faz '$file->get_id();'
         $param->filename = '';
         $param->grade = $iassign_statement_current->grade;
-        $param->timecreated = $iassign_statement_current->timecreated; // oculto
+        $param->timecreated = $iassign_statement_current->timecreated; // hidden
         $param->timeavailable = $iassign_statement_current->timeavailable;
         $param->timedue = $iassign_statement_current->timedue;
         $param->preventlate = $iassign_statement_current->preventlate;
         $param->test = $iassign_statement_current->test;
-        $param->special_param1 = $iassign_statement_current->special_param1;
-        $param->position = $iassign_statement_current->position; // oculto
+        $param->special_param1 = $iassign_statement_current->special_param1;  // 'special_param1 == 1' => script of iGeom
+        $param->position = $iassign_statement_current->position; // hidden
         $param->visible = $iassign_statement_current->visible;
         $param->max_experiment = $iassign_statement_current->max_experiment;
         $param->automatic_evaluate = $iassign_statement_current->automatic_evaluate;
@@ -2124,10 +2120,19 @@ var exercises = [ '; // '
     $param->position = $total_of_activities;
 
     // Create form and associate its data
-    // $mform = new mod_iassign_form(null, null, null, null, array('id'=>'mform1')); // ./mod/iassign/iassign_form.php
-    
-    $mform = new mod_iassign_form(null, null, null, null, array('id'=>'mform1'));
-    $mform->set_data($param);
+    // 'mform1' is used in: ./mod/iassign/iassign_form.php, ./mod/iassign/settings_form.php
+    // new mod_iassign_form(...) in ./mod/iassign/iassign_form.php extends /lib/formslib.php:
+    // /lib/formslib.php: __construct($action=null, $customdata=null, $method='post', $target='', $attributes=null, $editable=true, $ajaxformdata=null) 
+    if (isset($param->iassign_ilmid)) {
+      // array is additional atributes to 'form'
+      // 'special_param1 == 1' => script of iGeom : <select class="custom-select" name="special_param1" id="id_special_param1"> "Assignment with script(algorithm)? (Applicable only to iGeom iLM)"
+      $mform = new mod_iassign_form(null, array('special_param1'=>$param->special_param1), 'post', null, array('id'=>'mform1', 'iassign_ilmid'=>$param->iassign_ilmid), true, null);
+      }
+    else {
+      $mform = new mod_iassign_form(null, null, null, null, array('id'=>'mform1')); // ./mod/iassign/iassign_form.php
+      }
+
+    $mform->set_data($param); // define data in the form
 
     if ($mform->is_cancelled()) {
       $this->return_home_course('iassign_cancel');
@@ -2290,19 +2295,19 @@ var exercises = [ '; // '
 
     $grade_iassign = $DB->get_record("iassign", array("id" => $iassignid));
     $grades = NULL;
-    $params = array('itemname' => $grade_iassign->name);
-    $params['iteminstance'] = $iassignid;
-    $params['gradetype'] = GRADE_TYPE_VALUE;
+    $params_temp = array('itemname' => $grade_iassign->name);
+    $params_temp['iteminstance'] = $iassignid;
+    $params_temp['gradetype'] = GRADE_TYPE_VALUE;
     //2016 if ($sum_grade != 0) {
-    $params['grademax'] = $sum_grade;
-    $params['rawgrademax'] = $sum_grade;
-    //2016 } else { $params['grademax'] = 0; $params['rawgrademax'] = 0; }
-    $params['grademin'] = 0;
+    $params_temp['grademax'] = $sum_grade;
+    $params_temp['rawgrademax'] = $sum_grade;
+    //2016 } else { $params_temp['grademax'] = 0; $params_temp['rawgrademax'] = 0; }
+    $params_temp['grademin'] = 0;
     // @calls /lib/gradelib.php: call to grade_item->insert()
     //TODO: is there any error here in Moodle version 3.0?
     //TODO: Incorrect property 'grademax' found when inserting grade object
     //TODO: line 899 of /mod/iassign/locallib.php: call to grade_update()
-    grade_update('mod/iassign', $grade_iassign->course, 'mod', 'iassign', $iassignid, 0, $grades, $params);
+    grade_update('mod/iassign', $grade_iassign->course, 'mod', 'iassign', $iassignid, 0, $grades, $params_temp);
     }
 
 
@@ -2333,15 +2338,15 @@ var exercises = [ '; // '
 
     $grades['userid'] = $userid;
     $grades['rawgrade'] = $total_grade; // sum of all submissions for this iAssign activity
-    $params = array('itemname' => $grade_iassign->name);
-    $params['iteminstance'] = $iassignid;
-    $params['gradetype'] = GRADE_TYPE_VALUE;
+    $params_temp = array('itemname' => $grade_iassign->name);
+    $params_temp['iteminstance'] = $iassignid;
+    $params_temp['gradetype'] = GRADE_TYPE_VALUE;
 
     //2016 if ($sum_grade != 0) { // depois eliminar comentario
-    $params['grademax'] = $sum_grade;
-    $params['rawgrademax'] = $sum_grade;
-    //2016 } else { $params['grademax'] = 0; $params['rawgrademax'] = 0; }
-    grade_update('mod/iassign', $grade_iassign->course, 'mod', 'iassign', $iassignid, 0, $grades, $params);
+    $params_temp['grademax'] = $sum_grade;
+    $params_temp['rawgrademax'] = $sum_grade;
+    //2016 } else { $params_temp['grademax'] = 0; $params_temp['rawgrademax'] = 0; }
+    grade_update('mod/iassign', $grade_iassign->course, 'mod', 'iassign', $iassignid, 0, $grades, $params_temp);
     }
 
   /// Display caption of icons
@@ -3116,14 +3121,14 @@ var exercises = [ '; // '
     }
 
     // Finding enrolled students:
-    $params = array('shortname' => 'student');
-    $role = $DB->get_record_sql("SELECT s.id, s.shortname FROM {role} s WHERE s.shortname = :shortname", $params);
+    $params_temp = array('shortname' => 'student');
+    $role = $DB->get_record_sql("SELECT s.id, s.shortname FROM {role} s WHERE s.shortname = :shortname", $params_temp);
     $context = context_course::instance($this->course->id);
-    $params = array('contextid' => $context->id, 'roleid' => $role->id);
+    $params_temp = array('contextid' => $context->id, 'roleid' => $role->id);
     $students = $DB->get_records_sql(
         "SELECT s.userid, a.firstname, a.lastname FROM {role_assignments} s, {user} a " .
         " WHERE s.contextid = :contextid AND s.userid = a.id AND s.roleid = :roleid " .
-        " ORDER BY a.firstname ASC,a.lastname ASC", $params);
+        " ORDER BY a.firstname ASC,a.lastname ASC", $params_temp);
 
     foreach ($students as $student) {
       $str .= $student->userid . ',';
@@ -3233,17 +3238,17 @@ var exercises = [ '; // '
     if ($num_exerc > 1) {
 
       // $role = $DB->get_record_sql("SELECT s.id, s.shortname FROM {$CFG->prefix}role s WHERE s.shortname = 'student'");
-      $params = array('shortname' => 'student');
+      $params_temp = array('shortname' => 'student');
       $role = $DB->get_record_sql(
         "SELECT s.id, s.shortname FROM {role} s " .
-        " WHERE s.shortname = :shortname", $params);
+        " WHERE s.shortname = :shortname", $params_temp);
 
       // $students = $DB->get_records_sql("SELECT s.userid, a.firstname, a.lastname FROM {$CFG->prefix}role_assignments s, {$CFG->prefix}user a WHERE s.contextid = '$context->id' AND s.userid = a.id AND s.roleid = '$role->id' ORDER BY a.firstname ASC,a.lastname ASC");
-      $params = array('contextid' => $context->id, 'roleid' => $role->id);
+      $params_temp = array('contextid' => $context->id, 'roleid' => $role->id);
       $students = $DB->get_records_sql(
         "SELECT s.userid, a.firstname, a.lastname FROM {role_assignments} s, {user} a " .
         " WHERE s.contextid = :contextid AND s.userid = a.id AND s.roleid = :roleid " .
-        " ORDER BY a.firstname ASC,a.lastname ASC", $params);
+        " ORDER BY a.firstname ASC,a.lastname ASC", $params_temp);
 
       print '<tr><th class="header c1">' . get_string('students', 'iassign') . '</th>' . "\n";
 
@@ -3292,10 +3297,10 @@ var exercises = [ '; // '
 
               // Get student comments
               // $student_submissions_comment = $DB->get_record_sql("SELECT COUNT(iassign_submissionid) FROM {$CFG->prefix}ia_assign_submissions_comment WHERE iassign_submissionid = '$student_submissions->id'");
-              $params = array('iassign_submissionid' => $student_submissions->id);
+              $params_temp = array('iassign_submissionid' => $student_submissions->id);
               $student_submissions_comment = $DB->get_record_sql(
                 "SELECT COUNT(iassign_submissionid) FROM {iassign_submission_comment} " .
-                "WHERE iassign_submissionid = :iassign_submissionid", $params);
+                "WHERE iassign_submissionid = :iassign_submissionid", $params_temp);
               if ($student_submissions_comment) // student has comment
                 foreach ($student_submissions_comment as $tmp)
                   $sum_comment = $tmp;
@@ -3325,12 +3330,12 @@ var exercises = [ '; // '
               // $verify_message = $DB->get_record_sql("SELECT COUNT(iassign_submissionid) FROM {$CFG->prefix}ia_assign_submissions_comment " .
               // "WHERE iassign_submissionid = '$student_submissions->id' AND return_status='0' AND receiver='1'");
 
-              $params = array('iassign_submissionid' => $student_submissions->id, 'return_status' => '0', 'receiver' => '1');
+              $params_temp = array('iassign_submissionid' => $student_submissions->id, 'return_status' => '0', 'receiver' => '1');
               $verify_message = $DB->get_record_sql(
                 "SELECT COUNT(iassign_submissionid) FROM {iassign_submission_comment} " .
                 "WHERE iassign_submissionid = :iassign_submissionid " .
                 "  AND return_status= :return_status " .
-                "  AND receiver= :receiver", $params);
+                "  AND receiver= :receiver", $params_temp);
 
               if ($verify_message)
                 foreach ($verify_message as $tmp)
@@ -3517,18 +3522,18 @@ var exercises = [ '; // '
 
     if ($i > 1) {
       // $role = $DB->get_record_sql("SELECT s.id, s.shortname FROM {$CFG->prefix}role s WHERE s.shortname = 'student'");
-      $params = array('shortname' => 'student');
+      $params_temp = array('shortname' => 'student');
       $role = $DB->get_record_sql(
         "SELECT s.id, s.shortname FROM {role} s " .
-        " WHERE s.shortname = :shortname", $params);
+        " WHERE s.shortname = :shortname", $params_temp);
 
       // $students = $DB->get_records_sql("SELECT s.userid, a.firstname, a.lastname FROM {$CFG->prefix}role_assignments s, {$CFG->prefix}user a WHERE s.contextid = '$context->id' AND s.userid = a.id AND s.roleid = '$role->id' ORDER BY a.firstname ASC,a.lastname ASC");
 
-      $params = array('contextid' => $context->id, 'roleid' => $role->id);
+      $params_temp = array('contextid' => $context->id, 'roleid' => $role->id);
       $students = $DB->get_records_sql(
         "SELECT s.userid, a.firstname, a.lastname FROM {role_assignments} s, {user} a " .
         " WHERE s.contextid = :contextid AND s.userid = a.id AND s.roleid = :roleid " .
-        " ORDER BY a.firstname ASC,a.lastname ASC", $params);
+        " ORDER BY a.firstname ASC,a.lastname ASC", $params_temp);
 
       $total = 0;
       $sum_student = 0;
@@ -4226,9 +4231,9 @@ var exercises = [ '; // '
         $sum_comment = 0;
         $iassign_submissions = $DB->get_records('iassign_submission', array('iassign_statementid' => $iassign_current));
         foreach ($iassign_submissions as $iassign_submission) {
-          $params = array('iassign_submissionid' => $iassign_submission->id, 'return_status' => '0', 'receiver' => '1');
+          $params_temp = array('iassign_submissionid' => $iassign_submission->id, 'return_status' => '0', 'receiver' => '1');
           $verify_message = $DB->get_record_sql("SELECT COUNT(iassign_submissionid) FROM {iassign_submission_comment} " .
-            " WHERE iassign_submissionid = :iassign_submissionid AND return_status= :return_status AND receiver= :receiver", $params);
+            " WHERE iassign_submissionid = :iassign_submissionid AND return_status= :return_status AND receiver= :receiver", $params_temp);
           if ($verify_message)
             foreach ($verify_message as $tmp)
               $sum_comment += $tmp;
@@ -4314,10 +4319,10 @@ var exercises = [ '; // '
            // receiver=2 - message to student
            // $verify_message = $DB->get_record_sql("SELECT COUNT(iassign_submissionid) FROM {$CFG->prefix}ia_assign_submissions_comment WHERE iassign_submissionid = '$iassign_submission->id' and return_status= 0 and receiver=2");
 
-           $params = array('iassign_submissionid' => $iassign_submission->id, 'return_status' => '0', 'receiver' => '2');
+           $params_temp = array('iassign_submissionid' => $iassign_submission->id, 'return_status' => '0', 'receiver' => '2');
            $verify_message = $DB->get_record_sql(
              "SELECT COUNT(iassign_submissionid) FROM {iassign_submission_comment} " .
-             " WHERE iassign_submissionid = :iassign_submissionid AND return_status= :return_status AND receiver= :receiver", $params);
+             " WHERE iassign_submissionid = :iassign_submissionid AND return_status= :return_status AND receiver= :receiver", $params_temp);
 
            if ($verify_message)
              foreach ($verify_message as $tmp)
@@ -4505,23 +4510,23 @@ var exercises = [ '; // '
       // verificar se existe uma submissão para o exercício e aluno informados
       if (!$iassign_submission) {
         $iassign_submission = $DB->get_record("iassign_submission", array("iassign_statementid" => $this->activity->get_activity()->id, "userid" => $USER->id));
-      }
+        }
 
       if (!$iassign_submission) {
         $iassign_statement_activity_item = $DB->get_record("iassign_statement", array("id" => $this->activity->get_activity()->id));
-
         $id_submission = $this->new_submission($iassign_statement_activity_item->id, $this->userid_iassign, $receiver);
         $this->iassign_submission_current = $id_submission;
-        } else {
+        }
+      else {
         $id_submission = $iassign_submission->id;
         } // if (!$iassign_submission)
       // $comments = $DB->get_record_sql("SELECT COUNT(iassign_submissionid) FROM {$CFG->prefix}ia_assign_submissions_comment
       // WHERE iassign_submissionid = '$id_submission' and comment='$submission_comment' and comment_authorid='$USER->id'"); //
       // Attention: this Moodle function 'get_record_sql' makes a replace in ':comment'
-      $params = array("iassign_submissionid" => $id_submission, "comment" => $submission_comment, "comment_authorid" => $USER->id);
+      $params_temp = array("iassign_submissionid" => $id_submission, "comment" => $submission_comment, "comment_authorid" => $USER->id);
       $comments = $DB->get_record_sql(
-            "SELECT COUNT(iassign_submissionid) FROM {iassign_submission_comment} " .
-            " WHERE iassign_submissionid = :iassign_submissionid AND comment= :comment AND comment_authorid= :comment_authorid", $params);
+        "SELECT COUNT(iassign_submissionid) FROM {iassign_submission_comment} " .
+        " WHERE iassign_submissionid = :iassign_submissionid AND comment= :comment AND comment_authorid= :comment_authorid", $params_temp);
 
       if ($comments)
         foreach ($comments as $tmp)
@@ -6828,7 +6833,6 @@ class ilm_manager {
   function add_ilm () {
     $fileid = optional_param('fileid', NULL, PARAM_INT);
     $filename = optional_param('filename', NULL, PARAM_TEXT);
-
     $output = "
   <script type='text/javascript'>
     //<![CDATA[
@@ -8054,10 +8058,10 @@ class iassign_utils {
       if (is_object($text)) // with iAssign did not filtered text from JSON format
         $text = json_decode($text)->{current_language()};
       // $text = htmlspecialchars($text); // not good ideia, it results strange at 'iassign_ilm' field
-      $array1 = array("(", ")", ",", "/", "\\", "!", "@", "#", "$", "&", "*", "+", "!", "?", ".", " ",
+      $array1 = array("(", ")", ",", "/", "\\", "!", "@", "#", "$", "&", "*", "+", "!", "?", ".", " ", ":",
                 "á", "à", "â", "ã", "ä", "é", "è", "ê", "ë", "ẽ", "í", "ì", "î", "ï", "ó", "ò", "ô", "õ", "ö", "ú", "ù", "û", "ü",
                 "ç", "Á", "À", "Â", "Ã", "Ä", "É", "È", "Ê", "Ë", "Í", "Ì", "Î", "Ï", "Ó", "Ò", "Ô", "Õ", "Ö", "Ú", "Ù", "Û", "Ü", "Ç");
-      $array2 = array("", "", "_", "_", "_", "", "", "", "", "", "", "", "", "", "_", "_",
+      $array2 = array("", "", "_", "_", "_", "", "", "", "", "", "", "", "", "", "_", "_", "-",
                 "a", "a", "a", "a", "a", "e", "e", "e", "e", "e", "i", "i", "i", "i", "o", "o", "o", "o", "o", "u", "u", "u", "u",
                 "c", "A", "A", "A", "A", "A", "E", "E", "E", "E", "I", "I", "I", "I", "O", "O", "O", "O", "O", "U", "U", "U", "U", "C");
 

+ 1 - 1
version.php

@@ -90,7 +90,7 @@ defined('MOODLE_INTERNAL') || die();
 // v 1.0 2012/10/16
 $plugin->component = 'mod_iassign';  // Full name of the plugin (used for diagnostics)
 $plugin->release = '2.8.01 (Build: 2020080300)'; // Human-readable version name
-$plugin->version = 2020102927;       // The current module version (Date: YYYYMMDDXX)
+$plugin->version = 2020102929;       // The current module version (Date: YYYYMMDDXX)
 $plugin->requires = 2014021100;      // Requires this Moodle version since 3.0.0)
 $plugin->maturity = MATURITY_STABLE; // How stable the plugin is: MATURITY_ALPHA, MATURITY_BETA, MATURITY_RC, MATURITY_STABLE (Moodle 2.0 and above)
 $plugin->cron = 60;