Преглед на файлове

Update 'locallib.php'

+ function view_iassign_current (): 186/1076
   * Acresc. condicao para evitar erro em "print $OUTPUT->user_picture($user_data);":
     if ($user_data) // additional security (if sessions ends)
   * No "else if ($iassign_submission && $allow_resubmission)" acresc. p/ permitir prof. ver enunc. (qdo aluno NAO enviou solucao):
     else if (!$student_answer) { $loadTeacherActivity = true; }
leo преди 2 години
родител
ревизия
12acc02762
променени са 1 файла, в които са добавени 174 реда и са изтрити 170 реда
  1. 174 170
      locallib.php

+ 174 - 170
locallib.php

@@ -4,6 +4,9 @@
  * This class provides all the functionality for an ia (interactive activities).
  *
  * Release Notes:
+ * - v 4.9.6 2022/01/21
+ *   + Try to fix view activity not sent through report ("view_iassign_current()": else if (!$student_answer) $loadTeacherActivity=true;)
+ *
  * - v 4.9.5 2021/12/28
  *   + Detail to fix order o activities inside a block ('iassign_statement.position' - old instalation could generate order error)
  *
@@ -659,32 +662,32 @@ class iassign {
         }
       $i++;
       }
-    print '<center>';
-    print '<table cellpading=5 cellspacing=5 style="padding-bottom: 2rem;font-size: 1.1em;"><tr><td>' . get_string('exercise', 'iassign') . ':</td><td>' . $atual_statement->name . '</td></tr>';
-    print '<tr><td>' . get_string('student', 'iassign') . '</td><td>' . $user->firstname . ' ' . $user->lastname . '</td></tr>';
-    print '<tr><td>' . get_string('grade_student', 'iassign') . ':</td><td>' . $atual_submission->grade . '</td></tr>';
-    print '<tr><td>' . get_string('all_submissions_manager_date', 'iassign') . ':</td><td>' . userdate($atual_submission->timecreated) . '</td></tr>';
+    print '<center>' . "\n";
+    print '<table cellpading=5 cellspacing=5 style="padding-bottom: 2rem;font-size: 1.1em;"><tr><td>' . get_string('exercise', 'iassign') . ':</td><td>' . $atual_statement->name . '</td></tr>' . "\n";
+    print '<tr><td>' . get_string('student', 'iassign') . '</td><td>' . $user->firstname . ' ' . $user->lastname . '</td></tr>' . "\n";
+    print '<tr><td>' . get_string('grade_student', 'iassign') . ':</td><td>' . $atual_submission->grade . '</td></tr>' . "\n";
+    print '<tr><td>' . get_string('all_submissions_manager_date', 'iassign') . ':</td><td>' . userdate($atual_submission->timecreated) . '</td></tr>' . "\n";
 
-    print '</table>';
+    print '</table>' . "\n";
 
     if ($previous) {
       $url_prev = "" . $CFG->wwwroot . "/mod/iassign/view.php?action=open_individual_submission&" . $param_aux . "&item=" . $previous->id;
-      print '<a href="'.$url_prev.'" style="color: blue; text-decoration: none;margin: 1rem;"><span>&#9664;</span> '.get_string('all_submissions_manager_previous', 'iassign').'</a> ';
+      print '<a href="' . $url_prev . '" style="color: blue; text-decoration: none;margin: 1rem;"><span>&#9664;</span> ' . get_string('all_submissions_manager_previous', 'iassign') . '</a> ';
     } else {
-      print '<a href="#" style="color: gray; text-decoration: none;margin: 1rem;"><span>&#9664;</span> '.get_string('all_submissions_manager_previous', 'iassign').'</a> ';
+      print '<a href="#" style="color: gray; text-decoration: none;margin: 1rem;"><span>&#9664;</span> ' . get_string('all_submissions_manager_previous', 'iassign') . '</a> ';
       }
     print ' (' . $i . '/' . count($all_submissions) . ')';
     if ($next) {
       $url_next = "" . $CFG->wwwroot . "/mod/iassign/view.php?action=open_individual_submission&" . $param_aux . "&item=" . $next->id;
-      print '<a href="'.$url_next.'" style="color: blue; text-decoration: none;margin: 1rem;">'.get_string('all_submissions_manager_next', 'iassign').' <span>&#9654;</span></a>';
+      print '<a href="' . $url_next . '" style="color: blue; text-decoration: none;margin: 1rem;">' . get_string('all_submissions_manager_next', 'iassign') . ' <span>&#9654;</span></a>' . "\n";
     } else {
-      print '<a href="#" style="color: gray; text-decoration: none;margin: 1rem;">'.get_string('all_submissions_manager_next', 'iassign').' <span>&#9654;</span></a>';
+      print '<a href="#" style="color: gray; text-decoration: none;margin: 1rem;">' . get_string('all_submissions_manager_next', 'iassign') . ' <span>&#9654;</span></a>' . "\n";
       }
     $statement = $DB->get_record('iassign_statement', array('id' => $atual_submission->iassign_statementid));
 
     //array("type" => "editor_new", "notSEND" => "true")
     print ilm_settings::build_ilm_tags($statement->iassign_ilmid, ['type' => "activity", 'Proposition' => $url, "notSEND" => "false"]);
-    print '</center>';
+    print '</center>' . "\n";
     } // function open_individual_submission()
 
 
@@ -747,7 +750,7 @@ class iassign {
 
     redirect($this->return, get_string($str_index, 'iassign'), null, \core\output\notification::NOTIFY_SUCCESS);
     exit;
-  }
+    }
 
   function import_activity () {
     global $COURSE, $CFG, $USER, $DB, $OUTPUT, $PAGE;
@@ -760,13 +763,13 @@ class iassign {
       document.getElementById("msg-error").classList.add("d-none");
 
       var checkboxes = document.getElementsByName("statements[]");
-      for(var i = 0; i < checkboxes.length; i++)
+      for (var i = 0; i < checkboxes.length; i++)
         if (checkboxes[i].checked) return true;
         
       document.getElementById("msg-error").classList.remove("d-none");
       return false;
-    }
-    </script>';
+      }
+    </script>'; // "
 
     $destiny_url = new moodle_url('/mod/iassign/view.php', array('id' => $this->cm->id, 'action' => 'import_activity_confirm'));
 
