Igor 3 лет назад
Родитель
Сommit
fbbc10e832
6 измененных файлов с 223 добавлено и 13 удалено
  1. 5 0
      lang/en/iassign.php
  2. 5 0
      lang/es/iassign.php
  3. 5 0
      lang/fr/iassign.php
  4. 5 0
      lang/pt_br/iassign.php
  5. 202 12
      locallib.php
  6. 1 1
      version.php

+ 5 - 0
lang/en/iassign.php

@@ -424,6 +424,11 @@ $string['N_legend']                       = '(does not agree with what the teach
 $string['name_ilm']                       = 'Name';
 $string['new_category']                   = 'New category';
 $string['new_comment']                    = 'New messages';
+$string['new_comment_mail_answer']        = 'Answer';
+$string['new_comment_mail_course']        = 'Course';
+$string['new_comment_mail_open_exercise'] = 'Open exercise	';
+$string['new_comment_mail_sent_by']       = 'Sent by';
+$string['new_comment_mail_subject']       = 'New received message';
 $string['new_dir']                        = 'New directory';
 $string['new_file_jar']                   = 'New file JAR';
 $string['new_ilm']                        = 'Create a new interactive activity';

+ 5 - 0
lang/es/iassign.php

@@ -421,6 +421,11 @@ $string['N_legend']                       = '(no esta en acuerdo en relación a
 $string['name_ilm']                       = 'Nombre';
 $string['new_category']                   = 'Nueva categoria';
 $string['new_comment']                    = 'Recados nuevos';
+$string['new_comment_mail_answer']        = 'Answer';
+$string['new_comment_mail_course']        = 'Course';
+$string['new_comment_mail_open_exercise'] = 'Open exercise';
+$string['new_comment_mail_sent_by']       = 'Sent by';
+$string['new_comment_mail_subject']       = 'New received message';
 $string['new_dir']                        = 'Nuevo directorio';
 $string['new_file_jar']                   = 'Nuevo Fichero JAR';
 $string['new_ilm']                        = 'Crea una nueva actividad interactiva';

+ 5 - 0
lang/fr/iassign.php

@@ -420,6 +420,11 @@ $string['N_legend']                       = '(n\'est pas d\'accord avec ce que l
 $string['name_ilm']                       = 'Nom';
 $string['new_category']                   = 'Nouvelle catégorie';
 $string['new_comment']                    = 'Nouveaux messages';
+$string['new_comment_mail_answer']        = 'Answer';
+$string['new_comment_mail_course']        = 'Course';
+$string['new_comment_mail_open_exercise'] = 'Open exercise';
+$string['new_comment_mail_sent_by']       = 'Sent by';
+$string['new_comment_mail_subject']       = 'New received message';
 $string['new_dir']                        = 'Nouveau dossier';
 $string['new_file_jar']                   = 'Nouveau fichier JAR';
 $string['new_ilm']                        = 'Créer une nouvelle activité interactive';

+ 5 - 0
lang/pt_br/iassign.php

@@ -421,6 +421,11 @@ $string['N_legend']                       = '(não está de acordo com o que o p
 $string['name_ilm']                       = 'Nome';
 $string['new_category']                   = 'Nova categoria';
 $string['new_comment']                    = 'Nova mensagem';
+$string['new_comment_mail_answer']        = 'Responder';
+$string['new_comment_mail_course']        = 'Curso';
+$string['new_comment_mail_open_exercise'] = 'Ver exercício';
+$string['new_comment_mail_sent_by']       = 'Enviado por';
+$string['new_comment_mail_subject']       = 'Nova mensagem recebida';
 $string['new_dir']                        = 'Nova Pasta';
 $string['new_file_jar']                   = 'Novo arquivo jar';
 $string['new_ilm']                        = 'Criar nova atividade interativa online';

+ 202 - 12
locallib.php

