Browse Source

Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x

Yannick Warnier 8 years ago
parent
commit
233833f6c9
81 changed files with 1116 additions and 697 deletions
  1. 8 4
      .travis.yml
  2. 1 1
      app/Migrations/Schema/V111/Version111.php
  3. 1 1
      composer.json
  4. 6 1
      main/admin/configure_inscription.php
  5. 1 3
      main/admin/course_add.php
  6. 1 2
      main/admin/course_edit.php
  7. 0 6
      main/admin/course_export.php
  8. 1 1
      main/admin/course_list.php
  9. 1 2
      main/admin/course_request_edit.php
  10. 1 1
      main/admin/legal_add.php
  11. 3 1
      main/admin/settings.lib.php
  12. 25 21
      main/admin/special_exports.php
  13. 1 1
      main/admin/user_add.php
  14. 1 1
      main/admin/user_edit.php
  15. 4 2
      main/admin/user_information.php
  16. 23 19
      main/admin/user_update_import.php
  17. 2 2
      main/auth/courses_controller.php
  18. 1 2
      main/auth/inscription.php
  19. 1 1
      main/auth/profile.php
  20. 2 6
      main/course_info/download.php
  21. 4 1
      main/course_info/infocours.php
  22. 1 3
      main/create_course/add_course.php
  23. 5 5
      main/exercise/adminhp.php
  24. 22 9
      main/exercise/exercise.class.php
  25. 9 8
      main/exercise/exercise.php
  26. 0 2
      main/exercise/hotpotatoes.php
  27. 1 1
      main/exercise/question_pool.php
  28. 12 1
      main/gradebook/exercise_jump.php
  29. 0 1
      main/gradebook/gradebook_add_link.php
  30. 1 2
      main/gradebook/gradebook_edit_cat.php
  31. 53 31
      main/gradebook/lib/be/category.class.php
  32. 85 56
      main/gradebook/lib/be/exerciselink.class.php
  33. 4 2
      main/gradebook/lib/be/studentpublicationlink.class.php
  34. 31 41
      main/gradebook/lib/fe/catform.class.php
  35. 49 89
      main/gradebook/lib/fe/evalform.class.php
  36. 39 26
      main/gradebook/lib/fe/linkaddeditform.class.php
  37. 13 6
      main/gradebook/lib/fe/linkform.class.php
  38. BIN
      main/img/icons/22/cd_na.png
  39. 1 1
      main/inc/ajax/exercise.ajax.php
  40. 1 1
      main/inc/ajax/work.ajax.php
  41. 2 2
      main/inc/lib/api.lib.php
  42. 1 1
      main/inc/lib/events.lib.php
  43. 1 1
      main/inc/lib/exercise.lib.php
  44. 0 3
      main/inc/lib/extra_field.lib.php
  45. 19 0
      main/inc/lib/formvalidator/Element/DateRangePicker.php
  46. 84 0
      main/inc/lib/formvalidator/Element/FloatNumber.php
  47. 18 18
      main/inc/lib/formvalidator/Element/SelectLanguage.php
  48. 19 15
      main/inc/lib/formvalidator/Element/SelectTheme.php
  49. 4 4
      main/inc/lib/formvalidator/Element/Url.php
  50. 3 2
      main/inc/lib/formvalidator/Element/receivers.php
  51. 232 0
      main/inc/lib/formvalidator/FormValidator.class.php
  52. 9 9
      main/inc/lib/formvalidator/Rule/Date.php
  53. 14 15
      main/inc/lib/formvalidator/Rule/FileName.php
  54. 1 1
      main/inc/lib/myspace.lib.php
  55. 0 1
      main/inc/lib/pdf.lib.php
  56. 79 151
      main/inc/lib/pear/HTML/QuickForm.php
  57. 2 4
      main/inc/lib/pear/HTML/QuickForm/Rule/Regex.php
  58. 3 5
      main/inc/lib/pear/HTML/QuickForm/RuleRegistry.php
  59. 12 20
      main/inc/lib/pear/HTML/QuickForm/email.php
  60. 2 2
      main/inc/lib/pear/HTML/QuickForm/input.php
  61. 0 2
      main/inc/lib/pear/HTML/QuickForm/text.php
  62. 2 5
      main/inc/lib/social.lib.php
  63. 2 0
      main/install/configuration.dist.php
  64. 3 3
      main/lp/lp_list.php
  65. 2 0
      main/messages/inbox.php
  66. 6 1
      main/mySpace/myStudents.php
  67. 1 10
      main/session/session_export.php
  68. 1 1
      main/social/home.php
  69. 1 1
      main/survey/fillsurvey.php
  70. 1 1
      main/template/default/javascript/editor/elfinder_standalone.tpl
  71. 2 2
      main/template/default/social/home.tpl
  72. 1 1
      main/upload/upload_ppt.php
  73. 3 1
      main/work/upload.php
  74. 3 1
      main/work/upload_from_template.php
  75. 1 1
      src/Chamilo/CoreBundle/Component/Editor/Driver/CourseDriver.php
  76. 1 8
      src/Chamilo/CoreBundle/Component/Editor/Driver/PersonalDriver.php
  77. 152 25
      src/Chamilo/CoreBundle/Component/Editor/Finder.php
  78. 7 9
      src/Chamilo/CourseBundle/Component/CourseCopy/CourseBuilder.php
  79. 6 5
      src/Chamilo/CourseBundle/Component/CourseCopy/CourseSelectForm.php
  80. 1 1
      tests/main/inc/lib/events.lib.inc.test.php
  81. 0 1
      tests/test_suite.php

+ 8 - 4
.travis.yml

@@ -14,11 +14,12 @@ before_install:
   - sudo apt-get install -qq apache2 libapache2-mod-fastcgi
   # enable php-fpm
   - sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf
+  - if [[ ${TRAVIS_PHP_VERSION:0:3} == "7.0" ]]; then sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf ; fi
   - sudo a2enmod rewrite actions fastcgi alias
   - echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
   - echo "memory_limit = 2G" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
   - echo "phar.readonly = 0" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
-  - echo "date.timezone = Europe/Paris" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
+  - echo 'date.timezone = "Europe/Paris"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
   - ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm
   # configure apache virtual hosts
   - sudo cp -f tests/travis-apache /etc/apache2/sites-available/default
@@ -60,7 +61,7 @@ before_script:
   # install Chash, a database, and then install Chamilo
   - git clone https://github.com/chamilo/chash
   - cd chash
-  - composer install
+  #- composer install
   - composer update
   - php -d phar.readonly=0 createPhar.php
   - chmod +x chash.phar
@@ -74,10 +75,13 @@ before_script:
   #- sudo php5 chamilo-cli-installer.php -l admin -p admin -U travis -u 'http://localhost/' -X travis -L english -z 'admin@example.com' -f 'John' -g 'Doe' -b '555-5555' -c 'Test campus' -y 'Chamilo' -x 'https://chamilo.org'
   #- cd ../..
   # install Chamilo with Chash - see reference https://github.com/sonnym/travis-ci-drupal-module-example/blob/master/.travis.yml
-  - cd /home/travis/build/chamilo/chamilo-lms
+  # - cd /home/travis/build/chamilo/chamilo-lms
   # There's an issue with Chash, starting in version 1.10, whereby PHP CLI on Travis-ci is PHP5.3, whatever the version you ask for.
   # This effectively breaks the installer and renders these tests useless. We are looking for a solution (for example using containers)
-  - sudo chash chash:chamilo_install --no-interaction --sitename="Chamilo" --site_url="http://localhost/" --institution="Chamilo" --institution_url="https://chamilo.org" --encrypt_method="sha1" --firstname="John" --lastname="Doe" --language="english" --driver="pdo_mysql" --host="localhost" --port="3306" --dbname="chamilo" --dbuser="root" --permissions_for_new_directories="0777" --permissions_for_new_files="0666" --linux-user="www-data" --linux-group="www-data" --username="admin" --password="admin" --email="admin@example.com" --phone="555-5555" 1.10.x
+  - sudo php -d date.timezone="Europe/Paris" chash.php chash:chamilo_install 1.11.x /home/travis/build/chamilo/chamilo-lms --download-package --no-interaction --only-download-package
+  - cd /home/travis/build/chamilo/chamilo-lms
+  - composer update
+  - sudo php -d date.timezone="Europe/Paris" /home/travis/build/chamilo/chamilo-lms/chash/chash.php chash:chamilo_install 1.11.x /home/travis/build/chamilo/chamilo-lms --no-interaction --sitename="Chamilo" --site_url="http://localhost/" --institution="Chamilo" --institution_url="https://chamilo.org" --encrypt_method="sha1" --firstname="John" --lastname="Doe" --language="english" --driver="pdo_mysql" --host="localhost" --port="3306" --dbname="chamilo" --dbuser="root" --permissions_for_new_directories="0777" --permissions_for_new_files="0666" --linux-user="www-data" --linux-group="www-data" --username="admin" --password="admin" --email="admin@example.com" --phone="555-5555"
 
 script:
   # - phpunit -c tests/phpunit

+ 1 - 1
app/Migrations/Schema/V111/Version111.php

@@ -405,7 +405,7 @@ class Version111 extends AbstractMigrationChamilo
 
         $this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'none', 'None')");
         $this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'exercise', 'Exercise')");
-        $this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'lp', 'Learning path')");
+        $this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'lp', 'LearningPath')");
         $this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'exercise_and_lp', 'ExerciseAndLearningPath')");
     }
 

+ 1 - 1
composer.json

@@ -78,7 +78,7 @@
         "szymach/c-pchart": "1.*",
         "aferrandini/phpqrcode": "1.0.1",
         "mpdf/mpdf": "6.1.*",
-        "barryvdh/elfinder-builds": "2.1.0.3",
+        "studio-42/elfinder": "2.1.*",
         "jbroadway/urlify": "dev-master",
         "monolog/monolog": "~1.0",
         "ircmaxell/password-compat": "~1.0.4",

+ 6 - 1
main/admin/configure_inscription.php

