Browse Source

Adicionado o campo 'reevaluate' ao iassign_ilm

Igor 3 years ago
parent
commit
168f4d4f3b
8 changed files with 72 additions and 11 deletions
  1. 2 1
      db/install.xml
  2. 27 0
      db/upgrade.php
  3. 4 1
      ilm_handlers/html5.php
  4. 2 0
      lang/en/iassign.php
  5. 2 0
      lang/pt_br/iassign.php
  6. 21 3
      locallib.php
  7. 13 5
      settings.php
  8. 1 1
      version.php

+ 2 - 1
db/install.xml

@@ -19,7 +19,8 @@
                 <FIELD NAME="timemodified" TYPE="int"  LENGTH="10"     NOTNULL="true" UNSIGNED="true" SEQUENCE="false" DEFAULT="0"   ENUM="false" COMMENT="Date of last modification"               PREVIOUS="enable"       NEXT="author"/>
                 <FIELD NAME="author"       TYPE="int"  LENGTH="10"     NOTNULL="true" UNSIGNED="true" SEQUENCE="false" DEFAULT="0"   ENUM="false" COMMENT="id of the author of the iLM"             PREVIOUS="timemodified" NEXT="timecreated"/>
                 <FIELD NAME="timecreated"  TYPE="int"  LENGTH="10"     NOTNULL="true" UNSIGNED="true" SEQUENCE="false" DEFAULT="0"   ENUM="false" COMMENT="Date of registration of iLM"             PREVIOUS="author"       NEXT="evaluate"/>
-                <FIELD NAME="evaluate"     TYPE="int"  LENGTH="1"                     UNSIGNED="true" SEQUENCE="false" DEFAULT="0"   ENUM="false" COMMENT="iLM has automatic evaluator? 0-no/1-yes" PREVIOUS="timecreated"/>
+                <FIELD NAME="evaluate"     TYPE="int"  LENGTH="1"                     UNSIGNED="true" SEQUENCE="false" DEFAULT="0"   ENUM="false" COMMENT="iLM has automatic evaluator? 0-no/1-yes" PREVIOUS="timecreated"  NEXT="reevaluate"/>
+                <FIELD NAME="reevaluate"   TYPE="int"  LENGTH="1"      NOTNULL="true" UNSIGNED="true" SEQUENCE="false" DEFAULT="0"   ENUM="false" COMMENT="iLM has automatic reevaluator? 0-no/1-yes" PREVIOUS="timecreated"/>
             </FIELDS>
             <KEYS>
                 <KEY   NAME="primary"      TYPE="primary" FIELDS="id"/>

+ 27 - 0
db/upgrade.php

@@ -590,6 +590,33 @@ function xmldb_iassign_upgrade ($oldversion) {
         }
 
     } // if ($oldversion < 2019112200)