@@ -628,9 +628,13 @@ class iassign {
 
     $atual_submission = $DB->get_record('iassign_allsubmissions', array('id' => $submissionid));
 
+    $atual_statement = $DB->get_record("iassign_statement", array("id" => $atual_submission->iassign_statementid));
+
     $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));
+
     $previous = null;
     $next = null;
     $i = 0;
@@ -648,8 +652,13 @@ 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 style="padding-top: 2rem;">';
+    print '</table>';
 
     if ($previous) {
       $url_prev = "" . $CFG->wwwroot . "/mod/iassign/view.php?action=open_individual_submission&" . $param_aux . "&item=" . $previous->id;
@@ -1448,7 +1457,174 @@ var exercises = [ '; // '
         $id_submission = $iassign_submission->id;
       }
     }
+    
+    $content = $this->search_comment_submission($id_submission);
+    ob_end_clean();
+    header("Connection: close\r\n");
+    header("Content-Encoding: none\r\n");
+    header('Content-Type: text/html');
+    ob_start();
     echo $this->search_comment_submission($id_submission);
+
+    $size = ob_get_length();
+    header("Content-Length: $size");
+    ob_end_flush();
+    flush();
+    ob_end_clean();
+
+    // Send email to users:
+    $iassign_submission = 
+      $DB->get_record("iassign_submission", 
+        array(
+              "id" => $id_submission
+            )
+      );
+    
+    $this->send_alert_new_comment($submission_comment, $iassign_submission->userid);
+  }
+
+  /// This method alerts envolved to new comment sent
+  function send_alert_new_comment ($comment, $student_id = -1) {
+    global $USER, $DB, $COURSE, $SITE;
+
+    $subject = $COURSE->shortname . ": " . get_string('new_comment_mail_subject', 'iassign');
+
+    $url_curso;
+    $url_submissao;
+    
+    $text = "<p style='margin-top: 1rem;'>";
+
+    $text .=  "<a href=\""
+             . new moodle_url('/course/view.php', array('id' => $COURSE->id))
+             . "\">" . $COURSE->shortname . "</a> "
+             . " &#8811; ";
+
+    $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; ";
+        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>";
+
+    $text .= " &#8811; ";
+
+    $url_submissao = new moodle_url('/mod/iassign/view.php', 
+        array(
+          'id' => $this->cm->id, 
+          'action' => 'viewsubmission', 
+          'iassign_current' => $this->activity->get_activity()->id,
+          'userid_iassign' => $USER->id));
+
+    $text .= "<a href=\"" 
+              . $url_submissao
+              . "\">"
+              . $this->activity->get_activity()->name
+              . "</a>";
+    
+    $text .= "</p>";
+
+    $text .= "<div style='margin-left: .5rem;'>";
+    
+    $text .= get_string('new_comment_mail_course', 'iassign') . ": <a href=\"" . $url_curso . "\">" . $COURSE->fullname . "</a>";
+
+    $text .= "</div><div style='margin-top: .3rem; margin-left: .5rem;'>";
+
+    $text .= get_string('exercise', 'iassign') . ": <a href=\"" . $url_submissao . "\">" . $this->activity->get_activity()->name . "</a>";
+
+    $text .= "</div><div style='margin-top: .3rem; margin-left: .5rem;'>";
+
+    $text .= get_string('new_comment_mail_sent_by', 'iassign') . ': ' 
+            . "<a href=\"" . new moodle_url('/user/view.php', array('id' => $USER->id, 'course' => $COURSE->id)) . "\">"
+            . $USER->firstname . " " . $USER->lastname
+            . "</a>";
+    
+    $text .= " - " . userdate(time());
+
+    $text .= "</div><div style='margin: 2rem;'>";
+
+    $text .= $comment;
+
+    $text .= "</div><div>";
+
+    $text .= "<a href=\"" . $url_submissao . "#comments\">" . get_string('new_comment_mail_open_exercise', 'iassign') .  "</a> | ";
+
+    $text .= "<a href=\"" . $url_submissao . "#comments\">" . get_string('new_comment_mail_answer', 'iassign') . "</a>";
+
+    $text .= "</div>";
+
+    // Who has to receive?
+    $teachers = get_users_by_capability($this->context, 'mod/iassign:evaluateiassign');
+    $userfrom = \core_user::get_noreply_user();
+
+    if (has_capability('mod/iassign:evaluateiassign', $this->context, $USER->id)) { // a teacher has sent the comment:
+
+      // other teachers receive also: (excepts the sender)
+      foreach ($teachers as $teacher) {
+        if ($teacher->id != $USER->id)
+          email_to_user(
+            $teacher, 
+            $USER->firstname . " " . $USER->lastname . " (via " . $SITE->shortname . ")",
+            $subject, 
+            "", 
+            $text, 
+            '', 
+            '', 
+            false,
+            $userfrom->email,
+            'Não responda a esta mensagem'
+          );
+      }
+      // and student:
+      $student = $DB->get_record('user', array('id' => $student_id));
+      email_to_user(
+        $student, 
+        $USER->firstname . " " . $USER->lastname . " (via " . $SITE->shortname . ")",
+        $subject, 
+        "", 
+        str_replace("viewsubmission", "view", $text), 
+        '', 
+        '', 
+        false,
+        $userfrom->email,
+        'Não responda a esta mensagem'
+      );
+      
+
+    } else { // a student has sent the comment:
+      
+      foreach ($teachers as $teacher) {
+        email_to_user(
+          $teacher, 
+          $USER->firstname . " " . $USER->lastname . " (via " . $SITE->shortname . ")",
+          $subject, 
+          "", 
+          $text, 
+          '', 
+          '', 
+          false,
+          $userfrom->email,
+          'Não responda a esta mensagem'
+        );
+      }
+    }
   }
 
   /// This method gets the content from the iLM and register it