@@ -774,81 +777,73 @@ class iassign {
 
     $this->print_main_menu();
 
-    print '<h2 class="m-b-2 mt-4">' . get_string('import_activity', 'iassign') . '</h2>';
+    print '<h2 class="m-b-2 mt-4">' . get_string('import_activity', 'iassign') . '</h2>' . "\n";
+    print '<form action="' . $destiny_url . '" method="post" onsubmit="return verify_selection()">' . "\n";
 
-    print '<form action="'.$destiny_url.'" method="post" onsubmit="return verify_selection()">';
-    
     $courses_as_teacher = $this->get_courses_enroled_as_teacher($USER->id);
 
     foreach ($courses_as_teacher as $course) {
-
-      print '<a href="#item-'.$course->id.'" class="list-group-item list-group-item-action h5" style="margin-top: 1rem;" data-toggle="collapse" onclick=\'$(".fa-caret-right, .fa-caret-down", this).toggleClass("fa-caret-right").toggleClass("fa-caret-down");\' > <i class="fa fa-caret-right"></i> ' . $course->fullname . ' </a>';
-
-      print '<div class="collapse" style="padding: 0 1.5rem;" id="item-'.$course->id.'">';
+      print '<a href="#item-' . $course->id . '" class="list-group-item list-group-item-action h5" style="margin-top: 1rem;" data-toggle="collapse" onclick=\'$(".fa-caret-right, .fa-caret-down", this).toggleClass("fa-caret-right").toggleClass("fa-caret-down");\' > <i class="fa fa-caret-right"></i> ' . $course->fullname . ' </a>' . "\n";
+      print '<div class="collapse" style="padding: 0 1.5rem;" id="item-' . $course->id . '">' . "\n";
 
       $iassigns = $this->get_iassign_items_by_course($course->id);
 
       if ($iassigns) {
         foreach ($iassigns as $iassign) {
-          print '<a href="#item-'.$course->id.'-'.$iassign->id.'" class="list-group-item list-group-item-action" data-toggle="collapse" onclick=\'$(".fa-caret-right, .fa-caret-down", this).toggleClass("fa-caret-right").toggleClass("fa-caret-down");\'><i class="fa fa-caret-right"></i> '.$iassign->name.'</a>';
+          print '<a href="#item-' . $course->id . '-' . $iassign->id . '" class="list-group-item list-group-item-action" data-toggle="collapse" onclick=\'$(".fa-caret-right, .fa-caret-down", this).toggleClass("fa-caret-right").toggleClass("fa-caret-down");\'><i class="fa fa-caret-right"></i> ' . $iassign->name . '</a>' . "\n";
+          print '<div class="collapse" style="padding: 0 1.5rem;" id="item-' . $course->id . '-' . $iassign->id . '">' . "\n";
 
-          print '<div class="collapse" style="padding: 0 1.5rem;" id="item-'.$course->id.'-'.$iassign->id.'">';
-          
           $statements = $this->get_iassign_statement_by_iassign($iassign->id);
 
-          print '<table class="table table-hover">';
+          print '<table class="table table-hover">' . "\n";
 
           if ($statements) {
             foreach ($statements as $statement) {
-              print '<tr><td> <div class="form-check"> <input class="form-check-input" name="statements[]" type="checkbox" value="'.$statement->id.'" id="statement-' . $statement->id . '">';
-              print '<label class="form-check-label w-100" for="statement-' . $statement->id . '">' . $statement->name;  
-              print '</label></div></td></tr>';
+              print '<tr><td> <div class="form-check"> <input class="form-check-input" name="statements[]" type="checkbox" value="' . $statement->id . '" id="statement-' . $statement->id . '">' . "\n";
+              print '<label class="form-check-label w-100" for="statement-' . $statement->id . '">' . $statement->name;
+              print '</label></div></td></tr>' . "\n";
+              }
             }
-          }
           else {
-            print '<tr><td>' . get_string('no_activity', 'iassign') . '</td></tr>';
+            print '<tr><td>' . get_string('no_activity', 'iassign') . '</td></tr>' . "\n";
+            }
+          print '</table></div>' . "\n";
           }
-          
-          print '</table></div>';
         }
-      }
       else {
-        print '<div class="p-2">' . get_string('import_statement_empty', 'iassign').'</div>';
+        print '<div class="p-2">' . get_string('import_statement_empty', 'iassign') . '</div>' . "\n";
+        }
+      print '</div>' . "\n";
       }
-      print '</div>';
-    }
-    print '<div class="text-center"><button type="submit" class="btn btn-primary mt-2">Confirmar</button></div>';
-    print '<div class="text-center text-danger d-none" id="msg-error">'.get_string('import_statement_no_exercise', 'iassign').'</div>';
+    print '<div class="text-center"><button type="submit" class="btn btn-primary mt-2">Confirmar</button></div>' . "\n";
+    print '<div class="text-center text-danger d-none" id="msg-error">' . get_string('import_statement_no_exercise', 'iassign') . '</div>' . "\n";
 
     print "</form>\n";
 
     print $OUTPUT->footer();
-  }
+    } // function post_auto_eval_result()
 
   function get_iassign_items_by_course ($courseid) {
     global $DB;
-
     return $DB->get_records("iassign", array("course" => $courseid));
-  }
+    }
 
   function get_iassign_statement_by_iassign ($iassignid) {
     global $DB;
-
     return $DB->get_records("iassign_statement", array("iassignid" => $iassignid));
-  }
+    }
 
   function get_courses_enroled_as_teacher($userid) {
     $all_enroled = enrol_get_users_courses($userid);
     $return = array();
     foreach ($all_enroled as $enroled) {
       $context_course = context_course::instance($enroled->id);
-
       if (has_capability('mod/iassign:runautoevaluate', $context_course, $userid, false) ) {
         array_push($return, $enroled);
+        }
       }
-    }
     return $return;
-  }
+    }
   //2021/12 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - final 1
 
 
