Ver Fonte

Update 'settings_form.php'

Synchronizing iAssign Git with the current iAssign stable version (until Moodle 5.0).
Small changes in: ilm_manager.php, lang/*/iassign.php
Bigger changes in: ilm_manager_form.php, lib.php, settings_form.php, settings.php, version.php, backup/moodle2/*.php, ilm_debug/escreva.php, ilm_handlers/java.php
New iLM versions: iassign/ilm/iFractions/, iassign/ilm/iHanoi/, iassign/ilm/iVProg/
New file (was missing): settings_activities.php
leo há 2 semanas atrás
pai
commit
1c53f3d629
1 ficheiros alterados com 72 adições e 27 exclusões
  1. 72 27
      settings_form.php

+ 72 - 27
settings_form.php

@@ -3,10 +3,12 @@
 /**
  * Form to add and edit interactive Learning Module (iLM).
  * The fields are initially filled at locallib.php:add_edit_copy_ilm($ilm_id, $action)
- * The final processing is performed by 'locallib.php', that is called bye './settings_ilm.php' (with ilm_settings::copy_new_version_ilm($formdata))
+ * The final processing is performed by 'locallib.php', that is called by './settings_ilm.php' (with ilm_settings::copy_new_version_ilm($formdata))
  * then by 'ilm_handlers/(html5 or java).php' with copy_new_version_ilm($param, $files_extract)'
  * 
  * Release Notes:
+ * - v 2.0.1 2024/05/10
+ *   + Improved messages to "Add iLM" and "Import iLM"
  * - v 2.0.1 2022/09/15
  *   + Considering table 'iassign_ilm': messages to fields 'evaluate', 'reevaluate', 'editingbehavior'; fixes to allow the edition of 'reevaluate', 'editingbehavior'
  * - v 1.6.3 2020/04/28
@@ -38,8 +40,8 @@
  * @see ./ilm_handlers/html5.php : save_ilm_by_xml($application_xml, $files_extract): return null;
  * 
  * @author Patricia Alves Rodrigues
- * @author Leônidas O. Brandão
- * @version v 1.6 2013/12/12
+ * @author Leo^nidas de Oliveira Branda~o
+ * @version v 2.0.2 2023/05/10
  * @package mod_iassign_settings
  * @since 2010/09/27
  * @copyright iMatica (<a href="http://www.matematica.br">iMath</a>) - Computer Science Dep. of IME-USP (Brazil)
@@ -189,7 +191,7 @@ class mod_ilm_form extends moodleform {
       //-------------------------------------------------------------------------------
       /// Adding the "data_ilm" fieldset, where all the common settings are showed
 
-      if ($CFG->action_ilm != 'add') {
+      if (true) { // here are the fields that will be used to new entry of table {iassign_ilm}
 
         // $mform->addElement('header', 'type_ilm', get_string('type_ilm', 'iassign'));
         // // Adding the select option for HTML5 or Java
@@ -199,7 +201,23 @@ class mod_ilm_form extends moodleform {
         // $mform->addHelpButton('ilm_type', 'ilm_type', 'iassign');
         // $mform->addElement('header', 'data_ilm', get_string('data_ilm', 'iassign'));
 
-        // Adding the standard "name" field
+        // Add information about this Importer: add_ilm_iassign_help="See a more complete description of iLM"; add_ilm_iassign_about_ilm=
+        // A <a href="https://www.matematica.br/ia/#iLM" title="see a more complete description" target="_blank">iLM</a> is any education Web system
+//        $msg1 = get_string('add_ilm_iassign_help', 'iassign');
+//        $msg2 = get_string('add_ilm_iassign_about_ilm', 'iassign');
+//        $html_div  = '<div id="form_import_explain" class="box generalbox formsettingheading" style="padding: 35px; padding-left: 0;">' . $msg2 . "</div>\n";
+//        $html_div .= '<div id="form_import_required" class="fitem required fitem_fgroup" style="padding: 35px; padding-left: 0;">' . chr(13);
+//        $html_div .= '<span><a><i class="icon fa fa-exclamation-circle text-danger fa-fw " title=""></i>'. $msg . '</span></div>' . "\n";
+
+        // Text explaining the "Add iLM" process and the meaning of the 'ilm-application.xml' description file
+        $msg1 = get_string('add_ilm_iassign_about_ilm', 'iassign'); // 
+        $msg2 = get_string('add_ilm_iassign_help', 'iassign'); // 
+        $html_div  = '<div id="form_import_explain" class="box generalbox formsettingheading" style="padding: 35px; padding-left: 0;">' . $msg1 . "</div>\n";
+        $html_div .= '<div id="form_import_explain" class="fitem required fitem_fgroup" style="padding: 35px; padding-left: 0;">' . chr(13);
+        $html_div .= '<span><a><i class="icon fa fa-exclamation-circle text-danger fa-fw " title=""></i>'. $msg2 . "</span></div>\n";
+        $mform->addElement('html', $html_div);
+
+        // Adding the standard "name" field: {iassign_ilm}.name
         if ($CFG->action_ilm != 'add') {
           $mform->addElement('static', 'name_ilm', get_string('name_ilm', 'iassign'));
           $mform->addElement('hidden', 'name');
@@ -210,21 +228,27 @@ class mod_ilm_form extends moodleform {
           $mform->setType('name', PARAM_TEXT);
           }
 
-        // Adding the standard "version" field
+        // Adding the standard "version" field: {iassign_ilm}.version
         $mform->addElement('text', 'version', get_string('version_ilm', 'iassign'), array('size' => '55'));
         $mform->setType('version', PARAM_TEXT);
         $mform->addHelpButton('version', 'version_ilm', 'iassign');
  
-        // Adding the type of iLM
-        $mform->addElement('static', 'ilm_type', get_string('type_ilm', 'iassign'));
-        $mform->addElement('hidden', 'type');
-        $mform->setType('type', PARAM_TEXT);
-
-        // Adding the standard "url" field
+        // Adding the type of iLM: {iassign_ilm}.type
+        // $mform->addElement('static', 'ilm_type', get_string('type_ilm', 'iassign'));
+        // $mform->addElement('hidden', 'type'); $mform->setType('type', PARAM_TEXT);
+        $selectElem = array("HTML5", "Java"); // 0 = package JavaScript; 1 = package Java (JAR)
+        $mform->addElement('select', 'type', get_string('type_ilm', 'iassign'), $selectElem);
+        $mform->setDefault('type', 0); // default is "HTML5"
+        $mform->addHelpButton('type', 'type_ilm', 'iassign');
+
+        // Adding the standard "url" field: {iassign_ilm}.url
         $mform->addElement('text', 'url', get_string('url_ilm', 'iassign'), array('size' => '55'));
         $mform->setType('url', PARAM_TEXT);
-
-        $mform->addElement('select', 'lang', get_string('language_label', 'iassign'), get_string_manager()->get_list_of_translations(), array('onChange' => 'change_language(this.value);'));
+	  
+        // ./lib/moodlelib.php: function get_string_manager($forcereload=false): $singleton=new core_string_manager_standard($CFG->langotherroot, $CFG->langlocalroot, $translist, $transaliases);
+        $list_of_lang = get_string_manager()->get_list_of_translations(); // ./lib/classes/string_manager_standard.php: class core_string_manager_standard implements core_string_manager
+        $array_lang = array('onChange' => 'change_language(this.value);');
+        $mform->addElement('select', 'lang', get_string('language_label', 'iassign'), $list_of_lang, $array_lang); // languages
         $mform->setDefault('lang', current_language());
 
         //D Came from 'settings_ilm.php: if ($action == 'edit') 
@@ -234,10 +258,10 @@ class mod_ilm_form extends moodleform {
         //D echo "settings_form.php: param="; print_r($param); echo "<br/>";
         //D echo "description=" . $description . "<br/>";
 	  
-        // Adding the standard "description" field
+        // Adding the standard "description" field: {iassign_ilm}.description
         //moodle2 $mform->addElement('htmleditor', 'description', get_string('description', 'iassign'));
         //TODO $mform->addElement('editor', 'description', get_string('description', 'iassign'), $description); // moodle3 => 'editor', but not working
-        $mform->addElement('text', 'description', get_string('description', 'iassign'), array('size' => '80'));//, $description, 200); //moodle3
+        $mform->addElement('text', 'description', get_string('description', 'iassign'), array('size' => '80'));
         $mform->setType('description', PARAM_RAW);
 
         // Adding the "data_file_jar" fieldset, where all the common settings are showed ---
@@ -246,12 +270,15 @@ class mod_ilm_form extends moodleform {
 
         $mform->addElement('static', 'file_jar_static', get_string('fields_info', 'iassign')); // non editable text
 
-        // Fields: file_jar  file_class
+        // Field 'file_jar': {iassign_ilm}.file_jar
         $mform->addElement('text', 'file_jar', get_string('file_jar_path', 'iassign'), array('size' => '55')); // editable text
-        $mform->setType('file_jar', PARAM_TEXT);
-	  
+        $mform->setType('file_jar', PARAM_TEXT); // 'The iLM name of its main directory (HTML/JS) or iLM package (Java JAR)'
+        $mform->addHelpButton('file_jar', 'file_jar_help', 'iassign'); // messages 'file_jar_help' and 'file_jar_help_help'
+
+	// Field 'file_class': {iassign_ilm}.file_class
         $mform->addElement('text', 'file_class', get_string('file_class', 'iassign')); // editable text
-        $mform->setType('file_class', PARAM_TEXT);	  
+        $mform->setType('file_class', PARAM_TEXT);
+        $mform->addHelpButton('file_class', 'file_class_form', 'iassign'); // messages 'file_class_form_help' and 'file_class_form_help_help'
 
         //TODO : acho que vale a pena incluir o campo 'file_jar'...
         // $mform->addElement('static', 'file_jar', get_string('file_jar', 'iassign'));
@@ -262,23 +289,23 @@ class mod_ilm_form extends moodleform {
         //TD $mform->setType('file_jar', PARAM_TEXT);
         //TD $mform->addHelpButton('file_jar', 'file_jar_form_help', 'iassign'); // first => field name; second => text to be presented
 
-        // Adding the standard "extension" field
+        // Adding the standard "extension" field: {iassign_ilm}.extension
         $mform->addElement('text', 'extension', get_string('extension', 'iassign'), array('size' => '30', 'onchange' => 'search_extension(this.value);'));
         $mform->setType('extension', PARAM_TEXT);
         //$mform->addRule('extension', get_string('required', 'iassign'), 'required');
         $mform->addHelpButton('extension', 'extension', 'iassign');
 
-        // Adding the standard "width" field
+        // Adding the standard "width" field: {iassign_ilm}.width
         $mform->addElement('text', 'width', get_string('width', 'iassign'), array('size' => '10'));
         $mform->setType('width', PARAM_TEXT);
         //$mform->addRule('width', get_string('required', 'iassign'), 'required');
 
-        // Adding the standard "height" field
+        // Adding the standard "height" field: {iassign_ilm}.height
         $mform->addElement('text', 'height', get_string('height', 'iassign'), array('size' => '10'));
         $mform->setType('height', PARAM_TEXT);
         //$mform->addRule('height', get_string('required', 'iassign'), 'required');
 
-        // Adding the field "evaluate"
+        // Adding the field "evaluate": {iassign_ilm}.evaluate
         $mform->addElement('selectyesno', 'evaluate', get_string('auto_evaluate', 'iassign'));
         $mform->setDefault('evaluate', 1);
         //$mform->addRule('evaluate', get_string('required', 'iassign'), 'required');
@@ -299,11 +326,16 @@ class mod_ilm_form extends moodleform {
         $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
+        // "Basic information about the new iLM"
+        // Adding the "data_file_html" fieldset, where all the common settings are showed
         $mform->addElement('header', 'data_file_html', get_string('data_file_html', 'iassign'));
+        // Adding static text --- do not use this options (since it produce a frame with few columns), prefer 'html' bellow
+        // $mform->addElement('static', 'data_file_html_static', get_string('data_file_html_static', 'iassign'));
+        $msg = get_string('data_file_html_static', 'iassign'); // "To add an iLM (encoded in HTML/JS), it is sufficient to submit the file in the field below."
+        $html_div  = '<div id="form_import_explain" class="box generalbox formsettingheading" style="padding: 35px; padding-left: 0;">' . $msg . "</div>\n";
+        $mform->addElement('html', $html_div);
+	  
 
-        // 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
@@ -352,7 +384,20 @@ class mod_ilm_form extends moodleform {
       $mform->addElement('html', $code_javascript);
       } // if ($CFG->action_ilm != 'import')
     else {
+      // This is used to insert new iLM using the IPZ package
+      // In it all fields to the table {iassign_ilm} is defined by the file 'ilm-application.xml'
+
+      // Header: Upload package iLM
       $mform->addElement('header', 'upload_ilm', get_string('upload_ilm', 'iassign'));
+
+      // Text explaining the Import process and the meaning of the 'ilm-application.xml' description file
+      $msg1 = get_string('import_ilm_about', 'iassign'); // Under this option, it is possible to insert a new iLM ...
+      $msg2 = get_string('import_ilm_help', 'iassign'); // Import a new iLM , using a IPZ package: it must have the file 'ilm-application.xml'...
+      $html_div  = '<div id="form_import_explain" class="box generalbox formsettingheading" style="padding: 35px; padding-left: 0;">' . $msg1 . "</div>\n";
+      $html_div .= '<div id="form_import_explain" class="fitem required fitem_fgroup" style="padding: 35px; padding-left: 0;">' . chr(13);
+      $html_div .= '<span><a><i class="icon fa fa-exclamation-circle text-danger fa-fw " title=""></i>'. $msg2 . "</span></div>\n";
+      $mform->addElement('html', $html_div);
+
       //$mform->setExpanded('upload_ilm');
       $options = array('subdirs' => 0, 'maxbytes' => $CFG->userquota, 'maxfiles' => 1, 'accepted_types' => array('*'));
       $mform->addElement('filepicker', 'file', null, null, $options);