Exemplo n.º 1
0
 /**
  * @param array $data
  * @return array
  */
 public function get_thematic_plan_div($data)
 {
     $final_return = array();
     $uinfo = api_get_user_info();
     foreach ($data as $thematic_id => $thematic_plan_data) {
         $new_thematic_plan_data = array();
         foreach ($thematic_plan_data as $thematic_item) {
             $thematic_simple_list[] = $thematic_item['description_type'];
             $new_thematic_plan_data[$thematic_item['description_type']] = $thematic_item;
         }
         if (!empty($thematic_simple_list)) {
             foreach ($thematic_simple_list as $item) {
                 $default_thematic_plan_title[$item] = $new_thematic_plan_data[$item]['title'];
             }
         }
         $no_data = true;
         $session_star = '';
         $return = '<div id="thematic_plan_' . $thematic_id . '">';
         if (!empty($default_thematic_plan_title)) {
             foreach ($default_thematic_plan_title as $id => $title) {
                 //avoid others
                 if ($title == 'Others' && empty($data[$thematic_id][$id]['description'])) {
                     continue;
                 }
                 if (!empty($data[$thematic_id][$id]['title']) && !empty($data[$thematic_id][$id]['description'])) {
                     if (api_is_allowed_to_edit(null, true)) {
                         if ($data[$thematic_id][$id]['session_id'] != 0) {
                             $session_star = api_get_session_image(api_get_session_id(), $uinfo['status']);
                         }
                     }
                     $return .= Display::tag('h3', Security::remove_XSS($data[$thematic_id][$id]['title'], STUDENT) . $session_star);
                     $return .= Security::remove_XSS($data[$thematic_id][$id]['description'], STUDENT);
                     $no_data = false;
                 }
             }
         }
         if ($no_data) {
             $return .= '<div><em>' . get_lang('StillDoNotHaveAThematicPlan') . '</em></div>';
         }
         $return .= '</div>';
         $final_return[$thematic_id] = $return;
     }
     return $final_return;
 }
Exemplo n.º 2
0
/**
 * Return the icon for the question type
 * @author hubert.borderiou 13-10-2011
 */
function get_question_type_for_question($in_selectedcourse, $in_questionid)
{
    $myObjQuestion = Question::read($in_questionid, $in_selectedcourse);
    $questionType = null;
    if (!empty($myObjQuestion)) {
        list($typeImg, $typeExpl) = $myObjQuestion->get_type_icon_html();
        $questionType = Display::tag('div', Display::return_icon($typeImg, $typeExpl, array(), 32), array());
        unset($myObjQuestion);
    }
    return $questionType;
}
Exemplo n.º 3
0
                echo '</td>';
                echo '</tr>';
                if (!empty($sessions)) {
                    foreach ($sessions as $session) {
                        $course_list = $session['courses'];
                        $url = Display::url($session['data']['name'], '../session/resume_session.php?id_session=' . $session['data']['id']);
                        echo '<tr>';
                        //Session name
                        echo Display::tag('td', $url);
                        echo '<td>';
                        //Courses
                        echo '<table>';
                        if (!empty($course_list)) {
                            foreach ($course_list as $course) {
                                echo '<tr>';
                                $url = Display::url($course['title'], api_get_path(WEB_COURSE_PATH) . $course['directory'] . '/index.php?id_session=' . $session['data']['id']);
                                echo Display::tag('td', $url);
                                echo '</tr>';
                            }
                            echo '</table>';
                            echo '</td>';
                            echo '</tr>';
                        }
                    }
                }
            }
        }
    }
}
echo '</table>';
Display::display_footer();
 /**
  * Get li HTML of page number
  * @param $pageNumber
  * @param $pageLength
  * @param array $liAttributes
  * @param string $content
  * @return string
  */
 function getPageNumberItem($pageNumber, $pageLength, $liAttributes = array(), $content = '')
 {
     // Get page URL
     $url = self::getCourseCategoryUrl($pageNumber, $pageLength);
     // If is current page ('active' class) clear URL
     if (isset($liAttributes) && is_array($liAttributes) && isset($liAttributes['class'])) {
         if (strpos('active', $liAttributes['class']) !== false) {
             $url = '';
         }
     }
     $content = !empty($content) ? $content : $pageNumber;
     return Display::tag('li', Display::url($content, $url), $liAttributes);
 }
Exemplo n.º 5
0
 /**
  * @param int $courseId
  * @param string $keyword
  * @return string
  */
 public static function getOverview($courseId, $keyword = null)
 {
     $content = null;
     $categories = GroupManager::get_categories();
     if (!empty($categories)) {
         foreach ($categories as $category) {
             if (api_get_setting('allow_group_categories') == 'true') {
                 $content .= '<h2>' . $category['title'] . '</h2>';
             }
             if (!empty($keyword)) {
                 $groups = GroupManager::getGroupListFilterByName($keyword, $category['id'], $courseId);
             } else {
                 $groups = GroupManager::get_group_list($category['id']);
             }
             $content .= '<ul>';
             if (!empty($groups)) {
                 foreach ($groups as $group) {
                     $content .= '<li>';
                     $content .= Display::tag('h3', Security::remove_XSS($group['name']));
                     $users = GroupManager::getTutors($group['id']);
                     if (!empty($users)) {
                         $content .= '<ul>';
                         $content .= "<li>" . Display::tag('h4', get_lang('Tutors')) . "</li><ul>";
                         foreach ($users as $user) {
                             $user_info = api_get_user_info($user['user_id']);
                             $content .= '<li title="' . $user_info['username'] . '">' . $user_info['complete_name_with_username'] . '</li>';
                         }
                         $content .= '</ul>';
                         $content .= '</ul>';
                     }
                     $users = GroupManager::getStudents($group['id']);
                     if (!empty($users)) {
                         $content .= '<ul>';
                         $content .= "<li>" . Display::tag('h4', get_lang('Students')) . "</li><ul>";
                         foreach ($users as $user) {
                             $user_info = api_get_user_info($user['user_id']);
                             $content .= '<li title="' . $user_info['username'] . '">' . $user_info['complete_name_with_username'] . '</li>';
                         }
                         $content .= '</ul>';
                         $content .= '</ul>';
                     }
                     $content .= '</li>';
                 }
             }
             $content .= '</ul>';
         }
     }
     return $content;
 }
Exemplo n.º 6
0
 /**
  * Displays the form to register users in a blog (in a course)
  * The listed users are users subcribed in the course.
  * @author Toon Keppens
  *
  * @param Integer $blog_id
  *
  * @return Html Form with sortable table with users to unsubcribe from a blog.
  */
 public static function display_form_user_unsubscribe($blog_id)
 {
     $_user = api_get_user_info();
     $is_western_name_order = api_is_western_name_order();
     // Init
     $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
     $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
     echo '<legend>' . get_lang('UnsubscribeMembers') . '</legend>';
     $properties["width"] = "100%";
     //table column titles
     $column_header[] = array('', false, '');
     if ($is_western_name_order) {
         $column_header[] = array(get_lang('FirstName'), true, '');
         $column_header[] = array(get_lang('LastName'), true, '');
     } else {
         $column_header[] = array(get_lang('LastName'), true, '');
         $column_header[] = array(get_lang('FirstName'), true, '');
     }
     $column_header[] = array(get_lang('Email'), false, '');
     $column_header[] = array(get_lang('TaskManager'), true, '');
     $column_header[] = array(get_lang('UnRegister'), false, '');
     $course_id = api_get_course_int_id();
     $sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username\n                FROM {$tbl_users} user INNER JOIN {$tbl_blogs_rel_user} blogs_rel_user\n                ON user.user_id = blogs_rel_user.user_id\n                WHERE blogs_rel_user.c_id = {$course_id} AND  blogs_rel_user.blog_id = '" . (int) $blog_id . "'";
     if (!($sql_result = Database::query($sql))) {
         return false;
     }
     $user_data = array();
     while ($myrow = Database::fetch_array($sql_result)) {
         $row = array();
         $row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" ' . (isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe" ? ' checked="checked" ' : '') . '/>';
         $username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES);
         if ($is_western_name_order) {
             $row[] = $myrow["firstname"];
             $row[] = Display::tag('span', $myrow["lastname"], array('title' => $username));
         } else {
             $row[] = Display::tag('span', $myrow["lastname"], array('title' => $username));
             $row[] = $myrow["firstname"];
         }
         $row[] = Display::icon_mailto_link($myrow["email"]);
         $sql = "SELECT bt.title task\n\t\t\t\t\tFROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER) . " btu\n\t\t\t\t\tINNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS) . " bt\n\t\t\t\t\tON btu.task_id = bt.task_id\n\t\t\t\t\tWHERE \tbtu.c_id \t= {$course_id}  AND\n\t\t\t\t\t\t\tbt.c_id \t= {$course_id}  AND\n\t\t\t\t\t\t\tbtu.blog_id = {$blog_id} AND\n\t\t\t\t\t\t\tbtu.user_id = " . $myrow['user_id'];
         $sql_res = Database::query($sql);
         $task = '';
         while ($r = Database::fetch_array($sql_res)) {
             $task .= stripslashes($r['task']) . ', ';
         }
         //echo $task;
         $task = api_strlen(trim($task)) != 0 ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader');
         $row[] = $task;
         //Link to register users
         if ($myrow["user_id"] != $_user['user_id']) {
             $row[] = "<a class=\"btn btn-primary\" href=\"" . api_get_self() . "?action=manage_members&blog_id={$blog_id}&unregister=yes&user_id=" . $myrow['user_id'] . "\">" . get_lang('UnRegister') . "</a>";
         } else {
             $row[] = '';
         }
         $user_data[] = $row;
     }
     $query_vars['action'] = 'manage_members';
     $query_vars['blog_id'] = $blog_id;
     echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">';
     Display::display_sortable_table($column_header, $user_data, null, null, $query_vars);
     $link = '';
     $link .= isset($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : '';
     $link .= "blog_id={$blog_id}&";
     echo '<a href="blog.php?' . $link . 'selectall=unsubscribe">' . get_lang('SelectAll') . '</a> - ';
     echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> ';
     echo get_lang('WithSelected') . ' : ';
     echo '<select name="action">';
     echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>';
     echo '</select>';
     echo '<input type="hidden" name="unregister" value="true" />';
     echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>';
     echo '</form>';
 }
 list($typeImg, $typeExpl) = $objQuestionTmp->get_type_icon_html();
 $questionType = Display::tag('div', Display::return_icon($typeImg, $typeExpl, array(), ICON_SIZE_MEDIUM), array('style' => $styleType));
 // Question category
 $txtQuestionCat = Security::remove_XSS(TestCategory::getCategoryNameForQuestion($objQuestionTmp->id));
 if (empty($txtQuestionCat)) {
     $txtQuestionCat = "-";
 }
 $questionCategory = Display::tag('div', '<a href="#" style="padding:0px; margin:0px;" title="' . $txtQuestionCat . '">' . cut($txtQuestionCat, 42) . '</a>', array('style' => $styleCat));
 // Question level
 $txtQuestionLevel = $objQuestionTmp->level;
 if (empty($objQuestionTmp->level)) {
     $txtQuestionLevel = '-';
 }
 $questionLevel = Display::tag('div', $txtQuestionLevel, array('style' => $styleLevel));
 // Question score
 $questionScore = Display::tag('div', $objQuestionTmp->selectWeighting(), array('style' => $styleScore));
 echo '<div id="question_id_list_' . $id . '" >';
 echo '<div class="header_operations">';
 echo $questionName;
 echo $questionType;
 echo $questionCategory;
 echo $questionLevel;
 echo $questionScore;
 echo $actions;
 echo '</div>';
 echo '<div class="question-list-description-block">';
 echo '<p class="lead">' . get_lang($question_class) . '</p>';
 //echo get_lang('Level').': '.$objQuestionTmp->selectLevel();
 ExerciseLib::showQuestion($id, false, null, null, false, true, false, true, $objExercise->feedback_type, true);
 echo '</div>';
 echo '</div>';
Exemplo n.º 8
0
 * @package chamilo.plugin.buycourses
 */
/**
 * Init
 */
require_once '../config.php';
require_once api_get_path(LIBRARY_PATH) . 'mail.lib.inc.php';

$language_file = array('course_description');

// Get the name of the database course.		
$tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);

$code = Database::escape_string($_GET['code']);
$course_info = api_get_course_info($code);
echo Display::tag('h2', $course_info['name']);
echo '<br />';

$sql = "SELECT * FROM $tbl_course_description
    WHERE c_id = " . intval($course_info['real_id']) . "
    AND session_id = 0 ORDER BY id";

$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
    while ($description = Database::fetch_object($result)) {
        $descriptions[$description->id] = $description;
    }
    // Function that displays the details of the course description in html.
    echo CourseManager::get_details_course_description_html($descriptions, api_get_system_encoding(), false);
} else {
    echo get_lang('NoDescription');
Exemplo n.º 9
0
 /**
  * @param int $user_id
  * @param string $filter current|history
  * @param int $page
  * @return bool|null|string
  */
 public function returnSessions($user_id, $filter, $page)
 {
     if (empty($user_id)) {
         return false;
     }
     $app = $this->app;
     $loadHistory = isset($filter) && $filter == 'history' ? true : false;
     $app['session_menu'] = function ($app) use($loadHistory) {
         $menu = $app['knp_menu.factory']->createItem('root', array('childrenAttributes' => array('class' => 'nav nav-tabs', 'currentClass' => 'active')));
         $current = $menu->addChild(get_lang('Current'), array('route' => 'userportal', 'routeParameters' => array('filter' => 'current', 'type' => 'sessions')));
         $history = $menu->addChild(get_lang('HistoryTrainingSession'), array('route' => 'userportal', 'routeParameters' => array('filter' => 'history', 'type' => 'sessions')));
         //@todo use URIVoter
         if ($loadHistory) {
             $history->setCurrent(true);
         } else {
             $current->setCurrent(true);
         }
         return $menu;
     };
     //@todo move this in template
     $app['knp_menu.menus'] = array('actions_menu' => 'session_menu');
     $start = ($page - 1) * $this->maxPerPage;
     if ($loadHistory) {
         // Load sessions in category in *history*.
         $nbResults = (int) UserManager::get_sessions_by_category($user_id, true, true, true, null, null, 'no_category');
         $session_categories = UserManager::get_sessions_by_category($user_id, true, false, true, $start, $this->maxPerPage, 'no_category');
     } else {
         // Load sessions in category.
         $nbResults = (int) UserManager::get_sessions_by_category($user_id, false, true, false, null, null, 'no_category');
         $session_categories = UserManager::get_sessions_by_category($user_id, false, false, false, $start, $this->maxPerPage, 'no_category');
     }
     $html = null;
     // Showing history title
     if ($loadHistory) {
         // $html .= Display::page_subheader(get_lang('HistoryTrainingSession'));
         if (empty($session_categories)) {
             $html .= get_lang('YouDoNotHaveAnySessionInItsHistory');
         }
     }
     $load_directories_preview = api_get_setting('show_documents_preview') == 'true' ? true : false;
     $sessions_with_no_category = $html;
     if (isset($session_categories) && !empty($session_categories)) {
         foreach ($session_categories as $session_category) {
             $session_category_id = $session_category['session_category']['id'];
             // Sessions does not belong to a session category
             if ($session_category_id == 0) {
                 // Independent sessions
                 if (isset($session_category['sessions'])) {
                     foreach ($session_category['sessions'] as $session) {
                         $session_id = $session['session_id'];
                         // Don't show empty sessions.
                         if (count($session['courses']) < 1) {
                             continue;
                         }
                         $html_courses_session = '';
                         $count_courses_session = 0;
                         foreach ($session['courses'] as $course) {
                             //Read only and accessible
                             if (api_get_setting('hide_courses_in_sessions') == 'false') {
                                 $html_courses_session .= CourseManager::get_logged_user_course_html($course, $session_id, $load_directories_preview);
                             }
                             $count_courses_session++;
                         }
                         if ($count_courses_session > 0) {
                             $params = array();
                             $params['icon'] = Display::return_icon('window_list.png', $session['session_name'], array('id' => 'session_img_' . $session_id), ICON_SIZE_LARGE);
                             $params['is_session'] = true;
                             //Default session name
                             $session_link = $session['session_name'];
                             $params['link'] = null;
                             if (api_get_setting('session_page_enabled') == 'true' && !api_is_drh()) {
                                 //session name with link
                                 $session_link = Display::tag('a', $session['session_name'], array('href' => api_get_path(WEB_CODE_PATH) . 'session/index.php?session_id=' . $session_id));
                                 $params['link'] = api_get_path(WEB_CODE_PATH) . 'session/index.php?session_id=' . $session_id;
                             }
                             $params['title'] = $session_link;
                             $moved_status = SessionManager::get_session_change_user_reason($session['moved_status']);
                             $moved_status = isset($moved_status) && !empty($moved_status) ? ' (' . $moved_status . ')' : null;
                             $params['subtitle'] = isset($session['coach_info']) ? $session['coach_info']['complete_name'] : null . $moved_status;
                             $params['dates'] = $session['date_message'];
                             $params['right_actions'] = '';
                             if (api_is_platform_admin()) {
                                 $params['right_actions'] .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'admin/resume_session.php?id_session=' . $session_id . '">';
                                 $params['right_actions'] .= Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>';
                             }
                             if (api_get_setting('hide_courses_in_sessions') == 'false') {
                                 //    $params['extra'] .=  $html_courses_session;
                             }
                             $sessions_with_no_category .= CourseManager::course_item_parent(CourseManager::course_item_html($params, true), $html_courses_session);
                         }
                     }
                 }
             }
         }
         $adapter = new FixedAdapter($nbResults, array());
         $pagerfanta = new Pagerfanta($adapter);
         $pagerfanta->setMaxPerPage($this->maxPerPage);
         // 10 by default
         $pagerfanta->setCurrentPage($page);
         // 1 by default
         $this->app['pagerfanta.view.router.name'] = 'userportal';
         $this->app['pagerfanta.view.router.params'] = array('filter' => $filter, 'type' => 'sessions', 'page' => $page);
         $this->app['template']->assign('pagination', $pagerfanta);
     }
     return $sessions_with_no_category;
 }
Exemplo n.º 10
0
        echo $template->fetch('default/javascript/chat/start_video.tpl');
        break;
    case 'create_room':
        $room = VideoChat::getChatRoomByUsers(api_get_user_id(), $to_user_id);
        $createdRoom = false;
        if ($room === false) {
            $roomName = isset($_REQUEST['room_name']) ? Security::remove_XSS($_REQUEST['room_name']) : null;
            if (VideoChat::nameExists($roomName)) {
                echo Display::return_message(get_lang('TheVideoChatRoomXNameAlreadyExists'), 'error');
                break;
            }
            $createdRoom = VideoChat::createRoom($roomName, api_get_user_id(), $to_user_id);
        } else {
            $roomName = $room['room_name'];
            $createdRoom = true;
        }
        if ($createdRoom === false) {
            echo Display::return_message(get_lang('ChatRoomNotCreated'), 'error');
            break;
        }
        $videoChatLink = Display::url(Display::tag('i', null, ['class' => 'fa fa-video-camera']) . "&nbsp;" . get_lang('StartVideoChat'), api_get_path(WEB_LIBRARY_JS_PATH) . "chat/video.php?room={$roomName}");
        $chat->send(api_get_user_id(), $to_user_id, $videoChatLink, false);
        echo Display::tag('p', $videoChatLink, ['class' => 'lead']);
        break;
    case 'notify_not_support':
        $chat->send(api_get_user_id(), $to_user_id, get_lang('TheXUserBrowserDoesNotSupportWebRTC'));
        break;
    default:
        echo '';
}
exit;
Exemplo n.º 11
0
    }
    $label_attributes = array();
    $label_attributes['class'] = 'checkbox';
    $label_attributes['for'] = $check_id;
    $label_attributes['class'] = "checkbox";
    $checkbox = Display::input('checkbox', 'remind_list[' . $questionId . ']', '', $attributes);
    $url = 'exercise_submit.php?exerciseId=' . $objExercise->id . '&num=' . $counter . '&reminder=1';
    $counter++;
    if ($objExercise->type == ONE_PER_PAGE) {
        $question_title = Display::url($counter . '. ' . cut($objQuestionTmp->selectTitle(), 40), $url);
        $question_title = $counter . '. ' . cut($objQuestionTmp->selectTitle(), 40);
    } else {
        $question_title = $counter . '. ' . cut($objQuestionTmp->selectTitle(), 40);
    }
    //Check if the question doesn't have an answer
    if (!in_array($questionId, $exercise_result)) {
        $question_title = Display::label($question_title, 'warning');
    }
    $question_title = Display::tag('label', $checkbox . $question_title, $label_attributes);
    $table .= Display::div($question_title, array('class' => 'exercise_reminder_item'));
}
// end foreach() block that loops over all questions
echo Display::div($table, array('class' => 'span10'));
$exercise_actions = Display::url(get_lang('EndTest'), 'javascript://', array('onclick' => 'final_submit();', 'class' => 'btn btn-warning'));
$exercise_actions .= '&nbsp;' . Display::url(get_lang('ReviewQuestions'), 'javascript://', array('onclick' => 'review_questions();', 'class' => 'btn btn-success'));
echo Display::div('', array('class' => 'clear'));
echo Display::div($exercise_actions, array('class' => 'form-actions'));
if ($origin != 'learnpath') {
    // We are not in learnpath tool
    Display::display_footer();
}
Exemplo n.º 12
0
                $result['id'],
                $result['picture_uri'],
                80
            );
            $result['picture_uri'] = '<img class="social-groups-image" src="' . $picture['file'] . '" hspace="4" height="50" border="2" align="left" width="50" />';

            $item_0 = Display::div(
                $result['picture_uri'],
                array('class' => 'box_description_group_image')
            );
            $members = Display::span(
                $count_users_group,
                array('class' => 'box_description_group_member')
            );
            $item_1 = Display::div(
                Display::tag('h3', $url_open . $name . $url_close) . $members,
                array('class' => 'box_description_group_title')
            );

            if ($result['description'] != '') {
                $item_3 = '<div class="box_description_group_content" >' . cut(
                        $result['description'],
                        100,
                        true
                    ) . '</div>';
            } else {
                $item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2"></span></div>';
                $item_3 = '<div class="box_description_group_content" ></div>';
            }

            $join_url = '';
