Julio Montoya 11 жил өмнө
parent
commit
857b4cec0f

+ 30 - 15
main/admin/user_add.php

@@ -19,16 +19,33 @@ api_protect_admin_script(true);
 $is_platform_admin = api_is_platform_admin() ? 1 : 0;
 
 $message = null;
+$htmlHeadXtra[] = api_get_password_checker_js('#username', '#password');
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/tag/jquery.fcbkcomplete.js" type="text/javascript" language="javascript"></script>';
+$htmlHeadXtra[] = '<link href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/tag/style.css" rel="stylesheet" type="text/css" />';
+if (isset($_configuration['allow_strength_pass_checker']) && $_configuration['allow_strength_pass_checker']) {
+    $htmlHeadXtra[] = '
+    <script>
+        $(document).ready(function() {
+            $("input[name=\'password[password_auto]\']").each(function(index, value) {
+                $(this).click(function() {
+                    var value = $(this).attr("value");
+                    if (value == 0) {
+                        $("#password_progress").show();
+                        $(".password-verdict").show();
+                        $(".error-list").show();
+                    } else {
+                        $("#password_progress").hide();
+                        $(".password-verdict").hide();
+                        $(".error-list").hide();
+                    }
+                });
+            });
+        });
+        </script>';
+}
 
-$htmlHeadXtra[] = '<script src="'.api_get_path(
-    WEB_LIBRARY_PATH
-).'javascript/tag/jquery.fcbkcomplete.js" type="text/javascript" language="javascript"></script>';
-$htmlHeadXtra[] = '<link href="'.api_get_path(
-    WEB_LIBRARY_PATH
-).'javascript/tag/style.css" rel="stylesheet" type="text/css" />';
 $htmlHeadXtra[] = '
 <script>
-<!--
 function enable_expiration_date() { //v2.0
 	document.user_add.radio_expiration_date[0].checked=false;
 	document.user_add.radio_expiration_date[1].checked=true;
@@ -63,7 +80,6 @@ function display_drh_list(){
             document.getElementById("id_platform_admin").style.display="none";
 	}
 }
