コード例 #1
0
ファイル: social.lib.php プロジェクト: jloguercio/chamilo-lms
 /**
  * @param int $user_id
  * @param $link_shared
  * @param $show_full_profile
  * @return string
  */
 public static function listMyFriends($user_id, $link_shared, $show_full_profile)
 {
     //SOCIALGOODFRIEND , USER_RELATION_TYPE_FRIEND, USER_RELATION_TYPE_PARENT
     $friends = SocialManager::get_friends($user_id, USER_RELATION_TYPE_FRIEND);
     $number_of_images = 30;
     $number_friends = count($friends);
     $friendHtml = '';
     if ($number_friends != 0) {
         if ($number_friends > $number_of_images) {
             if (api_get_user_id() == $user_id) {
                 $friendHtml .= ' <span><a href="friends.php">' . get_lang('SeeAll') . '</a></span>';
             } else {
                 $friendHtml .= ' <span>' . '<a href="' . api_get_path(WEB_CODE_PATH) . 'social/profile_friends_and_groups.inc.php' . '?view=friends&height=390&width=610&user_id=' . $user_id . '"' . 'class="ajax" data-title="' . get_lang('SeeAll') . '" title="' . get_lang('SeeAll') . '" >' . get_lang('SeeAll') . '</a></span>';
             }
         }
         $friendHtml .= '<ul class="nav nav-list">';
         $j = 1;
         for ($k = 0; $k < $number_friends; $k++) {
             if ($j > $number_of_images) {
                 break;
             }
             if (isset($friends[$k])) {
                 $friend = $friends[$k];
                 $name_user = api_get_person_name($friend['firstName'], $friend['lastName']);
                 $user_info_friend = api_get_user_info($friend['friend_user_id'], true);
                 if ($user_info_friend['user_is_online']) {
                     $statusIcon = Display::span('', array('class' => 'online_user_in_text'));
                 } else {
                     $statusIcon = Display::span('', array('class' => 'offline_user_in_text'));
                 }
                 $friendHtml .= '<li>';
                 $friendHtml .= '<div>';
                 // the height = 92 must be the same in the image_friend_network span style in default.css
                 $friends_profile = UserManager::getUserPicture($friend['friend_user_id'], USER_IMAGE_SIZE_SMALL);
                 $friendHtml .= '<img src="' . $friends_profile . '" id="imgfriend_' . $friend['friend_user_id'] . '" title="' . $name_user . '"/>';
                 $link_shared = empty($link_shared) ? '' : '&' . $link_shared;
                 $friendHtml .= $statusIcon . '<a href="profile.php?' . 'u=' . $friend['friend_user_id'] . $link_shared . '">' . $name_user . '</a>';
                 $friendHtml .= '</div>';
                 $friendHtml .= '</li>';
             }
             $j++;
         }
         $friendHtml .= '</ul>';
     } else {
         $friendHtml .= '<div class="">' . get_lang('NoFriendsInYourContactList') . '<br />' . '<a class="btn btn-primary" href="' . api_get_path(WEB_PATH) . 'whoisonline.php"><em class="fa fa-search"></em> ' . get_lang('TryAndFindSomeFriends') . '</a></div>';
     }
     $friendHtml = Display::panel($friendHtml, get_lang('SocialFriend') . ' (' . $number_friends . ')');
     return $friendHtml;
 }
コード例 #2
0
    /**
     * Return the five star HTML
     *
     * @param  string  id of the rating ul element
     * @param  string  url that will be added (for jquery see hot_courses.tpl)
     * @param	string	point info array see function CourseManager::get_course_ranking()
     * @param	bool	add a div wrapper
     * @todo	use     templates
     **/
    public static function return_rating_system($id, $url, $point_info = array(), $add_div_wrapper = true)
    {
        $number_of_users_who_voted = isset($point_info['users_who_voted']) ? $point_info['users_who_voted'] : null;
        $percentage = isset($point_info['point_average']) ? $point_info['point_average'] : 0;
        if (!empty($percentage)) {
            $percentage = $percentage * 125 / 100;
        }
        $accesses = isset($point_info['accesses']) ? $point_info['accesses'] : 0;
        $star_label = sprintf(get_lang('XStarsOutOf5'), $point_info['point_average_star']);
        $html = '<ul id="' . $id . '" class="star-rating">
					<li class="current-rating" style="width:' . $percentage . 'px;"></li>
					<li><a href="javascript:void(0);" data-link="' . $url . '&amp;star=1" title="' . $star_label . '" class="one-star">1</a></li>
					<li><a href="javascript:void(0);" data-link="' . $url . '&amp;star=2" title="' . $star_label . '" class="two-stars">2</a></li>
					<li><a href="javascript:void(0);" data-link="' . $url . '&amp;star=3" title="' . $star_label . '" class="three-stars">3</a></li>
					<li><a href="javascript:void(0);" data-link="' . $url . '&amp;star=4" title="' . $star_label . '" class="four-stars">4</a></li>
					<li><a href="javascript:void(0);" data-link="' . $url . '&amp;star=5" title="' . $star_label . '" class="five-stars">5</a></li>
				</ul>';
        $labels = array();
        $labels[] = $number_of_users_who_voted == 1 ? $number_of_users_who_voted . ' ' . get_lang('Vote') : $number_of_users_who_voted . ' ' . get_lang('Votes');
        $labels[] = $accesses == 1 ? $accesses . ' ' . get_lang('Visit') : $accesses . ' ' . get_lang('Visits');
        if (!empty($number_of_users_who_voted)) {
            $labels[] = get_lang('Average') . ' ' . $point_info['point_average_star'] . '/5';
        }
        $labels[] = $point_info['user_vote'] ? get_lang('YourVote') . ' [' . $point_info['user_vote'] . ']' : get_lang('YourVote') . ' [?] ';
        if (!$add_div_wrapper && api_is_anonymous()) {
            $labels[] = Display::tag('span', get_lang('LoginToVote'), array('class' => 'error'));
        }
        $html .= Display::span(implode(' | ', $labels), array('id' => 'vote_label_' . $id, 'class' => 'vote_label_info'));
        $html .= ' ' . Display::span(' ', array('id' => 'vote_label2_' . $id));
        if ($add_div_wrapper) {
            $html = Display::div($html, array('id' => 'rating_wrapper_' . $id));
        }
        return $html;
    }
コード例 #3
0
ファイル: work.lib.php プロジェクト: omaoibrahim/chamilo-lms
/**
 * @param int $start
 * @param int $limit
 * @param int $column
 * @param string $direction
 * @param int $work_id
 * @param array $where_condition
 * @param int $studentId
 * @param bool $getCount
 * @return array
 */