@@ -2593,8 +2769,8 @@ $param->special_param1 = 0; // 'special_param1 == 1' => script of iGeom
 
       print '<table width=100% border=0 valign="top"><tr>' . "\n";
       print '<td width=60% valign="top">' . "\n";
-      print '<strong>' . get_string('proposition', 'iassign') . '</strong>' . "\n";
-      print '<p>' . $iassign_statement_activity_item->proposition . '</p>' . "\n";
+      print '<p><strong>' . get_string('proposition', 'iassign') . ':</strong></p>' . "\n";
+      print '<div class="proposition">' . $iassign_statement_activity_item->proposition . '</div>' . "\n";
 
       if ($iassign_statement_activity_item->automatic_evaluate == 1)
         $resp = get_string('yes');
@@ -2699,6 +2875,8 @@ $param->special_param1 = 0; // 'special_param1 == 1' => script of iGeom
 
       $USER->iassignEdit = $this->bottonPost;
 
+      print activity::toggle_columns_script();
+
       if ($iassign_submission && $allow_resubmission) {
 
         // Put the iLM to
@@ -2727,6 +2905,7 @@ $param->special_param1 = 0; // 'special_param1 == 1' => script of iGeom
         print $OUTPUT->box('<p><strong>' . $last_iassign . '</strong></p>' . "\n");
 
         if (!isset($enderecoPOST)) $enderecoPOST = "";
+        print activity::toggle_columns_script();
         // Prepare tags to present the iLM
         print $OUTPUT->box($ilm->view_iLM($iassign_statement_activity_item, $student_answer, $enderecoPOST, $loadTeacherActivity));
 
@@ -2736,7 +2915,6 @@ $param->special_param1 = 0; // 'special_param1 == 1' => script of iGeom
       //2020 Estava subordinado ao: elseif (($this->action == 'viewsubmission') && has_capability('mod/iassign:evaluateiassign', $USER->context, $USER->id))
       //2020 e com isso NAO permitia aluno ter o quadro para envio!
       //2020 Foi para final dessa funcao 'view_iassign_current()'
-
     } // elseif (($this->action == 'viewsubmission') && has_capability('mod/iassign:evaluateiassign', $USER->context, $USER->id))
     // *** (end) Teacher access (view learner's submission to the activity)
 