Exemplo n.º 13
0
 /**
  * @param int $user_id
  * @param $filter
  * @param bool $load_dirs
  * @param int $getCount
  * @param int $start
  * @param null $maxPerPage
  * @return null|string
  */
 public static function displayCourses($user_id, $filter, $load_dirs, $getCount, $start = null, $maxPerPage = null)
 {
     // Table definitions
     $TABLECOURS = Database::get_main_table(TABLE_MAIN_COURSE);
     $TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
     $TABLE_ACCESS_URL_REL_COURSE = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
     $current_url_id = api_get_current_access_url_id();
     // Get course list auto-register
     $special_course_list = self::get_special_course_list();
     $without_special_courses = '';
     if (!empty($special_course_list)) {
         //$without_special_courses = ' AND course.code NOT IN ("'.implode('","',$special_course_list).'")';
     }
     $select = " SELECT DISTINCT\n                    course.id,\n                    course.title,\n                    course.code,\n                    course.subscribe subscr,\n                    course.unsubscribe unsubscr,\n                    course_rel_user.status status,\n                    course_rel_user.sort sort,\n                    course_rel_user.user_course_cat user_course_cat,\n                    course.id as real_id\n        ";
     $from = "{$TABLECOURS} course, {$TABLECOURSUSER}  course_rel_user, {$TABLE_ACCESS_URL_REL_COURSE} url ";
     $where = "  course.id = course_rel_user.c_id AND\n                    url.c_id = course.id AND\n                    course_rel_user.user_id = '" . $user_id . "' AND\n                    course_rel_user.user_course_cat = 0\n                    ";
     $order = " ORDER BY course_rel_user.user_course_cat, course_rel_user.sort ASC";
     if ($getCount) {
         $select = "SELECT count(course.id) as total";
     }
     $sql = "{$select} FROM {$from} WHERE {$where} {$without_special_courses} ";
     // corresponding to the current URL.
     if (api_get_multiple_access_url() && $current_url_id != -1) {
         $sql .= " AND url.c_id = course.id AND access_url_id='" . $current_url_id . "'";
     }
     $sql .= $order;
     if (isset($start) && isset($maxPerPage)) {
         $start = intval($start);
         $maxPerPage = intval($maxPerPage);
         $limitCondition = " LIMIT {$start}, {$maxPerPage}";
         $sql .= $limitCondition;
     }
     if ($getCount) {
         $result = Database::query($sql);
         $row = Database::fetch_array($result);
         return $row['total'];
     }
     $result = Database::query($sql);
     $html = null;
     $course_list = array();
     // Browse through all courses.
     while ($course = Database::fetch_array($result)) {
         $course_info = api_get_course_info($course['code']);
         $course_info['id_session'] = null;
         $course_info['status'] = $course['status'];
         //In order to avoid doubles
         if (in_array($course_info['real_id'], $course_list)) {
             continue;
         } else {
             $course_list[] = $course_info['real_id'];
         }
         // For each course, get if there is any notification icon to show
         // (something that would have changed since the user's last visit).
         $show_notification = Display::show_notification($course_info);
         // New code displaying the user's status in respect to this course.
         $status_icon = Display::return_icon('blackboard.png', $course_info['title'], array(), ICON_SIZE_LARGE);
         $params = array();
         $params['right_actions'] = '';
         if (api_is_platform_admin()) {
             if ($load_dirs) {
                 $params['right_actions'] .= '<a id="document_preview_' . $course_info['real_id'] . '_0" class="document_preview" href="javascript:void(0);">' . Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>';
                 $params['right_actions'] .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'course_info/infocours.php?cidReq=' . $course['code'] . '">' . Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>';
                 $params['right_actions'] .= Display::div('', array('id' => 'document_result_' . $course_info['real_id'] . '_0', 'class' => 'document_preview_container'));
             } else {
                 $params['right_actions'] .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'course_info/infocours.php?cidReq=' . $course['code'] . '">' . Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>';
             }
             if ($course_info['status'] == COURSEMANAGER) {
                 //echo Display::return_icon('teachers.gif', get_lang('Status').': '.get_lang('Teacher'), array('style'=>'width: 11px; height: 11px;'));
             }
         } else {
             if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED) {
                 if ($load_dirs) {
                     $params['right_actions'] .= '<a id="document_preview_' . $course_info['real_id'] . '_0" class="document_preview" href="javascript:void(0);">' . Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>';
                     $params['right_actions'] .= Display::div('', array('id' => 'document_result_' . $course_info['real_id'] . '_0', 'class' => 'document_preview_container'));
                 } else {
                     if ($course_info['status'] == COURSEMANAGER) {
                         $params['right_actions'] .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'course_info/infocours.php?cidReq=' . $course['code'] . '">' . Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>';
                     }
                 }
             }
         }
         $course_title_url = '';
         if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED || $course['status'] == COURSEMANAGER) {
             //$course_title_url = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php?id_session=0';
             $course_title_url = api_get_path(WEB_COURSE_PATH) . $course_info['code'] . '/index.php?id_session=0';
             $course_title = Display::url($course_info['title'], $course_title_url);
         } else {
             $course_title = $course_info['title'] . " " . Display::tag('span', get_lang('CourseClosed'), array('class' => 'item_closed'));
         }
         // Start displaying the course block itself
         if (api_get_setting('course.display_coursecode_in_courselist') == 'true') {
             $course_title .= ' (' . $course_info['visual_code'] . ') ';
         }
         $teachers = null;
         if (api_get_setting('course.display_teacher_in_courselist') == 'true') {
             $teachers = $course_info['teacher_list_formatted'];
         }
         $params['link'] = $course_title_url;
         $params['icon'] = $status_icon;
         $params['title'] = $course_title;
         $params['teachers'] = $teachers;
         if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED) {
             $params['notifications'] = $show_notification;
         }
         $is_subcontent = true;
         if (empty($user_category_id)) {
             $is_subcontent = false;
         }
         $html .= self::course_item_html($params, $is_subcontent);
     }
     return $html;
 }