-//-->
 </script>';
 
 if (!empty($_GET['message'])) {
@@ -136,7 +152,7 @@ $form->addRule(
 
 // Username
 if (api_get_setting('login_is_email') != 'true') {
-    $form->addElement('text', 'username', get_lang('LoginName'), array('maxlength' => USERNAME_MAX_LENGTH));
+    $form->addElement('text', 'username', get_lang('LoginName'), array('id'=> 'username', 'maxlength' => USERNAME_MAX_LENGTH));
     $form->addRule('username', get_lang('ThisFieldIsRequired'), 'required');
     $form->addRule(
         'username',
@@ -178,14 +194,13 @@ $group[] = $form->createElement(
     1
 );
 $group[] = $form->createElement('radio', 'password_auto', 'id="radio_user_password"', null, 0);
-$group[] = $form->createElement(
-    'password',
-    'password',
-    null,
-    array('onkeydown' => 'javascript: password_switch_radio_button();')
-);
+$group[] = $form->createElement('password', 'password', null, array('id'=> 'password', 'onkeydown' => 'javascript: password_switch_radio_button();'));
 $form->addGroup($group, 'password', get_lang('Password'), '');
 
+if (isset($_configuration['allow_strength_pass_checker']) && $_configuration['allow_strength_pass_checker']) {
+    $form->addElement('label', null, '<div id="password_progress" style="display:none"></div>');
+}
+
 // Status
 $status = api_get_user_roles();
 

+ 1 - 1
main/admin/user_list.php

@@ -419,7 +419,7 @@ function get_user_data($from, $number_of_items, $column, $direction, $get_count
     $from 	= intval($from);
     $number_of_items = intval($number_of_items);
 
-    //Returns counts and exits function
+    // Returns counts and exits function.
     if ($get_count) {
         $res = Database::query($sql);
         $user = Database::fetch_array($res);

+ 2 - 2
main/auth/inscription.php

@@ -19,7 +19,7 @@ if (api_get_setting('allow_registration') === 'false') {
     api_not_allowed(true);
 }
 
-$htmlHeadXtra[] = api_get_password_checker_js('#pass1');
+$htmlHeadXtra[] = api_get_password_checker_js('#username', '#pass1');
 
 if (!empty($_SESSION['user_language_choice'])) {
     $user_selected_language = $_SESSION['user_language_choice'];
@@ -92,7 +92,7 @@ if ($user_already_registered_show_terms == false) {
 
     //	USERNAME
     if (api_get_setting('login_is_email') != 'true') {
-        $form->addElement('text', 'username', get_lang('UserName'), array('size' => USERNAME_MAX_LENGTH));
+        $form->addElement('text', 'username', get_lang('UserName'), array('id' => 'username', 'size' => USERNAME_MAX_LENGTH));
         $form->applyFilter('username','trim');
         $form->addRule('username', get_lang('ThisFieldIsRequired'), 'required');
         $form->addRule('username', sprintf(get_lang('UsernameMaxXCharacters'), (string)USERNAME_MAX_LENGTH), 'maxlength', USERNAME_MAX_LENGTH);

+ 3 - 5
main/auth/profile.php

@@ -23,7 +23,7 @@ if (api_get_setting('allow_social_tool') == 'true') {
     $this_section = SECTION_MYPROFILE;
 }
 
-$htmlHeadXtra[] = api_get_password_checker_js('#password1');
+$htmlHeadXtra[] = api_get_password_checker_js('#username', '#password1');
 $_SESSION['this_section'] = $this_section;
 
 if (!(isset($_user['user_id']) && $_user['user_id']) || api_is_anonymous($_user['user_id'], true)) {
@@ -31,9 +31,7 @@ if (!(isset($_user['user_id']) && $_user['user_id']) || api_is_anonymous($_user[
 }
 
 $htmlHeadXtra[] = '<script src="../inc/lib/javascript/tag/jquery.fcbkcomplete.js" type="text/javascript" language="javascript"></script>';
-$htmlHeadXtra[] = '<link href="'.api_get_path(
-    WEB_LIBRARY_PATH
-).'javascript/tag/style.css" rel="stylesheet" type="text/css" />';
+$htmlHeadXtra[] = '<link href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/tag/style.css" rel="stylesheet" type="text/css" />';
 
 $htmlHeadXtra[] = '<script>
 function confirmation(name) {
@@ -147,7 +145,7 @@ $form->addElement(
     'text',
     'username',
     get_lang('UserName'),
-    array('maxlength' => USERNAME_MAX_LENGTH, 'size' => USERNAME_MAX_LENGTH)
+    array('id' => 'username', 'maxlength' => USERNAME_MAX_LENGTH, 'size' => USERNAME_MAX_LENGTH)
 );
 if (api_get_setting('profile', 'login') !== 'true') {
     $form->freeze('username');

+ 5 - 2
main/exercice/exercise_submit.php

@@ -541,7 +541,7 @@ if (!isset($questionListInSession)) {
     }
 }
 
-//Fix in order to get the correct question list
+// Fix in order to get the correct question list.
 $questionListUncompressed = $objExercise->getQuestionListWithMediasUncompressed();
 
 Session::write('question_list_uncompressed', $questionListUncompressed);
@@ -596,7 +596,10 @@ if (!empty($exercise_stat_info['questions_to_check'])) {
 	$my_remind_list = array_filter($my_remind_list);
 }
 
-if ($debug) { error_log("6.0 my_remind_list array: ".print_r($my_remind_list, 1)); }
+if ($debug) {
+    error_log("6.0 my_remind_list array: ".print_r($my_remind_list, 1));
+}
+//$now = time();
 $params = "exe_id=$exe_id&exerciseId=$exerciseId&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id&".api_get_cidreq();
 
 if ($debug) { error_log("6.1 params: $params"); };

+ 37 - 16
main/exercice/testcategory.class.php

@@ -16,6 +16,7 @@ class Testcategory
     public $course_id;
     public $c_id; // from db
     public $root;
+    public $visibility;
 
     /**
      * Constructor of the class Category
@@ -31,7 +32,7 @@ class Testcategory
      * @param string $type
      * @param int $course_id
      */
-    public function Testcategory($in_id = 0, $in_name = '', $in_description = "", $parent_id = 0, $type = 'simple', $course_id = null)
+    public function Testcategory($in_id = 0, $in_name = '', $in_description = "", $parent_id = 0, $type = 'simple', $course_id = null, $visibility = 1)
     {
 		if ($in_id != 0 && $in_name == "") {
 			$tmpobj = new Testcategory();
@@ -44,6 +45,7 @@ class Testcategory
             $this->parent_path = $this->name;
             $this->c_id = $tmpobj->c_id;
             $this->root = $tmpobj->root;
+            $this->visibility = $tmpobj->visibility;
 
             if (!empty($tmpobj->parent_id)) {
                 $category = new Testcategory($tmpobj->parent_id);
@@ -54,6 +56,7 @@ class Testcategory
 			$this->name = $in_name;
 			$this->description = $in_description;
             $this->parent_id = $parent_id;
+            $this->visibility = $visibility;
         }
         $this->type = $type;
 
@@ -89,6 +92,7 @@ class Testcategory
             $this->parent_id = $row['parent_id'];
             $this->c_id = $row['c_id'];
             $this->root = $row['root'];
+            $this->visibility = $row['visibility'];
         } else {
             return false;
         }
@@ -168,6 +172,7 @@ class Testcategory
 
         $category->setTitle($this->name);
         $category->setDescription($this->description);
+        $category->setVisibility($this->visibility);
 
         if (!empty($this->parent_id)) {
             foreach ($this->parent_id as $parentId) {
@@ -397,10 +402,11 @@ class Testcategory
      * @param int $question_id
      * @param int $course_id
      * @param bool $display_into_labels
+     * @param bool $categoryMinusOne shows category - 1 see BT#6540
      * @return string
      */
-    public static function getCategoryNamesForQuestion($question_id, $course_id = null, $display_into_labels = true) {
-        $result = array(); // result
+    public static function getCategoryNamesForQuestion($question_id, $course_id = null, $display_into_labels = true, $categoryMinusOne = false)
+    {
         if (empty($course_id) || $course_id == "") {
             $course_id = api_get_course_int_id();
         }
@@ -413,9 +419,17 @@ class Testcategory
                 ON (qc.category_id = c.iid AND qc.c_id = $course_id)
                 WHERE question_id = '$question_id' ";
 		$res = Database::query($sql);
+        $result = array();
 		if (Database::num_rows($res) > 0) {
             while ($row = Database::fetch_array($res)) {
                 $cat = new Testcategory($row['iid']);
+                if ($categoryMinusOne) {
+                    $catParts = explode('>', $cat->parent_path);
+                    if (isset($catParts[0])) {
+                        unset($catParts[0]);
+                        $cat->parent_path = implode('>', $catParts);
+                    }
+                }
                 $result[] = array('title' => $cat->parent_path);
             }
 		}
@@ -906,10 +920,13 @@ class Testcategory
 
     /**
      * Returns a category summary report
-     * @params int exercise id
-     * @params array prefilled array with the category_id, score, and weight example: array(1 => array('score' => '10', 'total' => 20));
+     *
+     * @param int exercise id
+     * @param array prefilled array with the category_id, score, and weight example: array(1 => array('score' => '10', 'total' => 20));
+     * @param bool $categoryMinusOne shows category - 1 see BT#6540
+     * @return string
      */
-    public static function get_stats_table_by_attempt($exercise_id, $category_list = array())
+    public static function get_stats_table_by_attempt($exercise_id, $category_list = array(), $categoryMinusOne = false)
     {
         global $app;
         if (empty($category_list)) {
@@ -949,9 +966,13 @@ class Testcategory
 
                 $categoryName = $category_name_list[$category_id];
 
-                if (isset($path[0])) {
-                    $category_id = $path[0]->getIid();
-                    $categoryName = $path[0]->getTitle();
+                $index = 0;
+                if ($categoryMinusOne) {
+                    $index = 1;
+                }
+                if (isset($path[$index])) {
+                    $category_id = $path[$index]->getIid();
+                    $categoryName = $path[$index]->getTitle();
                 }
                 if (!isset($globalCategoryScore[$category_id])) {
                     $globalCategoryScore[$category_id] = array();
@@ -1036,21 +1057,14 @@ class Testcategory
 
         $result = Database::query($sql);
         if (Database::num_rows($result)) {
-            //$list = array();
              while ($row = Database::fetch_array($result, 'ASSOC')) {
                 if ($excludeCategoryWithNoQuestions) {
-                    //if ($row['count_questions'] == 0 || $row['count_questions'] == -1) {
-                    /*0 means no questions selected this options is also filtered in the function:
-                    Exercise::pickQuestionsPerCategory() */
                     if ($row['count_questions'] == 0) {
                         continue;
                     }
                 }
                 $categories[$row['category_id']] = $row;
             }
-            if (!empty($list)) {
-                //$categories = $this->sort_tree_array($list);
-            }
         }
 
         if ($shuffle) {
@@ -1142,6 +1156,12 @@ class Testcategory
         $form->add_html_editor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Width' => '90%', 'Height' => '200'));
         $category_parent_list = array();
 
+        $options = array(
+            '1' => get_lang('Visible'),
+            '0' => get_lang('Hidden')
+        );
+        $form->addElement('select', 'visibility', get_lang('Visibility'), $options);
+
         $script = null;
         if (!empty($this->parent_id)) {
             $parent_cat = new Testcategory($this->parent_id);
@@ -1159,6 +1179,7 @@ class Testcategory
         $defaults["category_name"] = $this->name;
         $defaults["category_description"] = $this->description;
         $defaults["parent_id"] = $this->parent_id;
+        $defaults["visibility"] = $this->visibility;
         $form->setDefaults($defaults);
 
         // setting the rules

+ 4 - 2
main/exercice/tests_category.php

@@ -129,7 +129,8 @@ function edit_category_form($in_action, $type = 'simple') {
                 $v_name = $values['category_name'];
                 $v_description = $values['category_description'];
                 $parent_id = isset($values['parent_id']) ? $values['parent_id'] : null;
-                $objcat = new Testcategory($v_id, $v_name, $v_description, $parent_id, $type);
+                $visibility = isset($values['visibility']) ? $values['visibility'] : 1;
+                $objcat = new Testcategory($v_id, $v_name, $v_description, $parent_id, $type, null, $visibility);
                 if ($objcat->modifyCategory()) {
                     Display::display_confirmation_message(get_lang('MofidfyCategoryDone'));
                 } else {
@@ -153,7 +154,8 @@ function edit_category_form($in_action, $type = 'simple') {
 }
 
 // process to delete a category
-function delete_category_form($in_action, $type = 'simple') {
+function delete_category_form($in_action, $type = 'simple')
+{
     $in_action = Security::remove_XSS($in_action);
     if (isset($_GET['category_id']) && is_numeric($_GET['category_id'])) {
         $category_id = Security::remove_XSS($_GET['category_id']);

+ 65 - 8
main/inc/lib/api.lib.php

@@ -6953,12 +6953,29 @@ function api_get_user_roles()
 
 
 
+/**
+ * Finds all the information about a user from username instead of user id
+ * @param $username (string): the username
+ * @return $user_info (array): user_id, lastname, firstname, username, email, ...
+ * @author Yannick Warnier <yannick.warnier@beeznest.com>
+ */
+function api_get_user_info_from_official_code($official_code = '') {
+    if (empty($official_code)) { return false; }
+    $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)." WHERE official_code ='".Database::escape_string($official_code)."'";
+    $result = Database::query($sql);
+    if (Database::num_rows($result) > 0) {
+        $result_array = Database::fetch_array($result);
+        return _api_format_user($result_array);
+    }
+    return false;
+}
+
 /**
  *
  * @param string $inputId the jquery id example: #password
  * @return string
  */
-function api_get_password_checker_js($inputId)
+function api_get_password_checker_js($usernameInputId, $passwordInputid)
 {
     global $_configuration;
     $useStrengthPassChecker = isset($_configuration['allow_strength_pass_checker']) ? $_configuration['allow_strength_pass_checker'] : false;
@@ -6967,13 +6984,14 @@ function api_get_password_checker_js($inputId)
         return null;
     }
 
-    $verdicts = array(get_lang('Weak'), get_lang('Normal'), get_lang('Medium'), get_lang('Strong'), get_lang('VeryStrong'));
+    $verdicts = array(get_lang('PasswordWeak'), get_lang('PasswordNormal'), get_lang('PasswordMedium'), get_lang('PasswordStrong'), get_lang('PasswordVeryStrong'));
     $js = api_get_js('strength/strength.js');
     $js .=  "<script>
 
     var verdicts = ['".implode("','", $verdicts)."'];
     var errorMessages = {
-        password_to_short : '".get_lang('PasswordIsTooShort')."'
+        password_to_short : '".get_lang('PasswordIsTooShort')."',
+        same_as_username : '".get_lang('YourPasswordCannotBeTheSameAsYourUsername')."',
     };
 
     $(document).ready(function() {
@@ -6987,12 +7005,13 @@ function api_get_password_checker_js($inputId)
             },
             errorMessages : errorMessages,
             viewports: {
-              progress: '#password_progress',
-              //verdict: undefined,
-              //errors: undefined
-          }
+                progress: '#password_progress',
+                //verdict: undefined,
+                //errors: undefined
+            },
+            usernameField: '$usernameInputId'
         };
-        $('".$inputId."').pwstrength(options);
+        $('".$passwordInputid."').pwstrength(options);
     });
     </script>";
     return $js;
@@ -7012,3 +7031,41 @@ function api_get_easy_password_list()
     return $passwordList;
 }
 
+/**
+ *
+* create an user extra field called 'captcha_blocked_until_date'
+ */
+function api_block_account_captcha($username)
+{
+    $userInfo = api_get_user_info_from_username($username);
+    if (empty($userInfo)) {
+        return false;
+    }
+    global $_configuration;
+    $minutesToBlock = isset($_configuration['captcha_time_to_block']) ? $_configuration['captcha_time_to_block'] : 10;
+    $time = time() + $minutesToBlock*60;
+    Usermanager::update_extra_field_value($userInfo['user_id'], 'captcha_blocked_until_date', api_get_utc_datetime($time));
+}
+
+function api_clean_account_captcha($username)
+{
+    $userInfo = api_get_user_info_from_username($username);
+    if (empty($userInfo)) {
+        return false;
+    }
+    Session::erase('loginFailedCount');
+    Usermanager::update_extra_field_value($userInfo['user_id'], 'captcha_blocked_until_date', null);
+}
+
+function api_get_user_blocked_by_captcha($username)
+{
+    $userInfo = api_get_user_info_from_username($username);
+    if (empty($userInfo)) {
+        return false;
+    }
+    $data = Usermanager::get_extra_user_data_by_field($userInfo['user_id'], 'captcha_blocked_until_date');
+    if (isset($data)) {
+        return $data['captcha_blocked_until_date'];
+    }
+    return false;
+}

+ 4 - 2
main/inc/lib/exercise.lib.php

@@ -38,7 +38,8 @@ class ExerciseLib
         $show_comment = false,
         $exercise_feedback = null,
         $show_answers = false,
-        $modelType = null
+        $modelType = null,
+        $categoryMinusOne = true
     ) {
         // Text direction for the current language
         //$is_ltr_text_direction = api_get_text_direction() != 'rtl';
@@ -73,7 +74,8 @@ class ExerciseLib
                 $questionDescription = $objQuestionTmp->selectDescription();
 
                 if ($show_title) {
-                    $html .= Testcategory::getCategoryNamesForQuestion($objQuestionTmp->id);
+                    $categoryName = Testcategory::getCategoryNamesForQuestion($objQuestionTmp->id, null, true, $categoryMinusOne);
+                    $html .= $categoryName;
                     $html .= Display::div($current_item.'. '.$objQuestionTmp->selectTitle(), array('class' => 'question_title'));
                     if (!empty($questionDescription)) {
                         $html .= Display::div($questionDescription, array('class' => 'question_description'));

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

@@ -123,6 +123,9 @@ class FormValidator extends HTML_QuickForm
         $this->registerElementType('style_reset_button', $dir . 'Element/style_reset_button.php', 'HTML_QuickForm_styleresetbutton');
         $this->registerElementType('button', $dir . 'Element/style_submit_button.php', 'HTML_QuickForm_stylesubmitbutton');
 
+        $this->registerElementType('captcha', 'HTML/QuickForm/CAPTCHA.php', 'HTML_QuickForm_CAPTCHA');
+        $this->registerElementType('CAPTCHA_Image', 'HTML/QuickForm/CAPTCHA/Image.php', 'HTML_QuickForm_CAPTCHA_Image');
+
         $this->registerRule('date', null, 'HTML_QuickForm_Rule_Date', $dir . 'Rule/Date.php');
         $this->registerRule('date_compare', null, 'HTML_QuickForm_Rule_DateCompare', $dir . 'Rule/DateCompare.php');
         $this->registerRule('html', null, 'HTML_QuickForm_Rule_HTML', $dir . 'Rule/HTML.php');
@@ -134,6 +137,9 @@ class FormValidator extends HTML_QuickForm
         $this->registerRule('compare_fields', null, 'HTML_QuickForm_Compare_Fields', $dir . 'Rule/CompareFields.php');
         $this->registerRule('compare_datetime_text', null, 'HTML_QuickForm_Rule_CompareDateTimeText', $dir . 'Rule/CompareDateTimeText.php');
 
+        $this->registerRule('CAPTCHA', 'rule', 'HTML_QuickForm_Rule_CAPTCHA', 'HTML/QuickForm/Rule/CAPTCHA.php');
+
+
         // Modify the default templates
         $renderer = & $this->defaultRenderer();
 

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

@@ -65,7 +65,8 @@ $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'] = array(
     'advanced_settings' => array('HTML/QuickForm/advanced_settings.php','HTML_QuickForm_advanced_settings'),
     'label'             => array('HTML/QuickForm/label.php','HTML_QuickForm_label'),
     'email'             => array('HTML/QuickForm/email.php','HTML_QuickForm_email'),
-    'advmultiselect'    => array('HTML/QuickForm/advmultiselect.php','HTML_QuickForm_advmultiselect')
+    'advmultiselect'    => array('HTML/QuickForm/advmultiselect.php','HTML_QuickForm_advmultiselect'),
+    'captcha'           => array('HTML/QuickForm/CAPTCHA.php','HTML_QuickForm_advmultiselect')
 );
 
 /**
@@ -91,7 +92,8 @@ $GLOBALS['_HTML_QuickForm_registered_rules'] = array(
     //'compare'       => array('html_quickform_rule_compare',  'HTML/QuickForm/Rule/Compare.php')
     'compare'       => array('html_quickform_rule_compare',  'HTML/QuickForm/Rule/Compare.php'),
     'comparedate'   => array('html_quickform_rule_comparedate',  'HTML/QuickForm/Rule/CompareDate.php'),
-    'errordate'  	=> array('html_quickform_rule_date',  'HTML/QuickForm/Rule/Date.php')
+    'errordate'  	=> array('html_quickform_rule_date',  'HTML/QuickForm/Rule/Date.php'),
+    'captcha'  	    => array('HTML_QuickForm_Rule_CAPTCHA',  'HTML/QuickForm/Rule/CAPTCHA.php')
     //
 );
 

+ 12 - 0
main/inc/lib/template.lib.php

@@ -399,6 +399,10 @@ class Template
         $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.css';
         $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/chosen/chosen.css';
 
+        if (api_get_setting('use_virtual_keyboard') == 'true') {
+            $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/keyboard/keyboard.css';
+        }
+
         $css_file_to_string = null;
         foreach ($css as $file) {
             $css_file_to_string .= api_get_css($file);
@@ -497,6 +501,14 @@ class Template
             $js_files[] = $jsFolder.'asciimath/ASCIIMathML.js';
         }
 
+        if (api_get_setting('use_virtual_keyboard') == 'true') {
+            $js_files[] = 'keyboard/jquery.keyboard.js';
+        }
+
+        if (api_get_setting('disable_copy_paste') == 'true') {
+            $js_files[] = 'jquery.nocutcopypaste.js';
+        }
+
         $js_file_to_string = null;
 
         foreach ($js_files as $js_file) {

+ 1 - 0
main/inc/routes.php

@@ -279,6 +279,7 @@ $userPermissionsInsideACourse = function (Request $request) use ($app) {
 
         // Checking the course access
         $is_allowed_in_course = false;
+        $_course =& $courseInfo; //fix issue in code rewriting: TODO: do it properly, renaming $_course where appropriate
 
         if (isset($_course)) {
             switch ($_course['visibility']) {