+
+    if ($oldversion < 2020070612) {
+      
+      $table = new xmldb_table('iassign_ilm');
+
+      $field = new xmldb_field('reevaluate');
+      $field->set_attributes(XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', null, null, null);
+      
+      if (!$dbman->field_exists($table, $field)) {
+        $dbman->add_field($table, $field);
+      }
+
+      $iassign_ilm = $DB->get_records('iassign_ilm');
+      foreach ($iassign_ilm as $iassign) {
+        if ($iassign->name == 'iVProg' && $iassign->type == 'HTML5') {
+          $updateentry = new stdClass();
+          $updateentry->id = $iassign->id;
+          $updateentry->reevaluate = 1;
+          $updateentry->timemodified = time();
+
+          $DB->update_record("iassign_ilm", $updateentry);
+          break;
+        }
+      }
+
+      }
+
     
 
   // log event -----------------------------------------------------

+ 4 - 1
ilm_handlers/html5.php

@@ -522,6 +522,7 @@ class html5 implements ilm_handle {
     $application_descriptor .= '  <width>' . $iassign_ilm->width . '</width>' . "\n";
     $application_descriptor .= '  <height>' . $iassign_ilm->height . '</height>' . "\n";
     $application_descriptor .= '  <evaluate>' . $iassign_ilm->evaluate . '</evaluate>' . "\n";
+    $application_descriptor .= '  <reevaluate>' . $iassign_ilm->reevaluate . '</reevaluate>' . "\n";
 
     if ($iassign_ilm_configs) { //MOOC 2016
       $application_descriptor .= '   <params>' . "\n";
@@ -549,7 +550,7 @@ class html5 implements ilm_handle {
     header("Content-Type: application/zip");
     header("Content-Disposition: attachment; filename=\"" . basename($zip_filename) . "\";");
     header("Content-Transfer-Encoding: binary");
-    header("Content-Length: " . (filesize($zip_filename) + 1000));
+    header("Content-Length: " . (filesize($zip_filename)));
     set_time_limit(0);
     readfile($zip_filename) || die("File not found.");
     unlink($zip_filename);
@@ -793,6 +794,7 @@ class html5 implements ilm_handle {
         $newentry->author = $USER->id;
         $newentry->timecreated = time();
         $newentry->evaluate = (String) $application_xml->evaluate;
+        $newentry->reevaluate = (String) $application_xml->reevaluate;
         $newentry->parent = $iassign_ilm->id;
 
         $newentry->id = $DB->insert_record("iassign_ilm", $newentry);
@@ -881,6 +883,7 @@ class html5 implements ilm_handle {
         $newentry->author = $USER->id;
         $newentry->timecreated = time();
         $newentry->evaluate = (String) $application_xml->evaluate;
+        $newentry->reevaluate = (String) $application_xml->reevaluate;
         $newentry->parent = $iassign_ilm->id;
 
         //MOOC 2016 $newentry->id = $DB->insert_record("iassign_ilm", $newentry);

+ 2 - 0
lang/en/iassign.php

@@ -50,6 +50,7 @@ $string['auto_evaluate_grade_registered'] = 'Previously registered grade:';
 $string['auto_evaluate_help']             = 'What means automatic evaluation? It depends on the iLM implementation. '.
         'If the iLM has automatic evaluation select Yes to use its automatic evaluation to the activity.';
 
+$string['auto_evaluate_missing']          = 'iLM has not auto reevaluation';
 $string['auto_evaluate_msg_diff_cases']   = 'The original test cases are different from the students\' exercise. This can be a fraud attempt! <br> For security reasons, students grade has been updated to 0 (zero). <br> Refresh the page and try again.';
 $string['auto_evaluate_msg_empty_cases']  = 'The test cases used by iLM to evaluation are empty. <br> Refresh the page and try again.';
 $string['auto_evaluate_msg_fail']         = 'When trying run automatic evaluation, iLM reported a failure. <br> Click on the icon to details.';
@@ -58,6 +59,7 @@ $string['auto_evaluate_msg_t_diff_cases'] = 'Differences found in test cases. Cl
 $string['auto_evaluate_msg_t_empty_cases']= 'Empty test cases. Click on the icon to details.';
 $string['auto_evaluate_msg_t_fail']       = 'Execution failure. Click on the icon to details.';
 $string['auto_evaluate_msg_time']         = 'iLM was asked to evaluate students exercise, but did not return any information to iAssign. This can happen when iLM has no re-evaluator. <br> Refresh the page and try again.';
+$string['auto_evaluate_name_config']      = 'Auto reevaluation';
 $string['auto_evaluate_ok']               = 'Grade and submission are reliable';
 
 $string['auto_evaluate_reprocess']        = 'Reevaluate automatically';

+ 2 - 0
lang/pt_br/iassign.php

@@ -50,6 +50,7 @@ $string['auto_evaluate_grade_registered'] = 'Nota registrada anteriormente:';
 $string['auto_evaluate_help']             = 'O que significa avaliação automática? Isso depende do modelo implementado pelo iMA. '.
         'Se o iMA tem avaliação automática, selecione Sim para usar seu avaliador automático.';
 
+$string['auto_evaluate_missing']          = 'O iMA não possui reavaliador automático.';
 $string['auto_evaluate_msg_diff_cases']   = 'Os casos de teste originais são diferentes daqueles armazenados. Isso pode indicar uma tentativa de fraude! <br> Por motivos de segurança, a nota do aluno foi atualizada para 0 (zero). <br>Recarregue a página e tente novamente.';
 $string['auto_evaluate_msg_empty_cases']  = 'Os casos de teste utilizados pelo iMA no processo de avaliação automática estão vazios.<br>Recarregue a página e tente novamente.';
 $string['auto_evaluate_msg_fail']         = 'Ao tentar executar a avaliação da atividade, o iMA reportou uma falha.<br>Recarregue a página e tente novamente.';
@@ -58,6 +59,7 @@ $string['auto_evaluate_msg_t_diff_cases'] = 'Casos de teste diferentes. Clique n
 $string['auto_evaluate_msg_t_empty_cases']= 'Casos de teste vazios. Clique no ícone para detalhes.';
 $string['auto_evaluate_msg_t_fail']       = 'Falha na execução. Clique no ícone para detalhes.';
 $string['auto_evaluate_msg_time']         = 'Foi solicitado ao iMA que avaliasse o exercício do estudante, porém, o iMA não respondeu ao iTarefa. Isso pode indicar que o iMA não possui re-avaliador em lote. <br>Recarregue a página e tente novamente!';
+$string['auto_evaluate_name_config']      = 'Reavaliador automático';
 $string['auto_evaluate_ok']               = 'Envio e nota íntegros';
 
 $string['auto_evaluate_reprocess']        = 'Reavaliar automaticamente';

+ 21 - 3
locallib.php

@@ -428,10 +428,24 @@ class iassign {
       $matches = [];
       preg_match('/[0-9]*\.?[0-9]*/', $exercise->name, $matches, PREG_OFFSET_CAPTURE);
       
-      if ($matches[0][0]) {
-        print '<li id="li-item-'.$exercise->id.'"><input data-iditem="'.$matches[0][0].'" data-exercise="'.$exercise->id.'" class="form-check-input" type="checkbox" id="ex_'.$exercise->id.'"><label id="label_ex_'.$exercise->id.'" for="ex_'.$exercise->id.'">' . $exercise->name . '</label></li>';
+      $iassign_ilm = $DB->get_record("iassign_ilm", array("id" => $exercise->iassign_ilmid));
+
+      if ($iassign_ilm && $iassign_ilm->reevaluate == 1) {
+
+        if ($matches[0][0]) {
+          print '<li id="li-item-'.$exercise->id.'"><input data-iditem="'.$matches[0][0].'" data-exercise="'.$exercise->id.'" class="form-check-input" type="checkbox" id="ex_'.$exercise->id.'"><label id="label_ex_'.$exercise->id.'" for="ex_'.$exercise->id.'">' . $exercise->name . '</label></li>';
+        } else {
+          print '<li id="li-item-'.$exercise->id.'"><input data-iditem="('.$exercise->id.')" data-exercise="'.$exercise->id.'" class="form-check-input" type="checkbox" id="ex_'.$exercise->id.'"><label id="label_ex_'.$exercise->id.'" for="ex_'.$exercise->id.'">(' . $exercise->id . ') - ' . $exercise->name . '</label></li>';
+        }
+
       } else {
-        print '<li id="li-item-'.$exercise->id.'"><input data-iditem="('.$exercise->id.')" data-exercise="'.$exercise->id.'" class="form-check-input" type="checkbox" id="ex_'.$exercise->id.'"><label id="label_ex_'.$exercise->id.'" for="ex_'.$exercise->id.'">(' . $exercise->id . ') - ' . $exercise->name . '</label></li>';
+
+        if ($matches[0][0]) {
+          print '<li id="li-item-'.$exercise->id.'"> <i onmouseenter="$(\'#li-item-'.$exercise->id.'\').find(\'i\').tooltip(\'show\');" class="fa fa-times without-reevaluator" style="font-size: 1.1em;color: red;margin-bottom: .7em;margin-left: -1.3em;margin-right: .58em;" data-toggle="tooltip" data-original-title="'.get_string('auto_evaluate_missing', 'iassign').'"></i>' . $exercise->name . '</li>';
+        } else {
+          print '<li id="li-item-'.$exercise->id.'">  <i onmouseenter="$(\'#li-item-'.$exercise->id.'\').find(\'i\').tooltip(\'show\');" class="fa fa-times without-reevaluator" style="font-size: 1.1em;color: red;margin-bottom: .7em;margin-left: -1.3em;margin-right: .58em;" data-toggle="tooltip" data-original-title="'.get_string('auto_evaluate_missing', 'iassign').'"></i>(' . $exercise->id . ') - ' . $exercise->name . '</li>';
+        }
+
       }
 
     }
@@ -451,6 +465,10 @@ class iassign {
 
     print '<script>';
 
+    print '
+    
+    ';
+
     print 'var submissions = [';
 
     // Get list of student id have submit for each exercise:

+ 13 - 5
settings.php

@@ -354,7 +354,14 @@ else if ($action == 'config') { // Administration > plugins > iAssign : after se
         $ilm_parent->file_jar = basename($ilm_parent->file_jar);
         }
 
-      $str .= '<tr><td colspan=3><strong>' . get_string('url_ilm', 'iassign') . '</strong>&nbsp;<a href="' . $url_ilm . '" target="_blank">' . $url_ilm . '</a></td></tr>';
+      $str .= '<tr><td><strong>' . get_string('url_ilm', 'iassign') . ':</strong>&nbsp;<a href="' . $url_ilm . '" target="_blank">' . $url_ilm . '</a></td>';
+      
+      if ($ilm_parent->enable == 1 || $ilm_parent->enable == -1)
+        $enable = get_string('yes', 'iassign');
+      else
+        $enable = get_string('no', 'iassign');
+      $str .= '<td width="50%"><strong>' . get_string('enable', 'iassign') . ':</strong>&nbsp;' . $enable . '</td></tr>';
+
       $str .= '<tr><td width="50%" title="field: file_jar"><strong>' . get_string('file_jar', 'iassign') . ':</strong>&nbsp;' . $ilm_parent->file_jar . '</td>';
       $str .= '<td width="50%" title="field: file_class"><strong>' . get_string('file_class', 'iassign') . ':</strong>&nbsp;' . $ilm_parent->file_class . '</td></tr>';
 
@@ -369,12 +376,13 @@ else if ($action == 'config') { // Administration > plugins > iAssign : after se
 
       $str .= '<tr><td width="50%" title="field: evaluate"><strong>' . get_string('evaluate', 'iassign') . ':</strong>&nbsp;' . $evaluate . '</td>';
 
-      if ($ilm_parent->enable == 1 || $ilm_parent->enable == -1)
-        $enable = get_string('yes', 'iassign');
+      if ($ilm_parent->reevaluate == 1)
+        $reevaluate = get_string('yes', 'iassign');
       else
-        $enable = get_string('no', 'iassign');
-      $str .= '<td width="50%"><strong>' . get_string('enable', 'iassign') . ':</strong>&nbsp;' . $enable . '</td></tr>';
+        $reevaluate = get_string('no', 'iassign');
+      $str .= '<td width="50%"><strong>' . get_string('auto_evaluate_name_config', 'iassign') . ':</strong>&nbsp;' . $reevaluate . '</td></tr>';
 
+      
       $str .= '<tr>' . chr(13);
       $str .= '<td width="50%"><strong>' . get_string('file_created', 'iassign') . ':</strong>&nbsp;' . userdate($ilm_parent->timecreated) . '</td>';
       $str .= '<td width="50%"><strong>' . get_string('file_modified', 'iassign') . ':</strong>&nbsp;' . userdate($ilm_parent->timemodified) . '</td>' . chr(13);

+ 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.00 (Build: 2020061700)'; // Human-readable version name
-$plugin->version = 2020061700;                   // The current module version (Date: YYYYMMDDXX)
+$plugin->version = 2020070612;                   // 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;