function get_work_user_list($start, $limit, $column, $direction, $work_id, $where_condition = null, $studentId = null, $getCount = false)
{
    $work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
    $iprop_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
    $user_table = Database::get_main_table(TABLE_MAIN_USER);
    $session_id = api_get_session_id();
    $group_id = api_get_group_id();
    $course_info = api_get_course_info();
    $course_id = $course_info['real_id'];
    $work_id = intval($work_id);
    $column = !empty($column) ? Database::escape_string($column) : 'sent_date';
    $start = intval($start);
    $limit = intval($limit);
    if (!in_array($direction, array('asc', 'desc'))) {
        $direction = 'desc';
    }
    $work_data = get_work_data_by_id($work_id);
    $is_allowed_to_edit = api_is_allowed_to_edit() || api_is_coach();
    $condition_session = api_get_session_condition($session_id, true, false, 'work.session_id');
    $locked = api_resource_is_locked_by_gradebook($work_id, LINK_STUDENTPUBLICATION);
    $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(api_get_user_id(), $course_info);
    if (!empty($work_data)) {
        if (!empty($group_id)) {
            $extra_conditions = " work.post_group_id = '" . intval($group_id) . "' ";
            // set to select only messages posted by the user's group
        } else {
            $extra_conditions = " work.post_group_id = '0' ";
        }
        if ($is_allowed_to_edit || $isDrhOfCourse) {
            $extra_conditions .= ' AND work.active IN (0, 1) ';
        } else {
            if (isset($course_info['show_score']) && $course_info['show_score'] == 1) {
                $extra_conditions .= " AND (u.user_id = " . api_get_user_id() . " AND work.active IN (0, 1)) ";
            } else {
                $extra_conditions .= ' AND work.active IN (0, 1) ';
            }
        }
        $extra_conditions .= " AND parent_id  = " . $work_id . " ";
        $select = 'SELECT DISTINCT
                        u.user_id,
                        work.id as id,
                        title as title,
                        description,
                        url,
                        sent_date,
                        contains_file,
                        has_properties,
                        view_properties,
                        qualification,
                        weight,
                        allow_text_assignment,
                        u.firstname,
                        u.lastname,
                        u.username,
                        parent_id,
                        accepted,
                        qualificator_id,
                        url_correction
                        ';
        if ($getCount) {
            $select = "SELECT DISTINCT count(u.user_id) as count ";
        }
        $user_condition = "INNER JOIN {$user_table} u  ON (work.user_id = u.user_id) ";
        $work_condition = "{$iprop_table} prop INNER JOIN {$work_table} work\n                           ON (prop.ref = work.id AND prop.c_id = {$course_id} AND work.c_id = {$course_id} ) ";
        $work_assignment = get_work_assignment_by_id($work_id);
        if (!empty($studentId)) {
            $where_condition .= " AND u.user_id = " . intval($studentId);
        }
        $sql = " {$select}\n                FROM {$work_condition}  {$user_condition}\n                WHERE {$extra_conditions} {$where_condition} {$condition_session}\n                    AND u.status != " . INVITEE . "\n                ORDER BY {$column} {$direction}";
        if (!empty($start) && !empty($limit)) {
            $sql .= " LIMIT {$start}, {$limit}";
        }
        $result = Database::query($sql);
        $works = array();
        if ($getCount) {
            $work = Database::fetch_array($result, 'ASSOC');
            return $work['count'];
        }
        $url = api_get_path(WEB_CODE_PATH) . 'work/';
        $unoconv = api_get_configuration_value('unoconv.binaries');
        while ($work = Database::fetch_array($result, 'ASSOC')) {
            $item_id = $work['id'];
            // Get the author ID for that document from the item_property table
            $is_author = false;
            $can_read = false;
            $owner_id = $work['user_id'];
            /* Because a bug found when saving items using the api_item_property_update()
               the field $item_property_data['insert_user_id'] is not reliable. */
            if (!$is_allowed_to_edit && $owner_id == api_get_user_id()) {
                $is_author = true;
            }
            if ($course_info['show_score'] == 0) {
                $can_read = true;
            }
            if ($work['accepted'] == '0') {
                $class = 'invisible';
            } else {
                $class = '';
            }
            $qualification_exists = false;
            if (!empty($work_data['qualification']) && intval($work_data['qualification']) > 0) {
                $qualification_exists = true;
            }
            $qualification_string = '';
            if ($qualification_exists) {
                if ($work['qualification'] == '') {
                    $qualification_string = Display::label('-');
                } else {
                    $label = 'info';
                    $relativeScore = $work['qualification'] / $work_data['qualification'];
                    if ($relativeScore < 0.5) {
                        $label = 'important';
                    } elseif ($relativeScore < 0.75) {
                        $label = 'warning';
                    }
                    $qualification_string = Display::label($work['qualification'] . ' / ' . $work_data['qualification'], $label);
                }
            }
            $work['qualification_score'] = $work['qualification'];
            $add_string = '';
            $time_expires = '';
            if (!empty($work_assignment['expires_on'])) {
                $time_expires = api_strtotime($work_assignment['expires_on'], 'UTC');
            }
            if (!empty($work_assignment['expires_on']) && !empty($time_expires) && $time_expires < api_strtotime($work['sent_date'], 'UTC')) {
                $add_string = Display::label(get_lang('Expired'), 'important');
            }
            if ($can_read && $work['accepted'] == '1' || $is_author && in_array($work['accepted'], array('1', '0')) || ($is_allowed_to_edit || api_is_drh())) {
                // Firstname, lastname, username
                $work['firstname'] = Display::div($work['firstname'], array('class' => $class));
                $work['lastname'] = Display::div($work['lastname'], array('class' => $class));
                $work['title_clean'] = $work['title'];
                if (strlen($work['title']) > 30) {
                    $short_title = substr($work['title'], 0, 27) . '...';
                    $work['title'] = Display::span($short_title, array('class' => $class, 'title' => $work['title']));
                } else {
                    $work['title'] = Display::div($work['title'], array('class' => $class));
                }
                // Type.
                $work['type'] = DocumentManager::build_document_icon_tag('file', $work['url']);
                // File name.
                $link_to_download = null;
                // If URL is present then there's a file to download keep BC.
                if ($work['contains_file'] || !empty($work['url'])) {
                    $link_to_download = '<a href="' . $url . 'download.php?id=' . $item_id . '&' . api_get_cidreq() . '">' . Display::return_icon('save.png', get_lang('Save'), array(), ICON_SIZE_SMALL) . '</a> ';
                }
                $send_to = Portfolio::share('work', $work['id'], array('style' => 'white-space:nowrap;'));
                $feedback = null;
                $count = getWorkCommentCount($item_id, $course_info);
                if (!is_null($count) && !empty($count)) {
                    if ($qualification_exists) {
                        $feedback .= "<br />";
                    }
                    $feedback .= '<a href="' . $url . 'view.php?' . api_get_cidreq() . '&id=' . $item_id . '" title="' . get_lang('View') . '">' . Display::label($count . ' ' . get_lang('Feedback'), 'info') . '</a> ';
                }
                $work['qualification'] = $qualification_string . $feedback;
                $work['qualification_only'] = $qualification_string;
                // Date.
                $work_date = api_convert_and_format_date($work['sent_date']);
                $work['sent_date_from_db'] = $work['sent_date'];
                $work['sent_date'] = '<div class="date-time">' . date_to_str_ago(api_get_local_time($work['sent_date'])) . ' ' . $add_string . ' ' . $work_date . '</div>';
                // Actions.
                $correction = '';
                $action = '';
                if (api_is_allowed_to_edit()) {
                    if (!empty($work['url_correction'])) {
                        $action .= Display::url(Display::return_icon('check-circle.png', get_lang('Correction'), null, ICON_SIZE_SMALL), api_get_path(WEB_CODE_PATH) . 'work/download.php?id=' . $item_id . '&' . api_get_cidreq() . '&correction=1');
                    }
                    $action .= '<a href="' . $url . 'view.php?' . api_get_cidreq() . '&id=' . $item_id . '" title="' . get_lang('View') . '">' . Display::return_icon('default.png', get_lang('View'), array(), ICON_SIZE_SMALL) . '</a> ';
                    if ($unoconv && empty($work['contains_file'])) {
                        $action .= '<a href="' . $url . 'work_list_all.php?' . api_get_cidreq() . '&id=' . $work_id . '&action=export_to_doc&item_id=' . $item_id . '" title="' . get_lang('ExportToDoc') . '" >' . Display::return_icon('export_doc.png', get_lang('ExportToDoc'), array(), ICON_SIZE_SMALL) . '</a> ';
                    }
                    $correction = '
                        <form
                        id="file_upload_' . $item_id . '"
                        class="work_correction_file_upload file_upload_small"
                        action="' . api_get_path(WEB_AJAX_PATH) . 'work.ajax.php?' . api_get_cidreq() . '&a=upload_correction_file&item_id=' . $item_id . '" method="POST" enctype="multipart/form-data"
                        >
                        <div class="button-load">
                            ' . get_lang('ClickOrDropFilesHere') . '
                        </div>
                        <input type="file" name="file" multiple>
                        <button type="submit"></button>
                        </form>
                    ';
                    $correction .= "\n                        <script>\n                        \$(document).ready(function() {\n                            \$('#file_upload_" . $item_id . "').fileupload({\n                                uploadTable: \$('.files'),\n                                downloadTable: \$('.files'),\n                                buildUploadRow: function (files, index) {\n                                    \$('.files').show();\n                                    return\n                                        \$('<tr><td>' + files[index].name + '<\\/td>' +\n                                        '<td class=\"file_upload_progress\"><div><\\/div><\\/td>' +\n                                        '<td class=\"file_upload_cancel\">' +\n                                        '<button class=\"ui-state-default ui-corner-all\" title=\"" . get_lang('Cancel') . "\">' +\n                                        '<span class=\"ui-icon ui-icon-cancel\">" . get_lang('Cancel') . "<\\/span>' +'<\\/button>'+\n                                        '<\\/td><\\/tr>');\n                                },\n                                buildDownloadRow: function (file) {\n                                    return \$('<tr><td>' + file.name + '<\\/td> <td> ' + file.size + ' <\\/td>  <td>&nbsp;' + file.result + ' <\\/td> <\\/tr>');\n                                }\n                            });\n                        });\n                        </script>\n                    ";
                    if ($locked) {
                        if ($qualification_exists) {
                            $action .= Display::return_icon('rate_work_na.png', get_lang('CorrectAndRate'), array(), ICON_SIZE_SMALL);
                        } else {
                            $action .= Display::return_icon('edit_na.png', get_lang('Comment'), array(), ICON_SIZE_SMALL);
                        }
                    } else {
                        if ($qualification_exists) {
                            $action .= '<a href="' . $url . 'edit.php?' . api_get_cidreq() . '&item_id=' . $item_id . '&id=' . $work['parent_id'] . '" title="' . get_lang('Edit') . '"  >' . Display::return_icon('rate_work.png', get_lang('CorrectAndRate'), array(), ICON_SIZE_SMALL) . '</a>';
                        } else {
                            $action .= '<a href="' . $url . 'edit.php?' . api_get_cidreq() . '&item_id=' . $item_id . '&id=' . $work['parent_id'] . '" title="' . get_lang('Modify') . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>';
                        }
                    }
                    if ($work['contains_file']) {
                        if ($locked) {
                            $action .= Display::return_icon('move_na.png', get_lang('Move'), array(), ICON_SIZE_SMALL);
                        } else {
                            $action .= '<a href="' . $url . 'work.php?' . api_get_cidreq() . '&action=move&item_id=' . $item_id . '&id=' . $work['parent_id'] . '" title="' . get_lang('Move') . '">' . Display::return_icon('move.png', get_lang('Move'), array(), ICON_SIZE_SMALL) . '</a>';
                        }
                    }
                    if ($work['accepted'] == '1') {
                        $action .= '<a href="' . $url . 'work_list_all.php?' . api_get_cidreq() . '&id=' . $work_id . '&action=make_invisible&item_id=' . $item_id . '" title="' . get_lang('Invisible') . '" >' . Display::return_icon('visible.png', get_lang('Invisible'), array(), ICON_SIZE_SMALL) . '</a>';
                    } else {
                        $action .= '<a href="' . $url . 'work_list_all.php?' . api_get_cidreq() . '&id=' . $work_id . '&action=make_visible&item_id=' . $item_id . '" title="' . get_lang('Visible') . '" >' . Display::return_icon('invisible.png', get_lang('Visible'), array(), ICON_SIZE_SMALL) . '</a> ';
                    }
                    if ($locked) {
                        $action .= Display::return_icon('delete_na.png', get_lang('Delete'), '', ICON_SIZE_SMALL);
                    } else {
                        $action .= '<a href="' . $url . 'work_list_all.php?' . api_get_cidreq() . '&id=' . $work_id . '&action=delete&item_id=' . $item_id . '" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)) . "'" . ')) return false;" title="' . get_lang('Delete') . '" >' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>';
                    }
                } elseif ($is_author && (empty($work['qualificator_id']) || $work['qualificator_id'] == 0)) {
                    $action .= '<a href="' . $url . 'view.php?' . api_get_cidreq() . '&id=' . $item_id . '" title="' . get_lang('View') . '">' . Display::return_icon('default.png', get_lang('View'), array(), ICON_SIZE_SMALL) . '</a>';
                    if (api_get_course_setting('student_delete_own_publication') == 1) {
                        if (api_is_allowed_to_session_edit(false, true)) {
                            $action .= '<a href="' . $url . 'edit.php?' . api_get_cidreq() . '&item_id=' . $item_id . '&id=' . $work['parent_id'] . '" title="' . get_lang('Modify') . '">' . Display::return_icon('edit.png', get_lang('Comment'), array(), ICON_SIZE_SMALL) . '</a>';
                        }
                        $action .= ' <a href="' . $url . 'work_list.php?' . api_get_cidreq() . '&action=delete&item_id=' . $item_id . '&id=' . $work['parent_id'] . '" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)) . "'" . ')) return false;" title="' . get_lang('Delete') . '"  >' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>';
                    } else {
                        $action .= Display::return_icon('edit_na.png', get_lang('Modify'), array(), ICON_SIZE_SMALL);
                    }
                } else {
                    $action .= '<a href="' . $url . 'view.php?' . api_get_cidreq() . '&id=' . $item_id . '" title="' . get_lang('View') . '">' . Display::return_icon('default.png', get_lang('View'), array(), ICON_SIZE_SMALL) . '</a>';
                    $action .= Display::return_icon('edit_na.png', get_lang('Modify'), array(), ICON_SIZE_SMALL);
                }
                // Status.
                if (empty($work['qualificator_id'])) {
                    $qualificator_id = Display::label(get_lang('NotRevised'), 'warning');
                } else {
                    $qualificator_id = Display::label(get_lang('Revised'), 'success');
                }
                $work['qualificator_id'] = $qualificator_id;
                $work['actions'] = $send_to . $link_to_download . $action;
                $work['correction'] = $correction;
                $works[] = $work;
            }
        }
        return $works;
    }
}
コード例 #4
0
ファイル: link.lib.php プロジェクト: feroli1000/chamilo-lms
 /**
  * Displays all the links of a given category.
  * @author Patrick Cool <*****@*****.**>, Ghent University
  */
 public static function showlinksofcategory($catid)
 {
     global $token;
     $_user = api_get_user_info();
     $course_id = api_get_course_int_id();
     $session_id = api_get_session_id();
     $catid = intval($catid);
     $tbl_link = Database::get_course_table(TABLE_LINK);
     $TABLE_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
     // Condition for the session.
     $condition_session = api_get_session_condition($session_id, true, true, 'link.session_id');
     $content = '';
     $sql = "SELECT *, link.id FROM {$tbl_link} link\n                INNER JOIN {$TABLE_ITEM_PROPERTY} itemproperties\n                ON (link.id=itemproperties.ref AND link.c_id = itemproperties.c_id )\n                WHERE\n                    itemproperties.tool='" . TOOL_LINK . "' AND\n                    link.category_id='" . $catid . "' AND\n                    (itemproperties.visibility='0' OR itemproperties.visibility='1')\n                    {$condition_session} AND\n                    link.c_id = " . $course_id . " AND\n                    itemproperties.c_id = " . $course_id . "\n                ORDER BY link.display_order DESC";
     $result = Database::query($sql);
     $numberoflinks = Database::num_rows($result);
     if ($numberoflinks > 0) {
         $content .= '<div class="link list-group">';
         $i = 1;
         while ($myrow = Database::fetch_array($result)) {
             // Validation when belongs to a session.
             $session_img = api_get_session_image($myrow['session_id'], $_user['status']);
             //$css_class = $i % 2 == 0 ? $css_class = 'row_odd' : $css_class = 'row_even';
             $toolbar = '';
             $link_validator = '';
             if (api_is_allowed_to_edit(null, true)) {
                 $toolbar .= Display::toolbarButton('', '#', 'retweet', 'default btn-sm', array('onclick' => "check_url('" . $myrow['id'] . "', '" . addslashes($myrow['url']) . "');", 'title' => get_lang('CheckURL')));
                 $link_validator .= Display::span('', array('id' => 'url_id_' . $myrow['id'], 'class' => 'check-link'));
             }
             if (api_is_allowed_to_edit(null, true)) {
                 if ($session_id == $myrow['session_id']) {
                     $url = api_get_self() . '?' . api_get_cidreq() . '&action=editlink&category=' . (!empty($category) ? $category : '') . '&id=' . $myrow['id'] . '&category_id=' . $myrow['id'];
                     $title = get_lang('Edit');
                     $toolbar .= Display::toolbarButton('', $url, 'pencil', 'default btn-sm', array('title' => $title));
                     // DISPLAY MOVE UP COMMAND only if it is not the top link.
                     /* commented at least since 2014-10-11
                                             if ($i != 1) {
                                                 echo '<a href="' . api_get_self() . '?' . api_get_cidreq() .  '&sec_token='.$token.'&urlview=' . $urlview . '&up=', $myrow[0], '" title="' . get_lang('Up') . '">' . Display :: return_icon('up.png', get_lang('Up'), array (), ICON_SIZE_SMALL) . '', "</a>\n";
                                             } else {
                                                 echo Display :: return_icon('up_na.png', get_lang('Up'), array (), ICON_SIZE_SMALL) . '</a>';
                                             }
                     
                                             // DISPLAY MOVE DOWN COMMAND only if it is not the bottom link.
                                             if ($i < $numberoflinks) {
                                                 echo '<a href="' . api_get_self() . '?' . api_get_cidreq() .  '&sec_token='.$token.'&urlview=' . $urlview . '&down=' . $myrow[0] . '" title="' . get_lang('Down') . '">' . Display :: return_icon('down.png', get_lang('Down'), array (), ICON_SIZE_SMALL) . '', "</a>\n";
                                             } else {
                                                 echo Display :: return_icon('down_na.png', get_lang('Down'), array (), ICON_SIZE_SMALL) . '', "</a>\n";
                                             }*/
                     if ($myrow['visibility'] == '1') {
                         $url .= 'link.php?' . api_get_cidreq() . '&sec_token=' . $token . '&action=invisible&id=' . $myrow['id'] . '&scope=link&category_id=' . $myrow['category_id'];
                         $title = get_lang('MakeInvisible');
                         $toolbar .= Display::toolbarButton('', $url, 'eye', 'default btn-sm', array('title' => $title));
                     }
                     if ($myrow['visibility'] == '0') {
                         $url .= 'link.php?' . api_get_cidreq() . '&sec_token=' . $token . '&action=visible&id=' . $myrow['id'] . '&scope=link&category_id=' . $myrow['category_id'];
                         $title = get_lang('MakeVisible');
                         $toolbar .= Display::toolbarButton('', $url, 'eye-slash', 'primary btn-sm', array('title' => $title));
                     }
                     $url .= api_get_self() . '?' . api_get_cidreq() . '&sec_token=' . $token . '&action=deletelink&id=' . $myrow['id'] . '&category_id=' . $myrow['category_id'];
                     $event = "javascript: if(!confirm('" . get_lang('LinkDelconfirm') . "'))return false;";
                     $title = get_lang('Delete');
                     $toolbar .= Display::toolbarButton('', $url, 'trash', 'default btn-sm', array('onclick' => $event, 'title' => $title));
                 } else {
                     $title = get_lang('EditionNotAvailableFromSession');
                     $toolbar .= Display::toolbarButton('', '#', 'trash-o', 'default btn-sm', array('title' => $title));
                 }
             }
             $iconLink = Display::return_icon('url.png', get_lang('Link'), null, ICON_SIZE_SMALL);
             if ($myrow['visibility'] == '1') {
                 $content .= '<div class="list-group-item">';
                 $content .= '<div class="pull-right"><div class="btn-group">' . $toolbar . '</div></div>';
                 $content .= '<h4 class="list-group-item-heading">';
                 $content .= $iconLink;
                 $url = 'link_goto.php?' . api_get_cidreq() . '&link_id=' . $myrow['id'] . '&link_url=' . urlencode($myrow['url']);
                 $content .= Display::tag('a', Security::remove_XSS($myrow['title']), array('href' => $url, 'target' => $myrow['target']));
                 $content .= $link_validator;
                 $content .= $session_img;
                 $content .= '</h4>';
                 $content .= '<p class="list-group-item-text">' . $myrow['description'] . '</p>';
                 $content .= '</div>';
             } else {
                 if (api_is_allowed_to_edit(null, true)) {
                     $content .= '<div class="list-group-item">';
                     $content .= '<div class="pull-right"><div class="btn-group">' . $toolbar . '</div></div>';
                     $content .= '<h4 class="list-group-item-heading">';
                     $content .= $iconLink;
                     $url = 'link_goto.php?' . api_get_cidreq() . '&link_id=' . $myrow['id'] . "&link_url=" . urlencode($myrow['url']);
                     $content .= Display::tag('a', Security::remove_XSS($myrow['title']), array('href' => $url, 'target' => '_blank', 'class' => 'invisible'));
                     $content .= $link_validator;
                     $content .= $session_img;
                     $content .= '</h4>';
                     $content .= '<p class="list-group-item-text">' . $myrow['description'] . '</p>';
                     $content .= '</div>';
                 }
             }
             $i++;
         }
         $content .= '</div>';
     }
     return $content;
 }