@@ -2838,8 +3016,7 @@ $param->special_param1 = 0; // 'special_param1 == 1' => script of iGeom
 
         print '<table width=100% border=0 valign="top">' . "\n";
         print '<tr><td width=60% valign="top">' . "\n";
-        print '<strong>' . get_string('proposition', 'iassign') . '</strong>' . "\n";
-        print '<p>' . $iassign_statement_activity_item->proposition . '</p>' . "\n";
+        
         $flag_dependency = true;
 
         if ($iassign_statement_activity_item->type_iassign == 3) {
@@ -2975,6 +3152,11 @@ $param->special_param1 = 0; // 'special_param1 == 1' => script of iGeom
           print '</td></tr></table>' . "\n";
           //2019 print $OUTPUT->box_end(); // closing Box 5 but sometimes it does reach this point - see it at the end of 'if ($this->view_iassign)'
 
+          print activity::toggle_columns_script();
+
+          print '<p class="mt-5"><strong>' . get_string('proposition', 'iassign') . '</strong></p>' . "\n";
+          print '<div class="proposition">' . $iassign_statement_activity_item->proposition . '</div>' . "\n";
+
           $output = '';
 
           if (!$iassign_ilm) {
@@ -2994,7 +3176,7 @@ $param->special_param1 = 0; // 'special_param1 == 1' => script of iGeom
             $output .= $ilm->view_iLM($iassign_statement_activity_item, $student_answer, $enderecoPOST, true); // presents iLM and true => see the teacher file
           } elseif ($iassign_submission && $iassign_submission->answer == '0') {
             $student_answer = "";
-            $output .= $ilm->view_iLM($iassign_statement_activity_item, $student_answer, $enderecoPOST, true); // presents iLM
+            $output .=  $ilm->view_iLM($iassign_statement_activity_item, $student_answer, $enderecoPOST, true); // presents iLM
           } else {
             // When student is redoing his activity
 
@@ -3074,6 +3256,7 @@ $param->special_param1 = 0; // 'special_param1 == 1' => script of iGeom
 
 
       //if (!empty($history_comment)) {
+        $output .= "<a id='comments'></a>";
         $output .= "  <table id='outlinetable' class='generaltable boxaligncenter' cellpadding='5' width='100%'> \n";
         $output .= "     <tr><th><i style='font-size: 20px' class='icon fa fa-comments-o'></i>" . get_string('history_comments', 'iassign') . "</th></tr>";
         $output .= "</table>";
@@ -5124,6 +5307,16 @@ class activity {
       $output .= '<strong style="margin-left: 3rem;">' . get_string('grade_iassign', 'iassign') . ':</strong>&nbsp;' . $this->activity->grade . '</p>' . "\n";
       } // if ($iassign_statement_activity_item->type_iassign == 3)
 
+    $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()
+
+  /// Provide script to toggle columns
+  static function toggle_columns_script () {
+    $output = "";
     $output .= '<script>
     function toLeft () {
 
@@ -5154,11 +5347,8 @@ class activity {
     
     $output .= '<span 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 .= '<p><strong>' . get_string('proposition', 'iassign') . ':</p>&nbsp;<div class="proposition">' . $this->activity->proposition . '</div>' . "\n";
-    
-    print $OUTPUT->box($output);
-    } // function show_info_iassign()
-
+    return $output;
+  }
 
   /// Shows date of opening and closing activities
   function view_dates () {

+ 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 = 2020102929;       // The current module version (Date: YYYYMMDDXX)
+$plugin->version = 2020102933;       // 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;