@@ -230,7 +230,12 @@ if ($display_all_form) {
 
     //	LANGUAGE
     if (api_get_setting('registration', 'language') == 'true') {
-        $form->addElement('select_language', 'language', get_lang('Language'), '', array('disabled' => 'disabled'));
+        $form->addSelectLanguage(
+            'language',
+            get_lang('Language'),
+            '',
+            array('disabled' => 'disabled')
+        );
     }
 
     //	STUDENT/TEACHER

+ 1 - 3
main/admin/course_add.php

@@ -106,14 +106,12 @@ if (count($languages['name']) === 1) {
     // If there's only one language available, there's no point in asking
     $form->addElement('hidden', 'course_language', $languages['folder'][0]);
 } else {
-    $form->addElement(
-        'select_language',
+    $form->addSelectLanguage(
         'course_language',
         get_lang('Ln'),
         array(),
         array('style' => 'width:150px')
     );
-    $form->applyFilter('select_language', 'html_filter');
 }
 
 if (api_get_setting('teacher_can_select_course_template') === 'true') {

+ 1 - 2
main/admin/course_edit.php

@@ -197,8 +197,7 @@ $form->addText('department_url', get_lang('CourseDepartmentURL'), false, array('
 $form->applyFilter('department_url', 'html_filter');
 $form->applyFilter('department_url', 'trim');
 
-$form->addElement('select_language', 'course_language', get_lang('CourseLanguage'));
-$form->applyFilter('select_language', 'html_filter');
+$form->addSelectLanguage('course_language', get_lang('CourseLanguage'));
 
 $group = array();
 $group[]= $form->createElement('radio', 'visibility', get_lang("CourseAccess"), get_lang('OpenToTheWorld'), COURSE_VISIBILITY_OPEN_WORLD);

+ 0 - 6
main/admin/course_export.php

@@ -18,9 +18,6 @@ $interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAd
 
 set_time_limit(0);
 
-$archivePath = api_get_path(SYS_ARCHIVE_PATH);
-$archiveURL = api_get_path(WEB_CODE_PATH).'course_info/download.php?archive=';
-
 $course_list = CourseManager::get_courses_list();
 $formSent = null;
 $courses = $selected_courses = array();
@@ -47,9 +44,7 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
     }
 
 	if (!empty($courses)) {
-
         $archiveFile = 'export_courses_list_'.api_get_local_time();
-
         $listToExport[] = [
             'Code',
             'Title',
@@ -117,7 +112,6 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
 	}
 }
 
-
 Display:: display_header($tool_name);
 
 $form = new FormValidator('export', 'post', api_get_self());

+ 1 - 1
main/admin/course_list.php

@@ -319,7 +319,7 @@ if (isset ($_GET['search']) && $_GET['search'] === 'advanced') {
         )
     );
 
-    $el = $form->addElement('select_language', 'keyword_language', get_lang('CourseLanguage'));
+    $el = $form->addSelectLanguage('keyword_language', get_lang('CourseLanguage'));
     $el->addOption(get_lang('All'), '%');
     $form->addElement('radio', 'keyword_visibility', get_lang("CourseAccess"), get_lang('OpenToTheWorld'), COURSE_VISIBILITY_OPEN_WORLD);
     $form->addElement('radio', 'keyword_visibility', null, get_lang('OpenToThePlatform'), COURSE_VISIBILITY_OPEN_PLATFORM);

+ 1 - 2
main/admin/course_request_edit.php

@@ -84,8 +84,7 @@ if ($course_validation_feature) {
         $form->addRule('target_audience', get_lang('ThisFieldIsRequired'), 'required');
 
         // Course language.
-        $form->addElement('select_language', 'course_language', get_lang('Ln'));
-        $form->applyFilter('select_language', 'html_filter');
+        $form->addSelectLanguage('course_language', get_lang('Ln'));
 
         // Exemplary content checkbox.
         $form->addElement('checkbox', 'exemplary_content', get_lang('FillWithExemplaryContent'));

+ 1 - 1
main/admin/legal_add.php

@@ -137,7 +137,7 @@ if (isset($_POST['language'])) {
     $form->addElement('html', $buttons);
 
 } else {
-	$form->addElement('select_language', 'language', get_lang('Language'),null,array());
+    $form->addSelectLanguage('language', get_lang('Language'), null, array());
 	$form->addButtonSearch(get_lang('Load'), 'send');
 
 }

+ 3 - 1
main/admin/settings.lib.php

@@ -1711,8 +1711,10 @@ function generateCSSDownloadLink($style)
         $zip = new PclZip($arch);
         // Remove path prefix except the style name and put file on disk
         $zip->create($dir, PCLZIP_OPT_REMOVE_PATH, substr($dir,0,-strlen($style)));
+        $url = api_get_path(WEB_CODE_PATH) . 'course_info/download.php?archive_path=&archive=' . str_replace(api_get_path(SYS_ARCHIVE_PATH), '', $arch);
+
         //@TODO: use more generic script to download.
-        $str = '<a class="btn btn-primary btn-large" href="' . api_get_path(WEB_CODE_PATH) . 'course_info/download.php?archive=' . str_replace(api_get_path(SYS_ARCHIVE_PATH), '', $arch) . '">'.get_lang('ClickHereToDownloadTheFile').'</a>';
+        $str = '<a class="btn btn-primary btn-large" href="' .$url. '">'.get_lang('ClickHereToDownloadTheFile').'</a>';
         Display::display_normal_message($str, false);
     } else {
         Display::addFlash(Display::return_message(get_lang('FileNotFound'), 'warning'));

+ 25 - 21
main/admin/special_exports.php

@@ -22,6 +22,7 @@ $interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAd
 api_protect_admin_script(true);
 $nameTools = get_lang('SpecialExports');
 $export = '';
+$querypath = '';
 
 // include additional libraries
 if (function_exists('ini_set')) {
@@ -43,10 +44,10 @@ $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
 $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
 
 if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form') ||
-    (isset ($_POST['backup_option']) && $_POST['backup_option'] == 'full_backup')
+    (isset($_POST['backup_option']) && $_POST['backup_option'] == 'full_backup')
 ) {
 	$export = false;
-    if (isset ($_POST['action']) && $_POST['action'] == 'course_select_form') {
+    if (isset($_POST['action']) && $_POST['action'] == 'course_select_form') {
         $FileZip = create_zip();
         $to_group_id = 0;
         $sql_session = "SELECT id, name FROM $tbl_session ";
@@ -61,7 +62,7 @@ if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form') ||
             $groupCondition = " (props.to_group_id = 0 OR props.to_group_id IS NULL)";
         }
 
-        $zip_folder=new PclZip($FileZip['TEMP_FILE_ZIP']);
+        $zip_folder = new PclZip($FileZip['TEMP_FILE_ZIP']);
         if (!isset($_POST['resource']) || count($_POST['resource']) == 0) {
             Display::display_error_message(get_lang('ErrorMsgSpecialExport'));
         } else {
@@ -130,7 +131,7 @@ if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form') ||
 
 if ($export && $name) {
     Display::display_confirmation_message(get_lang('BackupCreated'));
-    echo '<br /><a class="btn btn-default" href="'.api_get_path(WEB_CODE_PATH).'course_info/download.php?archive='.urlencode($name).'&session=true">'.get_lang('Download').'</a>';
+    echo '<br /><a class="btn btn-default" href="'.api_get_path(WEB_CODE_PATH).'course_info/download.php?archive_path=&archive='.urlencode($name).'">'.get_lang('Download').'</a>';
 } else {
     // Display forms especial export
     if (isset($_POST['backup_option']) && $_POST['backup_option'] == 'select_items') {
@@ -153,7 +154,7 @@ Display::display_footer();
 
 function form_special_export()
 {
-    $form = new FormValidator('special_exports','post');
+    $form = new FormValidator('special_exports', 'post');
     $renderer = $form->defaultRenderer();
     $renderer->setCustomElementTemplate('<div>{element}</div> ');
     $form->addElement('radio', 'backup_option', '',  get_lang('SpecialCreateFullBackup'), 'full_backup');
@@ -173,9 +174,9 @@ function create_zip()
         $path = '/';
     }
     $remove_dir = ($path != '/') ? substr($path, 0, strlen($path) - strlen(basename($path))) : '/';
-    $sys_archive_path = api_get_path(SYS_ARCHIVE_PATH);
+    $sys_archive_path = api_get_path(SYS_ARCHIVE_PATH).'special_export/';
     $sys_course_path = api_get_path(SYS_COURSE_PATH);
-    $temp_zip_dir = $sys_archive_path."temp";
+    $temp_zip_dir = $sys_archive_path;
     if (!is_dir($temp_zip_dir)) {
         mkdir($temp_zip_dir, api_get_permissions_for_new_directories());
     } else {
@@ -237,8 +238,8 @@ function fullexportspecial()
     }
 
     if (count($list_course) > 0) {
-        foreach($list_course as $_course) {
-            if($FileZip['PATH'] == '/') {
+        foreach ($list_course as $_course) {
+            if ($FileZip['PATH'] == '/') {
                 $querypath=''; // to prevent ...path LIKE '//%'... in query
             } else {
                 $querypath = $FileZip['PATH'];
@@ -256,23 +257,23 @@ function fullexportspecial()
                     AND $groupCondition
                     AND docs.c_id = $course_id
                     AND props.c_id = $course_id";
-            $query = Database::query($sql );
+            $query = Database::query($sql);
             while ($rows_course_file = Database::fetch_assoc($query)) {
-                $rows_course_file['path'];
-                $zip_folder->add($FileZip['PATH_COURSE'].$_course['directory']."/document".$rows_course_file['path'],
-                    PCLZIP_OPT_ADD_PATH, $_course['directory'],
+                $zip_folder->add(
+                    $FileZip['PATH_COURSE'].$_course['directory']."/document".$rows_course_file['path'],
+                    PCLZIP_OPT_ADD_PATH,
+                    $_course['directory'],
                     PCLZIP_OPT_REMOVE_PATH, $FileZip['PATH_COURSE'].$_course['directory']."/document".$FileZip['PATH_REMOVE']
                 );
             }
+
             //Add tem to the zip file session course
-            $code_course = $_course['code'];
-            $sql_session = "SELECT s.id, name, c_id
+            $sql = "SELECT s.id, name, c_id
                             FROM $tbl_session_course sc
                             INNER JOIN $tbl_session  s
                             ON sc.session_id = s.id
                             WHERE c_id = '$course_id' ";
-
-            $query_session = Database::query($sql_session);
+            $query_session = Database::query($sql);
             while ($rows_session = Database::fetch_assoc($query_session)) {
                 $session_id = $rows_session['id'];
                 $sql_session_doc = "SELECT path FROM $tbl_document AS docs, $tbl_property AS props
@@ -287,10 +288,13 @@ function fullexportspecial()
                         AND props.c_id = $course_id ";
                 $query_session_doc = Database::query($sql_session_doc);
                 while ($rows_course_session_file = Database::fetch_assoc($query_session_doc)) {
-                    $zip_folder->add($FileZip['PATH_COURSE'].$_course['directory'].'/document'.$rows_course_session_file['path'],
-                         PCLZIP_OPT_ADD_PATH, $_course['directory']."/".$rows_session['name'],
-                         PCLZIP_OPT_REMOVE_PATH, $FileZip['PATH_COURSE'].$_course['directory'].'/document'.$FileZip['PATH_REMOVE']
-                     );
+                    $zip_folder->add(
+                        $FileZip['PATH_COURSE'].$_course['directory'].'/document'.$rows_course_session_file['path'],
+                        PCLZIP_OPT_ADD_PATH,
+                        $_course['directory']."/".$rows_session['name'],
+                        PCLZIP_OPT_REMOVE_PATH,
+                        $FileZip['PATH_COURSE'].$_course['directory'].'/document'.$FileZip['PATH_REMOVE']
+                    );
                 }
             }
         }

+ 1 - 1
main/admin/user_add.php

@@ -265,7 +265,7 @@ if (api_is_platform_admin()) {
     $form->addElement('html', '</div>');
 }
 
-$form->addElement('select_language', 'language', get_lang('Language'), null);
+$form->addSelectLanguage('language', get_lang('Language'), null);
 
 // Send email
 $group = array();

+ 1 - 1
main/admin/user_edit.php

@@ -269,7 +269,7 @@ if (api_is_platform_admin()) {
 }
 
 //Language
-$form->addElement('select_language', 'language', get_lang('Language'));
+$form->addSelectLanguage('language', get_lang('Language'));
 
 // Send email
 $group = array();

+ 4 - 2
main/admin/user_information.php

@@ -164,7 +164,6 @@ if (isset($_GET['action'])) {
     }
 }
 
-
 // Show info about who created this user and when
 $creatorId = $user['creator_id'];
 $creatorInfo = api_get_user_info($creatorId);
@@ -216,7 +215,10 @@ $data = array(
 
 if (api_get_setting('allow_terms_conditions') === 'true') {
     $extraFieldValue = new ExtraFieldValue('user');
-    $value = $extraFieldValue->get_values_by_handler_and_field_variable($userId, 'legal_accept');
+    $value = $extraFieldValue->get_values_by_handler_and_field_variable(
+        $userId,
+        'legal_accept'
+    );
     $icon = Display::return_icon('accept_na.png');
     if (isset($value['value'])) {
         list($legalId, $legalLanguageId, $legalTime) = explode(':', $value['value']);

+ 23 - 19
main/admin/user_update_import.php

@@ -1,5 +1,6 @@
 <?php
 /* For licensing terms, see /license.txt */
+
 /**
  * This tool allows platform admins to add users by uploading a CSV or XML file
  * @package chamilo.admin
@@ -60,8 +61,8 @@ function validate_data($users)
                     $user['error'] = get_lang('UserNameNotAvailable');
                     $errors[] = $user;
                 }
-             }
-          }
+            }
+        }
 
         // 3. Check status.
         if (isset($user['Status']) && !api_status_exists($user['Status'])) {
@@ -94,7 +95,6 @@ function validate_data($users)
             }
         }
     }
-
     return $errors;
 }
 
@@ -205,7 +205,11 @@ function updateUsers($users)
             if (!empty($user['ClassId'])) {
                 $classId = explode('|', trim($user['ClassId']));
                 foreach ($classId as $id) {
-                    $usergroup->subscribe_users_to_usergroup($id, array($user_id), false);
+                    $usergroup->subscribe_users_to_usergroup(
+                        $id,
+                        array($user_id),
+                        false
+                    );
                 }
             }
 
@@ -215,9 +219,13 @@ function updateUsers($users)
             // We are sure that the extra field exists.
             foreach ($extra_fields as $extras) {
                 if (isset($user[$extras[1]])) {
-                    $key 	= $extras[1];
-                    $value 	= $user[$extras[1]];
-                    UserManager::update_extra_field_value($user_id, $key, $value);
+                    $key = $extras[1];
+                    $value = $user[$extras[1]];
+                    UserManager::update_extra_field_value(
+                        $user_id,
+                        $key,
+                        $value
+                    );
                 }
             }
         }
@@ -336,10 +344,8 @@ $extra_fields = UserManager::get_extra_fields(0, 0, 5, 'ASC', true);
 $user_id_error = array();
 $error_message = '';
 
-if (isset($_POST['formSent']) && $_POST['formSent'] AND $_FILES['import_file']['size'] !== 0) {
-
+if (isset($_POST['formSent']) && $_POST['formSent'] && $_FILES['import_file']['size'] !== 0) {
     $file_type = 'csv';
-
     Security::clear_token();
     $tok = Security::get_token();
     $allowed_file_mimetype = array('csv', 'xml');
@@ -350,7 +356,7 @@ if (isset($_POST['formSent']) && $_POST['formSent'] AND $_FILES['import_file']['
 
     if (in_array($ext_import_file, $allowed_file_mimetype)) {
         if (strcmp($file_type, 'csv') === 0 && $ext_import_file == $allowed_file_mimetype[0]) {
-            $users	= parse_csv_data($_FILES['import_file']['tmp_name']);
+            $users = parse_csv_data($_FILES['import_file']['tmp_name']);
             $errors = validate_data($users);
             $error_kind_file = false;
         } elseif (strcmp($file_type, 'xml') === 0 && $ext_import_file == $allowed_file_mimetype[1]) {
@@ -358,7 +364,6 @@ if (isset($_POST['formSent']) && $_POST['formSent'] AND $_FILES['import_file']['
             $errors = validate_data($users);
             $error_kind_file = false;
         } else {
-
             $error_kind_file = true;
         }
     } else {
@@ -456,13 +461,12 @@ if ($count_fields > 0) {
 
 ?>
 <p><?php echo get_lang('CSVMustLookLike').' ('.get_lang('MandatoryFields').')'; ?> :</p>
-
-    <blockquote>
-        <pre>
-            <b>UserName</b>;LastName;FirstName;Email;NewUserName;Password;AuthSource;OfficialCode;PhoneNumber;Status;ExpiryDate;Active;Language;Courses;ClassId;
-            xxx;xxx;xxx;xxx;xxx;xxx;xxx;xxx;xxx;user/teacher/drh;0000-00-00 00:00:00;0/1;xxx;<span style="color:red;"><?php if (count($list_reponse) > 0) echo implode(';', $list_reponse).';'; ?></span>xxx1|xxx2|xxx3;1;<br />
-        </pre>
-    </blockquote>
+<blockquote>
+    <pre>
+        <b>UserName</b>;LastName;FirstName;Email;NewUserName;Password;AuthSource;OfficialCode;PhoneNumber;Status;ExpiryDate;Active;Language;Courses;ClassId;
+        xxx;xxx;xxx;xxx;xxx;xxx;xxx;xxx;xxx;user/teacher/drh;YYYY-MM-DD 00:00:00;0/1;xxx;<span style="color:red;"><?php if (count($list_reponse) > 0) echo implode(';', $list_reponse).';'; ?></span>xxx1|xxx2|xxx3;1;<br />
+    </pre>
+</blockquote>
 <p><?php
 
 Display :: display_footer();

+ 2 - 2
main/auth/courses_controller.php

@@ -244,7 +244,7 @@ class CoursesController
                 );
             } else {
                 Display::addFlash(
-                    Display::return_message($result['message'])
+                    Display::return_message($result['message'], 'normal', false)
                 );
             }
         }
@@ -522,7 +522,7 @@ class CoursesController
         $btnBing = false
     ) {
         if($btnBing){
-            $btnBing = 'btn-lg'; 
+            $btnBing = 'btn-lg';
         }else{
             $btnBing = 'btn-sm';
         }

+ 1 - 2
main/auth/inscription.php

@@ -205,8 +205,7 @@ if ($user_already_registered_show_terms === false) {
     // Language
     if (in_array('language', $allowedFields)) {
         if (api_get_setting('registration', 'language') == 'true') {
-            $form->addElement(
-                'select_language',
+            $form->addSelectLanguage(
                 'language',
                 get_lang('Language')
             );

+ 1 - 1
main/auth/profile.php

@@ -225,7 +225,7 @@ if (is_profile_editable() && api_get_setting('profile', 'picture') == 'true') {
 }
 
 //    LANGUAGE
-$form->addElement('select_language', 'language', get_lang('Language'));
+$form->addSelectLanguage('language', get_lang('Language'));
 if (api_get_setting('profile', 'language') !== 'true') {
     $form->freeze('language');
 }

+ 2 - 6
main/course_info/download.php

@@ -11,14 +11,11 @@ use Chamilo\CourseBundle\Component\CourseCopy\CourseArchiver;
 require_once __DIR__.'/../inc/global.inc.php';
 $this_section = SECTION_COURSES;
 
-if (isset($_GET['session']) && $_GET['session']) {
-	$archive_path = api_get_path(SYS_ARCHIVE_PATH).'temp/';
-	$_cid = true;
-	$is_courseAdmin = true;
+if (isset($_GET['archive_path'])) {
+	$archive_path = api_get_path(SYS_ARCHIVE_PATH);
 } else {
 	$archive_path = CourseArchiver::getBackupDir();
 }
-
 $archive_file = isset($_GET['archive']) ? $_GET['archive'] : null;
 $archive_file = str_replace(array('..', '/', '\\'), '', $archive_file);
 
@@ -40,7 +37,6 @@ if (in_array($extension, array('xml', 'csv')) && (api_is_platform_admin(true) ||
 if (empty($content_type)) {
     api_not_allowed(true);
 }
-
 if (Security::check_abs_path($archive_path.$archive_file, $archive_path)) {
     DocumentManager::file_send_for_download($archive_path.$archive_file, true, $archive_file);
     exit;

+ 4 - 1
main/course_info/infocours.php

@@ -140,7 +140,10 @@ $form->addElement(
     $categories,
     ['style'=>'width:350px', 'id'=>'category_code']
 );
-$form->addElement('select_language', 'course_language', array(get_lang('Ln'), get_lang('TipLang')));
+$form->addSelectLanguage(
+    'course_language',
+    array(get_lang('Ln'), get_lang('TipLang'))
+);
 
 $group = array(
     $form->createElement('radio', 'show_course_in_user_language', null, get_lang('Yes'), 1),

+ 1 - 3
main/create_course/add_course.php

@@ -147,14 +147,12 @@ if (count($languages['name']) === 1) {
     // If there's only one language available, there's no point in asking
     $form->addElement('hidden', 'course_language', $languages['folder'][0]);
 } else {
-    $form->addElement(
-        'select_language',
+    $form->addSelectLanguage(
         'course_language',
         get_lang('Ln'),
         array(),
         array('style' => 'width:150px')
     );
-    $form->applyFilter('select_language', 'html_filter');
 }
 
 // Exemplary content checkbox.

+ 5 - 5
main/exercise/adminhp.php

@@ -21,7 +21,7 @@ if (isset($_REQUEST["cancel"])) {
 
 $newName = !empty($_REQUEST['newName']) ? $_REQUEST['newName'] : '';
 $hotpotatoesName = !empty($_REQUEST['hotpotatoesName']) ? Security::remove_XSS($_REQUEST['hotpotatoesName']) : '';
-$is_allowedToEdit=api_is_allowed_to_edit(null,true);
+$is_allowedToEdit = api_is_allowed_to_edit(null, true);
 
 // document path
 $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
@@ -67,8 +67,8 @@ require_once api_get_path(SYS_CODE_PATH).'/exercise/hotpotatoes.lib.php';
 if (isset($newName)) {
     if ($newName!="") {
         //alter database record for that test
-        SetComment($hotpotatoesName,$newName);
-        echo "<script language='Javascript' type='text/javascript'> window.location='exercise.php'; </script>";
+        SetComment($hotpotatoesName, $newName);
+        echo "<script> window.location='exercise.php'; </script>";
     }
 }
 
@@ -79,10 +79,10 @@ echo "<input type=\"text\" name=\"newName\" value=\"";
 $lstrComment = '';
 $lstrComment = GetComment($hotpotatoesName);
 if ($lstrComment == '') {
-    $lstrComment = GetQuizName($hotpotatoesName,$documentPath);
+    $lstrComment = GetQuizName($hotpotatoesName, $documentPath);
 }
 if ($lstrComment == '') {
-    $lstrComment = basename($hotpotatoesName,$documentPath);
+    $lstrComment = basename($hotpotatoesName, $documentPath);
 }
 
 echo $lstrComment;

+ 22 - 9
main/exercise/exercise.class.php

@@ -2276,7 +2276,7 @@ class Exercise
                 require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
 
                 $form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument'));
-                $form->addElement('select_language', 'language', get_lang('SearchFeatureDocumentLanguage'));
+                $form->addSelectLanguage('language', get_lang('SearchFeatureDocumentLanguage'));
 
                 $specific_fields = get_specific_field_list();
 
@@ -7922,7 +7922,6 @@ class Exercise
             }
 
             foreach ($question_list as $questionId) {
-
                 // Creates a temporary Question object
                 $objQuestionTmp = Question::read($questionId);
 
@@ -8003,7 +8002,13 @@ class Exercise
                 }
 
                 $score = array();
-                $score['result'] = get_lang('Score')." : ".ExerciseLib::show_score($my_total_score, $my_total_weight, false, true);
+                $score['result'] = get_lang('Score')." : ".
+                    ExerciseLib::show_score(
+                        $my_total_score,
+                        $my_total_weight,
+                        false,
+                        true
+                    );
                 $score['pass'] = $my_total_score >= $my_total_weight ? true : false;
                 $score['score'] = $my_total_score;
                 $score['weight'] = $my_total_weight;
@@ -8021,7 +8026,6 @@ class Exercise
                 $question_content = '<div class="question_row">';
 
                 if ($show_results) {
-
                     $show_media = false;
                     $counterToShow = $counter;
                     if ($objQuestionTmp->parent_id != 0) {
@@ -8040,16 +8044,25 @@ class Exercise
                     }
 
                     // Shows question title an description.
-                    $question_content .= $objQuestionTmp->return_header(null, $counterToShow, $score, $show_media, $this->getHideQuestionTitle());
+                    $question_content .= $objQuestionTmp->return_header(
+                        null,
+                        $counterToShow,
+                        $score,
+                        $show_media,
+                        $this->getHideQuestionTitle()
+                    );
 
                     // display question category, if any
-                    $question_content .= TestCategory::getCategoryNamesForQuestion($questionId, null, true, $this->categoryMinusOne);
+                    $question_content .= TestCategory::getCategoryNamesForQuestion(
+                        $questionId,
+                        null,
+                        true,
+                        $this->categoryMinusOne
+                    );
                 }
                 $counter++;
-
                 $question_content .= $contents;
                 $question_content .= '</div>';
-
                 $exercise_content .= $question_content;
             } // end foreach() block that loops over all questions
         }
@@ -8087,7 +8100,7 @@ class Exercise
             $learnpath_item_view_id = $exercise_stat_info['orig_lp_item_view_id'];
 
             if (api_is_allowed_to_session_edit()) {
-                update_event_exercise(
+                Event::update_event_exercise(
                     $exercise_stat_info['exe_id'],
                     $this->selectId(),
                     $total_score,

+ 9 - 8
main/exercise/exercise.php

@@ -564,7 +564,6 @@ if (isset($list_ordered) && !empty($list_ordered)) {
 }
 
 $tableRows = [];
-
 /*  Listing exercises  */
 if (!empty($exerciseList)) {
     if ($origin != 'learnpath') {
@@ -742,7 +741,7 @@ if (!empty($exerciseList)) {
 
                     // Export
                     $actions .= Display::url(
-                        Display::return_icon('cd.gif', get_lang('CopyExercise')),
+                        Display::return_icon('cd.png', get_lang('CopyExercise')),
                         '',
                         array(
                             'onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToCopy'), ENT_QUOTES, $charset))." ".addslashes($row['title'])."?"."')) return false;",
@@ -1023,22 +1022,24 @@ $hotpotatoes_exist = false;
 
 if ($is_allowedToEdit) {
     $sql = "SELECT d.path as path, d.comment as comment, ip.visibility as visibility
-            FROM $TBL_DOCUMENT d, $TBL_ITEM_PROPERTY ip
+            FROM $TBL_DOCUMENT d 
+            INNER JOIN $TBL_ITEM_PROPERTY ip
+            ON (d.id = ip.ref AND d.c_id = ip.c_id)
             WHERE
                 d.c_id = $courseId AND
-                ip.c_id = $courseId AND
-                d.id = ip.ref AND
+                ip.c_id = $courseId AND                
                 ip.tool = '".TOOL_DOCUMENT."' AND
                 (d.path LIKE '%htm%') AND
                 d.path  LIKE '".Database :: escape_string($uploadPath.'/%/%')."'
             LIMIT ".$from.",".$limit; // only .htm or .html files listed
 } else {
     $sql = "SELECT d.path as path, d.comment as comment, ip.visibility as visibility
-            FROM $TBL_DOCUMENT d, $TBL_ITEM_PROPERTY ip
+            FROM $TBL_DOCUMENT d 
+            INNER JOIN $TBL_ITEM_PROPERTY ip
+            ON (d.id = ip.ref AND d.c_id = ip.c_id)
             WHERE
                 d.c_id = $courseId AND
-                ip.c_id = $courseId AND
-                d.id = ip.ref AND
+                ip.c_id = $courseId AND                
                 ip.tool = '".TOOL_DOCUMENT."' AND
                 (d.path LIKE '%htm%') AND
                 d.path  LIKE '".Database :: escape_string($uploadPath.'/%/%')."' AND

+ 0 - 2
main/exercise/hotpotatoes.php

@@ -111,10 +111,8 @@ $form->addButtonSend(get_lang('SendFile'));
 
 // If finish is set; it's because the user came from this script in the first place (displaying hidden "finish" field).
 if ((api_is_allowed_to_edit(null, true)) && (($finish == 0) || ($finish == 2))) {
-
     // Moved this down here as the upload handling functions give output.
     if ($form->validate()) {
-
         // Initialise $finish
         if (!isset($finish)) {
             $finish = 0;

+ 1 - 1
main/exercise/question_pool.php

@@ -912,7 +912,7 @@ function get_action_icon_for_question(
 		case "clone":
             $url = api_get_self()."?".api_get_cidreq().$getParams."&question_copy=$in_questionid&course_id=$in_selected_course&fromExercise=$from_exercise";
             $res = Display::url(
-                Display::return_icon('cd.gif', get_lang('ReUseACopyInCurrentTest')),
+                Display::return_icon('cd.png', get_lang('ReUseACopyInCurrentTest')),
                 $url
             );
 			break;

+ 12 - 1
main/gradebook/exercise_jump.php

@@ -1,5 +1,6 @@
 <?php
 /* For licensing terms, see /license.txt */
+
 /**
  * Sets needed course variables and then jumps to the exercises result page.
  * This intermediate page is needed because the user is not inside a course
@@ -35,7 +36,17 @@ if (isset($_GET['doexercise'])) {
 
 // no support for hot potatoes
 if ($type == LINK_HOTPOTATOES) {
-    $doExerciseUrl = api_get_path(WEB_CODE_PATH) . 'exercise/exercice.php?session_id='.$session_id.'&cidReq='.Security::remove_XSS($cidReq);
+    $exerciseId = $_GET['exerciseId'];
+    $path = Security::remove_XSS($_GET['path']);
+    $doExerciseUrl = api_get_path(WEB_CODE_PATH) . 'exercise/showinframes.php?'.http_build_query([
+        'session_id' => $session_id,
+        'cidReq' => Security::remove_XSS($cidReq),
+        'file' => $path,
+        'cid' => api_get_course_id(),
+        'uid' => api_get_user_id(),
+    ]);
+    header('Location: '.$doExerciseUrl);
+    exit;
 }
 
 if (isset($_GET['doexercise'])) {

+ 0 - 1
main/gradebook/gradebook_add_link.php

@@ -85,7 +85,6 @@ if (isset($typeSelected) && $typeSelected != '0') {
 
         $parent_cat = Category::load($addvalues['select_gradebook']);
         $global_weight = $category[0]->get_weight();
-
         $link->set_weight($addvalues['weight_mask']);
 
         if ($link->needs_max()) {

+ 1 - 2
main/gradebook/gradebook_edit_cat.php

@@ -62,7 +62,7 @@ if ($form->validate()) {
         $cat->setGenerateCertificates(false);
     }
 
-    if ($values['hid_parent_id'] == 0 ) {
+    if ($values['hid_parent_id'] == 0) {
         $cat->set_certificate_min_score($values['certif_min_score']);
     }
 
@@ -79,7 +79,6 @@ if ($form->validate()) {
     } else {
         $cat->setIsRequirement(false);
     }
-
     $cat->save();
     header('Location: '.Security::remove_XSS($_SESSION['gradebook_dest']).'?editcat=&selectcat=' . $cat->get_parent_id().'&'.api_get_cidreq());
     exit;

+ 53 - 31
main/gradebook/lib/be/category.class.php

@@ -330,8 +330,8 @@ class Category implements GradebookItem
             return $cats;
         }
 
-        $courseCode = api_get_course_info_by_id(api_get_course_int_id());
-        $courseCode = $courseCode['code'];
+        $courseInfo = api_get_course_info_by_id(api_get_course_int_id());
+        $courseCode = $courseInfo['code'];
         $session_id = intval($session_id);
 
         if (!empty($session_id)) {
@@ -357,13 +357,13 @@ class Category implements GradebookItem
 
     /**
      * Retrieve categories and return them as an array of Category objects
-     * @param int      $id category id
-     * @param int      $user_id (category owner)
-     * @param string   $course_code
-     * @param int      $parent_id parent category
-     * @param bool     $visible
-     * @param int      $session_id (in case we are in a session)
-     * @param bool     $order_by Whether to show all "session"
+     * @param int $id category id
+     * @param int $user_id (category owner)
+     * @param string $course_code
+     * @param int $parent_id parent category
+     * @param bool $visible
+     * @param int $session_id (in case we are in a session)
+     * @param bool $order_by Whether to show all "session"
      * categories (true) or hide them (false) in case there is no session id
      */
     public static function load(
@@ -582,7 +582,6 @@ class Category implements GradebookItem
             $this->set_id($id);
 
             if (!empty($id)) {
-
                 $parent_id = $this->get_parent_id();
                 $grade_model_id = $this->get_grade_model_id();
                 if ($parent_id == 0) {
@@ -614,7 +613,10 @@ class Category implements GradebookItem
             }
 
             $gradebook= new Gradebook();
-            $gradebook->update_skills_to_gradebook($this->id, $this->get_skills(false));
+            $gradebook->update_skills_to_gradebook(
+                $this->id,
+                $this->get_skills(false)
+            );
 
             return $id;
         }
@@ -657,7 +659,6 @@ class Category implements GradebookItem
             $parent_id = $this->get_parent_id();
             $grade_model_id = $this->get_grade_model_id();
             if ($parent_id == 0) {
-
                 if (isset($grade_model_id) && !empty($grade_model_id) && $grade_model_id != '-1') {
                     $obj = new GradeModel();
                     $components = $obj->get_components($grade_model_id);
@@ -673,15 +674,13 @@ class Category implements GradebookItem
                     foreach ($components as $component) {
                         $gradebook = new Gradebook();
                         $params = array();
-
-                        $params['name']             = $component['acronym'];
-                        $params['description']      = $component['title'];
-                        $params['user_id']          = api_get_user_id();
-                        $params['parent_id']        = $this->id;
-                        $params['weight']           = $component['percentage']/100*$default_weight;
-                        $params['session_id']       = api_get_session_id();
-                        $params['course_code']      = $this->get_course_code();
-
+                        $params['name'] = $component['acronym'];
+                        $params['description'] = $component['title'];
+                        $params['user_id'] = api_get_user_id();
+                        $params['parent_id'] = $this->id;
+                        $params['weight'] = $component['percentage'] / 100 * $default_weight;
+                        $params['session_id'] = api_get_session_id();
+                        $params['course_code'] = $this->get_course_code();
                         $gradebook->save($params);
                     }
                 }
@@ -732,7 +731,8 @@ class Category implements GradebookItem
     public function update_category_delete($course_id)
     {
         $tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
-        $sql = 'UPDATE '.$tbl_grade_categories.' SET visible=3
+        $sql = 'UPDATE '.$tbl_grade_categories.' SET 
+                    visible = 3
                 WHERE course_code ="'.Database::escape_string($course_id).'"';
         Database::query($sql);
     }
@@ -743,13 +743,14 @@ class Category implements GradebookItem
     public function show_message_resource_delete($course_id)
     {
         $tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
-        $sql = 'SELECT count(*) AS num from '.$tbl_grade_categories.'
+        $sql = 'SELECT count(*) AS num 
+                FROM '.$tbl_grade_categories.'
                 WHERE
                     course_code = "'.Database::escape_string($course_id).'" AND
-                    visible=3';
+                    visible = 3';
         $res = Database::query($sql);
         $option = Database::fetch_array($res, 'ASSOC');
-        if ($option['num']>=1) {
+        if ($option['num'] >= 1) {
             return '&nbsp;&nbsp;<span class="resource-deleted">(&nbsp;'.get_lang('ResourceDeleted').'&nbsp;)</span>';
         } else {
             return false;
@@ -782,7 +783,7 @@ class Category implements GradebookItem
      */
     public function does_name_exist($name, $parent)
     {
-        if (!isset ($name)) {
+        if (!isset($name)) {
             $name = $this->name;
             $parent = $this->parent;
         }
@@ -805,11 +806,11 @@ class Category implements GradebookItem
             } else {
                 $sql .= ' AND user_id = '.api_get_user_id();
             }
-
         } else {
             $sql .= ' AND user_id = '.api_get_user_id();
         }
-        if (!isset ($parent)) {
+
+        if (!isset($parent)) {
             $sql.= ' AND parent_id is null';
         } else {
             $sql.= ' AND parent_id = '.intval($parent);
@@ -946,6 +947,11 @@ class Category implements GradebookItem
                 /** @var EvalLink|ExerciseLink $link */
                 foreach ($links as $link) {
                     $link->setStudentList($this->getStudentList());
+
+                    if ($session_id) {
+                        $link->set_session_id($session_id);
+                    }
+
                     $linkres = $link->calc_score($stud_id, null);
                     if (!empty($linkres) && $link->get_weight() != 0) {
                         $students[$stud_id] = $linkres[0];
@@ -1042,6 +1048,11 @@ class Category implements GradebookItem
                 /** @var EvalLink|ExerciseLink $link */
                 foreach ($links as $link) {
                     $link->setStudentList($this->getStudentList());
+
+                    if ($session_id) {
+                        $link->set_session_id($session_id);
+                    }
+	                
                     $linkres = $link->calc_score($stud_id, $type);
                     if (!empty($linkres) && $link->get_weight() != 0) {
                         $students[$stud_id] = $linkres[0];
@@ -1183,7 +1194,7 @@ class Category implements GradebookItem
                             cu.status = '.COURSEMANAGER.'
                     )';
             }
-        }elseif (api_is_platform_admin()) {
+        } elseif (api_is_platform_admin()) {
             if (isset($session_id) && $session_id!=0) {
                 $sql.=' AND session_id='.intval($session_id);
             } else {
@@ -1195,7 +1206,11 @@ class Category implements GradebookItem
 
         // course independent categories
         if (empty($course_code)) {
-            $cats = Category::get_independent_categories_with_result_for_student (0, $stud_id, $cats);
+            $cats = Category::get_independent_categories_with_result_for_student(
+                0,
+                $stud_id,
+                $cats
+            );
         }
 
         return $cats;
@@ -1241,7 +1256,14 @@ class Category implements GradebookItem
         $cats = Category::create_category_objects_from_sql_result($result);
         // course independent categories
         if (isset($course_code)) {
-            $indcats = Category::load(null,$user_id,$course_code,0,null,$session_id);
+            $indcats = Category::load(
+                null,
+                $user_id,
+                $course_code,
+                0,
+                null,
+                $session_id
+            );
             $cats = array_merge($cats, $indcats);
         }
 

+ 85 - 56
main/gradebook/lib/be/exerciselink.class.php

@@ -62,7 +62,7 @@ class ExerciseLink extends AbstractLink
      * Generate an array of all exercises available.
      * @return array 2-dimensional array - every element contains 2 subelements (id, name)
      */
-    public function get_all_links()
+    public function get_all_links($getOnlyHotPotatoes = false)
     {
         $TBL_DOCUMENT = Database :: get_course_table(TABLE_DOCUMENT);
         $TBL_ITEM_PROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY);
@@ -86,25 +86,33 @@ class ExerciseLink extends AbstractLink
         $sql = 'SELECT id,title FROM '.$exerciseTable.'
 				WHERE c_id = '.$this->course_id.' AND active=1  '.$session_condition;
 
-        $sqlLp = "SELECT e.id, e.title FROM $exerciseTable e INNER JOIN $lpItemTable i
+        $sqlLp = "SELECT e.id, e.title 
+                  FROM $exerciseTable e 
+                  INNER JOIN $lpItemTable i
                   ON (e.c_id = i.c_id AND e.id = i.path)
-				  WHERE e.c_id = $this->course_id AND active = 0 AND item_type = 'quiz'
+				  WHERE 
+				    e.c_id = $this->course_id AND 
+				    active = 0 AND 
+				    item_type = 'quiz'
 				  $session_condition";
 
         $sql2 = "SELECT d.path as path, d.comment as comment, ip.visibility as visibility, d.id
-                FROM $TBL_DOCUMENT d, $TBL_ITEM_PROPERTY ip
+                FROM $TBL_DOCUMENT d 
+                INNER JOIN $TBL_ITEM_PROPERTY ip
+                ON (d.id = ip.ref AND d.c_id = ip.c_id)
                 WHERE
                     d.c_id = $this->course_id AND
-                    ip.c_id = $this->course_id AND
-                    d.id = ip.ref AND
+                    ip.c_id = $this->course_id AND                
                     ip.tool = '".TOOL_DOCUMENT."' AND
-                    (d.path LIKE '%htm%')AND (d.path LIKE '%HotPotatoes_files%') AND
+                    (d.path LIKE '%htm%') AND 
+                    (d.path LIKE '%HotPotatoes_files%') AND
                     d.path  LIKE '".Database :: escape_string($uploadPath.'/%/%')."' AND
-                    ip.visibility='1'
+                    ip.visibility = '1'
                 ";
 
         require_once api_get_path(SYS_CODE_PATH).'exercise/hotpotatoes.lib.php';
         $exerciseInLP = array();
+
         if (!$this->is_hp) {
             $result = Database::query($sql);
             $resultLp = Database::query($sqlLp);
@@ -121,13 +129,10 @@ class ExerciseLink extends AbstractLink
                 }
             }
         }
-
+        $hotPotatoes = [];
         if (isset($result2)) {
             if (Database::num_rows($result2) > 0) {
-                while ($row=Database::fetch_array($result2)) {
-                    /*$path = $data['path'];
-                    $fname = GetQuizName($path,$documentPath);
-        			$cats[] = array ($data['id'], $fname);*/
+                while ($row = Database::fetch_array($result2)) {
                     $attribute['path'][] = $row['path'];
                     $attribute['visibility'][] = $row['visibility'];
                     $attribute['comment'][] = $row['comment'];
@@ -139,13 +144,19 @@ class ExerciseLink extends AbstractLink
                             if ($title == '') {
                                 $title = basename($path);
                             }
-                            $cats[] = array($attribute['id'], $title.'(HP)');
+                            $element = array($attribute['id'], $title.'(HP)');
+                            $cats[] = $element;
+                            $hotPotatoes[] = $element;
                         }
                     }
                 }
             }
         }
 
+        if ($getOnlyHotPotatoes) {
+            return $hotPotatoes;
+        }
+
         if (!empty($exerciseInLP)) {
             foreach ($exerciseInLP as $exercise) {
                 $cats[] = array(
@@ -166,13 +177,15 @@ class ExerciseLink extends AbstractLink
         $tbl_stats = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $session_id = api_get_session_id();
         $course_id = api_get_course_int_id($this->get_course_code());
-        $sql = 'SELECT count(exe_id) AS number FROM '.$tbl_stats."
+        $sql = "SELECT count(exe_id) AS number 
+                FROM $tbl_stats
                 WHERE
                     session_id = $session_id AND
                     c_id = $course_id AND
                     exe_exo_id   = ".(int)$this->get_ref_id();
         $result = Database::query($sql);
         $number=Database::fetch_row($result);
+
         return ($number[0] != 0);
     }
 
@@ -194,38 +207,38 @@ class ExerciseLink extends AbstractLink
         in exercise/exercise.php, look for note-query-exe-results marker*/
         $session_id = $this->get_session_id();
         $courseId = $this->getCourseId();
-	    $exercise = new Exercise($courseId);
+        $exercise = new Exercise($courseId);
         $exercise->read($this->get_ref_id());
+        $stud_id = (int) $stud_id;
 
         if (!$this->is_hp) {
+            if ($exercise->exercise_was_added_in_lp == false) {
+                $sql = "SELECT * FROM $tblStats
+                        WHERE
+                            exe_exo_id = ".intval($this->get_ref_id())." AND
+                            orig_lp_id = 0 AND
+                            orig_lp_item_id = 0 AND
+                            status <> 'incomplete' AND
+                            session_id = $session_id AND
+                            c_id = $courseId
+                        ";
+            } else {
+                $lpId = null;
+                if (!empty($exercise->lpList)) {
+                    // Taking only the first LP
+                    $lpId = current($exercise->lpList);
+                    $lpId = $lpId['lp_id'];
+                }
 
-		if ($exercise->exercise_was_added_in_lp == false) {
-			$sql = "SELECT * FROM $tblStats
-			        WHERE
-			            exe_exo_id = ".intval($this->get_ref_id())." AND
-			            orig_lp_id = 0 AND
-			            orig_lp_item_id = 0 AND
-			            status <> 'incomplete' AND
-			            session_id = $session_id AND
-                                    c_id = $courseId
-                                ";
-		    } else {
-		        $lpId = null;
-		        if (!empty($exercise->lpList)) {
-		            // Taking only the first LP
-		            $lpId = current($exercise->lpList);
-		            $lpId = $lpId['lp_id'];
-		        }
-
-		        $sql = "SELECT * FROM $tblStats
-		                WHERE
-		                    exe_exo_id = ".intval($this->get_ref_id())." AND
-		                    orig_lp_id = $lpId AND
-		                    status <> 'incomplete' AND
-		                    session_id = $session_id AND
-                                    c_id = $courseId
-                                ";
-		    }
+                $sql = "SELECT * 
+                        FROM $tblStats
+                        WHERE
+                            exe_exo_id = ".intval($this->get_ref_id())." AND
+                            orig_lp_id = $lpId AND
+                            status <> 'incomplete' AND
+                            session_id = $session_id AND
+                            c_id = $courseId ";
+            }
 
             if (!empty($stud_id) && $type != 'ranking') {
                 $sql .= " AND exe_user_id = $stud_id ";
@@ -233,13 +246,16 @@ class ExerciseLink extends AbstractLink
             $sql .= ' ORDER BY exe_id DESC';
 
         } else {
-            $sql = "SELECT * FROM $tblHp hp, $tblDoc doc
+            $sql = "SELECT * FROM $tblHp hp 
+                    INNER JOIN $tblDoc doc
+                    ON (hp.exe_name = doc.path AND doc.c_id = hp.c_id)
                     WHERE
-                        hp.c_id = $courseId AND
-                        hp.exe_user_id = $stud_id  AND
-                        hp.exe_name = doc.path AND
-                        doc.c_id = hp.c_id AND
+                        hp.c_id = $courseId AND                        
                         doc.id = ".intval($this->get_ref_id());
+
+            if (!empty($stud_id)) {
+                $sql .= " AND hp.exe_user_id = $stud_id ";
+            }
         }
 
         $scores = Database::query($sql);
@@ -309,18 +325,20 @@ class ExerciseLink extends AbstractLink
      */
     public function get_link()
     {
-        //status student
+        // Status student
         $user_id = api_get_user_id();
+        $session_id = api_get_session_id();
         $course_code = $this->get_course_code();
         $courseInfo = api_get_course_info($course_code);
         $courseId = $courseInfo['real_id'];
-
         $status_user = api_get_status_of_user_in_course($user_id, $courseId);
-        $session_id = api_get_session_id();
 
-        $url = api_get_path(WEB_CODE_PATH).'gradebook/exercise_jump.php?session_id='.$session_id.'&cidReq='.$this->get_course_code().'&gradebook=view&exerciseId='.$this->get_ref_id().'&type='.$this->get_type();
-        if ((!api_is_allowed_to_edit() && $this->calc_score(api_get_user_id()) == null) || $status_user!=1) {
-            $url .= '&amp;doexercise='.$this->get_ref_id();
+        $data = $this->get_exercise_data();
+        $path = isset($data['path']) ? $data['path'] : '';
+
+        $url = api_get_path(WEB_CODE_PATH).'gradebook/exercise_jump.php?path='.$path.'&session_id='.$session_id.'&cidReq='.$this->get_course_code().'&gradebook=view&exerciseId='.$this->get_ref_id().'&type='.$this->get_type();
+        if ((!api_is_allowed_to_edit() && $this->calc_score($user_id) == null) || $status_user != 1) {
+            $url .= '&doexercise='.$this->get_ref_id();
         }
 
         return $url;
@@ -363,8 +381,11 @@ class ExerciseLink extends AbstractLink
      */
     public function is_valid_link()
     {
-        $sql = 'SELECT count(id) from '.$this->get_exercise_table().'
-                WHERE c_id = '.$this->course_id.' AND id = '.(int)$this->get_ref_id().' ';
+        $sql = 'SELECT count(id) 
+                FROM '.$this->get_exercise_table().'
+                WHERE 
+                    c_id = '.$this->course_id.' AND 
+                    id = '.(int)$this->get_ref_id().' ';
         $result = Database::query($sql);
         $number = Database::fetch_row($result);
 
@@ -461,4 +482,12 @@ class ExerciseLink extends AbstractLink
     {
         return 'exercise';
     }
+
+    /**
+     * @param bool $hp
+     */
+    public function setHp($hp)
+    {
+        $this->hp = $hp;
+    }
 }

+ 4 - 2
main/gradebook/lib/be/studentpublicationlink.class.php

@@ -433,10 +433,12 @@ class StudentPublicationLink extends AbstractLink
         }
     }
 
+    /**
+     * @return string
+     */
     public function delete_linked_data()
     {
         $data = $this->get_exercise_data();
-
         if (empty($data)) {
             return '';
         }
@@ -444,7 +446,7 @@ class StudentPublicationLink extends AbstractLink
         if (!empty($id)) {
             //Cleans works
             $sql = 'UPDATE '.$this->get_studpub_table().' 
-                    SET weight=0
+                    SET weight = 0
                     WHERE c_id = '.$this->course_id.' AND id ='.$id;
             Database::query($sql);
         }

+ 31 - 41
main/gradebook/lib/fe/catform.class.php

@@ -16,11 +16,13 @@ class CatForm extends FormValidator
     private $category_object;
 
     /**
+     * CatForm constructor.
      * Builds a form containing form items based on a given parameter
-     * @param int form_type 1=add, 2=edit,3=move,4=browse
-     * @param obj cat_obj the category object
-     * @param string form name
-     * @param method method
+     * @param string $form_type 1=add, 2=edit,3=move,4=browse
+     * @param string $category_object
+     * @param string $form_name
+     * @param string $method
+     * @param null $action
      */
     public function __construct(
         $form_type,
@@ -31,7 +33,7 @@ class CatForm extends FormValidator
     ) {
         parent :: __construct($form_name, $method, $action);
         $this->form_type = $form_type;
-        if (isset ($category_object)) {
+        if (isset($category_object)) {
             $this->category_object = $category_object;
         }
         if ($this->form_type == self :: TYPE_EDIT) {
@@ -86,7 +88,6 @@ class CatForm extends FormValidator
         //check if we are a root category
         //if so, you can only choose between courses
         if ($this->category_object->get_parent_id() == '0') {
-            //$select = $this->addElement('select','select_course',array(get_lang('PickACourse'),'test'), null);
             $coursecat = Category :: get_not_created_course_categories(
                 api_get_user_id()
             );
@@ -146,6 +147,7 @@ class CatForm extends FormValidator
             $session_id,
             false
         ); //already init
+
         $links = null;
         if (isset($test_cats[0])) {
             $links = $test_cats[0]->get_links();
@@ -167,17 +169,17 @@ class CatForm extends FormValidator
 
         $this->setDefaults(
             array(
-                'name' 				=> $category_name,
-                'description' 		=> $this->category_object->get_description(),
-                'hid_user_id' 		=> $this->category_object->get_user_id(),
-                'hid_parent_id' 	=> $this->category_object->get_parent_id(),
-                'grade_model_id' 	=> $grade_model_id,
-                'skills'            => $skills,
-                'weight' 			=> $this->category_object->get_weight(),
-                'visible' 			=> $this->category_object->is_visible(),
-                'certif_min_score'  => $this->category_object->get_certificate_min_score(),
+                'name' => $category_name,
+                'description' => $this->category_object->get_description(),
+                'hid_user_id' => $this->category_object->get_user_id(),
+                'hid_parent_id' => $this->category_object->get_parent_id(),
+                'grade_model_id' => $grade_model_id,
+                'skills' => $skills,
+                'weight' => $this->category_object->get_weight(),
+                'visible' => $this->category_object->is_visible(),
+                'certif_min_score' => $this->category_object->get_certificate_min_score(),
                 'generate_certificates' => $this->category_object->getGenerateCertificates(),
-                'is_requirement' => $this->category_object->getIsRequirement()
+                'is_requirement' => $this->category_object->getIsRequirement(),
             )
         );
         $this->addElement('hidden', 'hid_id', $this->category_object->get_id());
@@ -194,7 +196,6 @@ class CatForm extends FormValidator
      */
     private function build_basic_form()
     {
-        $this->addElement('hidden', 'zero', 0);
         $this->addText(
             'name',
             get_lang('CategoryName'),
@@ -217,15 +218,16 @@ class CatForm extends FormValidator
         } else {
             $value = 100;
         }
-        $this->addText('weight',
+
+        $this->addFloat(
+            'weight',
             array(
                 get_lang('TotalWeight'),
-                get_lang('TotalSumOfWeights')
+                get_lang('TotalSumOfWeights'),
             ),
             true,
-            array('value' => $value, 'class' => 'span1', 'maxlength' => '5')
+            array('value' => $value, 'maxlength' => '5')
         );
-        $this->addRule('weight', get_lang('ThisFieldIsRequired'), 'required');
 
         $skillsDefaults = [];
 
@@ -263,24 +265,23 @@ class CatForm extends FormValidator
             $this->addText(
                 'certif_min_score',
                 get_lang('CertificateMinScore'),
-                false,
+                true,
                 array('maxlength' => '5')
             );
-            $this->addRule(
-                'certif_min_score',
-                get_lang('ThisFieldIsRequired'),
-                'required'
-            );
             $this->addRule(
                 'certif_min_score',
                 get_lang('OnlyNumbers'),
                 'numeric'
             );
             $this->addRule(
-                array('certif_min_score', 'zero'),
+                'certif_min_score',
                 get_lang('NegativeValue'),
                 'compare',
-                '>='
+                '>=',
+                'server',
+                false,
+                false,
+                0
             );
         } else {
             $this->addElement('checkbox', 'visible', null, get_lang('Visible'));
@@ -296,11 +297,8 @@ class CatForm extends FormValidator
 
         if (isset($this->category_object) &&
             $this->category_object->get_parent_id() == 0 &&
-            (api_is_platform_admin() || api_get_setting(
-                    'teachers_can_change_grade_model_settings'
-                ) == 'true')
+            (api_is_platform_admin() || api_get_setting('teachers_can_change_grade_model_settings') == 'true')
         ) {
-
             // Getting grade models
             $obj = new GradeModel();
             $obj->fill_grade_model_select_in_form(
@@ -368,14 +366,6 @@ class CatForm extends FormValidator
             $this->addButtonUpdate(get_lang('EditCategory'));
         }
 
-        $this->addRule('weight', get_lang('OnlyNumbers'), 'numeric');
-        $this->addRule(
-            array('weight', 'zero'),
-            get_lang('NegativeValue'),
-            'compare',
-            '>='
-        );
-
         $setting = api_get_setting('tool_visible_by_default_at_creation');
         $visibility_default = 1;
         if (isset($setting['gradebook']) && $setting['gradebook'] == 'false') {

+ 49 - 89
main/gradebook/lib/fe/evalform.class.php

@@ -127,8 +127,6 @@ class EvalForm extends FormValidator
     protected function build_all_results_edit_form()
     {
         //extra field for check on maxvalue
-        $this->addElement('hidden', 'maxvalue', $this->evaluation_object->get_max());
-        $this->addElement('hidden', 'minvalue', 0);
         $this->addElement('header', get_lang('EditResult'));
 
         $renderer = & $this->defaultRenderer();
@@ -181,35 +179,18 @@ class EvalForm extends FormValidator
             $result = $result_and_user['result'];
 
             $renderer = &$this->defaultRenderer();
-            $this->addText(
+            $this->addFloat(
                 'score['.$result->get_id().']',
                 $this->build_stud_label($user['user_id'], $user['username'], $user['lastname'], $user['firstname']),
                 false,
                 array(
-                    'class' => "span2",
                     'maxlength' => 5
-                )
-            );
-
-            $this->addRule('score[' . $result->get_id() . ']', get_lang('OnlyNumbers'), 'numeric');
-            $this->addRule(
-                array(
-                    'score['.$result->get_id().']',
-                    'maxvalue',
                 ),
-                get_lang('OverMax'),
-                'compare',
-                '<='
-            );
-            $this->addRule(
-                array(
-                    'score['.$result->get_id().']',
-                    'minvalue',
-                ),
-                get_lang('UnderMin'),
-                'compare',
-                '>='
+                false,
+                0,
+                $this->evaluation_object->get_max()
             );
+
             $defaults['score[' . $result->get_id() . ']'] = $result->get_score();
 
             if (api_is_western_name_order()) {
@@ -308,18 +289,18 @@ class EvalForm extends FormValidator
                 $scoreColumnProperties['autofocus'] = '';
                 $firstUser = false;
             }
+
             //user_id, user.username, lastname, firstname
-            $this->addText(
+            $this->addFloat(
                 $element_name,
                 $this->build_stud_label($user[0], $user[1], $user[2], $user[3]),
                 false,
-                $scoreColumnProperties
+                $scoreColumnProperties,
+                false,
+                0,
+                $this->evaluation_object->get_max()
             );
 
-            $this->addRule($element_name, get_lang('OnlyNumbers'), 'numeric');
-            $this->addRule(array($element_name, 'maxvalue'), get_lang('OverMax'), 'compare', '<=');
-            $this->addRule(array($element_name, 'minvalue'), get_lang('UnderMin'), 'compare', '>=');
-
             if (api_is_western_name_order()) {
                 $user_info = '<td align="left" >' . $user[3] . '</td>';
                 $user_info .= '<td align="left" >' . $user[2] . '</td>';
@@ -358,16 +339,18 @@ class EvalForm extends FormValidator
      */
     protected function build_result_edit_form()
     {
-        $this->setDefaults(array(
-            'score' => $this->result_object->get_score(),
-            'maximum' => $this->evaluation_object->get_max()
-        ));
+        $this->setDefaults(
+            array(
+                'score' => $this->result_object->get_score(),
+                'maximum' => $this->evaluation_object->get_max(),
+            )
+        );
         $userInfo = api_get_user_info($this->result_object->get_user_id());
         $renderer = & $this->defaultRenderer();
         $renderer->setCustomElementTemplate('<span>{element}</span> ');
         $this->addHeader(get_lang('User').': '.$userInfo['complete_name']);
 
-        $this->addText(
+        $this->addFloat(
             'score',
             array(
                 get_lang('Score'),
@@ -378,42 +361,14 @@ class EvalForm extends FormValidator
             array(
                 'size' => '4',
                 'maxlength' => '5',
-            )
+            ),
+            false,
+            0,
+            $this->evaluation_object->get_max()
         );
 
         $this->addButtonSave(get_lang('Edit'), 'submit');
-        $this->addElement('hidden', 'minvalue', 0);
         $this->addElement('hidden', 'hid_user_id', $this->result_object->get_user_id());
-        $this->addElement('hidden', 'maxvalue', $this->evaluation_object->get_max());
-
-        $this->addRule(
-            'score',
-            get_lang('OnlyNumbers'),
-            'numeric',
-            null,
-            'client'
-        );
-
-        $this->addRule(
-            array(
-                'score',
-                'maxvalue',
-            ),
-            get_lang('OverMax'),
-            'compare',
-            '<=',
-            'client'
-        );
-        $this->addRule(
-            array(
-                'score',
-                'minvalue',
-            ),
-            get_lang('UnderMin'),
-            'compare',
-            '>=',
-            'client'
-        );
     }
 
     /**
@@ -483,14 +438,18 @@ class EvalForm extends FormValidator
         }
 
         $this->addElement('header', $form_title);
-        $this->addElement('hidden', 'zero', 0);
         $this->addElement('hidden', 'hid_user_id');
         $this->addElement('hidden', 'hid_course_code');
 
-        $this->addText('name', get_lang('EvaluationName'), true, array(
-            'maxlength' => '50',
-            'id' => 'evaluation_title'
-        ));
+        $this->addText(
+            'name',
+            get_lang('EvaluationName'),
+            true,
+            array(
+                'maxlength' => '50',
+                'id' => 'evaluation_title',
+            )
+        );
 
         $cat_id = $this->evaluation_object->get_category_id();
 
@@ -517,7 +476,6 @@ class EvalForm extends FormValidator
                 array('id' => 'hid_category_id')
             );
             $this->addRule('hid_category_id', get_lang('ThisFieldIsRequired'), 'nonzero');
-
             $default_weight = 0;
             if (!empty($all_categories)) {
                 foreach ($all_categories as $my_cat) {
@@ -543,7 +501,7 @@ class EvalForm extends FormValidator
             }
         }
 
-        $this->addText(
+        $this->addFloat(
             'weight_mask',
             array(
                 get_lang('Weight'),
@@ -557,12 +515,6 @@ class EvalForm extends FormValidator
             )
         );
 
-        /* $this->addText('weight', array(null, null, '/ <span id="max_weight">'.$default_weight.'</span>'), true, array (
-          'size' => '4',
-          'maxlength' => '5',
-          'class' => 'span1'
-          )); */
-
         if ($edit) {
             if (!$this->evaluation_object->has_results()) {
                 $this->addText(
@@ -585,10 +537,14 @@ class EvalForm extends FormValidator
                 );
             }
         } else {
-            $this->addText('max', get_lang('QualificationNumeric'), true, array(
-                'class' => 'span1',
-                'maxlength' => '5'
-            ));
+            $this->addText(
+                'max',
+                get_lang('QualificationNumeric'),
+                true,
+                array(
+                    'maxlength' => '5',
+                )
+            );
             $default_max = api_get_setting('gradebook_default_weight');
             $defaults['max'] = isset($default_max) ? $default_max : 100;
             $this->setDefaults($defaults);
@@ -597,11 +553,8 @@ class EvalForm extends FormValidator
         $this->addElement('textarea', 'description', get_lang('Description'));
         $this->addRule('hid_category_id', get_lang('ThisFieldIsRequired'), 'required');
         $this->addElement('checkbox', 'visible', null, get_lang('Visible'));
-        $this->addRule('weight_mask', get_lang('OnlyNumbers'), 'numeric');
-        $this->addRule(array('weight_mask', 'zero'), get_lang('NegativeValue'), 'compare', '>=');
         $this->addRule('max', get_lang('OnlyNumbers'), 'numeric');
-        $this->addRule(array('max', 'zero'), get_lang('NegativeValue'), 'compare', '>=');
-
+        $this->addRule('max', get_lang('NegativeValue'), 'compare', '>=');
         $setting = api_get_setting('tool_visible_by_default_at_creation');
         $visibility_default = 1;
         if (isset($setting['gradebook']) && $setting['gradebook'] == 'false') {
@@ -620,6 +573,13 @@ class EvalForm extends FormValidator
         parent :: setDefaults($defaults, $filter);
     }
 
+    /**
+     * @param $id
+     * @param $username
+     * @param $lastname
+     * @param $firstname
+     * @return string
+     */
     private function build_stud_label($id, $username, $lastname, $firstname)
     {
         $opendocurl_start = '';
@@ -636,7 +596,7 @@ class EvalForm extends FormValidator
         return $opendocurl_start . api_get_person_name($firstname, $lastname) . ' (' . $username . ')' . $opendocurl_end;
     }
 
-    function sort_by_user($item1, $item2)
+    public function sort_by_user($item1, $item2)
     {
         $user1 = $item1['user'];
         $user2 = $item2['user'];

+ 39 - 26
main/gradebook/lib/fe/linkaddeditform.class.php

@@ -31,16 +31,14 @@ class LinkAddEditForm extends FormValidator
         if (isset($link_object)) {
             $link = $link_object;
         } elseif (isset($link_type) && isset($category_object)) {
-            $link = LinkFactory :: create ($link_type);
+            $link = LinkFactory:: create($link_type);
             $link->set_course_code(api_get_course_id());
             $link->set_category_id($category_object[0]->get_id());
         } else {
-            die ('LinkAddEditForm error: define link_type/category_object or link_object');
+            die('LinkAddEditForm error: define link_type/category_object or link_object');
         }
 
         $defaults = array();
-        $this->addElement('hidden', 'zero', 0);
-
         if (!empty($_GET['editlink'])) {
             $this->addElement('header', '', get_lang('EditLink'));
         }
@@ -56,8 +54,18 @@ class LinkAddEditForm extends FormValidator
                 }
             }
         } else {
-            $this->addElement('label', get_lang('Name'),  '<span class="freeze">'.$link->get_name().' ['.$link->get_type_name().']</span>');
-            $this->addElement('hidden','name_link',$link->get_name(),array('id'=>'name_link'));
+            $this->addElement(
+                'label',
+                get_lang('Name'),
+                '<span class="freeze">'.$link->get_name().' ['.$link->get_type_name().']</span>'
+            );
+
+            $this->addElement(
+                'hidden',
+                'name_link',
+                $link->get_name(),
+                array('id' => 'name_link')
+            );
         }
 
         if (count($category_object) == 1) {
@@ -71,7 +79,6 @@ class LinkAddEditForm extends FormValidator
                 array('id' => 'hide_category_id')
             );
             $this->addRule('select_gradebook', get_lang('ThisFieldIsRequired'), 'nonzero');
-
             $default_weight = 0;
             if (!empty($category_object)) {
                 foreach ($category_object as $my_cat) {
@@ -95,33 +102,25 @@ class LinkAddEditForm extends FormValidator
             }
         }
 
-        $this->addText(
+        $this->addFloat(
             'weight_mask',
-            array(get_lang('Weight'), null, ' [0 .. <span id="max_weight">'.$category_object[0]->get_weight().'</span>] '),
+            array(
+                get_lang('Weight'),
+                null,
+                ' [0 .. <span id="max_weight">'.$category_object[0]->get_weight(
+                ).'</span>] ',
+            ),
             true,
             array(
                 'size' => '4',
-                'maxlength' => '5',
-                'class' => 'span1'
+                'maxlength' => '5'
             )
         );
 
         $this->addElement('hidden', 'weight');
 
-        /*
-
-        // ELEMENT: weight
-        $this->addText('weight', array(get_lang('Weight'), null, '/ <span id="max_weight">'.$default_weight.'</span>'), true, array (
-            'size' => '4',
-            'maxlength' => '5',
-            'class' => 'span1'
-        ));*/
-
-        $this->addRule('weight_mask', get_lang('OnlyNumbers'), 'numeric');
-        $this->addRule(array ('weight_mask', 'zero'), get_lang('NegativeValue'), 'compare', '>=');
         if ($form_type == self :: TYPE_EDIT) {
             $parent_cat = Category :: load($link->get_category_id());
-
             if ($parent_cat[0]->get_parent_id() == 0) {
                 $values['weight'] = $link->get_weight();
             } else {
@@ -140,11 +139,20 @@ class LinkAddEditForm extends FormValidator
         // ELEMENT: max
         if ($link->needs_max()) {
             if ($form_type == self :: TYPE_EDIT && $link->has_results()) {
-                $this->addText('max', get_lang('QualificationNumeric'), false, array ('size' => '4','maxlength' => '5', 'disabled' => 'disabled'));
+                $this->addText(
+                    'max',
+                    get_lang('QualificationNumeric'),
+                    false,
+                    array(
+                        'size' => '4',
+                        'maxlength' => '5',
+                        'disabled' => 'disabled',
+                    )
+                );
             } else {
                 $this->addText('max', get_lang('QualificationNumeric'), true, array ('size' => '4','maxlength' => '5'));
                 $this->addRule('max', get_lang('OnlyNumbers'), 'numeric');
-                $this->addRule(array ('max', 'zero'), get_lang('NegativeValue'), 'compare', '>=');
+                $this->addRule('max', get_lang('NegativeValue'), 'compare', '>=');
             }
             if ($form_type == self :: TYPE_EDIT) {
                 $defaults['max'] = $link->get_max();
@@ -153,7 +161,12 @@ class LinkAddEditForm extends FormValidator
 
         // ELEMENT: description
         if ($link->needs_name_and_description()) {
-            $this->addElement('textarea', 'description', get_lang('Description'), array ('rows' => '3','cols' => '34'));
+            $this->addElement(
+                'textarea',
+                'description',
+                get_lang('Description'),
+                array('rows' => '3', 'cols' => '34')
+            );
             if ($form_type == self :: TYPE_EDIT) {
                 $defaults['description'] = $link->get_description();
             }

+ 13 - 6
main/gradebook/lib/fe/linkform.class.php

@@ -108,17 +108,24 @@ class LinkForm extends FormValidator
             if (!$link->needs_name_and_description() && count($link->get_all_links()) == '0') {
                 $select->addoption($link->get_type_name(), $linkType, 'disabled');
             } else {
-                if ($link->get_type() == LINK_EXERCISE) {
-                    // Adding exercise
-                    $select->addoption($link->get_type_name(), $linkType);
-                    // Adding hot potatoes
-                    $linkHot = $this->createLink(LINK_HOTPOTATOES, $courseCode);
+                $select->addoption($link->get_type_name(), $linkType);
+            }
+
+            if ($link->get_type() == LINK_EXERCISE) {
+                // Adding hot potatoes
+                $linkHot = $this->createLink(LINK_HOTPOTATOES, $courseCode);
+                $linkHot->setHp(true);
+                if ($linkHot->get_all_links(true)) {
                     $select->addoption(
                         '&nbsp;&nbsp;&nbsp;'.$linkHot->get_type_name(),
                         LINK_HOTPOTATOES
                     );
                 } else {
-                    $select->addoption($link->get_type_name(), $linkType);
+                    $select->addoption(
+                        '&nbsp;&nbsp;&nbsp;'.$linkHot->get_type_name(),
+                        LINK_HOTPOTATOES,
+                        'disabled'
+                    );
                 }
             }
         }

BIN
main/img/icons/22/cd_na.png


+ 1 - 1
main/inc/ajax/exercise.ajax.php

@@ -470,7 +470,7 @@ switch ($action) {
 
                 $_SESSION['duration_time'][$key] = time();
 
-                Event::update_event_exercice(
+                Event::update_event_exercise(
                     $exe_id,
                     $objExercise->selectId(),
                     $total_score,

+ 1 - 1
main/inc/ajax/work.ajax.php

@@ -51,7 +51,7 @@ switch ($action) {
                     $groupId,
                     $userId,
                     $file,
-                    false,
+                    api_get_configuration_value('assignment_prevent_duplicate_upload'),
                     false
                 );
 

+ 2 - 2
main/inc/lib/api.lib.php

@@ -1260,13 +1260,13 @@ function api_is_self_registration_allowed()
  *
  * example: The function can be used to check if a user is logged in
  *          if (api_get_user_id())
- * @return integer the id of the current user, 0 if is empty
+ * @return int the id of the current user, 0 if is empty
  */
 function api_get_user_id()
 {
     $userInfo = Session::read('_user');
     if ($userInfo && isset($userInfo['user_id'])) {
-        return $userInfo['user_id'];
+        return (int) $userInfo['user_id'];
     }
     return 0;
 }

+ 1 - 1
main/inc/lib/events.lib.php

@@ -318,7 +318,7 @@ class Event
      * @author Julio Montoya Armas <gugli100@gmail.com> Reworked 2010
      * @desc Record result of user when an exercise was done
      */
-    public static function update_event_exercice(
+    public static function update_event_exercise(
         $exeid,
         $exo_id,
         $score,

+ 1 - 1
main/inc/lib/exercise.lib.php

@@ -3762,7 +3762,7 @@ HOTSPOT;
             $learnpath_item_view_id = $exercise_stat_info['orig_lp_item_view_id'];
 
             if (api_is_allowed_to_session_edit()) {
-                Event::update_event_exercice(
+                Event::update_event_exercise(
                     $exercise_stat_info['exe_id'],
                     $objExercise->selectId(),
                     $total_score,

+ 0 - 3
main/inc/lib/extra_field.lib.php

@@ -1160,8 +1160,6 @@ class ExtraField extends Model
                                 $form->freeze('extra_'.$field_details['variable']);
                             }
                         }
-
-                        $form->applyFilter('theme', 'trim');
                         break;
                     case ExtraField::FIELD_TYPE_DATETIME:
                         $form->addDateTimePicker(
@@ -1178,7 +1176,6 @@ class ExtraField extends Model
                                 $form->freeze('extra_'.$field_details['variable']);
                             }
                         }
-                        $form->applyFilter('theme', 'trim');
                         break;
                     case ExtraField::FIELD_TYPE_DOUBLE_SELECT:
                         $first_select_id = 'first_extra_'.$field_details['variable'];

+ 19 - 0
main/inc/lib/formvalidator/Element/DateRangePicker.php

@@ -167,4 +167,23 @@ class DateRangePicker extends HTML_QuickForm_text
 
         return true;
     }
+
+    /**
+     * @param mixed $value
+     * @param array $submitValues
+     * @param array $errors
+     */
+    public function getSubmitValue($value, &$submitValues, &$errors)
+    {
+        /** @var DateRangePicker $element */
+        $elementName = $this->getName();
+        $parsedDates = $this->parseDateRange($value);
+        $validateFormat = $this->getAttribute('validate_format');
+
+        if (!$this->validateDates($parsedDates, $validateFormat)) {
+            $errors[$elementName] = get_lang('CheckDates');
+        }
+        $submitValues[$elementName.'_start'] = $parsedDates['start'];
+        $submitValues[$elementName.'_end'] = $parsedDates['end'];
+    }
 }

+ 84 - 0
main/inc/lib/formvalidator/Element/FloatNumber.php

@@ -0,0 +1,84 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+/**
+ * Float element
+ *
+ * Accepts values like 3.1415 and 3,1415 (its processed and converted to 3.1415)
+ *
+ * Class Float
+ */
+class FloatNumber extends HTML_QuickForm_text
+{
+    /**
+     * @param string $elementName
+     * @param string $elementLabel
+     * @param array  $attributes
+     */
+    public function __construct($elementName = null, $elementLabel = null, $attributes = null)
+    {
+        if (!isset($attributes['id'])) {
+            $attributes['id'] = $elementName;
+        }
+
+        $attributes['type'] = 'float';
+        $attributes['class'] = 'form-control';
+
+        parent::__construct($elementName, $elementLabel, $attributes);
+        $this->_appendName = true;
+        $this->setType('float');
+    }
+
+     /**
+     * @param string $value
+     */
+    public function setValue($value)
+    {
+        $value = api_float_val($value);
+        $this->updateAttributes(
+            array(
+                'value'=>$value
+            )
+        );
+    }
+
+    /**
+     * @return float
+     */
+    public function getValue()
+    {
+         $value = $this->getAttribute('value');
+         $value = api_float_val($value);
+
+         return $value;
+    }
+
+    /**
+     * @param mixed $value
+     * @param array $submitValues
+     * @param array $errors
+     */
+    public function getSubmitValue($value, &$submitValues, &$errors)
+    {
+        $value = api_float_val($value);
+        $elementName = $this->getName();
+        $submitValues[$elementName] = $value;
+
+        return $value;
+    }
+
+    /**
+     * We check the options and return only the values that _could_ have been
+     * selected. We also return a scalar value if select is not "multiple"
+     */
+    public function exportValue(&$submitValues, $assoc = false)
+    {
+        $value = $this->_findValue($submitValues);
+        $value = api_float_val($value);
+        if (!$value) {
+            $value = '';
+        }
+
+        return $this->_prepareValue($value, $assoc);
+    }
+}

+ 18 - 18
main/inc/lib/formvalidator/Element/SelectLanguage.php

@@ -7,22 +7,22 @@
  */
 class SelectLanguage extends HTML_QuickForm_select
 {
-	/**
-	 * Class constructor
-	 */
-	public function __construct($elementName = null, $elementLabel = null, $options = null, $attributes = null)
-	{
-		parent::__construct($elementName, $elementLabel, $options, $attributes);
-		// Get all languages
-		$languages = api_get_languages();
-		$this->_options = array();
-		$this->_values = array();
-		foreach ($languages['name'] as $index => $name) {
-			if ($languages['folder'][$index] == api_get_setting('platformLanguage')) {
-				$this->addOption($name, $languages['folder'][$index], array('selected'=>'selected'));
-			} else {
-				$this->addOption($name, $languages['folder'][$index]);
-			}
-		}
-	}
+    /**
+     * Class constructor
+     */
+    public function __construct($elementName = null, $elementLabel = null, $options = null, $attributes = null)
+    {
+        parent::__construct($elementName, $elementLabel, $options, $attributes);
+        // Get all languages
+        $languages = api_get_languages();
+        $this->_options = array();
+        $this->_values = array();
+        foreach ($languages['name'] as $index => $name) {
+            if ($languages['folder'][$index] == api_get_setting('platformLanguage')) {
+                $this->addOption($name, $languages['folder'][$index], array('selected'=>'selected'));
+            } else {
+                $this->addOption($name, $languages['folder'][$index]);
+            }
+        }
+    }
 }

+ 19 - 15
main/inc/lib/formvalidator/Element/SelectTheme.php

@@ -6,19 +6,23 @@
 */
 class SelectTheme extends HTML_QuickForm_select
 {
-	/**
-	 * Class constructor
-	 */
-	public function __construct($elementName=null, $elementLabel=null, $options=null, $attributes=null)
-	{
-		parent::__construct($elementName, $elementLabel, $options, $attributes);
-		// Get all languages
-		$themes = api_get_themes();
-		$this->_options = array();
-		$this->_values = array();
-		$this->addOption('--',''); // no theme select
-		for ($i=0; $i< count($themes[0]); $i++) {
-			$this->addOption($themes[1][$i],$themes[0][$i]);
-		}
-	}
+    /**
+     * Class constructor
+     */
+    public function __construct(
+        $elementName = null,
+        $elementLabel = null,
+        $options = null,
+        $attributes = null
+    ) {
+        parent::__construct($elementName, $elementLabel, $options, $attributes);
+        // Get all languages
+        $themes = api_get_themes();
+        $this->_options = array();
+        $this->_values = array();
+        $this->addOption('--', ''); // no theme select
+        for ($i = 0; $i < count($themes[0]); $i++) {
+            $this->addOption($themes[1][$i], $themes[0][$i]);
+        }
+    }
 }

+ 4 - 4
main/inc/lib/formvalidator/Element/Url.php

@@ -9,10 +9,10 @@
 class Url extends HTML_QuickForm_text
 {
     /**
-     * Constructor of Url class
-     * @param type $elementName
-     * @param type $elementLabel
-     * @param type $attributes
+     * Url constructor.
+     * @param string $elementName
+     * @param string $elementLabel
+     * @param array $attributes
      */
     public function __construct($elementName = null, $elementLabel = null, $attributes = null)
     {

+ 3 - 2
main/inc/lib/formvalidator/Element/receivers.php

@@ -37,6 +37,7 @@ class HTML_QuickForm_receivers extends HTML_QuickForm_group
 		$this->_appendName = true;
 		$this->_type = 'receivers';
 	}
+
 	/**
 	 * Create the form elements to build this element group
 	 */
@@ -48,6 +49,7 @@ class HTML_QuickForm_receivers extends HTML_QuickForm_group
 		$this->_elements[] = new HTML_QuickForm_advmultiselect('to', '', $this->receivers);
 		$this->_elements[2]->setSelected($this->receivers_selected);
 	}
+
 	/**
 	 * HTML representation
 	 */
@@ -91,5 +93,4 @@ class HTML_QuickForm_receivers extends HTML_QuickForm_group
 	{
 		$renderer->renderElement($this, $required, $error);
 	}
-}
-?>
+}

+ 232 - 0
main/inc/lib/formvalidator/FormValidator.class.php

@@ -878,6 +878,159 @@ EOT;
         }
     }
 
+    /**
+     * Adds a Google Maps Geolocalization field to the form
+     *
+     * @param $name
+     * @param $label
+     */
+    public function addGeoLocationMapField($name, $label)
+    {
+        $gMapsPlugin = GoogleMapsPlugin::create();
+        $geolocalization = $gMapsPlugin->get('enable_api') === 'true';
+
+        if ($geolocalization) {
+            $gmapsApiKey = $gMapsPlugin->get('api_key');
+            $this->addHtml('<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?key='. $gmapsApiKey . '" ></script>');
+        }
+        $this->addElement(
+            'text',
+            $name,
+            $label,
+            ['id' => $name]
+        );
+        $this->applyFilter($name, 'stripslashes');
+        $this->applyFilter($name, 'trim');
+        $this->addHtml('
+                            <div class="form-group">
+                                <label for="geolocalization_'.$name.'" class="col-sm-2 control-label"></label>
+                                <div class="col-sm-8">
+                                    <button class="null btn btn-default " id="geolocalization_'.$name.'" name="geolocalization_'.$name.'" type="submit"><em class="fa fa-map-marker"></em> '.get_lang('Geolocalization').'</button>
+                                    <button class="null btn btn-default " id="myLocation_'.$name.'" name="myLocation_'.$name.'" type="submit"><em class="fa fa-crosshairs"></em> '.get_lang('MyLocation').'</button>
+                                </div>
+                            </div>
+                        ');
+
+        $this->addHtml('
+                            <div class="form-group">
+                                <label for="map_'.$name.'" class="col-sm-2 control-label">
+                                    '.$label.' - '.get_lang('Map').'
+                                </label>
+                                <div class="col-sm-8">
+                                    <div name="map_'.$name.'" id="map_'.$name.'" style="width:100%; height:300px;">
+                                    </div>
+                                </div>
+                            </div>
+                        ');
+
+        $this->addHtml(
+            '<script>
+                $(document).ready(function() {
+
+                    if (typeof google === "object") {
+
+                        var address = $("#' . $name . '").val();
+                        initializeGeo'.$name.'(address, false);
+
+                        $("#geolocalization_'.$name.'").on("click", function() {
+                            var address = $("#'.$name.'").val();
+                            initializeGeo'.$name.'(address, false);
+                            return false;
+                        });
+
+                        $("#myLocation_'.$name.'").on("click", function() {
+                            myLocation'.$name.'();
+                            return false;
+                        });
+
+                        $("#'.$name.'").keypress(function (event) {
+                            if (event.which == 13) {
+                                $("#geolocalization_'.$name.'").click();
+                                return false;
+                            }
+                        });
+
+                    } else {
+                        $("#map_'.$name.'").html("<div class=\"alert alert-info\">' . get_lang('YouNeedToActivateTheGoogleMapsPluginInAdminPlatformToSeeTheMap') . '</div>");
+                    }
+
+                });
+
+                function myLocation'.$name.'() {
+                    if (navigator.geolocation) {
+                        var geoPosition = function(position) {
+                            var lat = position.coords.latitude;
+                            var lng = position.coords.longitude;
+                            var latLng = new google.maps.LatLng(lat, lng);
+                            initializeGeo'.$name.'(false, latLng)
+                        };
+
+                        var geoError = function(error) {
+                            alert("Geocode ' . get_lang('Error') . ': " + error);
+                        };
+
+                        var geoOptions = {
+                            enableHighAccuracy: true
+                        };
+
+                        navigator.geolocation.getCurrentPosition(geoPosition, geoError, geoOptions);
+                    }
+                }
+
+                function initializeGeo'.$name.'(address, latLng) {
+                    var geocoder = new google.maps.Geocoder();
+                    var latlng = new google.maps.LatLng(-34.397, 150.644);
+                    var myOptions = {
+                        zoom: 15,
+                        center: latlng,
+                        mapTypeControl: true,
+                        mapTypeControlOptions: {
+                            style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
+                        },
+                        navigationControl: true,
+                        mapTypeId: google.maps.MapTypeId.ROADMAP
+                    };
+
+                    map_'.$name.' = new google.maps.Map(document.getElementById("map_'.$name.'"), myOptions);
+
+                    var parameter = address ? { "address": address } : latLng ? { "latLng": latLng } : false;
+
+                    if (geocoder && parameter) {
+                        geocoder.geocode(parameter, function(results, status) {
+                            if (status == google.maps.GeocoderStatus.OK) {
+                                if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
+                                    map_'.$name.'.setCenter(results[0].geometry.location);
+                                    if (!address) {
+                                        $("#'.$name.'").val(results[0].formatted_address);
+                                    }
+                                    var infowindow = new google.maps.InfoWindow({
+                                        content: "<b>" + $("#'.$name.'").val() + "</b>",
+                                        size: new google.maps.Size(150, 50)
+                                    });
+
+                                    var marker = new google.maps.Marker({
+                                        position: results[0].geometry.location,
+                                        map: map_'.$name.',
+                                        title: $("#'.$name.'").val()
+                                    });
+                                    google.maps.event.addListener(marker, "click", function() {
+                                        infowindow.open(map_'.$name.', marker);
+                                    });
+                                } else {
+                                    alert("' . get_lang("NotFound") . '");
+                                }
+
+                            } else {
+                                alert("Geocode ' . get_lang('Error') . ': ' . get_lang("AddressField") . ' ' . get_lang("NotFound") . '");
+                            }
+                        });
+                    }
+                }
+            </script>
+        ');
+
+    }
+
     /**
      * @param string $name
      * @param string $label
@@ -1185,6 +1338,85 @@ EOT;
         );
     }
 
+    /**
+     * @param $name
+     * @param $label
+     * @param bool $required
+     * @param array $attributes
+     * @param bool $allowNegative
+     * @param null $minValue
+     * @param null $maxValue
+     */
+    public function addFloat(
+        $name,
+        $label,
+        $required = false,
+        $attributes = [],
+        $allowNegative = false,
+        $minValue = null,
+        $maxValue = null
+    ) {
+        $this->addElement(
+            'FloatNumber',
+            $name,
+            $label,
+            $attributes
+        );
+
+        $this->applyFilter($name, 'trim');
+
+        if ($required) {
+            $this->addRule($name, get_lang('ThisFieldIsRequired'), 'required');
+        }
+
+        // Rule allows "," and "."
+        /*$this->addRule(
+            $name,
+            get_lang('OnlyNumbers'),
+            'regex',
+            '/(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)|(^-?\d\d*\,\d*$)|(^-?\,\d\d*$)/'
+        );*/
+
+        if ($allowNegative == false) {
+            $this->addRule(
+                $name,
+                get_lang('NegativeValue'),
+                'compare',
+                '>=',
+                'server',
+                false,
+                false,
+                0
+            );
+        }
+
+        if (!is_null($minValue)) {
+            $this->addRule(
+                $name,
+                get_lang('UnderMin'),
+                'compare',
+                '>=',
+                'server',
+                false,
+                false,
+                $minValue
+            );
+        }
+
+        if (!is_null($maxValue)) {
+            $this->addRule(
+                $name,
+                get_lang('OverMax'),
+                'compare',
+                '<=',
+                'server',
+                false,
+                false,
+                $maxValue
+            );
+        }
+    }
+
     /**
      * Adds a text field for letters and spaces to the form.
      * A trim-filter is attached to the field.

+ 9 - 9
main/inc/lib/formvalidator/Rule/Date.php

@@ -7,16 +7,16 @@
  */
 class HTML_QuickForm_Rule_Date extends HTML_QuickForm_Rule
 {
-	/**
-	 * Check a date
-	 * @see HTML_QuickForm_Rule
-	 * @param string $date example 2014-04-30
+    /**
+     * Check a date
+     * @see HTML_QuickForm_Rule
+     * @param string $date example 2014-04-30
      * @param array $options
      *
-	 * @return boolean True if date is valid
-	 */
-	public function validate($date, $options)
-	{
+     * @return boolean True if date is valid
+     */
+    public function validate($date, $options)
+    {
         return api_is_valid_date($date, 'Y-m-d');
-	}
+    }
 }

+ 14 - 15
main/inc/lib/formvalidator/Rule/FileName.php

@@ -8,19 +8,18 @@
  */
 class HTML_QuickForm_Rule_FileName extends HTML_QuickForm_Rule
 {
-
-	/**
-	 * @param $value array     Uploaded file info (from $_FILES)
-	 * @param null $options
-	 * @return bool
-	 */
-	public function validate($value, $options = null)
-	{
-		if ((isset($elementValue['error']) && $elementValue['error'] == 0) ||
-			(!empty($elementValue['tmp_name']) && $elementValue['tmp_name'] != 'none')) {
-			return is_uploaded_file($elementValue['tmp_name']);
-		} else {
-			return false;
-		}
-	}
+    /**
+     * @param $value array     Uploaded file info (from $_FILES)
+     * @param null $options
+     * @return bool
+     */
+    public function validate($value, $options = null)
+    {
+        if ((isset($elementValue['error']) && $elementValue['error'] == 0) ||
+            (!empty($elementValue['tmp_name']) && $elementValue['tmp_name'] != 'none')) {
+            return is_uploaded_file($elementValue['tmp_name']);
+        } else {
+            return false;
+        }
+    }
 }

+ 1 - 1
main/inc/lib/myspace.lib.php

@@ -87,7 +87,7 @@ class MySpace
     public function export_csv($header, $data, $file_name = 'export.csv')
     {
         $archive_path = api_get_path(SYS_ARCHIVE_PATH);
-        $archive_url = api_get_path(WEB_CODE_PATH).'course_info/download.php?archive=';
+        $archive_url = api_get_path(WEB_CODE_PATH).'course_info/download.php?archive_path=&archive=';
 
         if (!$open = fopen($archive_path.$file_name, 'w+')) {
             $message = get_lang('noOpen');

+ 0 - 1
main/inc/lib/pdf.lib.php

@@ -561,7 +561,6 @@ class PDF
             $course_info = api_get_course_info($course_code);
             // course path
             $store_path  = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/'.api_get_current_access_url_id().'_pdf_watermark.png';
-
         } else {
             // course path
             $store_path = api_get_path(SYS_CODE_PATH).'default_course_document/images/'.api_get_current_access_url_id().'_pdf_watermark.png';

+ 79 - 151
main/inc/lib/pear/HTML/QuickForm.php

@@ -42,16 +42,16 @@
  *
  * @see HTML_QuickForm::errorMessage()
  */
-define('QUICKFORM_OK',                      1);
-define('QUICKFORM_ERROR',                  -1);
-define('QUICKFORM_INVALID_RULE',           -2);
-define('QUICKFORM_NONEXIST_ELEMENT',       -3);
-define('QUICKFORM_INVALID_FILTER',         -4);
-define('QUICKFORM_UNREGISTERED_ELEMENT',   -5);
-define('QUICKFORM_INVALID_ELEMENT_NAME',   -6);
-define('QUICKFORM_INVALID_PROCESS',        -7);
-define('QUICKFORM_DEPRECATED',             -8);
-define('QUICKFORM_INVALID_DATASOURCE',     -9);
+define('QUICKFORM_OK', 1);
+define('QUICKFORM_ERROR', -1);
+define('QUICKFORM_INVALID_RULE', -2);
+define('QUICKFORM_NONEXIST_ELEMENT', -3);
+define('QUICKFORM_INVALID_FILTER', -4);
+define('QUICKFORM_UNREGISTERED_ELEMENT', -5);
+define('QUICKFORM_INVALID_ELEMENT_NAME', -6);
+define('QUICKFORM_INVALID_PROCESS', -7);
+define('QUICKFORM_DEPRECATED', -8);
+define('QUICKFORM_INVALID_DATASOURCE', -9);
 /**#@-*/
 
 // }}}
@@ -216,9 +216,6 @@ class HTML_QuickForm extends HTML_Common
      */
     public $_flagSubmitted = false;
 
-    // }}}
-    // {{{ constructor
-
     /**
      * Class constructor
      * @param    string      $formName          Form's name.
@@ -229,8 +226,14 @@ class HTML_QuickForm extends HTML_Common
      * @param    bool        $trackSubmit       (optional)Whether to track if the form was submitted by adding a special hidden field
      * @access   public
      */
-    public function __construct($formName='', $method='post', $action='', $target='', $attributes=null, $trackSubmit = false)
-    {
+    public function __construct(
+        $formName = '',
+        $method = 'post',
+        $action = '',
+        $target = '',
+        $attributes = null,
+        $trackSubmit = false
+    ) {
         parent::__construct($attributes);
         $method = (strtoupper($method) == 'GET') ? 'get' : 'post';
         $action = ($action == '') ? api_get_self() : $action;
@@ -247,21 +250,8 @@ class HTML_QuickForm extends HTML_Common
         ) + $target;
         $this->updateAttributes($attributes);
         if (!$trackSubmit || isset($_REQUEST['_qf__' . $formName])) {
-            if (1 == get_magic_quotes_gpc()) {
-                $this->_submitValues = $this->_recursiveFilter('stripslashes', 'get' == $method? $_GET: $_POST);
-                foreach ($_FILES as $keyFirst => $valFirst) {
-                    foreach ($valFirst as $keySecond => $valSecond) {
-                        if ('name' == $keySecond) {
-                            $this->_submitFiles[$keyFirst][$keySecond] = $this->_recursiveFilter('stripslashes', $valSecond);
-                        } else {
-                            $this->_submitFiles[$keyFirst][$keySecond] = $valSecond;
-                        }
-                    }
-                }
-            } else {
-                $this->_submitValues = 'get' == $method? $_GET: $_POST;
-                $this->_submitFiles  = $_FILES;
-            }
+            $this->_submitValues = 'get' == $method ? $_GET : $_POST;
+            $this->_submitFiles = $_FILES;
             $this->_flagSubmitted = count($this->_submitValues) > 0 || count($this->_submitFiles) > 0;
         }
         if ($trackSubmit) {
@@ -294,10 +284,7 @@ class HTML_QuickForm extends HTML_Common
 //                $this->_maxFileSize = intval($free_course_quota);
 //            }
 //        }
-    } // end constructor
-
-    // }}}
-    // {{{ apiVersion()
+    }
 
     /**
      * Returns the current API version
@@ -309,10 +296,7 @@ class HTML_QuickForm extends HTML_Common
     function apiVersion()
     {
         return 3.2;
-    } // end func apiVersion
-
-    // }}}
-    // {{{ registerElementType()
+    }
 
     /**
      * Registers a new element type
@@ -327,10 +311,7 @@ class HTML_QuickForm extends HTML_Common
     function registerElementType($typeName, $include, $className)
     {
         $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'][strtolower($typeName)] = array($include, $className);
-    } // end func registerElementType
-
-    // }}}
-    // {{{ registerRule()
+    }
 
     /**
      * Registers a new validation rule
@@ -347,10 +328,7 @@ class HTML_QuickForm extends HTML_Common
     {
         $registry =& HTML_QuickForm_RuleRegistry::singleton();
         $registry->registerRule($ruleName, $type, $data1, $data2);
-    } // end func registerRule
-
-    // }}}
-    // {{{ elementExists()
+    }
 
     /**
      * Returns true if element is in the form
@@ -365,10 +343,6 @@ class HTML_QuickForm extends HTML_Common
         return isset($this->_elementIndex[$element]);
     }
 
-
-    // }}}
-    // {{{ setDefaults()
-
     /**
      * Initializes default form values
      *
@@ -403,10 +377,7 @@ class HTML_QuickForm extends HTML_Common
                 $this->_elements[$key]->onQuickFormEvent('updateValue', null, $this);
             }
         }
-    } // end func setDefaults
-
-    // }}}
-    // {{{ setConstants()
+    }
 
     /**
      * Initializes constant form values.
@@ -442,10 +413,7 @@ class HTML_QuickForm extends HTML_Common
                 $this->_elements[$key]->onQuickFormEvent('updateValue', null, $this);
             }
         }
-    } // end func setConstants
-
-    // }}}
-    // {{{ setMaxFileSize()
+    }
 
     /**
      * Sets the value of MAX_FILE_SIZE hidden element
@@ -466,10 +434,7 @@ class HTML_QuickForm extends HTML_Common
             $el =& $this->getElement('MAX_FILE_SIZE');
             $el->updateAttributes(array('value' => $this->_maxFileSize));
         }
-    } // end func setMaxFileSize
-
-    // }}}
-    // {{{ getMaxFileSize()
+    }
 
     /**
      * Returns the value of MAX_FILE_SIZE hidden element
@@ -481,10 +446,7 @@ class HTML_QuickForm extends HTML_Common
     public function getMaxFileSize()
     {
         return $this->_maxFileSize;
-    } // end func getMaxFileSize
-
-    // }}}
-    // {{{ &createElement()
+    }
 
     /**
      * Creates a new form element of the given type.
@@ -501,12 +463,13 @@ class HTML_QuickForm extends HTML_Common
     public function &createElement($elementType)
     {
         $args = func_get_args();
-        $element = HTML_QuickForm::_loadElement('createElement', $elementType, array_slice($args, 1));
+        $element = HTML_QuickForm::_loadElement(
+            'createElement',
+            $elementType,
+            array_slice($args, 1)
+        );
         return $element;
-    } // end func createElement
-
-    // }}}
-    // {{{ _loadElement()
+    }
 
     /**
      * Returns a form element of the given type
@@ -578,9 +541,6 @@ class HTML_QuickForm extends HTML_Common
         return $element;
     }
 
-    // }}}
-    // {{{ addElement()
-
     /**
      * Adds an element into the form
      *
@@ -701,9 +661,6 @@ class HTML_QuickForm extends HTML_Common
         return $element;
     }
 
-    // }}}
-    // {{{ addGroup()
-
     /**
      * Adds an element group
      * @param    array      $elements       array of elements composing the group
@@ -727,10 +684,7 @@ class HTML_QuickForm extends HTML_Common
         }
         $group = & $this->addElement('group', $name, $groupLabel, $elements, $separator, $appendName);
         return $group;
-    } // end func addGroup
-
-    // }}}
-    // {{{ &getElement()
+    }
 
     /**
      * Returns a reference to the element
@@ -751,6 +705,15 @@ class HTML_QuickForm extends HTML_Common
         }
     }
 
+    /**
+     * @param string $element
+     * @return bool
+     */
+    public function hasElement($element)
+    {
+        return isset($this->_elementIndex[$element]);
+    }
+
     /**
      * Returns the element's raw value
      *
@@ -791,7 +754,7 @@ class HTML_QuickForm extends HTML_Common
      * @access    public
      * @return    mixed     submitted element value or null if not set
      */
-    function getSubmitValue($elementName)
+    public function getSubmitValue($elementName)
     {
         $value = null;
         if (isset($this->_submitValues[$elementName]) || isset($this->_submitFiles[$elementName])) {
@@ -804,19 +767,20 @@ class HTML_QuickForm extends HTML_Common
                     );
                 }
             }
-
         } elseif ('file' == $this->getElementType($elementName)) {
             return $this->getElementValue($elementName);
 
         } elseif (false !== ($pos = strpos($elementName, '['))) {
             $base = str_replace(
-                        array('\\', '\''), array('\\\\', '\\\''),
-                        substr($elementName, 0, $pos)
-                    );
-            $idx  = "['" . str_replace(
-                        array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"),
-                        substr($elementName, $pos + 1, -1)
-                    ) . "']";
+                array('\\', '\''),
+                array('\\\\', '\\\''),
+                substr($elementName, 0, $pos)
+            );
+            $idx = "['".str_replace(
+                    array('\\', '\'', ']', '['),
+                    array('\\\\', '\\\'', '', "']['"),
+                    substr($elementName, $pos + 1, -1)
+                )."']";
             if (isset($this->_submitValues[$base])) {
                 $value = eval("return (isset(\$this->_submitValues['{$base}']{$idx})) ? \$this->_submitValues['{$base}']{$idx} : null;");
             }
@@ -852,20 +816,15 @@ class HTML_QuickForm extends HTML_Common
             }
         }
 
-        if ($this->getElementType($elementName) == 'date_range_picker') {
-            /** @var DateRangePicker $element */
+        if ($this->hasElement($elementName)) {
             $element = $this->getElement($elementName);
-            $parsedDates = $element->parseDateRange($value);
-
-            $validateFormat = $element->getAttribute('validate_format');
-
-            if (!$element->validateDates($parsedDates, $validateFormat)) {
-                $this->_errors[$elementName] = get_lang('CheckDates');
+            if (method_exists($element, 'getSubmitValue')) {
+                $value = $element->getSubmitValue(
+                    $value,
+                    $this->_submitValues,
+                    $this->_errors
+                );
             }
-
-            $this->_submitValues[$elementName.'_start'] = $parsedDates['start'];
-            $this->_submitValues[$elementName.'_end'] = $parsedDates['end'];
-
         }
 
         return $value;
@@ -891,9 +850,6 @@ class HTML_QuickForm extends HTML_Common
         }
     }
 
-    // }}}
-    // {{{ getElementError()
-
     /**
      * Returns error corresponding to validated element
      *
@@ -978,10 +934,7 @@ class HTML_QuickForm extends HTML_Common
                 }
             }
         }
-    } // end func updateElementAttr
-
-    // }}}
-    // {{{ removeElement()
+    }
 
     /**
      * Removes an element
@@ -1029,13 +982,13 @@ class HTML_QuickForm extends HTML_Common
      * To validate grouped elements as separated entities,
      * use addGroupRule instead of addRule.
      *
-     * @param    string     $element       Form element name
-     * @param    string     $message       Message to display for invalid data
-     * @param    string     $type          Rule type, use getRegisteredRules() to get types
-     * @param    string     $format        (optional)Required for extra rule data
-     * @param    string     $validation    (optional)Where to perform validation: "server", "client"
-     * @param    boolean    $reset         Client-side validation: reset the form element to its original value if there is an error?
-     * @param    boolean    $force         Force the rule to be applied, even if the target form element does not exist
+     * @param    string $element Form element name
+     * @param    string $message Message to display for invalid data
+     * @param    string $type Rule type, use getRegisteredRules() to get types
+     * @param    string $format (optional)Required for extra rule data
+     * @param    string $validation (optional)Where to perform validation: "server", "client"
+     * @param    boolean $reset Client-side validation: reset the form element to its original value if there is an error?
+     * @param    boolean $force Force the rule to be applied, even if the target form element does not exist
      * @since    1.0
      * @access   public
      */
@@ -1046,7 +999,8 @@ class HTML_QuickForm extends HTML_Common
         $format = null,
         $validation = 'server',
         $reset = false,
-        $force = false
+        $force = false,
+        $dependent = null
     ) {
         if (!$force) {
             if (!is_array($element) && !$this->elementExists($element)) {
@@ -1064,12 +1018,12 @@ class HTML_QuickForm extends HTML_Common
         } elseif (is_string($newName)) {
             $type = $newName;
         }
+
         if (is_array($element)) {
             $dependent = $element;
-            $element   = array_shift($dependent);
-        } else {
-            $dependent = null;
+            $element = array_shift($dependent);
         }
+
         if ($type == 'required' || $type == 'uploadedfile') {
             $this->_required[] = $element;
         }
@@ -1091,7 +1045,6 @@ class HTML_QuickForm extends HTML_Common
         );
     }
 
-
     /**
      * Adds a validation rule for the given group of elements
      *
@@ -1356,32 +1309,7 @@ class HTML_QuickForm extends HTML_Common
     function isRuleRegistered($name, $autoRegister = false)
     {
         return true;
-        if (is_scalar($name) && isset($GLOBALS['_HTML_QuickForm_registered_rules'][$name])) {
-            return true;
-        } elseif (!$autoRegister) {
-            return false;
-        }
-        $ruleName = false;
-        if (is_object($name) && is_a($name, 'html_quickform_rule')) {
-            $ruleName = !empty($name->name)? $name->name: strtolower(get_class($name));
-        } elseif (is_string($name) && class_exists($name)) {
-            $parent = strtolower($name);
-            do {
-                if ('html_quickform_rule' == strtolower($parent)) {
-                    $ruleName = strtolower($name);
-                    break;
-                }
-            } while ($parent = get_parent_class($parent));
-        }
-        if ($ruleName) {
-            $registry =& HTML_QuickForm_RuleRegistry::singleton();
-            $registry->registerRule($ruleName, null, $name);
-        }
-        return $ruleName;
-    } // end func isRuleRegistered
-
-    // }}}
-    // {{{ getRegisteredRules()
+    }
 
     /**
      * Returns an array of registered validation rules
@@ -1501,7 +1429,6 @@ class HTML_QuickForm extends HTML_Common
         foreach ($this->_rules as $target => $rules) {
             $submitValue = $this->getSubmitValue($target);
 
-
             foreach ($rules as $rule) {
                 if ((isset($rule['group']) && isset($this->_errors[$rule['group']])) ||
                      isset($this->_errors[$target])) {
@@ -1538,6 +1465,7 @@ class HTML_QuickForm extends HTML_Common
                         }
                     }
                 }
+
                 if (isset($rule['dependent']) && is_array($rule['dependent'])) {
                     $values = array($submitValue);
                     foreach ($rule['dependent'] as $elName) {
@@ -1806,7 +1734,7 @@ class HTML_QuickForm extends HTML_Common
      */
     public function getSubmitValues($mergeFiles = false)
     {
-        return $mergeFiles? HTML_QuickForm::arrayMerge($this->_submitValues, $this->_submitFiles): $this->_submitValues;
+        return $mergeFiles ? HTML_QuickForm::arrayMerge($this->_submitValues, $this->_submitFiles): $this->_submitValues;
     }
 
     /**
@@ -1842,7 +1770,7 @@ class HTML_QuickForm extends HTML_Common
      * @return mixed
      * @throws HTML_QuickForm_Error
      */
-    function exportValue($element)
+    public function exportValue($element)
     {
         if (!isset($this->_elementIndex[$element])) {
             throw new \Exception("Element '$element' does not exist in HTML_QuickForm::getElementValue()");
@@ -1873,7 +1801,7 @@ class HTML_QuickForm extends HTML_Common
      * @return  array   An assoc array of elements' values
      * @throws  HTML_QuickForm_Error
      */
-    function exportValues($elementList = null)
+    public function exportValues($elementList = null)
     {
         $values = array();
         if (null === $elementList) {

+ 2 - 4
main/inc/lib/pear/HTML/QuickForm/Rule/Regex.php

@@ -84,7 +84,6 @@ class HTML_QuickForm_Rule_Regex extends HTML_QuickForm_Rule
         $this->_data[$name] = $pattern;
     } // end func addData
 
-
     function getValidationScript($options = null)
     {
         $regex = isset($this->_data[$this->name]) ? $this->_data[$this->name] : $options;
@@ -96,6 +95,5 @@ class HTML_QuickForm_Rule_Regex extends HTML_QuickForm_Rule
         }
 
         return array("  var regex = " . $regex . ";\n", "{jsVar} != '' && !regex.test({jsVar})");
-    } // end func getValidationScript
-
-}
+    }
+}

+ 3 - 5
main/inc/lib/pear/HTML/QuickForm/RuleRegistry.php

@@ -43,7 +43,6 @@ class HTML_QuickForm_RuleRegistry
      */
     var $_rules = array();
 
-
     /**
      * Returns a singleton of HTML_QuickForm_RuleRegistry
      *
@@ -84,7 +83,7 @@ class HTML_QuickForm_RuleRegistry
      * @access    public
      * @return    void
      */
-    function registerRule($ruleName, $type, $data1, $data2 = null)
+    public function registerRule($ruleName, $type, $data1, $data2 = null)
     {
         $type = strtolower($type);
         if ($type == 'regex') {
@@ -109,7 +108,7 @@ class HTML_QuickForm_RuleRegistry
      * @access    public
      * @return    HTML_QuickForm_Rule
      */
-    function getRule($ruleName)
+    public function getRule($ruleName)
     {
         if (empty($ruleName)) {
             return false;
@@ -383,5 +382,4 @@ class HTML_QuickForm_RuleRegistry
         }
         return array($value, $tmp_reset);
     }
-} // end class HTML_QuickForm_RuleRegistry
-?>
+}

+ 12 - 20
main/inc/lib/pear/HTML/QuickForm/email.php

@@ -12,8 +12,6 @@
  */
 class HTML_QuickForm_email extends HTML_QuickForm_input
 {
-    // {{{ constructor
-
     /**
      * Class constructor
      *
@@ -26,14 +24,17 @@ class HTML_QuickForm_email extends HTML_QuickForm_input
      * @return    void
      * @throws
      */
-    public function __construct($elementName=null, $elementLabel=null, $attributes=null)
-    {
+    public function __construct(
+        $elementName = null,
+        $elementLabel = null,
+        $attributes = null
+    ) {
+        if (is_array($attributes) || empty($attributes)) {
+            $attributes['class'] = 'form-control';
+        }
         parent::__construct($elementName, $elementLabel, $attributes);
         $this->setType('email');
-    } //end constructor
-
-    // }}}
-    // {{{ setSize()
+    }
 
     /**
      * Sets size of password element
@@ -46,10 +47,7 @@ class HTML_QuickForm_email extends HTML_QuickForm_input
     function setSize($size)
     {
         $this->updateAttributes(array('size'=>$size));
-    } //end func setSize
-
-    // }}}
-    // {{{ setMaxlength()
+    }
 
     /**
      * Sets maxlength of password element
@@ -62,11 +60,5 @@ class HTML_QuickForm_email extends HTML_QuickForm_input
     function setMaxlength($maxlength)
     {
         $this->updateAttributes(array('maxlength'=>$maxlength));
-    } //end func setMaxlength
-
-    // }}}
-    // {{{ getFrozenHtml()
-
-    // }}}
-
-} //end class HTML_QuickForm_password
+    }
+}

+ 2 - 2
main/inc/lib/pear/HTML/QuickForm/input.php

@@ -111,7 +111,7 @@ class HTML_QuickForm_input extends HTML_QuickForm_element
      * @access    public
      * @return    void
      */
-    function setValue($value)
+    public function setValue($value)
     {
         $this->updateAttributes(array('value'=>$value));
     } // end func setValue
@@ -126,7 +126,7 @@ class HTML_QuickForm_input extends HTML_QuickForm_element
      * @access    public
      * @return    string
      */
-    function getValue()
+    public function getValue()
     {
         return $this->getAttribute('value');
     } // end func getValue

+ 0 - 2
main/inc/lib/pear/HTML/QuickForm/text.php

@@ -72,7 +72,6 @@ class HTML_QuickForm_text extends HTML_QuickForm_input
 
         parent::__construct($elementName, $elementLabel, $attributes);
         $this->_persistantFreeze = true;
-
         $this->setType('text');
     }
 
@@ -124,7 +123,6 @@ class HTML_QuickForm_text extends HTML_QuickForm_input
             }
         }
 
-
         switch ($layout) {
             case FormValidator::LAYOUT_INLINE:
                 return '

+ 2 - 5
main/inc/lib/social.lib.php

@@ -19,7 +19,6 @@ class SocialManager extends UserManager
      */
     public function __construct()
     {
-
     }
 
     /**
@@ -56,7 +55,6 @@ class SocialManager extends UserManager
         $list_type_friend = self::show_list_type_friends();
         foreach ($list_type_friend as $value_type_friend) {
             if (strtolower($value_type_friend['title']) == $relation_type_name) {
-
                 return $value_type_friend['id'];
             }
         }
@@ -1320,10 +1318,10 @@ class SocialManager extends UserManager
      * @param int $userId id of wall shown
      * @param string $messageStatus status wall message
      * @param int|string $parentId id message (Post main)
-     * @param date $start Date from which we want to show the messages, in UTC time
+     * @param string $start Date from which we want to show the messages, in UTC time
      * @param int $limit Limit for the number of parent messages we want to show
      * @param int $offset Wall message query offset
-     * @return boolean
+     * @return array
      * @author Yannick Warnier
      */
     public static function getWallMessages($userId, $messageStatus, $parentId = '', $start = null, $limit = 10, $offset = 0)
@@ -1674,7 +1672,6 @@ class SocialManager extends UserManager
         );
 
         $profileEditionLink = null;
-
         if ($currentUserId === $userId) {
             $profileEditionLink = Display::getProfileEditionLink($userId);
         } else {

+ 2 - 0
main/install/configuration.dist.php

@@ -275,3 +275,5 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
 // $_configuration['allow_redirect_to_session_after_inscription_about'] = false;
 // Allows to do a remove_XSS in course introduction with user status COURSEMANAGERLOWSECURITY in order to accept all embed type videos (like vimeo, wistia, etc)
 // $_configuration['allow_course_introduction_low_security'] = false;
+// Prevents the duplicate upload in assignments
+// $_configuration['assignment_prevent_duplicate_upload'] = false;

+ 3 - 3
main/lp/lp_list.php

@@ -614,7 +614,7 @@ foreach ($categories as $item) {
                 if ($details['lp_type'] == 1) {
                     $dsp_disk = Display::url(
                         Display::return_icon(
-                            'cd.gif',
+                            'cd.png',
                             get_lang('Export'),
                             array(),
                             ICON_SIZE_SMALL
@@ -625,7 +625,7 @@ foreach ($categories as $item) {
                 } elseif ($details['lp_type'] == 2) {
                     $dsp_disk = Display::url(
                         Display::return_icon(
-                            'cd.gif',
+                            'cd.png',
                             get_lang('Export'),
                             array(),
                             ICON_SIZE_SMALL
@@ -634,7 +634,7 @@ foreach ($categories as $item) {
                     );
                 } else {
                     $dsp_disk = Display::return_icon(
-                        'cd_gray.gif',
+                        'cd_na.png',
                         get_lang('Export'),
                         array(),
                         ICON_SIZE_SMALL

+ 2 - 0
main/messages/inbox.php

@@ -1,8 +1,10 @@
 <?php
 /* For licensing terms, see /license.txt */
+
 /**
  * 	@package chamilo.messages
  */
+
 $cidReset = true;
 
 require_once __DIR__.'/../inc/global.inc.php';

+ 6 - 1
main/mySpace/myStudents.php

@@ -679,7 +679,12 @@ if (!empty($student_id)) {
             $access_start_date = '';
             $access_end_date = '';
             $date_session = '';
-            $title = Display::return_icon('course.png', get_lang('Courses'), array(), ICON_SIZE_SMALL).' '.get_lang('Courses');
+            $title = Display::return_icon(
+                    'course.png',
+                    get_lang('Courses'),
+                    array(),
+                    ICON_SIZE_SMALL
+                ).' '.get_lang('Courses');
 
             $session_info = api_get_session_info($sId);
             if ($session_info) {

+ 1 - 10
main/session/session_export.php

@@ -28,7 +28,7 @@ $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
 $tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
 
 $archivePath = api_get_path(SYS_ARCHIVE_PATH);
-$archiveURL = api_get_path(WEB_CODE_PATH).'course_info/download.php?archive=';
+$archiveURL = api_get_path(WEB_CODE_PATH).'course_info/download.php?archive_path=&archive=';
 
 $tool_name = get_lang('ExportSessionListXMLCSV');
 
@@ -80,15 +80,9 @@ if (isset($_POST['formSent'])) {
 	}
 
 	if (Database::num_rows($result)) {
-
-
-
 		$sessionListToExport = [];
-
 		if (in_array($file_type, ['csv', 'xls'])) {
-
 			$archiveFile = 'export_sessions_'.$session_id.'_'.api_get_local_time();
-
 			$cvs = true;
 			$sessionListToExport[] = [
 				'SessionName',
@@ -121,7 +115,6 @@ if (isset($_POST['formSent'])) {
 			fputs($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Sessions>\n");
 		}
 
-
 		while ($row = Database::fetch_array($result)) {
 			$row['name'] = str_replace(';',',',$row['name']);
 			$row['username'] = str_replace(';',',',$row['username']);
@@ -129,8 +122,6 @@ if (isset($_POST['formSent'])) {
 			$row['access_end_date'] = str_replace(';',',',$row['access_end_date']);
 			$row['visibility'] = str_replace(';',',',$row['visibility']);
 			$row['session_category'] = str_replace(';',',',$row['session_category_id']);
-
-
 			// users
 			$sql = "SELECT DISTINCT $tbl_user.username
 					FROM $tbl_user

+ 1 - 1
main/social/home.php

@@ -227,7 +227,7 @@ SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'home');
 
 $tpl->assign('social_menu_block', $social_menu_block);
 $tpl->assign('social_friend_block', $friend_html);
-$tpl->assign('sessionList', $social_session_block);
+$tpl->assign('session_list', $social_session_block);
 $tpl->assign('social_search_block', $social_search_block);
 $tpl->assign('social_skill_block', SocialManager::getSkillBlock($user_id));
 $tpl->assign('social_group_block', $social_group_block);

+ 1 - 1
main/survey/fillsurvey.php

@@ -466,7 +466,7 @@ if ($survey_data['form_fields'] != '' &&
 
     if (isset($list['language']) && $list['language'] == 1) {
         // LANGUAGE
-        $form->addElement('select_language', 'language', get_lang('Language'));
+        $form->addSelectLanguage('language', get_lang('Language'));
         if (api_get_setting('profile', 'language') !== 'true') {
             $form->freeze('language');
         }

+ 1 - 1
main/template/default/javascript/editor/elfinder_standalone.tpl

@@ -1,4 +1,4 @@
-{% set finderFolder = _p.web ~ 'vendor/barryvdh/elfinder-builds/' %}
+{% set finderFolder = _p.web ~ 'vendor/studio-42/elfinder/' %}
 <!-- elFinder CSS (REQUIRED) -->
 <link rel="stylesheet" type="text/css" media="screen" href="{{ finderFolder }}css/elfinder.full.css">
 <link rel="stylesheet" type="text/css" media="screen" href="{{ finderFolder }}css/theme.css">

+ 2 - 2
main/template/default/social/home.tpl

@@ -39,7 +39,7 @@
             </div>
 
             <!-- Block session list -->
-            {% if sessionList != null %}
+            {% if session_list != null %}
             <div class="panel-group" id="session-block" role="tablist" aria-multiselectable="true">
                 <div class="panel panel-default">
                     <div class="panel-heading" role="tab" id="headingOne">
@@ -52,7 +52,7 @@
                     <div id="sessionList" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
                         <div class="panel-body">
                             <ul class="list-group">
-                                {% for session in sessionList %}
+                                {% for session in session_list %}
                                 <li id="session_{{ session.id }}" class="list-group-item" style="min-height:65px;">
                                     <img class="img-session" src="{{ session.image }}"/>
                                     <span class="title">{{ session.name }}</span>

+ 1 - 1
main/upload/upload_ppt.php

@@ -85,7 +85,7 @@ if (api_get_setting('search_enabled') === 'true') {
     require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php');
     $specific_fields = get_specific_field_list();
     $form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument'));
-    $form->addElement('select_language', 'language', get_lang('SearchFeatureDocumentLanguage'));
+    $form->addSelectLanguage('language', get_lang('SearchFeatureDocumentLanguage'));
     foreach ($specific_fields as $specific_field) {
         $form->addElement('text', $specific_field['code'], $specific_field['name'].' : ');
     }

+ 3 - 1
main/work/upload.php

@@ -99,7 +99,9 @@ if ($form->validate()) {
             $course_info,
             $session_id,
             $group_id,
-            $user_id
+            $user_id,
+            [],
+            api_get_configuration_value('assignment_prevent_duplicate_upload')
         );
         $script = 'work_list.php';
         if ($is_allowed_to_edit) {

+ 3 - 1
main/work/upload_from_template.php

@@ -96,7 +96,9 @@ if ($form->validate()) {
             $course_info,
             $id_session,
             $group_id,
-            $user_id
+            $user_id,
+            [],
+            api_get_configuration_value('assignment_prevent_duplicate_upload')
         );
         $script = 'work_list.php';
         if ($is_allowed_to_edit) {

+ 1 - 1
src/Chamilo/CoreBundle/Component/Editor/Driver/CourseDriver.php

@@ -219,7 +219,7 @@ class CourseDriver extends Driver implements DriverInterface
     /**
      * {@inheritdoc}
      */
-    public function upload($fp, $dst, $name, $tmpname)
+    public function upload($fp, $dst, $name, $tmpname, $hashes = array())
     {
         $this->setConnectorFromPlugin();
 

+ 1 - 8
src/Chamilo/CoreBundle/Component/Editor/Driver/PersonalDriver.php

@@ -20,7 +20,6 @@ class PersonalDriver extends Driver implements DriverInterface
         $userId = api_get_user_id();
         $dir = \UserManager::getUserPathById($userId, 'system');
         if (!empty($dir)) {
-
             if (!is_dir($dir)) {
                 mkdir($dir);
             }
@@ -37,11 +36,9 @@ class PersonalDriver extends Driver implements DriverInterface
     public function getConfiguration()
     {
         if ($this->allow()) {
-
             $userId = api_get_user_id();
 
             if (!empty($userId)) {
-
                 // Adding user personal files
                 $dir = \UserManager::getUserPathById($userId, 'system');
                 $dirWeb = \UserManager::getUserPathById($userId, 'web');
@@ -78,12 +75,10 @@ class PersonalDriver extends Driver implements DriverInterface
     /**
      * {@inheritdoc}
      */
-    public function upload($fp, $dst, $name, $tmpname)
+    public function upload($fp, $dst, $name, $tmpname, $hashes = array())
     {
         $this->setConnectorFromPlugin();
-
         if ($this->allow()) {
-
             return parent::upload($fp, $dst, $name, $tmpname);
         }
     }
@@ -96,7 +91,6 @@ class PersonalDriver extends Driver implements DriverInterface
         $this->setConnectorFromPlugin();
 
         if ($this->allow()) {
-
             return parent::rm($hash);
         }
     }
@@ -107,7 +101,6 @@ class PersonalDriver extends Driver implements DriverInterface
     public function allow()
     {
         //if ($this->connector->security->isGranted('IS_AUTHENTICATED_FULLY')) {
-
         return !api_is_anonymous();
     }
 }

+ 152 - 25
src/Chamilo/CoreBundle/Component/Editor/Finder.php

@@ -3,7 +3,16 @@
 
 namespace Chamilo\CoreBundle\Component\Editor;
 
+use elFinder;
+use elFinderSession;
+use Exception;
+use elFinderSessionInterface;
+
 /**
+ *
+ * Based in \elFinder this class only has a small change that allows use
+ * drivers with out adding elFinderVolume as class name.
+ *
  * Class Finder
  *
  * This class just modifies this line:
@@ -14,33 +23,123 @@ namespace Chamilo\CoreBundle\Component\Editor;
  */
 class Finder extends \elFinder
 {
-
     /**
      * Constructor
      *
      * @param  array  elFinder and roots configurations
-     * @return void
      * @author Dmitry (dio) Levashov
-     **/
-    public function __construct($opts)
-    {
-        if (session_id() == '') {
-            session_start();
+     */
+    public function __construct($opts) {
+        // set error handler of WARNING, NOTICE
+        $errLevel = E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_STRICT | E_RECOVERABLE_ERROR;
+        if (defined('E_DEPRECATED')) {
+            $errLevel |= E_DEPRECATED | E_USER_DEPRECATED;
         }
+        set_error_handler('elFinder::phpErrorHandler', $errLevel);
 
-        $this->time  = $this->utime();
+        // convert PATH_INFO to GET query
+        if (! empty($_SERVER['PATH_INFO'])) {
+            $_ps = explode('/', trim($_SERVER['PATH_INFO'], '/'));
+            if (! isset($_GET['cmd'])) {
+                $_cmd = $_ps[0];
+                if (isset($this->commands[$_cmd])) {
+                    $_GET['cmd'] = $_cmd;
+                    $_i = 1;
+                    foreach(array_keys($this->commands[$_cmd]) as $_k) {
+                        if (isset($_ps[$_i])) {
+                            if (! isset($_GET[$_k])) {
+                                $_GET[$_k] = $_ps[$_i];
+                            }
+                        } else {
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+
+        // set elFinder instance
+        elFinder::$instance = $this;
+
+        // setup debug mode
         $this->debug = (isset($opts['debug']) && $opts['debug'] ? true : false);
+        if ($this->debug) {
+            error_reporting(defined('ELFINDER_DEBUG_ERRORLEVEL')? ELFINDER_DEBUG_ERRORLEVEL : -1);
+            ini_set('diaplay_errors', '1');
+        }
+
+        if (! interface_exists('elFinderSessionInterface')) {
+            include_once dirname(__FILE__).'/elFinderSessionInterface.php';
+        }
+
+        // session handler
+        if (!empty($opts['session']) && $opts['session'] instanceof elFinderSessionInterface) {
+            $this->session = $opts['session'];
+        } else {
+            $sessionOpts = array(
+                'base64encode' => !empty($opts['base64encodeSessionData']),
+                'keys' => array(
+                    'default'   => !empty($opts['sessionCacheKey']) ? $opts['sessionCacheKey'] : 'elFinderCaches',
+                    'netvolume' => !empty($opts['netVolumesSessionKey'])? $opts['netVolumesSessionKey'] : 'elFinderNetVolumes'
+                )
+            );
+            if (! class_exists('elFinderSession')) {
+                include_once dirname(__FILE__) . '/elFinderSession.php';
+            }
+            $this->session = new elFinderSession($sessionOpts);
+        }
+        // try session start | restart
+        $this->session->start();
+
+        $sessionUseCmds = array();
+        if (isset($opts['sessionUseCmds']) && is_array($opts['sessionUseCmds'])) {
+            $sessionUseCmds = $opts['sessionUseCmds'];
+        }
+
+        // set self::$volumesCnt by HTTP header "X-elFinder-VolumesCntStart"
+        if (isset($_SERVER['HTTP_X_ELFINDER_VOLUMESCNTSTART']) && ($volumesCntStart = intval($_SERVER['HTTP_X_ELFINDER_VOLUMESCNTSTART']))) {
+            self::$volumesCnt = $volumesCntStart;
+        }
+
+        $this->time  = $this->utime();
+        $this->sessionCloseEarlier = isset($opts['sessionCloseEarlier'])? (bool)$opts['sessionCloseEarlier'] : true;
+        $this->sessionUseCmds = array_flip($sessionUseCmds);
         $this->timeout = (isset($opts['timeout']) ? $opts['timeout'] : 0);
-        $this->netVolumesSessionKey = !empty($opts['netVolumesSessionKey'])? $opts['netVolumesSessionKey'] : 'elFinderNetVolumes';
+        $this->uploadTempPath = (isset($opts['uploadTempPath']) ? $opts['uploadTempPath'] : '');
         $this->callbackWindowURL = (isset($opts['callbackWindowURL']) ? $opts['callbackWindowURL'] : '');
+        $this->maxTargets = (isset($opts['maxTargets']) ? intval($opts['maxTargets']) : $this->maxTargets);
+        elFinder::$commonTempPath = (isset($opts['commonTempPath']) ? $opts['commonTempPath'] : './.tmp');
+        if (!is_writable(elFinder::$commonTempPath)) {
+            elFinder::$commonTempPath = sys_get_temp_dir();
+            if (!is_writable(elFinder::$commonTempPath)) {
+                elFinder::$commonTempPath = '';
+            }
+        }
+        $this->maxArcFilesSize = isset($opts['maxArcFilesSize'])? intval($opts['maxArcFilesSize']) : 0;
+        $this->optionsNetVolumes = (isset($opts['optionsNetVolumes']) && is_array($opts['optionsNetVolumes']))? $opts['optionsNetVolumes'] : array();
+        if (isset($opts['itemLockExpire'])) {
+            $this->itemLockExpire = intval($opts['itemLockExpire']);
+        }
+
+        // deprecated settings
+        $this->netVolumesSessionKey = !empty($opts['netVolumesSessionKey'])? $opts['netVolumesSessionKey'] : 'elFinderNetVolumes';
+        self::$sessionCacheKey = !empty($opts['sessionCacheKey']) ? $opts['sessionCacheKey'] : 'elFinderCaches';
+
+        // check session cache
+        $_optsMD5 = md5(json_encode($opts['roots']));
+        if ($this->session->get('_optsMD5') !== $_optsMD5) {
+            $this->session->set('_optsMD5', $_optsMD5);
+        }
 
         // setlocale and global locale regists to elFinder::locale
         self::$locale = !empty($opts['locale']) ? $opts['locale'] : 'en_US.UTF-8';
-
-        if (false === @setlocale(LC_ALL, self::$locale)) {
+        if (false === setlocale(LC_ALL, self::$locale)) {
             self::$locale = setlocale(LC_ALL, '');
         }
 
+        // set defaultMimefile
+        elFinder::$defaultMimefile = (isset($opts['defaultMimefile']) ? $opts['defaultMimefile'] : '');
+
         // bind events listeners
         if (!empty($opts['bind']) && is_array($opts['bind'])) {
             $_req = $_SERVER["REQUEST_METHOD"] == 'POST' ? $_POST : $_GET;
@@ -52,8 +151,13 @@ class Finder extends \elFinder
                     $doRegist = ($_reqCmd && in_array($_reqCmd, array_map($_getcmd, explode(' ', $cmd))));
                 }
                 if ($doRegist) {
-                    if (! is_array($handlers) || is_object($handlers[0])) {
+                    // for backward compatibility
+                    if (! is_array($handlers)) {
                         $handlers = array($handlers);
+                    } else {
+                        if (count($handlers) === 2 && is_object($handlers[0])) {
+                            $handlers = array($handlers);
+                        }
                     }
                     foreach($handlers as $handler) {
                         if ($handler) {
@@ -61,7 +165,7 @@ class Finder extends \elFinder
                                 list($_domain, $_name, $_method) = array_pad(explode('.', $handler), 3, '');
                                 if (strcasecmp($_domain, 'plugin') === 0) {
                                     if ($plugin = $this->getPluginInstance($_name, isset($opts['plugin'][$_name])? $opts['plugin'][$_name] : array())
-                                        and method_exists($plugin, $_method)) {
+                                            and method_exists($plugin, $_method)) {
                                         $this->bind($cmd, array($plugin, $_method));
                                     }
                                 }
@@ -79,35 +183,58 @@ class Finder extends \elFinder
         }
 
         // check for net volumes stored in session
-        foreach ($this->getNetVolumes() as $root) {
-            $opts['roots'][] = $root;
+        $netVolumes = $this->getNetVolumes();
+        foreach ($netVolumes as $key => $root) {
+            if (! isset($root['id'])) {
+                // given fixed unique id
+                if (! $root['id'] = $this->getNetVolumeUniqueId($netVolumes)) {
+                    $this->mountErrors[] = 'Netmount Driver "'.$root['driver'].'" : Could\'t given volume id.';
+                    continue;
+                }
+            }
+            $opts['roots'][$key] = $root;
         }
 
         // "mount" volumes
         foreach ($opts['roots'] as $i => $o) {
             //$class = 'elFinderVolume'.(isset($o['driver']) ? $o['driver'] : '');
-            $class = isset($o['driver']) ? $o['driver'] : '';
+            // Chamilo change
+            $class = (isset($o['driver']) ? $o['driver'] : '');
 
             if (class_exists($class)) {
                 $volume = new $class();
 
-                if ($volume->mount($o)) {
-                    // unique volume id (ends on "_") - used as prefix to files hash
-                    $id = $volume->id();
+                try {
+                    if ($this->maxArcFilesSize && (empty($o['maxArcFilesSize']) || $this->maxArcFilesSize < $o['maxArcFilesSize'])) {
+                        $o['maxArcFilesSize'] = $this->maxArcFilesSize;
+                    }
+                    // pass session handler
+                    $volume->setSession($this->session);
+                    if ($volume->mount($o)) {
+                        // unique volume id (ends on "_") - used as prefix to files hash
+                        $id = $volume->id();
 
-                    $this->volumes[$id] = $volume;
-                    if (!$this->default && $volume->isReadable()) {
-                        $this->default = $this->volumes[$id];
+                        $this->volumes[$id] = $volume;
+                        if ((!$this->default || $volume->root() !== $volume->defaultPath()) && $volume->isReadable()) {
+                            $this->default = $this->volumes[$id];
+                        }
+                    } else {
+                        $this->removeNetVolume($i, $volume);
+                        $this->mountErrors[] = 'Driver "'.$class.'" : '.implode(' ', $volume->error());
                     }
-                } else {
-                    $this->mountErrors[] = 'Driver "'.$class.'" : '.implode(' ', $volume->error());
+                } catch (Exception $e) {
+                    $this->removeNetVolume($i, $volume);
+                    $this->mountErrors[] = 'Driver "'.$class.'" : '.$e->getMessage();
                 }
             } else {
-                $this->mountErrors[] = 'Driver "'.$class.'" does not exists';
+                $this->mountErrors[] = 'Driver "'.$class.'" does not exist';
             }
         }
 
         // if at least one readable volume - ii desu >_<
         $this->loaded = !empty($this->default);
+
+        // restore error handler for now
+        restore_error_handler();
     }
 }

+ 7 - 9
src/Chamilo/CourseBundle/Component/CourseCopy/CourseBuilder.php

@@ -1334,9 +1334,7 @@ class CourseBuilder
     public function build_session_course()
     {
         $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
-        $tbl_session_course = Database::get_main_table(
-            TABLE_MAIN_SESSION_COURSE
-        );
+        $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
         $list_course = CourseManager::get_course_list();
         $list = array();
         foreach ($list_course as $_course) {
@@ -1347,12 +1345,12 @@ class CourseBuilder
             $this->course->backup_path = api_get_path(SYS_COURSE_PATH).$_course['directory'];
             $this->course->encoding = api_get_system_encoding(); //current platform encoding
             $courseId = $_course['real_id'];
-            $sql_session = "SELECT s.id, name, c_id
-                FROM $tbl_session_course sc
-                INNER JOIN $tbl_session s
-                ON sc.session_id = s.id
-                WHERE sc.c_id = '$courseId' ";
-            $query_session = Database::query($sql_session);
+            $sql = "SELECT s.id, name, c_id
+                    FROM $tbl_session_course sc
+                    INNER JOIN $tbl_session s
+                    ON sc.session_id = s.id
+                    WHERE sc.c_id = '$courseId' ";
+            $query_session = Database::query($sql);
             while ($rows_session = Database::fetch_assoc($query_session)) {
                 $session = new CourseSession(
                     $rows_session['id'],

+ 6 - 5
src/Chamilo/CourseBundle/Component/CourseCopy/CourseSelectForm.php

@@ -52,9 +52,11 @@ class CourseSelectForm
 				el = document.getElementById('div_'+item);
                 if (el.style.display == 'none') {
                     el.style.display = '';
+                    if (document.getElementById('img_'+item).length)
 					document.getElementById('img_'+item).className = 'fa fa-minus-square-o fa-lg';
 				} else {
 					el.style.display='none';
+					if (document.getElementById('img_'+item).length)
 					document.getElementById('img_'+item).className ='fa fa-plus-square-o fa-lg';
 				}
 			}
@@ -148,10 +150,8 @@ class CourseSelectForm
 			echo '</h3>';
 		}
         echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>';
-		echo '<script type="text/javascript">var myUpload = new upload(1000);</script>';
-        $icon = Display::returnIconPath('myprogress_bar.gif');
         echo '<div class="tool-backups-options">';
-		echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="javascript: myUpload.start(\'dynamic_div\',\''.$icon.',\''.get_lang('PleaseStandBy', '').'\',\'upload_form\')">';
+		echo '<form method="post" id="upload_form" name="course_select_form">';
 		echo '<input type="hidden" name="action" value="course_select_form"/>';
 
 		if (!empty($hidden_fields['destination_course']) &&
@@ -596,10 +596,12 @@ class CourseSelectForm
 				el = document.getElementById('div_'+item);
                 if (el.style.display == 'none') {
                     el.style.display = '';
+                    if (document.getElementById('img_'+item).length)
 					document.getElementById('img_'+item).className('fa fa-minus-square-o fa-lg');
 				}
 				else{
                     el.style.display = 'none';
+                    if (document.getElementById('img_'+item).length)
 					document.getElementById('img_'+item).className('fa fa-plus-square-o fa-lg');
 				}
 			}
@@ -646,10 +648,9 @@ class CourseSelectForm
 		}
 
 		echo '<script src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/upload.js" type="text/javascript"></script>';
-		echo '<script type="text/javascript">var myUpload = new upload(1000);</script>';
         $icon = Display::returnIconPath('progress_bar.gif');
         echo '<div class="tool-backups-options">';
-		echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="myUpload.start(\'dynamic_div\',\''.$icon.'\',\''.get_lang('PleaseStandBy').'\',\'upload_form\')">';
+		echo '<form method="post" id="upload_form" name="course_select_form">';
 		echo '<input type="hidden" name="action" value="course_select_form"/>';
 		foreach ($list_course as $course) {
 			foreach ($course->resources as $type => $resources) {

+ 1 - 1
tests/main/inc/lib/events.lib.inc.test.php

@@ -143,7 +143,7 @@ class TestEvents extends UnitTestCase {
 		$session_id='';
 		$duration='';
 		$question_list = array();
-		$res=Event::update_event_exercice($exeid,$exo_id, $score, $weighting,$session_id,$learnpath_id=0,$learnpath_item_id=0, $duration, $question_list);
+		$res=Event::update_event_exercise($exeid,$exo_id, $score, $weighting,$session_id,$learnpath_id=0,$learnpath_item_id=0, $duration, $question_list);
 		$this->assertTrue(is_bool($res));
 		//var_dump($res);
 	}

+ 0 - 1
tests/test_suite.php

@@ -170,7 +170,6 @@ class TestsSuite extends TestSuite
         $this->addFile(api_get_path(SYS_TEST_PATH).'main/gradebook/lib/be/evaluation.class.test.php');
         $this->addFile(api_get_path(SYS_TEST_PATH).'main/gradebook/lib/be/exerciselink.class.test.php');
         $this->addFile(api_get_path(SYS_TEST_PATH).'main/gradebook/lib/be/forumthreadlink.class.test.php');
-        $this->addFile(api_get_path(SYS_TEST_PATH).'main/course_info/download.lib.test.php');
 */
         // NEW SCORM
         //$this->addFile(api_get_path(SYS_TEST_PATH).'main/lp/learnpath.class.test.php');