コード例 #5
0
    public function return_new_tree($update_audio = 'false', $drop_element_here = false)
    {
        $ajax_url = api_get_path(WEB_AJAX_PATH) . 'lp.ajax.php';
        echo '<script>
        var newOrderData= "";
        function processChildren(parentId) {
            //Loop through the children of the UL element defined by the parentId
            var ulParentID= "UL_" + parentId;
            $("#" + ulParentID).children().each(function () {

                /*Only process elements with an id attribute (in order to skip the blank,
                    unmovable <li> elements.*/

                if ($(this).attr("id")) {
                    /*Build a string of data with the childs ID and parent ID,
                        using the "|" as a delimiter between the two IDs and the "^"
                        as a record delimiter (these delimiters were chosen in case the data
                        involved includes more common delimiters like commas within the content)
                    */
                    newOrderData= newOrderData + $(this).attr("id") + "|" + parentId + "^";

                    //Determine if this child is a containter
                    if ($(this).is(".container")) {
                        //Process the child elements of the container
                        processChildren($(this).attr("id"));
                    }
                }
            });  //end of children loop
        } //end of processChildren function

        $(function() {

            $(".item_data").on("mouseover", function(event) {
                $(".button_actions", this).show();
            });

            $(".item_data").on("mouseout", function() {
                $(".button_actions",this).hide();
            });

            $(".button_actions").hide();

            $( ".lp_resource" ).sortable({
                items: ".lp_resource_element ",
                handle: ".moved", //only the class "moved"
                cursor: "move",
                connectWith: "#lp_item_list",
                placeholder: "ui-state-highlight", //defines the yellow highlight

                start: function(event, ui) {
                    $(ui.item).css("width", "160px");
                    $(ui.item).find(".item_data").attr("style", "");

                },
                stop: function(event, ui) {
                    $(ui.item).css("width", "100%");
                },
            });

            $("#lp_item_list").sortable({
                items: "li",
                handle: ".moved", //only the class "moved"
                cursor: "move",
                placeholder: "ui-state-highlight", //defines the yellow highlight

                update: function(event, ui) {

                    //Walk through the direct descendants of the lp_item_list <ul>
                    $("#lp_item_list").children().each(function () {

                        /*Only process elements with an id attribute (in order to skip the blank,
                        unmovable <li> elements.*/

                        if ($(this).attr("id")) {
                                /*Build a string of data with the child s ID and parent ID,
                                using the "|" as a delimiter between the two IDs and the "^"
                                as a record delimiter (these delimiters were chosen in case the data
                                involved includes more common delimiters like commas within the content)
                                */
                                newOrderData= newOrderData + $(this).attr("id") + "|" + "0" + "^";

                                //Determine if this child is a containter
                                if ($(this).is(".li_container")) {
                                    //Process the child elements of the container
                                    processChildren($(this).attr("id"));
                                }
                            }
                    }); //end of lp_item_list children loop

                    var order = "new_order="+ newOrderData + "&a=update_lp_item_order";
                    $.post("' . $ajax_url . '", order, function(reponse){
                        $("#message").html(reponse);
                    });
                },
                receive: function(event, ui) {

                    var id = $(ui.item).attr("data_id");
                    var type = $(ui.item).attr("data_type");
                    var title = $(ui.item).attr("title");

                    if (ui.item.parent()[0]) {
                        var parent_id = $(ui.item.parent()[0]).attr("id");
                        var previous_id = $(ui.item.prev()).attr("id");

                        if (parent_id) {
                            parent_id = parent_id.split("_")[1];
                            var params = {
                                    "a": "add_lp_item",
                                    "id": id,
                                    "parent_id": parent_id,
                                    "previous_id": previous_id,
                                    "type": type,
                                    "title" : title
                                };
                            $.ajax({
                                type: "GET",
                                url: "' . $ajax_url . '",
                                data: params,
                                async: false,
                                success: function(data) {
                                    if (data == -1) {
                                    } else {

                                        $(".normal-message").hide();
                                        $(ui.item).attr("id", data);
                                        $(ui.item).addClass("lp_resource_element_new");
                                        $(ui.item).find(".item_data").attr("style", "");
                                        $(ui.item).addClass("record li_container");
                                        $(ui.item).removeClass("lp_resource_element");
                                        $(ui.item).removeClass("doc_resource");
                                    }
                                }
                            });
                        }
                    }//
                }//end receive
            });
        });
        </script>';
        $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
        $course_id = api_get_course_int_id();
        $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
        $sql = "SELECT * FROM {$tbl_lp_item}\n                WHERE c_id = {$course_id} AND lp_id = " . $this->lp_id;
        $result = Database::query($sql);
        $arrLP = array();
        while ($row = Database::fetch_array($result)) {
            $row['title'] = Security::remove_XSS($row['title']);
            $row['description'] = Security::remove_XSS($row['description']);
            $arrLP[] = array('id' => $row['id'], 'item_type' => $row['item_type'], 'title' => $row['title'], 'path' => $row['path'], 'description' => $row['description'], 'parent_item_id' => $row['parent_item_id'], 'previous_item_id' => $row['previous_item_id'], 'next_item_id' => $row['next_item_id'], 'max_score' => $row['max_score'], 'min_score' => $row['min_score'], 'mastery_score' => $row['mastery_score'], 'prerequisite' => $row['prerequisite'], 'display_order' => $row['display_order'], 'audio' => $row['audio']);
        }
        $this->tree_array($arrLP);
        $arrLP = $this->arrMenu;
        unset($this->arrMenu);
        $default_data = null;
        $default_content = null;
        $elements = array();
        $return_audio = null;
        $iconSysPath = api_get_path(SYS_IMG_PATH);
        for ($i = 0; $i < count($arrLP); $i++) {
            $title = $arrLP[$i]['title'];
            $title_cut = Text::cut($arrLP[$i]['title'], 25);
            //Link for the documents
            if ($arrLP[$i]['item_type'] == 'document') {
                $url = api_get_self() . '?' . api_get_cidreq() . '&amp;action=view_item&amp;mode=preview_document&amp;id=' . $arrLP[$i]['id'] . '&amp;lp_id=' . $this->lp_id;
                $title_cut = Display::url($title_cut, $url, array('class' => 'ajax'));
            }
            if ($i % 2 == 0) {
                $oddclass = 'row_odd';
            } else {
                $oddclass = 'row_even';
            }
            $return_audio .= '<tr id ="lp_item_' . $arrLP[$i]['id'] . '" class="' . $oddclass . '">';
            $icon_name = str_replace(' ', '', $arrLP[$i]['item_type']);
            $icon = '';
            if (file_exists($iconSysPath . 'lp_' . $icon_name . '.png')) {
                $icon = Display::return_icon('lp_' . $icon_name . '.png');
            } else {
                if (file_exists($iconSysPath . 'lp_' . $icon_name . '.gif')) {
                    $icon = Display::return_icon('lp_' . $icon_name . '.gif');
                } else {
                    $icon = Display::return_icon('folder_document.gif');
                }
            }
            // The audio column.
            $return_audio .= '<td align="center">';
            $audio = '';
            if (!$update_audio or $update_audio != 'true') {
                if (!empty($arrLP[$i]['audio'])) {
                    /*$audio .= '<span id="container'.$i.'"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</span>';
                      $audio .= '<script type="text/javascript" src="../inc/lib/mediaplayer/swfobject.js"></script>';
                      $audio .= '<script type="text/javascript">
                                      var s1 = new SWFObject("../inc/lib/mediaplayer/player.swf","ply","250","20","9","#FFFFFF");
                                      s1.addParam("allowscriptaccess","always");
                                      s1.addParam("flashvars","file=../../courses/' . $_course['path'] . '/document/audio/' . $arrLP[$i]['audio'] . '");
                                      s1.write("container' . $i . '");
                                  </script>';*/
                } else {
                    $audio .= '';
                }
            } else {
                if ($arrLP[$i]['item_type'] != 'dokeos_chapter' && $arrLP[$i]['item_type'] != 'dokeos_module' && $arrLP[$i]['item_type'] != 'dir') {
                    $audio .= '<input type="file" name="mp3file' . $arrLP[$i]['id'] . '" id="mp3file" />';
                    if (!empty($arrLP[$i]['audio'])) {
                        $audio .= '<br />' . Security::remove_XSS($arrLP[$i]['audio']) . '<br /><input type="checkbox" name="removemp3' . $arrLP[$i]['id'] . '" id="checkbox' . $arrLP[$i]['id'] . '" />' . get_lang('RemoveAudio');
                    }
                }
            }
            $return_audio .= Display::span($icon . ' ' . $title) . Display::tag('td', $audio, array('style' => ''));
            $return_audio .= '</td>';
            $move_icon = '';
            $move_item_icon = '';
            $edit_icon = '';
            $delete_icon = '';
            $audio_icon = '';
            $prerequisities_icon = '';
            if ($is_allowed_to_edit) {
                if (!$update_audio or $update_audio != 'true') {
                    $move_icon .= '<a class="moved" href="#">';
                    $move_icon .= Display::return_icon('move_everywhere.png', get_lang('Move'), array(), ICON_SIZE_TINY);
                    $move_icon .= '</a>';
                }
                // No edit for this item types
                if (!in_array($arrLP[$i]['item_type'], array('sco', 'asset'))) {
                    if (!in_array($arrLP[$i]['item_type'], array('dokeos_chapter', 'dokeos_module'))) {
                        $edit_icon .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;action=edit_item&amp;view=build&amp;id=' . $arrLP[$i]['id'] . '&amp;lp_id=' . $this->lp_id . '&amp;path_item=' . $arrLP[$i]['path'] . '">';
                        $edit_icon .= Display::return_icon('edit.png', get_lang('LearnpathEditModule'), array(), ICON_SIZE_TINY);
                        $edit_icon .= '</a>';
                    } else {
                        $edit_icon .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;action=edit_item&amp;id=' . $arrLP[$i]['id'] . '&amp;lp_id=' . $this->lp_id . '&amp;path_item=' . $arrLP[$i]['path'] . '">';
                        $edit_icon .= Display::return_icon('edit.png', get_lang('LearnpathEditModule'), array(), ICON_SIZE_TINY);
                        $edit_icon .= '</a>';
                    }
                }
                $delete_icon .= ' <a href="' . api_get_self() . '?' . api_get_cidreq() . '&amp;action=delete_item&amp;id=' . $arrLP[$i]['id'] . '&amp;lp_id=' . $this->lp_id . '" onClick="return confirmation(\'' . addslashes($title) . '\');">';
                $delete_icon .= Display::return_icon('delete.png', get_lang('LearnpathDeleteModule'), array(), ICON_SIZE_TINY);
                $delete_icon .= '</a>';
                $url = api_get_self() . '?' . api_get_cidreq() . '&view=build&id=' . $arrLP[$i]['id'] . '&lp_id=' . $this->lp_id;
                if (!in_array($arrLP[$i]['item_type'], array('dokeos_chapter', 'dokeos_module', 'dir'))) {
                    $prerequisities_icon = Display::url(Display::return_icon('accept.png', get_lang('LearnpathPrerequisites'), array(), ICON_SIZE_TINY), $url . '&action=edit_item_prereq');
                    $move_item_icon = Display::url(Display::return_icon('move.png', get_lang('Move'), array(), ICON_SIZE_TINY), $url . '&action=move_item');
                    $audio_icon = Display::url(Display::return_icon('audio.png', get_lang('UplUpload'), array(), ICON_SIZE_TINY), $url . '&action=add_audio');
                }
            }
            if ($update_audio != 'true') {
                $row = $move_icon . ' ' . $icon . Display::span($title_cut) . Display::span($audio . $edit_icon . $prerequisities_icon . $move_item_icon . $audio_icon . $delete_icon, array('class' => 'button_actions'));
            } else {
                $row = Display::span($title . $icon) . Display::span($audio, array('class' => 'button_actions'));
            }
            $parent_id = $arrLP[$i]['parent_item_id'];
            $default_data[$arrLP[$i]['id']] = $row;
            $default_content[$arrLP[$i]['id']] = $arrLP[$i];
            if (empty($parent_id)) {
                $elements[$arrLP[$i]['id']]['data'] = $row;
                $elements[$arrLP[$i]['id']]['type'] = $arrLP[$i]['item_type'];
            } else {
                $parent_arrays = array();
                if ($arrLP[$i]['depth'] > 1) {
                    //Getting list of parents
                    for ($j = 0; $j < $arrLP[$i]['depth']; $j++) {
                        foreach ($arrLP as $item) {
                            if ($item['id'] == $parent_id) {
                                if ($item['parent_item_id'] == 0) {
                                    $parent_id = $item['id'];
                                    break;
                                } else {
                                    $parent_id = $item['parent_item_id'];
                                    if (empty($parent_arrays)) {
                                        $parent_arrays[] = intval($item['id']);
                                    }
                                    $parent_arrays[] = $parent_id;
                                    break;
                                }
                            }
                        }
                    }
                }
                if (!empty($parent_arrays)) {
                    $parent_arrays = array_reverse($parent_arrays);
                    $val = '$elements';
                    $x = 0;
                    foreach ($parent_arrays as $item) {
                        if ($x != count($parent_arrays) - 1) {
                            $val .= '["' . $item . '"]["children"]';
                        } else {
                            $val .= '["' . $item . '"]["children"]';
                        }
                        $x++;
                    }
                    $val .= "";
                    $code_str = $val . "[" . $arrLP[$i]['id'] . "][\"load_data\"] = '" . $arrLP[$i]['id'] . "' ; ";
                    eval($code_str);
                } else {
                    $elements[$parent_id]['children'][$arrLP[$i]['id']]['data'] = $row;
                    $elements[$parent_id]['children'][$arrLP[$i]['id']]['type'] = $arrLP[$i]['item_type'];
                }
            }
        }
        $return = '<div class="lp_tree well">';
        $return .= '<ul id="lp_item_list">';
        $return .= '<h4>' . $this->name . '</h4><br>';
        $tree = self::print_recursive($elements, $default_data, $default_content);
        if (!empty($tree)) {
            $return .= $tree;
        } else {
            if ($drop_element_here) {
                $return .= Display::return_message(get_lang("DragAndDropAnElementHere"));
            }
        }
        $return .= '</ul>';
        if ($update_audio == 'true') {
            $return = $return_audio;
        } else {
            $return .= '</div>';
        }
        return $return;
    }
コード例 #6
0
ファイル: link.lib.php プロジェクト: KRCM13/chamilo-lms
 /**
  * Displays all the links of a given category.
  * @author Patrick Cool <*****@*****.**>, Ghent University
  */
 public static function showlinksofcategory($catid)
 {
     global $urlview, $up, $down, $_user, $token;
     $tbl_link = Database::get_course_table(TABLE_LINK);
     $TABLE_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
     // Condition for the session.
     $session_id = api_get_session_id();
     $condition_session = api_get_session_condition($session_id, true, true, 'link.session_id');
     $catid = intval($catid);
     $course_id = api_get_course_int_id();
     $sqlLinks = "SELECT *, link.id FROM {$tbl_link} link\n                     INNER JOIN {$TABLE_ITEM_PROPERTY} itemproperties\n                     ON (link.id=itemproperties.ref AND link.c_id = itemproperties.c_id )\n                     WHERE\n                        itemproperties.tool='" . TOOL_LINK . "' AND\n                        link.category_id='" . $catid . "' AND\n                        (itemproperties.visibility='0' OR itemproperties.visibility='1')\n                        {$condition_session} AND\n                        link.c_id = " . $course_id . " AND\n                        itemproperties.c_id = " . $course_id . "\n                    ORDER BY link.display_order DESC";
     $result = Database::query($sqlLinks);
     $numberoflinks = Database::num_rows($result);
     if ($numberoflinks > 0) {
         echo '<table class="data_table" width="100%">';
         $i = 1;
         while ($myrow = Database::fetch_array($result)) {
             // Validation when belongs to a session.
             $session_img = api_get_session_image($myrow['session_id'], $_user['status']);
             $css_class = $i % 2 == 0 ? $css_class = 'row_odd' : ($css_class = 'row_even');
             $link_validator = '';
             if (api_is_allowed_to_edit(null, true)) {
                 $link_validator = Display::url(Display::return_icon('preview_view.png', get_lang('CheckURL'), array(), 16), '#', array('onclick' => "check_url('" . $myrow['id'] . "', '" . addslashes($myrow['url']) . "');"));
                 $link_validator .= Display::span('', array('id' => 'url_id_' . $myrow['id']));
             }
             if ($myrow['visibility'] == '1') {
                 echo '<tr class="' . $css_class . '">';
                 echo '<td align="center" valign="middle" width="5%">';
                 echo '<a href="link_goto.php?' . api_get_cidreq() . '&link_id=' . $myrow['id'] . '&link_url=' . urlencode($myrow['url']) . '" target="_blank">
                         <img src="../../main/img/link.gif" border="0" alt="' . get_lang('Link') . '"/></a>
                     </td>
                     <td width="80%" valign="top">
                     <a href="link_goto.php?' . api_get_cidreq() . '&link_id=' . $myrow['id'] . '&link_url=' . urlencode($myrow['url']) . '" target="' . $myrow['target'] . '">';
                 echo Security::remove_XSS($myrow['title']);
                 echo '</a>';
                 echo $link_validator;
                 echo $session_img;
                 echo '<br />' . $myrow['description'];
             } else {
                 if (api_is_allowed_to_edit(null, true)) {
                     echo '<tr class="' . $css_class . '">';
                     echo '<td align="center" valign="middle" width="5%">
                         <a href="link_goto.php?' . api_get_cidreq() . '&link_id=' . $myrow['id'] . "\n                            &link_url=" . urlencode($myrow['url']) . '"
                         target="_blank" class="invisible">';
                     echo Display::return_icon('link_na.gif', get_lang('Link')), '</a>';
                     echo '</td><td width="80%" valign="top">
                           <a href="link_goto.php?', api_get_cidreq(), '&link_id=', $myrow['id'], '&link_url=', urlencode($myrow['url']), '" target="', $myrow['target'], '"  class="invisible">';
                     echo Security::remove_XSS($myrow['title']);
                     echo "</a>";
                     echo $link_validator;
                     echo $session_img, '<br />', $myrow['description'];
                 }
             }
             if (api_is_allowed_to_edit(null, true)) {
                 echo '<td style="text-align:center;">';
                 if ($session_id == $myrow['session_id']) {
                     $url = api_get_self() . '?' . api_get_cidreq() . '&action=editlink&category=' . (!empty($category) ? $category : '') . '&id=' . $myrow['id'] . '&category_id=' . $myrow['id'];
                     echo '<a href="' . $url . '">' . Display::return_icon('edit.png', get_lang('Modify'), array(), ICON_SIZE_SMALL) . '</a>';
                     // DISPLAY MOVE UP COMMAND only if it is not the top link.
                     /* commented at least since 2014-10-11
                                             if ($i != 1) {
                                                 echo '<a href="' . api_get_self() . '?' . api_get_cidreq() .  '&sec_token='.$token.'&urlview=' . $urlview . '&up=', $myrow[0], '" title="' . get_lang('Up') . '">' . Display :: return_icon('up.png', get_lang('Up'), array (), ICON_SIZE_SMALL) . '', "</a>\n";
                                             } else {
                                                 echo Display :: return_icon('up_na.png', get_lang('Up'), array (), ICON_SIZE_SMALL) . '</a>';
                                             }
                     
                                             // DISPLAY MOVE DOWN COMMAND only if it is not the bottom link.
                                             if ($i < $numberoflinks) {
                                                 echo '<a href="' . api_get_self() . '?' . api_get_cidreq() .  '&sec_token='.$token.'&urlview=' . $urlview . '&down=' . $myrow[0] . '" title="' . get_lang('Down') . '">' . Display :: return_icon('down.png', get_lang('Down'), array (), ICON_SIZE_SMALL) . '', "</a>\n";
                                             } else {
                                                 echo Display :: return_icon('down_na.png', get_lang('Down'), array (), ICON_SIZE_SMALL) . '', "</a>\n";
                                             }*/
                     if ($myrow['visibility'] == '1') {
                         echo '<a href="link.php?' . api_get_cidreq() . '&sec_token=' . $token . '&action=invisible&id=' . $myrow['id'] . '&scope=link&category_id=' . $myrow['category_id'] . '" title="' . get_lang('Hide') . '">' . Display::return_icon('visible.png', get_lang('Hide'), array(), ICON_SIZE_SMALL) . '</a>';
                     }
                     if ($myrow['visibility'] == '0') {
                         echo ' <a href="link.php?' . api_get_cidreq() . '&sec_token=' . $token . '&action=visible&id=' . $myrow['id'] . '&scope=link&category_id=' . $myrow['category_id'] . '" title="' . get_lang('Show') . '">' . Display::return_icon('invisible.png', get_lang('Show'), array(), ICON_SIZE_SMALL) . '</a>';
                     }
                     echo ' <a href="' . api_get_self() . '?' . api_get_cidreq() . '&sec_token=' . $token . '&action=deletelink&id=' . $myrow['id'] . '&category_id=' . $myrow['category_id'] . "\"\n                            onclick=\"javascript: if(!confirm('" . get_lang('LinkDelconfirm') . "'))\n                            return false;\" title=\"" . get_lang('Delete') . '">' . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>';
                 } else {
                     echo Display::return_icon('edit_na.png', get_lang('EditionNotAvailableFromSession'), array(), ICON_SIZE_SMALL);
                     //get_lang('EditionNotAvailableFromSession');
                 }
                 echo '</td>';
             }
             echo '</tr>';
             $i++;
         }
         echo '</table>';
     }
 }