Exemplo n.º 14
0
    foreach ($thematic_plan_data as $thematic_item) {
        $thematic_simple_list[] = $thematic_item['description_type'];
        $new_thematic_plan_data[$thematic_item['description_type']] = $thematic_item;
    }
}
$new_id = ADD_THEMATIC_PLAN;
if (!empty($thematic_simple_list)) {
    foreach ($thematic_simple_list as $item) {
        if ($item >= ADD_THEMATIC_PLAN) {
            $new_id = $item + 1;
            $default_thematic_plan_title[$item] = $new_thematic_plan_data[$item]['title'];
        }
    }
}
$i = 1;
echo Display::tag('h2', $thematic_data['title']);
echo $thematic_data['content'];
if ($message == 'ok') {
    Display::display_normal_message(get_lang('ThematicSectionHasBeenCreatedSuccessfull'));
}
if ($action == 'thematic_plan_list') {
    $form = new FormValidator('thematic_plan_add', 'POST', 'index.php?action=thematic_plan_list&thematic_id=' . $thematic_id . '&' . api_get_cidreq() . $param_gradebook, '', 'style="width: 100%;"');
    $form->addElement('hidden', 'action', 'thematic_plan_add');
    $form->addElement('hidden', 'thematic_plan_token', $token);
    $form->addElement('hidden', 'thematic_id', $thematic_id);
    foreach ($default_thematic_plan_title as $id => $title) {
        $form->addElement('hidden', 'description_type[' . $id . ']', $id);
        $form->add_textfield('title[' . $id . ']', get_lang('Title'), false, array('size' => '50'));
        $form->add_html_editor('description[' . $id . ']', get_lang('Description'), false, false, array('ToolbarStartExpanded' => 'false', 'ToolbarSet' => 'TrainingDescription', 'Width' => '80%', 'Height' => '150'));
        //$form->addElement('textarea', 'description['.$id.']', get_lang('Description'));
        if (!empty($thematic_simple_list) && in_array($id, $thematic_simple_list)) {
Exemplo n.º 15
0
 function print_recursive($elements, $default_data, $default_content)
 {
     $return = '';
     foreach ($elements as $key => $item) {
         if (isset($item['load_data']) || empty($item['data'])) {
             $item['data'] = $default_data[$item['load_data']];
             $item['type'] = $default_content[$item['load_data']]['item_type'];
         }
         $sub_list = '';
         if (isset($item['type']) && $item['type'] == 'dokeos_chapter') {
             $sub_list = Display::tag('li', '', array('class' => 'sub_item empty'));
             // empty value
         }
         if (empty($item['children'])) {
             $sub_list = Display::tag('ul', $sub_list, array('id' => 'UL_' . $key, 'class' => 'record li_container'));
             $active = null;
             if (isset($_REQUEST['id']) && $key == $_REQUEST['id']) {
                 $active = 'active';
             }
             $return .= Display::tag('li', Display::div($item['data'], array('class' => "item_data {$active}")) . $sub_list, array('id' => $key, 'class' => 'record li_container'));
         } else {
             //sections
             if (isset($item['children'])) {
                 $data = self::print_recursive($item['children'], $default_data, $default_content);
             }
             $sub_list = Display::tag('ul', $sub_list . $data, array('id' => 'UL_' . $key, 'class' => 'record li_container'));
             $return .= Display::tag('li', Display::div($item['data'], array('class' => 'item_data')) . $sub_list, array('id' => $key, 'class' => 'record li_container'));
         }
     }
     return $return;
 }
Exemplo n.º 16
0
    /**
     * Displays the header for the gradebook containing the navigation tree and links
     * @param Category $catobj
     * @param int $showtree '1' will show the browse tree and naviation buttons
     * @param boolean $is_course_admin
     * @param boolean $is_platform_admin
     * @param boolean Whether to show or not the link to add a new qualification
     * (we hide it in case of the course-embedded tool where we have only one
     * calification per course or session)
     * @param boolean Whether to show or not the link to add a new item inside
     * the qualification (we hide it in case of the course-embedded tool
     * where we have only one calification per course or session)
     * @return void Everything is printed on screen upon closing
     */
    static function display_header_gradebook($catobj, $showtree, $selectcat, $is_course_admin, $is_platform_admin, $simple_search_form, $show_add_qualification = true, $show_add_link = true, $certificateLinkInfo = null)
    {
        // Student.
        $status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
        $objcat = new Category();
        $course_id = Database::get_course_by_category($selectcat);
        $message_resource = $objcat->show_message_resource_delete($course_id);
        $grade_model_id = $catobj->get_grade_model_id();
        $header = null;
        //@todo move these in a function
        $sum_categories_weight_array = array();
        if (isset($catobj) && !empty($catobj)) {
            $categories = Category::load(null, null, null, $catobj->get_id());
            if (!empty($categories)) {
                foreach ($categories as $category) {
                    $sum_categories_weight_array[$category->get_id()] = $category->get_weight();
                }
            } else {
                $sum_categories_weight_array[$catobj->get_id()] = $catobj->get_weight();
            }
        }
        if (!$is_course_admin && $status != 1 && $selectcat != 0) {
            $user_id = api_get_user_id();
            $catcourse = Category::load($catobj->get_id());
            $main_weight = $catcourse[0]->get_weight();
            $scoredisplay = ScoreDisplay::instance();
            //$categories = Category::getCategories($catcourse[0]->get_id());
            // generating the total score for a course
            /*if (count($categories) > 0) {
                  foreach ($categories as $category) {
                      $allevals = $category->get_evaluations($user_id, true);
                      $alllinks = $category->get_links($user_id, true);
                      $catEvalsLinks = array_merge($allevals, $alllinks);
                  }
              }*/
            $allevals = $catcourse[0]->get_evaluations($user_id, true);
            $alllinks = $catcourse[0]->get_links($user_id, true);
            $allEvalsLinks = array_merge($allevals, $alllinks);
            $item_value_total = 0;
            $scoreinfo = null;
            for ($count = 0; $count < count($allEvalsLinks); $count++) {
                $item = $allEvalsLinks[$count];
                $score = $item->calc_score($user_id);
                if (!empty($score)) {
                    $divide = $score[1] == 0 ? 1 : $score[1];
                    //$sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()];
                    //$item_value = $score[0] / $divide * $item->get_weight() / $sub_cat_percentage * $sub_cat_percentage / $main_weight * $main_weight;
                    $item_value = $score[0] / $divide * $item->get_weight();
                    //var_dump($score[0], $divide, $item->get_weight(), $sub_cat_percentage, $main_weight, $item_value);
                    $item_value_total += $item_value;
                }
            }
            $item_total = $main_weight;
            $total_score = array($item_value_total, $item_total);
            $scorecourse_display = $scoredisplay->display_score($total_score, SCORE_DIV_PERCENT);
            if (!$catobj->get_id() == '0' && !isset($_GET['studentoverview']) && !isset($_GET['search'])) {
                $certificateLink = null;
                if (!empty($certificateLinkInfo) && isset($certificateLinkInfo['certificate_link'])) {
                    $certificateLink .= '<span style="float:right"> ' . $certificateLinkInfo['certificate_link'] . "</span>";
                }
                $scoreinfo .= '<h4>' . get_lang('Total') . ' : ' . $scorecourse_display . $certificateLink . '</h4>';
            }
            Display::display_normal_message($scoreinfo, false);
        }
        // show navigation tree and buttons?
        if ($showtree == '1' || isset($_GET['studentoverview'])) {
            $header = '<div class="actions"><table>';
            $header .= '<tr>';
            if (!$selectcat == '0') {
                $header .= '<td><a href="' . api_get_self() . '?selectcat=' . $catobj->get_parent_id() . '">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('RootCat'), '', ICON_SIZE_MEDIUM) . '</a></td>';
            }
            $header .= '<td>' . get_lang('CurrentCategory') . '</td>' . '<td><form name="selector"><select name="selectcat" onchange="document.selector.submit()">';
            $cats = Category::load();
            $tree = $cats[0]->get_tree();
            unset($cats);
            $line = null;
            foreach ($tree as $cat) {
                for ($i = 0; $i < $cat[2]; $i++) {
                    $line .= '&mdash;';
                }
                $line = isset($line) ? $line : '';
                if (isset($_GET['selectcat']) && $_GET['selectcat'] == $cat[0]) {
                    $header .= '<option selected value=' . $cat[0] . '>' . $line . ' ' . $cat[1] . '</option>';
                } else {
                    $header .= '<option value=' . $cat[0] . '>' . $line . ' ' . $cat[1] . '</option>';
                }
                $line = '';
            }
            $header .= '</select></form></td>';
            if (!empty($simple_search_form) && $message_resource === false) {
                $header .= '<td style="vertical-align: top;">' . $simple_search_form->toHtml() . '</td>';
            } else {
                $header .= '<td></td>';
            }
            if ($is_course_admin && $message_resource === false && $_GET['selectcat'] != 0) {
                /* $header .= '<td style="vertical-align: top;"><a href="gradebook_flatview.php?'.api_get_cidreq().'&selectcat=' . $catobj->get_id() . '"><img src="../img/view_list.gif" alt="' . get_lang('FlatView') . '" /> ' . get_lang('FlatView') . '</a>';
                   if ($is_course_admin && $message_resource===false) {
                   $header .= '<td style="vertical-align: top;"><a href="gradebook_scoring_system.php?'.api_get_cidreq().'&selectcat=' . $catobj->get_id() .'"><img src="../img/acces_tool.gif" alt="' . get_lang('ScoreEdit') . '" /> ' . get_lang('ScoreEdit') . '</a>';
                   } */
            } elseif (!isset($_GET['studentoverview'])) {
                if ($message_resource === false) {
                    //$header .= '<td style="vertical-align: top;"><a href="'.api_get_self().'?'.api_get_cidreq().'&studentoverview=&selectcat=' . $catobj->get_id() . '"><img src="../img/view_list.gif" alt="' . get_lang('FlatView') . '" /> ' . get_lang('FlatView') . '</a>';
                }
            } else {
                $header .= '<td style="vertical-align: top;"><a href="' . api_get_self() . '?' . api_get_cidreq() . '&studentoverview=&exportpdf=&selectcat=' . $catobj->get_id() . '" target="_blank">
							<img src="../img/icons/32/pdf.png" alt="' . get_lang('ExportPDF') . '" /> ' . get_lang('ExportPDF') . '</a>';
            }
            $header .= '</td></tr>';
            $header .= '</table></div>';
        }
        // for course admin & platform admin add item buttons are added to the header
        $header .= '<div class="actions">';
        $my_category = $catobj->shows_all_information_an_category($catobj->get_id());
        $user_id = api_get_user_id();
        $my_api_cidreq = api_get_cidreq();
        //$course_code = $my_category['course_code'];
        //$status_user = api_get_status_of_user_in_course ($user_id,$course_code);
        if (api_is_allowed_to_edit(null, true)) {
            if (empty($grade_model_id) || $grade_model_id == -1) {
                $header .= '<a href="gradebook_add_cat.php?' . api_get_cidreq() . '&selectcat=' . $catobj->get_id() . '">' . Display::return_icon('new_folder.png', get_lang('AddGradebook'), array(), ICON_SIZE_MEDIUM) . '</a></td>';
            }
            if ($selectcat == '0') {
            } else {
                $my_category = $catobj->shows_all_information_an_category($catobj->get_id());
                if ($my_api_cidreq == '') {
                    $my_api_cidreq = 'cidReq=' . $my_category['course_code'];
                }
                if ($show_add_link && !$message_resource) {
                    $header .= '<td><a href="gradebook_add_eval.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '" >' . Display::return_icon('new_evaluation.png', get_lang('NewEvaluation'), '', ICON_SIZE_MEDIUM) . '</a>';
                    $cats = Category::load($selectcat);
                    if ($cats[0]->get_course_code() != null && !$message_resource) {
                        $header .= '<td><a href="gradebook_add_link.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' . Display::return_icon('new_online_evaluation.png', get_lang('MakeLink'), '', ICON_SIZE_MEDIUM) . '</a>';
                    } else {
                        $header .= '<td><a href="gradebook_add_link_select_course.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' . Display::return_icon('new_online_evaluation.png', get_lang('MakeLink'), '', ICON_SIZE_MEDIUM) . '</a>';
                    }
                }
                if (!$message_resource) {
                    $header .= '<td style="vertical-align: top;"><a href="gradebook_flatview.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' . Display::return_icon('stats.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM) . '</a>';
                    $header .= '<td style="vertical-align: top;"><a href="gradebook_display_certificate.php?' . $my_api_cidreq . '&amp;cat_id=' . (int) $_GET['selectcat'] . '">' . Display::return_icon('certificate_list.png', get_lang('GradebookSeeListOfStudentsCertificates'), '', ICON_SIZE_MEDIUM) . '</a>';
                    // Right icons
                    $modify_icons = '<a href="gradebook_edit_cat.php?editcat=' . $catobj->get_id() . '&amp;cidReq=' . $catobj->get_course_code() . '&id_session=' . $catobj->get_session_id() . '">' . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM) . '</a>';
                    $modify_icons .= '<a href="../document/document.php?curdirpath=/certificates&' . $my_api_cidreq . '&origin=gradebook&selectcat=' . $catobj->get_id() . '">' . Display::return_icon('certificate.png', get_lang('AttachCertificate'), '', ICON_SIZE_MEDIUM) . '</a>';
                    if (empty($categories)) {
                        $modify_icons .= '<a href="gradebook_edit_all.php?id_session=' . api_get_session_id() . '&amp;' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' . Display::return_icon('percentage.png', get_lang('EditAllWeights'), '', ICON_SIZE_MEDIUM) . '</a>';
                    }
                    $score_display_custom = api_get_setting('gradebook_score_display_custom');
                    if (api_get_setting('teachers_can_change_score_settings') == 'true' && $score_display_custom['my_display_custom'] == 'true') {
                        $modify_icons .= '<a href="gradebook_scoring_system.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' . Display::return_icon('ranking.png', get_lang('ScoreEdit'), '', ICON_SIZE_MEDIUM) . '</a>';
                    }
                    $header .= Display::div($modify_icons, array('class' => 'right'));
                }
            }
        } elseif (isset($_GET['search'])) {
            $header .= '<b>' . get_lang('SearchResults') . ' :</b>';
        }
        $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(api_get_user_id(), api_get_course_info());
        if ($isDrhOfCourse) {
            $header .= '<td style="vertical-align: top;"><a href="gradebook_flatview.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' . Display::return_icon('stats.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM) . '</a>';
            /*$header .= '<td style="vertical-align: top;"><a href="gradebook_display_certificate.php?' . $my_api_cidreq . '&amp;cat_id=' . (int) $_GET['selectcat'] . '">' .
              Display::return_icon('certificate_list.png', get_lang('GradebookSeeListOfStudentsCertificates'), '', ICON_SIZE_MEDIUM) . '</a>';*/
        }
        $header .= '</div>';
        echo $header;
        if (api_is_allowed_to_edit(null, true)) {
            $weight = intval($catobj->get_weight()) > 0 ? $catobj->get_weight() : 0;
            $weight = get_lang('TotalWeight') . ' : ' . $weight;
            $min_certification = intval($catobj->get_certificate_min_score() > 0) ? $catobj->get_certificate_min_score() : 0;
            $min_certification = get_lang('CertificateMinScore') . ' : ' . $min_certification;
            $edit_icon = '<a class="right_link" href="gradebook_edit_cat.php?editcat=' . $catobj->get_id() . '&amp;cidReq=' . $catobj->get_course_code() . '&id_session=' . $catobj->get_session_id() . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>';
            //$msg = Display::tag('h3', $weight.' - '.$min_certification);
            $msg = Display::tag('h4', $weight . ' - ' . $min_certification . $edit_icon);
            //@todo show description
            $description = $catobj->get_description() == "" || is_null($catobj->get_description()) ? '' : '<strong>' . get_lang('GradebookDescriptionLog') . '</strong>' . ': ' . $catobj->get_description();
            Display::display_normal_message($msg, false);
            if (!empty($description)) {
                echo Display::div($description, array());
            }
        }
    }
Exemplo n.º 17
0
 /**
  * Displays messages of a group with nested view
  *
  * @param int $group_id
  */
 public static function display_messages_for_group($group_id)
 {
     global $my_group_role;
     $rows = self::get_messages_by_group($group_id);
     $topics_per_page = 10;
     $html_messages = '';
     $query_vars = array('id' => $group_id, 'topics_page_nr' => 0);
     if (is_array($rows) && count($rows) > 0) {
         // prepare array for topics with its items
         $topics = array();
         $x = 0;
         foreach ($rows as $index => $value) {
             if (empty($value['parent_id'])) {
                 $topics[$value['id']] = $value;
             }
         }
         $new_topics = array();
         foreach ($topics as $id => $value) {
             $rows = null;
             $rows = self::get_messages_by_group_by_message($group_id, $value['id']);
             if (!empty($rows)) {
                 $count = count(self::calculate_children($rows, $value['id']));
             } else {
                 $count = 0;
             }
             $value['count'] = $count;
             $new_topics[$id] = $value;
         }
         $array_html = array();
         foreach ($new_topics as $index => $topic) {
             $html = '';
             // topics
             $user_sender_info = api_get_user_info($topic['user_sender_id']);
             $name = $user_sender_info['complete_name'];
             $html .= '<div class="row">';
             $items = $topic['count'];
             $reply_label = $items == 1 ? get_lang('GroupReply') : get_lang('GroupReplies');
             $label = Display::label($items . ' ' . $reply_label);
             $topic['title'] = trim($topic['title']);
             if (empty($topic['title'])) {
                 $topic['title'] = get_lang('Untitled');
             }
             $html .= '<div class="col-md-8">';
             $html .= Display::tag('h4', Display::url(Security::remove_XSS($topic['title'], STUDENT, true), api_get_path(WEB_CODE_PATH) . 'social/group_topics.php?id=' . $group_id . '&topic_id=' . $topic['id']));
             $actions = '';
             if ($my_group_role == GROUP_USER_PERMISSION_ADMIN || $my_group_role == GROUP_USER_PERMISSION_MODERATOR) {
                 $actions = '<br />' . Display::url(get_lang('Delete'), api_get_path(WEB_CODE_PATH) . 'social/group_topics.php?action=delete&id=' . $group_id . '&topic_id=' . $topic['id'], array('class' => 'btn btn-default'));
             }
             $date = '';
             if ($topic['send_date'] != $topic['update_date']) {
                 if (!empty($topic['update_date']) && $topic['update_date'] != '0000-00-00 00:00:00') {
                     $date .= '<div class="message-group-date" > <i>' . get_lang('LastUpdate') . ' ' . date_to_str_ago($topic['update_date']) . '</i></div>';
                 }
             } else {
                 $date .= '<div class="message-group-date"> <i>' . get_lang('Created') . ' ' . date_to_str_ago($topic['send_date']) . '</i></div>';
             }
             $html .= $date . $label . $actions;
             $html .= '</div>';
             $image = $user_sender_info['avatar'];
             $user_info = '<td valign="top"><a href="' . api_get_path(WEB_PATH) . 'main/social/profile.php?u=' . $topic['user_sender_id'] . '">' . $name . '&nbsp;</a>';
             $user_info .= '<div class="message-group-author"><img src="' . $image . '" alt="' . $name . '"  width="32" height="32" title="' . $name . '" /></div>';
             $user_info .= '</td>';
             $html .= '<div class="col-md-2">';
             $html .= $user_info;
             $html .= '</div>';
             $html .= '</div>';
             $array_html[] = array($html);
         }
         // grids for items and topics  with paginations
         $html_messages .= Display::return_sortable_grid('topics', array(), $array_html, array('hide_navigation' => false, 'per_page' => $topics_per_page), $query_vars, false, array(true, true, true, false), false);
     }
     return $html_messages;
 }
Exemplo n.º 18
0
		</script>
    <?php 
        } else {
            echo "<img src='download.php?doc_url={$path}/" . $image_files_only[$slide] . "' alt='" . $image_files_only[$slide] . "' border='0'" . $height_width_tags . ">";
        }
        echo '</a>';
        echo '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>';
        echo $row['comment'];
        echo '</td>';
        echo '<tr>';
        echo '<td style="padding:10px;" align="center">';
        echo Display::tag('h3', $row['title']);
        echo '</td>';
        echo '</tr>';
        echo '</tr>';
        echo '</table>';
        echo '<table align="center" border="0">';
        if (api_is_allowed_to_edit(null, true)) {
            $aux = explode('.', htmlspecialchars($image_files_only[$slide]));
            $ext = $aux[count($aux) - 1];
            if ($_SESSION['image_resizing'] == 'resizing') {
                $resize_info = get_lang('Resizing') . '<br />';
                $resize_widht = $_SESSION["image_resizing_width"] . ' x ';
                $resize_height = $_SESSION['image_resizing_height'];
            } elseif ($_SESSION['image_resizing'] != 'noresizing') {
                $resize_info = get_lang('Resizing') . '<br />';
                $resize_widht = get_lang('Auto') . ' x ';
Exemplo n.º 19
0
 /**
  * Shows the user detail progress (when clicking in the details link)
  * @param   int     $user_id
  * @param   string  $course_code
  * @param   int     $session_id
  * @return  string  html code
  */
 public static function show_course_detail($user_id, $course_code, $session_id)
 {
     $html = '';
     if (isset($course_code)) {
         $user_id = intval($user_id);
         $session_id = intval($session_id);
         $course = Database::escape_string($course_code);
         $course_info = CourseManager::get_course_information($course);
         $html .= Display::page_subheader($course_info['title']);
         $html .= '<table class="data_table" width="100%">';
         //Course details
         $html .= '
             <tr>
             <th class="head" style="color:#000">' . get_lang('Exercises') . '</th>
             <th class="head" style="color:#000">' . get_lang('Attempts') . '</th>
             <th class="head" style="color:#000">' . get_lang('BestAttempt') . '</th>
             <th class="head" style="color:#000">' . get_lang('Ranking') . '</th>
             <th class="head" style="color:#000">' . get_lang('BestResultInCourse') . '</th>
             <th class="head" style="color:#000">' . get_lang('Statistics') . ' ' . Display::return_icon('info3.gif', get_lang('OnlyBestResultsPerStudent'), array('align' => 'absmiddle', 'hspace' => '3px')) . '</th>
             </tr>';
         if (empty($session_id)) {
             $user_list = CourseManager::get_user_list_from_course_code($course, $session_id, null, null, STUDENT);
         } else {
             $user_list = CourseManager::get_user_list_from_course_code($course, $session_id, null, null, 0);
         }
         // Show exercise results of invisible exercises? see BT#4091
         $exercise_list = ExerciseLib::get_all_exercises($course_info, $session_id, false, null, false, 2);
         $to_graph_exercise_result = array();
         if (!empty($exercise_list)) {
             $score = $weighting = $exe_id = 0;
             foreach ($exercise_list as $exercices) {
                 $exercise_obj = new Exercise($course_info['real_id']);
                 $exercise_obj->read($exercices['id']);
                 $visible_return = $exercise_obj->is_visible();
                 $score = $weighting = $attempts = 0;
                 // Getting count of attempts by user
                 $attempts = Event::count_exercise_attempts_by_user(api_get_user_id(), $exercices['id'], $course_info['real_id'], $session_id);
                 $html .= '<tr class="row_even">';
                 $url = api_get_path(WEB_CODE_PATH) . "exercice/overview.php?cidReq={$course_info['code']}&id_session={$session_id}&exerciseId={$exercices['id']}";
                 if ($visible_return['value'] == true) {
                     $exercices['title'] = Display::url($exercices['title'], $url, array('target' => SESSION_LINK_TARGET));
                 }
                 $html .= Display::tag('td', $exercices['title']);
                 // Exercise configuration show results or show only score
                 if ($exercices['results_disabled'] == 0 || $exercices['results_disabled'] == 2) {
                     //For graphics
                     $best_exercise_stats = Event::get_best_exercise_results_by_user($exercices['id'], $course_info['real_id'], $session_id);
                     $to_graph_exercise_result[$exercices['id']] = array('title' => $exercices['title'], 'data' => $best_exercise_stats);
                     $latest_attempt_url = '';
                     $best_score = $position = $percentage_score_result = '-';
                     $graph = $normal_graph = null;
                     // Getting best results
                     $best_score_data = ExerciseLib::get_best_attempt_in_course($exercices['id'], $course_info['real_id'], $session_id);
                     $best_score = '';
                     if (!empty($best_score_data)) {
                         $best_score = ExerciseLib::show_score($best_score_data['exe_result'], $best_score_data['exe_weighting']);
                     }
                     if ($attempts > 0) {
                         $exercise_stat = ExerciseLib::get_best_attempt_by_user(api_get_user_id(), $exercices['id'], $course_info['real_id'], $session_id);
                         if (!empty($exercise_stat)) {
                             //Always getting the BEST attempt
                             $score = $exercise_stat['exe_result'];
                             $weighting = $exercise_stat['exe_weighting'];
                             $exe_id = $exercise_stat['exe_id'];
                             $latest_attempt_url .= api_get_path(WEB_CODE_PATH) . 'exercice/result.php?id=' . $exe_id . '&cidReq=' . $course_info['code'] . '&show_headers=1&id_session=' . $session_id;
                             $percentage_score_result = Display::url(ExerciseLib::show_score($score, $weighting), $latest_attempt_url);
                             $my_score = 0;
                             if (!empty($weighting) && intval($weighting) != 0) {
                                 $my_score = $score / $weighting;
                             }
                             //@todo this function slows the page
                             $position = ExerciseLib::get_exercise_result_ranking($my_score, $exe_id, $exercices['id'], $course_info['code'], $session_id, $user_list);
                             $graph = self::generate_exercise_result_thumbnail_graph($to_graph_exercise_result[$exercices['id']]);
                             $normal_graph = self::generate_exercise_result_graph($to_graph_exercise_result[$exercices['id']]);
                         }
                     }
                     $html .= Display::div($normal_graph, array('id' => 'main_graph_' . $exercices['id'], 'class' => 'dialog', 'style' => 'display:none'));
                     if (empty($graph)) {
                         $graph = '-';
                     } else {
                         $graph = Display::url('<img src="' . $graph . '" >', $normal_graph, array('id' => $exercices['id'], 'class' => 'expand-image'));
                     }
                     $html .= Display::tag('td', $attempts, array('align' => 'center'));
                     $html .= Display::tag('td', $percentage_score_result, array('align' => 'center'));
                     $html .= Display::tag('td', $position, array('align' => 'center'));
                     $html .= Display::tag('td', $best_score, array('align' => 'center'));
                     $html .= Display::tag('td', $graph, array('align' => 'center'));
                     //$html .= Display::tag('td', $latest_attempt_url,       array('align'=>'center', 'width'=>'25'));
                 } else {
                     // Exercise configuration NO results
                     $html .= Display::tag('td', $attempts, array('align' => 'center'));
                     $html .= Display::tag('td', '-', array('align' => 'center'));
                     $html .= Display::tag('td', '-', array('align' => 'center'));
                     $html .= Display::tag('td', '-', array('align' => 'center'));
                     $html .= Display::tag('td', '-', array('align' => 'center'));
                 }
                 $html .= '</tr>';
             }
         } else {
             $html .= '<tr><td colspan="5" align="center">' . get_lang('NoEx') . '</td></tr>';
         }
         $html .= '</table>';
         // LP table results
         $html .= '<table class="data_table">';
         $html .= Display::tag('th', get_lang('Learnpaths'), array('class' => 'head', 'style' => 'color:#000'));
         $html .= Display::tag('th', get_lang('LatencyTimeSpent'), array('class' => 'head', 'style' => 'color:#000'));
         $html .= Display::tag('th', get_lang('Progress'), array('class' => 'head', 'style' => 'color:#000'));
         $html .= Display::tag('th', get_lang('Score'), array('class' => 'head', 'style' => 'color:#000'));
         $html .= Display::tag('th', get_lang('LastConnexion'), array('class' => 'head', 'style' => 'color:#000'));
         $html .= '</tr>';
         $list = new LearnpathList(api_get_user_id(), $course_info['code'], $session_id, 'publicated_on ASC', true);
         $lp_list = $list->get_flat_list();
         if (!empty($lp_list) > 0) {
             foreach ($lp_list as $lp_id => $learnpath) {
                 $progress = Tracking::get_avg_student_progress($user_id, $course, array($lp_id), $session_id);
                 $last_connection_in_lp = Tracking::get_last_connection_time_in_lp($user_id, $course, $lp_id, $session_id);
                 $time_spent_in_lp = Tracking::get_time_spent_in_lp($user_id, $course, array($lp_id), $session_id);
                 $percentage_score = Tracking::get_avg_student_score($user_id, $course, array($lp_id), $session_id);
                 if (is_numeric($percentage_score)) {
                     $percentage_score = $percentage_score . '%';
                 } else {
                     $percentage_score = '0%';
                 }
                 $time_spent_in_lp = api_time_to_hms($time_spent_in_lp);
                 $html .= '<tr class="row_even">';
                 $url = api_get_path(WEB_CODE_PATH) . "newscorm/lp_controller.php?cidReq={$course_code}&id_session={$session_id}&lp_id={$lp_id}&action=view";
                 if ($learnpath['lp_visibility'] == 0) {
                     $html .= Display::tag('td', $learnpath['lp_name']);
                 } else {
                     $html .= Display::tag('td', Display::url($learnpath['lp_name'], $url, array('target' => SESSION_LINK_TARGET)));
                 }
                 $html .= Display::tag('td', $time_spent_in_lp, array('align' => 'center'));
                 if (is_numeric($progress)) {
                     $progress = $progress . '%';
                 }
                 $html .= Display::tag('td', $progress, array('align' => 'center'));
                 $html .= Display::tag('td', $percentage_score);
                 $last_connection = '-';
                 if (!empty($last_connection_in_lp)) {
                     $last_connection = api_convert_and_format_date($last_connection_in_lp, DATE_TIME_FORMAT_LONG);
                 }
                 $html .= Display::tag('td', $last_connection, array('align' => 'center', 'width' => '180px'));
                 $html .= "</tr>";
             }
         } else {
             $html .= '<tr>
                     <td colspan="4" align="center">
                         ' . get_lang('NoLearnpath') . '
                     </td>
                   </tr>';
         }
         $html .= '</table>';
     }
     return $html;
 }
Exemplo n.º 20
0
        $result['description'] = Security::remove_XSS($result['description'], STUDENT, true);
        $id = $result['id'];
        $url_open = '<a href="group_view.php?id=' . $id . '">';
        $url_close = '</a>';
        $count_users_group = count($usergroup->get_users_by_group($id, false, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER, GROUP_USER_PERMISSION_MODERATOR), 0, 1000));
        if ($count_users_group == 1) {
            $count_users_group = $count_users_group . ' ' . get_lang('Member');
        } else {
            $count_users_group = $count_users_group . ' ' . get_lang('Members');
        }
        $name = cut($result['name'], GROUP_TITLE_LENGTH, true);
        $picture = $usergroup->get_picture_group($result['id'], $result['picture'], 80);
        $result['picture'] = '<img class="social-groups-image" src="' . $picture['file'] . '" />';
        $item_0 = Display::div($result['picture'], array('class' => 'box_description_group_image'));
        $members = Display::span($count_users_group, array('class' => 'box_description_group_member'));
        $item_1 = Display::div(Display::tag('h4', $url_open . $name . $url_close) . $members, array('class' => 'box_description_group_title'));
        if ($result['description'] != '') {
            $item_3 = '<div class="box_description_group_content" >' . cut($result['description'], 100, true) . '</div>';
        } else {
            $item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2"></span></div>';
            $item_3 = '<div class="box_description_group_content" ></div>';
        }
        $join_url = '';
        if (!in_array($id, $my_group_list)) {
            $join_url = '<a class="btn" href="group_view.php?id=' . $id . '&action=join&u=' . api_get_user_id() . '">' . get_lang('JoinGroup') . '</a> ';
        }
        $item_4 = '<div class="box_description_group_actions" >' . $join_url . '</div>';
        $grid_item_2 = $item_0 . $item_1 . $item_2 . $item_3 . $item_4;
        $grid_pop_groups[] = array($grid_item_2);
    }
}
Exemplo n.º 21
0
     $session_displayed = '';
 }
 $forum['forum_of_group'] == 0 ? $groupid = '' : ($groupid = $forum['forum_of_group']);
 $number_threads = isset($forum['number_of_threads']) ? $forum['number_of_threads'] : 0;
 $number_posts = isset($forum['number_of_posts']) ? $forum['number_of_posts'] : 0;
 $html .= '<div class="row">';
 $html .= '<div class="col-md-6">';
 $html .= '<div class="col-md-3">';
 $html .= '<div class="number-post">' . $forum_image . '<p>' . $number_posts . ' ' . get_lang('Posts') . '</p>' . '</div>';
 $html .= '</div>';
 $html .= '<div class="col-md-9">';
 $iconForum = Display::return_icon('forum_yellow.png', get_lang($forumCategory['cat_title']), null, ICON_SIZE_MEDIUM);
 $linkForum = '';
 $linkForum .= Display::tag('a', $forum['forum_title'], array('href' => 'viewforum.php?' . api_get_cidreq() . '&gidReq=' . intval($groupid) . '&forum=' . intval($forum['forum_id']), 'class' => return_visible_invisible(strval(intval($forum['visibility'])))));
 $html .= '<h3 class="title">' . $iconForum . $linkForum . '</h3>';
 $html .= Display::tag('p', strip_tags($forum['forum_comment']), array('class' => 'description'));
 $html .= '</div>';
 $html .= '</div>';
 $iconEmpty = '';
 // The number of topics and posts.
 if ($forum['forum_of_group'] !== '0') {
     $newPost = '';
     if (is_array($mywhatsnew_post_info) && !empty($mywhatsnew_post_info)) {
         $newPost = ' ' . Display::return_icon('alert.png', get_lang('Forum'), null, ICON_SIZE_SMALL);
     } else {
         $newPost = $iconEmpty;
     }
 } else {
     if (is_array($mywhatsnew_post_info) && !empty($mywhatsnew_post_info)) {
         $newPost = ' ' . Display::return_icon('alert.png', get_lang('Forum'), null, ICON_SIZE_SMALL);
     } else {
Exemplo n.º 22
0
 /**
  * @param float $score
  * @param float $weight
  * @param string $pass_percentage
  * @return string
  */
 public static function show_success_message($score, $weight, $pass_percentage)
 {
     $res = "";
     if (self::is_pass_pourcentage_enabled($pass_percentage)) {
         $is_success = self::is_success_exercise_result($score, $weight, $pass_percentage);
         if ($is_success) {
             $html = get_lang('CongratulationsYouPassedTheTest');
             $icon = Display::return_icon('completed.png', get_lang('Correct'), array(), ICON_SIZE_MEDIUM);
         } else {
             //$html .= Display::return_message(get_lang('YouDidNotReachTheMinimumScore'), 'warning');
             $html = get_lang('YouDidNotReachTheMinimumScore');
             $icon = Display::return_icon('warning.png', get_lang('Wrong'), array(), ICON_SIZE_MEDIUM);
         }
         $html = Display::tag('h4', $html);
         $html .= Display::tag('h5', $icon, array('style' => 'width:40px; padding:2px 10px 0px 0px'));
         $res = $html;
     }
     return $res;
 }
Exemplo n.º 23
0
 }
 if ($row['thread_sticky'] == 1) {
     echo Display::return_icon('exclamation.gif');
 }
 echo '</td>';
 echo '<td>';
 echo '<a href="viewthread.php?' . api_get_cidreq() . '&amp;forum=' . Security::remove_XSS($my_forum) . '&amp;origin=' . $origin . '&amp;thread=' . $row['thread_id'] . $origin_string . '&amp;search=' . Security::remove_XSS(urlencode($my_search)) . '" ' . class_visible_invisible($row['visibility']) . '>' . prepare4display($row['thread_title']) . '</a></td>';
 echo '<td>' . $row['thread_replies'] . '</td>';
 echo '<td>' . $row['thread_views'] . '</td>';
 // display the author name
 $tab_poster_info = api_get_user_info($row['user_id']);
 $poster_username = sprintf(get_lang('LoginX'), $tab_poster_info['username']);
 if ($origin != 'learnpath') {
     echo '<td>' . display_user_link($row['user_id'], api_get_person_name($row['firstname'], $row['lastname']), '', $poster_username) . '</td>';
 } else {
     echo '<td>' . Display::tag('span', api_get_person_name($row['firstname'], $row['lastname']), array("title" => api_htmlentities($poster_username, ENT_QUOTES))) . '</td>';
 }
 $last_post_info = get_last_post_by_thread($row['c_id'], $row['thread_id'], $row['forum_id'], is_allowed_to_edit());
 $last_post = null;
 if ($last_post_info) {
     $poster_info = api_get_user_info($last_post_info['poster_id']);
     $post_date = api_convert_and_format_date($last_post_info['post_date']);
     $last_post = $post_date . ' ' . get_lang('By') . ' ' . display_user_link($last_post_info['poster_id'], $poster_info['complete_name'], '', $poster_info['username']);
 }
 /*
             if ($row['last_poster_user_id'] == '0') {
                 $name = $row['poster_name'];
                 $last_poster_username = "";
             } else {
                 $name = api_get_person_name($row['last_poster_firstname'], $row['last_poster_lastname']);
                 $tab_last_poster_info = api_get_user_info($row['last_poster_user_id']);
Exemplo n.º 24
0
 /**
  * Show the monthcalender of the given month
  * @param	array	Agendaitems
  * @param	int	Month number
  * @param	int	Year number
  * @param	array	Array of strings containing long week day names (deprecated, you can send an empty array instead)
  * @param	string	The month name
  * @return	void	Direct output
  */
 public static function display_mymonthcalendar($user_id, $agendaitems, $month, $year, $weekdaynames = array(), $monthName, $show_content = true)
 {
     global $DaysShort, $course_path;
     //Handle leap year
     $numberofdays = array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
     if ($year % 400 == 0 or $year % 4 == 0 and $year % 100 != 0) {
         $numberofdays[2] = 29;
     }
     //Get the first day of the month
     $dayone = getdate(mktime(0, 0, 0, $month, 1, $year));
     //Start the week on monday
     $startdayofweek = $dayone['wday'] != 0 ? $dayone['wday'] - 1 : 6;
     $g_cc = isset($_GET['courseCode']) ? $_GET['courseCode'] : '';
     $prev_icon = Display::return_icon('action_prev.png', get_lang('Previous'));
     $next_icon = Display::return_icon('action_next.png', get_lang('Next'));
     $next_month = $month == 1 ? 12 : $month - 1;
     $prev_month = $month == 12 ? 1 : $month + 1;
     $next_year = $month == 1 ? $year - 1 : $year;
     $prev_year = $month == 12 ? $year + 1 : $year;
     if ($show_content) {
         $back_url = Display::url($prev_icon, api_get_self() . "?coursePath=" . urlencode($course_path) . "&courseCode=" . Security::remove_XSS($g_cc) . "&action=view&view=month&month=" . $next_month . "&year=" . $next_year);
         $next_url = Display::url($next_icon, api_get_self() . "?coursePath=" . urlencode($course_path) . "&courseCode=" . Security::remove_XSS($g_cc) . "&action=view&view=month&month=" . $prev_month . "&year=" . $prev_year);
     } else {
         $back_url = Display::url($prev_icon, '', array('onclick' => "load_calendar('" . $user_id . "','" . $next_month . "', '" . $next_year . "'); "));
         $next_url = Display::url($next_icon, '', array('onclick' => "load_calendar('" . $user_id . "','" . $prev_month . "', '" . $prev_year . "'); "));
     }
     echo '<table id="agenda_list"><tr>';
     echo '<th width="10%">' . $back_url . '</th>';
     echo '<th width="80%" colspan="5"><br /><h3>' . $monthName . " " . $year . '</h3></th>';
     echo '<th width="10%">' . $next_url . '</th>';
     echo '</tr>';
     echo '<tr>';
     for ($ii = 1; $ii < 8; $ii++) {
         echo '<td class="weekdays">' . $DaysShort[$ii % 7] . '</td>';
     }
     echo '</tr>';
     $curday = -1;
     $today = getdate();
     while ($curday <= $numberofdays[$month]) {
         echo "<tr>";
         for ($ii = 0; $ii < 7; $ii++) {
             if ($curday == -1 && $ii == $startdayofweek) {
                 $curday = 1;
             }
             if ($curday > 0 && $curday <= $numberofdays[$month]) {
                 $bgcolor = $class = 'class="days_week"';
                 $dayheader = Display::div($curday, array('class' => 'agenda_day'));
                 if ($curday == $today['mday'] && $year == $today['year'] && $month == $today['mon']) {
                     $class = "class=\"days_today\" style=\"width:10%;\"";
                 }
                 echo "<td " . $class . ">" . $dayheader;
                 if (!empty($agendaitems[$curday])) {
                     $items = $agendaitems[$curday];
                     $items = msort($items, 'start_date_tms');
                     foreach ($items as $value) {
                         $value['title'] = Security::remove_XSS($value['title']);
                         $start_time = api_format_date($value['start_date'], TIME_NO_SEC_FORMAT);
                         $end_time = '';
                         if (!empty($value['end_date']) && $value['end_date'] != '0000-00-00 00:00:00') {
                             $end_time = '-&nbsp;<i>' . api_format_date($value['end_date'], DATE_TIME_FORMAT_LONG) . '</i>';
                         }
                         $complete_time = '<i>' . api_format_date($value['start_date'], DATE_TIME_FORMAT_LONG) . '</i>&nbsp;' . $end_time;
                         $time = '<i>' . $start_time . '</i>';
                         switch ($value['calendar_type']) {
                             case 'personal':
                                 $bg_color = '#D0E7F4';
                                 $icon = Display::return_icon('user.png', get_lang('MyAgenda'), array(), ICON_SIZE_SMALL);
                                 break;
                             case 'global':
                                 $bg_color = '#FFBC89';
                                 $icon = Display::return_icon('view_remove.png', get_lang('GlobalEvent'), array(), ICON_SIZE_SMALL);
                                 break;
                             case 'course':
                                 $bg_color = '#CAFFAA';
                                 $icon_name = 'course.png';
                                 if (!empty($value['session_id'])) {
                                     $icon_name = 'session.png';
                                 }
                                 if ($show_content) {
                                     $icon = Display::url(Display::return_icon($icon_name, $value['course_name'] . ' ' . get_lang('Course'), array(), ICON_SIZE_SMALL), $value['url']);
                                 } else {
                                     $icon = Display::return_icon($icon_name, $value['course_name'] . ' ' . get_lang('Course'), array(), ICON_SIZE_SMALL);
                                 }
                                 break;
                             default:
                                 break;
                         }
                         $result = '<div class="rounded_div_agenda" style="background-color:' . $bg_color . ';">';
                         if ($show_content) {
                             //Setting a personal event to green
                             $icon = Display::div($icon, array('style' => 'float:right'));
                             $link = $value['calendar_type'] . '_' . $value['id'] . '_' . $value['course_id'] . '_' . $value['session_id'];
                             //Link to bubble
                             $url = Display::url(cut($value['title'], 40), '#', array('id' => $link, 'class' => 'opener'));
                             $result .= $time . ' ' . $icon . ' ' . Display::div($url);
                             //Hidden content
                             $content = Display::div($icon . Display::tag('h2', $value['course_name']) . '<hr />' . Display::tag('h3', $value['title']) . $complete_time . '<hr />' . Security::remove_XSS($value['content']));
                             //Main div
                             $result .= Display::div($content, array('id' => 'main_' . $link, 'class' => 'dialog', 'style' => 'display:none'));
                             $result .= '</div>';
                             echo $result;
                             //echo Display::div($content, array('id'=>'main_'.$value['calendar_type'].'_'.$value['id'], 'class' => 'dialog'));
                         } else {
                             echo $result .= $icon . '</div>';
                         }
                     }
                 }
                 echo "</td>";
                 $curday++;
             } else {
                 echo "<td></td>";
             }
         }
         echo "</tr>";
     }
     echo "</table>";
 }
Exemplo n.º 25
0
             $actions_first_col .= ' ' . Display::return_icon('up_na.png', '&nbsp;', '', ICON_SIZE_SMALL);
         }
         if (isset($thematic['max_thematic_item']) && $thematic['display_order'] < $thematic['max_thematic_item']) {
             $actions_first_col .= ' <a href="' . api_get_self() . '?action=movedown&a' . api_get_cidreq() . '&thematic_id=' . $my_thematic_id . $urlParam . $url_token . '">' . Display::return_icon('down.png', get_lang('Down'), '', ICON_SIZE_SMALL) . '</a>';
         } else {
             $actions_first_col .= ' ' . Display::return_icon('down_na.png', '&nbsp;', '', ICON_SIZE_SMALL);
         }
     }
     if (api_get_session_id() == $thematic['session_id']) {
         $actions_first_col .= '<a href="index.php?' . api_get_cidreq() . '&action=thematic_edit&thematic_id=' . $my_thematic_id . $urlParam . $url_token . '">' . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . '</a>';
         $actions_first_col .= '<a onclick="javascript:if(!confirm(\'' . get_lang('AreYouSureToDelete') . '\')) return false;" href="index.php?' . api_get_cidreq() . '&action=thematic_delete&thematic_id=' . $my_thematic_id . $urlParam . $url_token . '">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>';
     }
     $actions_first_col = Display::div($actions_first_col, array('id' => 'thematic_id_content_' . $thematic['id'], 'class' => 'thematic_tools'));
     $actions_first_col = Display::div($actions_first_col, array('style' => 'height:20px'));
 }
 echo Display::tag('td', Display::tag('h3', Security::remove_XSS($thematic['title'], STUDENT) . $session_star) . Security::remove_XSS($thematic['content'], STUDENT) . $actions_first_col, array('id' => 'thematic_td_content_' . $thematic['id'], 'class' => 'thematic_content'));
 // Display 2nd column - thematic plan data
 echo '<td>';
 //if (api_is_allowed_to_edit(null, true) &&  api_get_session_id() == $thematic['session_id']) {
 if (api_is_allowed_to_edit(null, true)) {
     echo '<div style="text-align:right"><a href="index.php?' . api_get_cidreq() . '&origin=thematic_details&action=thematic_plan_list&thematic_id=' . $thematic['id'] . '&width=700&height=500">' . Display::return_icon('edit.png', get_lang('EditThematicPlan'), array('style' => 'vertical-align:middle'), ICON_SIZE_MEDIUM) . '</a></div><br />';
 }
 if (empty($thematic_plan_div[$thematic['id']])) {
     echo Display::div('', array('id' => "thematic_plan_" . $thematic['id']));
 } else {
     echo $thematic_plan_div[$thematic['id']];
 }
 echo '</td>';
 // Display 3rd column - thematic advance data
 echo '<td style="vertical-align:top">';
 //if (api_is_allowed_to_edit(null, true) &&  api_get_session_id() == $thematic['session_id']) {