@@ -872,7 +867,7 @@ class iassign {
       <div class="modal-dialog modal-dialog-centered" role="document">
         <div class="modal-content">
           <div class="modal-header">
-            <h5 class="modal-title" id="exampleModalLongTitle">'.get_string('delete', 'iassign').'</h5>
+            <h5 class="modal-title" id="exampleModalLongTitle">' . get_string('delete', 'iassign') . '</h5>
             <button type="button" class="close" data-dismiss="modal" aria-label="Close">
               <span aria-hidden="true">&times;</span>
             </button>
@@ -993,9 +988,9 @@ class iassign {
           $date = new DateTime();
           $date->setTimestamp($individual->timecreated);
           print '<tr>';
-          print '<td>'.$i++.'</td>';
-          print '<td>'.date_format($date, 'd/m/Y H:i:s').'</td>';
-          print '<td>'.$individual->grade.'</td>';
+          print '<td>' . ($i++) . '</td>';
+          print '<td>' . date_format($date, 'd/m/Y H:i:s') . '</td>';
+          print '<td>' . $individual->grade . '</td>';
           print '<td>
             <i onclick="open_submission('.$individual->id.')" class="fa fa-external-link" style="color:#1177d1; cursor: pointer; font-size: 1.2rem; margin-right: .5rem;" aria-hidden="true"></i>
 
@@ -1080,7 +1075,7 @@ class iassign {
       </center>'; // close "
 
     print '   </div>' . "\n";
-    print ' <script>';
+    print ' <script>' . "\n";
     print '// #submissions = ' . count($exercises_list) . "\n"; //Debug
     print '   var submissions = [';
 
@@ -1541,11 +1536,10 @@ var exercises = [ '; // '
 
       foreach ($files as $value) {
         if ($value->get_filename() != ".") {
-
           //2021/12 $last_id = $DB->get_record_sql('SELECT itemid FROM {files} WHERE component="mod_iassign" ORDER BY itemid DESC LIMIT 1')->itemid;
           //2021/12 $newfile = $fs->create_file_from_storedfile(array('contextid' => $id_context, 'component' => 'mod_iassign', 'filearea' => 'exercise', 'itemid' => $iassign_id), $value);
           $fs->delete_area_files(context_module::instance($this->cm->id)->id, 'mod_iassign', 'exercise', $value->get_itemid());
-          $newfile = null; //TODO: desnecessario! Atribuicao 2 linhas abaixo!
+
           $destiny_context = context_module::instance($course_module->id);
           $newfile = $fs->create_file_from_string(array('contextid' => $destiny_context->id, 'component' => 'mod_iassign', 'filearea' => 'exercise', 'itemid' => $iassign_id, 'filepath' => '/', 'filename' => $value->get_filename()), $value->get_content());
 
@@ -1555,7 +1549,6 @@ var exercises = [ '; // '
 
           $DB->update_record("iassign_statement", $updateentry);
           //2021/12 $fs->delete_area_files(context_module::instance($this->cm->id)->id, 'mod_iassign', 'exercise', $value->get_itemid());
-
           break;
           }
         }
@@ -1671,25 +1664,23 @@ var exercises = [ '; // '
     $iassign_ilm = $DB->get_record("iassign_ilm", array("id" => $this->activity->get_activity()->iassign_ilmid)); //leo 2021/12
     $subject .= $iassign_ilm->name . ' ' . get_string('new_comment_mail_at', 'iassign') . ' ' . get_string("iassign", "iassign") . '/Moodle'; //leo 2021/12
 
-    $url_curso;
-    $url_submissao;
+    // $url_curso; $url_submissao;
 
     $text = "<p style='margin-top: 1rem;'>\n";
-    $text .= "<a href=\"" . new moodle_url('/course/view.php', array('id' => $COURSE->id)) . "\">" . $COURSE->shortname . "</a> " . " &#8811;\n";
+    $text .= "<a href=\"" . new moodle_url('/course/view.php', array('id' => $COURSE->id)) . "\">" . $COURSE->shortname . "</a> " . " &#8811; \n";
 
     $modinfo = get_fast_modinfo($COURSE);
 
     for ($i = 0; $i < count($modinfo->sections); $i++) {
       if ($modinfo->get_section_info($i) && $modinfo->get_section_info($i)->id == $this->cm->section) {
         $url_curso = new moodle_url('/course/view.php', array('id' => $COURSE->id));
-        $text .= "<a href=\"" . $url_curso . "#section-" . $modinfo->get_section_info($i)->section . "\">" . get_section_name($COURSE, $modinfo->get_section_info($i)->section) . "</a> &#8811;\n";
+        $text .= "<a href=\"" . $url_curso . "#section-" . $modinfo->get_section_info($i)->section . "\">" . get_section_name($COURSE, $modinfo->get_section_info($i)->section) . "</a> &#8811; \n";
         break;
         }
       }
 
     $iassign = $DB->get_record('iassign', array('id' => $this->activity->get_activity()->iassignid));
-
-    $text .= "<a href=\"" . new moodle_url('/mod/iassign/view.php', array('id' => $this->cm->id)) . "\">" . $iassign->name . "</a> &#8811;\n";
+    $text .= "<a href=\"" . new moodle_url('/mod/iassign/view.php', array('id' => $this->cm->id)) . "\">" . $iassign->name . "</a> &#8811; \n";
 
     $url_submissao = new moodle_url('/mod/iassign/view.php', 
         array(
@@ -1750,7 +1741,7 @@ var exercises = [ '; // '
           $message->contexturlname = $this->activity->get_activity()->name;
           $messageid = message_send($message);
           }
-        } // foreach
+        } // foreach ($teachers as $teacher)
       // and student:
       $student = $DB->get_record('user', array('id' => $student_id));
       $formated_text = str_replace("viewsubmission", "view", $text);
@@ -1785,18 +1776,17 @@ var exercises = [ '; // '
       $message->contexturl = $url_student . '#comments';
       $message->contexturlname = $this->activity->get_activity()->name;
       $messageid = message_send($message);
-
-    } else { // a student has sent the comment:
-      
+      } // if (has_capability('mod/iassign:evaluateiassign', $this->context, $USER->id))
+    else { // a student has sent the comment:
       foreach ($teachers as $teacher) {
         email_to_user(
-          $teacher, 
+          $teacher,
           $USER->firstname . " " . $USER->lastname . " (via " . $SITE->shortname . ")",
-          $subject, 
-          "", 
-          $text, 
-          '', 
-          '', 
+          $subject,
+          "",
+          $text,
+          '',
+          '',
           false,
           $userfrom->email,
           'Não responda a esta mensagem' //TODO: internacionalizar
@@ -1815,9 +1805,9 @@ var exercises = [ '; // '
         $message->contexturl = $url_submissao . '#comments';
         $message->contexturlname = $this->activity->get_activity()->name;
         $messageid = message_send($message);
+        } // foreach ($teachers as $teacher)
       }
-    }
-  } // function send_alert_new_comment($comment, $student_id = -1)
+    } // function send_alert_new_comment($comment, $student_id = -1)
 
 
   /// This method gets the content from the iLM and register it
@@ -2223,7 +2213,7 @@ var exercises = [ '; // '
           exit; // just in case
           }
         }
-      }
+      } // foreach ($iassign_statements as $iassign_statement)
 
     $zip->close(); // close the ZIP file
 
@@ -2511,7 +2501,7 @@ var exercises = [ '; // '
     // Create form and associate its data
     // '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) 
+    // /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)"
@@ -2749,7 +2739,6 @@ var exercises = [ '; // '
     else
       print '<table width=100%><tr>';
     print '<td >';
-    //leo 2021/12 cortes: /home/leo/projetos/iMA/lms/itarefa/novo/alteracoes_2021/locallib_view_legend_icons_antes_corte.php
 
     if (has_capability('mod/iassign:viewreport', $this->context, $USER->id) && $this->action == 'report') {
       if ($this->action != 'print') {
@@ -2856,7 +2845,7 @@ var exercises = [ '; // '
       $this->activity->view_dates();
       $USER->iassignEdit = $this->bottonPost;
       $this->activity->show_info_iassign();
-      
+     
       if ($iassign_submission) {
         //xxx $param_aux = "action=get_answer&iassign_submission_current=" . $iassign_submission->id . "&id=" . $id . "&iassign_current=" . $this->activity->get_activity()->id . "&write_solution=" . $this->write_solution . "&userid_iassign=" . $USER->id;
         $param_aux = "action=get_answer&iassign_submission_current=" . $iassign_submission->id . "&id=" . $id . "&iassign_current=" . $this->activity->get_activity()->id . "&userid_iassign=" . $USER->id;
@@ -2888,24 +2877,36 @@ var exercises = [ '; // '
       $link_up = iassign_icons::insert('up_disable');
       $link_down = iassign_icons::insert('down_disable');
 
-      $has_row_column = isset($USER->matrix_iassign[$row][$column]) ? True : False;
+      if (isset($USER->matrix_iassign[$row][$column])) {
+        $has_row_column = True;
+        $element_matrix_iassign = $USER->matrix_iassign[$row][$column];
+        }
+      else {
+        $has_row_column = False;
+        $element_matrix_iassign = $USER->matrix_iassign[$row][$column];
+        }
+      $msgViewAction = "view.php?action=viewsubmission&id=$id&iassign_submission_current=";
+      $msgUserId_current = "&userid_iassign=" . $this->userid_iassign . "&iassign_current=";
       // next_activity
-      if ($has_row_column && $USER->matrix_iassign[$row][$column]->iassign_next != - 1) {
-        $url_next = "view.php?action=viewsubmission&id=$id&iassign_submission_current=" . $USER->matrix_iassign[$row][$column + 1]->iassign_submission_current . "&userid_iassign=$t$
+      if ($has_row_column && $element_matrix_iassign->iassign_next != - 1) {
+        $url_next = $msgViewAction . $USER->matrix_iassign[$row][$column + 1]->iassign_submission_current . $msgUserId_current . $element_matrix_iassign->iassign_next . "&view_iassign=report&row=" . ($row) . "&column=" . ($column + 1);
         $link_next = "<a href='" . $url_next . "'>" . (iassign_icons::insert('next_activity')) . "</a>";
         }
       // previous_activity
-      if ($has_row_column && $USER->matrix_iassign[$row][$column]->iassign_previous != - 1) {
-        $url_previous = "view.php?action=viewsubmission&id=$id&iassign_submission_current=" . $USER->matrix_iassign[$row][$column - 1]->iassign_submission_current . "&userid_iassig$
+      if ($has_row_column && $element_matrix_iassign->iassign_previous != - 1) {
+        $url_previous = $msgViewAction . $USER->matrix_iassign[$row][$column - 1]->iassign_submission_current . $msgUserId_current . $element_matrix_iassign->iassign_previous . "&view_iassign=report&row=" . ($row) . "&column=" . ($column - 1);
         $link_previous = "<a href='" . $url_previous . "'>" . (iassign_icons::insert('previous_activity')) . "</a>";
         }
       // previous_student
-      if ($has_row_column && $USER->matrix_iassign[$row][$column]->user_next != - 1) {
-        $url_down = "view.php?action=viewsubmission&id=$id&iassign_submission_current=" . $USER->matrix_iassign[$row + 1][$column]->iassign_submission_current . "&userid_iassign=" $
+      if ($has_row_column && $element_matrix_iassign->user_next != - 1) {
+        $url_down = $msgViewAction . $USER->matrix_iassign[$row + 1][$column]->iassign_submission_current . "&userid_iassign=" . $element_matrix_iassign->user_next . "&iassign_current=" . $this->activity->get_activity()->id . "&view_iassign=report&row=" . ($row + 1) . "&column=" . ($column);
         $link_down = "<a href='" . $url_down . "'>" . (iassign_icons::insert('previous_student')) . "</a>";
         }
       // next_student
-      if ($has_row_column && $USER->matrix_iassign[$row][$column]->user_previous != - 1) {
+      if ($has_row_column && $element_matrix_iassign->user_previous != - 1) {
+        $url_up = $msgViewAction . $USER->matrix_iassign[$row - 1][$column]->iassign_submission_current . "&userid_iassign=" . $element_matrix_iassign->user_previous . "&iassign_current=" . $this->activity->get_activity()->id . "&view_iassign=report&row=" . ($row - 1) . "&column=" . ($column);
+        $link_up = "<a href='" . $url_up . "'>" . (iassign_icons::insert('next_student')) . "</a>";
+        }
 
       if ($iassign_submission) {
         $student_answer = $iassign_submission->answer;
@@ -2920,7 +2921,8 @@ var exercises = [ '; // '
       print $OUTPUT->box_start();
       print '<table width=100% border=0 valign="top"><tr>' . "\n";
       print '<td width=80%><font color="blue"><strong>' . get_string('area_available', 'iassign') . '</strong></font><br>' . "\n";
-      print $OUTPUT->user_picture($user_data);
+      if ($user_data) // additional security (if occurs programming errors in $$url_next, $url_previous...)
+        print $OUTPUT->user_picture($user_data);
       print '&nbsp;' . $user_data->firstname . '&nbsp;' . $user_data->lastname;
       print '</td>' . "\n";
       print '<td width=20% align=right>' . "\n";
@@ -3060,14 +3062,20 @@ var exercises = [ '; // '
 
         print $OUTPUT->box_end();
 
-      } else { // if ($iassign_submission && $allow_resubmission) - techer view student answer
+        } // if ($iassign_submission && $allow_resubmission)
+      else { // if ($iassign_submission && $allow_resubmission) - techer view student answer
 
+	// If '$student_answer' is empty, then the student does not submit any solution to the exercice
         // ATTENTION: exception used by iGeom (exercise with "script")
         $loadTeacherActivity = false; // use 'true' whenever 'special_param1 == 1'
         if (substr($ilm_name, 0, 5)=="igeom") {
           if ($iassign_statement_activity_item->special_param1 == 1) // if 1 => use the teacher activity with some complement from the student (in iGeom = GEO + SCR)
             $loadTeacherActivity = true;
           }
+	else
+        if (!$student_answer) { //2022/01 this student does not submit any soluction => load the teacher content
+          $loadTeacherActivity = true;
+          }
 
         print $OUTPUT->box('<p><strong>' . $last_iassign . '</strong></p>' . "\n");
 
@@ -3183,7 +3191,7 @@ var exercises = [ '; // '
 
         print '<table width=100% border=0 valign="top">' . "\n";
         print '<tr><td width=60% valign="top">' . "\n";
-        
+       
         $flag_dependency = true;
 
         if ($iassign_statement_activity_item->type_iassign == 3) {
@@ -3309,7 +3317,7 @@ var exercises = [ '; // '
           print '</tr></table>' . "\n";
 
           // Presents the iLM
-          
+         
           print '<table width=100% border=0 valign="top">' . "\n";
           print '<td width=80% align="left">';
           print '<strong>' . $last_iassign . ' ' . get_string('repeat_msg', 'iassign') . '</strong></td>' . "\n"; // If you want to do this activity from the beginning again, use the \"Redo button\".
@@ -3401,7 +3409,7 @@ var exercises = [ '; // '
       print $output;
       }
 
-    //2020 Quadro com area para enivar e ler comentarios veio para este ponto para permitir todos o terem
+    //2020 Frame with area to send and read comments (in this point to allow everyone read)
     // $only_one_send_button is to avoid to put 2 copies of comments (area to send and see comments between teacher and student)
     if ($only_one_send_button==0 && $iassign_statement_activity_item->type_iassign == 3) { // type_iassign=3 => activity of type "exercise" - submit button and automatic evaluation
       // Put a block with area to sent/answer comments
@@ -3449,7 +3457,7 @@ var exercises = [ '; // '
               }
             }
           };
-          document.formEnvioComment.submission_comment.value = ''; 
+          document.formEnvioComment.submission_comment.value = '';
           request.send(formData);
         }
 
@@ -3491,10 +3499,10 @@ var exercises = [ '; // '
     $iassign_list = $DB->get_records_list('iassign_statement', 'iassignid', array('iassignid' => $this->iassign->id), "position ASC");
     $c = 1;
     foreach ($iassign_list as $iassign) {
-      $fields .= ", activity_id_$c, activity_name_$c, total_submissions_activity_$c, grade_activity_$c"
-          . ", status_activity_$c, ilm_id_activity_$c, ilm_name_activity_$c";
+      $fields .= ", activity_id_" . $c . ", activity_name_" . $c . ", total_submissions_activity_" . $c . ", grade_activity_" . $c . ""
+         . ", status_activity_" . $c . ", ilm_id_activity_" . $c . ", ilm_name_activity_" . $c;
       $c++;
-    }
+      }
 
     // Finding enrolled students:
     $params_temp = array('shortname' => 'student');
@@ -3629,10 +3637,10 @@ var exercises = [ '; // '
       print '<tr><th class="header c1">' . get_string('students', 'iassign') . '</th>' . "\n";
 
       $width = 90/$num_exerc;
-      
+     
       for ($j=1; $j<$num_exerc; $j++) { // all exercises on this block
         $sum_iassign_correct[$j] = 0;
-        
+       
         print '<th class="header c1" scope="col" style="width:'.$width.'%; text-align: center;">' . $num[$j]->id . '</th>' . "\n"; // <th class="header c1" scope="col">
         }
 
@@ -3739,11 +3747,11 @@ var exercises = [ '; // '
 
               if ($this->action != 'print') {
                 if ($tentativas > 0)
-                  print '<td style="text-align: center;"> <a href="' . $url . '" ' . $last_solution_submission . '>' 
+                  print '<td style="text-align: center;"> <a href="' . $url . '" ' . $last_solution_submission . '>'
                   . '<button type="button" class="btn btn-secondary" style="'.$stylebutton.'">'
                   . $feedback
                   .'<span class="badge badge-light" style="font-size: 1rem; margin-left: .5rem;">'
-                  . $tentativas 
+                  . $tentativas
                   . '</span> </button>'
                   . '</a>' . "\n";
                 else
@@ -3754,7 +3762,7 @@ var exercises = [ '; // '
                   . '</a>' . "\n";
 
                 if ($sum_comment > 0 && $sum_verify_message > 0)
-                  print '<a href="' . $url . '"> ' 
+                  print '<a href="' . $url . '"> '
                   . '<button type="button" class="btn btn-secondary" style="'.$stylebutton.'">'
                   . $comment
                   .'<span class="badge badge-light" style="font-size: 1rem; margin-left: .5rem;">'
@@ -3762,7 +3770,7 @@ var exercises = [ '; // '
                   . '</span> </button>'
                   . '</a>';
                 else if ($sum_comment > 0)
-                  print '<a href="' . $url . '"> ' 
+                  print '<a href="' . $url . '"> '
                   . '<button type="button" class="btn btn-secondary" style="'.$stylebutton.'"> '
                   . $comment
                   .'<span class="badge badge-light" style="font-size: 1rem; margin-left: .5rem;">'
@@ -3776,9 +3784,9 @@ var exercises = [ '; // '
                 print $feedback . '&nbsp;(' . $tentativas . ')<br>' . $comment . '&nbsp;(' . $sum_comment . ')&nbsp;' . "\n";
 
               } // if ($student_submissions)
-            else { // if ($student_submissions)  
+            else { // if ($student_submissions) 
               // Student does not have any submission
-  
+ 
               // informations to browse previous activities
               if ($j - 1 < 1 || $j == $i) $iassign_previous = "-1";
               else $iassign_previous = $num[$j - 1]->iassignid;
@@ -3802,7 +3810,7 @@ var exercises = [ '; // '
               if ($this->action == 'print')
                 print $feedback . '&nbsp;(0)<br>' . $comment . '&nbsp;(' . $sum_comment . ')&nbsp;' . "\n";
               else {
-                print '<td  style="text-align: center;"> <a href="' . $url . '">' 
+                print '<td  style="text-align: center;"> <a href="' . $url . '">'
                 . '<button type="button" class="btn btn-secondary" style="'.$stylebutton.'">'
                   . $feedback
                   .'</button>'
@@ -3842,7 +3850,7 @@ var exercises = [ '; // '
           $sum_correct_student[$sum_student] = new stdClass();
           $sum_correct_student[$sum_student]->name = $name;
           $sum_correct_student[$sum_student]->sum = $total_student;
-          } // for ($x = 0; $x < $w; $x ++)
+          } // for ($x = 0; $x < $w; $x++)
 
         for ($i = 1; $i < $j; $i++) {
           if (is_null($sum_iassign_correct[$i]))
@@ -3861,7 +3869,7 @@ var exercises = [ '; // '
     print "</table>\n";
 
     print '<p class="mt-5">' . get_string('ps_experiment', 'iassign') . "</p>\n"; // the number of atemps is...
-    print '<p>' . get_string('ps_comment', 'iassign') .  "</p>\n"; // the total number of messages is...
+    print '<p>' . get_string('ps_comment', 'iassign') . "</p>\n"; // the total number of messages is...
 
     if ($this->action != 'print')
       print $OUTPUT->footer();
@@ -4314,13 +4322,11 @@ var exercises = [ '; // '
 
     if (has_capability('mod/iassign:editiassign', $this->context, $USER->id)) {
       $params = array('userid' => $USER->id, 'course' => $COURSE->id, 'receiver' => '1');
-
       $total_messages = $DB->get_record_sql("SELECT COUNT(*) AS total FROM {iassign_submission_comment} AS c, {iassign_submission} AS s, {iassign_statement} AS st, {iassign} AS ias "
         . " WHERE c.return_status=0 AND c.receiver=:receiver AND c.iassign_submissionid=s.id AND s.iassign_statementid=st.id AND st.iassignid=ias.id AND ias.course=:course", $params);
       }
     else {
       $params = array('userid' => $USER->id, 'course' => $COURSE->id, 'receiver' => '2');
-
       $total_messages = $DB->get_record_sql("SELECT COUNT(*) AS total FROM {iassign_submission_comment} AS c, {iassign_submission} AS s, {iassign_statement} AS st, {iassign} AS ias "
         . " WHERE c.return_status=0 AND c.receiver=:receiver AND c.iassign_submissionid=s.id AND s.userid=:userid AND s.iassign_statementid=st.id AND st.iassignid=ias.id AND ias.course=:course", $params);
       }
@@ -4331,26 +4337,23 @@ var exercises = [ '; // '
     global $DB, $USER, $COURSE;
 
     if (has_capability('mod/iassign:editiassign', $this->context, $USER->id)) {
-
       $params = array('userid' => $USER->id, 'course' => $COURSE->id, 'receiver' => '1');
       $totais = array();
-
       $messages = $DB->get_records_sql("SELECT c.id AS commentid, st.id AS stid, s.userid AS user, ias.id AS iasid, s.id AS subid, st.name AS stname, ias.name AS iasname FROM {iassign_submission_comment} AS c, {iassign_submission} AS s, {iassign_statement} AS st, {iassign} AS ias "
         . " WHERE c.return_status=0 AND c.receiver=:receiver AND c.iassign_submissionid=s.id AND s.iassign_statementid=st.id AND st.iassignid=ias.id AND ias.course=:course", $params);
-      
+
       foreach($messages as $item) {
         if (isset($totais[$item->subid])) {
           $totais[$item->subid]->total++;
-        }
+          }
         else {
           $totais[$item->subid] = new stdclass();
           $item->total = 1;
           $totais[$item->subid] = $item;
+          }
         }
-      }
-
       return $totais;
-    }
+      }
     else {
       $params = array('userid' => $USER->id, 'course' => $COURSE->id, 'receiver' => '2');
       $totais = array();
@@ -4361,16 +4364,16 @@ var exercises = [ '; // '
       foreach($messages as $item) {
         if (isset($totais[$item->subid])) {
           $totais[$item->subid]->total++;
-        }
+          }
         else {
           $totais[$item->subid] = new stdclass();
           $item->total = 1;
           $totais[$item->subid] = $item;
+          }
         }
-      }
       return $totais;
+      }
     }
-  }
 
   function view_notifications_teachers () {
     global $OUTPUT, $USER, $DB;
@@ -4388,8 +4391,8 @@ var exercises = [ '; // '
 
     if ($messages)
       foreach ($messages as $item)
-        if ($item->iasid == $actual_block) 
-          if (!in_array($item->stid, $activities_actual_block)) 
+        if ($item->iasid == $actual_block)
+          if (!in_array($item->stid, $activities_actual_block))
             array_push($activities_actual_block, $item->stid);
 
     if ($activities_actual_block)
@@ -4417,9 +4420,9 @@ var exercises = [ '; // '
               . $user->firstname . ' ' . $user->lastname . ' </td>'.
               '<td class="align-middle"> <a href="'.$submission_url.'#comments"><span class="badge bg-danger" style="color:white; font-size: .9em;"><i class="fa fa-envelope" aria-hidden="true"></i> ' . $label . ' <span class="badge rounded-pill bg-light text-dark" style="font-size: .8em;">'.$item->total.'</span> </span></a></td>'
               .'</tr>';
-            
+           
             $total_include++;
-            
+           
           }
         }
         print '</td></tr></table>';
@@ -4431,10 +4434,10 @@ var exercises = [ '; // '
       print '<h6 class="ml-5">'.get_string('empty_new_messages_block', 'iassign').'</h6>';
       print '<hr class="my-4">';
     }
-    
-    if ($messages && $total_include == count($messages)) { 
+   
+    if ($messages && $total_include == count($messages)) {
       print $OUTPUT->footer();
-      return; 
+      return;
     }
 
     print '<h4 class="mt-4 mb-3 ml-2"><i class="fa fa-comments-o" aria-hidden="true"></i> '.get_string('new_messages_other_blocks', 'iassign').'</h4>';
@@ -4444,15 +4447,15 @@ var exercises = [ '; // '
       foreach ($messages as $item)
         if (!in_array($item->iasid, $iassign_ids) && $item->iasid != $actual_block)
           array_push($iassign_ids, $item->iasid);
-    
+   
     foreach ($iassign_ids as $id_iassign) {
       $printed = false;
 
       $activities_in_block = array();
 
       foreach ($messages as $subitem)
-          if ($subitem->iasid == $id_iassign) 
-            if (!in_array($item->stid, $activities_in_block)) 
+          if ($subitem->iasid == $id_iassign)
+            if (!in_array($item->stid, $activities_in_block))
               array_push($activities_in_block, $item->stid);
 
       foreach ($messages as $item) {
@@ -4509,7 +4512,7 @@ var exercises = [ '; // '
 
   function view_notifications () {
     global $OUTPUT, $USER;
-    
+   
     print $OUTPUT->header();
 
     $this->print_main_menu();
@@ -4544,7 +4547,7 @@ var exercises = [ '; // '
           $student_url = "view.php?id=$id&userid_iassign=$USER->id&action=view&iassign_current=$item->stid#comments";
 
           $link_student = "<a href='$student_url'>" . $item->stname . "</a>";
-          
+         
           $label = $item->total > 1 ? get_string('comment_unread', 'iassign') : get_string('comment_unread_one', 'iassign');
 
           print '<tr><td style="white-space: nowrap; width: 1%; padding-right: 2rem;" class="align-middle">' . $link_student . '</td><td class="align-middle"> <a href="'.$student_url.'"><span class="badge bg-danger" style="color:white; font-size: .9em;"><i class="fa fa-envelope" aria-hidden="true"></i> ' . $label . ' <span class="badge rounded-pill bg-light text-dark" style="font-size: .8em;">'.$item->total.'</span> </span></a></td></tr>';
@@ -4558,7 +4561,7 @@ var exercises = [ '; // '
       print '<h6 class="ml-5">'.get_string('empty_new_messages_block', 'iassign').'</h6>';
       print '<hr class="my-4">';
     }
-    
+   
     if ($messages && $total_include == count($messages)) {
       print $OUTPUT->footer();
       return;
@@ -4566,7 +4569,7 @@ var exercises = [ '; // '
 
 
     print '<h4 class="mt-4 mb-3 ml-2"><i class="fa fa-comments-o" aria-hidden="true"></i> '.get_string('new_messages_other_blocks', 'iassign').'</h4>';
-    
+   
     // 2º. listar as mensagens recebidas nos demais blocos do curso:
     $iassign_ids = array();
     if ($messages)
@@ -4585,11 +4588,11 @@ var exercises = [ '; // '
 
             print '<table class="table table-hover ml-5 w-75" style="border-bottom: 1px solid #dee2e6;">';
           }
-          
+         
           $student_url = "view.php?id=$id&userid_iassign=$USER->id&action=view&iassign_current=$item->stid#comments";
 
           $link_student = "<a href='$student_url'>" . $item->stname . "</a>";
-        
+       
           $label = $item->total > 1 ? get_string('comment_unread', 'iassign') : get_string('comment_unread_one', 'iassign');
 
           print '<tr><td style="white-space: nowrap; width: 1%; padding-right: 2rem;" class="align-middle">' . $link_student . '</td><td class="align-middle"> <a href="'.$student_url.'"><span class="badge bg-danger" style="color:white; font-size: .9em;"><i class="fa fa-envelope" aria-hidden="true"></i> ' . $label . ' <span class="badge rounded-pill bg-light text-dark" style="font-size: .8em;">'.$item->total.'</span> </span></a> </td></tr>';
@@ -4609,7 +4612,7 @@ var exercises = [ '; // '
     $id = $this->cm->id;
 
     $actual_action = optional_param('action', '', PARAM_TEXT);
-    
+   
     $url_help = new moodle_url('/mod/iassign/settings_ilm.php', array('action' => 'list', 'ilm_id' => 1));
     $url_report = new moodle_url('/mod/iassign/view.php', array('action' => 'report', 'id' => $id, 'iassignid' => $this->iassign->id));
     $url_add = new moodle_url('/mod/iassign/view.php', array('id' => $id, 'action' => 'add', 'iassignid' => $this->iassign->id));
@@ -4624,7 +4627,7 @@ var exercises = [ '; // '
     print '<div class="btn-group" role="group" aria-label="">';
 
     print '<a href="' . $url_home . '" class="btn btn-outline-primary ' . ($actual_action == '' ? 'active' : '') . '">' . "\n";
-    print '    <i class="fa fa-home" aria-hidden="true"></i> ' . get_string('activities_page', 'iassign') . "</a>\n";
+    print '   <i class="fa fa-home" aria-hidden="true"></i> ' . get_string('activities_page', 'iassign') . "</a>\n";
 
     if (has_capability('mod/iassign:viewiassignall', $this->context, $USER->id)) {
       // could be "has_capability('mod/iassign:viewiassignall', $this->context, $USER->id)"
@@ -4644,12 +4647,12 @@ var exercises = [ '; // '
             </div>
         '; // "
 
-      print '<a href="'.$url_stats.'" class="btn btn-outline-primary '.($actual_action == 'stats_student' ? 'active' : '').'"><i class="fa fa-list" aria-hidden="true"></i> '.get_string('results', 'iassign').'</a>';
+      print '<a href="' . $url_stats . '" class="btn btn-outline-primary ' . ($actual_action == 'stats_student' ? 'active' : '') . '"><i class="fa fa-list" aria-hidden="true"></i> ' . get_string('results', 'iassign') . '</a>';
 
-      print '<a href="'.$url_auto_evaluate.'" class="btn btn-outline-primary '.($actual_action == 'auto_evaluate' ? 'active' : '').'"><i class="fa fa-check-square-o" aria-hidden="true"></i> '.get_string('auto_evaluate_name_config', 'iassign').'</a>';
-      
+      print '<a href="' . $url_auto_evaluate . '" class="btn btn-outline-primary ' . ($actual_action == 'auto_evaluate' ? 'active' : '') . '"><i class="fa fa-check-square-o" aria-hidden="true"></i> ' . get_string('auto_evaluate_name_config', 'iassign') . '</a>';
+     
       } // if (has_capability('mod/iassign:viewiassignall', $this->context, $USER->id))
-    
+   
     $notifications = $this->get_total_notifications();
 
     print '<a href="' . $url_notifications . '" class="btn btn-outline-primary ' . ($actual_action == 'notifications' ? 'active' : '') . '">' . "\n"; // '
@@ -4657,7 +4660,7 @@ var exercises = [ '; // '
 
     if ($notifications > 0)
       print ' <span class="badge bg-danger rounded-pill" style="color: white; font-size: .9rem;">'.$notifications.'</span>';
-    
+   
     print '</a></div><div class="btn-group">';
 
     if (has_capability('mod/iassign:editiassign', $this->context, $USER->id)) {
@@ -4667,7 +4670,7 @@ var exercises = [ '; // '
       <button type="button" class="btn btn-success dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
       </button>
       <div class="dropdown-menu">
-        <a class="dropdown-item" href="'.$url_import_activity.'">'.get_string('import_activity', 'iassign').'</a>
+        <a class="dropdown-item" href="' . $url_import_activity . '">' . get_string('import_activity', 'iassign') . '</a>
       </div>'; // "
       } // if (has_capability('mod/iassign:editiassign', $this->context, $USER->id))
 
@@ -5083,9 +5086,9 @@ var exercises = [ '; // '
             if ($iassign_array[$j]->type_iassign == 3) {
               if ($iassign_array[$j]->show_answer == 1) {
                 if ($iassign_submission->status == 3)
-                  $icon_status = '<i class="fa fa-check" style="color: green; font-size: 1.2rem;" aria-hidden="true" title="' . get_string('correct', 'iassign').'"></i>' . "\n";
+                  $icon_status = '<i class="fa fa-check" style="color: green; font-size: 1.2rem;" aria-hidden="true" title="' . get_string('correct', 'iassign') . '"></i>' . "\n";
                 elseif ($iassign_submission->status == 2)
-                  $icon_status = '<i class="fa fa-times" style="color: red; font-size: 1.2rem;" aria-hidden="true" title="' . get_string('incorrect', 'iassign').'"></i>' . "\n";
+                  $icon_status = '<i class="fa fa-times" style="color: red; font-size: 1.2rem;" aria-hidden="true" title="' . get_string('incorrect', 'iassign') . '"></i>' . "\n";
                 elseif ($iassign_submission->status == 1)
                   $icon_status = '<i class="fa fa-question" style="color: #77229; font-size: 1.2rem;" aria-hidden="true" title="' . get_string('post', 'iassign') . '"></i>' . "\n";
                   //2021/12 $icon_status = iassign_icons::insert('post');
@@ -5093,12 +5096,14 @@ var exercises = [ '; // '
                   $icon_status = '<i class="fa fa-question" style="color: red; font-size: 1.2rem;" aria-hidden="true" title="' . get_string('not_post', 'iassign') . '"></i>' . "\n";
                 } // if ($iassign_array[$j]->show_answer==1)
               else {
-                if ($iassign_submission->status == 0)
+                if ($iassign_submission->status == 0) {
                   //TODO: $icon_status = '<i class="fa fa-question" style="color: #77229c; font-size: 1.2rem;" aria-hidden="true" title="' . get_string('not_post', 'iassign') . '"></i>' . "\n";
                   $icon_status = iassign_icons::insert('not_post');
-                else
+                  }
+                else {
                   //TODO: $icon_status = '<i class="fa fa-question" style="color: #77229c; font-size: 1.2rem;" aria-hidden="true" title="' . get_string('post', 'iassign') . '"></i>' . "\n";
                   $icon_status = iassign_icons::insert('post');
+                  }
                 }
               } // if ($iassign_array[$j]->type_iassign == 3)
             } // if ($iassign_submission)
@@ -5106,14 +5111,16 @@ var exercises = [ '; // '
             $icon_status = '<i class="fa fa-question" style="color: #77229c; font-size: 1.2rem;" aria-hidden="true" title="' . get_string('not_post', 'iassign') . '"></i>' . "\n";
             //2021/12 $icon_status = iassign_icons::insert('not_post');
             } // if ($iassign_array[$j]->type_iassign == 3)
-          print '<tr><td style="white-space: nowrap; width: 1%; padding-right: 0; text-align: center;">'. $icon_status .'</td><td style="white-space: nowrap; width: 1%; padding-right: 2rem; padding-left: 0.2rem;">'
-            . $links . '</td><td>'. $icon_comment.'</td></tr>' . "\n";
+
+          print '<tr><td style="white-space: nowrap; width: 1%; padding-right: 0; text-align: center;">' . $icon_status . '</td><td style="white-space: nowrap; width: 1%; padding-right: 2rem; padding-left: 0.2rem;">'
+            . $links . '</td><td>' . $icon_comment . '</td></tr>' . "\n";
           //print '<p>' . $icon_status . '&nbsp;' . $links . '&nbsp;' . $icon_comment . '</p>' . "\n";
           } // if ($iassign_array[$j]->visible == 1)
 
         } // for ($j=0; $j<$total_of_activities; $j++)
 
       print "</table>\n";
+
       } // elseif (has_capability('mod/iassign:submitiassign', $this->context, $USER->id))
     else if (isguestuser()) {
       print($OUTPUT->notification(get_string('no_permission_iassign', 'iassign'), 'notifyproblem'));
@@ -5297,7 +5304,7 @@ var exercises = [ '; // '
         $ia_assign_submissions_comment_id = $DB->insert_record('iassign_submission_comment', $newentry);
         //T foreach ($tousers as $touser) { //TODO Para registrar mensagem na area do Moodle - tem que ativar '$tousers[] = $DB->get_record(...);' acima
 
-        // Trigger module viewed event.
+        // Trigger module viewed event
         $event = \mod_iassign\event\submission_comment_created::create(array(
           'objectid' => $this->iassign->id,
           'context' => $this->context
@@ -5389,6 +5396,7 @@ class activity {
       return null;
     }
 
+
   /// Delete interactive activities
   function delete ($return) {
     global $USER, $CFG, $DB, $OUTPUT;
@@ -5411,15 +5419,15 @@ class activity {
         } // if (!has_capability('mod/iassign:deleteiassignnotnull', $this->context, $USER->id))
       }   // if ($iassign_submission_currents)
     else
-      $output .= "<p>" . get_string('not_submissions_activity', 'iassign') . "</p>";
+      $output .= "<p>" . get_string('not_submissions_activity', 'iassign') . "</p>\n";
     $output .= '<table width=50% border=0>';
     $output .= '<tr valign="top"><td>';
-    $output .= "<p>" . get_string('what_do', 'iassign') . "</p>";
+    $output .= "<p>" . get_string('what_do', 'iassign') . "</p>\n";
     $output .= '</td><td>';
 
     $bottonDelete_yes = get_string('delete_iassign', 'iassign');
     $deleteiassignyes = $CFG->wwwroot . "/mod/iassign/view.php?id=" . $USER->cm . "&action=deleteyes&iassign_current=" . $this->activity->id;
-    $output .= "<form name='formDelete' id='formDelete' method='post' action='$deleteiassignyes' enctype='multipart/form-data'>";
+    $output .= "<form name='formDelete' id='formDelete' method='post' action='$deleteiassignyes' enctype='multipart/form-data'>\n";
     $output .= " <input type=submit value='$bottonDelete_yes'/>\n";
     $output .= "</form>\n";
     $output .= '</td><td>';
@@ -5455,7 +5463,7 @@ class activity {
       //$delete_iassign_statement_config = $DB->delete_records('iassign_statement_config', array('iassign_statementid' => $this->activity->id)); //MOOC 2016
 
       // Remove all files associated to this activity:
-      $fs = get_file_storage(); 
+      $fs = get_file_storage();
       $fs->delete_area_files($iassign->context->id, 'mod_iassign', 'exercise', $this->activity->id);
 
       $this->delete_calendar($this->activity->id);
@@ -5474,15 +5482,13 @@ class activity {
     } // function deleteyes($return, $iassign)
 
 
-  // Change fields 'iassign_statement.position' between 2 activities
-  // @calledby : class this->move_iassign($move_action, $target, $return)
-  // @calledby : class iassign show_iassign($title, $iassign_array, $total_of_activities) - this is used only to fix 'position' erros (e.g. {1,2,2,3} to {1,2,3,4})
+  /// Change fields 'iassign_statement.position' between 2 activities
+  //  @calledby : class this->move_iassign($move_action, $target, $return)
+  //  @calledby : class iassign show_iassign($title, $iassign_array, $total_of_activities) - this is used only to fix 'position' erros (e.g. {1,2,2,3} to {1,2,3,4})
   static function move_change_activity_position ($DB, $idFrom, $idTo, $posFrom, $posTo) { //1
     $newentry = new stdClass(); // define a new object (activity) to receive only 2 fields: 'id' and 'position'
     $newentry->id = $idFrom; // ID of the "source activity" //1 $this->activity->id -> $idFrom
     $newentry->position = $posFrom; // final position to source //1 $final_position_source -> $posFrom
-    //D echo "mover: id=" . $idFrom . ": de " . $this->activity->position . " -> " . $final_position_source . "<br/>";
-    //D echo "mover: id=" . $iassign_target->id . ": de " . $iassign_target->position . " -> " . $final_position_target . "<br/>"; exit;
     if (!$DB->update_record('iassign_statement', $newentry)) { // modify 'position' of the activity with 'id'=$target
       print_error('error_update_move_iassign', 'iassign');
       }
@@ -5500,7 +5506,6 @@ class activity {
   //  @param $target = if 'down' => is 'iassign_statement.id' of the activity bellow the current one; if 'up' => is activity above the current one
   function move_iassign ($move_action, $target, $return) {
     global $DB, $OUTPUT;
-    //D echo "mover: this->id=" . $this->activity->id . ", target = $target<br/>";
     $initial_position_source = $this->activity->position; // the position of the "source activity" (that one to be moved)
     $iassign_target = $DB->get_record("iassign_statement", array("id" => $target)); // "target activity" = the activity in the position the receive "source activity"
     if ($move_action=="firstdown") {
@@ -5857,7 +5862,7 @@ class activity {
     $output .= $this->toggle_columns_script();
 
     $output .= '<p><strong>' . get_string('proposition', 'iassign') . ':</strong></p>&nbsp;<div class="proposition">' . $this->activity->proposition . '</div>' . "\n";
-    
+   
     print $OUTPUT->box($output);
     } // function show_info_iassign()
 
@@ -5866,20 +5871,17 @@ class activity {
     $output = "";
     $output .= '<script>
     function toLeft () {
-
       document.getElementsByClassName("proposition")[0].style.cssFloat = "left";
       document.getElementsByClassName("proposition")[0].style.width = "40%";
       document.getElementById("fullscreen").style.marginTop = "-3rem";
       document.getElementById("columnsbutton").style.color = "#1da075";
-    }
+      }
     function toDefault () {
-
       document.getElementsByClassName("proposition")[0].style.cssFloat = "none";
       document.getElementsByClassName("proposition")[0].style.width = "100%";
       document.getElementById("fullscreen").style.marginTop = "0";
       document.getElementById("columnsbutton").style.color = "#343a40";
       }
-
     var activate = false;
     function toggleColumns () {
       if (activate) {
@@ -5892,13 +5894,14 @@ class activity {
       }
     </script>'; // '
 
-    $output .= '<span tabindex="0" data-toggle="tooltip" title="'.get_string('enable_disable_columns', 'iassign').'" style="float: right"> <i id="columnsbutton" onclick="toggleColumns()" class="fa fa-columns" style="font-size: 1.5rem;" aria-hidden="true" role="button"></i></span>';
+    $output .= '<span tabindex="0" data-toggle="tooltip" title="' . get_string('enable_disable_columns', 'iassign')
+      . '" style="float: right"> <i id="columnsbutton" onclick="toggleColumns()" class="fa fa-columns" style="font-size: 1.5rem;" aria-hidden="true" role="button"></i></span>' . "\n";
 
     return $output;
-    }
+    } // function write_comment_submission()
 
 
-  static function get_latest_array_item ($DB, $iassignid, $position) { //TODO: may be search for the gratest grade?
+  static function get_latest_array_item ($DB, $iassignid, $position) { //TODO: may be search for the greatest grade?
     $iassign_statement = $DB->get_records('iassign_statement', array('iassignid' => $iassignid, 'position' => $position));
     $item = NULL;
     foreach ($iassign_statement as $item) ; // get the last item!
@@ -5961,6 +5964,7 @@ class activity {
       }
     else {
       // Get all previous/next solution sent by this student (present link to his last answer)
+
       // $iassign_previous = $DB->get_record('iassign_statement', array('iassignid' => $this->activity->iassignid, 'position' => $this->activity->position - 1));
       $iassign_previous = activity::get_latest_array_item($DB, $this->activity->iassignid, $this->activity->position-1); // previous activity of this student inside this block
 
@@ -6953,7 +6957,7 @@ class ilm_settings {
     global $DB;
     $iassign_ilm = $DB->get_record('iassign_ilm', array('id' => $ilmid));
 
-    // Get the iLM type and calls its correpondent handler ('Java' or 'HTML5')
+    // Get the iLM type and calls its correspondent handler ('Java' or 'HTML5')
     $typec = strtolower($iassign_ilm->type);
     require_once 'ilm_handlers/' . $typec . '.php';
     $retorno = $typec::view_ilm($ilmid, $from);
@@ -7288,7 +7292,7 @@ class ilm_manager {
    <tr><td>" . get_string('label_file_iassign', 'iassign') . " <input type='text' name='filename' size=50/>
 
      <input type=button value='" . get_string('label_write_iassign', 'iassign') . "' title='' onclick='" . $str_submitbutton_name . ";'/></td>
- 
+
    </tr>
    </table>\n";
 
@@ -8162,14 +8166,14 @@ class ilm_manager {
     global $DB, $USER;
     // $iassign_statement_activity_list = $DB->get_records("iassign_statement", array("file" => $fileid));
     //TODO Criar coluna 'authorid'
-    $str_query = "SELECT * FROM {iassign_statement} " .
-                 " WHERE file = " . $fileid . " ORDER BY author_name, timecreated DESC";
+    $str_query = "SELECT * FROM {iassign_statement} WHERE file = " . $fileid . " ORDER BY author_name, timecreated DESC";
     $array_iassign_ilm = $DB->get_records_sql($str_query);
     return $array_iassign_ilm;
     }
 
 
   //NN
+//NN
   // Build string with JavaScript code with function to edit/remove/double iLM files
   // @calledby view_files_ilm($iassign_ilm_class, $extension, $start = 0)
   function get_string_JavaScript_functions ($dirid, $ilmid, $files_array, $dirs_array) {