Igor 3 years ago
parent
commit
2da280163d
11 changed files with 619 additions and 747 deletions
  1. 51 219
      TODO.txt
  2. 3 3
      db/install.xml
  3. 151 136
      db/upgrade.php
  4. 49 40
      iassign_form.php
  5. 1 1
      ilm_handlers/html5.php
  6. 5 5
      ilm_manager.php
  7. 5 5
      ilm_manager_form.php
  8. 328 321
      locallib.php
  9. 14 10
      settings_form.php
  10. 11 6
      settings_ilm.php
  11. 1 1
      version.php

+ 51 - 219
TODO.txt

@@ -1,250 +1,82 @@
-Alterações iTarefa:
+Prontos:
 
---> quando o aluno tentava acessar uma atividade que foi removida, era gerado um bug
-:: com as alterações, o aluno recebe um alerta.
+	1. iTarefa
 
-SOLUÇÃO:
-* locallib.php
-   função: view_iassign_current() 
-   if (!$iassign_statement_activity_item) {
-       print $OUTPUT->header();
-       \core\notification::error(get_string('activity_not_found', 'iassign'));
-       print $OUTPUT->footer();
-       exit;
-     }
+  - sobrescrita dos arquivos enviados pelo professor Leo (iassign_alteracoes_2020_12_28.tgz)
 
+  TODO: na instalacao/atualizacao, mudar 'assign_ilm.file_jar' o INDEX (mudar "update" e "install")
+  -> Removido o INDEX para o campo file_jar no install.xml
+  -> Adicionado o campo no upgrade.php: $DB->execute("ALTER TABLE {iassign_ilm} DROP INDEX {iassilm_fil_uix}");
 
---> quando o aluno finalizava uma tarefa no iFractions, a tela do iMA ficava preta
-problema: ao carregar a página inicial, o iTarefa entrega um código para acessar o ilm_security,
-mas com a finalização da atividade, o mesmo código era mantido, portanto, não tinha como acessar, 
-pois o código do ilm_security só pode ser usado uma única vez.
+  CAMPO: 'iassing_statement.filesid':
+  -> adicinada uma nova entrada ao arquivo install.xml para o campo 'iassing_statement.filesid'
 
-SOLUÇÃO: 
-* iFractions/index.html:
-   função: finish_redirect()
-     parent.location.reload(true); // Ao passar o "true", o navegador não usa o cache e busca um novo código ilm_security
+  upgrade: criar campo 'iassing_statement.filesid' (='files.id') - ja esta no cod que passei
+  -> criar o campo 'iassing_ilm.filesid' e para todos os registros existentes na tabela, fazer uma cópia dos valores do iassing_statement.file
 
+* obs: Igor usou: 'iassing_ilm.filesid' (voce usou 'iassing_ilm.files' no 'upgrade')
+  Revisar no codigo para usar 'iassing_statement.filesid'
 
---> manter selecionado o iLM que foi usado recentemente para criar a última atividade, a fim de melhorar a usabilidade e produtividade
-* arquivo alterado: iassign_form.php
+  * Acertos relatorio: Igor vai procurar as alteracoes que ja' tinha resolvido (tabela HTML)
+  --> Não encontrei essa modificação, que já havia implementado e compartilhado.
 
--->  Gerenciamento de arquivos:
+* Erros do form do editor de iMA ./mod/iassign/settings_ilm.php
+  --> Não consegui reproduzir o erro
 
-1. Criação da atividade:
-- O campo itemid passa a receber o statementid.
-- Função: new_iassign //locallib.php
- // IGOR: itemid do arquivo é o mesmo que o id do statemente registrado acima:
-      $itemid = $id;
 
-2. Alteração da atividade:
-- Atualmente, o arquivo anterior é removido, mas não remove também as entradas de diretórios.
+ * Remover qualquer referencia a sitios externos:
+      -- cdn.jsdelivr.net: /var/www/html/moo391p/filter/mathjaxloader/settings.php //line
+      criar diretorio: /var/www/html/saw/copias_locais/
 
-3. Exclusão da atividade:
-- O iTarefa não removia as entradas do files, que estão associadas àquela atividade excluída.
-- Para corrigir, as linhas abaixo foram adicionadas:
+  --> Por se tratarem de bibliotecas que o Moodle e outros plugins utilizam, não alterei localmente, pois não surtiriam efeito em nossa versão de produção. A se pensar para o futuro.
 
-função deleteyes: // locallib.php
+Fazendo:
 
-   $fs = get_file_storage(); 
-      $fs->delete_area_files(
-        $iassign->context->id, 
-        'mod_iassign', 
-        'exercise', 
-        $this->activity->id
-      );
 
-4. Cópia de atividade: 
-- Com a alteração feita para a criação, a cópia também passou a registrar o itemid com o statementid.
 
-5. Mover atividade:
-- Para preservar o itemid do arquivo, a seguinte linha foi atualizada:
 