Exemplo n.º 26
0
/**
 * Display the already registerd text in a course in the course catalog
 * @param $in_status
 */
function return_already_registered_label($in_status)
{
    $icon = Display::return_icon('teacher.png', get_lang('Teacher'), null, ICON_SIZE_TINY);
    if ($in_status == 'student') {
        $icon = Display::return_icon('user.png', get_lang('Student'), null, ICON_SIZE_TINY);
    }
    $html = Display::tag('button', $icon, array('id' => 'register', 'class' => 'btn btn-default btn-sm', 'title' => get_lang("AlreadyRegisteredToCourse")));
    return $html;
}
Exemplo n.º 27
0
 /**
  * Function used by SortableTable to generate the data to display
  * @param int $from
  * @param int $per_page
  * @param int $column
  * @param string $direction
  * @param int $sort
  * @return array|mixed
  */
 public function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null)
 {
     //variables load in index.php
     global $my_score_in_gradebook, $certificate_min_score;
     $scoretotal = 0;
     // determine sorting type
     $col_adjust = api_is_allowed_to_edit() ? 1 : 0;
     // By id
     $this->column = 5;
     switch ($this->column) {
         // Type
         case 0 + $col_adjust:
             $sorting = GradebookDataGenerator::GDG_SORT_TYPE;
             break;
         case 1 + $col_adjust:
             $sorting = GradebookDataGenerator::GDG_SORT_NAME;
             break;
         case 2 + $col_adjust:
             $sorting = GradebookDataGenerator::GDG_SORT_DESCRIPTION;
             break;
         case 3 + $col_adjust:
             $sorting = GradebookDataGenerator::GDG_SORT_WEIGHT;
             break;
         case 4 + $col_adjust:
             $sorting = GradebookDataGenerator::GDG_SORT_DATE;
         case 5 + $col_adjust:
             $sorting = GradebookDataGenerator::GDG_SORT_ID;
             break;
     }
     if ($this->direction == 'DESC') {
         $sorting |= GradebookDataGenerator::GDG_SORT_DESC;
     } else {
         $sorting |= GradebookDataGenerator::GDG_SORT_ASC;
     }
     //status of user in course
     $user_id = api_get_user_id();
     $course_code = api_get_course_id();
     $courseId = api_get_course_int_id();
     $session_id = api_get_session_id();
     $status_user = api_get_status_of_user_in_course($user_id, $courseId);
     $data_array = $this->datagen->get_data($sorting, $from, $this->per_page);
     // generate the data to display
     $sortable_data = array();
     $weight_total_links = 0;
     $main_categories = array();
     $main_cat = Category::load(null, null, $course_code, null, null, $session_id, false);
     $total_categories_weight = 0;
     $scoredisplay = ScoreDisplay::instance();
     //Categories
     foreach ($data_array as $data) {
         // list of items inside the gradebook (exercises, lps, forums, etc)
         $row = array();
         $item = $item_category = $data[0];
         $id = $item->get_id();
         //if the item is invisible, wrap it in a span with class invisible
         $invisibility_span_open = api_is_allowed_to_edit() && $item->is_visible() == '0' ? '<span class="invisible">' : '';
         $invisibility_span_close = api_is_allowed_to_edit() && $item->is_visible() == '0' ? '</span>' : '';
         if (api_is_allowed_to_edit(null, true)) {
             //id
             $row[] = $this->build_id_column($item);
         }
         //Type
         $row[] = $this->build_type_column($item);
         //Name
         if (get_class($item) == 'Category') {
             $row[] = $invisibility_span_open . '<h3>' . $item->get_name() . '</h3>' . $invisibility_span_close;
             $main_categories[$item->get_id()]['name'] = $item->get_name();
         } else {
             $row[] = $invisibility_span_open . $this->build_name_link($item) . $invisibility_span_close;
             $main_categories[$item->get_id()]['name'] = $this->build_name_link($item);
         }
         $main_categories[$item->get_id()]['weight'] = $item->get_weight();
         $total_categories_weight += $item->get_weight();
         //Description
         $row[] = $invisibility_span_open . $data[2] . $invisibility_span_close;
         //Weight
         //$row[] = $invisibility_span_open .Display::tag('h4', $data['3'] .' / '.$this->currentcat->get_weight()).$invisibility_span_close;
         //$average = $data['3']/$this->currentcat->get_weight()*100;
         $average = $scoredisplay->display_score(array($data['3'], $this->currentcat->get_weight()), SCORE_SIMPLE, SCORE_BOTH, true);
         if (api_is_allowed_to_edit(null, true)) {
             $row[] = $invisibility_span_open . Display::tag('h4', $average) . $invisibility_span_close;
         } else {
             $row[] = $invisibility_span_open . $average . $invisibility_span_close;
         }
         $category_weight = $item->get_weight();
         if (api_is_allowed_to_edit(null, true)) {
             $weight_total_links += $data[3];
         } else {
             $cattotal = Category::load($_GET['selectcat']);
             $scoretotal = $cattotal[0]->calc_score(api_get_user_id());
             $item_value = $scoredisplay->display_score($scoretotal, SCORE_SIMPLE);
         }
         //Date
         //$row[] = $invisibility_span_open.$data[4].$invisibility_span_close;
         //Edit (for admins)
         if (api_is_allowed_to_edit(null, true)) {
             $cat = new Category();
             $show_message = $cat->show_message_resource_delete($item->get_course_code());
             if ($show_message === false) {
                 $row[] = $this->build_edit_column($item);
             }
         } else {
             //students get the results and certificates columns
             if (count($this->evals_links) > 0 && $status_user != 1) {
                 $value_data = isset($data[4]) ? $data[4] : null;
                 if (!is_null($value_data)) {
                     $row[] = Display::tag('h4', $value_data);
                 } else {
                     $row[] = $this->build_edit_column($item);
                 }
             } else {
                 $score = $item->calc_score(api_get_user_id());
                 if (!empty($score[1])) {
                     $complete_score = $scoredisplay->display_score($score, SCORE_DIV_PERCENT);
                     $score = $score[0] / $score[1] * $item->get_weight();
                     $score = $scoredisplay->display_score(array($score, null), SCORE_SIMPLE);
                     $row[] = Display::tip($score, $complete_score);
                 } else {
                     $row[] = '-';
                 }
                 if (!empty($this->cats)) {
                     $row[] = $this->build_edit_column($item);
                 }
             }
         }
         //Category added
         $sortable_data[] = $row;
         // Loading childrens
         if (get_class($item) == 'Category') {
             $stud_id = api_get_user_id();
             $course_code = api_get_course_id();
             $session_id = api_get_session_id();
             $parent_id = $item->get_id();
             $cats = Category::load($parent_id, null, null, null, null, null);
             if (isset($cats[0])) {
                 $allcat = $cats[0]->get_subcategories($stud_id, $course_code, $session_id);
                 $alleval = $cats[0]->get_evaluations($stud_id);
                 $alllink = $cats[0]->get_links($stud_id);
                 $sub_cat_info = new GradebookDataGenerator($allcat, $alleval, $alllink);
                 $data_array = $sub_cat_info->get_data($sorting, $from, $this->per_page);
                 $total_weight = 0;
                 //Links
                 foreach ($data_array as $data) {
                     $row = array();
                     $item = $data[0];
                     //if the item is invisible, wrap it in a span with class invisible
                     $invisibility_span_open = api_is_allowed_to_edit() && $item->is_visible() == '0' ? '<span class="invisible">' : '';
                     $invisibility_span_close = api_is_allowed_to_edit() && $item->is_visible() == '0' ? '</span>' : '';
                     $main_categories[$parent_id]['children'][$item->get_id()]['name'] = $item->get_name();
                     $main_categories[$parent_id]['children'][$item->get_id()]['weight'] = $item->get_weight();
                     if (api_is_allowed_to_edit(null, true)) {
                         $row[] = $this->build_id_column($item);
                     }
                     $row[] = $this->build_type_column($item, array('style' => 'padding-left:5px'));
                     //Name
                     $row[] = $invisibility_span_open . "&nbsp;&nbsp;&nbsp;  " . $this->build_name_link($item) . $invisibility_span_close;
                     //Description
                     $row[] = $invisibility_span_open . $data[2] . $invisibility_span_close;
                     //Weight
                     //$weight = $data[3]/$category_weight*$main_cat[0]->get_weight();
                     $weight = $data[3];
                     //$extra = " - $data[3]  $category_weight -".$main_cat[0]->get_weight();
                     $total_weight += $weight;
                     $row[] = $invisibility_span_open . $weight . $invisibility_span_close;
                     if (api_is_allowed_to_edit(null, true)) {
                         //$weight_total_links += intval($data[3]);
                     } else {
                         $cattotal = Category::load($_GET['selectcat']);
                         $scoretotal = $cattotal[0]->calc_score(api_get_user_id());
                         $item_value = $scoretotal[0];
                     }
                     //Date
                     //$row[] = $invisibility_span_open.$data[4].$invisibility_span_close;
                     //Admins get an edit column
                     if (api_is_allowed_to_edit(null, true)) {
                         $cat = new Category();
                         $show_message = $cat->show_message_resource_delete($item->get_course_code());
                         if ($show_message === false) {
                             $row[] = $this->build_edit_column($item);
                         }
                     } else {
                         //students get the results and certificates columns
                         $eval_n_links = array_merge($alleval, $alllink);
                         if (count($eval_n_links) > 0 && $status_user != 1) {
                             $value_data = isset($data[4]) ? $data[4] : null;
                             if (!is_null($value_data)) {
                                 $score = $item->calc_score(api_get_user_id());
                                 $new_score = $data[3] * $score[0] / $score[1];
                                 $new_score = floatval(number_format($new_score, api_get_setting('gradebook_number_decimals')));
                                 $row[] = Display::tip($new_score, $data[4]);
                             }
                         }
                         if (!empty($cats)) {
                             $row[] = null;
                         }
                     }
                     $row['child_of'] = $parent_id;
                     $sortable_data[] = $row;
                 }
                 //"Warning row"
                 if (!empty($data_array)) {
                     if (api_is_allowed_to_edit()) {
                         // Compare the category weight to the sum of all weights inside the category
                         if (intval($total_weight) == $category_weight) {
                             $label = null;
                             $total = score_badges(array($total_weight . ' / ' . $category_weight, '100'));
                         } else {
                             $label = Display::return_icon('warning.png', sprintf(get_lang('TotalWeightMustBeX'), $category_weight));
                             $total = Display::badge($total_weight . ' / ' . $category_weight, 'warning');
                         }
                         $row = array(null, null, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<h5>" . get_lang('SubTotal') . '</h5>', null, $total . ' ' . $label, 'child_of' => $parent_id);
                         $sortable_data[] = $row;
                     }
                 }
             }
         }
         //end looping categories
     }
     //end looping categories
     if (api_is_allowed_to_edit()) {
         if (count($main_cat) > 1) {
             $main_weight = intval($main_cat[0]->get_weight());
             if (intval($total_categories_weight) == $main_weight) {
                 $total = score_badges(array($total_categories_weight . ' / ' . $main_weight, '100'));
             } else {
                 $total = Display::badge($total_categories_weight . ' / ' . $main_weight, 'warning');
             }
             $row = array(null, null, '<h3>' . get_lang('Total') . '</h3>', null, $total);
             $sortable_data[] = $row;
         }
     }
     // warning messages
     $view = isset($_GET['view']) ? $_GET['view'] : null;
     if (api_is_allowed_to_edit()) {
         if (isset($_GET['selectcat']) && $_GET['selectcat'] > 0 && $view != 'presence') {
             $id_cat = intval($_GET['selectcat']);
             $category = Category::load($id_cat);
             //$weight_category = intval($this->build_weight($category[0]));
             $weight_category = intval($this->build_weight($category[0]));
             $course_code = $this->build_course_code($category[0]);
             $weight_total_links = round($weight_total_links);
             if ($weight_total_links > $weight_category || $weight_total_links < $weight_category || $weight_total_links > $weight_category) {
                 $warning_message = sprintf(get_lang('TotalWeightMustBeX'), $weight_category);
                 $modify_icons = '<a class="right_link" href="gradebook_edit_cat.php?editcat=' . $id_cat . '&cidReq=' . $course_code . '">' . Display::return_icon('edit.png', $warning_message, array(), ICON_SIZE_SMALL) . '</a>';
                 $warning_message .= $modify_icons;
                 Display::display_warning_message($warning_message, false);
             }
             $content_html = DocumentManager::replace_user_info_into_html(api_get_user_id(), $course_code);
             if (!empty($content_html)) {
                 $new_content = explode('</head>', $content_html['content']);
             }
             if (empty($new_content[0])) {
                 $warning_message = get_lang('ThereIsNotACertificateAvailableByDefault');
                 $cert_icon = '<a class="right_link" href="../document/document.php?curdirpath=/certificates&' . $course_code . '&origin=gradebook&selectcat=' . $id_cat . '">' . Display::return_icon('certificate.png', get_lang('AttachCertificate'), array(), ICON_SIZE_SMALL) . '</a>';
                 Display::display_warning_message($warning_message . $cert_icon, false);
             }
         }
         if (empty($_GET['selectcat'])) {
             $categories = Category::load();
             $weight_categories = $certificate_min_scores = $course_codes = array();
             foreach ($categories as $category) {
                 $course_code_category = $this->build_course_code($category);
                 if (!empty($course_code)) {
                     if ($course_code_category == $course_code) {
                         $weight_categories[] = intval($this->build_weight($category));
                         $certificate_min_scores[] = intval($this->build_certificate_min_score($category));
                         $course_codes[] = $course_code;
                         break;
                     }
                 } else {
                     $weight_categories[] = intval($this->build_weight($category));
                     $certificate_min_scores[] = intval($this->build_certificate_min_score($category));
                     $course_codes[] = $course_code_category;
                 }
             }
             if (is_array($weight_categories) && is_array($certificate_min_scores) && is_array($course_codes)) {
                 $warning_message = '';
                 for ($x = 0; $x < count($weight_categories); $x++) {
                     $weight_category = intval($weight_categories[$x]);
                     $certificate_min_score = intval($certificate_min_scores[$x]);
                     $course_code = $course_codes[$x];
                     if (empty($certificate_min_score) || $certificate_min_score > $weight_category) {
                         $warning_message .= $course_code . '&nbsp;-&nbsp;' . get_lang('CertificateMinimunScoreIsRequiredAndMustNotBeMoreThan') . '&nbsp;' . $weight_category . '<br />';
                     }
                 }
                 if (!empty($warning_message)) {
                     Display::display_warning_message($warning_message, false);
                 }
             }
         }
     }
     return $sortable_data;
 }
Exemplo n.º 28
0
 /**
  * This function was originally found in the exercise_show.php
  * @param int       $exeId
  * @param int       $questionId
  * @param int       $choice the user selected
  * @param string    $from  function is called from 'exercise_show' or 'exercise_result'
  * @param array     $exerciseResultCoordinates the hotspot coordinates $hotspot[$question_id] = coordinates
  * @param bool      $saved_results save results in the DB or just show the reponse
  * @param bool      $from_database gets information from DB or from the current selection
  * @param bool      $show_result show results or not
  * @param int       $propagate_neg
  * @param array     $hotspot_delineation_result
  *
  * @todo    reduce parameters of this function
  * @return  string  html code
  */
 public function manage_answer($exeId, $questionId, $choice, $from = 'exercise_show', $exerciseResultCoordinates = array(), $saved_results = true, $from_database = false, $show_result = true, $propagate_neg = 0, $hotspot_delineation_result = array())
 {
     global $debug;
     //needed in order to use in the exercise_attempt() for the time
     global $learnpath_id, $learnpath_item_id;
     require_once api_get_path(LIBRARY_PATH) . 'geometry.lib.php';
     $feedback_type = $this->selectFeedbackType();
     $results_disabled = $this->selectResultsDisabled();
     if ($debug) {
         error_log("<------ manage_answer ------> ");
         error_log('exe_id: ' . $exeId);
         error_log('$from:  ' . $from);
         error_log('$saved_results: ' . intval($saved_results));
         error_log('$from_database: ' . intval($from_database));
         error_log('$show_result: ' . $show_result);
         error_log('$propagate_neg: ' . $propagate_neg);
         error_log('$exerciseResultCoordinates: ' . print_r($exerciseResultCoordinates, 1));
         error_log('$hotspot_delineation_result: ' . print_r($hotspot_delineation_result, 1));
         error_log('$learnpath_id: ' . $learnpath_id);
         error_log('$learnpath_item_id: ' . $learnpath_item_id);
         error_log('$choice: ' . print_r($choice, 1));
     }
     $extra_data = array();
     $final_overlap = 0;
     $final_missing = 0;
     $final_excess = 0;
     $overlap_color = 0;
     $missing_color = 0;
     $excess_color = 0;
     $threadhold1 = 0;
     $threadhold2 = 0;
     $threadhold3 = 0;
     $arrques = null;
     $arrans = null;
     $questionId = intval($questionId);
     $exeId = intval($exeId);
     $TBL_TRACK_ATTEMPT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
     $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER);
     // Creates a temporary Question object
     $course_id = $this->course_id;
     $objQuestionTmp = Question::read($questionId, $course_id);
     if ($objQuestionTmp === false) {
         return false;
     }
     $questionName = $objQuestionTmp->selectTitle();
     $questionWeighting = $objQuestionTmp->selectWeighting();
     $answerType = $objQuestionTmp->selectType();
     $quesId = $objQuestionTmp->selectId();
     $extra = $objQuestionTmp->extra;
     $next = 1;
     //not for now
     // Extra information of the question
     if (!empty($extra)) {
         $extra = explode(':', $extra);
         if ($debug) {
             error_log(print_r($extra, 1));
         }
         // Fixes problems with negatives values using intval
         $true_score = floatval(trim($extra[0]));
         $false_score = floatval(trim($extra[1]));
         $doubt_score = floatval(trim($extra[2]));
     }
     $totalWeighting = 0;
     $totalScore = 0;
     // Destruction of the Question object
     unset($objQuestionTmp);
     // Construction of the Answer object
     $objAnswerTmp = new Answer($questionId);
     $nbrAnswers = $objAnswerTmp->selectNbrAnswers();
     if ($debug) {
         error_log('Count of answers: ' . $nbrAnswers);
         error_log('$answerType: ' . $answerType);
     }
     if ($answerType == FREE_ANSWER || $answerType == ORAL_EXPRESSION || $answerType == CALCULATED_ANSWER) {
         $nbrAnswers = 1;
     }
     $nano = null;
     if ($answerType == ORAL_EXPRESSION) {
         $exe_info = Event::get_exercise_results_by_attempt($exeId);
         $exe_info = isset($exe_info[$exeId]) ? $exe_info[$exeId] : null;
         $params = array();
         $params['course_id'] = $course_id;
         $params['session_id'] = api_get_session_id();
         $params['user_id'] = isset($exe_info['exe_user_id']) ? $exe_info['exe_user_id'] : api_get_user_id();
         $params['exercise_id'] = isset($exe_info['exe_exo_id']) ? $exe_info['exe_exo_id'] : $this->id;
         $params['question_id'] = $questionId;
         $params['exe_id'] = isset($exe_info['exe_id']) ? $exe_info['exe_id'] : $exeId;
         $nano = new Nanogong($params);
         //probably this attempt came in an exercise all question by page
         if ($feedback_type == 0) {
             $nano->replace_with_real_exe($exeId);
         }
     }
     $user_answer = '';
     // Get answer list for matching
     $sql = "SELECT id_auto, id, answer\n                FROM {$table_ans}\n                WHERE c_id = {$course_id} AND question_id = {$questionId}";
     $res_answer = Database::query($sql);
     $answerMatching = array();
     while ($real_answer = Database::fetch_array($res_answer)) {
         $answerMatching[$real_answer['id_auto']] = $real_answer['answer'];
     }
     $real_answers = array();
     $quiz_question_options = Question::readQuestionOption($questionId, $course_id);
     $organs_at_risk_hit = 0;
     $questionScore = 0;
     if ($debug) {
         error_log('Start answer loop ');
     }
     $answer_correct_array = array();
     for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
         $answer = $objAnswerTmp->selectAnswer($answerId);
         $answerComment = $objAnswerTmp->selectComment($answerId);
         $answerCorrect = $objAnswerTmp->isCorrect($answerId);
         $answerWeighting = (double) $objAnswerTmp->selectWeighting($answerId);
         $answerAutoId = $objAnswerTmp->selectAutoId($answerId);
         $answer_correct_array[$answerId] = (bool) $answerCorrect;
         if ($debug) {
             error_log("answer auto id: {$answerAutoId} ");
             error_log("answer correct: {$answerCorrect} ");
         }
         // Delineation
         $delineation_cord = $objAnswerTmp->selectHotspotCoordinates(1);
         $answer_delineation_destination = $objAnswerTmp->selectDestination(1);
         switch ($answerType) {
             // for unique answer
             case UNIQUE_ANSWER:
             case UNIQUE_ANSWER_IMAGE:
             case UNIQUE_ANSWER_NO_OPTION:
                 if ($from_database) {
                     $sql = "SELECT answer FROM {$TBL_TRACK_ATTEMPT}\n                                WHERE\n                                    exe_id = '" . $exeId . "' AND\n                                    question_id= '" . $questionId . "'";
                     $result = Database::query($sql);
                     $choice = Database::result($result, 0, "answer");
                     $studentChoice = $choice == $answerAutoId ? 1 : 0;
                     if ($studentChoice) {
                         $questionScore += $answerWeighting;
                         $totalScore += $answerWeighting;
                     }
                 } else {
                     $studentChoice = $choice == $answerAutoId ? 1 : 0;
                     if ($studentChoice) {
                         $questionScore += $answerWeighting;
                         $totalScore += $answerWeighting;
                     }
                 }
                 break;
                 // for multiple answers
             // for multiple answers
             case MULTIPLE_ANSWER_TRUE_FALSE:
                 if ($from_database) {
                     $choice = array();
                     $sql = "SELECT answer FROM {$TBL_TRACK_ATTEMPT}\n                                WHERE\n                                    exe_id = {$exeId} AND\n                                    question_id = " . $questionId;
                     $result = Database::query($sql);
                     while ($row = Database::fetch_array($result)) {
                         $ind = $row['answer'];
                         $values = explode(':', $ind);
                         $my_answer_id = isset($values[0]) ? $values[0] : '';
                         $option = isset($values[1]) ? $values[1] : '';
                         $choice[$my_answer_id] = $option;
                     }
                 }
                 $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
                 if (!empty($studentChoice)) {
                     if ($studentChoice == $answerCorrect) {
                         $questionScore += $true_score;
                     } else {
                         if ($quiz_question_options[$studentChoice]['name'] == "Don't know" || $quiz_question_options[$studentChoice]['name'] == "DoubtScore") {
                             $questionScore += $doubt_score;
                         } else {
                             $questionScore += $false_score;
                         }
                     }
                 } else {
                     // If no result then the user just hit don't know
                     $studentChoice = 3;
                     $questionScore += $doubt_score;
                 }
                 $totalScore = $questionScore;
                 break;
             case MULTIPLE_ANSWER:
                 //2
                 if ($from_database) {
                     $choice = array();
                     $sql = "SELECT answer FROM " . $TBL_TRACK_ATTEMPT . "\n                                WHERE exe_id = '" . $exeId . "' AND question_id= '" . $questionId . "'";
                     $resultans = Database::query($sql);
                     while ($row = Database::fetch_array($resultans)) {
                         $ind = $row['answer'];
                         $choice[$ind] = 1;
                     }
                     $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
                     $real_answers[$answerId] = (bool) $studentChoice;
                     if ($studentChoice) {
                         $questionScore += $answerWeighting;
                     }
                 } else {
                     $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
                     $real_answers[$answerId] = (bool) $studentChoice;
                     if (isset($studentChoice)) {
                         $questionScore += $answerWeighting;
                     }
                 }
                 $totalScore += $answerWeighting;
                 if ($debug) {
                     error_log("studentChoice: {$studentChoice}");
                 }
                 break;
             case GLOBAL_MULTIPLE_ANSWER:
                 if ($from_database) {
                     $choice = array();
                     $sql = "SELECT answer FROM {$TBL_TRACK_ATTEMPT}\n                                WHERE exe_id = '" . $exeId . "' AND question_id= '" . $questionId . "'";
                     $resultans = Database::query($sql);
                     while ($row = Database::fetch_array($resultans)) {
                         $ind = $row['answer'];
                         $choice[$ind] = 1;
                     }
                     $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
                     $real_answers[$answerId] = (bool) $studentChoice;
                     if ($studentChoice) {
                         $questionScore += $answerWeighting;
                     }
                 } else {
                     $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
                     if (isset($studentChoice)) {
                         $questionScore += $answerWeighting;
                     }
                     $real_answers[$answerId] = (bool) $studentChoice;
                 }
                 $totalScore += $answerWeighting;
                 if ($debug) {
                     error_log("studentChoice: {$studentChoice}");
                 }
                 break;
             case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE:
                 if ($from_database) {
                     $sql = "SELECT answer FROM " . $TBL_TRACK_ATTEMPT . "\n                                WHERE exe_id = {$exeId} AND question_id= " . $questionId;
                     $resultans = Database::query($sql);
                     while ($row = Database::fetch_array($resultans)) {
                         $ind = $row['answer'];
                         $result = explode(':', $ind);
                         if (isset($result[0])) {
                             $my_answer_id = isset($result[0]) ? $result[0] : '';
                             $option = isset($result[1]) ? $result[1] : '';
                             $choice[$my_answer_id] = $option;
                         }
                     }
                     $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : '';
                     if ($answerCorrect == $studentChoice) {
                         //$answerCorrect = 1;
                         $real_answers[$answerId] = true;
                     } else {
                         //$answerCorrect = 0;
                         $real_answers[$answerId] = false;
                     }
                 } else {
                     $studentChoice = $choice[$answerAutoId];
                     if ($answerCorrect == $studentChoice) {
                         //$answerCorrect = 1;
                         $real_answers[$answerId] = true;
                     } else {
                         //$answerCorrect = 0;
                         $real_answers[$answerId] = false;
                     }
                 }
                 break;
             case MULTIPLE_ANSWER_COMBINATION:
                 if ($from_database) {
                     $sql = "SELECT answer FROM {$TBL_TRACK_ATTEMPT}\n                                WHERE exe_id = {$exeId} AND question_id= {$questionId}";
                     $resultans = Database::query($sql);
                     while ($row = Database::fetch_array($resultans)) {
                         $ind = $row['answer'];
                         $choice[$ind] = 1;
                     }
                     $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
                     if ($answerCorrect == 1) {
                         if ($studentChoice) {
                             $real_answers[$answerId] = true;
                         } else {
                             $real_answers[$answerId] = false;
                         }
                     } else {
                         if ($studentChoice) {
                             $real_answers[$answerId] = false;
                         } else {
                             $real_answers[$answerId] = true;
                         }
                     }
                 } else {
                     $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
                     if ($answerCorrect == 1) {
                         if ($studentChoice) {
                             $real_answers[$answerId] = true;
                         } else {
                             $real_answers[$answerId] = false;
                         }
                     } else {
                         if ($studentChoice) {
                             $real_answers[$answerId] = false;
                         } else {
                             $real_answers[$answerId] = true;
                         }
                     }
                 }
                 break;
             case FILL_IN_BLANKS:
                 $str = '';
                 if ($from_database) {
                     $sql = "SELECT answer\n                                    FROM {$TBL_TRACK_ATTEMPT}\n                                    WHERE\n                                        exe_id = {$exeId} AND\n                                        question_id= " . intval($questionId);
                     $result = Database::query($sql);
                     $str = Database::result($result, 0, 'answer');
                 }
                 if ($saved_results == false && strpos($str, 'font color') !== false) {
                     // the question is encoded like this
                     // [A] B [C] D [E] F::10,10,10@1
                     // number 1 before the "@" means that is a switchable fill in blank question
                     // [A] B [C] D [E] F::10,10,10@ or  [A] B [C] D [E] F::10,10,10
                     // means that is a normal fill blank question
                     // first we explode the "::"
                     $pre_array = explode('::', $answer);
                     // is switchable fill blank or not
                     $last = count($pre_array) - 1;
                     $is_set_switchable = explode('@', $pre_array[$last]);
                     $switchable_answer_set = false;
                     if (isset($is_set_switchable[1]) && $is_set_switchable[1] == 1) {
                         $switchable_answer_set = true;
                     }
                     $answer = '';
                     for ($k = 0; $k < $last; $k++) {
                         $answer .= $pre_array[$k];
                     }
                     // splits weightings that are joined with a comma
                     $answerWeighting = explode(',', $is_set_switchable[0]);
                     // we save the answer because it will be modified
                     $temp = $answer;
                     $answer = '';
                     $j = 0;
                     //initialise answer tags
                     $user_tags = $correct_tags = $real_text = array();
                     // the loop will stop at the end of the text
                     while (1) {
                         // quits the loop if there are no more blanks (detect '[')
                         if (($pos = api_strpos($temp, '[')) === false) {
                             // adds the end of the text
                             $answer = $temp;
                             $real_text[] = $answer;
                             break;
                             //no more "blanks", quit the loop
                         }
                         // adds the piece of text that is before the blank
                         //and ends with '[' into a general storage array
                         $real_text[] = api_substr($temp, 0, $pos + 1);
                         $answer .= api_substr($temp, 0, $pos + 1);
                         //take the string remaining (after the last "[" we found)
                         $temp = api_substr($temp, $pos + 1);
                         // quit the loop if there are no more blanks, and update $pos to the position of next ']'
                         if (($pos = api_strpos($temp, ']')) === false) {
                             // adds the end of the text
                             $answer .= $temp;
                             break;
                         }
                         if ($from_database) {
                             $queryfill = "SELECT answer FROM " . $TBL_TRACK_ATTEMPT . "\n                                          WHERE\n                                            exe_id = '" . $exeId . "' AND\n                                            question_id= " . intval($questionId) . "";
                             $resfill = Database::query($queryfill);
                             $str = Database::result($resfill, 0, 'answer');
                             api_preg_match_all('#\\[([^[]*)\\]#', $str, $arr);
                             $str = str_replace('\\r\\n', '', $str);
                             $choice = $arr[1];
                             if (isset($choice[$j])) {
                                 $tmp = api_strrpos($choice[$j], ' / ');
                                 $choice[$j] = api_substr($choice[$j], 0, $tmp);
                                 $choice[$j] = trim($choice[$j]);
                                 // Needed to let characters ' and " to work as part of an answer
                                 $choice[$j] = stripslashes($choice[$j]);
                             } else {
                                 $choice[$j] = null;
                             }
                         } else {
                             // This value is the user input, not escaped while correct answer is escaped by fckeditor
                             $choice[$j] = api_htmlentities(trim($choice[$j]));
                         }
                         $user_tags[] = $choice[$j];
                         //put the contents of the [] answer tag into correct_tags[]
                         $correct_tags[] = api_substr($temp, 0, $pos);
                         $j++;
                         $temp = api_substr($temp, $pos + 1);
                     }
                     $answer = '';
                     $real_correct_tags = $correct_tags;
                     $chosen_list = array();
                     for ($i = 0; $i < count($real_correct_tags); $i++) {
                         if ($i == 0) {
                             $answer .= $real_text[0];
                         }
                         if (!$switchable_answer_set) {
                             // Needed to parse ' and " characters
                             $user_tags[$i] = stripslashes($user_tags[$i]);
                             if ($correct_tags[$i] == $user_tags[$i]) {
                                 // gives the related weighting to the student
                                 $questionScore += $answerWeighting[$i];
                                 // increments total score
                                 $totalScore += $answerWeighting[$i];
                                 // adds the word in green at the end of the string
                                 $answer .= $correct_tags[$i];
                             } elseif (!empty($user_tags[$i])) {
                                 // else if the word entered by the student IS NOT the same as the one defined by the professor
                                 // adds the word in red at the end of the string, and strikes it
                                 $answer .= '<font color="red"><s>' . $user_tags[$i] . '</s></font>';
                             } else {
                                 // adds a tabulation if no word has been typed by the student
                                 $answer .= '';
                                 // remove &nbsp; that causes issue
                             }
                         } else {
                             // switchable fill in the blanks
                             if (in_array($user_tags[$i], $correct_tags)) {
                                 $chosen_list[] = $user_tags[$i];
                                 $correct_tags = array_diff($correct_tags, $chosen_list);
                                 // gives the related weighting to the student
                                 $questionScore += $answerWeighting[$i];
                                 // increments total score
                                 $totalScore += $answerWeighting[$i];
                                 // adds the word in green at the end of the string
                                 $answer .= $user_tags[$i];
                             } elseif (!empty($user_tags[$i])) {
                                 // else if the word entered by the student IS NOT the same as the one defined by the professor
                                 // adds the word in red at the end of the string, and strikes it
                                 $answer .= '<font color="red"><s>' . $user_tags[$i] . '</s></font>';
                             } else {
                                 // adds a tabulation if no word has been typed by the student
                                 $answer .= '';
                                 // remove &nbsp; that causes issue
                             }
                         }
                         // adds the correct word, followed by ] to close the blank
                         $answer .= ' / <font color="green"><b>' . $real_correct_tags[$i] . '</b></font>]';
                         if (isset($real_text[$i + 1])) {
                             $answer .= $real_text[$i + 1];
                         }
                     }
                 } else {
                     // insert the student result in the track_e_attempt table, field answer
                     // $answer is the answer like in the c_quiz_answer table for the question
                     // student data are choice[]
                     $listCorrectAnswers = FillBlanks::getAnswerInfo($answer);
                     $switchableAnswerSet = $listCorrectAnswers["switchable"];
                     $answerWeighting = $listCorrectAnswers["tabweighting"];
                     // user choices is an array $choice
                     // get existing user data in n the BDD
                     if ($from_database) {
                         $sql = "SELECT answer\n                                    FROM {$TBL_TRACK_ATTEMPT}\n                                    WHERE\n                                        exe_id = {$exeId} AND\n                                        question_id= " . intval($questionId);
                         $result = Database::query($sql);
                         $str = Database::result($result, 0, 'answer');
                         $listStudentResults = FillBlanks::getAnswerInfo($str, true);
                         $choice = $listStudentResults['studentanswer'];
                     }
                     // loop other all blanks words
                     if (!$switchableAnswerSet) {
                         // not switchable answer, must be in the same place than teacher order
                         for ($i = 0; $i < count($listCorrectAnswers['tabwords']); $i++) {
                             $studentAnswer = isset($choice[$i]) ? trim($choice[$i]) : '';
                             // This value is the user input, not escaped while correct answer is escaped by fckeditor
                             // Works with cyrillic alphabet and when using ">" chars see #7718 #7610 #7618
                             if (!$from_database) {
                                 $studentAnswer = htmlentities(api_utf8_encode($studentAnswer));
                             }
                             $correctAnswer = $listCorrectAnswers['tabwords'][$i];
                             $isAnswerCorrect = 0;
                             if (FillBlanks::isGoodStudentAnswer($studentAnswer, $correctAnswer)) {
                                 // gives the related weighting to the student
                                 $questionScore += $answerWeighting[$i];
                                 // increments total score
                                 $totalScore += $answerWeighting[$i];
                                 $isAnswerCorrect = 1;
                             }
                             $listCorrectAnswers['studentanswer'][$i] = $studentAnswer;
                             $listCorrectAnswers['studentscore'][$i] = $isAnswerCorrect;
                         }
                     } else {
                         // switchable answer
                         $listStudentAnswerTemp = $choice;
                         $listTeacherAnswerTemp = $listCorrectAnswers['tabwords'];
                         // for every teacher answer, check if there is a student answer
                         for ($i = 0; $i < count($listStudentAnswerTemp); $i++) {
                             $studentAnswer = trim($listStudentAnswerTemp[$i]);
                             $found = false;
                             for ($j = 0; $j < count($listTeacherAnswerTemp); $j++) {
                                 $correctAnswer = $listTeacherAnswerTemp[$j];
                                 if (!$found) {
                                     if (FillBlanks::isGoodStudentAnswer($studentAnswer, $correctAnswer)) {
                                         $questionScore += $answerWeighting[$i];
                                         $totalScore += $answerWeighting[$i];
                                         $listTeacherAnswerTemp[$j] = "";
                                         $found = true;
                                     }
                                 }
                             }
                             $listCorrectAnswers['studentanswer'][$i] = $studentAnswer;
                             if (!$found) {
                                 $listCorrectAnswers['studentscore'][$i] = 0;
                             } else {
                                 $listCorrectAnswers['studentscore'][$i] = 1;
                             }
                         }
                     }
                     $answer = FillBlanks::getAnswerInStudentAttempt($listCorrectAnswers);
                 }
                 break;
                 // for calculated answer
             // for calculated answer
             case CALCULATED_ANSWER:
                 $calculatedAnswer = Session::read('calculatedAnswerId');
                 $answer = $objAnswerTmp->selectAnswer($calculatedAnswer[$questionId]);
                 $preArray = explode('@@', $answer);
                 $last = count($preArray) - 1;
                 $answer = '';
                 for ($k = 0; $k < $last; $k++) {
                     $answer .= $preArray[$k];
                 }
                 $answerWeighting = array($answerWeighting);
                 // we save the answer because it will be modified
                 $temp = $answer;
                 $answer = '';
                 $j = 0;
                 //initialise answer tags
                 $userTags = $correctTags = $realText = array();
                 // the loop will stop at the end of the text
                 while (1) {
                     // quits the loop if there are no more blanks (detect '[')
                     if (($pos = api_strpos($temp, '[')) === false) {
                         // adds the end of the text
                         $answer = $temp;
                         $realText[] = $answer;
                         break;
                         //no more "blanks", quit the loop
                     }
                     // adds the piece of text that is before the blank
                     //and ends with '[' into a general storage array
                     $realText[] = api_substr($temp, 0, $pos + 1);
                     $answer .= api_substr($temp, 0, $pos + 1);
                     //take the string remaining (after the last "[" we found)
                     $temp = api_substr($temp, $pos + 1);
                     // quit the loop if there are no more blanks, and update $pos to the position of next ']'
                     if (($pos = api_strpos($temp, ']')) === false) {
                         // adds the end of the text
                         $answer .= $temp;
                         break;
                     }
                     if ($from_database) {
                         $queryfill = "SELECT answer FROM " . $TBL_TRACK_ATTEMPT . "\n                                          WHERE\n                                            exe_id = '" . $exeId . "' AND\n                                            question_id= " . intval($questionId) . "";
                         $resfill = Database::query($queryfill);
                         $str = Database::result($resfill, 0, 'answer');
                         api_preg_match_all('#\\[([^[]*)\\]#', $str, $arr);
                         $str = str_replace('\\r\\n', '', $str);
                         $choice = $arr[1];
                         if (isset($choice[$j])) {
                             $tmp = api_strrpos($choice[$j], ' / ');
                             $choice[$j] = api_substr($choice[$j], 0, $tmp);
                             $choice[$j] = trim($choice[$j]);
                             // Needed to let characters ' and " to work as part of an answer
                             $choice[$j] = stripslashes($choice[$j]);
                         } else {
                             $choice[$j] = null;
                         }
                     } else {
                         // This value is the user input, not escaped while correct answer is escaped by fckeditor
                         $choice[$j] = api_htmlentities(trim($choice[$j]));
                     }
                     $userTags[] = $choice[$j];
                     //put the contents of the [] answer tag into correct_tags[]
                     $correctTags[] = api_substr($temp, 0, $pos);
                     $j++;
                     $temp = api_substr($temp, $pos + 1);
                 }
                 $answer = '';
                 $realCorrectTags = $correctTags;
                 for ($i = 0; $i < count($realCorrectTags); $i++) {
                     if ($i == 0) {
                         $answer .= $realText[0];
                     }
                     // Needed to parse ' and " characters
                     $userTags[$i] = stripslashes($userTags[$i]);
                     if ($correctTags[$i] == $userTags[$i]) {
                         // gives the related weighting to the student
                         $questionScore += $answerWeighting[$i];
                         // increments total score
                         $totalScore += $answerWeighting[$i];
                         // adds the word in green at the end of the string
                         $answer .= $correctTags[$i];
                     } elseif (!empty($userTags[$i])) {
                         // else if the word entered by the student IS NOT the same as the one defined by the professor
                         // adds the word in red at the end of the string, and strikes it
                         $answer .= '<font color="red"><s>' . $userTags[$i] . '</s></font>';
                     } else {
                         // adds a tabulation if no word has been typed by the student
                         $answer .= '';
                         // remove &nbsp; that causes issue
                     }
                     // adds the correct word, followed by ] to close the blank
                     $answer .= ' / <font color="green"><b>' . $realCorrectTags[$i] . '</b></font>]';
                     if (isset($realText[$i + 1])) {
                         $answer .= $realText[$i + 1];
                     }
                 }
                 break;
                 // for free answer
             // for free answer
             case FREE_ANSWER:
                 if ($from_database) {
                     $query = "SELECT answer, marks FROM " . $TBL_TRACK_ATTEMPT . "\n                                   WHERE exe_id = '" . $exeId . "' AND question_id= '" . $questionId . "'";
                     $resq = Database::query($query);
                     $data = Database::fetch_array($resq);
                     $choice = $data['answer'];
                     $choice = str_replace('\\r\\n', '', $choice);
                     $choice = stripslashes($choice);
                     $questionScore = $data['marks'];
                     if ($questionScore == -1) {
                         $totalScore += 0;
                     } else {
                         $totalScore += $questionScore;
                     }
                     if ($questionScore == '') {
                         $questionScore = 0;
                     }
                     $arrques = $questionName;
                     $arrans = $choice;
                 } else {
                     $studentChoice = $choice;
                     if ($studentChoice) {
                         //Fixing negative puntation see #2193
                         $questionScore = 0;
                         $totalScore += 0;
                     }
                 }
                 break;
             case ORAL_EXPRESSION:
                 if ($from_database) {
                     $query = "SELECT answer, marks FROM " . $TBL_TRACK_ATTEMPT . "\n                                   WHERE exe_id = '" . $exeId . "' AND question_id= '" . $questionId . "'";
                     $resq = Database::query($query);
                     $choice = Database::result($resq, 0, 'answer');
                     $choice = str_replace('\\r\\n', '', $choice);
                     $choice = stripslashes($choice);
                     $questionScore = Database::result($resq, 0, "marks");
                     if ($questionScore == -1) {
                         $totalScore += 0;
                     } else {
                         $totalScore += $questionScore;
                     }
                     $arrques = $questionName;
                     $arrans = $choice;
                 } else {
                     $studentChoice = $choice;
                     if ($studentChoice) {
                         //Fixing negative puntation see #2193
                         $questionScore = 0;
                         $totalScore += 0;
                     }
                 }
                 break;
             case DRAGGABLE:
                 //no break
             //no break
             case MATCHING_DRAGGABLE:
                 //no break
             //no break
             case MATCHING:
                 if ($from_database) {
                     $sql = 'SELECT id, answer, id_auto
                             FROM ' . $table_ans . '
                             WHERE
                                 c_id = ' . $course_id . ' AND
                                 question_id = "' . $questionId . '" AND
                                 correct = 0';
                     $res_answer = Database::query($sql);
                     // Getting the real answer
                     $real_list = array();
                     while ($real_answer = Database::fetch_array($res_answer)) {
                         $real_list[$real_answer['id_auto']] = $real_answer['answer'];
                     }
                     $sql = 'SELECT id, answer, correct, id_auto, ponderation
                             FROM ' . $table_ans . '
                             WHERE
                                 c_id = ' . $course_id . ' AND
                                 question_id="' . $questionId . '" AND
                                 correct <> 0
                             ORDER BY id_auto';
                     $res_answers = Database::query($sql);
                     $questionScore = 0;
                     while ($a_answers = Database::fetch_array($res_answers)) {
                         $i_answer_id = $a_answers['id'];
                         //3
                         $s_answer_label = $a_answers['answer'];
                         // your daddy - your mother
                         $i_answer_correct_answer = $a_answers['correct'];
                         //1 - 2
                         $i_answer_id_auto = $a_answers['id_auto'];
                         // 3 - 4
                         $sql = "SELECT answer FROM {$TBL_TRACK_ATTEMPT}\n                                    WHERE\n                                        exe_id = '{$exeId}' AND\n                                        question_id = '{$questionId}' AND\n                                        position = '{$i_answer_id_auto}'";
                         $res_user_answer = Database::query($sql);
                         if (Database::num_rows($res_user_answer) > 0) {
                             //  rich - good looking
                             $s_user_answer = Database::result($res_user_answer, 0, 0);
                         } else {
                             $s_user_answer = 0;
                         }
                         $i_answerWeighting = $a_answers['ponderation'];
                         $user_answer = '';
                         if (!empty($s_user_answer)) {
                             if ($answerType == DRAGGABLE) {
                                 if ($s_user_answer == $i_answer_correct_answer) {
                                     $questionScore += $i_answerWeighting;
                                     $totalScore += $i_answerWeighting;
                                     $user_answer = Display::label(get_lang('Correct'), 'success');
                                 } else {
                                     $user_answer = Display::label(get_lang('Incorrect'), 'danger');
                                 }
                             } else {
                                 if ($s_user_answer == $i_answer_correct_answer) {
                                     $questionScore += $i_answerWeighting;
                                     $totalScore += $i_answerWeighting;
                                     if (isset($real_list[$i_answer_id])) {
                                         $user_answer = Display::span($real_list[$i_answer_id]);
                                     }
                                 } else {
                                     $user_answer = Display::span($real_list[$s_user_answer], ['style' => 'color: #FF0000; text-decoration: line-through;']);
                                 }
                             }
                         } elseif ($answerType == DRAGGABLE) {
                             $user_answer = Display::label(get_lang('Incorrect'), 'danger');
                         }
                         if ($show_result) {
                             echo '<tr>';
                             echo '<td>' . $s_answer_label . '</td>';
                             echo '<td>' . $user_answer;
                             if (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) {
                                 if (isset($real_list[$i_answer_correct_answer])) {
                                     echo Display::span($real_list[$i_answer_correct_answer], ['style' => 'color: #008000; font-weight: bold;']);
                                 }
                             }
                             echo '</td>';
                             echo '</tr>';
                         }
                     }
                     break 2;
                     // break the switch and the "for" condition
                 } else {
                     if ($answerCorrect) {
                         if (isset($choice[$answerAutoId]) && $answerCorrect == $choice[$answerAutoId]) {
                             $questionScore += $answerWeighting;
                             $totalScore += $answerWeighting;
                             $user_answer = Display::span($answerMatching[$choice[$answerAutoId]]);
                         } else {
                             if (isset($answerMatching[$choice[$answerAutoId]])) {
                                 $user_answer = Display::span($answerMatching[$choice[$answerAutoId]], ['style' => 'color: #FF0000; text-decoration: line-through;']);
                             }
                         }
                         $matching[$answerAutoId] = $choice[$answerAutoId];
                     }
                     break;
                 }
             case HOT_SPOT:
                 if ($from_database) {
                     $TBL_TRACK_HOTSPOT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
                     $sql = "SELECT hotspot_correct\n                                FROM {$TBL_TRACK_HOTSPOT}\n                                WHERE\n                                    hotspot_exe_id = '" . $exeId . "' AND\n                                    hotspot_question_id= '" . $questionId . "' AND\n                                    hotspot_answer_id = " . intval($answerAutoId) . "";
                     $result = Database::query($sql);
                     $studentChoice = Database::result($result, 0, "hotspot_correct");
                     if ($studentChoice) {
                         $questionScore += $answerWeighting;
                         $totalScore += $answerWeighting;
                     }
                 } else {
                     if (!isset($choice[$answerAutoId])) {
                         $choice[$answerAutoId] = 0;
                     } else {
                         $studentChoice = $choice[$answerAutoId];
                         $choiceIsValid = false;
                         if (!empty($studentChoice)) {
                             $hotspotType = $objAnswerTmp->selectHotspotType($answerId);
                             $hotspotCoordinates = $objAnswerTmp->selectHotspotCoordinates($answerId);
                             $choicePoint = Geometry::decodePoint($studentChoice);
                             switch ($hotspotType) {
                                 case 'square':
                                     $hotspotProperties = Geometry::decodeSquare($hotspotCoordinates);
                                     $choiceIsValid = Geometry::pointIsInSquare($hotspotProperties, $choicePoint);
                                     break;
                                 case 'circle':
                                     $hotspotProperties = Geometry::decodeEllipse($hotspotCoordinates);
                                     $choiceIsValid = Geometry::pointIsInEllipse($hotspotProperties, $choicePoint);
                                     break;
                                 case 'poly':
                                     $hotspotProperties = Geometry::decodePolygon($hotspotCoordinates);
                                     $choiceIsValid = Geometry::pointIsInPolygon($hotspotProperties, $choicePoint);
                                     break;
                             }
                         }
                         $choice[$answerAutoId] = 0;
                         if ($choiceIsValid) {
                             $questionScore += $answerWeighting;
                             $totalScore += $answerWeighting;
                             $choice[$answerAutoId] = 1;
                         }
                     }
                 }
                 break;
                 // @todo never added to chamilo
                 //for hotspot with fixed order
             // @todo never added to chamilo
             //for hotspot with fixed order
             case HOT_SPOT_ORDER:
                 $studentChoice = $choice['order'][$answerId];
                 if ($studentChoice == $answerId) {
                     $questionScore += $answerWeighting;
                     $totalScore += $answerWeighting;
                     $studentChoice = true;
                 } else {
                     $studentChoice = false;
                 }
                 break;
                 // for hotspot with delineation
             // for hotspot with delineation
             case HOT_SPOT_DELINEATION:
                 if ($from_database) {
                     // getting the user answer
                     $TBL_TRACK_HOTSPOT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
                     $query = "SELECT hotspot_correct, hotspot_coordinate\n                                    FROM {$TBL_TRACK_HOTSPOT}\n                                    WHERE\n                                        hotspot_exe_id = '" . $exeId . "' AND\n                                        hotspot_question_id= '" . $questionId . "' AND\n                                        hotspot_answer_id='1'";
                     //by default we take 1 because it's a delineation
                     $resq = Database::query($query);
                     $row = Database::fetch_array($resq, 'ASSOC');
                     $choice = $row['hotspot_correct'];
                     $user_answer = $row['hotspot_coordinate'];
                     // THIS is very important otherwise the poly_compile will throw an error!!
                     // round-up the coordinates
                     $coords = explode('/', $user_answer);
                     $user_array = '';
                     foreach ($coords as $coord) {
                         list($x, $y) = explode(';', $coord);
                         $user_array .= round($x) . ';' . round($y) . '/';
                     }
                     $user_array = substr($user_array, 0, -1);
                 } else {
                     if (!empty($studentChoice)) {
                         $newquestionList[] = $questionId;
                     }
                     if ($answerId === 1) {
                         $studentChoice = $choice[$answerId];
                         $questionScore += $answerWeighting;
                         if ($hotspot_delineation_result[1] == 1) {
                             $totalScore += $answerWeighting;
                             //adding the total
                         }
                     }
                 }
                 $_SESSION['hotspot_coord'][1] = $delineation_cord;
                 $_SESSION['hotspot_dest'][1] = $answer_delineation_destination;
                 break;
         }
         // end switch Answertype
         if ($show_result) {
             if ($debug) {
                 error_log('show result ' . $show_result);
             }
             if ($from == 'exercise_result') {
                 if ($debug) {
                     error_log('Showing questions $from ' . $from);
                 }
                 //display answers (if not matching type, or if the answer is correct)
                 if (!in_array($answerType, [MATCHING, DRAGGABLE, MATCHING_DRAGGABLE]) || $answerCorrect) {
                     if (in_array($answerType, array(UNIQUE_ANSWER, UNIQUE_ANSWER_IMAGE, UNIQUE_ANSWER_NO_OPTION, MULTIPLE_ANSWER, MULTIPLE_ANSWER_COMBINATION, GLOBAL_MULTIPLE_ANSWER))) {
                         //if ($origin != 'learnpath') {
                         ExerciseShowFunctions::display_unique_or_multiple_answer($feedback_type, $answerType, $studentChoice, $answer, $answerComment, $answerCorrect, 0, 0, 0, $results_disabled);
                         //}
                     } elseif ($answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
                         //if ($origin!='learnpath') {
                         ExerciseShowFunctions::display_multiple_answer_true_false($feedback_type, $answerType, $studentChoice, $answer, $answerComment, $answerCorrect, 0, $questionId, 0, $results_disabled);
                         //}
                     } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
                         //	if ($origin!='learnpath') {
                         ExerciseShowFunctions::display_multiple_answer_combination_true_false($feedback_type, $answerType, $studentChoice, $answer, $answerComment, $answerCorrect, 0, 0, 0, $results_disabled);
                         //}
                     } elseif ($answerType == FILL_IN_BLANKS) {
                         //if ($origin!='learnpath') {
                         ExerciseShowFunctions::display_fill_in_blanks_answer($feedback_type, $answer, 0, 0, $results_disabled);
                         //	}
                     } elseif ($answerType == CALCULATED_ANSWER) {
                         //if ($origin!='learnpath') {
                         ExerciseShowFunctions::display_calculated_answer($feedback_type, $answer, 0, 0);
                         //  }
                     } elseif ($answerType == FREE_ANSWER) {
                         //if($origin != 'learnpath') {
                         ExerciseShowFunctions::display_free_answer($feedback_type, $choice, $exeId, $questionId, $questionScore);
                         //}
                     } elseif ($answerType == ORAL_EXPRESSION) {
                         // to store the details of open questions in an array to be used in mail
                         //if ($origin != 'learnpath') {
                         ExerciseShowFunctions::display_oral_expression_answer($feedback_type, $choice, 0, 0, $nano);
                         //}
                     } elseif ($answerType == HOT_SPOT) {
                         //if ($origin != 'learnpath') {
                         ExerciseShowFunctions::display_hotspot_answer($feedback_type, $answerId, $answer, $studentChoice, $answerComment, $results_disabled);
                         //	}
                     } elseif ($answerType == HOT_SPOT_ORDER) {
                         //if ($origin != 'learnpath') {
                         ExerciseShowFunctions::display_hotspot_order_answer($feedback_type, $answerId, $answer, $studentChoice, $answerComment);
                         //}
                     } elseif ($answerType == HOT_SPOT_DELINEATION) {
                         $user_answer = $_SESSION['exerciseResultCoordinates'][$questionId];
                         //round-up the coordinates
                         $coords = explode('/', $user_answer);
                         $user_array = '';
                         foreach ($coords as $coord) {
                             list($x, $y) = explode(';', $coord);
                             $user_array .= round($x) . ';' . round($y) . '/';
                         }
                         $user_array = substr($user_array, 0, -1);
                         if ($next) {
                             $user_answer = $user_array;
                             // we compare only the delineation not the other points
                             $answer_question = $_SESSION['hotspot_coord'][1];
                             $answerDestination = $_SESSION['hotspot_dest'][1];
                             //calculating the area
                             $poly_user = convert_coordinates($user_answer, '/');
                             $poly_answer = convert_coordinates($answer_question, '|');
                             $max_coord = poly_get_max($poly_user, $poly_answer);
                             $poly_user_compiled = poly_compile($poly_user, $max_coord);
                             $poly_answer_compiled = poly_compile($poly_answer, $max_coord);
                             $poly_results = poly_result($poly_answer_compiled, $poly_user_compiled, $max_coord);
                             $overlap = $poly_results['both'];
                             $poly_answer_area = $poly_results['s1'];
                             $poly_user_area = $poly_results['s2'];
                             $missing = $poly_results['s1Only'];
                             $excess = $poly_results['s2Only'];
                             //$overlap = round(polygons_overlap($poly_answer,$poly_user));
                             // //this is an area in pixels
                             if ($debug > 0) {
                                 error_log(__LINE__ . ' - Polygons results are ' . print_r($poly_results, 1), 0);
                             }
                             if ($overlap < 1) {
                                 //shortcut to avoid complicated calculations
                                 $final_overlap = 0;
                                 $final_missing = 100;
                                 $final_excess = 100;
                             } else {
                                 // the final overlap is the percentage of the initial polygon
                                 // that is overlapped by the user's polygon
                                 $final_overlap = round((double) $overlap / (double) $poly_answer_area * 100);
                                 if ($debug > 1) {
                                     error_log(__LINE__ . ' - Final overlap is ' . $final_overlap, 0);
                                 }
                                 // the final missing area is the percentage of the initial polygon
                                 // that is not overlapped by the user's polygon
                                 $final_missing = 100 - $final_overlap;
                                 if ($debug > 1) {
                                     error_log(__LINE__ . ' - Final missing is ' . $final_missing, 0);
                                 }
                                 // the final excess area is the percentage of the initial polygon's size
                                 // that is covered by the user's polygon outside of the initial polygon
                                 $final_excess = round(((double) $poly_user_area - (double) $overlap) / (double) $poly_answer_area * 100);
                                 if ($debug > 1) {
                                     error_log(__LINE__ . ' - Final excess is ' . $final_excess, 0);
                                 }
                             }
                             //checking the destination parameters parsing the "@@"
                             $destination_items = explode('@@', $answerDestination);
                             $threadhold_total = $destination_items[0];
                             $threadhold_items = explode(';', $threadhold_total);
                             $threadhold1 = $threadhold_items[0];
                             // overlap
                             $threadhold2 = $threadhold_items[1];
                             // excess
                             $threadhold3 = $threadhold_items[2];
                             //missing
                             // if is delineation
                             if ($answerId === 1) {
                                 //setting colors
                                 if ($final_overlap >= $threadhold1) {
                                     $overlap_color = true;
                                     //echo 'a';
                                 }
                                 //echo $excess.'-'.$threadhold2;
                                 if ($final_excess <= $threadhold2) {
                                     $excess_color = true;
                                     //echo 'b';
                                 }
                                 //echo '--------'.$missing.'-'.$threadhold3;
                                 if ($final_missing <= $threadhold3) {
                                     $missing_color = true;
                                     //echo 'c';
                                 }
                                 // if pass
                                 if ($final_overlap >= $threadhold1 && $final_missing <= $threadhold3 && $final_excess <= $threadhold2) {
                                     $next = 1;
                                     //go to the oars
                                     $result_comment = get_lang('Acceptable');
                                     $final_answer = 1;
                                     // do not update with  update_exercise_attempt
                                 } else {
                                     $next = 0;
                                     $result_comment = get_lang('Unacceptable');
                                     $comment = $answerDestination = $objAnswerTmp->selectComment(1);
                                     $answerDestination = $objAnswerTmp->selectDestination(1);
                                     //checking the destination parameters parsing the "@@"
                                     $destination_items = explode('@@', $answerDestination);
                                 }
                             } elseif ($answerId > 1) {
                                 if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') {
                                     if ($debug > 0) {
                                         error_log(__LINE__ . ' - answerId is of type noerror', 0);
                                     }
                                     //type no error shouldn't be treated
                                     $next = 1;
                                     continue;
                                 }
                                 if ($debug > 0) {
                                     error_log(__LINE__ . ' - answerId is >1 so we\'re probably in OAR', 0);
                                 }
                                 //check the intersection between the oar and the user
                                 //echo 'user';	print_r($x_user_list);		print_r($y_user_list);
                                 //echo 'official';print_r($x_list);print_r($y_list);
                                 //$result = get_intersection_data($x_list,$y_list,$x_user_list,$y_user_list);
                                 $inter = $result['success'];
                                 //$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId);
                                 $delineation_cord = $objAnswerTmp->selectHotspotCoordinates($answerId);
                                 $poly_answer = convert_coordinates($delineation_cord, '|');
                                 $max_coord = poly_get_max($poly_user, $poly_answer);
                                 $poly_answer_compiled = poly_compile($poly_answer, $max_coord);
                                 $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled, $max_coord);
                                 if ($overlap == false) {
                                     //all good, no overlap
                                     $next = 1;
                                     continue;
                                 } else {
                                     if ($debug > 0) {
                                         error_log(__LINE__ . ' - Overlap is ' . $overlap . ': OAR hit', 0);
                                     }
                                     $organs_at_risk_hit++;
                                     //show the feedback
                                     $next = 0;
                                     $comment = $answerDestination = $objAnswerTmp->selectComment($answerId);
                                     $answerDestination = $objAnswerTmp->selectDestination($answerId);
                                     $destination_items = explode('@@', $answerDestination);
                                     $try_hotspot = $destination_items[1];
                                     $lp_hotspot = $destination_items[2];
                                     $select_question_hotspot = $destination_items[3];
                                     $url_hotspot = $destination_items[4];
                                 }
                             }
                         } else {
                             // the first delineation feedback
                             if ($debug > 0) {
                                 error_log(__LINE__ . ' first', 0);
                             }
                         }
                     } elseif (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) {
                         echo '<tr>';
                         echo Display::tag('td', $answerMatching[$answerId]);
                         echo Display::tag('td', "{$user_answer} / " . Display::tag('strong', $answerMatching[$answerCorrect], ['style' => 'color: #008000; font-weight: bold;']));
                         echo '</tr>';
                     }
                 }
             } else {
                 if ($debug) {
                     error_log('Showing questions $from ' . $from);
                 }
                 switch ($answerType) {
                     case UNIQUE_ANSWER:
                     case UNIQUE_ANSWER_IMAGE:
                     case UNIQUE_ANSWER_NO_OPTION:
                     case MULTIPLE_ANSWER:
                     case GLOBAL_MULTIPLE_ANSWER:
                     case MULTIPLE_ANSWER_COMBINATION:
                         if ($answerId == 1) {
                             ExerciseShowFunctions::display_unique_or_multiple_answer($feedback_type, $answerType, $studentChoice, $answer, $answerComment, $answerCorrect, $exeId, $questionId, $answerId, $results_disabled);
                         } else {
                             ExerciseShowFunctions::display_unique_or_multiple_answer($feedback_type, $answerType, $studentChoice, $answer, $answerComment, $answerCorrect, $exeId, $questionId, "", $results_disabled);
                         }
                         break;
                     case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE:
                         if ($answerId == 1) {
                             ExerciseShowFunctions::display_multiple_answer_combination_true_false($feedback_type, $answerType, $studentChoice, $answer, $answerComment, $answerCorrect, $exeId, $questionId, $answerId, $results_disabled);
                         } else {
                             ExerciseShowFunctions::display_multiple_answer_combination_true_false($feedback_type, $answerType, $studentChoice, $answer, $answerComment, $answerCorrect, $exeId, $questionId, "", $results_disabled);
                         }
                         break;
                     case MULTIPLE_ANSWER_TRUE_FALSE:
                         if ($answerId == 1) {
                             ExerciseShowFunctions::display_multiple_answer_true_false($feedback_type, $answerType, $studentChoice, $answer, $answerComment, $answerCorrect, $exeId, $questionId, $answerId, $results_disabled);
                         } else {
                             ExerciseShowFunctions::display_multiple_answer_true_false($feedback_type, $answerType, $studentChoice, $answer, $answerComment, $answerCorrect, $exeId, $questionId, "", $results_disabled);
                         }
                         break;
                     case FILL_IN_BLANKS:
                         ExerciseShowFunctions::display_fill_in_blanks_answer($feedback_type, $answer, $exeId, $questionId, $results_disabled, $str);
                         break;
                     case CALCULATED_ANSWER:
                         ExerciseShowFunctions::display_calculated_answer($feedback_type, $answer, $exeId, $questionId);
                         break;
                     case FREE_ANSWER:
                         echo ExerciseShowFunctions::display_free_answer($feedback_type, $choice, $exeId, $questionId, $questionScore);
                         break;
                     case ORAL_EXPRESSION:
                         echo '<tr>
                             <td valign="top">' . ExerciseShowFunctions::display_oral_expression_answer($feedback_type, $choice, $exeId, $questionId, $nano) . '</td>
                             </tr>
                             </table>';
                         break;
                     case HOT_SPOT:
                         ExerciseShowFunctions::display_hotspot_answer($feedback_type, $answerId, $answer, $studentChoice, $answerComment, $results_disabled);
                         break;
                     case HOT_SPOT_DELINEATION:
                         $user_answer = $user_array;
                         if ($next) {
                             //$tbl_track_e_hotspot = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
                             // Save into db
                             /*	$sql = "INSERT INTO $tbl_track_e_hotspot (
                                 * hotspot_user_id,
                                 *  hotspot_course_code,
                                 *  hotspot_exe_id,
                                 *  hotspot_question_id,
                                 *  hotspot_answer_id,
                                 *  hotspot_correct,
                                 *  hotspot_coordinate
                                 *  )
                                VALUES (
                                 * '".Database::escape_string($_user['user_id'])."',
                                 *  '".Database::escape_string($_course['id'])."',
                                 *  '".Database::escape_string($exeId)."', '".Database::escape_string($questionId)."',
                                 *  '".Database::escape_string($answerId)."',
                                 *  '".Database::escape_string($studentChoice)."',
                                 *  '".Database::escape_string($user_array)."')";
                                $result = Database::query($sql,__FILE__,__LINE__);
                                 */
                             $user_answer = $user_array;
                             // we compare only the delineation not the other points
                             $answer_question = $_SESSION['hotspot_coord'][1];
                             $answerDestination = $_SESSION['hotspot_dest'][1];
                             //calculating the area
                             $poly_user = convert_coordinates($user_answer, '/');
                             $poly_answer = convert_coordinates($answer_question, '|');
                             $max_coord = poly_get_max($poly_user, $poly_answer);
                             $poly_user_compiled = poly_compile($poly_user, $max_coord);
                             $poly_answer_compiled = poly_compile($poly_answer, $max_coord);
                             $poly_results = poly_result($poly_answer_compiled, $poly_user_compiled, $max_coord);
                             $overlap = $poly_results['both'];
                             $poly_answer_area = $poly_results['s1'];
                             $poly_user_area = $poly_results['s2'];
                             $missing = $poly_results['s1Only'];
                             $excess = $poly_results['s2Only'];
                             //$overlap = round(polygons_overlap($poly_answer,$poly_user)); //this is an area in pixels
                             if ($debug > 0) {
                                 error_log(__LINE__ . ' - Polygons results are ' . print_r($poly_results, 1), 0);
                             }
                             if ($overlap < 1) {
                                 //shortcut to avoid complicated calculations
                                 $final_overlap = 0;
                                 $final_missing = 100;
                                 $final_excess = 100;
                             } else {
                                 // the final overlap is the percentage of the initial polygon that is overlapped by the user's polygon
                                 $final_overlap = round((double) $overlap / (double) $poly_answer_area * 100);
                                 if ($debug > 1) {
                                     error_log(__LINE__ . ' - Final overlap is ' . $final_overlap, 0);
                                 }
                                 // the final missing area is the percentage of the initial polygon that is not overlapped by the user's polygon
                                 $final_missing = 100 - $final_overlap;
                                 if ($debug > 1) {
                                     error_log(__LINE__ . ' - Final missing is ' . $final_missing, 0);
                                 }
                                 // the final excess area is the percentage of the initial polygon's size that is covered by the user's polygon outside of the initial polygon
                                 $final_excess = round(((double) $poly_user_area - (double) $overlap) / (double) $poly_answer_area * 100);
                                 if ($debug > 1) {
                                     error_log(__LINE__ . ' - Final excess is ' . $final_excess, 0);
                                 }
                             }
                             //checking the destination parameters parsing the "@@"
                             $destination_items = explode('@@', $answerDestination);
                             $threadhold_total = $destination_items[0];
                             $threadhold_items = explode(';', $threadhold_total);
                             $threadhold1 = $threadhold_items[0];
                             // overlap
                             $threadhold2 = $threadhold_items[1];
                             // excess
                             $threadhold3 = $threadhold_items[2];
                             //missing
                             // if is delineation
                             if ($answerId === 1) {
                                 //setting colors
                                 if ($final_overlap >= $threadhold1) {
                                     $overlap_color = true;
                                     //echo 'a';
                                 }
                                 //echo $excess.'-'.$threadhold2;
                                 if ($final_excess <= $threadhold2) {
                                     $excess_color = true;
                                     //echo 'b';
                                 }
                                 //echo '--------'.$missing.'-'.$threadhold3;
                                 if ($final_missing <= $threadhold3) {
                                     $missing_color = true;
                                     //echo 'c';
                                 }
                                 // if pass
                                 if ($final_overlap >= $threadhold1 && $final_missing <= $threadhold3 && $final_excess <= $threadhold2) {
                                     $next = 1;
                                     //go to the oars
                                     $result_comment = get_lang('Acceptable');
                                     $final_answer = 1;
                                     // do not update with  update_exercise_attempt
                                 } else {
                                     $next = 0;
                                     $result_comment = get_lang('Unacceptable');
                                     $comment = $answerDestination = $objAnswerTmp->selectComment(1);
                                     $answerDestination = $objAnswerTmp->selectDestination(1);
                                     //checking the destination parameters parsing the "@@"
                                     $destination_items = explode('@@', $answerDestination);
                                 }
                             } elseif ($answerId > 1) {
                                 if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') {
                                     if ($debug > 0) {
                                         error_log(__LINE__ . ' - answerId is of type noerror', 0);
                                     }
                                     //type no error shouldn't be treated
                                     $next = 1;
                                     continue;
                                 }
                                 if ($debug > 0) {
                                     error_log(__LINE__ . ' - answerId is >1 so we\'re probably in OAR', 0);
                                 }
                                 //check the intersection between the oar and the user
                                 //echo 'user';	print_r($x_user_list);		print_r($y_user_list);
                                 //echo 'official';print_r($x_list);print_r($y_list);
                                 //$result = get_intersection_data($x_list,$y_list,$x_user_list,$y_user_list);
                                 $inter = $result['success'];
                                 //$delineation_cord=$objAnswerTmp->selectHotspotCoordinates($answerId);
                                 $delineation_cord = $objAnswerTmp->selectHotspotCoordinates($answerId);
                                 $poly_answer = convert_coordinates($delineation_cord, '|');
                                 $max_coord = poly_get_max($poly_user, $poly_answer);
                                 $poly_answer_compiled = poly_compile($poly_answer, $max_coord);
                                 $overlap = poly_touch($poly_user_compiled, $poly_answer_compiled, $max_coord);
                                 if ($overlap == false) {
                                     //all good, no overlap
                                     $next = 1;
                                     continue;
                                 } else {
                                     if ($debug > 0) {
                                         error_log(__LINE__ . ' - Overlap is ' . $overlap . ': OAR hit', 0);
                                     }
                                     $organs_at_risk_hit++;
                                     //show the feedback
                                     $next = 0;
                                     $comment = $answerDestination = $objAnswerTmp->selectComment($answerId);
                                     $answerDestination = $objAnswerTmp->selectDestination($answerId);
                                     $destination_items = explode('@@', $answerDestination);
                                     $try_hotspot = $destination_items[1];
                                     $lp_hotspot = $destination_items[2];
                                     $select_question_hotspot = $destination_items[3];
                                     $url_hotspot = $destination_items[4];
                                 }
                             }
                         } else {
                             // the first delineation feedback
                             if ($debug > 0) {
                                 error_log(__LINE__ . ' first', 0);
                             }
                         }
                         break;
                     case HOT_SPOT_ORDER:
                         ExerciseShowFunctions::display_hotspot_order_answer($feedback_type, $answerId, $answer, $studentChoice, $answerComment);
                         break;
                     case DRAGGABLE:
                         //no break
                     //no break
                     case MATCHING_DRAGGABLE:
                         //no break
                     //no break
                     case MATCHING:
                         echo '<tr>';
                         echo Display::tag('td', $answerMatching[$answerId]);
                         echo Display::tag('td', "{$user_answer} / " . Display::tag('strong', $answerMatching[$answerCorrect], ['style' => 'color: #008000; font-weight: bold;']));
                         echo '</tr>';
                         break;
                 }
             }
         }
         if ($debug) {
             error_log(' ------ ');
         }
     }
     // end for that loops over all answers of the current question
     if ($debug) {
         error_log('-- end answer loop --');
     }
     $final_answer = true;
     foreach ($real_answers as $my_answer) {
         if (!$my_answer) {
             $final_answer = false;
         }
     }
     //we add the total score after dealing with the answers
     if ($answerType == MULTIPLE_ANSWER_COMBINATION || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
         if ($final_answer) {
             //getting only the first score where we save the weight of all the question
             $answerWeighting = $objAnswerTmp->selectWeighting(1);
             $questionScore += $answerWeighting;
             $totalScore += $answerWeighting;
         }
     }
     //Fixes multiple answer question in order to be exact
     //if ($answerType == MULTIPLE_ANSWER || $answerType == GLOBAL_MULTIPLE_ANSWER) {
     /* if ($answerType == GLOBAL_MULTIPLE_ANSWER) {
                 $diff = @array_diff($answer_correct_array, $real_answers);
     
                 // All good answers or nothing works like exact
     
                 $counter = 1;
                 $correct_answer = true;
                 foreach ($real_answers as $my_answer) {
                     if ($debug)
                         error_log(" my_answer: $my_answer answer_correct_array[counter]: ".$answer_correct_array[$counter]);
                     if ($my_answer != $answer_correct_array[$counter]) {
                         $correct_answer = false;
                         break;
                     }
                     $counter++;
                 }
     
                 if ($debug) error_log(" answer_correct_array: ".print_r($answer_correct_array, 1)."");
                 if ($debug) error_log(" real_answers: ".print_r($real_answers, 1)."");
                 if ($debug) error_log(" correct_answer: ".$correct_answer);
     
                 if ($correct_answer == false) {
                     $questionScore = 0;
                 }
     
                 // This makes the result non exact
                 if (!empty($diff)) {
                     $questionScore = 0;
                 }
             }*/
     $extra_data = array('final_overlap' => $final_overlap, 'final_missing' => $final_missing, 'final_excess' => $final_excess, 'overlap_color' => $overlap_color, 'missing_color' => $missing_color, 'excess_color' => $excess_color, 'threadhold1' => $threadhold1, 'threadhold2' => $threadhold2, 'threadhold3' => $threadhold3);
     if ($from == 'exercise_result') {
         // if answer is hotspot. To the difference of exercise_show.php,
         //  we use the results from the session (from_db=0)
         // TODO Change this, because it is wrong to show the user
         //  some results that haven't been stored in the database yet
         if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER || $answerType == HOT_SPOT_DELINEATION) {
             if ($debug) {
                 error_log('$from AND this is a hotspot kind of question ');
             }
             $my_exe_id = 0;
             $from_database = 0;
             if ($answerType == HOT_SPOT_DELINEATION) {
                 if (0) {
                     if ($overlap_color) {
                         $overlap_color = 'green';
                     } else {
                         $overlap_color = 'red';
                     }
                     if ($missing_color) {
                         $missing_color = 'green';
                     } else {
                         $missing_color = 'red';
                     }
                     if ($excess_color) {
                         $excess_color = 'green';
                     } else {
                         $excess_color = 'red';
                     }
                     if (!is_numeric($final_overlap)) {
                         $final_overlap = 0;
                     }
                     if (!is_numeric($final_missing)) {
                         $final_missing = 0;
                     }
                     if (!is_numeric($final_excess)) {
                         $final_excess = 0;
                     }
                     if ($final_overlap > 100) {
                         $final_overlap = 100;
                     }
                     $table_resume = '<table class="data_table">
                             <tr class="row_odd" >
                                 <td></td>
                                 <td ><b>' . get_lang('Requirements') . '</b></td>
                                 <td><b>' . get_lang('YourAnswer') . '</b></td>
                             </tr>
                             <tr class="row_even">
                                 <td><b>' . get_lang('Overlap') . '</b></td>
                                 <td>' . get_lang('Min') . ' ' . $threadhold1 . '</td>
                                 <td><div style="color:' . $overlap_color . '">' . ($final_overlap < 0 ? 0 : intval($final_overlap)) . '</div></td>
                             </tr>
                             <tr>
                                 <td><b>' . get_lang('Excess') . '</b></td>
                                 <td>' . get_lang('Max') . ' ' . $threadhold2 . '</td>
                                 <td><div style="color:' . $excess_color . '">' . ($final_excess < 0 ? 0 : intval($final_excess)) . '</div></td>
                             </tr>
                             <tr class="row_even">
                                 <td><b>' . get_lang('Missing') . '</b></td>
                                 <td>' . get_lang('Max') . ' ' . $threadhold3 . '</td>
                                 <td><div style="color:' . $missing_color . '">' . ($final_missing < 0 ? 0 : intval($final_missing)) . '</div></td>
                             </tr>
                         </table>';
                     if ($next == 0) {
                         $try = $try_hotspot;
                         $lp = $lp_hotspot;
                         $destinationid = $select_question_hotspot;
                         $url = $url_hotspot;
                     } else {
                         //show if no error
                         //echo 'no error';
                         $comment = $answerComment = $objAnswerTmp->selectComment($nbrAnswers);
                         $answerDestination = $objAnswerTmp->selectDestination($nbrAnswers);
                     }
                     echo '<h1><div style="color:#333;">' . get_lang('Feedback') . '</div></h1>
                         <p style="text-align:center">';
                     $message = '<p>' . get_lang('YourDelineation') . '</p>';
                     $message .= $table_resume;
                     $message .= '<br />' . get_lang('ResultIs') . ' ' . $result_comment . '<br />';
                     if ($organs_at_risk_hit > 0) {
                         $message .= '<p><b>' . get_lang('OARHit') . '</b></p>';
                     }
                     $message .= '<p>' . $comment . '</p>';
                     echo $message;
                 } else {
                     echo $hotspot_delineation_result[0];
                     //prints message
                     $from_database = 1;
                     // the hotspot_solution.swf needs this variable
                 }
                 //save the score attempts
                 if (1) {
                     //getting the answer 1 or 0 comes from exercise_submit_modal.php
                     $final_answer = $hotspot_delineation_result[1];
                     if ($final_answer == 0) {
                         $questionScore = 0;
                     }
                     // we always insert the answer_id 1 = delineation
                     Event::saveQuestionAttempt($questionScore, 1, $quesId, $exeId, 0);
                     //in delineation mode, get the answer from $hotspot_delineation_result[1]
                     Event::saveExerciseAttemptHotspot($exeId, $quesId, 1, $hotspot_delineation_result[1], $exerciseResultCoordinates[$quesId]);
                 } else {
                     if ($final_answer == 0) {
                         $questionScore = 0;
                         $answer = 0;
                         Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0);
                         if (is_array($exerciseResultCoordinates[$quesId])) {
                             foreach ($exerciseResultCoordinates[$quesId] as $idx => $val) {
                                 Event::saveExerciseAttemptHotspot($exeId, $quesId, $idx, 0, $val);
                             }
                         }
                     } else {
                         Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0);
                         if (is_array($exerciseResultCoordinates[$quesId])) {
                             foreach ($exerciseResultCoordinates[$quesId] as $idx => $val) {
                                 Event::saveExerciseAttemptHotspot($exeId, $quesId, $idx, $choice[$idx], $val);
                             }
                         }
                     }
                 }
                 $my_exe_id = $exeId;
             }
         }
         if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER) {
             // We made an extra table for the answers
             if ($show_result) {
                 //	if ($origin != 'learnpath') {
                 echo '</table></td></tr>';
                 echo "\n                        <tr>\n                            <td colspan=\"2\">\n                                <p><em>" . get_lang('HotSpot') . "</em></p>\n                                <div id=\"hotspot-solution-{$questionId}\"></div>\n\n                                <script>\n                                    \$(document).on('ready', function () {\n                                        new HotspotQuestion({\n                                            questionId: {$questionId},\n                                            exerciseId: {$exeId},\n                                            selector: '#hotspot-solution-{$questionId}',\n                                            for: 'solution'\n                                        });\n                                    });\n                                </script>\n                            </td>\n                        </tr>\n                    ";
                 //	}
             }
         }
         //if ($origin != 'learnpath') {
         if ($show_result) {
             echo '</table>';
         }
         //	}
     }
     unset($objAnswerTmp);
     $totalWeighting += $questionWeighting;
     // Store results directly in the database
     // For all in one page exercises, the results will be
     // stored by exercise_results.php (using the session)
     if ($saved_results) {
         if ($debug) {
             error_log("Save question results {$saved_results}");
         }
         if ($debug) {
             error_log(print_r($choice, 1));
         }
         if (empty($choice)) {
             $choice = 0;
         }
         if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
             if ($choice != 0) {
                 $reply = array_keys($choice);
                 for ($i = 0; $i < sizeof($reply); $i++) {
                     $ans = $reply[$i];
                     Event::saveQuestionAttempt($questionScore, $ans . ':' . $choice[$ans], $quesId, $exeId, $i, $this->id);
                     if ($debug) {
                         error_log('result =>' . $questionScore . ' ' . $ans . ':' . $choice[$ans]);
                     }
                 }
             } else {
                 Event::saveQuestionAttempt($questionScore, 0, $quesId, $exeId, 0, $this->id);
             }
         } elseif ($answerType == MULTIPLE_ANSWER || $answerType == GLOBAL_MULTIPLE_ANSWER) {
             if ($choice != 0) {
                 $reply = array_keys($choice);
                 if ($debug) {
                     error_log("reply " . print_r($reply, 1) . "");
                 }
                 for ($i = 0; $i < sizeof($reply); $i++) {
                     $ans = $reply[$i];
                     Event::saveQuestionAttempt($questionScore, $ans, $quesId, $exeId, $i, $this->id);
                 }
             } else {
                 Event::saveQuestionAttempt($questionScore, 0, $quesId, $exeId, 0, $this->id);
             }
         } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION) {
             if ($choice != 0) {
                 $reply = array_keys($choice);
                 for ($i = 0; $i < sizeof($reply); $i++) {
                     $ans = $reply[$i];
                     Event::saveQuestionAttempt($questionScore, $ans, $quesId, $exeId, $i, $this->id);
                 }
             } else {
                 Event::saveQuestionAttempt($questionScore, 0, $quesId, $exeId, 0, $this->id);
             }
         } elseif (in_array($answerType, [MATCHING, DRAGGABLE, MATCHING_DRAGGABLE])) {
             if (isset($matching)) {
                 foreach ($matching as $j => $val) {
                     Event::saveQuestionAttempt($questionScore, $val, $quesId, $exeId, $j, $this->id);
                 }
             }
         } elseif ($answerType == FREE_ANSWER) {
             $answer = $choice;
             Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0, $this->id);
         } elseif ($answerType == ORAL_EXPRESSION) {
             $answer = $choice;
             Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0, $this->id, $nano);
         } elseif (in_array($answerType, [UNIQUE_ANSWER, UNIQUE_ANSWER_IMAGE, UNIQUE_ANSWER_NO_OPTION])) {
             $answer = $choice;
             Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0, $this->id);
             //            } elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_DELINEATION) {
         } elseif ($answerType == HOT_SPOT) {
             $answer = [];
             if (isset($exerciseResultCoordinates[$questionId]) && !empty($exerciseResultCoordinates[$questionId])) {
                 Database::delete(Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT), ['hotspot_exe_id = ? AND hotspot_question_id = ? AND c_id = ?' => [$exeId, $questionId, api_get_course_int_id()]]);
                 foreach ($exerciseResultCoordinates[$questionId] as $idx => $val) {
                     $answer[] = $val;
                     Event::saveExerciseAttemptHotspot($exeId, $quesId, $idx, $choice[$idx], $val, false, $this->id);
                 }
             }
             Event::saveQuestionAttempt($questionScore, implode('|', $answer), $quesId, $exeId, 0, $this->id);
         } else {
             Event::saveQuestionAttempt($questionScore, $answer, $quesId, $exeId, 0, $this->id);
         }
     }
     if ($propagate_neg == 0 && $questionScore < 0) {
         $questionScore = 0;
     }
     if ($saved_results) {
         $stat_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
         $sql = 'UPDATE ' . $stat_table . ' SET
                     exe_result = exe_result + ' . floatval($questionScore) . '
                 WHERE exe_id = ' . $exeId;
         if ($debug) {
             error_log($sql);
         }
         Database::query($sql);
     }
     $return_array = array('score' => $questionScore, 'weight' => $questionWeighting, 'extra' => $extra_data, 'open_question' => $arrques, 'open_answer' => $arrans, 'answer_type' => $answerType);
     return $return_array;
 }
