浏览代码

fix: remove view call at iassign constructor

Bernardo Martins 1 年之前
父节点
当前提交
4eb91fec9c
共有 2 个文件被更改,包括 49 次插入51 次删除
  1. 44 46
      locallib.php
  2. 5 5
      view.php

+ 44 - 46
locallib.php

@@ -214,9 +214,7 @@ class iassign {
     $this->bottonPost = 0;
     $this->view_iassign = optional_param('action', false, PARAM_BOOL);
     $this->activity = new activity(optional_param('iassign_current', NULL, PARAM_TEXT)); // this is the activity inside iAssign block
-
-    $this->view();
-    } // function __construct($iassign, $cm, $course)
+  } // function __construct($iassign, $cm, $course)
 
 
   /// Show iAssign by using the security filter (temporary data on '*_iassign_security')
@@ -442,7 +440,7 @@ class iassign {
     $json_obj->submissions[] = $csvfields;
 
     $exercise_dir = [];
-    $exercises_list = []; 
+    $exercises_list = [];
     foreach ($list as $item) {
 
       if (!in_array($item->iassign_statementid, $exercise_dir)) {
@@ -476,9 +474,9 @@ class iassign {
       mkdir($iassignfilespath, 0777, true);
       }
 
-    $diretorio = $CFG->dataroot . DIRECTORY_SEPARATOR . 'temp' 
+    $diretorio = $CFG->dataroot . DIRECTORY_SEPARATOR . 'temp'
      . DIRECTORY_SEPARATOR . 'iassign_files' . DIRECTORY_SEPARATOR;
-    
+
     if (!file_exists($diretorio)) {
       echo 'Não foi possível criar o diretório para preparar o arquivo com as submissões. Possivelmente o caminho está bloqueado para escrita.';
       exit;
@@ -507,7 +505,7 @@ class iassign {
         }
 
       foreach ($students_list as $student) {
-        $individual_dir = 
+        $individual_dir =
           $dir_ex . DIRECTORY_SEPARATOR .
           iassign_utils::format_filename($student->firstname . ' ' . $student->lastname);
 
@@ -644,7 +642,7 @@ class iassign {
 
     $atual_statement = $DB->get_record("iassign_statement", array("id" => $atual_submission->iassign_statementid));
 
-    $all_submissions = $DB->get_records('iassign_allsubmissions', 
+    $all_submissions = $DB->get_records('iassign_allsubmissions',
         array('iassign_statementid' => $atual_submission->iassign_statementid, 'userid' => $atual_submission->userid));
 
     $user = $DB->get_record('user', array('id' => $atual_submission->userid));
@@ -720,7 +718,7 @@ class iassign {
       $author = $DB->get_record("user", array('id' => $USER->id));
       $activity_source->author_modified_name = $author->firstname . ' ' . $author->lastname;
       $activity_source->author_modified = $activity_source->author_modified_name;
-      
+
       if ($id_ = $DB->insert_record("iassign_statement", $activity_source)) {
         $fs = get_file_storage();
         // Duplicate activity file
@@ -728,7 +726,7 @@ class iassign {
 
         print 'Arquivos a serem copiados: ';
         print_r($files_ids);
-        
+
         foreach ($files_ids as $fileid) {
           $source_file = $fs->get_file_by_id($fileid->id);
 
@@ -765,7 +763,7 @@ class iassign {
       var checkboxes = document.getElementsByName("statements[]");
       for (var i = 0; i < checkboxes.length; i++)
         if (checkboxes[i].checked) return true;
-        
+
       document.getElementById("msg-error").classList.remove("d-none");
       return false;
       }
@@ -941,8 +939,8 @@ class iassign {
       $iassign_ilm = $DB->get_record("iassign_ilm", array("id" => $exercise->iassign_ilmid));
 
       print '
-        <a href="#item-'.$exercise->id.'" class="list-group-item list-group-item-action h4" 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> ' 
-          . $exercise->name 
+        <a href="#item-'.$exercise->id.'" class="list-group-item list-group-item-action h4" 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> '
+          . $exercise->name
           . ' - ' . $iassign_ilm->name
           . '<i class="fa fa-times" onclick="event.stopPropagation(); delete_submission(\'exercise\', '
           . $exercise->id .', this)" style="color:#C62828; cursor: pointer; font-size: 1.5rem; float: right; margin-left: .5rem;" aria-hidden="true"></i>'
@@ -967,7 +965,7 @@ class iassign {
           }
 
         print '<a href="#item-'.$exercise->id.'-'.$student->userid.'" 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> ' . $student->firstname . ' ' . $student->lastname 
+              <i class="fa fa-caret-right"></i> ' . $student->firstname . ' ' . $student->lastname
               . '<i class="fa fa-times" onclick="event.stopPropagation(); delete_submission(\'student\', '
               . $student->userid .', this, '.$exercise->id.')" style="color:#C62828; cursor: pointer; font-size: 1.5rem; float: right; margin-left: .5rem;" aria-hidden="true"></i>'
               . '<i onclick="event.stopPropagation(); download_submission(\'student\', '.$student->userid.', '.$exercise->id.')" class="fa fa-download" style="float: right; color: #1fa67a; font-size: 1.3rem; cursor: pointer; margin-left: 1rem; margin-top: .1rem;" aria-hidden="true"></i> '
@@ -994,7 +992,7 @@ class iassign {
           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>
 
-            <i onclick="download_submission(\'individual\', '.$individual->id.')" class="fa fa-download" style="color: #1fa67a; font-size: 1.2rem; cursor: pointer; margin-right: .5rem;" aria-hidden="true"></i> 
+            <i onclick="download_submission(\'individual\', '.$individual->id.')" class="fa fa-download" style="color: #1fa67a; font-size: 1.2rem; cursor: pointer; margin-right: .5rem;" aria-hidden="true"></i>
 
             <i class="fa fa-times" onclick="delete_submission(\'individual\', '.$individual->id.', this)" style="color:#C62828; cursor: pointer; font-size: 1.5rem; " aria-hidden="true"></i></td>';
           print " </tr>\n";
@@ -1683,10 +1681,10 @@ var exercises = [ '; // '
     $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";
 
-    $url_submissao = new moodle_url('/mod/iassign/view.php', 
+    $url_submissao = new moodle_url('/mod/iassign/view.php',
         array(
-          'id' => $this->cm->id, 
-          'action' => 'viewsubmission', 
+          'id' => $this->cm->id,
+          'action' => 'viewsubmission',
           'iassign_current' => $this->activity->get_activity()->id,
           'userid_iassign' => $USER->id));
 
@@ -1716,13 +1714,13 @@ var exercises = [ '; // '
       foreach ($teachers as $teacher) {
         if ($teacher->id != $USER->id) {
           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
@@ -2849,7 +2847,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;
@@ -3195,7 +3193,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) {
@@ -3321,7 +3319,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\".
@@ -3641,10 +3639,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">
         }
 
@@ -3788,9 +3786,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;
@@ -4424,9 +4422,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>';
@@ -4438,7 +4436,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;
@@ -4451,7 +4449,7 @@ 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;
 
@@ -4516,7 +4514,7 @@ var exercises = [ '; // '
 
   function view_notifications () {
     global $OUTPUT, $USER;
-   
+
     print $OUTPUT->header();
 
     $this->print_main_menu();
@@ -4551,7 +4549,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>';
@@ -4565,7 +4563,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;
@@ -4573,7 +4571,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)
@@ -4592,11 +4590,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>';
@@ -4616,7 +4614,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));
@@ -4654,9 +4652,9 @@ var exercises = [ '; // '
       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>';
-     
+
       } // 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"; // '
@@ -4664,7 +4662,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)) {
@@ -5871,7 +5869,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()
 

+ 5 - 5
view.php

@@ -2,15 +2,15 @@
 
 /**
  * This php script contains all the stuff to display iAssign.
- * 
+ *
  * @author Patricia Alves Rodrigues
  * @author Leo^nidas O. Branda~o
  * @version v 1.0 2012/10/16
  * @package mod_iassign
  * @since 2010/09/27
  * @copyright iMatica (<a href="http://www.matematica.br">iMath</a>) - Computer Science Dep. of IME-USP (Brazil)
- * 
- * <b>License</b> 
+ *
+ * <b>License</b>
  *  - http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
@@ -35,7 +35,7 @@ function get_all_iassign_files () {
   $all_files = $DB->get_records_sql($str_query);
 
   $total = count($all_files);
-  $msg = "#linhas = " . $total . "\n";  
+  $msg = "#linhas = " . $total . "\n";
   foreach ($all_files as $linha) {
     foreach ($linha as $key => $value) {
       if ($key == "timecreated") {
@@ -122,4 +122,4 @@ $write_solution = 1;
 $iassigninstance = new iassign($iassign, $cm, $course);
 
  // ./mod/iassign/locallib.php : in class iassign, actually who display the iAssign whose id is '$id'! (this function ignores parameters)
-$iassigninstance->view(); //     will call $this->action(), that calls view_iassign_current()
+$iassigninstance->view(); // Will call $this->action(), that calls view_iassign_current()