-função move_activity: //locallib.php
-$newfile = $fs->create_file_from_storedfile(array('contextid' => $id_context, 'component' => 'mod_iassign', 'filearea' => 'exercise', 'itemid' => $iassign_id), $value);
-  
-
-5. No update: 
-
-..> Testar na nossa base:
-
-if ($oldversion < 2020102800) {
-      // 1. encontrar os contextos dos arquivos do itarefa:
-      $iassign_contexts_list = $DB->get_records_sql("SELECT contextid FROM {files} f " .
-        " WHERE component='mod_iassign'");
-      // 2. compor um array com todos os contextos encontrados: 
-      $contexts = array();
-      foreach ($iassign_contexts_list as $iassign_context_item) {
-        array_push($contexts, $iassign_context_item->contextid);
-      }
-      // 3. encontrar todas as atividades do itarefa, em que o arquivo não tenha o mesmo id do statement:
-      $iassign_statement_list = $DB->get_records_sql("SELECT * FROM {iassign_statement} s " .
-        " WHERE s.id != s.file");
-      $fs = get_file_storage();
-
-      // 4. percorrer o conjunto de atividades:
-      foreach ($iassign_statement_list as $iassign_statement_activity_item) {
-        
-        // 5. encontrar o arquivo, considerando os possíveis contextos:
-        $files = array();
-        foreach ($contexts as $context) {
-
-          $files = $fs->get_area_files($context, 'mod_iassign', 'exercise', $iassign_statement_activity_item->file);
-
-          // 6. se o arquivo for encontrado, fazer uma cópia do conteúdo, 
-          // com o itemid novo, atualizar o iassign_statement, e apagar o arquivo antigo:
-          if ($files) {
-            foreach ($files as $value) {
-              if ($value != null && $value->get_filename() != ".") {
-                // 6.A. Fazer uma cópia:
-                $newfile = $fs->create_file_from_storedfile(array('contextid' => $context, 'component' => 'mod_iassign', 'filearea' => 'exercise', 'itemid' => $iassign_statement_activity_item->id), $value);
-
-                // 6.B. Atualizar o registro da atividade para o arquivo novo:
-                $update_entry = new stdClass();
-                $update_entry->id = $iassign_statement_activity_item->id;
-                $update_entry->file = $newfile->get_itemid();
-                $DB->update_record("iassign_statement", $update_entry);
-
-                // 6.C. Remover o arquivo antigo:
-                $value->delete();
-              } else if ($value != null && $value->get_filename() == ".") {
-                // 6.C.I. Remover também os indicadores de diretório:
-                $value->delete();
-              }
-            }
-            break;
-          }
-        }
-                  
-      }
-    } // if ($oldversion < 2020102800)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-09/11/2020:
-
-
-:: editingbehavior ::
-
-editingbehavior = 0: para iGeom, iHanoi => ter que clicar no "Refazer atividade" : desabilita botao "enviar" ao entrar em atividade feita
-editingbehavior = 1: para iVProg => permite continuar edicao (do ponto que parou) : deixa habilitado o botao "enviar" em qq situacao
-title do botão
-editingbehavior = 2: para iFraction => não tem o botão enviar, o envio é contínuo
-
-:: submissionbehavior ::
-
-se editingbehavior=0, entao: trocar 'title' para 
-'Este iMA nao permite continuar edicao de solucao enviada. 
-Para editar, por favor, clique no botao 'Refazer atividade'"
-
-
-iassign_ilm: 2 novos campos 'editingbehavior' e 'submissionbehavior'
-
-Sendo:
- id name version type editingbehavior  description url extension parent file_jar file_class width height enable timemodified author timecreated evaluate reevaluate
- editingbehavior = 0: para iGeom, iHanoi => ter que clicar no "Refazer atividade"          : desabilita botao "enviar" ao entrar em atividade feita
- editingbehavior = 1: para iVProg        => permite continuar edicao (do ponto que parou)  : deixa habilitado o botao "enviar" em qq situacao
-
- submissionbehavior = 0: para iGeom, iVprog, iHanoi  => NAO trocar de pagina        
- submissionbehavior = 1: para iFractions             => ao finalizar deve invocar iTarefa.finish_and_redirect()
+Afazeres:
 
+  
+2. MConf/Elo
+3. Moodle 3.10+
 
-:: iassign_allsubmissions ::
-
-Criar nova tabela 'iassign_allsubmissions'.  Se a atividade estiver marcada para gravar todas, qdo aluno clicar no "avaliar", gravar nova entrada.
-
-No formulario para criar atividade, se o iMA for do tipo (1,0), mostrar opcao para gravar tudo
-No 'locallib', sempre que o aluno clicar no "avaliar"
-
-
-No iVProg
-
--> mensagem de fechar a janela com edição
-
-
--->> AFAZERES:
-
-
-
-
-
-
-
-
-
-
-
-
-
-iassign_ilm: 2 novos campos 'editingbehavior' e 'submissionbehavior'
-Sendo:
- id name version type editingbehavior  description url extension parent file_jar file_class width height enable timemodified author timecreated evaluate reevaluate
-
- editingbehavior = 0: para iGeom, iHanoi, iFractions => ter que clicar no "Refazer atividade"          : desabilita botao "enviar" ao entrar em atividade feita
-
- editingbehavior = 1: para iVProg        => permite continuar edicao (do ponto que parou)  : deixa habilitado o botao "enviar" em qq situacao
-
-
- @Igor: 
-  Finalizada a implementação do 'editingbehavior'
-
-
- submissionbehavior = 0: para iGeom, iVprog, iHanoi  => NAO trocar de pagina        
- submissionbehavior = 1: para iFractions             => ao finalizar deve invocar iTarefa.finish_and_redirect()
-
-
-Criar nova tabela 'iassign_allsubmissions'. Se a atividade estiver marcada para gravar todas, qdo aluno clicar no "avaliar", gravar nova entrada.
-
-No formulario para criar atividade, se o iMA for do tipo (1,0), mostrar opcao para gravar tudo
-No 'locallib', sempre que o aluno clicar no "avaliar"
-
+4. Cursos Verao
+Patricia
+Rafael Antonio Cosentino
+Thiago Silveira (esta na Alemanha)
 
+5. Materiais de cursos
+- Meus materiais: https://www.ime.usp.br/~leo/intr_prog/ 
+    --> para carregar página interna (iframe) remover o 
+- Instruções de como usar o MCONF: https://docs.atp.usp.br/artigos/mconf/
+- Instruções de como VPL: colocar na coluna 3 do "docs"
+- Produzir um texto sobre importancia de resolver (o mais) sozinho (possivel) cada exercicio
+- Estrutura do curso no Moodle:
+    -- Bloco: Motivação: histórias e aplicações (uma página Web Moodle com apontadores para nosssas paginas aberta, estilo "www.ime.usp.br/~leo/intr_prog/ ")
+    -- Bloco: Tópicos: tipos de algoritmos, técnicas de programação
+    -- Bloco: Exercícios iVProg/VPL base e desafios + questionario likert para cada questao (dificuldade)
+ - Avaliacao: 24H exercicios iVProg/VPL + questionario
 