Exemplo n.º 29
0
/**
 * This function retrieves all the personal agenda items of the user and shows
 * these items in one list (ordered by date and grouped by month (the month_bar)
 */
function show_personal_agenda()
{
    global $MonthsLong, $charset;
    $tbl_personal_agenda = Database::get_main_table(TABLE_PERSONAL_AGENDA);
    // The SQL statement that retrieves all the personal agenda items of this user
    $sql = "SELECT * FROM " . $tbl_personal_agenda . " WHERE user='******' ORDER BY date DESC";
    $result = Database::query($sql);
    // variable initialisation
    $month_bar = "";
    // setting the default day, month and year
    if (!isset($_GET['day']) and !isset($_GET['month']) and !isset($_GET['year'])) {
        $today = getdate();
        $year = $today['year'];
        $month = $today['mon'];
        $day = $today['mday'];
    }
    $export_icon = 'export.png';
    $export_icon_low = 'export_low_fade.png';
    $export_icon_high = 'export_high_fade.png';
    // starting the table output
    echo '<table class="data_table">';
    $th = Display::tag('th', get_lang('Title'));
    $th .= Display::tag('th', get_lang('Content'));
    $th .= Display::tag('th', get_lang('StartTimeWindow'));
    $th .= Display::tag('th', get_lang('Modify'));
    echo Display::tag('tr', $th);
    if (Database::num_rows($result) > 0) {
        $counter = 0;
        while ($myrow = Database::fetch_array($result)) {
            /* 	display: the month bar		*/
            if ($month_bar != date("m", strtotime($myrow["date"])) . date("Y", strtotime($myrow["date"]))) {
                $month_bar = date("m", strtotime($myrow["date"])) . date("Y", strtotime($myrow["date"]));
                //echo "<tr><th class=\"title\" colspan=\"2\" class=\"month\" valign=\"top\">".$MonthsLong[date("n", strtotime($myrow["date"])) - 1]." ".date("Y", strtotime($myrow["date"]))."</th></tr>";
            }
            // highlight: if a date in the small calendar is clicked we highlight the relevant items
            $db_date = (int) date("d", strtotime($myrow["date"])) . date("n", strtotime($myrow["date"])) . date("Y", strtotime($myrow["date"]));
            /*
            			if ($_GET["day"].$_GET["month"].$_GET["year"] <> $db_date) {
            				$style = "data";
            				$text_style = "text";
            			} else {
            				$style = "datanow";
            				$text_style = "text";
            			}*/
            $class = 'row_even';
            if ($counter % 2) {
                $class = 'row_odd';
            }
            echo '<tr class="' . $class . '">';
            echo '<td>';
            /*   display: the title  */
            echo $myrow['title'];
            echo "</td>";
            // display: the content
            $content = $myrow['text'];
            echo "<td>";
            echo $content;
            echo "</td>";
            //display: date and time
            echo '<td>';
            // adding an internal anchor
            /*echo "<a name=\"".$myrow["id"]."\"></a>";
            		echo date("d", strtotime($myrow["date"]))." ".$MonthsLong[date("n", strtotime($myrow["date"])) - 1]." ".date("Y", strtotime($myrow["date"]))."&nbsp;";*/
            $myrow["date"] = api_get_local_time($myrow["date"]);
            echo api_format_date($myrow["date"], DATE_TIME_FORMAT_LONG);
            echo "</td>";
            //echo '<td></td>'; //remove when enabling ical
            //echo '<td class="'.$style.'">';
            //echo '<a class="ical_export" href="ical_export.php?type=personal&id='.$myrow['id'].'&class=confidential" title="'.get_lang('ExportiCalConfidential').'">'.Display::return_icon($export_icon_high, get_lang('ExportiCalConfidential')).'</a>';
            //echo '<a class="ical_export" href="ical_export.php?type=personal&id='.$myrow['id'].'&class=private" title="'.get_lang('ExportiCalPrivate').'">'.Display::return_icon($export_icon_low, get_lang('ExportiCalPrivate')).'</a>';
            //echo '<a class="ical_export" href="ical_export.php?type=personal&id='.$myrow['id'].'&class=public" title="'.get_lang('ExportiCalPublic').'">'.Display::return_icon($export_icon, get_lang('ExportiCalPublic')).'</a>';
            //echo "</td>";
            //echo "</tr>";
            /* display: the edit / delete icons */
            echo "<td>";
            echo "<a href=\"myagenda.php?action=edit_personal_agenda_item&amp;id=" . $myrow['id'] . "\">" . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . "</a> ";
            echo "<a href=\"" . api_get_self() . "?action=delete&amp;id=" . $myrow['id'] . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)) . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . "</a>";
            echo "</td></tr>";
            $counter++;
        }
    } else {
        echo '<tr><td colspan="2">' . get_lang('NoAgendaItems') . '</td></tr>';
    }
    echo "</table>";
}
Exemplo n.º 30
0
 /**
  * display user dashboard list
  * @param int  User id
  * @return void
  */
 public static function display_user_dashboard_list($user_id)
 {
     $enabled_dashboard_plugins = self::get_enabled_dashboard_blocks();
     $user_block_data = self::get_user_block_data($user_id);
     if (count($enabled_dashboard_plugins) > 0) {
         echo '<div style="margin-top:20px">';
         echo '<div><strong>' . get_lang('SelectBlockForDisplayingInsideBlocksDashboardView') . '</strong></div><br />';
         echo '<form name="dashboard_list" method="post" action="index.php?action=store_user_block">';
         echo '<table class="data_table">';
         echo '<tr>';
         echo '<th width="5%">';
         echo get_lang('Enabled');
         echo '</th>';
         echo '<th width="30%">';
         echo get_lang('Name');
         echo '</th>';
         echo '<th width="40%">';
         echo get_lang('Description');
         echo '</th>';
         echo '<th>';
         echo get_lang('ColumnPosition');
         echo '</th>';
         echo '</tr>';
         // We display all enabled plugins and the checkboxes
         foreach ($enabled_dashboard_plugins as $block) {
             $path = $block['path'];
             $controller_class = $block['controller'];
             $filename_controller = $path . '.class.php';
             $dashboard_plugin_path = api_get_path(SYS_PLUGIN_PATH) . 'dashboard/' . $path . '/';
             require_once $dashboard_plugin_path . $filename_controller;
             if (class_exists($controller_class)) {
                 $obj_block = new $controller_class($user_id);
                 // check if user is allowed to see the block
                 if (method_exists($obj_block, 'is_block_visible_for_user')) {
                     $is_block_visible_for_user = $obj_block->is_block_visible_for_user($user_id);
                     if (!$is_block_visible_for_user) {
                         continue;
                     }
                 }
                 echo '<tr>';
                 // checkboxes
                 self::display_user_dashboard_list_checkboxes($user_id, $block['id']);
                 echo '<td>' . $block['name'] . '</td>';
                 echo '<td>' . $block['description'] . '</td>';
                 echo '<td>
                         <select name="columns[' . $block['id'] . ']">
                         <option value="1" ' . (isset($user_block_data[$block['id']]) && $user_block_data[$block['id']]['column'] == 1 ? 'selected' : '') . ' >1</option>
                         <option value="2" ' . (isset($user_block_data[$block['id']]) && $user_block_data[$block['id']]['column'] == 2 ? 'selected' : '') . ' >2</option>
                         </select>
                       </td>';
                 echo '</tr>';
             } else {
                 echo Display::tag('tr', Display::tag('td', get_lang('Error') . ' ' . $controller_class, array('colspan' => '3')));
             }
         }
         echo '</table>';
         echo '<br />';
         echo '<button class="btn btn-default" type="submit" name="submit_dashboard_list" value="' . get_lang('EnableDashboardBlock') . '">' . get_lang('EnableDashboardBlock') . '</button></form>';
         echo '</div>';
     } else {
         echo '<div style="margin-top:20px">' . get_lang('ThereAreNoEnabledDashboardPlugins') . '</div>';
         if (api_is_platform_admin()) {
             echo '<a class="btn btn-default" href="' . api_get_path(WEB_CODE_PATH) . 'admin/settings.php?category=Plugins">' . get_lang('ConfigureDashboardPlugin') . '</a>';
         }
     }
 }