public function setRulesFromScore($score_arr)
 {
     require_once _base_ . '/lib/lib.json.php';
     require_once _lms_ . '/lib/lib.subscribe.php';
     $res = true;
     $where_score_arr = array();
     foreach ($score_arr as $val) {
         $where_score_arr[] = "(category_id = '" . (int) $val['category_id'] . "' " . "AND from_score <= '" . (int) $val['score'] . "' AND to_score >= '" . (int) $val['score'] . "')";
     }
     if (empty($where_score_arr)) {
         return '';
     }
     $fields = "*";
     $qtxt = "SELECT " . $fields . " FROM %lms_assessment_rule\r\n\t\t\tWHERE test_id='" . $this->test_id . "'\r\n\t\t\tAND (" . implode(' OR ', $where_score_arr) . ")\r\n\t\t\tORDER BY from_score ASC";
     $q = $this->db->query($qtxt);
     $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
     $csm = new CourseSubscribe_Management();
     $cmpman = new CompetencesAdm();
     $feedback_txt = array();
     while ($row = $this->db->fetch_assoc($q)) {
         $course_arr = $json->decode($row['courses_list']);
         $competence_arr = $json->decode($row['competences_list']);
         $feedback_txt[] = $row['feedback_txt'];
         //courses subscriptions - only students are affected
         if (!empty($course_arr) && $_SESSION['levelCourse'] <= 3) {
             $arr_courses = array_keys($course_arr);
             $csm->multipleUserSubscribe(getLogUserId(), $arr_courses, 3);
         }
         //competences assignment - only students are affected
         if (!empty($competence_arr) && $_SESSION['levelCourse'] <= 3) {
             foreach ($competence_arr as $c_id => $data) {
                 if ($data['type'] == 'score') {
                     $score = isset($data['score']) ? $data['score'] : 0;
                     if ($score > 0) {
                         if (!$cmpman->userHasCompetence($c_id, Docebo::user()->getIdst())) {
                             $cmpman->assignCompetenceUsers($c_id, array(Docebo::user()->getIdst() => $score));
                         } else {
                             $cmpman->addScoreToUsers($c_id, array(Docebo::user()->getIdst()), $score);
                         }
                     }
                 } else {
                     if (!$cmpman->userHasCompetence($c_id, Docebo::user()->getIdst())) {
                         $cmpman->assignCompetenceUsers($c_id, array(Docebo::user()->getIdst() => 1));
                     }
                 }
             }
         }
     }
     $output = "";
     if (!empty($feedback_txt)) {
         $output = implode('<br/><br />', $feedback_txt);
     }
     return $output;
 }