コード例 #7
0
 /**
  * @param string string $update_audio
  * @param bool $drop_element_here
  * @return string
  */
 public function return_new_tree($update_audio = 'false', $drop_element_here = false)
 {
     $return = '';
     $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
     $course_id = api_get_course_int_id();
     $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
     $sql = "SELECT * FROM {$tbl_lp_item}\n                WHERE c_id = {$course_id} AND lp_id = " . $this->lp_id;
     $result = Database::query($sql);
     $arrLP = array();
     while ($row = Database::fetch_array($result)) {
         $arrLP[] = array('id' => $row['id'], 'item_type' => $row['item_type'], 'title' => Security::remove_XSS($row['title']), 'path' => $row['path'], 'description' => Security::remove_XSS($row['description']), 'parent_item_id' => $row['parent_item_id'], 'previous_item_id' => $row['previous_item_id'], 'next_item_id' => $row['next_item_id'], 'max_score' => $row['max_score'], 'min_score' => $row['min_score'], 'mastery_score' => $row['mastery_score'], 'prerequisite' => $row['prerequisite'], 'display_order' => $row['display_order'], 'audio' => $row['audio'], 'prerequisite_max_score' => $row['prerequisite_max_score'], 'prerequisite_min_score' => $row['prerequisite_min_score']);
     }
     $this->tree_array($arrLP);
     $arrLP = isset($this->arrMenu) ? $this->arrMenu : null;
     unset($this->arrMenu);
     $default_data = null;
     $default_content = null;
     $elements = array();
     $return_audio = null;
     for ($i = 0; $i < count($arrLP); $i++) {
         $title = $arrLP[$i]['title'];
         $title_cut = cut($arrLP[$i]['title'], 25);
         //Link for the documents
         if ($arrLP[$i]['item_type'] == 'document') {
             $url = api_get_self() . '?' . api_get_cidreq() . '&action=view_item&mode=preview_document&id=' . $arrLP[$i]['id'] . '&lp_id=' . $this->lp_id;
             $title_cut = Display::url($title_cut, $url, array('class' => 'ajax', 'data-title' => $title_cut));
         }
         if ($i % 2 == 0) {
             $oddClass = 'row_odd';
         } else {
             $oddClass = 'row_even';
         }
         $return_audio .= '<tr id ="lp_item_' . $arrLP[$i]['id'] . '" class="' . $oddClass . '">';
         $icon_name = str_replace(' ', '', $arrLP[$i]['item_type']);
         $icon = '';
         if (file_exists('../img/lp_' . $icon_name . '.png')) {
             $icon = '<img src="../img/lp_' . $icon_name . '.png" />';
         } else {
             if (file_exists('../img/lp_' . $icon_name . '.gif')) {
                 $icon = '<img src="../img/lp_' . $icon_name . '.gif"  />';
             } else {
                 $icon = '<img src="../img/folder_document.gif" />';
             }
         }
         // The audio column.
         $return_audio .= '<td align="left" style="padding-left:10px;">';
         $audio = '';
         if (!$update_audio || $update_audio != 'true') {
             if (!empty($arrLP[$i]['audio'])) {
                 /*$audio .= '<span id="container'.$i.'"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</span>';
                   $audio .= '<script type="text/javascript" src="../inc/lib/mediaplayer/swfobject.js"></script>';
                   $audio .= '<script type="text/javascript">
                                   var s1 = new SWFObject("../inc/lib/mediaplayer/player.swf","ply","250","20","9","#FFFFFF");
                                   s1.addParam("allowscriptaccess","always");
                                   s1.addParam("flashvars","file=../../courses/' . $_course['path'] . '/document/audio/' . $arrLP[$i]['audio'] . '");
                                   s1.write("container' . $i . '");
                               </script>';*/
             } else {
                 $audio .= '';
             }
         } else {
             $types = self::getChapterTypes();
             if (!in_array($arrLP[$i]['item_type'], $types)) {
                 $audio .= '<input type="file" name="mp3file' . $arrLP[$i]['id'] . '" id="mp3file" />';
                 if (!empty($arrLP[$i]['audio'])) {
                     $audio .= '<br />' . Security::remove_XSS($arrLP[$i]['audio']) . '<br />
                     <input type="checkbox" name="removemp3' . $arrLP[$i]['id'] . '" id="checkbox' . $arrLP[$i]['id'] . '" />' . get_lang('RemoveAudio');
                 }
             }
         }
         $return_audio .= Display::span($icon . ' ' . $title) . Display::tag('td', $audio, array('style' => ''));
         $return_audio .= '</td>';
         $move_icon = '';
         $move_item_icon = '';
         $edit_icon = '';
         $delete_icon = '';
         $audio_icon = '';
         $prerequisities_icon = '';
         if ($is_allowed_to_edit) {
             if (!$update_audio || $update_audio != 'true') {
                 $move_icon .= '<a class="moved" href="#">';
                 $move_icon .= Display::return_icon('move_everywhere.png', get_lang('Move'), array(), ICON_SIZE_TINY);
                 $move_icon .= '</a>';
             }
             // No edit for this item types
             if (!in_array($arrLP[$i]['item_type'], array('sco', 'asset'))) {
                 if (!in_array($arrLP[$i]['item_type'], array('dokeos_chapter', 'dokeos_module'))) {
                     $edit_icon .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=edit_item&view=build&id=' . $arrLP[$i]['id'] . '&lp_id=' . $this->lp_id . '&path_item=' . $arrLP[$i]['path'] . '">';
                     $edit_icon .= Display::return_icon('edit.png', get_lang('LearnpathEditModule'), array(), ICON_SIZE_TINY);
                     $edit_icon .= '</a>';
                 } else {
                     $edit_icon .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=edit_item&id=' . $arrLP[$i]['id'] . '&lp_id=' . $this->lp_id . '&path_item=' . $arrLP[$i]['path'] . '">';
                     $edit_icon .= Display::return_icon('edit.png', get_lang('LearnpathEditModule'), array(), ICON_SIZE_TINY);
                     $edit_icon .= '</a>';
                 }
             }
             $delete_icon .= ' <a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=delete_item&id=' . $arrLP[$i]['id'] . '&lp_id=' . $this->lp_id . '" onClick="return confirmation(\'' . addslashes($title) . '\');">';
             $delete_icon .= Display::return_icon('delete.png', get_lang('LearnpathDeleteModule'), array(), ICON_SIZE_TINY);
             $delete_icon .= '</a>';
             $url = api_get_self() . '?' . api_get_cidreq() . '&view=build&id=' . $arrLP[$i]['id'] . '&lp_id=' . $this->lp_id;
             if (!in_array($arrLP[$i]['item_type'], array('dokeos_chapter', 'dokeos_module', 'dir'))) {
                 $prerequisities_icon = Display::url(Display::return_icon('accept.png', get_lang('LearnpathPrerequisites'), array(), ICON_SIZE_TINY), $url . '&action=edit_item_prereq');
                 $move_item_icon = Display::url(Display::return_icon('move.png', get_lang('Move'), array(), ICON_SIZE_TINY), $url . '&action=move_item');
                 $audio_icon = Display::url(Display::return_icon('audio.png', get_lang('UplUpload'), array(), ICON_SIZE_TINY), $url . '&action=add_audio');
             }
         }
         if ($update_audio != 'true') {
             $row = $move_icon . ' ' . $icon . Display::span($title_cut) . Display::span($audio . $edit_icon . $prerequisities_icon . $move_item_icon . $audio_icon . $delete_icon, array('class' => 'button_actions'));
         } else {
             $row = Display::span($title . $icon) . Display::span($audio, array('class' => 'button_actions'));
         }
         $parent_id = $arrLP[$i]['parent_item_id'];
         $default_data[$arrLP[$i]['id']] = $row;
         $default_content[$arrLP[$i]['id']] = $arrLP[$i];
         if (empty($parent_id)) {
             $elements[$arrLP[$i]['id']]['data'] = $row;
             $elements[$arrLP[$i]['id']]['type'] = $arrLP[$i]['item_type'];
         } else {
             $parent_arrays = array();
             if ($arrLP[$i]['depth'] > 1) {
                 //Getting list of parents
                 for ($j = 0; $j < $arrLP[$i]['depth']; $j++) {
                     foreach ($arrLP as $item) {
                         if ($item['id'] == $parent_id) {
                             if ($item['parent_item_id'] == 0) {
                                 $parent_id = $item['id'];
                                 break;
                             } else {
                                 $parent_id = $item['parent_item_id'];
                                 if (empty($parent_arrays)) {
                                     $parent_arrays[] = intval($item['id']);
                                 }
                                 $parent_arrays[] = $parent_id;
                                 break;
                             }
                         }
                     }
                 }
             }
             if (!empty($parent_arrays)) {
                 $parent_arrays = array_reverse($parent_arrays);
                 $val = '$elements';
                 $x = 0;
                 foreach ($parent_arrays as $item) {
                     if ($x != count($parent_arrays) - 1) {
                         $val .= '["' . $item . '"]["children"]';
                     } else {
                         $val .= '["' . $item . '"]["children"]';
                     }
                     $x++;
                 }
                 $val .= "";
                 $code_str = $val . "[" . $arrLP[$i]['id'] . "][\"load_data\"] = '" . $arrLP[$i]['id'] . "' ; ";
                 eval($code_str);
             } else {
                 $elements[$parent_id]['children'][$arrLP[$i]['id']]['data'] = $row;
                 $elements[$parent_id]['children'][$arrLP[$i]['id']]['type'] = $arrLP[$i]['item_type'];
             }
         }
     }
     $list = '<ul id="lp_item_list">';
     $tree = self::print_recursive($elements, $default_data, $default_content);
     if (!empty($tree)) {
         $list .= $tree;
     } else {
         if ($drop_element_here) {
             $list .= Display::return_message(get_lang("DragAndDropAnElementHere"));
         }
     }
     $list .= '</ul>';
     //$return .= Display::panel($list, $this->name);
     $return .= Display::panelCollapse($this->name, $list, 'scorm-list', null, 'scorm-list-accordion', 'scorm-list-collapse');
     if ($update_audio == 'true') {
         $return = $return_audio;
     }
     return $return;
 }
コード例 #8
0
 /**
  * Converts the score with the exercise_max_note and exercise_min_score
  * the platform settings + formats the results using the float_format function
  *
  * @param float $score
  * @param float $weight
  * @param bool $show_percentage show percentage or not
  * @param bool $use_platform_settings use or not the platform settings
  * @param bool $show_only_percentage
  * @return  string  an html with the score modified
  */
 public static function show_score($score, $weight, $show_percentage = true, $use_platform_settings = true, $show_only_percentage = false)
 {
     if (is_null($score) && is_null($weight)) {
         return '-';
     }
     $max_note = api_get_setting('exercise.exercise_max_score');
     $min_note = api_get_setting('exercise.exercise_min_score');
     if ($use_platform_settings) {
         if ($max_note != '' && $min_note != '') {
             if (!empty($weight) && intval($weight) != 0) {
                 $score = $min_note + ($max_note - $min_note) * $score / $weight;
             } else {
                 $score = $min_note;
             }
             $weight = $max_note;
         }
     }
     $percentage = 100 * $score / ($weight != 0 ? $weight : 1);
     // Formats values
     $percentage = float_format($percentage, 1);
     $score = float_format($score, 1);
     $weight = float_format($weight, 1);
     $html = null;
     if ($show_percentage) {
         $parent = '(' . $score . ' / ' . $weight . ')';
         $html = $percentage . "%  {$parent}";
         if ($show_only_percentage) {
             $html = $percentage . "% ";
         }
     } else {
         $html = $score . ' / ' . $weight;
     }
     $html = Display::span($html, array('class' => 'score_exercise'));
     return $html;
 }
