فهرست منبع

Update 'ilm_handlers/html5.php'

Fixed function import_ilm(.): if the new version of previous HTML5 iLM, with the same name of an old Java version, was getting the iassign_ilm.id of Java version.
leo 1 روز پیش
والد
کامیت
25abdfc771
1فایلهای تغییر یافته به همراه10 افزوده شده و 6 حذف شده
  1. 10 6
      ilm_handlers/html5.php

+ 10 - 6
ilm_handlers/html5.php

@@ -6,7 +6,8 @@
  * @author Igor Moreira Fe'lix
  * @author Patricia Alves Rodrigues
  * @author Leo^nidas O. Branda~o
- * @version v 1 2017/17/10
+ * @version v 1.1 2026/09/03
+ * @version v 1   2017/17/10
  * @package mod_iassign_ilm_handlers
  * @copyright iMatica (<a href="http://www.matematica.br">iMath</a>) - Computer Science Dep. of IME-USP (Brazil)
  * 
@@ -192,7 +193,7 @@ class html5 implements ilm_handle {
     } // public static function show_ilm_commands()
 
 
-//TODO: Remover em favor do 'files_functions.php ! get_from_files(.)'
+  //TODO: Remover em favor do 'files_functions.php ! get_from_files(.)'
   // Try to get file from {files} using fields 'id', 'file' and 'filesid' in this order
   // The current convention is {files}.itemid = {iassign_statement}.id (however previously the others were used)
   public static function recover_from_files ($fs, $context_id, $iassign_statement_id, $iassign_statement_file, $iassign_statement_files) {
@@ -255,7 +256,7 @@ class html5 implements ilm_handle {
       //$files = $fs->get_area_files($context->id, 'mod_iassign', 'exercise', $iassign_statement_activity_item->id); // iassign_statement_activity_item = table 'iassign_statement'
       // $answer_files = html5::recover_from_files($fs, $context->id, $iassign_statement_activity_item->id, $iassign_statement_activity_item->file, $iassign_statement_activity_item->filesid);
 
-      require_once($CFG->dirroot . '/mod/iassign/files_functions.php');
+      require_once($CFG->dirroot . '/mod/iassign/files_functions.php'); // files_functions.php ! get_from_files(.)
       // echo "html5.php: {iassign_statement}.id=" . $iassign_statement_activity_item->id . ", file=" . $iassign_statement_activity_item->file . ", filesid=" . $iassign_statement_activity_item->filesid . "<br/>\n";
 
       $answer_files = NULL;
@@ -1140,7 +1141,7 @@ else echo "ilm_handlers/html5.php!delete_ilm(.): else k==0, ilm_id=" . $ilm_id .
 
       $ilm_final_directory = $dir_and_file_jar[0]; // {iassign_ilm}.file_jar is the first element (not used here)
       $file_jar = $dir_and_file_jar[1]; // {iassign_ilm}.file_jar is the second element
-echo "dir_and_file_jar : ilm_final_directory="; print_r($ilm_final_directory); echo "<br/>file_jar="; print_r($file_jar); //exit;
+echo "dir_and_file_jar : ilm_final_directory="; print_r($ilm_final_directory); echo "<br/>file_jar="; print_r($file_jar); echo "<br/>"; //exit;
 
       if (!is_dir($file_jar)) { // If the admin does not includes "ilm/<iLM name>" add it to the $file_jar (since this path is necessary)
         // $items = explode("/", $ilm_final_directory); // get [<iLM name>, <iLM version>]
@@ -1163,8 +1164,11 @@ echo " - completado file_jar=" . $file_jar. "<br/>\n"; //2025/04/11 leo
         $msg_error = get_string('error_add_ilm', 'iassign') . "<br/>In import_ilm: file_jar empty, files_extract=" . $files_extract . "<br/>\n";
         print_error($msg_error); //xx print_error('error_add_ilm', 'iassign'); //D print("Import file = " . file_jar . "<br/>");  
         }
-      else { // if (empty($file_jar))
-        $iassign_ilm = $DB->get_record('iassign_ilm', array("parent" => 0, "name" => $ilm_xml_name));
+      else { // else if (empty($file_jar))
+        // Seach for iLM with this name $ilm_xml_name, considering only those with "type == 'HTML5'" (avoid to return similar Java iLM)
+        $iassign_ilm = $DB->get_record('iassign_ilm', array("parent" => 0, "name" => $ilm_xml_name, "type" => "HTML5"));
+echo "apos get_record: iassign_ilm="; print_r($iassign_ilm); echo "<br/>"; //2026/09/03 leo
+//TODO: NAO esta' removendo o diretorio?! //2026/09/03 leo
         if (!$iassign_ilm) { // New iLM (it does not have any parent)
           $iassign_ilm = new stdClass();
           $iassign_ilm->id = 0;