-TODO
+Objetivos
+Sobre a importância de resolver (o máximo possível) sozinho cada exercício
+Existe muitos trabalhos que comprovam a necessidade do aprendiz empregar esforço individual em problemas/exercícios para conseguir alcançar o entendimento. Lembre-se da metáfora do exercício físico (pipoca+sofá x praticar+forma)
+Isso é particularmente mais importante em Introdução à Programação. É essencial tentar resolver problemas "novos" (muito diferentes daqueles que já resolveu antes). Procure quebrar o problema (https://pt.wikipedia.org/wiki/Divis%C3%A3o_e_conquista), resolver casos particulares (https://pt.wikipedia.org/wiki/M%C3%A9todo_indutivo), testar manualmente (minha apostila), para depois ir visualizando o algoritmo.
+Com o tempo adiquirirá base para reconhecer onde cada técnica de programação poderá ajudar a resolver o problema.
 
-1. 1 tabela nova: iassign_allsubmissions
+Para isso sugerimos adotar o seguinte "algoritmo":
+1. Tentar resolver sozinho.
+2. Se não conseguiu depois de X minuntos
+3. Então tente explicar para monitor/professor/colega sua dificuldade (e.g. o que pensou)
+               a partir dai o monitor/professor/colega poderá lhe dar alguma dica
+4.           Volte ao passo 1
 
-  @Igor:
-  Campos na tabela iassign_allsubmissions:
-    1. id
-    2. iassign_statementid
-    3. userid
-    4. timecreated
-    5. grade
-    6. answer
 
 
-2. 2 campos novos na tabela 'iassign_ilm': editingbehavior, submissionbehavior
-  
-3. 1 campo novo na tabela 'iassign_statement': store_all_submissions
 
-iMA:
-- getEvaluation(): tem que chamar o 'getEvaluation()' do iTarefa
-iTarefa:
-- Alterar com sua funcao 'getEvaluation()' com eventual codigo para gravar (senao ela e' vazia)
 
 
 
 
-30/11/2020:
---> tabela ilm:
-- action_button
-  0: submission desabilitado
-  1: padrão. submission habilitado.
 
---> se o ima possui autoavaliador e é do tipo exercício,
-trocar o rótulo do botão para 'Avaliar':
-  'roda o avaliador e envia o registro, 
-    clicando no avaliar, automaticamente vai ser registrado'
-  Verificar se a nota é maior ou menor
 

+ 3 - 3
db/install.xml

@@ -29,8 +29,7 @@
         <KEY   NAME="primary"        TYPE="primary" FIELDS="id"/>
       </KEYS>
       <INDEXES>
-        <INDEX NAME="name_version"   UNIQUE="true" FIELDS="name,version" NEXT="file_jar"/>
-        <INDEX NAME="file_jar"       UNIQUE="true" FIELDS="file_jar" PREVIOUS="name_version"/>
+        <INDEX NAME="name_version"   UNIQUE="true" FIELDS="name,version"/>
       </INDEXES>
     </TABLE>
     <TABLE NAME="iassign_ilm_config" COMMENT="Info about config iLM" PREVIOUS="iassign_ilm" NEXT= "iassign">
@@ -118,7 +117,8 @@
         <FIELD NAME="dependency"               TYPE="char" LENGTH="255"    NOTNULL="true"  UNSIGNED="true"  DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="List the activities that this activity depends. 0 - independent"  PREVIOUS="max_experiment"       NEXT="automatic_evaluate"/>
         <FIELD NAME="automatic_evaluate"       TYPE="int"  LENGTH="1"      NOTNULL="false" UNSIGNED="true"  DEFAULT="1" SEQUENCE="false" ENUM="false" COMMENT="Using automatic evaluation activity?0 - no / 1 - yes"             PREVIOUS="dependency"           NEXT="show_answer"/>
         <FIELD NAME="show_answer"              TYPE="int"  LENGTH="1"      NOTNULL="false" UNSIGNED="true"  DEFAULT="1" SEQUENCE="false" ENUM="false" COMMENT="Show automatic evaluation results to students? 0 - no / 1 - yes"  PREVIOUS="automatic_evaluate" NEXT="store_all_submissions"/>
-        <FIELD NAME="store_all_submissions"            TYPE="int"  LENGTH="10"     NOTNULL="true"  UNSIGNED="true"   DEFAULT="0"  SEQUENCE="false" ENUM="false" COMMENT="If all submissions must be stored" PREVIOUS="show_answer" />
+        <FIELD NAME="store_all_submissions"            TYPE="int"  LENGTH="10"     NOTNULL="true"  UNSIGNED="true"   DEFAULT="0"  SEQUENCE="false" ENUM="false" COMMENT="If all submissions must be stored" PREVIOUS="show_answer" NEXT="filesid" />
+        <FIELD NAME="filesid"  TYPE="char" LENGTH="255"    NOTNULL="false"  SEQUENCE="false" ENUM="false" COMMENT="Address and file name of the activity"    PREVIOUS="store_all_submissions"/>
       </FIELDS>
       <KEYS>
         <KEY NAME="primary"       TYPE="primary" FIELDS="id" NEXT="iassignid"/>

+ 151 - 136
db/upgrade.php

@@ -264,11 +264,9 @@ function xmldb_iassign_upgrade ($oldversion) {
       print '</div>' + "\n";
       }
 
-// s_iassign_ilm: atualizou iHanoi existente, mas nao era isso! Deveria ter inserido novo!
-//   id name   version type  ...  parent file_jar              file_class  width height  ...  evaluate reevaluate
-//   53 iHanoi 2       HTML5 ...  0      ilm/iHanoi/2/ihanoi/  index.html  1100  700     ...  1        0
-
-
+    // iassign_ilm: atualizou iHanoi existente, mas nao era isso! Deveria ter inserido novo!
+    //   id name   version type  ...  parent file_jar              file_class  width height  ...  evaluate reevaluate
+    //   53 iHanoi 2       HTML5 ...  0      ilm/iHanoi/2/ihanoi/  index.html  1100  700     ...  1        0
     $iassign_ilm = $DB->get_records('iassign_ilm');
     foreach ($iassign_ilm as $iassign) { // for iLM iHanoi update the new field 'reevaluate' as 1
       if ($iassign->name == 'iHanoi' && $iassign->type == 'HTML5' && $iassign->reevaluate!=1) {
@@ -286,170 +284,187 @@ function xmldb_iassign_upgrade ($oldversion) {
 
     } // if ($oldversion < 2020080300)
 
-    //TODO Codigo do Igor para atualizar 'files.itemid' e 'iassign_statement.filesid':
-    if ($oldversion < 2020102800) {
-      // 1. encontrar os contextos dos arquivos do itarefa:
-      $iassign_contexts_list = $DB->get_records_sql("SELECT contextid FROM {files} f " .
-        " WHERE component='mod_iassign'");
-      // 2. compor um array com todos os contextos encontrados: 
-      $contexts = array();
-      foreach ($iassign_contexts_list as $iassign_context_item) {
-        array_push($contexts, $iassign_context_item->contextid);
-      }
-      // 3. encontrar todas as atividades do itarefa, em que o arquivo não tenha o mesmo id do statement:
-      $iassign_statement_list = $DB->get_records_sql("SELECT * FROM {iassign_statement} s " .
-        " WHERE s.id != s.file");
-      $fs = get_file_storage();
+  //TODO Codigo do Igor para atualizar 'files.itemid' e 'iassign_statement.filesid':
+  if ($oldversion < 2020120500) {
 
-      // 4. percorrer o conjunto de atividades:
-      foreach ($iassign_statement_list as $iassign_statement_activity_item) {
-        
-        // 5. encontrar o arquivo, considerando os possíveis contextos:
-        $files = array();
-        foreach ($contexts as $context) {
-
-          $files = $fs->get_area_files($context, 'mod_iassign', 'exercise', $iassign_statement_activity_item->file);
-
-          // 6. se o arquivo for encontrado, fazer uma cópia do conteúdo, 
-          // com o itemid novo, atualizar o iassign_statement, e apagar o arquivo antigo:
-          if ($files) {
-            foreach ($files as $value) {
-              if ($value != null && $value->get_filename() != ".") {
-                // 6.A. Fazer uma cópia:
-                $newfile = $fs->create_file_from_storedfile(array('contextid' => $context, 'component' => 'mod_iassign', 'filearea' => 'exercise', 'itemid' => $iassign_statement_activity_item->id), $value);
-
-                // 6.B. Atualizar o registro da atividade para o arquivo novo:
-                $update_entry = new stdClass();
-                $update_entry->id = $iassign_statement_activity_item->id;
-                $update_entry->file = $newfile->get_itemid();
-                $DB->update_record("iassign_statement", $update_entry);
-
-                // 6.C. Remover o arquivo antigo:
-                $value->delete();
-              } else if ($value != null && $value->get_filename() == ".") {
-                // 6.C.I. Remover também os indicadores de diretório:
-                $value->delete();
-              }
-            }
-            break;
-          }
-        }
-                  
-      }
-    } // if ($oldversion < 2020102800)
+    // Adding field iassing_statement.filesid
+    $table = new xmldb_table('iassign_statement');
 
-    /// @Igor - adicionar a tabela iassign_allsubmissions
-    if ($oldversion < 2020112000) { 
+    $field_filesid = new xmldb_field('filesid', XMLDB_TYPE_CHAR, '255', null, null, null, null, null);
 
-      // Define table iassign_allsubmissions to be created.
-      $table = new xmldb_table('iassign_allsubmissions');
+    if (!$dbman->field_exists($table, $field_filesid))
+      $dbman->add_field($table, $field_filesid);
+    
+    // Updating all registers from iassing_statement.filesid
+    $DB->execute("UPDATE {iassign_statement} SET filesid = file");
 
-      // Adding fields to table iassign_allsubmissions.
-      $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
-      $table->add_field('iassign_statementid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
-      $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
-      $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '16', null, XMLDB_NOTNULL, null, null);
-      $table->add_field('grade', XMLDB_TYPE_FLOAT, null, null, null, null, null, null);
-      $table->add_field('answer', XMLDB_TYPE_TEXT, 'long', null, null, null, null, null);
 
-      // Adding keys to table iassign_allsubmissions.
-      $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
+    // 1. encontrar os contextos dos arquivos do itarefa:
+    $iassign_contexts_list = $DB->get_records_sql("SELECT DISTINCT contextid FROM {files} f WHERE component='mod_iassign'");
+    // 2. compor um array com todos os contextos encontrados: 
+    $contexts = array();
+    foreach ($iassign_contexts_list as $iassign_context_item) {
+      array_push($contexts, $iassign_context_item->contextid);
+      }
+    // 3. encontrar todas as atividades do itarefa, em que o arquivo não tenha o mesmo id do statement:
+    $iassign_statement_list = $DB->get_records_sql("SELECT * FROM {iassign_statement} s WHERE s.id != s.file");
+    $fs = get_file_storage();
 
-      // Conditionally launch create table for iassign_allsubmissions.
-      if (!$dbman->table_exists($table)) {
-          $dbman->create_table($table);
+    // 4. percorrer o conjunto de atividades:
+    foreach ($iassign_statement_list as $iassign_statement_activity_item) {
+        
+      // 5. encontrar o arquivo, considerando os possíveis contextos:
+      $files = array();
+      foreach ($contexts as $context) {
+
+        $files = $fs->get_area_files($context, 'mod_iassign', 'exercise', $iassign_statement_activity_item->file);
+
+        // 6. se o arquivo for encontrado, fazer uma cópia do conteúdo, 
+        // com o itemid novo, atualizar o iassign_statement, e apagar o arquivo antigo:
+        if ($files) {
+          foreach ($files as $value) {
+            if ($value != null && $value->get_filename() != ".") {
+              // 6.A. Fazer uma cópia:
+              $newfile = $fs->create_file_from_storedfile(array('contextid' => $context, 'component' => 'mod_iassign', 'filearea' => 'exercise', 'itemid' => $iassign_statement_activity_item->id), $value);
+
+              // 6.B. Atualizar o registro da atividade para o arquivo novo:
+              $update_entry = new stdClass();
+              $update_entry->id = $iassign_statement_activity_item->id;
+              $update_entry->file = $newfile->get_itemid();
+              $update_entry->filesid = $newfile->get_itemid();
+              $DB->update_record("iassign_statement", $update_entry);
+
+              // 6.C. Remover o arquivo antigo:
+              $value->delete();
+              }
+            else if ($value != null && $value->get_filename() == ".") {
+              // 6.C.I. Remover também os indicadores de diretório:
+              $value->delete();
+              }
+            }
+            break;
+          } // if ($files)
+        } // foreach ($contexts as $context)
+      } // foreach ($iassign_statement_list as $iassign_statement_activity_item)
+    } // if ($oldversion < 2020120500)
+
+  /// @Igor - adicionar a tabela iassign_allsubmissions
+  if ($oldversion < 2020122900) { 
+
+    // Define table iassign_allsubmissions to be created.
+    $table = new xmldb_table('iassign_allsubmissions');
+
+    // Adding fields to table iassign_allsubmissions.
+    $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+    $table->add_field('iassign_statementid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
+    $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
+    $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '16', null, XMLDB_NOTNULL, null, null);
+    $table->add_field('grade', XMLDB_TYPE_FLOAT, null, null, null, null, null, null);
+    $table->add_field('answer', XMLDB_TYPE_TEXT, 'long', null, null, null, null, null);
+
+    // Adding keys to table iassign_allsubmissions.
+    $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
+
+    // Conditionally launch create table for iassign_allsubmissions.
+    if (!$dbman->table_exists($table)) {
+      $dbman->create_table($table);
       }
 
-      // Adding fields to table iassign_ilm.
-      $table = new xmldb_table('iassign_ilm');
+    // Adding fields to table iassign_ilm.
+    $table = new xmldb_table('iassign_ilm');
 
-      $field_editingbehavior = new xmldb_field('editingbehavior', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', null);
+    $field_editingbehavior = new xmldb_field('editingbehavior', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', null);
 
-      if (!$dbman->field_exists($table, $field_editingbehavior))
-        $dbman->add_field($table, $field_editingbehavior);
+    if (!$dbman->field_exists($table, $field_editingbehavior))
+      $dbman->add_field($table, $field_editingbehavior);
 
-      $field_submissionbehavior = new xmldb_field('submissionbehavior', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', null);
+    $field_submissionbehavior = new xmldb_field('submissionbehavior', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', null);
 
-      if (!$dbman->field_exists($table, $field_submissionbehavior))
-        $dbman->add_field($table, $field_submissionbehavior);
+    if (!$dbman->field_exists($table, $field_submissionbehavior))
+      $dbman->add_field($table, $field_submissionbehavior);
 
-      $field_action_buttons = new xmldb_field('action_buttons', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1', null);
-      
-      if (!$dbman->field_exists($table, $field_action_buttons))
-        $dbman->add_field($table, $field_action_buttons);
+    $field_action_buttons = new xmldb_field('action_buttons', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1', null);
+    
+    if (!$dbman->field_exists($table, $field_action_buttons))
+      $dbman->add_field($table, $field_action_buttons);
 
-      // Adding field to table iassign_statement:
-      $table = new xmldb_table('iassign_statement');
+    // Adding field to table iassign_statement:
+    $table = new xmldb_table('iassign_statement');
 
-      $field_store_all_submissions = new xmldb_field('store_all_submissions', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', null);
+    $field_store_all_submissions = new xmldb_field('store_all_submissions', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', null);
 
-      if (!$dbman->field_exists($table, $field_store_all_submissions))
-        $dbman->add_field($table, $field_store_all_submissions);
+    if (!$dbman->field_exists($table, $field_store_all_submissions))
+      $dbman->add_field($table, $field_store_all_submissions);
 
-      // Update new fields for previous installed iLM:
-      $iassign_ilm = $DB->get_records('iassign_ilm');
-      foreach ($iassign_ilm as $iassign) { 
-        $updateentry = new stdClass();
-        $updateentry->id = $iassign->id;
-        if (($iassign->name == 'iHanoi' && $iassign->type == 'HTML5')) {
-          $updateentry->editingbehavior = 0;
-          $updateentry->submissionbehavior = 0;
+    // Update new fields for previous installed iLM:
+    $iassign_ilm = $DB->get_records('iassign_ilm');
+    foreach ($iassign_ilm as $iassign) { 
+      $updateentry = new stdClass();
+      $updateentry->id = $iassign->id;
+      if (($iassign->name == 'iHanoi' && $iassign->type == 'HTML5')) {
+        $updateentry->editingbehavior = 0;
+        $updateentry->submissionbehavior = 0;
         }
-        if (($iassign->name == 'iGeom' && $iassign->type == 'Java')) {
-          $updateentry->editingbehavior = 0;
-          $updateentry->submissionbehavior = 0;
+      if (($iassign->name == 'iGeom' && $iassign->type == 'Java')) {
+        $updateentry->editingbehavior = 0;
+        $updateentry->submissionbehavior = 0;
         }
-        if (($iassign->name == 'iVProg' && $iassign->type == 'HTML5')) {
-          $updateentry->editingbehavior = 1;
-          $updateentry->submissionbehavior = 0;
+      if (($iassign->name == 'iVProg' && $iassign->type == 'HTML5')) {
+        $updateentry->editingbehavior = 1;
+        $updateentry->submissionbehavior = 0;
         }
-        if (($iassign->name == 'iFractions' && $iassign->type == 'HTML5')) {
-          $updateentry->editingbehavior = 0;
-          $updateentry->submissionbehavior = 1;
+      if (($iassign->name == 'iFractions' && $iassign->type == 'HTML5')) {
+        $updateentry->editingbehavior = 0;
+        $updateentry->submissionbehavior = 1;
         }
-        if (($iassign->name == 'Risko' && $iassign->type == 'Java')) {
-          $updateentry->editingbehavior = 1;
-          $updateentry->submissionbehavior = 0;
+      if (($iassign->name == 'Risko' && $iassign->type == 'Java')) {
+        $updateentry->editingbehavior = 1;
+        $updateentry->submissionbehavior = 0;
         }
-        if (isset($updateentry->editingbehavior)) {
-          $updateentry->timemodified = time();
-          $DB->update_record("iassign_ilm", $updateentry);
+      if (isset($updateentry->editingbehavior)) {
+        $updateentry->timemodified = time();
+        $DB->update_record("iassign_ilm", $updateentry);
         }
       }
 
-      // Add iassign_allsubmissions table
-      $table = new xmldb_table('iassign_allsubmissions');
+    // Add iassign_allsubmissions table
+    $table = new xmldb_table('iassign_allsubmissions');
 
-      if (!$dbman->table_exists($table)) {
-        $field1 = new xmldb_field('id');
-        $field1->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null);
+    if (!$dbman->table_exists($table)) {
+      $field1 = new xmldb_field('id');
+      $field1->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null);
 
-        $field2 = new xmldb_field('iassign_statementid');
-        $field2->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null);
+      $field2 = new xmldb_field('iassign_statementid');
+      $field2->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null);
 
-        $field3 = new xmldb_field('userid');
-        $field3->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null);
-        
-        $field4 = new xmldb_field('timecreated');
-        $field4->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null);
+      $field3 = new xmldb_field('userid');
+      $field3->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null);
+      
+      $field4 = new xmldb_field('timecreated');
+      $field4->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null);
 
-        $field5 = new xmldb_field('grade');
-        $field5->set_attributes(XMLDB_TYPE_FLOAT, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null);
+      $field5 = new xmldb_field('grade');
+      $field5->set_attributes(XMLDB_TYPE_FLOAT, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null);
 
-        $field6 = new xmldb_field('answer');
-        $field6->set_attributes(XMLDB_TYPE_TEXT, 'long', null, null, null, null, 'type');
+      $field6 = new xmldb_field('answer');
+      $field6->set_attributes(XMLDB_TYPE_TEXT, 'long', null, null, null, null, 'type');
 
-        $table->addIndex($field1);
-        $table->addField($field2);
-        $table->addField($field3);
-        $table->addField($field4);
-        $table->addField($field5);
-        $table->addField($field6);
+      $table->addIndex($field1);
+      $table->addField($field2);
+      $table->addField($field3);
+      $table->addField($field4);
+      $table->addField($field5);
+      $table->addField($field6);
 
-        $dbman->create_table($table);
-      }
+      $dbman->create_table($table);
+      } // if (!$dbman->table_exists($table))
+
+    // Update file_jar field:
+    try {
+      $DB->execute("ALTER TABLE {iassign_ilm} DROP INDEX {iassilm_fil_uix}");
+    } catch (Exception $ex) {}
 
-    } // if ($oldversion < 2020112000) { 
+    } // if ($oldversion < 2020122900)
 
   // log event -----------------------------------------------------
   if (class_exists('plugin_manager'))

+ 49 - 40
iassign_form.php

@@ -18,7 +18,9 @@
  *   + Fix error in sql query for var $igeom.
  * - v 1.1 2013/07/12
  *   + Fix error messages of 'setType' in debug mode for hidden fields.
- * 
+ *
+ * @calledby ./locallib.php: function add_edit_iassign(): $mform = new mod_iassign_form(null, null, null, null, array('id'=>'mform1'));
+ *
  * @author Patricia Alves Rodrigues
  * @author Leônidas O. Brandão
  * @version v 1.5 2013/09/19
@@ -59,13 +61,13 @@ class mod_iassign_form extends moodleform {
     $id = $COURSE->cm;
     foreach ($igeom as $item)
       $idigeom = $item->id; // get the last id of iGeom
-    
+
     // Get recently used ilm id: @igor
     $params = array('curso' => $COURSE->id);
     $result_recent = $DB->get_record_sql(
       "SELECT stm.iassign_ilmid FROM {iassign_statement} stm, {iassign} ias
        WHERE stm.iassignid = ias.id AND ias.course=:curso ORDER BY stm.id DESC LIMIT 1", $params);
-    
+
     $all_ilm = $DB->get_records('iassign_ilm', array('enable' => 1)); // or use ./lib.php function: $all_ilm = search_iLM(1);
     $iassigns = $DB->get_records('iassign_statement', array('iassignid' => $COURSE->iassignid));
 
@@ -298,29 +300,35 @@ class mod_iassign_form extends moodleform {
     //TODO Assim o '/lib/formslib.php : get_data()' destroi o campo 'iassign_ilmid'...
     $html_group = get_string("group", "iassign") . " HTML";
     $java_group = get_string("group", "iassign") . " Java";
-    
+
 
     $arrayHTML = array();
     $arrayJava = array();
 
     for ($ii=0; $ii<$num_iLM_html; $ii++) {
       $arrayHTML[$list_html_id[$ii]] = $list_html[$ii];
-    }
+      }
     for ($ii=0; $ii<$num_iLM_java; $ii++) {
       $arrayJava[$list_applets_id[$ii]] = $list_applets[$ii];
-    }
+      }
 
     $selectElems = array(
       $html_group => $arrayHTML,
       $java_group => $arrayJava
-    );
- 
+      );
+
     $ilm_select = $mform->addElement('selectgroups', 'iassign_ilmid', get_string('choose_iLM', 'iassign'), $selectElems);
     $mform->addHelpButton('iassign_ilmid', 'choose_iLM', 'iassign');
-    
-    if ($result_recent && isset($result_recent->iassign_ilmid)) {
-      $code_javascript .= ' <script>  document.forms[0].iassign_ilmid.value = ' . $result_recent->iassign_ilmid . '</script>' ;
-    }
+
+    if (isset($this->_customdata['iassign_ilmid'])) { // if it is first acces, define 'iassign_ilmid'
+      // It is defined in "locallib.php:add_edit_iassign()": $mform = new mod_iassign_form(null, array('id'=>'mform1', 'iassign_ilmid'=>$param->iassign_ilmid));
+      $iassign_ilmid = $this->_customdata['iassign_ilmid'];
+      $code_javascript .= ' <script>  document.forms[0].iassign_ilmid.value = ' . $iassign_ilmid . '</script>' . "\n";
+      }
+    else
+    if ($result_recent && isset($result_recent->iassign_ilmid)) { // try the last iLM used...
+      $code_javascript .= ' <script>  document.forms[0].iassign_ilmid.value = ' . $result_recent->iassign_ilmid . '</script>' . "\n";
+      }
  
     //TODO Adaptives to use API of MoodleForm
     // addOption($optgroup, $text, $value, $attributes=null)
@@ -350,16 +358,16 @@ class mod_iassign_form extends moodleform {
       $fileurl = $CFG->wwwroot . "/pluginfile.php/" . $file->get_contextid() . "/mod_iassign/exercise" . '/' . $file->get_itemid() . $file->get_filepath() . $file->get_filename();
       $filename = $file->get_filename();
       }
-    //D echo "123";
+
     $html_div = '<div id="fitem_id_iassign_file_id" class="fitem required fitem_fgroup" style="padding: 35px; padding-left: 0;">';
     $html_div .= '<div class="fitemtitle col-md-3" style="padding: 0; float: left;">' . get_string('choose_file', 'iassign'); // 'Choose the file with the iLM activity'
-    
+
     $html_div .= '<span><a><i class="icon fa fa-exclamation-circle text-danger fa-fw " title="' . get_string('requiredelement', 'form') . '" aria-label="' . get_string('requiredelement', 'form') . '" style="float: right; cursor: help; padding-right: 15px;"></i></a></span></div>';
-    
+
     $html_div .= '<div class="felement fselect" id="error_message_file"><div class="file_iassign" id="file_border" style="display: inline;margin-left: 14px;border: 1px solid #cecfd1;padding: 8px;padding-right: 8px;border-radius: 4px;padding-right: 2px;">';
 
     $html_div .= '<i class="icon fa fa-file-text-o fa-fw" id="icon_doc" style="color: #8f8f8f;"></i><span id="iassign_file_link" style="color:#000000;"><a href="' . $fileurl . '" target="_blank" title="' . get_string('download_file', 'iassign') . $filename . '">' . $filename . '</a></span>';
-    
+
     if ($fileurl != "")
       $html_div .= '&nbsp;&nbsp;&nbsp;';
     $html_div .= '<input onclick="view_ilm_manager()" name="add_ilm" value="' . get_string('add_ilm', 'iassign') . '" type="button" id="id_add_ilm"/></div>';
@@ -531,33 +539,34 @@ class mod_iassign_form extends moodleform {
       if ($value == 0) {
         $errors['iassign_ilmid_t'] = get_string('required_iassign_file', 'iassign');
 
-        echo "<script>
-              window.onload = function(e){ 
-                document.getElementById('error_message_file').innerHTML += '<span style=\"font-size: 80%;color: #d9534f; margin-left: 1em;\">".get_string('required_iassign_file', 'iassign')."</span>';
-                document.getElementById('file_border').style.borderColor = '#d9534f';
-              } </script>";
-        } else {
-          $fs = get_file_storage(); // Get reference to all files in Moodle data
-          $file = $fs->get_file_by_id($value);
-
-          if ($file) {
-            // Verify if file extension is correct to iLM
-            $iassign_ilm = $DB->get_record('iassign_ilm', array('id' => $data['iassign_ilmid']));
-            
-            echo "<script>
-              window.onload = function(e){ 
-                document.getElementById('iassign_file_link').innerHTML = '".$file->get_filename()."&nbsp;&nbsp;&nbsp;';";
-                
-            if ($iassign_ilm->extension != pathinfo($file->get_filename(), PATHINFO_EXTENSION)) {
-              $errors['iassign_ilmid_t'] = get_string('incompatible_extension_file', 'iassign');
-
-              echo "document.getElementById('error_message_file').innerHTML += '<span style=\"font-size: 80%;color: #d9534f; margin-left: 1em;\">".get_string('incompatible_extension_file', 'iassign')."</span>';
-                    document.getElementById('file_border').style.borderColor = '#d9534f';";
+        print "<script>
+   window.onload = function (e) {
+     document.getElementById('error_message_file').innerHTML += '<span style=\"font-size: 80%;color: #d9534f; margin-left: 1em;\">".get_string('required_iassign_file', 'iassign')."</span>';
+     document.getElementById('file_border').style.borderColor = '#d9534f';
+     } </script>\n";
+        }
+      else {
+        $fs = get_file_storage(); // Get reference to all files in Moodle data
+        $file = $fs->get_file_by_id($value);
+
+        if ($file) {
+          // Verify if file extension is correct to iLM
+          $iassign_ilm = $DB->get_record('iassign_ilm', array('id' => $data['iassign_ilmid']));
+
+          print "<script>
+   window.onload = function (e) {
+     document.getElementById('iassign_file_link').innerHTML = '".$file->get_filename()."&nbsp;&nbsp;&nbsp;';\n";
+
+          if ($iassign_ilm->extension != pathinfo($file->get_filename(), PATHINFO_EXTENSION)) {
+            $errors['iassign_ilmid_t'] = get_string('incompatible_extension_file', 'iassign');
+
+            print "     document.getElementById('error_message_file').innerHTML += '<span style=\"font-size: 80%;color: #d9534f; margin-left: 1em;\">".get_string('incompatible_extension_file', 'iassign')."</span>';
+     document.getElementById('file_border').style.borderColor = '#d9534f';\n";
             }
 
-            echo "} </script>";
+          print "     } </script>\n";
           }
-          
+
         }
       }
 

+ 1 - 1
ilm_handlers/html5.php

@@ -190,7 +190,7 @@ class html5 implements ilm_handle {
     if ($view_teacherfileversion) { // get the exercise in Moodle data (teacher file)
       $fileid = "";
       $fs = get_file_storage();
-      $files = $fs->get_area_files($context->id, 'mod_iassign', 'exercise', $iassign_statement_activity_item->file); // iassign_statement_activity_item = table 'iassign_statement'
+      $files = $fs->get_area_files($context->id, 'mod_iassign', 'exercise', $iassign_statement_activity_item->filesid); // iassign_statement_activity_item = table 'iassign_statement'
       if ($files) {
         foreach ($files as $value) {
           if ($value->get_filename() != '.')

+ 5 - 5
ilm_manager.php

@@ -116,7 +116,7 @@ if ($id>0) { // if reach here by iLM get request, id is not defined!
   $context = context_course::instance($id);
   }
 
-$url = $CFG->wwwroot . "/mod/iassign/ilm_manager.php?iLM_PARAM_Authoring=true&from=$from&id=$id&ilmid=$ilmid";
+$url = $CFG->wwwroot . "/mod/iassign/ilm_manager.php?iLM_PARAM_Authoring=true&from=" . $from . "&id=" . $id . "&ilmid=" . $ilmid;
 
 //xx $course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST); //QUARANTINE it is not necessary to present the course in the header...
 $iassign_ilm = $DB->get_record('iassign_ilm', array('id' => $ilmid));
@@ -234,7 +234,7 @@ if (has_capability('mod/iassign:editiassign', $context, $USER->id)) {
       }
     } // if ($action)
 
-  $mform = new ilm_manager_form();
+  $mform = new ilm_manager_form(); // ./mod/iassign/ilm_manager_form.php
   $param = new stdClass();
   $param->id = $id;
   $param->from = $from;
@@ -243,7 +243,7 @@ if (has_capability('mod/iassign:editiassign', $context, $USER->id)) {
   $mform->set_data($param);
 
   if ($mform->is_cancelled()) {
-    redirect(new moodle_url("/course/view.php?id=$id"));
+    redirect(new moodle_url("/course/view.php?id=" . $id));
     }
   else if ($formdata = $mform->get_data()) { // if exists '$mform->get_data()' use with '$formdata'
     $fs = get_file_storage();
@@ -255,7 +255,7 @@ if (has_capability('mod/iassign:editiassign', $context, $USER->id)) {
       }
 
     if ($newfilename = $mform->get_new_filename('file')) {
-      $url = $CFG->wwwroot . "/mod/iassign/ilm_manager.php?from=$formdata->from&id=$id&ilmid=$ilmid&dirid=$formdata->dirid";
+      $url = $CFG->wwwroot . "/mod/iassign/ilm_manager.php?from=" . $formdata->from . "&id=" . $id . "&ilmid=" . $ilmid . "&dirid=" . $formdata->dirid;
 
       $file_extension_array = explode(".", $newfilename);
       $index_last_ext = count($file_extension_array) - 1;
@@ -320,7 +320,7 @@ if (has_capability('mod/iassign:editiassign', $context, $USER->id)) {
       $fs->delete_area_files($contextuser->id, 'user', 'draft', $formdata->file);
       } // if ($newfilename = $mform->get_new_filename('file'))
 
-    redirect(new moodle_url($url));
+   redirect(new moodle_url($url));
     } // else if ($formdata = $mform->get_data()) - 172/271,10
 
   print $OUTPUT->header();

+ 5 - 5
ilm_manager_form.php

@@ -18,15 +18,15 @@
  * 		+ Fix error messages of 'setType' in debug mode for hidden fields.
  * - v 1.1 2013/06/26
  * 		+ Remove the button of choose iLM (ID of iLM send of parent page).
- * 
+ *
  * @author Patricia Alves Rodrigues
  * @author Leônidas O. Brandão
  * @version v 1.7 2013/10/24
  * @package mod_iassign_ilm
  * @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
  */
 
@@ -57,8 +57,8 @@ class ilm_manager_form extends moodleform {
       if (ilmid == null || ilmid == '')
 	ilmid = document.getElementById('id_iassign_ilmid').value;
 	dirid = document.forms[0].dirid.value;
-	window.location='$CFG->wwwroot/mod/iassign/ilm_manager.php?from=$from&id=$id&action=new&ilmid='+ilmid+'&dirid='+dirid;
-        }             
+	window.location='$CFG->wwwroot/mod/iassign/ilm_manager.php?from=" . $from . "&id=" . $id . "&action=new&ilmid='+ilmid+'&dirid='+dirid;
+        }
   //]]>
   </script>\n";
 

File diff suppressed because it is too large
+ 328 - 321
locallib.php


+ 14 - 10
settings_form.php

@@ -65,7 +65,8 @@ class mod_ilm_form extends moodleform {
     global $CFG, $COURSE, $USER, $DB;
     global $description; // defined in 'settings_ilm.php'
 
-    $mform = & $this->_form;
+//    $mform = & $this->_form;
+$mform = $this->_form; //leo
 
     if ($CFG->action_ilm != 'import') {
 
@@ -201,11 +202,11 @@ class mod_ilm_form extends moodleform {
           $mform->addElement('static', 'name_ilm', get_string('name_ilm', 'iassign'));
           $mform->addElement('hidden', 'name');
           $mform->setType('name', PARAM_TEXT);
-        } 
+          } 
         else {
           $mform->addElement('text', 'name', get_string('name_ilm', 'iassign'), array('size' => '55', 'onchange' => 'search_name(this.value);'));
           $mform->setType('name', PARAM_TEXT);
-        }
+          }
 
         // Adding the standard "version" field
         $mform->addElement('text', 'version', get_string('version_ilm', 'iassign'), array('size' => '55'));
@@ -283,13 +284,14 @@ class mod_ilm_form extends moodleform {
 
         // Adding the standard "submissionbehavior" field
         $mform->addElement('text', 'submissionbehavior', get_string('auto_evaluate', 'iassign'));
+        $mform->setType('submissionbehavior', PARAM_INT);
 
         // Adding the "data_file_jar" fieldset, where all the common settings are showed
         $mform->addElement('header', 'data_file_html', get_string('data_file_html', 'iassign'));
 
         // Adding static text
         $mform->addElement('static', 'data_file_html_static', get_string('data_file_html_static', 'iassign'));
-        }
+        } // if ($CFG->action_ilm != 'add')
 
       // // Upload file ilm
       // $mform->addElement('header', 'upload_jar', get_string('upload_jar', 'iassign'));
@@ -298,11 +300,11 @@ class mod_ilm_form extends moodleform {
       // $mform->addElement('filemanager', 'file', null, null, $options);
 
       $mform->addElement('header', 'upload_jar', get_string('upload_jar', 'iassign'));
-      
+
       $options = array('subdirs' => 0, 'maxbytes' => $CFG->userquota, 'maxfiles' => 1, 'accepted_types' => array('*'));
       $mform->addElement('filepicker', 'file', null, null, $options);
       $mform->addRule('file', get_string('required', 'iassign'), 'required');
-      
+
       if ($CFG->action_ilm == 'add' || $CFG->action_ilm == 'copy' || $CFG->action_ilm == 'new_version')
         $mform->addRule('file', get_string('required', 'iassign'), 'required');
 
@@ -322,8 +324,10 @@ class mod_ilm_form extends moodleform {
       $mform->addElement('hidden', 'author');
       $mform->setType('author', PARAM_TEXT);
       $mform->addElement('hidden', 'action');
-      $mform->setType('action', PARAM_TEXT);
+
+      $mform->setType('action', PARAM_TEXT); //DEBUG: is it necessary?
       $mform->addElement('hidden', 'timecreated');
+
       $mform->setType('timecreated', PARAM_TEXT);
       $mform->addElement('hidden', 'timemodified');
       $mform->setType('timemodified', PARAM_TEXT);
@@ -341,11 +345,11 @@ class mod_ilm_form extends moodleform {
       $mform->addElement('filepicker', 'file', null, null, $options);
       $mform->addRule('file', get_string('required', 'iassign'), 'required');
 
-      $mform->addElement('hidden', 'action');
+      $mform->addElement('hidden', 'action'); //DEBUG: is it necessary?
       $mform->setType('action', PARAM_TEXT);
       }
 
     $this->add_action_buttons();
-    }
+    } // function definition()
 
-  }
+  } // class mod_ilm_form extends moodleform

+ 11 - 6
settings_ilm.php

@@ -63,15 +63,19 @@ if ($action == 'edit') { // Edit data of an iLM => processed in 'settings_form.p
   $title = get_string('edit_ilm', 'iassign') . $OUTPUT->help_icon('add_ilm_iassign', 'iassign');
   $PAGE->set_title($title);
 
+  // Get all fields of this iLM: name, type, set_lang, description_lang, author, action, timecreated, timemodified, parent, ...
   $param = ilm_settings::add_edit_copy_ilm($ilm_id, $action); // locallib.php: class ilm_settings: add_edit_copy_ilm($ilm_id, $action)
-  //D echo "settings_ilm.php: edit: param->description="; print_r($param->description); echo "<br/>";
+
+  //D echo "settings_ilm.php: edit: $title"; // echo "param->description="; print_r($param->description); 
   //D $description = $param->description_lang; // used to present the iLM description in 'settings_form.php'
   //D $description = $param->description; //TODO in 'settings_form.php' it does NOT present the description!!!
-  //D $param->description = $param->description_lang;
   $description = $param->description_lang; // used to present the iLM description in 'settings_form.php' - {"en":"...","pt":"..."}
 
-  $mform = new mod_ilm_form($param); // in 'settings_form.php': class mod_ilm_form
+  $mform = new mod_ilm_form(); // in 'settings_form.php': class mod_ilm_form
+  //DEBUG: do NOT use "mod_ilm_form($param)" Warning: htmlspecialchars() expects parameter 1 to be string, object given in /var/www/html/saw/lib/pear/HTML/Common.php on line 177
+  //DEBUg: since bellow fills form data
   $mform->set_data($param);
+
   if ($mform->is_cancelled()) {
     close_window();
     die;
@@ -83,10 +87,11 @@ if ($action == 'edit') { // Edit data of an iLM => processed in 'settings_form.p
     die;
     }
 
-  print($OUTPUT->header());
-  print($OUTPUT->heading($title));
+  print $OUTPUT->header();
+  print $OUTPUT->heading($title); // put the header title
   $mform->display();
-  print($OUTPUT->footer());
+  print $OUTPUT->footer();
+
   die;
   } // if ($action == 'edit')
 else

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