コード例 #9
0
 /**
  * @param string string $update_audio
  * @param bool $drop_element_here
  * @return string
  */
 public function return_new_tree($update_audio = 'false', $drop_element_here = false)
 {
     $return = '';
     $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
     $course_id = api_get_course_int_id();
     $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
     $sql = "SELECT * FROM {$tbl_lp_item}\n                WHERE c_id = {$course_id} AND lp_id = " . $this->lp_id;
     $result = Database::query($sql);
     $arrLP = array();
     while ($row = Database::fetch_array($result)) {
         $arrLP[] = array('id' => $row['id'], 'item_type' => $row['item_type'], 'title' => Security::remove_XSS($row['title']), 'path' => $row['path'], 'description' => Security::remove_XSS($row['description']), 'parent_item_id' => $row['parent_item_id'], 'previous_item_id' => $row['previous_item_id'], 'next_item_id' => $row['next_item_id'], 'max_score' => $row['max_score'], 'min_score' => $row['min_score'], 'mastery_score' => $row['mastery_score'], 'prerequisite' => $row['prerequisite'], 'display_order' => $row['display_order'], 'audio' => $row['audio'], 'prerequisite_max_score' => $row['prerequisite_max_score'], 'prerequisite_min_score' => $row['prerequisite_min_score']);
     }
     $this->tree_array($arrLP);
     $arrLP = isset($this->arrMenu) ? $this->arrMenu : null;
     unset($this->arrMenu);
     $default_data = null;
     $default_content = null;
     $elements = array();
     $return_audio = null;
     for ($i = 0; $i < count($arrLP); $i++) {
         $title = $arrLP[$i]['title'];
         $title_cut = cut($arrLP[$i]['title'], 25);
         $url = api_get_self() . '?' . api_get_cidreq() . '&action=view_item&id=' . $arrLP[$i]['id'] . '&lp_id=' . $this->lp_id;
         $title_cut = Display::url($title_cut, $url, array('class' => 'ajax moved', 'data-title' => $title_cut));
         if ($i % 2 == 0) {
             $oddClass = 'row_odd';
         } else {
             $oddClass = 'row_even';
         }
         $return_audio .= '<tr id ="lp_item_' . $arrLP[$i]['id'] . '" class="' . $oddClass . '">';
         $icon_name = str_replace(' ', '', $arrLP[$i]['item_type']);
         if (file_exists('../img/lp_' . $icon_name . '.png')) {
             $icon = Display::return_icon('lp_' . $icon_name . '.png');
         } else {
             if (file_exists('../img/lp_' . $icon_name . '.gif')) {
                 $icon = Display::return_icon('lp_' . $icon_name . '.gif');
             } else {
                 $icon = Display::return_icon('folder_document.gif');
             }
         }
         // The audio column.
         $return_audio .= '<td align="left" style="padding-left:10px;">';
         $audio = '';
         if (!$update_audio || $update_audio != 'true') {
             if (!empty($arrLP[$i]['audio'])) {
             } else {
                 $audio .= '';
             }
         } else {
             $types = self::getChapterTypes();
             if (!in_array($arrLP[$i]['item_type'], $types)) {
                 $audio .= '<input type="file" name="mp3file' . $arrLP[$i]['id'] . '" id="mp3file" />';
                 if (!empty($arrLP[$i]['audio'])) {
                     $audio .= '<br />' . Security::remove_XSS($arrLP[$i]['audio']) . '<br />
                     <input type="checkbox" name="removemp3' . $arrLP[$i]['id'] . '" id="checkbox' . $arrLP[$i]['id'] . '" />' . get_lang('RemoveAudio');
                 }
             }
         }
         $return_audio .= Display::span($icon . ' ' . $title) . Display::tag('td', $audio, array('style' => ''));
         $return_audio .= '</td>';
         $move_icon = '';
         $move_item_icon = '';
         $edit_icon = '';
         $delete_icon = '';
         $audio_icon = '';
         $prerequisities_icon = '';
         $forumIcon = '';
         $previewIcon = '';
         if ($is_allowed_to_edit) {
             if (!$update_audio || $update_audio != 'true') {
                 $move_icon .= '<a class="moved" href="#">';
                 $move_icon .= Display::return_icon('move_everywhere.png', get_lang('Move'), array(), ICON_SIZE_TINY);
                 $move_icon .= '</a>';
             }
             // No edit for this item types
             if (!in_array($arrLP[$i]['item_type'], array('sco', 'asset'))) {
                 if (!in_array($arrLP[$i]['item_type'], array('dokeos_chapter', 'dokeos_module'))) {
                     $edit_icon .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=edit_item&view=build&id=' . $arrLP[$i]['id'] . '&lp_id=' . $this->lp_id . '&path_item=' . $arrLP[$i]['path'] . '" class="btn btn-default">';
                     $edit_icon .= Display::return_icon('edit.png', get_lang('LearnpathEditModule'), array(), ICON_SIZE_TINY);
                     $edit_icon .= '</a>';
                     if (!in_array($arrLP[$i]['item_type'], ['forum', 'thread'])) {
                         if ($this->items[$arrLP[$i]['id']]->getForumThread($this->course_int_id, $this->lp_session_id)) {
                             $forumIconUrl = api_get_self() . '?' . api_get_cidreq() . '&' . http_build_query(['action' => 'dissociate_forum', 'id' => $arrLP[$i]['id'], 'lp_id' => $this->lp_id]);
                             $forumIcon = Display::url(Display::return_icon('forum.png', get_lang('DissociateForumToLPItem'), [], ICON_SIZE_TINY), $forumIconUrl, ['class' => 'btn btn-default lp-btn-dissociate-forum']);
                         } else {
                             $forumIconUrl = api_get_self() . '?' . api_get_cidreq() . '&' . http_build_query(['action' => 'create_forum', 'id' => $arrLP[$i]['id'], 'lp_id' => $this->lp_id]);
                             $forumIcon = Display::url(Display::return_icon('forum.png', get_lang('AssociateForumToLPItem'), [], ICON_SIZE_TINY), $forumIconUrl, ['class' => "btn btn-default lp-btn-associate-forum"]);
                         }
                     }
                 } else {
                     $edit_icon .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=edit_item&id=' . $arrLP[$i]['id'] . '&lp_id=' . $this->lp_id . '&path_item=' . $arrLP[$i]['path'] . '" class="btn btn-default">';
                     $edit_icon .= Display::return_icon('edit.png', get_lang('LearnpathEditModule'), array(), ICON_SIZE_TINY);
                     $edit_icon .= '</a>';
                 }
             }
             $delete_icon .= ' <a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=delete_item&id=' . $arrLP[$i]['id'] . '&lp_id=' . $this->lp_id . '" onclick="return confirmation(\'' . addslashes($title) . '\');" class="btn btn-default">';
             $delete_icon .= Display::return_icon('delete.png', get_lang('LearnpathDeleteModule'), array(), ICON_SIZE_TINY);
             $delete_icon .= '</a>';
             $url = api_get_self() . '?' . api_get_cidreq() . '&view=build&id=' . $arrLP[$i]['id'] . '&lp_id=' . $this->lp_id;
             if ($arrLP[$i]['item_type'] == 'document') {
                 $urlPreviewLink = api_get_self() . '?' . api_get_cidreq() . '&action=view_item&mode=preview_document&id=' . $arrLP[$i]['id'] . '&lp_id=' . $this->lp_id;
                 $previewIcon = Display::url(Display::return_icon('preview_view.png', get_lang('Preview'), array(), ICON_SIZE_TINY), $urlPreviewLink, array('class' => 'btn btn-default ajax', 'data-title' => $arrLP[$i]['title']));
             } else {
                 $previewIcon = Display::url(Display::return_icon('preview_view.png', get_lang('Preview'), array(), ICON_SIZE_TINY), $url . '&action=view_item', ['class' => 'btn btn-default']);
             }
             if (!in_array($arrLP[$i]['item_type'], array('dokeos_chapter', 'dokeos_module', 'dir'))) {
                 $prerequisities_icon = Display::url(Display::return_icon('accept.png', get_lang('LearnpathPrerequisites'), array(), ICON_SIZE_TINY), $url . '&action=edit_item_prereq', ['class' => 'btn btn-default']);
                 $move_item_icon = Display::url(Display::return_icon('move.png', get_lang('Move'), array(), ICON_SIZE_TINY), $url . '&action=move_item', ['class' => 'btn btn-default']);
                 $audio_icon = Display::url(Display::return_icon('audio.png', get_lang('UplUpload'), array(), ICON_SIZE_TINY), $url . '&action=add_audio', ['class' => 'btn btn-default']);
             }
         }
         if ($update_audio != 'true') {
             $row = $move_icon . ' ' . $icon . Display::span($title_cut) . Display::tag('div', "<div class=\"btn-group btn-group-xs\">{$previewIcon} {$audio} {$edit_icon} {$forumIcon} {$prerequisities_icon} {$move_item_icon} {$audio_icon} {$delete_icon}</div>", array('class' => 'btn-toolbar button_actions'));
         } else {
             $row = Display::span($title . $icon) . Display::span($audio, array('class' => 'button_actions'));
         }
         $parent_id = $arrLP[$i]['parent_item_id'];
         $default_data[$arrLP[$i]['id']] = $row;
         $default_content[$arrLP[$i]['id']] = $arrLP[$i];
         if (empty($parent_id)) {
             $elements[$arrLP[$i]['id']]['data'] = $row;
             $elements[$arrLP[$i]['id']]['type'] = $arrLP[$i]['item_type'];
         } else {
             $parent_arrays = array();
             if ($arrLP[$i]['depth'] > 1) {
                 //Getting list of parents
                 for ($j = 0; $j < $arrLP[$i]['depth']; $j++) {
                     foreach ($arrLP as $item) {
                         if ($item['id'] == $parent_id) {
                             if ($item['parent_item_id'] == 0) {
                                 $parent_id = $item['id'];
                                 break;
                             } else {
                                 $parent_id = $item['parent_item_id'];
                                 if (empty($parent_arrays)) {
                                     $parent_arrays[] = intval($item['id']);
                                 }
                                 $parent_arrays[] = $parent_id;
                                 break;
                             }
                         }
                     }
                 }
             }
             if (!empty($parent_arrays)) {
                 $parent_arrays = array_reverse($parent_arrays);
                 $val = '$elements';
                 $x = 0;
                 foreach ($parent_arrays as $item) {
                     if ($x != count($parent_arrays) - 1) {
                         $val .= '["' . $item . '"]["children"]';
                     } else {
                         $val .= '["' . $item . '"]["children"]';
                     }
                     $x++;
                 }
                 $val .= "";
                 $code_str = $val . "[" . $arrLP[$i]['id'] . "][\"load_data\"] = '" . $arrLP[$i]['id'] . "' ; ";
                 eval($code_str);
             } else {
                 $elements[$parent_id]['children'][$arrLP[$i]['id']]['data'] = $row;
                 $elements[$parent_id]['children'][$arrLP[$i]['id']]['type'] = $arrLP[$i]['item_type'];
             }
         }
     }
     $list = '<ul id="lp_item_list">';
     $tree = self::print_recursive($elements, $default_data, $default_content);
     if (!empty($tree)) {
         $list .= $tree;
     } else {
         if ($drop_element_here) {
             $list .= Display::return_message(get_lang("DragAndDropAnElementHere"));
         }
     }
     $list .= '</ul>';
     $return .= Display::panelCollapse($this->name, $list, 'scorm-list', null, 'scorm-list-accordion', 'scorm-list-collapse');
     if ($update_audio == 'true') {
         $return = $return_audio;
     }
     return $return;
 }
コード例 #10
0
 /**
  * @param Application $app
  * @return string
  */
 public function indexAction(Application $app)
 {
     $request = $app['request'];
     $language_file = array('admin', 'exercice', 'gradebook', 'tracking');
     // 1. Setting variables needed by jqgrid
     $action = $request->get('a');
     $page = $request->get('page');
     //page
     $limit = $request->get('rows');
     //quantity of rows
     $sidx = $request->get('sidx');
     //index (field) to filter
     $sord = $request->get('sord');
     //asc or desc
     if (strpos(strtolower($sidx), 'asc') !== false) {
         $sidx = str_replace(array('asc', ','), '', $sidx);
         $sord = 'asc';
     }
     if (strpos(strtolower($sidx), 'desc') !== false) {
         $sidx = str_replace(array('desc', ','), '', $sidx);
         $sord = 'desc';
     }
     if (!in_array($sord, array('asc', 'desc'))) {
         $sord = 'desc';
     }
     if (!in_array($action, array('get_exercise_results', 'get_hotpotatoes_exercise_results', 'get_work_user_list', 'get_timelines', 'get_user_skill_ranking', 'get_usergroups_teacher', 'get_question_list', 'get_user_list_plugin_widescale'))) {
         api_protect_admin_script(true);
     }
     if ($action == 'get_user_list_plugin_widescale') {
         $allowed = api_is_drh() || api_is_platform_admin();
         if (!$allowed) {
             api_not_allowed();
         }
     }
     // Search features.
     // If there is no search request sent by jqgrid, $where should be empty.
     $where_condition = "";
     $operation = $request->get('oper');
     $export_format = $request->get('export_format');
     $search_field = $request->get('searchField');
     $search_oper = $request->get('searchOper');
     $search_string = $request->get('searchString');
     $isSearch = $request->get('_search');
     $filters = $request->get('filters');
     $type = $request->get('type');
     $extra_fields = array();
     $questionFields = array();
     if ($isSearch == 'true') {
         $where_condition = ' 1 = 1 ';
         $where_condition_in_form = $this->getWhereClause($search_field, $search_oper, $search_string);
         if (!empty($where_condition_in_form)) {
             $where_condition .= ' AND ' . $where_condition_in_form;
         }
         $filters = isset($filters) ? json_decode($filters) : false;
         // for now
         if (!empty($filters)) {
             switch ($action) {
                 case 'get_questions':
                     $extraFieldtype = 'question';
                     break;
                 case 'get_sessions':
                     $extraFieldtype = 'session';
                     break;
             }
             // Extra field.
             $extraField = new \ExtraField($extraFieldtype);
             $result = $extraField->getExtraFieldRules($filters, 'extra_');
             $extra_fields = $result['extra_fields'];
             $condition_array = $result['condition_array'];
             if (!empty($condition_array)) {
                 $where_condition .= ' AND ( ';
                 $where_condition .= implode($filters->groupOp, $condition_array);
                 $where_condition .= ' ) ';
             }
             // Question field.
             $resultQuestion = $extraField->getExtraFieldRules($filters, 'question_');
             $questionFields = $resultQuestion['extra_fields'];
             $condition_array = $resultQuestion['condition_array'];
             if (!empty($condition_array)) {
                 $where_condition .= ' AND ( ';
                 $where_condition .= implode($filters->groupOp, $condition_array);
                 $where_condition .= ' ) ';
             }
         }
     }
     // get index row - i.e. user click to sort $sord = $_GET['sord'];
     // get the direction
     if (!$sidx) {
         $sidx = 1;
     }
     //2. Selecting the count FIRST
     //@todo rework this
     switch ($action) {
         case 'get_questions':
             $categoryId = $request->get('categoryId');
             $exerciseId = $request->get('exerciseId');
             //$courseId = null; //$request->get('courseId');
             $courseId = $request->get('courseId');
             // Question manager can view all questions
             if (api_is_question_manager()) {
                 $courseId = null;
             }
             $count = \Question::getQuestions($app, $categoryId, $exerciseId, $courseId, array('where' => $where_condition, 'extra' => $extra_fields, 'question' => $questionFields), true);
             break;
         case 'get_user_list_plugin_widescale':
             $count = \UserManager::get_user_data(null, null, null, null, true);
             break;
         case 'get_question_list':
             require_once api_get_path(SYS_CODE_PATH) . 'exercice/exercise.class.php';
             $exerciseId = $request->get('exerciseId');
             $exercise = new \Exercise(api_get_course_int_id());
             $exercise->read($exerciseId);
             $count = $exercise->selectNbrQuestions();
             break;
         case 'get_group_reporting':
             $course_id = $request->get('course_id');
             $group_id = $request->get('gidReq');
             $count = \Tracking::get_group_reporting($course_id, $group_id, 'count');
             break;
         case 'get_user_course_report_resumed':
             $count = \CourseManager::get_count_user_list_from_course_code(true, 'ruc');
             break;
         case 'get_user_course_report':
             $count = \CourseManager::get_count_user_list_from_course_code(false);
             break;
         case 'get_course_exercise_medias':
             $course_id = api_get_course_int_id();
             $count = \Question::get_count_course_medias($course_id);
             break;
         case 'get_user_skill_ranking':
             $skill = new \Skill();
             $count = $skill->get_user_list_skill_ranking_count();
             break;
         case 'get_work_user_list':
             require_once api_get_path(SYS_CODE_PATH) . 'work/work.lib.php';
             $work_id = $request->get('work_id');
             //$_REQUEST['work_id'];
             $count = get_count_work($work_id);
             break;
         case 'get_exercise_results':
             $exercise_id = $request->get('exerciseId');
             //$_REQUEST['exerciseId'];
             $filter_by_user = $request->get('filter_by_user');
             if (isset($filter_by_user) && !empty($filter_by_user)) {
                 $filter_user = intval($filter_by_user);
                 if ($where_condition == "") {
                     $where_condition .= " te.exe_user_id  = '{$filter_user}'";
                 } else {
                     $where_condition .= " AND te.exe_user_id  = '{$filter_user}'";
                 }
             }
             $count = \ExerciseLib::get_count_exam_results($exercise_id, $where_condition);
             break;
         case 'get_hotpotatoes_exercise_results':
             $hotpot_path = $request->get('path');
             //$_REQUEST['path'];
             $count = \ExerciseLib::get_count_exam_hotpotatoes_results($hotpot_path);
             break;
         case 'get_sessions':
             $list_type = $request->get('list_type');
             if ($list_type == 'simple' || empty($list_type)) {
                 $count = \SessionManager::get_sessions_admin(array('where' => $where_condition, 'extra' => $extra_fields), true);
             } else {
                 $count = \SessionManager::get_count_admin_complete(array('where' => $where_condition, 'extra' => $extra_fields));
             }
             break;
         case 'get_extra_fields':
             $obj = new \ExtraField($type);
             $count = $obj->get_count();
             break;
         case 'get_extra_field_options':
             $field_id = $request->get('field_id');
             $obj = new \ExtraFieldOption($type);
             $count = $obj->get_count_by_field_id($field_id);
             break;
         case 'get_timelines':
             $obj = new \Timeline();
             $count = $obj->get_count();
             break;
         case 'get_gradebooks':
             $obj = new \Gradebook();
             $count = $obj->get_count();
             break;
         case 'get_event_email_template':
             $obj = new \EventEmailTemplate();
             $count = $obj->get_count();
             break;
         case 'get_careers':
             $obj = new \Career();
             $count = $obj->get_count();
             break;
         case 'get_promotions':
             $obj = new \Promotion();
             $count = $obj->get_count();
             break;
         case 'get_grade_models':
             $obj = new \GradeModel();
             $count = $obj->get_count();
             break;
         case 'get_usergroups':
             $obj = new \UserGroup();
             $count = $obj->get_count();
             break;
         case 'get_usergroups_teacher':
             $obj = new \UserGroup();
             $course_id = api_get_course_int_id();
             if ($type == 'registered') {
                 $count = $obj->get_usergroup_by_course_with_data_count($course_id);
             } else {
                 $count = $obj->get_count();
             }
             break;
         default:
             exit;
     }
     //3. Calculating first, end, etc
     $total_pages = 0;
     if ((int) $count > 0) {
         if (!empty($limit)) {
             $total_pages = ceil($count / $limit);
         }
     }
     if ($page > $total_pages) {
         $page = $total_pages;
     }
     $start = $limit * $page - $limit;
     if ($start < 0) {
         $start = 0;
     }
     //4. Deleting an element if the user wants to
     if ($operation == 'del') {
         $obj->delete($request->get('id'));
     }
     $is_allowedToEdit = api_is_allowed_to_edit(null, true) || api_is_allowed_to_edit(true) || api_is_drh();
     //5. Querying the DB for the elements
     $columns = array();
     switch ($action) {
         case 'get_questions':
             $columns = \Question::getQuestionColumns(api_get_course_id(), $extra_fields, $questionFields, true);
             $columns = $columns['simple_column_name'];
             $result = \Question::getQuestions($app, $categoryId, $exerciseId, $courseId, array('where' => $where_condition, 'order' => "{$sidx} {$sord}", 'extra' => $extra_fields, 'question' => $questionFields, 'limit' => "{$start} , {$limit}"));
             //var_dump($result);
             break;
         case 'get_user_list_plugin_widescale':
             $columns = array('username', 'firstname', 'lastname', 'exam_password');
             $column_names = array(get_lang('Username'), get_lang('Firstname'), get_lang('Lastname'), get_lang('Password'));
             $result = \UserManager::get_user_data($start, $limit, $sidx, $sord);
             break;
         case 'get_question_list':
             if (isset($exercise) && !empty($exercise)) {
                 $columns = array('question', 'type', 'category', 'level', 'score', 'actions');
                 $result = $exercise->getQuestionListPagination($start, $limit, $sidx, $sord, $where_condition);
             }
             break;
         case 'get_group_reporting':
             $columns = array('name', 'time', 'progress', 'score', 'works', 'messages', 'actions');
             $result = \Tracking::get_group_reporting($course_id, $group_id, 'all', $start, $limit, $sidx, $sord, $where_condition);
             break;
         case 'get_course_exercise_medias':
             $columns = array('question');
             $result = \Question::get_course_medias($course_id, $start, $limit, $sidx, $sord, $where_condition);
             if (!empty($result)) {
                 foreach ($result as &$media) {
                     $media['id'] = $media['iid'];
                 }
             }
             break;
         case 'get_user_course_report_resumed':
             $columns = array('extra_ruc', 'training_hours', 'count_users', 'count_users_registered', 'average_hours_per_user', 'count_certificates');
             $column_names = array(get_lang('Company'), get_lang('TrainingHoursAccumulated'), get_lang('CountOfSubscriptions'), get_lang('CountOfUsers'), get_lang('AverageHoursPerStudent'), get_lang('CountCertificates'));
             $result = \CourseManager::get_user_list_from_course_code(null, null, "LIMIT {$start}, {$limit}", " {$sidx} {$sord}", null, null, true, true, 'ruc');
             $new_result = array();
             if (!empty($result)) {
                 foreach ($result as $row) {
                     $row['training_hours'] = api_time_to_hms($row['training_hours']);
                     $row['average_hours_per_user'] = api_time_to_hms($row['average_hours_per_user']);
                     $new_result[] = $row;
                 }
                 $result = $new_result;
             }
             break;
         case 'get_user_course_report':
             $columns = array('course', 'user', 'time', 'certificate', 'progress_100', 'progress');
             $column_names = array(get_lang('Course'), get_lang('User'), get_lang('ManHours'), get_lang('CertificateGenerated'), get_lang('Approved'), get_lang('CourseAdvance'));
             $extra_fields = \UserManager::get_extra_fields(0, 100, null, null, true, true);
             if (!empty($extra_fields)) {
                 foreach ($extra_fields as $extra) {
                     $columns[] = $extra['1'];
                     $column_names[] = $extra['3'];
                 }
             }
             $result = \CourseManager::get_user_list_from_course_code(null, null, "LIMIT {$start}, {$limit}", " {$sidx} {$sord}", null, null, true);
             break;
         case 'get_user_skill_ranking':
             $columns = array('photo', 'firstname', 'lastname', 'skills_acquired', 'currently_learning', 'rank');
             $result = $skill->get_user_list_skill_ranking($start, $limit, $sidx, $sord, $where_condition);
             $result = \ArrayClass::msort($result, 'skills_acquired', 'asc');
             $skills_in_course = array();
             if (!empty($result)) {
                 //$counter = 1;
                 foreach ($result as &$item) {
                     $user_info = api_get_user_info($item['user_id']);
                     $personal_course_list = \UserManager::get_personal_session_course_list($item['user_id']);
                     $count_skill_by_course = array();
                     foreach ($personal_course_list as $course_item) {
                         if (!isset($skills_in_course[$course_item['code']])) {
                             $count_skill_by_course[$course_item['code']] = $skill->get_count_skills_by_course($course_item['code']);
                             $skills_in_course[$course_item['code']] = $count_skill_by_course[$course_item['code']];
                         } else {
                             $count_skill_by_course[$course_item['code']] = $skills_in_course[$course_item['code']];
                         }
                     }
                     $item['photo'] = \Display::img($user_info['avatar_small']);
                     $item['currently_learning'] = !empty($count_skill_by_course) ? array_sum($count_skill_by_course) : 0;
                 }
             }
             break;
         case 'get_work_user_list':
             if (isset($type) && $type == 'simple') {
                 $columns = array('type', 'firstname', 'lastname', 'username', 'title', 'qualification', 'sent_date', 'qualificator_id', 'actions');
             } else {
                 $columns = array('type', 'firstname', 'lastname', 'username', 'title', 'sent_date', 'actions');
             }
             $result = get_work_user_list($start, $limit, $sidx, $sord, $work_id, $where_condition);
             break;
         case 'get_exercise_results':
             $course = api_get_course_info();
             //used inside get_exam_results_data()
             $documentPath = api_get_path(SYS_COURSE_PATH) . $course['path'] . "/document";
             if ($is_allowedToEdit) {
                 $columns = array('firstname', 'lastname', 'username', 'group_name', 'exe_duration', 'start_date', 'exe_date', 'score', 'status', 'lp', 'actions');
             } else {
                 //$columns = array('exe_duration', 'start_date', 'exe_date', 'score', 'status', 'actions');
             }
             $result = \ExerciseLib::get_exam_results_data($start, $limit, $sidx, $sord, $exercise_id, $where_condition);
             break;
         case 'get_hotpotatoes_exercise_results':
             $course = api_get_course_info();
             //used inside get_exam_results_data()
             $documentPath = api_get_path(SYS_COURSE_PATH) . $course['path'] . "/document";
             $columns = array('firstname', 'lastname', 'username', 'group_name', 'exe_date', 'score', 'actions');
             $result = ExerciseLib::get_exam_results_hotpotatoes_data($start, $limit, $sidx, $sord, $hotpot_path, $where_condition);
             //get_exam_results_data($start, $limit, $sidx, $sord, $exercise_id, $where_condition);
             break;
         case 'get_sessions':
             $session_columns = \SessionManager::get_session_columns($list_type);
             $columns = $session_columns['simple_column_name'];
             if ($list_type == 'simple') {
                 $result = SessionManager::get_sessions_admin(array('where' => $where_condition, 'order' => "{$sidx} {$sord}", 'extra' => $extra_fields, 'limit' => "{$start} , {$limit}"), false);
             } else {
                 $result = SessionManager::get_sessions_admin_complete(array('where' => $where_condition, 'order' => "{$sidx} {$sord}", 'extra' => $extra_fields, 'limit' => "{$start} , {$limit}"));
             }
             break;
         case 'get_timelines':
             $columns = array('headline', 'actions');
             //$columns = array('headline', 'type', 'start_date', 'end_date', 'text', 'media', 'media_credit', 'media_caption', 'title_slide', 'parent_id');
             if (!in_array($sidx, $columns)) {
                 $sidx = 'headline';
             }
             $course_id = api_get_course_int_id();
             $result = Database::select('*', $obj->table, array('where' => array('parent_id = ? AND c_id = ?' => array('0', $course_id)), 'order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}"));
             $new_result = array();
             foreach ($result as $item) {
                 if (!$item['status']) {
                     $item['name'] = '<font style="color:#AAA">' . $item['name'] . '</font>';
                 }
                 $item['headline'] = Display::url($item['headline'], api_get_path(WEB_CODE_PATH) . 'timeline/view.php?id=' . $item['id']);
                 $item['actions'] = Display::url(Display::return_icon('add.png', get_lang('AddItems')), api_get_path(WEB_CODE_PATH) . 'timeline/?action=add_item&parent_id=' . $item['id']);
                 $item['actions'] .= Display::url(Display::return_icon('edit.png', get_lang('Edit')), api_get_path(WEB_CODE_PATH) . 'timeline/?action=edit&id=' . $item['id']);
                 $item['actions'] .= Display::url(Display::return_icon('delete.png', get_lang('Delete')), api_get_path(WEB_CODE_PATH) . 'timeline/?action=delete&id=' . $item['id']);
                 $new_result[] = $item;
             }
             $result = $new_result;
             break;
         case 'get_gradebooks':
             $columns = array('name', 'certificates', 'skills', 'actions', 'has_certificates');
             if (!in_array($sidx, $columns)) {
                 $sidx = 'name';
             }
             $result = Database::select('*', $obj->table, array('order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}"));
             $new_result = array();
             foreach ($result as $item) {
                 if ($item['parent_id'] != 0) {
                     continue;
                 }
                 $skills = $obj->get_skills_by_gradebook($item['id']);
                 //Fixes bug when gradebook doesn't have names
                 if (empty($item['name'])) {
                     $item['name'] = $item['course_code'];
                 } else {
                     //$item['name'] =  $item['name'].' ['.$item['course_code'].']';
                 }
                 $item['name'] = Display::url($item['name'], api_get_path(WEB_CODE_PATH) . 'gradebook/index.php?id_session=0&cidReq=' . $item['course_code']);
                 if (!empty($item['certif_min_score']) && !empty($item['document_id'])) {
                     $item['certificates'] = Display::return_icon('accept.png', get_lang('WithCertificate'), array(), ICON_SIZE_SMALL);
                     $item['has_certificates'] = '1';
                 } else {
                     $item['certificates'] = Display::return_icon('warning.png', get_lang('NoCertificate'), array(), ICON_SIZE_SMALL);
                     $item['has_certificates'] = '0';
                 }
                 if (!empty($skills)) {
                     foreach ($skills as $skill) {
                         $item['skills'] .= Display::span($skill['name'], array('class' => 'label_tag skill'));
                     }
                 }
                 $new_result[] = $item;
             }
             $result = $new_result;
             break;
         case 'get_event_email_template':
             $columns = array('subject', 'event_type_name', 'language_id', 'activated', 'actions');
             if (!in_array($sidx, $columns)) {
                 $sidx = 'subject';
             }
             $result = Database::select('*', $obj->table, array('order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}"));
             $new_result = array();
             foreach ($result as $item) {
                 $language_info = api_get_language_info($item['language_id']);
                 $item['language_id'] = $language_info['english_name'];
                 $item['actions'] = Display::url(Display::return_icon('edit.png', get_lang('Edit')), api_get_path(WEB_CODE_PATH) . 'admin/event_type.php?action=edit&event_type_name=' . $item['event_type_name']);
                 $item['actions'] .= Display::url(Display::return_icon('delete.png', get_lang('Delete')), api_get_path(WEB_CODE_PATH) . 'admin/event_controller.php?action=delete&id=' . $item['id']);
                 /*if (!$item['status']) {
                       $item['name'] = '<font style="color:#AAA">'.$item['subject'].'</font>';
                   }*/
                 $new_result[] = $item;
             }
             $result = $new_result;
             break;
         case 'get_careers':
             $columns = array('name', 'description', 'actions');
             if (!in_array($sidx, $columns)) {
                 $sidx = 'name';
             }
             $result = Database::select('*', $obj->table, array('order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}"));
             $new_result = array();
             foreach ($result as $item) {
                 if (!$item['status']) {
                     $item['name'] = '<font style="color:#AAA">' . $item['name'] . '</font>';
                 }
                 $new_result[] = $item;
             }
             $result = $new_result;
             break;
         case 'get_promotions':
             $columns = array('name', 'career', 'description', 'actions');
             if (!in_array($sidx, $columns)) {
                 $sidx = 'name';
             }
             $result = Database::select('p.id,p.name, p.description, c.name as career, p.status', "{$obj->table} p LEFT JOIN " . Database::get_main_table(TABLE_CAREER) . " c  ON c.id = p.career_id ", array('order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}"));
             $new_result = array();
             foreach ($result as $item) {
                 if (!$item['status']) {
                     $item['name'] = '<font style="color:#AAA">' . $item['name'] . '</font>';
                 }
                 $new_result[] = $item;
             }
             $result = $new_result;
             break;
         case 'get_grade_models':
             $columns = array('name', 'description', 'actions');
             if (!in_array($sidx, $columns)) {
                 $sidx = 'name';
             }
             $result = Database::select('*', "{$obj->table} ", array('order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}"));
             $new_result = array();
             foreach ($result as $item) {
                 $new_result[] = $item;
             }
             $result = $new_result;
             break;
         case 'get_usergroups':
             $columns = array('name', 'users', 'courses', 'sessions', 'group_type', 'actions');
             $result = Database::select('*', $obj->table, array('order' => "name {$sord}", 'LIMIT' => "{$start} , {$limit}"));
             $new_result = array();
             if (!empty($result)) {
                 foreach ($result as $group) {
                     $group['sessions'] = count($obj->get_sessions_by_usergroup($group['id']));
                     $group['courses'] = count($obj->get_courses_by_usergroup($group['id']));
                     $group['users'] = count($obj->get_users_by_usergroup($group['id']));
                     switch ($group['group_type']) {
                         case '0':
                             $group['group_type'] = Display::label(get_lang('Class'), 'info');
                             break;
                         case '1':
                             $group['group_type'] = Display::label(get_lang('Social'), 'success');
                             break;
                     }
                     $new_result[] = $group;
                 }
                 $result = $new_result;
             }
             $columns = array('name', 'users', 'courses', 'sessions', 'group_type');
             if (!in_array($sidx, $columns)) {
                 $sidx = 'name';
             }
             //Multidimensional sort
             ArrayClass::msort($result, $sidx);
             break;
         case 'get_extra_fields':
             $obj = new \ExtraField($type);
             $columns = array('field_display_text', 'field_variable', 'field_type', 'field_changeable', 'field_visible', 'field_filter', 'field_order');
             $result = \Database::select('*', $obj->table, array('order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}"));
             $new_result = array();
             if (!empty($result)) {
                 foreach ($result as $item) {
                     $item['field_type'] = $obj->get_field_type_by_id($item['field_type']);
                     $item['field_changeable'] = $item['field_changeable'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif');
                     $item['field_visible'] = $item['field_visible'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif');
                     $item['field_filter'] = $item['field_filter'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif');
                     $new_result[] = $item;
                 }
                 $result = $new_result;
             }
             break;
         case 'get_extra_field_options':
             $obj = new \ExtraFieldOption($type);
             $columns = array('option_display_text', 'option_value', 'option_order');
             $result = \Database::select('*', $obj->table, array('where' => array("field_id = ? " => $field_id), 'order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}"));
             /*$new_result = array();
               if (!empty($result)) {
                   foreach ($result as $item) {
                       $item['field_type']         = $obj->get_field_type_by_id($item['field_type']);
                       $item['field_changeable']   = $item['field_changeable'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif');
                       $item['field_visible']      = $item['field_visible'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif');
                       $item['field_filter']       = $item['field_filter'] ? Display::return_icon('right.gif') : Display::return_icon('wrong.gif');
                       $new_result[]        = $item;
                   }
                   $result = $new_result;
               }*/
             break;
         case 'get_usergroups_teacher':
             $columns = array('name', 'users', 'actions');
             $options = array('order' => "name {$sord}", 'LIMIT' => "{$start} , {$limit}");
             $options['course_id'] = $course_id;
             switch ($type) {
                 case 'not_registered':
                     $options['where'] = array(" (course_id IS NULL OR course_id != ?) " => $course_id);
                     $result = $obj->get_usergroup_not_in_course($options);
                     break;
                 case 'registered':
                     $options['where'] = array(" usergroup.course_id = ? " => $course_id);
                     $result = $obj->get_usergroup_in_course($options);
                     break;
             }
             $new_result = array();
             if (!empty($result)) {
                 foreach ($result as $group) {
                     $group['users'] = count($obj->get_users_by_usergroup($group['id']));
                     if ($obj->usergroup_was_added_in_course($group['id'], $course_id)) {
                         $url = 'class.php?action=remove_class_from_course&id=' . $group['id'];
                         $icon = Display::return_icon('delete.png', get_lang('Remove'));
                     } else {
                         $url = 'class.php?action=add_class_to_course&id=' . $group['id'];
                         $icon = Display::return_icon('add.png', get_lang('Add'));
                     }
                     $group['actions'] = Display::url($icon, $url);
                     $new_result[] = $group;
                 }
                 $result = $new_result;
             }
             if (!in_array($sidx, $columns)) {
                 $sidx = 'name';
             }
             //Multidimensional sort
             \ArrayClass::msort($result, $sidx);
             break;
         default:
             exit;
     }
     $allowed_actions = array('get_careers', 'get_promotions', 'get_usergroups', 'get_usergroups_teacher', 'get_gradebooks', 'get_sessions', 'get_exercise_results', 'get_hotpotatoes_exercise_results', 'get_work_user_list', 'get_timelines', 'get_grade_models', 'get_event_email_template', 'get_user_skill_ranking', 'get_extra_fields', 'get_extra_field_options', 'get_course_exercise_medias', 'get_user_course_report', 'get_user_course_report_resumed', 'get_group_reporting', 'get_question_list', 'get_user_list_plugin_widescale', 'get_questions');
     //5. Creating an obj to return a json
     if (in_array($action, $allowed_actions)) {
         $response = new \stdClass();
         $response->page = $page;
         $response->total = $total_pages;
         $response->records = $count;
         if ($operation && $operation == 'excel') {
             $j = 1;
             $array = array();
             if (empty($column_names)) {
                 $column_names = $columns;
             }
             //Headers
             foreach ($column_names as $col) {
                 $array[0][] = $col;
             }
             foreach ($result as $row) {
                 foreach ($columns as $col) {
                     $array[$j][] = strip_tags($row[$col]);
                 }
                 $j++;
             }
             switch ($export_format) {
                 case 'xls':
                     Export::export_table_xls($array, 'company_report');
                     break;
                 case 'csv':
                 default:
                     Export::export_table_csv($array, 'company_report');
                     break;
             }
             exit;
         }
         $i = 0;
         if (!empty($result)) {
             foreach ($result as $row) {
                 //print_r($row);
                 // if results tab give not id, set id to $i otherwise id="null" for all <tr> of the jqgrid - ref #4235
                 if (!isset($row['id']) || isset($row['id']) && $row['id'] == "") {
                     $response->rows[$i]['id'] = $i;
                 } else {
                     $response->rows[$i]['id'] = $row['id'];
                 }
                 $array = array();
                 foreach ($columns as $col) {
                     $array[] = isset($row[$col]) ? $row[$col] : null;
                 }
                 $response->rows[$i]['cell'] = $array;
                 $i++;
             }
         }
         return json_encode($response);
     }
 }
コード例 #11
0
            break;
        default:
            $affected_rows = 0;
    }
    if ($affected_rows) {
        $msg = get_lang('AssignedUsersHaveBeenUpdatedSuccessfully');
    }
}
// Display header
Display::display_header($tool_name);
// actions
echo '<div class="actions">';
if ($userStatus != STUDENT_BOSS) {
    $actions = Display::url(Display::return_icon('course_add.gif', get_lang('AssignCourses'), array('style' => 'vertical-align:middle')) . get_lang('AssignCourses'), "dashboard_add_courses_to_user.php?user={$user_id}");
    $actions .= Display::url(Display::return_icon('view_more_stats.gif', get_lang('AssignSessions'), array('style' => 'vertical-align:middle')) . get_lang('AssignSessions'), "dashboard_add_sessions_to_user.php?user={$user_id}");
    echo Display::span($actions, array('style' => 'float: right; margin: 0; paddingg: 0;'));
}
echo Display::url(get_lang('AdvancedSearch'), '#', array('class' => 'advanced_options', 'id' => 'advanced_search'));
echo '</div>';
echo '<div id="advanced_search_options" style="display:none">';
$searchForm->display();
echo '</div>';
echo Display::page_header(sprintf(get_lang('AssignUsersToX'), api_get_person_name($user_info['firstname'], $user_info['lastname'])));
switch ($userStatus) {
    case DRH:
        $assigned_users_to_hrm = UserManager::get_users_followed_by_drh($user_id);
        break;
    case STUDENT_BOSS:
        $assigned_users_to_hrm = UserManager::getUsersFollowedByStudentBoss($user_id);
        break;
}
コード例 #12
0
ファイル: profile.php プロジェクト: ragebat/chamilo-lms
 $friend_html .= '</div>';
 // close div friend-header
 $friend_html .= '<ul class="thumbnails">';
 $j = 1;
 for ($k = 0; $k < $number_friends; $k++) {
     if ($j > $number_of_images) {
         break;
     }
     if (isset($friends[$k])) {
         $friend = $friends[$k];
         $name_user = api_get_person_name($friend['firstName'], $friend['lastName']);
         $user_info_friend = api_get_user_info($friend['friend_user_id'], true);
         if ($user_info_friend['user_is_online']) {
             $status_icon = Display::span('', array('class' => 'online_user_in_text'));
         } else {
             $status_icon = Display::span('', array('class' => 'offline_user_in_text'));
         }
         $friend_html .= '<li class="span2">';
         $friend_html .= '<div class="thumbnail">';
         // the height = 92 must be the sqme in the image_friend_network span style in default.css
         $friends_profile = SocialManager::get_picture_user($friend['friend_user_id'], $friend['image'], 92, USER_IMAGE_SIZE_ORIGINAL);
         $friend_html .= '<img src="' . $friends_profile['file'] . '"  id="imgfriend_' . $friend['friend_user_id'] . '" title="' . $name_user . '" />';
         $friend_html .= '<div class="caption">';
         $friend_html .= $status_icon . '<a href="' . $user_info_friend['profile_url'] . '">';
         $friend_html .= $name_user;
         $friend_html .= '</a></div>';
         $friend_html .= '</div>';
         $friend_html .= '</li>';
     }
     $j++;
 }
コード例 #13
0
ファイル: home.php プロジェクト: annickvdp/Chamilo1.9.10
        true
    );
    $result['name'] = Security::remove_XSS($result['name'], STUDENT, true);
    $id = $result['id'];
    $group_url = "groups.php?id=$id";

    if ($result['count'] == 1) {
        $result['count'] = '1 ' . get_lang('Member');
    } else {
        $result['count'] = $result['count'] . ' ' . get_lang('Members');
    }
    $result['name'] = Display::url(
            api_ucwords(cut($result['name'], 40, true)),
            $group_url
        ) . Display::span(
            '<br />' . $result['count'],
            array('class' => 'box_description_group_member')
        );
    $picture = GroupPortalManager::get_picture_group(
        $id,
        $result['picture_uri'],
        80
    );
    $result['picture_uri'] = '<img class="social-groups-image" src="' . $picture['file'] . '" hspace="10" height="44" border="2" align="left" width="44" />';
    $group_actions = '<div class="box_description_group_actions" ><a href="groups.php?#tab_browse-3">' . get_lang(
            'SeeMore'
        ) . '</a></div>';
    $groups_pop[] = array(
        Display::url($result['picture_uri'], $group_url),
        $result['name'],
        cut($result['description'], 120, true) . $group_actions
    );
コード例 #14
0
 if (api_get_setting('registration.allow_terms_conditions') == 'true' && $user_already_registered_show_terms) {
     $form_data['action'] = api_get_path(WEB_PATH) . 'user_portal.php';
 } else {
     if (!empty($values['email'])) {
         $text_after_registration .= '<p>' . get_lang('MailHasBeenSent', null, $_user['language']) . '.</p>';
     }
     if ($is_allowedCreateCourse) {
         if ($usersCanCreateCourse) {
             $form_data['message'] = '<p>' . get_lang('NowGoCreateYourCourse', null, $_user['language']) . "</p>";
         }
         $form_data['action'] = '../create_course/add_course.php';
         if (api_get_setting('course.course_validation') == 'true') {
             $form_data['button'] = Display::button('next', get_lang('CreateCourseRequest', null, $_user['language']), array('class' => 'btn btn-primary btn-large'));
         } else {
             $form_data['button'] = Display::button('next', get_lang('CourseCreate', null, $_user['language']), array('class' => 'btn btn-primary btn-large'));
             $form_data['go_button'] = '&nbsp;&nbsp;<a href="' . api_get_path(WEB_PATH) . 'index.php' . '">' . Display::span(get_lang('Next', null, $_user['language']), array('class' => 'btn btn-primary btn-large')) . '</a>';
         }
     } else {
         if (api_get_setting('display.allow_students_to_browse_courses') == 'true') {
             $form_data['action'] = 'courses.php?action=subscribe';
             $form_data['message'] = '<p>' . get_lang('NowGoChooseYourCourses', null, $_user['language']) . ".</p>";
         } else {
             $form_data['action'] = api_get_path(WEB_PATH) . 'user_portal.php';
         }
         $form_data['button'] = Display::button('next', get_lang('Next', null, $_user['language']), array('class' => 'btn btn-primary btn-large'));
     }
 }
 $form_data = CourseManager::redirectToCourse($form_data);
 $form_register = new FormValidator('form_register', 'post', $form_data['action']);
 if (!empty($form_data['message'])) {
     $form_register->addElement('html', $form_data['message'] . '<br /><br />');
コード例 #15
0
ファイル: search.php プロジェクト: KRCM13/chamilo-lms
 $group['description'] = Security::remove_XSS($group['description'], STUDENT, true);
 $id = $group['id'];
 $url_open = '<a class="btn btn-default" href="group_view.php?id=' . $id . '">';
 $url_close = '</a>';
 $name = cut($group['name'], 60, true);
 $count_users_group = count($usergroup->get_all_users_by_group($id));
 if ($count_users_group == 1) {
     $count_users_group = $count_users_group . ' ' . get_lang('Member');
 } else {
     $count_users_group = $count_users_group . ' ' . get_lang('Members');
 }
 $picture = $usergroup->get_picture_group($group['id'], $group['picture'], GROUP_IMAGE_SIZE_ORIGINAL);
 //$tags = $usergroup->get_group_tags($group['id']);
 $tags = null;
 $group['picture'] = '<img src="' . $picture['file'] . '" />';
 $members = Display::span($count_users_group);
 $item_1 = Display::tag('h3', $url_open . $name . $url_close) . $members;
 $social_right_content .= '
     <div class="col-md-4">
         <div class="card">
             <div class="avatar">
                 ' . $group['picture'] . '
             </div>
             <div class="content">
                 ' . $item_1 . '
                 <p>' . $group['description'] . '</p>
                 <p>' . $tags . '</p>
                 <p>' . $url_open . get_lang('SeeMore') . $url_close . '</p>
             </div>
         </div>
     </div>';
コード例 #16
0
ファイル: groups.php プロジェクト: KRCM13/chamilo-lms
     $result['name'] = Security::remove_XSS($result['name'], STUDENT, true);
     $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);
 }
コード例 #17
0
ファイル: home.php プロジェクト: ragebat/chamilo-lms
        $groups_newest[] = array(Display::url($result['picture_uri'], $group_url), $result['name'], Text::cut($result['description'], 120, true) . $group_actions);
    }
}
$results = $usergroup->get_groups_by_popularity(1, false);
$groups_pop = array();
foreach ($results as $result) {
    $result['description'] = Security::remove_XSS($result['description'], STUDENT, true);
    $result['name'] = Security::remove_XSS($result['name'], STUDENT, true);
    $id = $result['id'];
    $group_url = "groups.php?id={$id}";
    if ($result['count'] == 1) {
        $result['count'] = '1 ' . get_lang('Member');
    } else {
        $result['count'] = $result['count'] . ' ' . get_lang('Members');
    }
    $result['name'] = Display::url(api_ucwords(Text::cut($result['name'], 40, true)), $group_url) . Display::span('<br />' . $result['count'], array('class' => 'box_description_group_member'));
    $picture = $usergroup->get_picture_group($id, $result['picture'], 80);
    $result['picture_uri'] = '<img class="social-groups-image" src="' . $picture['file'] . '" hspace="10" height="44" border="2" align="left" width="44" />';
    $group_actions = '<div class="box_description_group_actions" ><a href="groups.php?#tab_browse-3">' . get_lang('SeeMore') . '</a></div>';
    $groups_pop[] = array(Display::url($result['picture_uri'], $group_url), $result['name'], Text::cut($result['description'], 120, true) . $group_actions);
}
if (count($groups_newest) > 0) {
    $social_right_content .= '<div class="social-groups-home-title">' . get_lang('Newest') . '</div>';
    $social_right_content .= Display::return_sortable_grid('home_group', array(), $groups_newest, array('hide_navigation' => true, 'per_page' => 100), array(), false, array(true, true, true, false));
}
if (count($groups_pop) > 0) {
    $social_right_content .= '<div class="social-groups-home-title">' . get_lang('Popular') . '</div>';
    $social_right_content .= Display::return_sortable_grid('home_group', array(), $groups_pop, array('hide_navigation' => true, 'per_page' => 100), array(), false, array(true, true, true, true, true));
}
$social_right_content .= '</div>';
$app['title'] = get_lang('SocialNetwork');
コード例 #18
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;
 }
コード例 #19
0
ファイル: work.lib.php プロジェクト: annickvdp/Chamilo1.9.10
/**
 * @param int $start
 * @param int $limit
 * @param int $column
 * @param string $direction
 * @param int $work_id
 * @param array $where_condition
 * @param int $studentId
 * @param bool $getCount
 * @return array
 */
function get_work_user_list(
    $start,
    $limit,
    $column,
    $direction,
    $work_id,
    $where_condition = null,
    $studentId = null,
    $getCount = false
) {
    $work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
    $iprop_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
    $user_table = Database::get_main_table(TABLE_MAIN_USER);

    $session_id = api_get_session_id();
    $course_id = api_get_course_int_id();
    $group_id = api_get_group_id();
    $course_info = api_get_course_info(api_get_course_id());

    $work_id = intval($work_id);
    $column = !empty($column) ? Database::escape_string($column) : 'sent_date';
    $start = intval($start);
    $limit = intval($limit);

    if (!in_array($direction, array('asc','desc'))) {
        $direction = 'desc';
    }

    $work_data = get_work_data_by_id($work_id);
    $is_allowed_to_edit = api_is_allowed_to_edit() || api_is_coach();
    $condition_session  = api_get_session_condition($session_id);
    $locked = api_resource_is_locked_by_gradebook($work_id, LINK_STUDENTPUBLICATION);

    $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
        api_get_user_id(),
        $course_info
    );

    if (!empty($work_data)) {
        if (!empty($group_id)) {
            $extra_conditions = " work.post_group_id = '".intval($group_id)."' ";
            // set to select only messages posted by the user's group
        } else {
            $extra_conditions = " work.post_group_id = '0' ";
        }

        if ($is_allowed_to_edit || $isDrhOfCourse) {
            $extra_conditions .= ' AND work.active IN (0, 1) ';
        } else {
            if (isset($course_info['show_score']) &&
                $course_info['show_score'] == 1
            ) {
                $extra_conditions .= " AND (u.user_id = ".api_get_user_id()." AND work.active IN (0, 1)) ";
            } else {
                $extra_conditions .= ' AND work.active IN (0, 1) ';
            }
        }

        $extra_conditions .= " AND parent_id  = ".$work_id." ";

        $select = 'SELECT DISTINCT
                        u.user_id,
                        work.id as id,
                        title as title,
                        description,
                        url,
                        sent_date,
                        contains_file,
                        has_properties,
                        view_properties,
                        qualification,
                        weight,
                        allow_text_assignment,
                        u.firstname,
                        u.lastname,
                        u.username,
                        parent_id,
                        accepted,
                        qualificator_id';
        if ($getCount) {
            $select = "SELECT DISTINCT count(u.user_id) as count ";
        }

        $user_condition = "INNER JOIN $user_table u  ON (work.user_id = u.user_id) ";
        $work_condition = "$iprop_table prop INNER JOIN $work_table work
                           ON (prop.ref = work.id AND prop.c_id = $course_id AND work.c_id = $course_id ) ";

        $work_assignment = get_work_assignment_by_id($work_id);

        if (!empty($studentId)) {
            $where_condition.= " AND u.user_id = ".intval($studentId);
        }

        $sql = " $select
                FROM $work_condition  $user_condition
                WHERE $extra_conditions $where_condition $condition_session
                ORDER BY $column $direction";

        if (!empty($start) && !empty($limit)) {
            $sql .= " LIMIT $start, $limit";
        }
        $result = Database::query($sql);
        $works = array();

        if ($getCount) {
            $work = Database::fetch_array($result, 'ASSOC');
            return $work['count'];
        }

        $url = api_get_path(WEB_CODE_PATH).'work/';

        while ($work = Database::fetch_array($result, 'ASSOC')) {
            $item_id = $work['id'];

            // Get the author ID for that document from the item_property table
            $is_author  = false;
            $can_read   = false;

            $owner_id = $work['user_id'];

            /* Because a bug found when saving items using the api_item_property_update()
               the field $item_property_data['insert_user_id'] is not reliable. */

            if (!$is_allowed_to_edit && $owner_id == api_get_user_id()) {
                $is_author = true;
            }

            if ($course_info['show_score'] == 0) {
                $can_read = true;
            }

            if ($work['accepted'] == '0') {
                $class = 'invisible';
            } else {
                $class = '';
            }

            $qualification_exists = false;
            if (!empty($work_data['qualification']) &&
                intval($work_data['qualification']) > 0
            ) {
                $qualification_exists = true;
            }

            $qualification_string = '';
            if ($qualification_exists) {
                if ($work['qualification'] == '') {
                    $qualification_string = Display::label('-');
                } else {
                    $label = 'info';
                    $relativeScore = $work['qualification']/$work_data['qualification'];
                    if ($relativeScore < 0.5) {
                        $label = 'important';
                    } elseif ($relativeScore < 0.75) {
                        $label = 'warning';
                    }
                    $qualification_string = Display::label(
                        $work['qualification'].' / '.$work_data['qualification'],
                        $label
                    );
                }
            }

            $work['qualification_score'] = $work['qualification'];

            $add_string = '';
            $time_expires = api_strtotime($work_assignment['expires_on'], 'UTC');

            if (!empty($work_assignment['expires_on']) &&
                $work_assignment['expires_on'] != '0000-00-00 00:00:00' &&
                $time_expires && ($time_expires < api_strtotime($work['sent_date'], 'UTC'))) {
                $add_string = Display::label(get_lang('Expired'), 'important');
            }

            if (($can_read && $work['accepted'] == '1') ||
                ($is_author && in_array($work['accepted'], array('1', '0'))) ||
                ($is_allowed_to_edit || api_is_drh())
            ) {
                // Firstname, lastname, username
                $work['firstname'] = Display::div($work['firstname'], array('class' => $class));
                $work['lastname'] = Display::div($work['lastname'], array('class' => $class));

                if (strlen($work['title']) > 30) {
                    $short_title = substr($work['title'], 0, 27).'...';
                    $work['title'] = Display::span($short_title, array('class' => $class, 'title' => $work['title']));
                } else {
                    $work['title'] = Display::div($work['title'], array('class' => $class));
                }

                // Type.
                $work['type'] = build_document_icon_tag('file', $work['url']);

                // File name.
                $link_to_download = null;

                // If URL is present then there's a file to download keep BC.
                if ($work['contains_file'] || !empty($work['url'])) {
                    $link_to_download = '<a href="'.$url.'download.php?id='.$item_id.'&'.api_get_cidreq().'">'.
                        Display::return_icon('save.png', get_lang('Save'),array(), ICON_SIZE_SMALL).'</a> ';
                }

                $send_to = Portfolio::share('work', $work['id'],  array('style' => 'white-space:nowrap;'));

                $feedback = null;
                $count = getWorkCommentCount($item_id, $course_info);
                if (!is_null($count) && !empty($count)) {
                    if ($qualification_exists) {
                        $feedback .= "<br />";
                    }
                    $feedback .= '<a href="'.$url.'view.php?'.api_get_cidreq().'&id='.$item_id.'" title="'.get_lang('View').'">'.
                        Display::label($count.' '.get_lang('Feedback'), 'info').'</a> ';
                }

                $work['qualification'] = $qualification_string.$feedback;
                $work['qualification_only'] = $qualification_string;

                // Date.
                $work_date = api_convert_and_format_date($work['sent_date']);

                $work['sent_date_from_db'] = $work['sent_date'];
                $work['sent_date'] = date_to_str_ago(api_get_local_time($work['sent_date'])) . ' ' . $add_string . '<br />' . $work_date;

                // Actions.

                $action = '';
                if (api_is_allowed_to_edit()) {
                    $action .= '<a href="'.$url.'view.php?'.api_get_cidreq().'&id='.$item_id.'" title="'.get_lang('View').'">'.
                        Display::return_icon('default.png', get_lang('View'),array(), ICON_SIZE_SMALL).'</a> ';

                    if ($locked) {
                        if ($qualification_exists) {
                            $action .= Display::return_icon('rate_work_na.png', get_lang('CorrectAndRate'),array(), ICON_SIZE_SMALL);
                        } else {
                            $action .= Display::return_icon('edit_na.png', get_lang('Comment'),array(), ICON_SIZE_SMALL);
                        }
                    } else {
                        if ($qualification_exists) {
                            $action .= '<a href="'.$url.'edit.php?'.api_get_cidreq().'&item_id='.$item_id.'&id='.$work['parent_id'].'" title="'.get_lang('Edit').'"  >'.
                                Display::return_icon('rate_work.png', get_lang('CorrectAndRate'), array(), ICON_SIZE_SMALL).'</a>';
                        } else {
                            $action .= '<a href="'.$url.'edit.php?'.api_get_cidreq().'&item_id='.$item_id.'&id='.$work['parent_id'].'" title="'.get_lang('Modify').'">'.
                                Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
                        }
                    }

                    if ($work['contains_file']) {
                        if ($locked) {
                            $action .= Display::return_icon('move_na.png', get_lang('Move'),array(), ICON_SIZE_SMALL);
                        } else {
                            $action .= '<a href="'.$url.'work.php?'.api_get_cidreq().'&action=move&item_id='.$item_id.'" title="'.get_lang('Move').'">'.
                                Display::return_icon('move.png', get_lang('Move'),array(), ICON_SIZE_SMALL).'</a>';
                        }
                    }

                    if ($work['accepted'] == '1') {
                        $action .= '<a href="'.$url.'work_list_all.php?'.api_get_cidreq().'&id='.$work_id.'&action=make_invisible&item_id='.$item_id.'" title="'.get_lang('Invisible').'" >'.
                            Display::return_icon('visible.png', get_lang('Invisible'),array(), ICON_SIZE_SMALL).'</a>';
                    } else {
                        $action .= '<a href="'.$url.'work_list_all.php?'.api_get_cidreq().'&id='.$work_id.'&action=make_visible&item_id='.$item_id.'" title="'.get_lang('Visible').'" >'.
                            Display::return_icon('invisible.png', get_lang('Visible'),array(), ICON_SIZE_SMALL).'</a> ';
                    }

                    if ($locked) {
                        $action .= Display::return_icon('delete_na.png', get_lang('Delete'), '', ICON_SIZE_SMALL);
                    } else {
                        $action .= '<a href="'.$url.'work_list_all.php?'.api_get_cidreq().'&id='.$work_id.'&action=delete&amp;item_id='.$item_id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES))."'".')) return false;" title="'.get_lang('Delete').'" >'.
                            Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
                    }
                } elseif ($is_author && (empty($work['qualificator_id']) || $work['qualificator_id'] == 0)) {
                    $action .= '<a href="'.$url.'view.php?'.api_get_cidreq().'&id='.$item_id.'" title="'.get_lang('View').'">'.
                        Display::return_icon('default.png', get_lang('View'),array(), ICON_SIZE_SMALL).'</a>';

                    if (api_get_course_setting('student_delete_own_publication') == 1) {
                        if (api_is_allowed_to_session_edit(false, true)) {
                            $action .= '<a href="'.$url.'edit.php?'.api_get_cidreq().'&item_id='.$item_id.'&id='.$work['parent_id'].'" title="'.get_lang('Modify').'">'.
                                Display::return_icon('edit.png', get_lang('Comment'),array(), ICON_SIZE_SMALL).'</a>';
                        }
                        $action .= ' <a href="'.$url.'work_list.php?'.api_get_cidreq().'&action=delete&item_id='.$item_id.'&id='.$work['parent_id'].'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES))."'".')) return false;" title="'.get_lang('Delete').'"  >'.
                            Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
                    } else {
                        $action .= Display::return_icon('edit_na.png', get_lang('Modify'),array(), ICON_SIZE_SMALL);
                    }
                } else {
                    $action .= '<a href="'.$url.'view.php?'.api_get_cidreq().'&id='.$item_id.'" title="'.get_lang('View').'">'.
                        Display::return_icon('default.png', get_lang('View'),array(), ICON_SIZE_SMALL).'</a>';
                    $action .= Display::return_icon('edit_na.png', get_lang('Modify'),array(), ICON_SIZE_SMALL);
                }

                // Status.
                if (empty($work['qualificator_id'])) {
                    $qualificator_id = Display::label(get_lang('NotRevised'), 'warning');
                } else {
                    $qualificator_id = Display::label(get_lang('Revised'), 'success');
                }
                $work['qualificator_id'] = $qualificator_id;
                $work['actions'] = $send_to.$link_to_download.$action;
                $works[] = $work;
            }
        }
        return $works;
    }
}
コード例 #20
0
ファイル: model.ajax.php プロジェクト: jloguercio/chamilo-lms
         //Fixes bug when gradebook doesn't have names
         if (empty($item['name'])) {
             $item['name'] = $item['course_code'];
         }
         $item['name'] = Display::url($item['name'], api_get_path(WEB_CODE_PATH) . 'gradebook/index.php?id_session=0&cidReq=' . $item['course_code']);
         if (!empty($item['certif_min_score']) && !empty($item['document_id'])) {
             $item['certificates'] = Display::return_icon('accept.png', get_lang('WithCertificate'), array(), ICON_SIZE_SMALL);
             $item['has_certificates'] = '1';
         } else {
             $item['certificates'] = Display::return_icon('warning.png', get_lang('NoCertificate'), array(), ICON_SIZE_SMALL);
             $item['has_certificates'] = '0';
         }
         if (!empty($skills)) {
             $item['skills'] = '';
             foreach ($skills as $skill) {
                 $item['skills'] .= Display::span($skill['name'], array('class' => 'label_tag skill'));
             }
         }
         $new_result[] = $item;
     }
     $result = $new_result;
     break;
 case 'get_event_email_template':
     $columns = array('subject', 'event_type_name', 'language_id', 'activated', 'actions');
     if (!in_array($sidx, $columns)) {
         $sidx = 'subject';
     }
     $result = Database::select('*', $obj->table, array('order' => "{$sidx} {$sord}", 'LIMIT' => "{$start} , {$limit}"));
     $new_result = array();
     foreach ($result as $item) {
         $language_info = api_get_language_info($item['language_id']);
コード例 #21
0
ファイル: social.lib.php プロジェクト: ragebat/chamilo-lms
 /**
  * Displays a sortable table with the list of online users.
  * @param array $user_list
  */
 public static function display_user_list($user_list)
 {
     if (!isset($_GET['id'])) {
         $html = null;
         $column_size = '9';
         $add_row = false;
         if (api_is_anonymous()) {
             $column_size = '12';
             $add_row = true;
         }
         $extra_params = array();
         $course_url = '';
         if (isset($_GET['cidReq']) && !empty($_GET['cidReq'])) {
             $extra_params['cidReq'] = Security::remove_XSS($_GET['cidReq']);
             $course_url = '&amp;cidReq=' . Security::remove_XSS($_GET['cidReq']);
         }
         if ($add_row) {
             $html .= '<div class="row">';
         }
         $html .= '<div class="span' . $column_size . '">';
         $html .= '<ul id="online_grid_container" class="thumbnails">';
         foreach ($user_list as $uid) {
             $user_info = api_get_user_info($uid);
             //Anonymous users can't have access to the profile
             if (!api_is_anonymous()) {
                 if (api_get_setting('allow_social_tool') == 'true') {
                     $url = $user_info['profile_url'] . $course_url;
                 } else {
                     $url = '?id=' . $uid . $course_url;
                 }
             } else {
                 $url = '#';
             }
             $image_array = UserManager::get_user_picture_path_by_id($uid, 'system', false, true);
             // reduce image
             $name = $user_info['complete_name'];
             $status_icon = Display::span('', array('class' => 'online_user_in_text'));
             $user_status = $user_info['status'] == 1 ? Display::span('', array('class' => 'teacher_online')) : Display::span('', array('class' => 'student_online'));
             if ($image_array['file'] == 'unknown.jpg' || !file_exists($image_array['dir'] . $image_array['file'])) {
                 $friends_profile['file'] = api_get_path(WEB_IMG_PATH) . 'unknown_180_100.jpg';
                 $img = '<img title = "' . $name . '" alt="' . $name . '" src="' . $friends_profile['file'] . '">';
             } else {
                 $friends_profile = UserManager::get_picture_user($uid, $image_array['file'], 80, USER_IMAGE_SIZE_ORIGINAL);
                 $img = '<img title = "' . $name . '" alt="' . $name . '" src="' . $friends_profile['file'] . '">';
             }
             $name = '<a href="' . $url . '">' . $status_icon . $user_status . $name . '</a><br>';
             $html .= '<li class="span' . $column_size / 3 . '"><div class="thumbnail">' . $img . '<div class="caption">' . $name . '</div</div></li>';
         }
         $counter = $_SESSION['who_is_online_counter'];
         $html .= '</ul></div>';
         if (count($user_list) >= 9) {
             $html .= '<div class="span' . $column_size . '"><a class="btn btn-large" id="link_load_more_items" data_link="' . $counter . '" >' . get_lang('More') . '</a></div>';
         }
         if ($add_row) {
             $html .= '</div>';
         }
     }
     return $html;
 }
コード例 #22
0
            exit;
        }
    }
}
$actions = null;
if ($is_allowedToEdit && $origin != 'learnpath') {
    // the form
    if (api_is_platform_admin() || api_is_course_admin() || api_is_course_tutor() || api_is_course_coach()) {
        $actions .= '<a href="admin.php?exerciseId=' . intval($_GET['exerciseId']) . '">' . Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM) . '</a>';
        $actions .= '<a href="live_stats.php?' . api_get_cidreq() . '&exerciseId=' . $exercise_id . '">' . Display::return_icon('activity_monitor.png', get_lang('LiveResults'), '', ICON_SIZE_MEDIUM) . '</a>';
        $actions .= '<a href="stats.php?' . api_get_cidreq() . '&exerciseId=' . $exercise_id . '">' . Display::return_icon('statistics.png', get_lang('ReportByQuestion'), '', ICON_SIZE_MEDIUM) . '</a>';
        $actions .= '<a id="export_opener" href="' . api_get_self() . '?export_report=1&exerciseId=' . intval($_GET['exerciseId']) . '" >' . Display::return_icon('save.png', get_lang('Export'), '', ICON_SIZE_MEDIUM) . '</a>';
        // clean result before a selected date icon
        $actions .= Display::url(Display::return_icon('clean_before_date.png', get_lang('CleanStudentsResultsBeforeDate'), '', ICON_SIZE_MEDIUM), '#', array('onclick' => "javascript:display_date_picker()"));
        // clean result before a selected date datepicker popup
        $actions .= Display::span(Display::input('input', 'datepicker_start', get_lang('SelectADateOnTheCalendar'), array('onmouseover' => 'datepicker_input_mouseover()', 'id' => 'datepicker_start', 'onchange' => 'datepicker_input_changed()', 'readonly' => 'readonly')) . Display::button('delete', get_lang('Delete'), array('onclick' => 'submit_datepicker()')), array('style' => 'display:none', 'id' => 'datepicker_span'));
    }
} else {
    $actions .= '<a href="exercise.php">' . Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM) . '</a>';
}
//Deleting an attempt
if (($is_allowedToEdit || $is_tutor || api_is_coach()) && isset($_GET['delete']) && $_GET['delete'] == 'delete' && !empty($_GET['did']) && $locked == false) {
    $exe_id = intval($_GET['did']);
    if (!empty($exe_id)) {
        $sql = 'DELETE FROM ' . $TBL_TRACK_EXERCISES . ' WHERE exe_id = ' . $exe_id;
        Database::query($sql);
        $sql = 'DELETE FROM ' . $TBL_TRACK_ATTEMPT . ' WHERE exe_id = ' . $exe_id;
        Database::query($sql);
        header('Location: exercise_report.php?' . api_get_cidreq() . '&exerciseId=' . $exercise_id);
        exit;
    }
コード例 #23
0
 /**
  * Get the HTML necessary for display the groups/classes name list
  * @param int $userId The user ID
  * @param int $filterByType Optional. The type of group
  * @return string
  */
 public function getLabelsFromNameList($userId, $filterByType = null)
 {
     $groupsNameListParsed = $this->getNameListByUser($userId, $filterByType);
     if (empty($groupsNameListParsed)) {
         return '';
     }
     $nameList = '<ul class="list-unstyled">';
     foreach ($groupsNameListParsed as $name) {
         $nameList .= '<li>' . Display::span($name, ['class' => 'label label-info']) . '</li>';
     }
     $nameList .= '</ul>';
     return $nameList;
 }