Exemplo n.º 1
0
 /**
  * Image constructor.
  * @param string $path
  */
 public function __construct($path)
 {
     if (IMAGE_PROCESSOR == 'gd') {
         $this->image_wrapper = new GDWrapper($path);
     } else {
         if (class_exists('Imagick')) {
             $this->image_wrapper = new ImagickWrapper($path);
         } else {
             Display::display_warning_message('Class Imagick not found');
             exit;
         }
     }
 }
Exemplo n.º 2
0
 function __construct($path)
 {
     $path = preg_match(VALID_WEB_PATH, $path) ? api_is_internal_path($path) ? api_get_path(TO_SYS, $path) : $path : $path;
     if (IMAGE_PROCESSOR == 'gd') {
         $this->image_wrapper = new GDWrapper($path);
     } else {
         if (class_exists('Imagick')) {
             $this->image_wrapper = new ImagickWrapper($path);
         } else {
             Display::display_warning_message('Class Imagick not found');
             exit;
         }
     }
 }
Exemplo n.º 3
0
    exit;
}
$action = isset($_GET['action']) ? $_GET['action'] : null;
switch ($action) {
    case 'empty':
        if (api_is_allowed_to_edit(false, true)) {
            GroupManager::unsubscribe_all_users($group_id);
            Display::display_confirmation_message(get_lang('GroupEmptied'));
        }
        break;
}
$defaults = $current_group;
$defaults['group_members'] = $selected_users;
$action = isset($_GET['action']) ? $_GET['action'] : '';
$defaults['action'] = $action;
if (!empty($_GET['keyword']) && !empty($_GET['submit'])) {
    $keyword_name = Security::remove_XSS($_GET['keyword']);
    echo '<br/>' . get_lang('SearchResultsFor') . ' <span style="font-style: italic ;"> ' . $keyword_name . ' </span><br>';
}
Display::display_header($nameTools, 'Group');
//@todo fix this
if (isset($_GET['show_message_warning'])) {
    echo Display::display_warning_message($_GET['show_message_warning']);
}
if (isset($_GET['show_message_sucess'])) {
    echo Display::display_normal_message($_GET['show_message_sucess']);
}
$form->setDefaults($defaults);
echo GroupManager::getSettingBar('member');
$form->display();
Display::display_footer();
Exemplo n.º 4
0
$this_section = SECTION_COURSES;
$current_course_tool = TOOL_COURSE_MAINTENANCE;
api_protect_course_script(true);
$_course = api_get_course_info();
$current_course_code = $_course['official_code'];
$current_course_name = $_course['name'];
if (!api_is_allowed_to_edit()) {
    api_not_allowed(true);
}
$tool_name = get_lang('DelCourse');
if (isset($_GET['delete']) && $_GET['delete'] == 'yes') {
    CourseManager::delete_course($_course['sysCode']);
    $obj_cat = new Category();
    $obj_cat->update_category_delete($_course['sysCode']);
    // DELETE CONFIRMATION MESSAGE
    Session::erase('_cid');
    Session::erase('_real_cid');
    $noPHP_SELF = true;
    $message = '<h2>' . get_lang('Course') . ' : ' . $current_course_name . ' (' . $current_course_code . ') </h2>';
    $message .= get_lang('HasDel');
    $message .= '<br /><br /><a href="../../index.php">' . get_lang('BackHome') . ' ' . api_get_setting('platform.site_name') . '</a>';
} else {
    $message = '<h3>' . get_lang('Course') . ' : ' . $current_course_name . ' (' . $current_course_code . ') </h3>';
    $message .= '<p>' . get_lang('ByDel') . '</p>';
    $message .= '<p><a class="btn btn-primary" href="' . api_get_path(WEB_CODE_PATH) . 'course_info/maintenance.php?' . api_get_cidreq() . '">' . get_lang('No') . '</a>&nbsp;<a class="btn" href="' . api_get_self() . '?delete=yes&' . api_get_cidreq() . '">' . get_lang('Yes') . '</a></p>';
    $interbreadcrumb[] = array('url' => 'maintenance.php', 'name' => get_lang('Maintenance'));
}
Display::display_header($tool_name, 'Settings');
echo Display::page_header($tool_name);
Display::display_warning_message($message, false);
Display::display_footer();
    $certificate_list = GradebookUtils::get_list_users_certificates($cat_id);
}
echo '<div class="btn-group">';
$url = api_get_self() . '?action=generate_all_certificates' . '&' . api_get_cidReq() . '&cat_id=' . $cat_id . '&filter=' . $filterOfficialCode;
echo Display::url(get_lang('GenerateCertificates'), $url, array('class' => 'btn btn-default'));
$url = api_get_self() . '?action=delete_all_certificates' . '&' . api_get_cidReq() . '&cat_id=' . $cat_id . '&filter=' . $filterOfficialCode;
echo Display::url(get_lang('DeleteAllCertificates'), $url, array('class' => 'btn btn-default'));
$hideCertificateExport = api_get_setting('hide_certificate_export_link');
if (count($certificate_list) > 0 && $hideCertificateExport !== 'true') {
    $url = api_get_self() . '?action=export_all_certificates' . '&' . api_get_cidReq() . '&cat_id=' . $cat_id . '&filter=' . $filterOfficialCode;
    echo Display::url(get_lang('ExportAllCertificatesToPDF'), $url, array('class' => 'btn btn-default'));
}
echo '</div>';
echo $filterForm;
if (count($certificate_list) == 0) {
    echo Display::display_warning_message(get_lang('NoResultsAvailable'));
} else {
    echo '<br /><br /><table class="data_table">';
    foreach ($certificate_list as $index => $value) {
        echo '<tr>
                <td width="100%" class="actions">' . get_lang('Student') . ' : ' . api_get_person_name($value['firstname'], $value['lastname']) . ' (' . $value['username'] . ')</td>';
        echo '</tr>';
        echo '<tr><td>
            <table class="data_table">';
        $list_certificate = GradebookUtils::get_list_gradebook_certificates_by_user_id($value['user_id'], $cat_id);
        foreach ($list_certificate as $value_certificate) {
            echo '<tr>';
            echo '<td width="50%">' . get_lang('Score') . ' : ' . $value_certificate['score_certificate'] . '</td>';
            echo '<td width="30%">' . get_lang('Date') . ' : ' . api_convert_and_format_date($value_certificate['created_at']) . '</td>';
            echo '<td width="20%">';
            $url = api_get_path(WEB_PATH) . 'certificates/index.php?id=' . $value_certificate['id'];
Exemplo n.º 6
0
    function overview()
    {
        $platform_charset = api_get_system_encoding();
        if ($this->debug > 0) {
            error_log('New LP - In learnpath::overview()', 0);
        }
        global $charset, $_course;
        $_SESSION['gradebook'] = Security::remove_XSS($_GET['gradebook']);
        $return = '';
        if (isset($_REQUEST['curr_id'])) {
            $curr_id = $_REQUEST['curr_id'];
        }
        $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
        $sql = "SELECT * FROM " . $tbl_lp_item . "\n\t\t\t\tWHERE lp_id = " . $this->lp_id . " ORDER BY display_order";
        $result = api_sql_query($sql, __FILE__, __LINE__);
        $arrLP = array();
        while ($row = Database::fetch_array($result)) {
            //	$row['title'] = Security :: remove_XSS(api_convert_encoding($row['title'], $platform_charset, $this->encoding));
            //	$row['description'] = Security :: remove_XSS(api_convert_encoding($row['description'], $platform_charset, $this->encoding));
            $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);
        if (api_is_allowed_to_edit()) {
            $gradebook = Security::remove_XSS($_GET['gradebook']);
            $author_lang_var = api_convert_encoding(get_lang('Author'), $charset, api_get_system_encoding());
            $content_lang_var = api_convert_encoding(get_lang('Content'), $charset, api_get_system_encoding());
            $scenario_lang_var = api_convert_encoding(get_lang('Scenario'), $charset, api_get_system_encoding());
            $publication_lang_var = api_convert_encoding(get_lang('Publication'), $charset, api_get_system_encoding());
            $view_lang_var = api_convert_encoding(get_lang('ViewRight'), $charset, api_get_system_encoding());
            $return .= '<div class="actions">';
            $return .= '<a href="' . api_get_self() . '?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '" title="' . $author_lang_var . '">' . Display::return_icon('pixel.gif', $author_lang_var, array('class' => 'toolactionplaceholdericon toolactionback')) . ' ' . $author_lang_var . '</a>';
            $return .= '<a href="lp_controller.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;action=add_item&amp;type=step&amp;lp_id=' . Security::remove_XSS($_GET['lp_id']) . '">' . Display::return_icon('pixel.gif', $content_lang_var, array('class' => 'toolactionplaceholdericon toolactionauthorcontent')) . $content_lang_var . '</a>';
            $return .= '<a href="lp_controller.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&action=admin_view&lp_id=' . $this->lp_id . '">' . Display::return_icon('pixel.gif', $scenario_lang_var, array('class' => 'toolactionplaceholdericon toolactionauthorscenario')) . $scenario_lang_var . '</a> ';
            $return .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&gradebook=&action=edit&lp_id=' . $_SESSION['oLP']->lp_id . '">' . Display::return_icon('pixel.gif', $publication_lang_var, array('class' => 'toolactionplaceholdericon toolsettings')) . $publication_lang_var . '</a>';
            $return .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&gradebook=&action=view&lp_id=' . $_SESSION['oLP']->lp_id . '">' . Display::return_icon('pixel.gif', $view_lang_var, array('class' => 'toolactionplaceholdericon toolactionauthorpreview')) . $view_lang_var . '</a>';
            $return .= '</div>';
        }
        // we need to start a form when we want to update all the mp3 files
        if ($_GET['updateaudio'] == 'true' and count($arrLP) != 0) {
            $return .= '<form action="' . api_get_self() . '?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;action=' . Security::remove_XSS($_GET['action']) . '&amp;lp_id=' . Security::remove_XSS($_GET['lp_id']) . '" method="post" enctype="multipart/form-data" name="updatemp3" id="updatemp3">';
            $return .= Display::display_warning_message(get_lang('LeaveEmptyToKeepCurrentFile'));
        }
        $return .= '<div id="content_with_secondary_actions" style="padding:10px 30px 0px 30px;"><div class="rounded" style="width: 100%; padding: 1px;"><table  class="gallery" style="width: 100%;"><tr><td><div id="GalleryContainer">';
        for ($i = 0; $i < count($arrLP); $i++) {
            $id = $arrLP[$i]['id'];
            $web_title = $arrLP[$i]['title'];
            $title = trim($web_title);
            // Unique ID for avoid use the same FLV video for create MP3 files
            $title = $title . '_hash_' . uniqid('', true);
            $title = str_replace(array(' ', '.'), '_', $title);
            $display_order = $arrLP[$i]['display_order'];
            $parent_item_id = $arrLP[$i]['parent_item_id'];
            $item_type = $arrLP[$i]['item_type'];
            if ($item_type == "link") {
                $img_type = "../img/navigation/link_48.png";
            } elseif ($item_type == "document") {
                $img_type = "../img/navigation/doc_48.png";
            } elseif ($item_type == "quiz") {
                $img_type = "../img/navigation/quiz_48.png";
            } elseif ($item_type == "survey") {
                $img_type = "../img/navigation/survey_48.png";
            } elseif ($item_type == "forum") {
                $img_type = "../img/navigation/forum_48.png";
            } elseif ($item_type == "student_publication") {
                $img_type = "../img/navigation/assignement_48.png";
            }
            $return .= '<div class="imageBox" id="imageBox' . $id . '">
                        <div class="imageBox_theImage" style="background-image:url(\'../img/scenario.png\')">
                            <div style="background-image:url(' . $img_type . ');background-repeat:no-repeat;width:100px;height:100px;background-position: center center;">
                                <p style="font-size:12px;font:verdana;">' . $web_title . '</p>
                            </div>
                        </div>
                        <div>';
            $return .= '<a href="' . api_get_self() . '?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&action=edit_item&view=build&id=' . $arrLP[$i]['id'] . '&lp_id=' . $this->lp_id . '&path_item=' . $arrLP[$i]['path'] . '">' . Display::return_icon('pixel.gif', get_lang('Edit'), array('class' => 'actionplaceholdericon actionedit')) . '
                            </a>
                            <input type="hidden" name="hdnItemId[]" value="' . $arrLP[$i]['id'] . '">
                            <input type="hidden" name="hdnItemOrder[]" value="' . ($i + 1) . '">
                            <a href="' . api_get_self() . '?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&action=delete_item&id=' . $arrLP[$i]['id'] . '&lp_id=' . $this->lp_id . '" onclick="javascript:if(!confirm(\'' . get_lang("ConfirmYourChoice") . '\')) return false;">' . Display::return_icon('pixel.gif', get_lang('Delete'), array('class' => 'actionplaceholdericon actiondelete')) . '
                            </a>
                        </div></div>';
        }
        $return .= '</div>
		<div id="insertionMarker">
		<img src="../img/marker_top.gif">
		<img src="../img/marker_middle.gif" id="insertionMarkerLine">
		<img src="../img/marker_bottom.gif">
		</div>
		<div id="dragDropContent">
		</div><div style="clear:both">
		</div>';
        $return .= '</td></tr>';
        if (count($arrLP) > 0) {
            $return .= '<tr><td align="right"><form  method="post"><div style="clear:both;padding-bottom:10px">';
            //	$return .= '<button class="save" type="submit" name="savescenario" id="savescenario" value="Save Display Order" onclick="saveImageOrder()">'.get_lang('SaveScenario').'</button>';
            $return .= '</div></form></td></tr>';
        } else {
            $return .= '<tr><td align="center"><a href="' . api_get_self() . '?' . api_get_cidreq() . '&gradebook=&action=add_item&type=step&lp_id=' . $_SESSION['oLP']->lp_id . '">' . api_convert_encoding(get_lang('CourseEmpty'), $charset, api_get_system_encoding()) . '</a></td></tr>';
        }
        $return .= '</table></div></div>';
        return $return;
    }
Exemplo n.º 7
0
 /**
  * Function used by SortableTable to generate the data to display
  * @param int $from
  * @param int $per_page
  * @param int $column
  * @param string $direction
  * @param int $sort
  * @return array|mixed
  */
 public function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null)
 {
     //variables load in index.php
     global $my_score_in_gradebook, $certificate_min_score;
     $scoretotal = 0;
     // determine sorting type
     $col_adjust = api_is_allowed_to_edit() ? 1 : 0;
     // By id
     $this->column = 5;
     switch ($this->column) {
         // Type
         case 0 + $col_adjust:
             $sorting = GradebookDataGenerator::GDG_SORT_TYPE;
             break;
         case 1 + $col_adjust:
             $sorting = GradebookDataGenerator::GDG_SORT_NAME;
             break;
         case 2 + $col_adjust:
             $sorting = GradebookDataGenerator::GDG_SORT_DESCRIPTION;
             break;
         case 3 + $col_adjust:
             $sorting = GradebookDataGenerator::GDG_SORT_WEIGHT;
             break;
         case 4 + $col_adjust:
             $sorting = GradebookDataGenerator::GDG_SORT_DATE;
         case 5 + $col_adjust:
             $sorting = GradebookDataGenerator::GDG_SORT_ID;
             break;
     }
     if ($this->direction == 'DESC') {
         $sorting |= GradebookDataGenerator::GDG_SORT_DESC;
     } else {
         $sorting |= GradebookDataGenerator::GDG_SORT_ASC;
     }
     //status of user in course
     $user_id = api_get_user_id();
     $course_code = api_get_course_id();
     $courseId = api_get_course_int_id();
     $session_id = api_get_session_id();
     $status_user = api_get_status_of_user_in_course($user_id, $courseId);
     $data_array = $this->datagen->get_data($sorting, $from, $this->per_page);
     // generate the data to display
     $sortable_data = array();
     $weight_total_links = 0;
     $main_categories = array();
     $main_cat = Category::load(null, null, $course_code, null, null, $session_id, false);
     $total_categories_weight = 0;
     $scoredisplay = ScoreDisplay::instance();
     //Categories
     foreach ($data_array as $data) {
         // list of items inside the gradebook (exercises, lps, forums, etc)
         $row = array();
         $item = $item_category = $data[0];
         $id = $item->get_id();
         //if the item is invisible, wrap it in a span with class invisible
         $invisibility_span_open = api_is_allowed_to_edit() && $item->is_visible() == '0' ? '<span class="invisible">' : '';
         $invisibility_span_close = api_is_allowed_to_edit() && $item->is_visible() == '0' ? '</span>' : '';
         if (api_is_allowed_to_edit(null, true)) {
             //id
             $row[] = $this->build_id_column($item);
         }
         //Type
         $row[] = $this->build_type_column($item);
         //Name
         if (get_class($item) == 'Category') {
             $row[] = $invisibility_span_open . '<h3>' . $item->get_name() . '</h3>' . $invisibility_span_close;
             $main_categories[$item->get_id()]['name'] = $item->get_name();
         } else {
             $row[] = $invisibility_span_open . $this->build_name_link($item) . $invisibility_span_close;
             $main_categories[$item->get_id()]['name'] = $this->build_name_link($item);
         }
         $main_categories[$item->get_id()]['weight'] = $item->get_weight();
         $total_categories_weight += $item->get_weight();
         //Description
         $row[] = $invisibility_span_open . $data[2] . $invisibility_span_close;
         //Weight
         //$row[] = $invisibility_span_open .Display::tag('h4', $data['3'] .' / '.$this->currentcat->get_weight()).$invisibility_span_close;
         //$average = $data['3']/$this->currentcat->get_weight()*100;
         $average = $scoredisplay->display_score(array($data['3'], $this->currentcat->get_weight()), SCORE_SIMPLE, SCORE_BOTH, true);
         if (api_is_allowed_to_edit(null, true)) {
             $row[] = $invisibility_span_open . Display::tag('h4', $average) . $invisibility_span_close;
         } else {
             $row[] = $invisibility_span_open . $average . $invisibility_span_close;
         }
         $category_weight = $item->get_weight();
         if (api_is_allowed_to_edit(null, true)) {
             $weight_total_links += $data[3];
         } else {
             $cattotal = Category::load($_GET['selectcat']);
             $scoretotal = $cattotal[0]->calc_score(api_get_user_id());
             $item_value = $scoredisplay->display_score($scoretotal, SCORE_SIMPLE);
         }
         //Date
         //$row[] = $invisibility_span_open.$data[4].$invisibility_span_close;
         //Edit (for admins)
         if (api_is_allowed_to_edit(null, true)) {
             $cat = new Category();
             $show_message = $cat->show_message_resource_delete($item->get_course_code());
             if ($show_message === false) {
                 $row[] = $this->build_edit_column($item);
             }
         } else {
             //students get the results and certificates columns
             if (count($this->evals_links) > 0 && $status_user != 1) {
                 $value_data = isset($data[4]) ? $data[4] : null;
                 if (!is_null($value_data)) {
                     $row[] = Display::tag('h4', $value_data);
                 } else {
                     $row[] = $this->build_edit_column($item);
                 }
             } else {
                 $score = $item->calc_score(api_get_user_id());
                 if (!empty($score[1])) {
                     $complete_score = $scoredisplay->display_score($score, SCORE_DIV_PERCENT);
                     $score = $score[0] / $score[1] * $item->get_weight();
                     $score = $scoredisplay->display_score(array($score, null), SCORE_SIMPLE);
                     $row[] = Display::tip($score, $complete_score);
                 } else {
                     $row[] = '-';
                 }
                 if (!empty($this->cats)) {
                     $row[] = $this->build_edit_column($item);
                 }
             }
         }
         //Category added
         $sortable_data[] = $row;
         // Loading childrens
         if (get_class($item) == 'Category') {
             $stud_id = api_get_user_id();
             $course_code = api_get_course_id();
             $session_id = api_get_session_id();
             $parent_id = $item->get_id();
             $cats = Category::load($parent_id, null, null, null, null, null);
             if (isset($cats[0])) {
                 $allcat = $cats[0]->get_subcategories($stud_id, $course_code, $session_id);
                 $alleval = $cats[0]->get_evaluations($stud_id);
                 $alllink = $cats[0]->get_links($stud_id);
                 $sub_cat_info = new GradebookDataGenerator($allcat, $alleval, $alllink);
                 $data_array = $sub_cat_info->get_data($sorting, $from, $this->per_page);
                 $total_weight = 0;
                 //Links
                 foreach ($data_array as $data) {
                     $row = array();
                     $item = $data[0];
                     //if the item is invisible, wrap it in a span with class invisible
                     $invisibility_span_open = api_is_allowed_to_edit() && $item->is_visible() == '0' ? '<span class="invisible">' : '';
                     $invisibility_span_close = api_is_allowed_to_edit() && $item->is_visible() == '0' ? '</span>' : '';
                     $main_categories[$parent_id]['children'][$item->get_id()]['name'] = $item->get_name();
                     $main_categories[$parent_id]['children'][$item->get_id()]['weight'] = $item->get_weight();
                     if (api_is_allowed_to_edit(null, true)) {
                         $row[] = $this->build_id_column($item);
                     }
                     $row[] = $this->build_type_column($item, array('style' => 'padding-left:5px'));
                     //Name
                     $row[] = $invisibility_span_open . "&nbsp;&nbsp;&nbsp;  " . $this->build_name_link($item) . $invisibility_span_close;
                     //Description
                     $row[] = $invisibility_span_open . $data[2] . $invisibility_span_close;
                     //Weight
                     //$weight = $data[3]/$category_weight*$main_cat[0]->get_weight();
                     $weight = $data[3];
                     //$extra = " - $data[3]  $category_weight -".$main_cat[0]->get_weight();
                     $total_weight += $weight;
                     $row[] = $invisibility_span_open . $weight . $invisibility_span_close;
                     if (api_is_allowed_to_edit(null, true)) {
                         //$weight_total_links += intval($data[3]);
                     } else {
                         $cattotal = Category::load($_GET['selectcat']);
                         $scoretotal = $cattotal[0]->calc_score(api_get_user_id());
                         $item_value = $scoretotal[0];
                     }
                     //Date
                     //$row[] = $invisibility_span_open.$data[4].$invisibility_span_close;
                     //Admins get an edit column
                     if (api_is_allowed_to_edit(null, true)) {
                         $cat = new Category();
                         $show_message = $cat->show_message_resource_delete($item->get_course_code());
                         if ($show_message === false) {
                             $row[] = $this->build_edit_column($item);
                         }
                     } else {
                         //students get the results and certificates columns
                         $eval_n_links = array_merge($alleval, $alllink);
                         if (count($eval_n_links) > 0 && $status_user != 1) {
                             $value_data = isset($data[4]) ? $data[4] : null;
                             if (!is_null($value_data)) {
                                 $score = $item->calc_score(api_get_user_id());
                                 $new_score = $data[3] * $score[0] / $score[1];
                                 $new_score = floatval(number_format($new_score, api_get_setting('gradebook_number_decimals')));
                                 $row[] = Display::tip($new_score, $data[4]);
                             }
                         }
                         if (!empty($cats)) {
                             $row[] = null;
                         }
                     }
                     $row['child_of'] = $parent_id;
                     $sortable_data[] = $row;
                 }
                 //"Warning row"
                 if (!empty($data_array)) {
                     if (api_is_allowed_to_edit()) {
                         // Compare the category weight to the sum of all weights inside the category
                         if (intval($total_weight) == $category_weight) {
                             $label = null;
                             $total = score_badges(array($total_weight . ' / ' . $category_weight, '100'));
                         } else {
                             $label = Display::return_icon('warning.png', sprintf(get_lang('TotalWeightMustBeX'), $category_weight));
                             $total = Display::badge($total_weight . ' / ' . $category_weight, 'warning');
                         }
                         $row = array(null, null, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<h5>" . get_lang('SubTotal') . '</h5>', null, $total . ' ' . $label, 'child_of' => $parent_id);
                         $sortable_data[] = $row;
                     }
                 }
             }
         }
         //end looping categories
     }
     //end looping categories
     if (api_is_allowed_to_edit()) {
         if (count($main_cat) > 1) {
             $main_weight = intval($main_cat[0]->get_weight());
             if (intval($total_categories_weight) == $main_weight) {
                 $total = score_badges(array($total_categories_weight . ' / ' . $main_weight, '100'));
             } else {
                 $total = Display::badge($total_categories_weight . ' / ' . $main_weight, 'warning');
             }
             $row = array(null, null, '<h3>' . get_lang('Total') . '</h3>', null, $total);
             $sortable_data[] = $row;
         }
     }
     // warning messages
     $view = isset($_GET['view']) ? $_GET['view'] : null;
     if (api_is_allowed_to_edit()) {
         if (isset($_GET['selectcat']) && $_GET['selectcat'] > 0 && $view != 'presence') {
             $id_cat = intval($_GET['selectcat']);
             $category = Category::load($id_cat);
             //$weight_category = intval($this->build_weight($category[0]));
             $weight_category = intval($this->build_weight($category[0]));
             $course_code = $this->build_course_code($category[0]);
             $weight_total_links = round($weight_total_links);
             if ($weight_total_links > $weight_category || $weight_total_links < $weight_category || $weight_total_links > $weight_category) {
                 $warning_message = sprintf(get_lang('TotalWeightMustBeX'), $weight_category);
                 $modify_icons = '<a class="right_link" href="gradebook_edit_cat.php?editcat=' . $id_cat . '&cidReq=' . $course_code . '">' . Display::return_icon('edit.png', $warning_message, array(), ICON_SIZE_SMALL) . '</a>';
                 $warning_message .= $modify_icons;
                 Display::display_warning_message($warning_message, false);
             }
             $content_html = DocumentManager::replace_user_info_into_html(api_get_user_id(), $course_code);
             if (!empty($content_html)) {
                 $new_content = explode('</head>', $content_html['content']);
             }
             if (empty($new_content[0])) {
                 $warning_message = get_lang('ThereIsNotACertificateAvailableByDefault');
                 $cert_icon = '<a class="right_link" href="../document/document.php?curdirpath=/certificates&' . $course_code . '&origin=gradebook&selectcat=' . $id_cat . '">' . Display::return_icon('certificate.png', get_lang('AttachCertificate'), array(), ICON_SIZE_SMALL) . '</a>';
                 Display::display_warning_message($warning_message . $cert_icon, false);
             }
         }
         if (empty($_GET['selectcat'])) {
             $categories = Category::load();
             $weight_categories = $certificate_min_scores = $course_codes = array();
             foreach ($categories as $category) {
                 $course_code_category = $this->build_course_code($category);
                 if (!empty($course_code)) {
                     if ($course_code_category == $course_code) {
                         $weight_categories[] = intval($this->build_weight($category));
                         $certificate_min_scores[] = intval($this->build_certificate_min_score($category));
                         $course_codes[] = $course_code;
                         break;
                     }
                 } else {
                     $weight_categories[] = intval($this->build_weight($category));
                     $certificate_min_scores[] = intval($this->build_certificate_min_score($category));
                     $course_codes[] = $course_code_category;
                 }
             }
             if (is_array($weight_categories) && is_array($certificate_min_scores) && is_array($course_codes)) {
                 $warning_message = '';
                 for ($x = 0; $x < count($weight_categories); $x++) {
                     $weight_category = intval($weight_categories[$x]);
                     $certificate_min_score = intval($certificate_min_scores[$x]);
                     $course_code = $course_codes[$x];
                     if (empty($certificate_min_score) || $certificate_min_score > $weight_category) {
                         $warning_message .= $course_code . '&nbsp;-&nbsp;' . get_lang('CertificateMinimunScoreIsRequiredAndMustNotBeMoreThan') . '&nbsp;' . $weight_category . '<br />';
                     }
                 }
                 if (!empty($warning_message)) {
                     Display::display_warning_message($warning_message, false);
                 }
             }
         }
     }
     return $sortable_data;
 }
                if (empty($objQuestionTmp->level)) {
                    $txtQuestionLevel = '-';
                }
                $questionLevel = Display::tag('div', $txtQuestionLevel, array('style' => $styleLevel));
                // Question score
                $questionScore = Display::tag('div', $objQuestionTmp->selectWeighting(), array('style' => $styleScore));
                echo '<div id="question_id_list_' . $id . '" >';
                echo '<div class="header_operations">';
                echo $questionName;
                echo $questionType;
                echo $questionCategory;
                echo $questionLevel;
                echo $questionScore;
                echo $actions;
                echo '</div>';
                echo '<div class="question-list-description-block">';
                echo '<p class="lead">' . get_lang($question_class) . '</p>';
                //echo get_lang('Level').': '.$objQuestionTmp->selectLevel();
                ExerciseLib::showQuestion($id, false, null, null, false, true, false, true, $objExercise->feedback_type, true);
                echo '</div>';
                echo '</div>';
                unset($objQuestionTmp);
            }
        }
    }
    if (!$nbrQuestions) {
        echo Display::display_warning_message(get_lang('NoQuestion'));
    }
    echo '</div>';
    //question list div
}
Exemplo n.º 9
0
/**
 * Check whether this survey has ended. If so, display message and exit rhis script
 */
function check_time_availability($surv_data) {

    $start_date = mktime(0, 0, 0, substr($surv_data['start_date'], 5, 2), substr($surv_data['start_date'], 8, 2), substr($surv_data['start_date'], 0, 4));
    $end_date = mktime(0, 0, 0, substr($surv_data['end_date'], 5, 2), substr($surv_data['end_date'], 8, 2), substr($surv_data['end_date'], 0, 4));
    $cur_date = time();

    if ($cur_date < $start_date) {
        Display :: display_warning_message(get_lang('SurveyNotAvailableYet'), false);
        Display :: display_footer();
        exit;
    }
    if ($cur_date > $end_date) {
        Display :: display_warning_message(get_lang('SurveyNotAvailableAnymore'), false);
        Display :: display_footer();
        exit;
    }
}
Exemplo n.º 10
0
    $defaults['comment'] = $document_data['comment'];
    $defaults['origin'] = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : null;
    $defaults['origin_opt'] = isset($_GET['origin_opt']) ? Security::remove_XSS($_GET['origin_opt']) : null;
    $form->setDefaults($defaults);
    show_return($parent_id, $dir_original, $call_from_tool, $slide_id, $is_certificate_mode);
    if ($is_certificate_mode) {
        $all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate(api_get_user_id(), api_get_course_id());
        $str_info = '';
        foreach ($all_information_by_create_certificate[0] as $info_value) {
            $str_info .= $info_value . '<br/>';
        }
        $create_certificate = get_lang('CreateCertificateWithTags');
        Display::display_normal_message($create_certificate . ': <br /><br />' . $str_info, false);
    }
    if ($extension == 'svg' && !api_browser_support('svg') && api_get_setting('enabled_support_svg') == 'true') {
        Display::display_warning_message(get_lang('BrowserDontSupportsSVG'));
    }
    echo $form->return_form();
}
Display::display_footer();
/* General functions */
/*
	Workhorse functions

	These do the actual work that is expected from of this tool, other functions
	are only there to support these ones.
*/
/**
This function changes the name of a certain file.
It needs no global variables, it takes all info from parameters.
It returns nothing.
Exemplo n.º 11
0
            } else {
                $resize_info = get_lang('NoResizing') . '<br />';
            }
            echo '<tr>';
            echo '<td align="center">';
            echo '<a href="edit_document.php?' . api_get_cidreq() . '&id=' . $row['id'] . '&origin=slideshow&origin_opt=' . $edit_slide_id . '&">
			      <img src="../img/edit.gif" border="0" title="' . get_lang('Modify') . '" alt="' . get_lang('Modify') . '" /></a><br />';
            echo $image_files_only[$slide] . ' <br />';
            echo $width . ' x ' . $height . ' <br />';
            echo round(filesize($image) / 1024, 2) . ' KB';
            echo ' - ' . $ext;
            echo '</td>';
            echo '</tr>';
            echo '<tr>';
            echo '<td align="center">';
            echo $resize_info;
            echo $resize_widht;
            echo $resize_height;
            echo '</td>';
            echo '</tr>';
        }
        echo '</table>';
    } else {
        Display::display_warning_message(get_lang('FileNotFound'));
    }
} else {
    if ($slide_id != 'all') {
        Display::display_warning_message(get_lang('NoDataAvailable'));
    }
}
Display::display_footer();
Exemplo n.º 12
0
if (isset($_GET['overwritemax'])) {
    Display::display_warning_message(get_lang('OverWriteMax'), false);
}
if (isset($_GET['importoverwritescore'])) {
    Display::display_confirmation_message(get_lang('ImportOverWriteScore') . ' ' . $_GET['importoverwritescore']);
}
if (isset($_GET['import_user_error'])) {
    $userinfo = api_get_user_info($_GET['import_user_error']);
    Display::display_warning_message(get_lang('UserInfoDoesNotMatch') . ' ' . api_get_person_name($userinfo['firstname'], $userinfo['lastname']));
}
if (isset($_GET['allresdeleted'])) {
    Display::display_confirmation_message(get_lang('AllResultDeleted'));
}
if (isset($_GET['import_score_error'])) {
    $userinfo = api_get_user_info($_GET['import_score_error']);
    Display::display_warning_message(get_lang('ScoreDoesNotMatch') . ' ' . api_get_person_name($userinfo['firstname'], $userinfo['lastname']));
}
if ($file_type == null) {
    //show the result header
    if (isset($export_result_form) && !isset($edit_res_form)) {
        echo $export_result_form->display();
        DisplayGradebook::display_header_result($eval[0], $currentcat[0]->get_id(), 1);
    } else {
        if (isset($import_result_form)) {
            echo $import_result_form->display();
        }
        if (isset($edit_res_form)) {
            echo $edit_res_form->toHtml();
        }
        DisplayGradebook::display_header_result($eval[0], $currentcat[0]->get_id(), 1);
    }
Exemplo n.º 13
0
    $result = rmdirr($archive_path, true, true);
    if (!empty($htaccess)) {
        @file_put_contents($archive_path . '/.htaccess', $htaccess);
    }
    if ($result) {
        $message = 'ArchiveDirCleanupSucceeded';
        $type = 'confirmation';
    } else {
        $message = 'ArchiveDirCleanupFailed';
        $type = 'error';
    }
    header('Location: ' . api_get_self() . '?msg=' . $message . '&type=' . $type);
    exit;
}
Display::display_header(get_lang('ArchiveDirCleanup'));
Display::display_warning_message(get_lang('ArchiveDirCleanupDescr'));
if (isset($_GET['msg']) && isset($_GET['type'])) {
    if (in_array($_GET['msg'], array('ArchiveDirCleanupSucceeded', 'ArchiveDirCleanupFailed'))) {
        switch ($_GET['type']) {
            case 'error':
                $message = Display::return_message(get_lang($_GET['msg']), 'error');
                break;
            case 'confirmation':
                $message = Display::return_message(get_lang($_GET['msg']), 'confirm');
        }
    }
}
if (!empty($message)) {
    echo $message;
}
$form->display();
Exemplo n.º 14
0
if (isset($_GET['overwritemax'])) {
    Display::display_warning_message(get_lang('OverWriteMax'), false);
}
if (isset($_GET['importoverwritescore'])) {
    Display::display_confirmation_message(get_lang('ImportOverWriteScore') . ' ' . $_GET['importoverwritescore']);
}
if (isset($_GET['import_user_error'])) {
    $userinfo = api_get_user_info($_GET['import_user_error']);
    Display::display_warning_message(get_lang('UserInfoDoesNotMatch') . ' ' . $userinfo['complete_name']);
}
if (isset($_GET['allresdeleted'])) {
    Display::display_confirmation_message(get_lang('AllResultDeleted'));
}
if (isset($_GET['import_score_error'])) {
    $userinfo = api_get_user_info($_GET['import_score_error']);
    Display::display_warning_message(get_lang('ScoreDoesNotMatch') . ' ' . $userinfo['complete_name']);
}
if ($file_type == null) {
    //show the result header
    if (isset($export_result_form) && !isset($edit_res_form)) {
        echo $export_result_form->display();
        DisplayGradebook::display_header_result($eval[0], $currentcat[0]->get_id(), 1);
    } else {
        if (isset($import_result_form)) {
            echo $import_result_form->display();
        }
        if (isset($edit_res_form)) {
            echo $edit_res_form->toHtml();
        }
        DisplayGradebook::display_header_result($eval[0], $currentcat[0]->get_id(), 1);
    }
Exemplo n.º 15
0
    Display::display_confirmation_message(get_lang('RecycleFinished'));
} elseif (Security::check_token('post') && (isset($_POST['recycle_option']) && $_POST['recycle_option'] == 'select_items')) {
    // Clear token
    Security::clear_token();
    $cb = new CourseBuilder();
    $course = $cb->build();
    // Add token to Course select form
    $hiddenFields['sec_token'] = Security::get_token();
    CourseSelectForm::display_form($course, $hiddenFields);
} else {
    $cb = new CourseBuilder();
    $course = $cb->build();
    if (!$course->has_resources()) {
        echo get_lang('NoResourcesToRecycle');
    } else {
        Display::display_warning_message(get_lang('RecycleWarning'), false);
        $form = new FormValidator('recycle_course', 'post', api_get_self() . '?' . api_get_cidreq());
        $form->addElement('header', get_lang('SelectOptionForBackup'));
        $form->addElement('radio', 'recycle_option', null, get_lang('FullRecycle'), 'full_backup');
        $form->addElement('radio', 'recycle_option', null, get_lang('LetMeSelectItems'), 'select_items');
        $form->addButtonSave(get_lang('RecycleCourse'));
        $form->setDefaults(array('recycle_option' => 'select_items'));
        // Add Security token
        $token = Security::get_token();
        $form->addElement('hidden', 'sec_token');
        $form->setConstants(array('sec_token' => $token));
        $form->display();
    }
}
// Display the footer
Display::display_footer();
Exemplo n.º 16
0
            if (api_is_allowed_to_edit(null, true)) {
                ?>
                        <button type="submit" class="btn btn-primary"><?php 
                echo get_lang('Save');
                ?>
</button>
                    <?php 
            }
        }
        ?>
  </div>
                </div>
        </form>
    <?php 
    } else {
        echo Display::display_warning_message('<a href="' . api_get_path(WEB_CODE_PATH) . 'user/user.php?' . api_get_cidreq() . '">' . get_lang('ThereAreNoRegisteredLearnersInsidetheCourse') . '</a>', false);
    }
} else {
    echo Display::page_header(get_lang('AttendanceSheetReport'));
    // View for students
    ?>
    <?php 
    if (!empty($users_presence)) {
        ?>
        <div>
            <table width="250px;">
                <tr>
                    <td><?php 
        echo get_lang('ToAttend') . ': ';
        ?>
</td>
Exemplo n.º 17
0
            $form->addButtonSave($text);
        } else {
            $class = "add";
            $text = get_lang('AddCategory');
            $form->setDefaults(array('auth_course_child' => 'TRUE'));
            $form->addButtonCreate($text);
        }
        $form->display();
    } elseif (api_get_multiple_access_url() && api_get_current_access_url_id() != 1) {
        // If multiple URLs and not main URL, prevent edition and inform user
        Display::display_warning_message(get_lang('CourseCategoriesAreGlobal'));
    }
} else {
    // If multiple URLs and not main URL, prevent deletion and inform user
    if ($action == 'delete' && api_get_multiple_access_url() && api_get_current_access_url_id() != 1) {
        Display::display_warning_message(get_lang('CourseCategoriesAreGlobal'));
    }
    echo '<div class="actions">';
    $link = null;
    if (!empty($parentInfo)) {
        $parentCode = $parentInfo['parent_id'];
        echo Display::url(Display::return_icon('back.png', get_lang("Back"), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . 'admin/course_category.php?category=' . $parentCode);
    }
    if (empty($parentInfo) || $parentInfo['auth_cat_child'] == 'TRUE') {
        echo Display::url(Display::return_icon('new_folder.png', get_lang("AddACategory"), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . 'admin/course_category.php?action=add&category=' . Security::remove_XSS($category));
    }
    echo '</div>';
    if (!empty($parentInfo)) {
        echo Display::page_subheader($parentInfo['name'] . ' (' . $parentInfo['code'] . ')');
    }
    echo listCategories($category);
Exemplo n.º 18
0
    /**
     * Shows a question
     *
     * @param int    $questionId question id
     * @param bool   $only_questions if true only show the questions, no exercise title
     * @param bool   $origin  i.e = learnpath
     * @param string $current_item current item from the list of questions
     * @param bool   $show_title
     * @param bool   $freeze
     * @param array  $user_choice
     * @param bool   $show_comment
     * @param bool   $exercise_feedback
     * @param bool   $show_answers
     * */
    public static function showQuestion($questionId, $only_questions = false, $origin = false, $current_item = '', $show_title = true, $freeze = false, $user_choice = array(), $show_comment = false, $exercise_feedback = null, $show_answers = false)
    {
        $course_id = api_get_course_int_id();
        // Change false to true in the following line to enable answer hinting
        $debug_mark_answer = $show_answers;
        // Reads question information
        if (!($objQuestionTmp = Question::read($questionId))) {
            // Question not found
            return false;
        }
        if ($exercise_feedback != EXERCISE_FEEDBACK_TYPE_END) {
            $show_comment = false;
        }
        $answerType = $objQuestionTmp->selectType();
        $pictureName = $objQuestionTmp->selectPicture();
        $s = '';
        if ($answerType != HOT_SPOT && $answerType != HOT_SPOT_DELINEATION) {
            // Question is not a hotspot
            if (!$only_questions) {
                $questionDescription = $objQuestionTmp->selectDescription();
                if ($show_title) {
                    TestCategory::displayCategoryAndTitle($objQuestionTmp->id);
                    echo Display::div($current_item . '. ' . $objQuestionTmp->selectTitle(), array('class' => 'question_title'));
                }
                if (!empty($questionDescription)) {
                    echo Display::div($questionDescription, array('class' => 'question_description'));
                }
            }
            if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION)) && $freeze) {
                return '';
            }
            echo '<div class="question_options row">';
            // construction of the Answer object (also gets all answers details)
            $objAnswerTmp = new Answer($questionId);
            $nbrAnswers = $objAnswerTmp->selectNbrAnswers();
            $quiz_question_options = Question::readQuestionOption($questionId, $course_id);
            // For "matching" type here, we need something a little bit special
            // because the match between the suggestions and the answers cannot be
            // done easily (suggestions and answers are in the same table), so we
            // have to go through answers first (elems with "correct" value to 0).
            $select_items = array();
            //This will contain the number of answers on the left side. We call them
            // suggestions here, for the sake of comprehensions, while the ones
            // on the right side are called answers
            $num_suggestions = 0;
            if (in_array($answerType, [MATCHING, DRAGGABLE, MATCHING_DRAGGABLE])) {
                if ($answerType == DRAGGABLE) {
                    $s .= '<div class="col-md-12 ui-widget ui-helper-clearfix">
                        <div class="clearfix">
                        <ul class="exercise-draggable-answer ui-helper-reset ui-helper-clearfix">';
                } else {
                    $s .= <<<HTML
                        <div id="drag{$questionId}_question" class="drag_question">
                            <table class="data_table">
HTML;
                }
                // Iterate through answers
                $x = 1;
                //mark letters for each answer
                $letter = 'A';
                $answer_matching = array();
                $cpt1 = array();
                for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
                    $answerCorrect = $objAnswerTmp->isCorrect($answerId);
                    $numAnswer = $objAnswerTmp->selectAutoId($answerId);
                    if ($answerCorrect == 0) {
                        // options (A, B, C, ...) that will be put into the list-box
                        // have the "correct" field set to 0 because they are answer
                        $cpt1[$x] = $letter;
                        $answer_matching[$x] = $objAnswerTmp->selectAnswerByAutoId($numAnswer);
                        $x++;
                        $letter++;
                    }
                }
                $i = 1;
                $select_items[0]['id'] = 0;
                $select_items[0]['letter'] = '--';
                $select_items[0]['answer'] = '';
                foreach ($answer_matching as $id => $value) {
                    $select_items[$i]['id'] = $value['id'];
                    $select_items[$i]['letter'] = $cpt1[$id];
                    $select_items[$i]['answer'] = $value['answer'];
                    $i++;
                }
                $user_choice_array_position = array();
                if (!empty($user_choice)) {
                    foreach ($user_choice as $item) {
                        $user_choice_array_position[$item['position']] = $item['answer'];
                    }
                }
                $num_suggestions = $nbrAnswers - $x + 1;
            } elseif ($answerType == FREE_ANSWER) {
                $fck_content = isset($user_choice[0]) && !empty($user_choice[0]['answer']) ? $user_choice[0]['answer'] : null;
                $form = new FormValidator('free_choice_' . $questionId);
                $config = array('ToolbarSet' => 'TestFreeAnswer');
                $form->addHtmlEditor("choice[" . $questionId . "]", null, false, false, $config);
                $form->setDefaults(array("choice[" . $questionId . "]" => $fck_content));
                $s .= $form->returnForm();
            } elseif ($answerType == ORAL_EXPRESSION) {
                // Add nanog
                if (api_get_setting('enable_nanogong') == 'true') {
                    //@todo pass this as a parameter
                    global $exercise_stat_info, $exerciseId, $exe_id;
                    if (!empty($exercise_stat_info)) {
                        $params = array('exercise_id' => $exercise_stat_info['exe_exo_id'], 'exe_id' => $exercise_stat_info['exe_id'], 'question_id' => $questionId);
                    } else {
                        $params = array('exercise_id' => $exerciseId, 'exe_id' => 'temp_exe', 'question_id' => $questionId);
                    }
                    $nano = new Nanogong($params);
                    echo $nano->show_button();
                }
                $form = new FormValidator('free_choice_' . $questionId);
                $config = array('ToolbarSet' => 'TestFreeAnswer');
                $form->addHtmlEditor("choice[" . $questionId . "]", null, false, false, $config);
                //$form->setDefaults(array("choice[" . $questionId . "]" => $fck_content));
                $s .= $form->return_form();
            }
            // Now navigate through the possible answers, using the max number of
            // answers for the question as a limiter
            $lines_count = 1;
            // a counter for matching-type answers
            if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
                $header = Display::tag('th', get_lang('Options'));
                foreach ($objQuestionTmp->options as $item) {
                    if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
                        if (in_array($item, $objQuestionTmp->options)) {
                            $header .= Display::tag('th', get_lang($item));
                        } else {
                            $header .= Display::tag('th', $item);
                        }
                    } else {
                        $header .= Display::tag('th', $item);
                    }
                }
                if ($show_comment) {
                    $header .= Display::tag('th', get_lang('Feedback'));
                }
                $s .= '<table class="table table-hover table-striped">';
                $s .= Display::tag('tr', $header, array('style' => 'text-align:left;'));
            }
            if ($show_comment) {
                if (in_array($answerType, array(MULTIPLE_ANSWER, MULTIPLE_ANSWER_COMBINATION, UNIQUE_ANSWER, UNIQUE_ANSWER_IMAGE, UNIQUE_ANSWER_NO_OPTION, GLOBAL_MULTIPLE_ANSWER))) {
                    $header = Display::tag('th', get_lang('Options'));
                    if ($exercise_feedback == EXERCISE_FEEDBACK_TYPE_END) {
                        $header .= Display::tag('th', get_lang('Feedback'));
                    }
                    $s .= '<table class="table table-hover table-striped">';
                    $s .= Display::tag('tr', $header, array('style' => 'text-align:left;'));
                }
            }
            $matching_correct_answer = 0;
            $user_choice_array = array();
            if (!empty($user_choice)) {
                foreach ($user_choice as $item) {
                    $user_choice_array[] = $item['answer'];
                }
            }
            for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
                $answer = $objAnswerTmp->selectAnswer($answerId);
                $answerCorrect = $objAnswerTmp->isCorrect($answerId);
                $numAnswer = $objAnswerTmp->selectAutoId($answerId);
                $comment = $objAnswerTmp->selectComment($answerId);
                $attributes = array();
                // Unique answer
                if (in_array($answerType, [UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION, UNIQUE_ANSWER_IMAGE])) {
                    $input_id = 'choice-' . $questionId . '-' . $answerId;
                    if (isset($user_choice[0]['answer']) && $user_choice[0]['answer'] == $numAnswer) {
                        $attributes = array('id' => $input_id, 'checked' => 1, 'selected' => 1);
                    } else {
                        $attributes = array('id' => $input_id);
                    }
                    if ($debug_mark_answer) {
                        if ($answerCorrect) {
                            $attributes['checked'] = 1;
                            $attributes['selected'] = 1;
                        }
                    }
                    if ($show_comment) {
                        $s .= '<tr><td>';
                    }
                    if ($answerType == UNIQUE_ANSWER_IMAGE) {
                        if ($show_comment) {
                            if (empty($comment)) {
                                $s .= '<div id="answer' . $questionId . $numAnswer . '" ' . 'class="exercise-unique-answer-image" style="text-align: center">';
                            } else {
                                $s .= '<div id="answer' . $questionId . $numAnswer . '" ' . 'class="exercise-unique-answer-image col-xs-6 col-sm-12" style="text-align: center">';
                            }
                        } else {
                            $s .= '<div id="answer' . $questionId . $numAnswer . '" ' . 'class="exercise-unique-answer-image col-xs-6 col-md-3" style="text-align: center">';
                        }
                    }
                    $answer = Security::remove_XSS($answer, STUDENT);
                    $s .= Display::input('hidden', 'choice2[' . $questionId . ']', '0');
                    $answer_input = null;
                    if ($answerType == UNIQUE_ANSWER_IMAGE) {
                        $attributes['style'] = 'display: none;';
                        $answer = '<div class="thumbnail">' . $answer . '</div>';
                    }
                    $answer_input .= '<label class="radio">';
                    $answer_input .= Display::input('radio', 'choice[' . $questionId . ']', $numAnswer, $attributes);
                    $answer_input .= $answer;
                    $answer_input .= '</label>';
                    if ($answerType == UNIQUE_ANSWER_IMAGE) {
                        $answer_input .= "</div>";
                    }
                    if ($show_comment) {
                        $s .= $answer_input;
                        $s .= '</td>';
                        $s .= '<td>';
                        $s .= $comment;
                        $s .= '</td>';
                        $s .= '</tr>';
                    } else {
                        $s .= $answer_input;
                    }
                } elseif ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE || $answerType == GLOBAL_MULTIPLE_ANSWER) {
                    $input_id = 'choice-' . $questionId . '-' . $answerId;
                    $answer = Security::remove_XSS($answer, STUDENT);
                    if (in_array($numAnswer, $user_choice_array)) {
                        $attributes = array('id' => $input_id, 'checked' => 1, 'selected' => 1);
                    } else {
                        $attributes = array('id' => $input_id);
                    }
                    if ($debug_mark_answer) {
                        if ($answerCorrect) {
                            $attributes['checked'] = 1;
                            $attributes['selected'] = 1;
                        }
                    }
                    if ($answerType == MULTIPLE_ANSWER || $answerType == GLOBAL_MULTIPLE_ANSWER) {
                        $s .= '<input type="hidden" name="choice2[' . $questionId . ']" value="0" />';
                        $answer_input = '<label class="checkbox">';
                        $answer_input .= Display::input('checkbox', 'choice[' . $questionId . '][' . $numAnswer . ']', $numAnswer, $attributes);
                        $answer_input .= $answer;
                        $answer_input .= '</label>';
                        if ($show_comment) {
                            $s .= '<tr><td>';
                            $s .= $answer_input;
                            $s .= '</td>';
                            $s .= '<td>';
                            $s .= $comment;
                            $s .= '</td>';
                            $s .= '</tr>';
                        } else {
                            $s .= $answer_input;
                        }
                    } elseif ($answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
                        $my_choice = array();
                        if (!empty($user_choice_array)) {
                            foreach ($user_choice_array as $item) {
                                $item = explode(':', $item);
                                $my_choice[$item[0]] = $item[1];
                            }
                        }
                        $s .= '<tr>';
                        $s .= Display::tag('td', $answer);
                        if (!empty($quiz_question_options)) {
                            foreach ($quiz_question_options as $id => $item) {
                                if (isset($my_choice[$numAnswer]) && $id == $my_choice[$numAnswer]) {
                                    $attributes = array('checked' => 1, 'selected' => 1);
                                } else {
                                    $attributes = array();
                                }
                                if ($debug_mark_answer) {
                                    if ($id == $answerCorrect) {
                                        $attributes['checked'] = 1;
                                        $attributes['selected'] = 1;
                                    }
                                }
                                $s .= Display::tag('td', Display::input('radio', 'choice[' . $questionId . '][' . $numAnswer . ']', $id, $attributes), array('style' => ''));
                            }
                        }
                        if ($show_comment) {
                            $s .= '<td>';
                            $s .= $comment;
                            $s .= '</td>';
                        }
                        $s .= '</tr>';
                    }
                } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION) {
                    // multiple answers
                    $input_id = 'choice-' . $questionId . '-' . $answerId;
                    if (in_array($numAnswer, $user_choice_array)) {
                        $attributes = array('id' => $input_id, 'checked' => 1, 'selected' => 1);
                    } else {
                        $attributes = array('id' => $input_id);
                    }
                    if ($debug_mark_answer) {
                        if ($answerCorrect) {
                            $attributes['checked'] = 1;
                            $attributes['selected'] = 1;
                        }
                    }
                    $answer = Security::remove_XSS($answer, STUDENT);
                    $answer_input = '<input type="hidden" name="choice2[' . $questionId . ']" value="0" />';
                    $answer_input .= '<label class="checkbox">';
                    $answer_input .= Display::input('checkbox', 'choice[' . $questionId . '][' . $numAnswer . ']', 1, $attributes);
                    $answer_input .= $answer;
                    $answer_input .= '</label>';
                    if ($show_comment) {
                        $s .= '<tr>';
                        $s .= '<td>';
                        $s .= $answer_input;
                        $s .= '</td>';
                        $s .= '<td>';
                        $s .= $comment;
                        $s .= '</td>';
                        $s .= '</tr>';
                    } else {
                        $s .= $answer_input;
                    }
                } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
                    $s .= '<input type="hidden" name="choice2[' . $questionId . ']" value="0" />';
                    $my_choice = array();
                    if (!empty($user_choice_array)) {
                        foreach ($user_choice_array as $item) {
                            $item = explode(':', $item);
                            if (isset($item[1]) && isset($item[0])) {
                                $my_choice[$item[0]] = $item[1];
                            }
                        }
                    }
                    $answer = Security::remove_XSS($answer, STUDENT);
                    $s .= '<tr>';
                    $s .= Display::tag('td', $answer);
                    foreach ($objQuestionTmp->options as $key => $item) {
                        if (isset($my_choice[$numAnswer]) && $key == $my_choice[$numAnswer]) {
                            $attributes = array('checked' => 1, 'selected' => 1);
                        } else {
                            $attributes = array();
                        }
                        if ($debug_mark_answer) {
                            if ($key == $answerCorrect) {
                                $attributes['checked'] = 1;
                                $attributes['selected'] = 1;
                            }
                        }
                        $s .= Display::tag('td', Display::input('radio', 'choice[' . $questionId . '][' . $numAnswer . ']', $key, $attributes));
                    }
                    if ($show_comment) {
                        $s .= '<td>';
                        $s .= $comment;
                        $s .= '</td>';
                    }
                    $s .= '</tr>';
                } elseif ($answerType == FILL_IN_BLANKS) {
                    // display the question, with field empty, for student to fill it,
                    // or filled to display the answer in the Question preview of the exercice/admin.php page
                    $displayForStudent = true;
                    $listAnswerInformations = FillBlanks::getAnswerInfo($answer);
                    $separatorStartRegexp = FillBlanks::escapeForRegexp($listAnswerInformations['blankseparatorstart']);
                    $separatorEndRegexp = FillBlanks::escapeForRegexp($listAnswerInformations['blankseparatorend']);
                    list($answer) = explode('::', $answer);
                    //Correct answers
                    $correctAnswerList = $listAnswerInformations['tabwords'];
                    //Student's answer
                    $studentAnswerList = array();
                    if (isset($user_choice[0]['answer'])) {
                        $arrayStudentAnswer = FillBlanks::getAnswerInfo($user_choice[0]['answer'], true);
                        $studentAnswerList = $arrayStudentAnswer['studentanswer'];
                    }
                    // If the question must be shown with the answer (in page exercice/admin.php) for teacher preview
                    // set the student-answer to the correct answer
                    if ($debug_mark_answer) {
                        $studentAnswerList = $correctAnswerList;
                        $displayForStudent = false;
                    }
                    if (!empty($correctAnswerList) && !empty($studentAnswerList)) {
                        $answer = "";
                        for ($i = 0; $i < count($listAnswerInformations["commonwords"]) - 1; $i++) {
                            // display the common word
                            $answer .= $listAnswerInformations["commonwords"][$i];
                            // display the blank word
                            $correctItem = $listAnswerInformations["tabwords"][$i];
                            $correctItemRegexp = $correctItem;
                            // replace / with \/ to allow the preg_replace bellow and all the regexp char
                            $correctItemRegexp = FillBlanks::getRegexpProtected($correctItemRegexp);
                            if (isset($studentAnswerList[$i])) {
                                // If student already started this test and answered this question,
                                // fill the blank with his previous answers
                                // may be "" if student viewed the question, but did not fill the blanks
                                $correctItem = $studentAnswerList[$i];
                            }
                            $attributes["style"] = "width:" . $listAnswerInformations["tabinputsize"][$i] . "px";
                            $answer .= FillBlanks::getFillTheBlankHtml($separatorStartRegexp, $separatorEndRegexp, $correctItemRegexp, $questionId, $correctItem, $attributes, $answer, $listAnswerInformations, $displayForStudent, $i);
                        }
                        // display the last common word
                        $answer .= $listAnswerInformations["commonwords"][$i];
                    } else {
                        // display empty [input] with the right width for student to fill it
                        $separatorStartRegexp = FillBlanks::escapeForRegexp($listAnswerInformations['blankseparatorstart']);
                        $separatorEndRegexp = FillBlanks::escapeForRegexp($listAnswerInformations['blankseparatorend']);
                        $answer = "";
                        for ($i = 0; $i < count($listAnswerInformations["commonwords"]) - 1; $i++) {
                            // display the common words
                            $answer .= $listAnswerInformations["commonwords"][$i];
                            // display the blank word
                            $attributes["style"] = "width:" . $listAnswerInformations["tabinputsize"][$i] . "px";
                            $correctItem = $listAnswerInformations["tabwords"][$i];
                            $correctItemRegexp = $correctItem;
                            // replace / with \/ to allow the preg_replace bellow and all the regexp char
                            $correctItemRegexp = FillBlanks::getRegexpProtected($correctItemRegexp);
                            $answer .= FillBlanks::getFillTheBlankHtml($separatorStartRegexp, $separatorEndRegexp, $correctItemRegexp, $questionId, '', $attributes, $answer, $listAnswerInformations, $displayForStudent, $i);
                        }
                        // display the last common word
                        $answer .= $listAnswerInformations["commonwords"][$i];
                    }
                    $s .= $answer;
                } elseif ($answerType == CALCULATED_ANSWER) {
                    /*
                     * In the CALCULATED_ANSWER test
                     * you mustn't have [ and ] in the textarea
                     * you mustn't have @@ in the textarea
                     * the text to find mustn't be empty or contains only spaces
                     * the text to find mustn't contains HTML tags
                     * the text to find mustn't contains char "
                     */
                    if ($origin !== null) {
                        global $exe_id;
                        $trackAttempts = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
                        $sqlTrackAttempt = 'SELECT answer FROM ' . $trackAttempts . '
                                            WHERE exe_id=' . $exe_id . ' AND question_id=' . $questionId;
                        $rsLastAttempt = Database::query($sqlTrackAttempt);
                        $rowLastAttempt = Database::fetch_array($rsLastAttempt);
                        $answer = $rowLastAttempt['answer'];
                        if (empty($answer)) {
                            $_SESSION['calculatedAnswerId'][$questionId] = mt_rand(1, $nbrAnswers);
                            $answer = $objAnswerTmp->selectAnswer($_SESSION['calculatedAnswerId'][$questionId]);
                        }
                    }
                    list($answer) = explode('@@', $answer);
                    // $correctAnswerList array of array with correct anwsers 0=> [0=>[\p] 1=>[plop]]
                    api_preg_match_all('/\\[[^]]+\\]/', $answer, $correctAnswerList);
                    // get student answer to display it if student go back to previous calculated answer question in a test
                    if (isset($user_choice[0]['answer'])) {
                        api_preg_match_all('/\\[[^]]+\\]/', $answer, $studentAnswerList);
                        $studentAnswerListTobecleaned = $studentAnswerList[0];
                        $studentAnswerList = array();
                        for ($i = 0; $i < count($studentAnswerListTobecleaned); $i++) {
                            $answerCorrected = $studentAnswerListTobecleaned[$i];
                            $answerCorrected = api_preg_replace('| / <font color="green"><b>.*$|', '', $answerCorrected);
                            $answerCorrected = api_preg_replace('/^\\[/', '', $answerCorrected);
                            $answerCorrected = api_preg_replace('|^<font color="red"><s>|', '', $answerCorrected);
                            $answerCorrected = api_preg_replace('|</s></font>$|', '', $answerCorrected);
                            $answerCorrected = '[' . $answerCorrected . ']';
                            $studentAnswerList[] = $answerCorrected;
                        }
                    }
                    // If display preview of answer in test view for exemple, set the student answer to the correct answers
                    if ($debug_mark_answer) {
                        // contain the rights answers surronded with brackets
                        $studentAnswerList = $correctAnswerList[0];
                    }
                    /*
                    Split the response by bracket
                    tabComments is an array with text surrounding the text to find
                    we add a space before and after the answerQuestion to be sure to
                    have a block of text before and after [xxx] patterns
                    so we have n text to find ([xxx]) and n+1 block of texts before,
                    between and after the text to find
                    */
                    $tabComments = api_preg_split('/\\[[^]]+\\]/', ' ' . $answer . ' ');
                    if (!empty($correctAnswerList) && !empty($studentAnswerList)) {
                        $answer = "";
                        $i = 0;
                        foreach ($studentAnswerList as $studentItem) {
                            // remove surronding brackets
                            $studentResponse = api_substr($studentItem, 1, api_strlen($studentItem) - 2);
                            $size = strlen($studentItem);
                            $attributes['class'] = self::detectInputAppropriateClass($size);
                            $answer .= $tabComments[$i] . Display::input('text', "choice[{$questionId}][]", $studentResponse, $attributes);
                            $i++;
                        }
                        $answer .= $tabComments[$i];
                    } else {
                        // display exercise with empty input fields
                        // every [xxx] are replaced with an empty input field
                        foreach ($correctAnswerList[0] as $item) {
                            $size = strlen($item);
                            $attributes['class'] = self::detectInputAppropriateClass($size);
                            $answer = str_replace($item, Display::input('text', "choice[{$questionId}][]", '', $attributes), $answer);
                        }
                    }
                    if ($origin !== null) {
                        $s = $answer;
                        break;
                    } else {
                        $s .= $answer;
                    }
                } elseif ($answerType == MATCHING) {
                    // matching type, showing suggestions and answers
                    // TODO: replace $answerId by $numAnswer
                    if ($answerCorrect != 0) {
                        // only show elements to be answered (not the contents of
                        // the select boxes, who are corrrect = 0)
                        $s .= '<tr><td width="45%" valign="top">';
                        $parsed_answer = $answer;
                        //left part questions
                        $s .= '<p class="indent">' . $lines_count . '.&nbsp;' . $parsed_answer . '</p></td>';
                        //middle part (matches selects)
                        $s .= '<td width="10%" valign="top" align="center" >
                                <div class="select-matching">
                                <select name="choice[' . $questionId . '][' . $numAnswer . ']">';
                        // fills the list-box
                        foreach ($select_items as $key => $val) {
                            // set $debug_mark_answer to true at function start to
                            // show the correct answer with a suffix '-x'
                            $selected = '';
                            if ($debug_mark_answer) {
                                if ($val['id'] == $answerCorrect) {
                                    $selected = 'selected="selected"';
                                }
                            }
                            //$user_choice_array_position
                            if (isset($user_choice_array_position[$numAnswer]) && $val['id'] == $user_choice_array_position[$numAnswer]) {
                                $selected = 'selected="selected"';
                            }
                            $s .= '<option value="' . $val['id'] . '" ' . $selected . '>' . $val['letter'] . '</option>';
                        }
                        // end foreach()
                        $s .= '</select></div></td><td width="5%" class="separate">&nbsp;</td>';
                        $s .= '<td width="40%" valign="top" >';
                        if (isset($select_items[$lines_count])) {
                            $s .= '<div class="text-right"><p class="indent">' . $select_items[$lines_count]['letter'] . '.&nbsp; ' . $select_items[$lines_count]['answer'] . '</p></div>';
                        } else {
                            $s .= '&nbsp;';
                        }
                        $s .= '</td>';
                        $s .= '</tr>';
                        $lines_count++;
                        //if the left side of the "matching" has been completely
                        // shown but the right side still has values to show...
                        if ($lines_count - 1 == $num_suggestions) {
                            // if it remains answers to shown at the right side
                            while (isset($select_items[$lines_count])) {
                                $s .= '<tr>
                                      <td colspan="2"></td>
                                      <td valign="top">';
                                $s .= '<b>' . $select_items[$lines_count]['letter'] . '.</b> ' . $select_items[$lines_count]['answer'];
                                $s .= "</td>\n                                </tr>";
                                $lines_count++;
                            }
                            // end while()
                        }
                        // end if()
                        $matching_correct_answer++;
                    }
                } elseif ($answerType == DRAGGABLE) {
                    if ($answerCorrect != 0) {
                        $parsed_answer = $answer;
                        /*$lines_count = '';
                          $data = $objAnswerTmp->getAnswerByAutoId($numAnswer);
                          $data = $objAnswerTmp->getAnswerByAutoId($data['correct']);
                          $lines_count = $data['answer'];*/
                        $windowId = $questionId . '_' . $lines_count;
                        $s .= '<li class="touch-items" id="' . $windowId . '">';
                        $s .= Display::div($parsed_answer, ['id' => "window_{$windowId}", 'class' => "window{$questionId}_question_draggable exercise-draggable-answer-option"]);
                        $selectedValue = 0;
                        $draggableSelectOptions = [];
                        foreach ($select_items as $key => $val) {
                            if ($debug_mark_answer) {
                                if ($val['id'] == $answerCorrect) {
                                    $selectedValue = $val['id'];
                                }
                            }
                            if (isset($user_choice[$matching_correct_answer]) && $val['id'] == $user_choice[$matching_correct_answer]['answer']) {
                                $selectedValue = $val['id'];
                            }
                            $draggableSelectOptions[$val['id']] = $val['letter'];
                        }
                        $s .= Display::select("choice[{$questionId}][{$numAnswer}]", $draggableSelectOptions, $selectedValue, ['id' => "window_{$windowId}_select", 'class' => 'select_option', 'style' => 'display: none;'], false);
                        if (!empty($answerCorrect) && !empty($selectedValue)) {
                            $s .= <<<JAVASCRIPT
                                <script>
                                    \$(function() {
                                        DraggableAnswer.deleteItem(
                                            \$('#{$questionId}_{$selectedValue}'),
                                            \$('#drop_{$windowId}')
                                        );
                                    });
                                </script>
JAVASCRIPT;
                        }
                        if (isset($select_items[$lines_count])) {
                            $s .= Display::div(Display::tag('b', $select_items[$lines_count]['letter']) . $select_items[$lines_count]['answer'], ['id' => "window_{$windowId}_answer", 'style' => 'display: none;']);
                        } else {
                            $s .= '&nbsp;';
                        }
                        $lines_count++;
                        if ($lines_count - 1 == $num_suggestions) {
                            while (isset($select_items[$lines_count])) {
                                $s .= Display::tag('b', $select_items[$lines_count]['letter']);
                                $s .= $select_items[$lines_count]['answer'];
                                $lines_count++;
                            }
                        }
                        $matching_correct_answer++;
                        $s .= '</li>';
                    }
                } elseif ($answerType == MATCHING_DRAGGABLE) {
                    if ($answerId == 1) {
                        echo $objAnswerTmp->getJs();
                    }
                    if ($answerCorrect != 0) {
                        $parsed_answer = $answer;
                        $windowId = "{$questionId}_{$lines_count}";
                        $s .= <<<HTML
                            <tr>
                                <td widht="45%">
                                    <div id="window_{$windowId}" class="window window_left_question window{$questionId}_question">
                                        <strong>{$lines_count}.</strong> {$parsed_answer}
                                    </div>
                                </td>
                                <td width="10%">
HTML;
                        $selectedValue = 0;
                        $questionOptions = [];
                        foreach ($select_items as $key => $val) {
                            if ($debug_mark_answer) {
                                if ($val['id'] == $answerCorrect) {
                                    $selectedValue = $val['id'];
                                }
                            }
                            if (isset($user_choice[$matching_correct_answer]) && $val['id'] == $user_choice[$matching_correct_answer]['answer']) {
                                $selectedValue = $val['id'];
                            }
                            $questionOptions[$val['id']] = $val['letter'];
                        }
                        $s .= Display::select("choice[{$questionId}][{$numAnswer}]", $questionOptions, $selectedValue, ['id' => "window_{$windowId}_select", 'class' => 'hidden'], false);
                        if (!empty($answerCorrect) && !empty($selectedValue)) {
                            // Show connect if is not freeze (question preview)
                            if (!$freeze) {
                                $s .= <<<JAVASCRIPT
                                <script>
                                    jsPlumb.ready(function() {
                                        jsPlumb.connect({
                                            source: 'window_{$windowId}',
                                            target: 'window_{$questionId}_{$selectedValue}_answer',
                                            endpoint: ['Blank', {radius: 15}],
                                            anchors: ['RightMiddle', 'LeftMiddle'],
                                            paintStyle: {strokeStyle: '#8A8888', lineWidth: 8},
                                            connector: [
                                                MatchingDraggable.connectorType,
                                                {curvines: MatchingDraggable.curviness}
                                            ]
                                        });
                                    });
                                </script>
JAVASCRIPT;
                            }
                        }
                        $s .= <<<HTML
                            </td>
                            <td width="45%">
HTML;
                        if (isset($select_items[$lines_count])) {
                            $s .= <<<HTML
                                <div id="window_{$windowId}_answer" class="window window_right_question">
                                    <strong>{$select_items[$lines_count]['letter']}.</strong> {$select_items[$lines_count]['answer']}
                                </div>
HTML;
                        } else {
                            $s .= '&nbsp;';
                        }
                        $s .= '</td></tr>';
                        $lines_count++;
                        if ($lines_count - 1 == $num_suggestions) {
                            while (isset($select_items[$lines_count])) {
                                $s .= <<<HTML
                                    <tr>
                                        <td colspan="2"></td>
                                        <td>
                                            <strong>{$select_items[$lines_count]['letter']}</strong>
                                            {$select_items[$lines_count]['answer']}
                                        </td>
                                    </tr>
HTML;
                                $lines_count++;
                            }
                        }
                        $matching_correct_answer++;
                    }
                }
            }
            // end for()
            if ($show_comment) {
                $s .= '</table>';
            } elseif (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE, UNIQUE_ANSWER_NO_OPTION, MULTIPLE_ANSWER_TRUE_FALSE, MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE])) {
                $s .= '</table>';
            }
            if ($answerType == DRAGGABLE) {
                $s .= "</ul></div>";
                $counterAnswer = 1;
                $s .= '<div class="col-md-12"><div class="row">';
                for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
                    $answerCorrect = $objAnswerTmp->isCorrect($answerId);
                    $windowId = $questionId . '_' . $counterAnswer;
                    if ($answerCorrect) {
                        $s .= Display::div($counterAnswer, ['id' => "drop_{$windowId}", 'class' => 'droppable col-md-2']);
                        $counterAnswer++;
                    }
                }
                $s .= '</div></div>';
            }
            if (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) {
                $s .= '</div>';
            }
            $s .= '</div>';
            // destruction of the Answer object
            unset($objAnswerTmp);
            // destruction of the Question object
            unset($objQuestionTmp);
            if ($origin != 'export') {
                echo $s;
            } else {
                return $s;
            }
        } elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_DELINEATION) {
            // Question is a HOT_SPOT
            //checking document/images visibility
            if (api_is_platform_admin() || api_is_course_admin()) {
                $course = api_get_course_info();
                $doc_id = DocumentManager::get_document_id($course, '/images/' . $pictureName);
                if (is_numeric($doc_id)) {
                    $images_folder_visibility = api_get_item_visibility($course, 'document', $doc_id, api_get_session_id());
                    if (!$images_folder_visibility) {
                        //This message is shown only to the course/platform admin if the image is set to visibility = false
                        Display::display_warning_message(get_lang('ChangeTheVisibilityOfTheCurrentImage'));
                    }
                }
            }
            $questionName = $objQuestionTmp->selectTitle();
            $questionDescription = $objQuestionTmp->selectDescription();
            if ($freeze) {
                echo Display::img($objQuestionTmp->selectPicturePath());
                return;
            }
            // Get the answers, make a list
            $objAnswerTmp = new Answer($questionId);
            $nbrAnswers = $objAnswerTmp->selectNbrAnswers();
            // get answers of hotpost
            $answers_hotspot = array();
            for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
                $answers = $objAnswerTmp->selectAnswerByAutoId($objAnswerTmp->selectAutoId($answerId));
                $answers_hotspot[$answers['id']] = $objAnswerTmp->selectAnswer($answerId);
            }
            // display answers of hotpost order by id
            $answer_list = '<div style="padding: 10px; margin-left: 0px; border: 1px solid #A4A4A4; height: 408px; width: 200px;"><b>' . get_lang('HotspotZones') . '</b><dl>';
            if (!empty($answers_hotspot)) {
                ksort($answers_hotspot);
                foreach ($answers_hotspot as $key => $value) {
                    $answer_list .= '<dt>' . $key . '.- ' . $value . '</dt><br />';
                }
            }
            $answer_list .= '</dl></div>';
            if ($answerType == HOT_SPOT_DELINEATION) {
                $answer_list = '';
                $swf_file = 'hotspot_delineation_user';
                $swf_height = 405;
            } else {
                $swf_file = 'hotspot_user';
                $swf_height = 436;
            }
            if (!$only_questions) {
                if ($show_title) {
                    TestCategory::displayCategoryAndTitle($objQuestionTmp->id);
                    echo '<div class="question_title">' . $current_item . '. ' . $questionName . '</div>';
                }
                //@todo I need to the get the feedback type
                echo '<input type="hidden" name="hidden_hotspot_id" value="' . $questionId . '" />';
                echo '<table class="exercise_questions" >
                      <tr>
                        <td valign="top" colspan="2">';
                echo $questionDescription;
                echo '</td></tr>';
            }
            $canClick = isset($_GET['editQuestion']) ? '0' : (isset($_GET['modifyAnswers']) ? '0' : '1');
            $s .= '<script type="text/javascript" src="../plugin/hotspot/JavaScriptFlashGateway.js"></script>
                            <script src="../plugin/hotspot/hotspot.js" type="text/javascript" ></script>
                            <script type="text/javascript">
                            <!--
                            // Globals
                            // Major version of Flash required
                            var requiredMajorVersion = 7;
                            // Minor version of Flash required
                            var requiredMinorVersion = 0;
                            // Minor version of Flash required
                            var requiredRevision = 0;
                            // the version of javascript supported
                            var jsVersion = 1.0;
                            // -->
                            </script>
                            <script language="VBScript" type="text/vbscript">
                            <!-- // Visual basic helper required to detect Flash Player ActiveX control version information
                            Function VBGetSwfVer(i)
                              on error resume next
                              Dim swControl, swVersion
                              swVersion = 0

                              set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash." + CStr(i))
                              if (IsObject(swControl)) then
                                swVersion = swControl.GetVariable("$version")
                              end if
                              VBGetSwfVer = swVersion
                            End Function
                            // -->
                            </script>

                            <script language="JavaScript1.1" type="text/javascript">
                            <!-- // Detect Client Browser type
                            var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
                            var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
                            var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
                            jsVersion = 1.1;
                            // JavaScript helper required to detect Flash Player PlugIn version information
                            function JSGetSwfVer(i) {
                                // NS/Opera version >= 3 check for Flash plugin in plugin array
                                if (navigator.plugins != null && navigator.plugins.length > 0) {
                                    if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
                                        var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
                                        var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
                                        descArray = flashDescription.split(" ");
                                        tempArrayMajor = descArray[2].split(".");
                                        versionMajor = tempArrayMajor[0];
                                        versionMinor = tempArrayMajor[1];
                                        if ( descArray[3] != "" ) {
                                            tempArrayMinor = descArray[3].split("r");
                                        } else {
                                            tempArrayMinor = descArray[4].split("r");
                                        }
                                        versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
                                        flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
                                    } else {
                                        flashVer = -1;
                                    }
                                }
                                // MSN/WebTV 2.6 supports Flash 4
                                else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
                                // WebTV 2.5 supports Flash 3
                                else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
                                // older WebTV supports Flash 2
                                else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
                                // Can\'t detect in all other cases
                                else
                                {
                                    flashVer = -1;
                                }
                                return flashVer;
                            }
                            // When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available

                            function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) {
                                reqVer = parseFloat(reqMajorVer + "." + reqRevision);
                                // loop backwards through the versions until we find the newest version
                                for (i=25;i>0;i--) {
                                    if (isIE && isWin && !isOpera) {
                                        versionStr = VBGetSwfVer(i);
                                    } else {
                                        versionStr = JSGetSwfVer(i);
                                    }
                                    if (versionStr == -1 ) {
                                        return false;
                                    } else if (versionStr != 0) {
                                        if(isIE && isWin && !isOpera) {
                                            tempArray         = versionStr.split(" ");
                                            tempString        = tempArray[1];
                                            versionArray      = tempString .split(",");
                                        } else {
                                            versionArray      = versionStr.split(".");
                                        }
                                        versionMajor      = versionArray[0];
                                        versionMinor      = versionArray[1];
                                        versionRevision   = versionArray[2];

                                        versionString     = versionMajor + "." + versionRevision;   // 7.0r24 == 7.24
                                        versionNum        = parseFloat(versionString);
                                        // is the major.revision >= requested major.revision AND the minor version >= requested minor
                                        if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
                                            return true;
                                        } else {
                                            return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );
                                        }
                                    }
                                }
                            }
                            // -->
                            </script>';
            $s .= '<tr><td valign="top" colspan="2" width="520"><table><tr><td width="520">
                        <script>
                            <!--
                            // Version check based upon the values entered above in "Globals"
                            var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

                            // Check to see if the version meets the requirements for playback
                            if (hasReqestedVersion) {  // if we\'ve detected an acceptable version
                                var oeTags = \'<object type="application/x-shockwave-flash" data="../plugin/hotspot/' . $swf_file . '.swf?modifyAnswers=' . $questionId . '&canClick:' . $canClick . '" width="600" height="' . $swf_height . '">\'
                                            + \'<param name="wmode" value="transparent">\'
                                            + \'<param name="movie" value="../plugin/hotspot/' . $swf_file . '.swf?modifyAnswers=' . $questionId . '&canClick:' . $canClick . '" />\'
                                            + \'<\\/object>\';
                                document.write(oeTags);   // embed the Flash Content SWF when all tests are passed
                            } else {  // flash is too old or we can\'t detect the plugin
                                var alternateContent = "Error<br \\/>"
                                    + "Hotspots requires Macromedia Flash 7.<br \\/>"
                                    + "<a href=\\"http://www.macromedia.com/go/getflash/\\">Get Flash<\\/a>";
                                document.write(alternateContent);  // insert non-flash content
                            }
                            // -->
                        </script>
                        </td>
                        <td valign="top" align="left">' . $answer_list . '</td></tr>
                        </table>
            </td></tr>';
            echo $s;
            echo '</table>';
        }
        return $nbrAnswers;
    }
    if (count($users) == 0) {
        header('Location: ' . api_get_self() . '?erroroneuser=&selecteval=' . Security::remove_XSS($_GET['selecteval']));
        exit;
    } else {
        foreach ($users as $user_id) {
            $result = new Result();
            $result->set_user_id($user_id);
            $result->set_evaluation_id($_GET['selecteval']);
            $result->add();
        }
    }
    header('Location: gradebook_view_result.php?adduser=&selecteval=' . Security::remove_XSS($_GET['selecteval']));
    exit;
} elseif ($_POST['firstLetterUser']) {
    $firstletter = $_POST['firstLetterUser'];
    if (!empty($firstletter)) {
        header('Location: ' . api_get_self() . '?firstletter=' . Security::remove_XSS($firstletter) . '&selecteval=' . Security::remove_XSS($_GET['selecteval']));
        exit;
    }
}
$interbreadcrumb[] = array('url' => Security::remove_XSS($_SESSION['gradebook_dest']), 'name' => get_lang('Gradebook'));
$interbreadcrumb[] = array('url' => 'gradebook_view_result.php?selecteval=' . Security::remove_XSS($_GET['selecteval']), 'name' => get_lang('ViewResult'));
Display::display_header(get_lang('AddUserToEval'));
if (isset($_GET['erroroneuser'])) {
    Display::display_warning_message(get_lang('AtLeastOneUser'), false);
}
DisplayGradebook::display_header_result($evaluation[0], null, 0, 0);
echo '<div class="main">';
echo $add_user_form->toHtml();
echo '</div>';
Display::display_footer();
Exemplo n.º 20
0
    /**
     * Shows a question
     *
     * @param int    $questionId question id
     * @param bool   $only_questions if true only show the questions, no exercise title
     * @param bool   $origin  i.e = learnpath
     * @param string $current_item current item from the list of questions
     * @param bool   $show_title
     * @param bool   $freeze
     * @param array  $user_choice
     * @param bool   $show_comment
     * @param bool   $exercise_feedback
     * @param bool   $show_answers
     * */
    public static function showQuestion($questionId, $only_questions = false, $origin = false, $current_item = '', $show_title = true, $freeze = false, $user_choice = array(), $show_comment = false, $exercise_feedback = null, $show_answers = false)
    {
        $course_id = api_get_course_int_id();
        // Change false to true in the following line to enable answer hinting
        $debug_mark_answer = $show_answers;
        // Reads question information
        if (!($objQuestionTmp = Question::read($questionId))) {
            // Question not found
            return false;
        }
        if ($exercise_feedback != EXERCISE_FEEDBACK_TYPE_END) {
            $show_comment = false;
        }
        $answerType = $objQuestionTmp->selectType();
        $pictureName = $objQuestionTmp->selectPicture();
        $s = '';
        if ($answerType != HOT_SPOT && $answerType != HOT_SPOT_DELINEATION) {
            // Question is not a hotspot
            if (!$only_questions) {
                $questionDescription = $objQuestionTmp->selectDescription();
                if ($show_title) {
                    TestCategory::displayCategoryAndTitle($objQuestionTmp->id);
                    echo Display::div($current_item . '. ' . $objQuestionTmp->selectTitle(), array('class' => 'question_title'));
                }
                if (!empty($questionDescription)) {
                    echo Display::div($questionDescription, array('class' => 'question_description'));
                }
            }
            if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION)) && $freeze) {
                return '';
            }
            echo '<div class="question_options row">';
            // construction of the Answer object (also gets all answers details)
            $objAnswerTmp = new Answer($questionId);
            $nbrAnswers = $objAnswerTmp->selectNbrAnswers();
            $quiz_question_options = Question::readQuestionOption($questionId, $course_id);
            // For "matching" type here, we need something a little bit special
            // because the match between the suggestions and the answers cannot be
            // done easily (suggestions and answers are in the same table), so we
            // have to go through answers first (elems with "correct" value to 0).
            $select_items = array();
            //This will contain the number of answers on the left side. We call them
            // suggestions here, for the sake of comprehensions, while the ones
            // on the right side are called answers
            $num_suggestions = 0;
            if (in_array($answerType, [MATCHING, DRAGGABLE, MATCHING_DRAGGABLE])) {
                if ($answerType == DRAGGABLE) {
                    $s .= '<div class="col-md-12 ui-widget ui-helper-clearfix">
                        <div class="clearfix">
                        <ul class="exercise-draggable-answer ui-helper-reset ui-helper-clearfix">';
                } else {
                    $s .= '<div id="drag' . $questionId . '_question" class="drag_question">
                           <table class="data_table">';
                }
                // Iterate through answers
                $x = 1;
                //mark letters for each answer
                $letter = 'A';
                $answer_matching = array();
                $cpt1 = array();
                for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
                    $answerCorrect = $objAnswerTmp->isCorrect($answerId);
                    $numAnswer = $objAnswerTmp->selectAutoId($answerId);
                    if ($answerCorrect == 0) {
                        // options (A, B, C, ...) that will be put into the list-box
                        // have the "correct" field set to 0 because they are answer
                        $cpt1[$x] = $letter;
                        $answer_matching[$x] = $objAnswerTmp->selectAnswerByAutoId($numAnswer);
                        $x++;
                        $letter++;
                    }
                }
                $i = 1;
                $select_items[0]['id'] = 0;
                $select_items[0]['letter'] = '--';
                $select_items[0]['answer'] = '';
                foreach ($answer_matching as $id => $value) {
                    $select_items[$i]['id'] = $value['id_auto'];
                    $select_items[$i]['letter'] = $cpt1[$id];
                    $select_items[$i]['answer'] = $value['answer'];
                    $i++;
                }
                $user_choice_array_position = array();
                if (!empty($user_choice)) {
                    foreach ($user_choice as $item) {
                        $user_choice_array_position[$item['position']] = $item['answer'];
                    }
                }
                $num_suggestions = $nbrAnswers - $x + 1;
            } elseif ($answerType == FREE_ANSWER) {
                $fck_content = isset($user_choice[0]) && !empty($user_choice[0]['answer']) ? $user_choice[0]['answer'] : null;
                $form = new FormValidator('free_choice_' . $questionId);
                $config = array('ToolbarSet' => 'TestFreeAnswer');
                $form->addHtmlEditor("choice[" . $questionId . "]", null, false, false, $config);
                $form->setDefaults(array("choice[" . $questionId . "]" => $fck_content));
                $s .= $form->returnForm();
            } elseif ($answerType == ORAL_EXPRESSION) {
                // Add nanog
                if (api_get_setting('document.enable_nanogong') == 'true') {
                    //@todo pass this as a parameter
                    global $exercise_stat_info, $exerciseId, $exe_id;
                    if (!empty($exercise_stat_info)) {
                        $params = array('exercise_id' => $exercise_stat_info['exe_exo_id'], 'exe_id' => $exercise_stat_info['exe_id'], 'question_id' => $questionId);
                    } else {
                        $params = array('exercise_id' => $exerciseId, 'exe_id' => 'temp_exe', 'question_id' => $questionId);
                    }
                    $nano = new Nanogong($params);
                    echo $nano->show_button();
                }
                $form = new FormValidator('free_choice_' . $questionId);
                $config = array('ToolbarSet' => 'TestFreeAnswer');
                $form->addHtmlEditor("choice[" . $questionId . "]", null, false, false, $config);
                //$form->setDefaults(array("choice[" . $questionId . "]" => $fck_content));
                $s .= $form->returnForm();
            }
            // Now navigate through the possible answers, using the max number of
            // answers for the question as a limiter
            $lines_count = 1;
            // a counter for matching-type answers
            if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
                $header = Display::tag('th', get_lang('Options'));
                foreach ($objQuestionTmp->options as $item) {
                    if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
                        if (in_array($item, $objQuestionTmp->options)) {
                            $header .= Display::tag('th', get_lang($item));
                        } else {
                            $header .= Display::tag('th', $item);
                        }
                    } else {
                        $header .= Display::tag('th', $item);
                    }
                }
                if ($show_comment) {
                    $header .= Display::tag('th', get_lang('Feedback'));
                }
                $s .= '<table class="table table-hover table-striped">';
                $s .= Display::tag('tr', $header, array('style' => 'text-align:left;'));
            }
            if ($show_comment) {
                if (in_array($answerType, array(MULTIPLE_ANSWER, MULTIPLE_ANSWER_COMBINATION, UNIQUE_ANSWER, UNIQUE_ANSWER_IMAGE, UNIQUE_ANSWER_NO_OPTION, GLOBAL_MULTIPLE_ANSWER))) {
                    $header = Display::tag('th', get_lang('Options'));
                    if ($exercise_feedback == EXERCISE_FEEDBACK_TYPE_END) {
                        $header .= Display::tag('th', get_lang('Feedback'));
                    }
                    $s .= '<table class="table table-hover table-striped">';
                    $s .= Display::tag('tr', $header, array('style' => 'text-align:left;'));
                }
            }
            $matching_correct_answer = 0;
            $user_choice_array = array();
            if (!empty($user_choice)) {
                foreach ($user_choice as $item) {
                    $user_choice_array[] = $item['answer'];
                }
            }
            for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
                $answer = $objAnswerTmp->selectAnswer($answerId);
                $answerCorrect = $objAnswerTmp->isCorrect($answerId);
                $numAnswer = $objAnswerTmp->selectAutoId($answerId);
                $comment = $objAnswerTmp->selectComment($answerId);
                $attributes = array();
                // Unique answer
                if (in_array($answerType, [UNIQUE_ANSWER, UNIQUE_ANSWER_NO_OPTION, UNIQUE_ANSWER_IMAGE])) {
                    $input_id = 'choice-' . $questionId . '-' . $answerId;
                    if (isset($user_choice[0]['answer']) && $user_choice[0]['answer'] == $numAnswer) {
                        $attributes = array('id' => $input_id, 'checked' => 1, 'selected' => 1);
                    } else {
                        $attributes = array('id' => $input_id);
                    }
                    if ($debug_mark_answer) {
                        if ($answerCorrect) {
                            $attributes['checked'] = 1;
                            $attributes['selected'] = 1;
                        }
                    }
                    if ($show_comment) {
                        $s .= '<tr><td>';
                    }
                    if ($answerType == UNIQUE_ANSWER_IMAGE) {
                        if ($show_comment) {
                            if (empty($comment)) {
                                $s .= '<div id="answer' . $questionId . $numAnswer . '" ' . 'class="exercise-unique-answer-image" style="text-align: center">';
                            } else {
                                $s .= '<div id="answer' . $questionId . $numAnswer . '" ' . 'class="exercise-unique-answer-image col-xs-6 col-sm-12" style="text-align: center">';
                            }
                        } else {
                            $s .= '<div id="answer' . $questionId . $numAnswer . '" ' . 'class="exercise-unique-answer-image col-xs-6 col-md-3" style="text-align: center">';
                        }
                    }
                    $answer = Security::remove_XSS($answer, STUDENT);
                    $s .= Display::input('hidden', 'choice2[' . $questionId . ']', '0');
                    $answer_input = null;
                    if ($answerType == UNIQUE_ANSWER_IMAGE) {
                        $attributes['style'] = 'display: none;';
                        $answer = '<div class="thumbnail">' . $answer . '</div>';
                    }
                    $answer_input .= '<label class="radio">';
                    $answer_input .= Display::input('radio', 'choice[' . $questionId . ']', $numAnswer, $attributes);
                    $answer_input .= $answer;
                    $answer_input .= '</label>';
                    if ($answerType == UNIQUE_ANSWER_IMAGE) {
                        $answer_input .= "</div>";
                    }
                    if ($show_comment) {
                        $s .= $answer_input;
                        $s .= '</td>';
                        $s .= '<td>';
                        $s .= $comment;
                        $s .= '</td>';
                        $s .= '</tr>';
                    } else {
                        $s .= $answer_input;
                    }
                } elseif ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE || $answerType == GLOBAL_MULTIPLE_ANSWER) {
                    $input_id = 'choice-' . $questionId . '-' . $answerId;
                    $answer = Security::remove_XSS($answer, STUDENT);
                    if (in_array($numAnswer, $user_choice_array)) {
                        $attributes = array('id' => $input_id, 'checked' => 1, 'selected' => 1);
                    } else {
                        $attributes = array('id' => $input_id);
                    }
                    if ($debug_mark_answer) {
                        if ($answerCorrect) {
                            $attributes['checked'] = 1;
                            $attributes['selected'] = 1;
                        }
                    }
                    if ($answerType == MULTIPLE_ANSWER || $answerType == GLOBAL_MULTIPLE_ANSWER) {
                        $s .= '<input type="hidden" name="choice2[' . $questionId . ']" value="0" />';
                        $answer_input = '<label class="checkbox">';
                        $answer_input .= Display::input('checkbox', 'choice[' . $questionId . '][' . $numAnswer . ']', $numAnswer, $attributes);
                        $answer_input .= $answer;
                        $answer_input .= '</label>';
                        if ($show_comment) {
                            $s .= '<tr><td>';
                            $s .= $answer_input;
                            $s .= '</td>';
                            $s .= '<td>';
                            $s .= $comment;
                            $s .= '</td>';
                            $s .= '</tr>';
                        } else {
                            $s .= $answer_input;
                        }
                    } elseif ($answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
                        $my_choice = array();
                        if (!empty($user_choice_array)) {
                            foreach ($user_choice_array as $item) {
                                $item = explode(':', $item);
                                $my_choice[$item[0]] = $item[1];
                            }
                        }
                        $s .= '<tr>';
                        $s .= Display::tag('td', $answer);
                        if (!empty($quiz_question_options)) {
                            foreach ($quiz_question_options as $id => $item) {
                                if (isset($my_choice[$numAnswer]) && $id == $my_choice[$numAnswer]) {
                                    $attributes = array('checked' => 1, 'selected' => 1);
                                } else {
                                    $attributes = array();
                                }
                                if ($debug_mark_answer) {
                                    if ($id == $answerCorrect) {
                                        $attributes['checked'] = 1;
                                        $attributes['selected'] = 1;
                                    }
                                }
                                $s .= Display::tag('td', Display::input('radio', 'choice[' . $questionId . '][' . $numAnswer . ']', $id, $attributes), array('style' => ''));
                            }
                        }
                        if ($show_comment) {
                            $s .= '<td>';
                            $s .= $comment;
                            $s .= '</td>';
                        }
                        $s .= '</tr>';
                    }
                } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION) {
                    // multiple answers
                    $input_id = 'choice-' . $questionId . '-' . $answerId;
                    if (in_array($numAnswer, $user_choice_array)) {
                        $attributes = array('id' => $input_id, 'checked' => 1, 'selected' => 1);
                    } else {
                        $attributes = array('id' => $input_id);
                    }
                    if ($debug_mark_answer) {
                        if ($answerCorrect) {
                            $attributes['checked'] = 1;
                            $attributes['selected'] = 1;
                        }
                    }
                    $answer = Security::remove_XSS($answer, STUDENT);
                    $answer_input = '<input type="hidden" name="choice2[' . $questionId . ']" value="0" />';
                    $answer_input .= '<label class="checkbox">';
                    $answer_input .= Display::input('checkbox', 'choice[' . $questionId . '][' . $numAnswer . ']', 1, $attributes);
                    $answer_input .= $answer;
                    $answer_input .= '</label>';
                    if ($show_comment) {
                        $s .= '<tr>';
                        $s .= '<td>';
                        $s .= $answer_input;
                        $s .= '</td>';
                        $s .= '<td>';
                        $s .= $comment;
                        $s .= '</td>';
                        $s .= '</tr>';
                    } else {
                        $s .= $answer_input;
                    }
                } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
                    $s .= '<input type="hidden" name="choice2[' . $questionId . ']" value="0" />';
                    $my_choice = array();
                    if (!empty($user_choice_array)) {
                        foreach ($user_choice_array as $item) {
                            $item = explode(':', $item);
                            if (isset($item[1]) && isset($item[0])) {
                                $my_choice[$item[0]] = $item[1];
                            }
                        }
                    }
                    $answer = Security::remove_XSS($answer, STUDENT);
                    $s .= '<tr>';
                    $s .= Display::tag('td', $answer);
                    foreach ($objQuestionTmp->options as $key => $item) {
                        if (isset($my_choice[$numAnswer]) && $key == $my_choice[$numAnswer]) {
                            $attributes = array('checked' => 1, 'selected' => 1);
                        } else {
                            $attributes = array();
                        }
                        if ($debug_mark_answer) {
                            if ($key == $answerCorrect) {
                                $attributes['checked'] = 1;
                                $attributes['selected'] = 1;
                            }
                        }
                        $s .= Display::tag('td', Display::input('radio', 'choice[' . $questionId . '][' . $numAnswer . ']', $key, $attributes));
                    }
                    if ($show_comment) {
                        $s .= '<td>';
                        $s .= $comment;
                        $s .= '</td>';
                    }
                    $s .= '</tr>';
                } elseif ($answerType == FILL_IN_BLANKS) {
                    // display the question, with field empty, for student to fill it,
                    // or filled to display the answer in the Question preview of the exercice/admin.php page
                    $displayForStudent = true;
                    $listAnswerInformations = FillBlanks::getAnswerInfo($answer);
                    $separatorStartRegexp = FillBlanks::escapeForRegexp($listAnswerInformations['blankseparatorstart']);
                    $separatorEndRegexp = FillBlanks::escapeForRegexp($listAnswerInformations['blankseparatorend']);
                    list($answer) = explode('::', $answer);
                    //Correct answers
                    $correctAnswerList = $listAnswerInformations['tabwords'];
                    //Student's answer
                    $studentAnswerList = array();
                    if (isset($user_choice[0]['answer'])) {
                        $arrayStudentAnswer = FillBlanks::getAnswerInfo($user_choice[0]['answer'], true);
                        $studentAnswerList = $arrayStudentAnswer['studentanswer'];
                    }
                    // If the question must be shown with the answer (in page exercice/admin.php) for teacher preview
                    // set the student-answer to the correct answer
                    if ($debug_mark_answer) {
                        $studentAnswerList = $correctAnswerList;
                        $displayForStudent = false;
                    }
                    if (!empty($correctAnswerList) && !empty($studentAnswerList)) {
                        $answer = "";
                        for ($i = 0; $i < count($listAnswerInformations["commonwords"]) - 1; $i++) {
                            // display the common word
                            $answer .= $listAnswerInformations["commonwords"][$i];
                            // display the blank word
                            $correctItem = $listAnswerInformations["tabwords"][$i];
                            $correctItemRegexp = $correctItem;
                            // replace / with \/ to allow the preg_replace bellow and all the regexp char
                            $correctItemRegexp = FillBlanks::getRegexpProtected($correctItemRegexp);
                            if (isset($studentAnswerList[$i])) {
                                // If student already started this test and answered this question,
                                // fill the blank with his previous answers
                                // may be "" if student viewed the question, but did not fill the blanks
                                $correctItem = $studentAnswerList[$i];
                            }
                            $attributes["style"] = "width:" . $listAnswerInformations["tabinputsize"][$i] . "px";
                            $answer .= FillBlanks::getFillTheBlankHtml($separatorStartRegexp, $separatorEndRegexp, $correctItemRegexp, $questionId, $correctItem, $attributes, $answer, $listAnswerInformations, $displayForStudent, $i);
                        }
                        // display the last common word
                        $answer .= $listAnswerInformations["commonwords"][$i];
                    } else {
                        // display empty [input] with the right width for student to fill it
                        $separatorStartRegexp = FillBlanks::escapeForRegexp($listAnswerInformations['blankseparatorstart']);
                        $separatorEndRegexp = FillBlanks::escapeForRegexp($listAnswerInformations['blankseparatorend']);
                        $answer = "";
                        for ($i = 0; $i < count($listAnswerInformations["commonwords"]) - 1; $i++) {
                            // display the common words
                            $answer .= $listAnswerInformations["commonwords"][$i];
                            // display the blank word
                            $attributes["style"] = "width:" . $listAnswerInformations["tabinputsize"][$i] . "px";
                            $correctItem = $listAnswerInformations["tabwords"][$i];
                            $correctItemRegexp = $correctItem;
                            // replace / with \/ to allow the preg_replace bellow and all the regexp char
                            $correctItemRegexp = FillBlanks::getRegexpProtected($correctItemRegexp);
                            $answer .= FillBlanks::getFillTheBlankHtml($separatorStartRegexp, $separatorEndRegexp, $correctItemRegexp, $questionId, '', $attributes, $answer, $listAnswerInformations, $displayForStudent, $i);
                        }
                        // display the last common word
                        $answer .= $listAnswerInformations["commonwords"][$i];
                    }
                    $s .= $answer;
                } elseif ($answerType == CALCULATED_ANSWER) {
                    /*
                     * In the CALCULATED_ANSWER test
                     * you mustn't have [ and ] in the textarea
                     * you mustn't have @@ in the textarea
                     * the text to find mustn't be empty or contains only spaces
                     * the text to find mustn't contains HTML tags
                     * the text to find mustn't contains char "
                     */
                    if ($origin !== null) {
                        global $exe_id;
                        $trackAttempts = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
                        $sql = 'SELECT answer
                                FROM ' . $trackAttempts . '
                                WHERE exe_id=' . $exe_id . ' AND question_id=' . $questionId;
                        $rsLastAttempt = Database::query($sql);
                        $rowLastAttempt = Database::fetch_array($rsLastAttempt);
                        $answer = $rowLastAttempt['answer'];
                        if (empty($answer)) {
                            $calculatedAnswerId = [];
                            $calculatedAnswerId[$questionId] = mt_rand(1, $nbrAnswers);
                            $answer = $objAnswerTmp->selectAnswer($calculatedAnswerId[$questionId]);
                            Session::write('calculatedAnswerId', $calculatedAnswerId);
                        }
                    }
                    list($answer) = explode('@@', $answer);
                    // $correctAnswerList array of array with correct anwsers 0=> [0=>[\p] 1=>[plop]]
                    api_preg_match_all('/\\[[^]]+\\]/', $answer, $correctAnswerList);
                    // get student answer to display it if student go back to previous calculated answer question in a test
                    if (isset($user_choice[0]['answer'])) {
                        api_preg_match_all('/\\[[^]]+\\]/', $answer, $studentAnswerList);
                        $studentAnswerListTobecleaned = $studentAnswerList[0];
                        $studentAnswerList = array();
                        for ($i = 0; $i < count($studentAnswerListTobecleaned); $i++) {
                            $answerCorrected = $studentAnswerListTobecleaned[$i];
                            $answerCorrected = api_preg_replace('| / <font color="green"><b>.*$|', '', $answerCorrected);
                            $answerCorrected = api_preg_replace('/^\\[/', '', $answerCorrected);
                            $answerCorrected = api_preg_replace('|^<font color="red"><s>|', '', $answerCorrected);
                            $answerCorrected = api_preg_replace('|</s></font>$|', '', $answerCorrected);
                            $answerCorrected = '[' . $answerCorrected . ']';
                            $studentAnswerList[] = $answerCorrected;
                        }
                    }
                    // If display preview of answer in test view for exemple, set the student answer to the correct answers
                    if ($debug_mark_answer) {
                        // contain the rights answers surronded with brackets
                        $studentAnswerList = $correctAnswerList[0];
                    }
                    /*
                    Split the response by bracket
                    tabComments is an array with text surrounding the text to find
                    we add a space before and after the answerQuestion to be sure to
                    have a block of text before and after [xxx] patterns
                    so we have n text to find ([xxx]) and n+1 block of texts before,
                    between and after the text to find
                    */
                    $tabComments = api_preg_split('/\\[[^]]+\\]/', ' ' . $answer . ' ');
                    if (!empty($correctAnswerList) && !empty($studentAnswerList)) {
                        $answer = "";
                        $i = 0;
                        foreach ($studentAnswerList as $studentItem) {
                            // remove surronding brackets
                            $studentResponse = api_substr($studentItem, 1, api_strlen($studentItem) - 2);
                            $size = strlen($studentItem);
                            $attributes['class'] = self::detectInputAppropriateClass($size);
                            $answer .= $tabComments[$i] . Display::input('text', "choice[{$questionId}][]", $studentResponse, $attributes);
                            $i++;
                        }
                        $answer .= $tabComments[$i];
                    } else {
                        // display exercise with empty input fields
                        // every [xxx] are replaced with an empty input field
                        foreach ($correctAnswerList[0] as $item) {
                            $size = strlen($item);
                            $attributes['class'] = self::detectInputAppropriateClass($size);
                            $answer = str_replace($item, Display::input('text', "choice[{$questionId}][]", '', $attributes), $answer);
                        }
                    }
                    if ($origin !== null) {
                        $s = $answer;
                        break;
                    } else {
                        $s .= $answer;
                    }
                } elseif ($answerType == MATCHING) {
                    // matching type, showing suggestions and answers
                    // TODO: replace $answerId by $numAnswer
                    if ($answerCorrect != 0) {
                        // only show elements to be answered (not the contents of
                        // the select boxes, who are corrrect = 0)
                        $s .= '<tr><td width="45%" valign="top">';
                        $parsed_answer = $answer;
                        //left part questions
                        $s .= '<p class="indent">' . $lines_count . '.&nbsp;' . $parsed_answer . '</p></td>';
                        //middle part (matches selects)
                        $s .= '<td width="10%" valign="top" align="center" >
                                <div class="select-matching">
                                <select name="choice[' . $questionId . '][' . $numAnswer . ']">';
                        // fills the list-box
                        foreach ($select_items as $key => $val) {
                            // set $debug_mark_answer to true at function start to
                            // show the correct answer with a suffix '-x'
                            $selected = '';
                            if ($debug_mark_answer) {
                                if ($val['id'] == $answerCorrect) {
                                    $selected = 'selected="selected"';
                                }
                            }
                            //$user_choice_array_position
                            if (isset($user_choice_array_position[$numAnswer]) && $val['id'] == $user_choice_array_position[$numAnswer]) {
                                $selected = 'selected="selected"';
                            }
                            $s .= '<option value="' . $val['id'] . '" ' . $selected . '>' . $val['letter'] . '</option>';
                        }
                        // end foreach()
                        $s .= '</select></div></td><td width="5%" class="separate">&nbsp;</td>';
                        $s .= '<td width="40%" valign="top" >';
                        if (isset($select_items[$lines_count])) {
                            $s .= '<div class="text-right"><p class="indent">' . $select_items[$lines_count]['letter'] . '.&nbsp; ' . $select_items[$lines_count]['answer'] . '</p></div>';
                        } else {
                            $s .= '&nbsp;';
                        }
                        $s .= '</td>';
                        $s .= '</tr>';
                        $lines_count++;
                        //if the left side of the "matching" has been completely
                        // shown but the right side still has values to show...
                        if ($lines_count - 1 == $num_suggestions) {
                            // if it remains answers to shown at the right side
                            while (isset($select_items[$lines_count])) {
                                $s .= '<tr>
                                      <td colspan="2"></td>
                                      <td valign="top">';
                                $s .= '<b>' . $select_items[$lines_count]['letter'] . '.</b> ' . $select_items[$lines_count]['answer'];
                                $s .= "</td>\n                                </tr>";
                                $lines_count++;
                            }
                            // end while()
                        }
                        // end if()
                        $matching_correct_answer++;
                    }
                } elseif ($answerType == DRAGGABLE) {
                    if ($answerCorrect != 0) {
                        $parsed_answer = $answer;
                        /*$lines_count = '';
                          $data = $objAnswerTmp->getAnswerByAutoId($numAnswer);
                          $data = $objAnswerTmp->getAnswerByAutoId($data['correct']);
                          $lines_count = $data['answer'];*/
                        $windowId = $questionId . '_' . $lines_count;
                        $s .= '<li class="touch-items" id="' . $windowId . '">';
                        $s .= Display::div($parsed_answer, ['id' => "window_{$windowId}", 'class' => "window{$questionId}_question_draggable exercise-draggable-answer-option"]);
                        $selectedValue = 0;
                        $draggableSelectOptions = [];
                        foreach ($select_items as $key => $val) {
                            if ($debug_mark_answer) {
                                if ($val['id'] == $answerCorrect) {
                                    $selectedValue = $val['id'];
                                }
                            }
                            if (isset($user_choice[$matching_correct_answer]) && $val['id'] == $user_choice[$matching_correct_answer]['answer']) {
                                $selectedValue = $val['id'];
                            }
                            $draggableSelectOptions[$val['id']] = $val['letter'];
                        }
                        $s .= Display::select("choice[{$questionId}][{$numAnswer}]", $draggableSelectOptions, $selectedValue, ['id' => "window_{$windowId}_select", 'class' => 'select_option', 'style' => 'display: none;'], false);
                        if (!empty($answerCorrect) && !empty($selectedValue)) {
                            $s .= <<<JAVASCRIPT
                                <script>
                                    \$(function() {
                                        DraggableAnswer.deleteItem(
                                            \$('#{$questionId}_{$selectedValue}'),
                                            \$('#drop_{$windowId}')
                                        );
                                    });
                                </script>
JAVASCRIPT;
                        }
                        if (isset($select_items[$lines_count])) {
                            $s .= Display::div(Display::tag('b', $select_items[$lines_count]['letter']) . $select_items[$lines_count]['answer'], ['id' => "window_{$windowId}_answer", 'style' => 'display: none;']);
                        } else {
                            $s .= '&nbsp;';
                        }
                        $lines_count++;
                        if ($lines_count - 1 == $num_suggestions) {
                            while (isset($select_items[$lines_count])) {
                                $s .= Display::tag('b', $select_items[$lines_count]['letter']);
                                $s .= $select_items[$lines_count]['answer'];
                                $lines_count++;
                            }
                        }
                        $matching_correct_answer++;
                        $s .= '</li>';
                    }
                } elseif ($answerType == MATCHING_DRAGGABLE) {
                    if ($answerId == 1) {
                        echo $objAnswerTmp->getJs();
                    }
                    if ($answerCorrect != 0) {
                        $parsed_answer = $answer;
                        $windowId = "{$questionId}_{$lines_count}";
                        $s .= <<<HTML
                            <tr>
                                <td widht="45%">
                                    <div id="window_{$windowId}" class="window window_left_question window{$questionId}_question">
                                        <strong>{$lines_count}.</strong> {$parsed_answer}
                                    </div>
                                </td>
                                <td width="10%">
HTML;
                        $selectedValue = 0;
                        $selectedPosition = 0;
                        $questionOptions = [];
                        $iTempt = 0;
                        foreach ($select_items as $key => $val) {
                            if ($debug_mark_answer) {
                                if ($val['id'] == $answerCorrect) {
                                    $selectedValue = $val['id'];
                                    $selectedPosition = $iTempt;
                                }
                            }
                            if (isset($user_choice[$matching_correct_answer]) && $val['id'] == $user_choice[$matching_correct_answer]['answer']) {
                                $selectedValue = $val['id'];
                                $selectedPosition = $iTempt;
                            }
                            $questionOptions[$val['id']] = $val['letter'];
                            $iTempt++;
                        }
                        $s .= Display::select("choice[{$questionId}][{$numAnswer}]", $questionOptions, $selectedValue, ['id' => "window_{$windowId}_select", 'class' => 'hidden'], false);
                        if (!empty($answerCorrect) && !empty($selectedValue)) {
                            // Show connect if is not freeze (question preview)
                            if (!$freeze) {
                                $s .= <<<JAVASCRIPT
                                <script>
                                    \$(document).on('ready', function () {
                                        jsPlumb.ready(function() {
                                            jsPlumb.connect({
                                                source: 'window_{$windowId}',
                                                target: 'window_{$questionId}_{$selectedPosition}_answer',
                                                endpoint: ['Blank', {radius: 15}],
                                                anchors: ['RightMiddle', 'LeftMiddle'],
                                                paintStyle: {strokeStyle: '#8A8888', lineWidth: 8},
                                                connector: [
                                                    MatchingDraggable.connectorType,
                                                    {curvines: MatchingDraggable.curviness}
                                                ]
                                            });
                                        });
                                    });
                                </script>
JAVASCRIPT;
                            }
                        }
                        $s .= <<<HTML
                            </td>
                            <td width="45%">
HTML;
                        if (isset($select_items[$lines_count])) {
                            $s .= <<<HTML
                                <div id="window_{$windowId}_answer" class="window window_right_question">
                                    <strong>{$select_items[$lines_count]['letter']}.</strong> {$select_items[$lines_count]['answer']}
                                </div>
HTML;
                        } else {
                            $s .= '&nbsp;';
                        }
                        $s .= '</td></tr>';
                        $lines_count++;
                        if ($lines_count - 1 == $num_suggestions) {
                            while (isset($select_items[$lines_count])) {
                                $s .= <<<HTML
                                    <tr>
                                        <td colspan="2"></td>
                                        <td>
                                            <strong>{$select_items[$lines_count]['letter']}</strong>
                                            {$select_items[$lines_count]['answer']}
                                        </td>
                                    </tr>
HTML;
                                $lines_count++;
                            }
                        }
                        $matching_correct_answer++;
                    }
                }
            }
            // end for()
            if ($show_comment) {
                $s .= '</table>';
            } elseif (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE, UNIQUE_ANSWER_NO_OPTION, MULTIPLE_ANSWER_TRUE_FALSE, MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE])) {
                $s .= '</table>';
            }
            if ($answerType == DRAGGABLE) {
                $s .= "</ul>";
                $s .= "</div>";
                //clearfix
                $counterAnswer = 1;
                $s .= '<div class="col-md-12"><div class="row">';
                for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
                    $answerCorrect = $objAnswerTmp->isCorrect($answerId);
                    $windowId = $questionId . '_' . $counterAnswer;
                    if ($answerCorrect) {
                        $s .= Display::div($counterAnswer, ['id' => "drop_{$windowId}", 'class' => 'droppable col-md-2']);
                        $counterAnswer++;
                    }
                }
                $s .= '</div>';
                // row
                $s .= '</div>';
                // col-md-12
                $s .= '</div>';
                // col-md-12 ui-widget ui-helper-clearfix
            }
            if (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) {
                $s .= '</div>';
                //drag_question
            }
            $s .= '</div>';
            //question_options row
            // destruction of the Answer object
            unset($objAnswerTmp);
            // destruction of the Question object
            unset($objQuestionTmp);
            if ($origin != 'export') {
                echo $s;
            } else {
                return $s;
            }
        } elseif ($answerType == HOT_SPOT || $answerType == HOT_SPOT_DELINEATION) {
            global $exerciseId, $exe_id;
            // Question is a HOT_SPOT
            //checking document/images visibility
            if (api_is_platform_admin() || api_is_course_admin()) {
                $course = api_get_course_info();
                $doc_id = DocumentManager::get_document_id($course, '/images/' . $pictureName);
                if (is_numeric($doc_id)) {
                    $images_folder_visibility = api_get_item_visibility($course, 'document', $doc_id, api_get_session_id());
                    if (!$images_folder_visibility) {
                        //This message is shown only to the course/platform admin if the image is set to visibility = false
                        Display::display_warning_message(get_lang('ChangeTheVisibilityOfTheCurrentImage'));
                    }
                }
            }
            $questionName = $objQuestionTmp->selectTitle();
            $questionDescription = $objQuestionTmp->selectDescription();
            if ($freeze) {
                echo "\n                    <script>\n                        \$(document).on('ready', function () {\n                            new " . ($answerType == HOT_SPOT ? "HotspotQuestion" : "DelineationQuestion") . "({\n                                questionId: {$questionId},\n                                exerciseId: {$exerciseId},\n                                selector: '#hotspot-preview-{$questionId}',\n                                for: 'preview'\n                            });\n                        });\n                    </script>\n                    <div id=\"hotspot-preview-{$questionId}\"></div>\n                ";
                return;
            }
            // Get the answers, make a list
            $objAnswerTmp = new Answer($questionId);
            $nbrAnswers = $objAnswerTmp->selectNbrAnswers();
            // get answers of hotpost
            $answers_hotspot = array();
            for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
                $answers = $objAnswerTmp->selectAnswerByAutoId($objAnswerTmp->selectAutoId($answerId));
                $answers_hotspot[$answers['id']] = $objAnswerTmp->selectAnswer($answerId);
            }
            $answerList = '';
            if ($answerType != HOT_SPOT_DELINEATION) {
                $answerList = '
                    <div class="well well-sm">
                        <h5 class="page-header">' . get_lang('HotspotZones') . '</h5>
                        <ol>
                ';
                if (!empty($answers_hotspot)) {
                    ksort($answers_hotspot);
                    $countAnswers = 1;
                    foreach ($answers_hotspot as $value) {
                        $answerList .= "<li><p>{$countAnswers} - {$value}</p></li>";
                        $countAnswers++;
                    }
                }
                $answerList .= '
                        </ol>
                    </div>
                ';
            }
            if (!$only_questions) {
                if ($show_title) {
                    TestCategory::displayCategoryAndTitle($objQuestionTmp->id);
                    echo '<div class="question_title">' . $current_item . '. ' . $questionName . '</div>';
                }
                //@todo I need to the get the feedback type
                echo <<<HOTSPOT
                    <input type="hidden" name="hidden_hotspot_id" value="{$questionId}" />
                    <div class="exercise_questions">
                        {$questionDescription}
                        <div class="row">
HOTSPOT;
            }
            $canClick = isset($_GET['editQuestion']) ? '0' : (isset($_GET['modifyAnswers']) ? '0' : '1');
            $s .= "\n                            <div class=\"col-sm-8 col-md-9\">\n                                <div class=\"hotspot-image\"></div>\n                                <script>\n                                    \$(document).on('ready', function () {\n                                        new " . ($answerType == HOT_SPOT_DELINEATION ? 'DelineationQuestion' : 'HotspotQuestion') . "({\n                                            questionId: {$questionId},\n                                            exerciseId: {$exe_id},\n                                            selector: '#question_div_' + {$questionId} + ' .hotspot-image',\n                                            for: 'user'\n                                        });\n                                    });\n                                </script>\n                            </div>\n                            <div class=\"col-sm-4 col-md-3\">\n                                {$answerList}\n                            </div>\n            ";
            echo <<<HOTSPOT
                            {$s}
                        </div>
                    </div>
HOTSPOT;
        }
        return $nbrAnswers;
    }
        } else {
            $html_result .= $question->question;
        }
        $html_result .= "</td>";
        $html_result .= "<td>";
        $html_result .= round($question->results, 2) . ' / ' . $question->weighting;
        $html_result .= "</td>";
        $html_result .= "<td>";
        $html_result .= $question->quantity;
        $html_result .= "</td>";
    }
    $html_result .= "</tr>";
    $html_result .= '</table>';
} else {
    if (!empty($course_code)) {
        Display::display_warning_message(get_lang('NoResults'));
    }
}
if (!$export_to_xls) {
    echo $html_result;
}
$filename = 'exam-reporting-' . date('Y-m-d-h:i:s') . '.xls';
if ($export_to_xls) {
    echo $html_result;
    export_complete_report_xls($filename, $export_array);
    exit;
}
function sort_user($a, $b)
{
    if (is_numeric($a['score']) && is_numeric($b['score'])) {
        echo $a['score'] . ' : ' . $b['score'];
Exemplo n.º 22
0
                        if ($course_subscribe_allowed) {
                            $html .= return_register_button($course, $stok, $code, $search_term);
                        }
                    }
                }
            }
            $html .= '</div>';
            $html .= '</div>';
            $html .= '</div>';
            $html .= '</div>';
            $html .= '</div>';
            echo $html;
        }
    } else {
        if (!isset($_REQUEST['subscribe_user_with_password']) && !isset($_REQUEST['subscribe_course'])) {
            Display::display_warning_message(get_lang('ThereAreNoCoursesInThisCategory'));
        }
    }
}
?>
</div>
<?php 
echo $cataloguePagination;
/**
 * Display the course catalog image of a course
 * @param $course
 * @param $icon_title
 */
function return_thumbnail($course, $icon_title)
{
    $html = '';
Exemplo n.º 23
0
            $tab_table_header[] = get_lang('Details');
        }
    }
    // display buttons to un hide hidden columns
    echo "<br/><br/><div id='unhideButtons'>";
    for ($i=0; $i < count($tab_table_header); $i++) {
        $index = $i + 1;
        echo "<span title='".get_lang('DisplayColumn')." ".$tab_table_header[$i]."' class='unhide_button hide' onclick='foldup($index)'>".Display :: return_icon('move.png', get_lang('DisplayColumn'), array('align'=>'absmiddle', 'hspace'=>'3px'), 16)." ".$tab_table_header[$i]."</span>";
    }
    echo "</div>";
    // Display the table
    echo "<div id='reporting_table'>";
    $table->display();
    echo "</div>";
} else {
    echo Display::display_warning_message(get_lang('NoUsersInCourse'));
}

// Send the csv file if asked.
if ($export_csv) {
    $csv_headers = array();

    $csv_headers[] = get_lang('OfficialCode', '');
    if ($is_western_name_order) {
        $csv_headers[] = get_lang('FirstName', '');
        $csv_headers[] = get_lang('LastName', '');
    } else {
        $csv_headers[] = get_lang('LastName', '');
        $csv_headers[] = get_lang('FirstName', '');
    }
    $csv_headers[] = get_lang('Login', ''); //
Exemplo n.º 24
0
    $id = intval($_GET['id']);
    $form = new FormValidator('usergroup', 'post', api_get_self() . '?action=' . Security::remove_XSS($_GET['action']) . '&id=' . $id);
    $defaults = $usergroup->get($id);
    $usergroup->setForm($form, 'edit', $defaults);
    // Setting the form elements
    $form->addElement('hidden', 'id', $id);
    // Setting the defaults
    $form->setDefaults($defaults);
    // The validation or display.
    if ($form->validate()) {
        $values = $form->getSubmitValues();
        $res = $usergroup->update($values);
        if ($res) {
            Display::display_confirmation_message(get_lang('Updated'));
        } else {
            Display::display_warning_message(Security::remove_XSS($values['name']) . ': ' . get_lang('AlreadyExists'));
        }
        $usergroup->display();
    } else {
        echo '<div class="actions">';
        echo '<a href="' . api_get_self() . '">' . Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM) . '</a>';
        echo '</div>';
        $form->display();
    }
} elseif (isset($_GET['action']) && $_GET['action'] == 'delete' && is_numeric($_GET['id'])) {
    $res = $usergroup->delete($_GET['id']);
    if ($res) {
        Display::display_confirmation_message(get_lang('Deleted'));
    }
    $usergroup->display();
} else {
 /**
  * This is a function to show the generated data
  * @param bool $displayWarning
  * @return array
  */
 public function get_data_to_graph2($displayWarning = true)
 {
     // do some checks on users/items counts, redefine if invalid values
     $usertable = array();
     foreach ($this->users as $user) {
         $usertable[] = $user;
     }
     // sort users array
     usort($usertable, array('FlatViewDataGenerator', 'sort_by_first_name'));
     // generate actual data array
     $scoredisplay = ScoreDisplay::instance();
     $data = array();
     $displaytype = SCORE_DIV;
     $selected_users = $usertable;
     foreach ($selected_users as $user) {
         $row = array();
         $row[] = $user[0];
         // user id
         $item_value = 0;
         $item_total = 0;
         $final_score = 0;
         $item_value_total = 0;
         $convert_using_the_global_weight = true;
         $course_code = api_get_course_id();
         $session_id = api_get_session_id();
         $allcat = $this->category->get_subcategories(null, $course_code, $session_id, 'ORDER BY id');
         if ($parent_id == 0 && !empty($allcat)) {
             foreach ($allcat as $sub_cat) {
                 $score = $sub_cat->calc_score($user[0]);
                 $real_score = $score;
                 $main_weight = $this->category->get_weight();
                 $divide = $score[1] == 0 ? 1 : $score[1];
                 $sub_cat_percentage = $sum_categories_weight_array[$sub_cat->get_id()];
                 $item_value = $score[0] / $divide * $main_weight;
                 $item_total += $sub_cat->get_weight();
                 $row[] = array($item_value, trim($scoredisplay->display_score($real_score, SCORE_CUSTOM, null, true)));
                 $item_value_total += $item_value;
                 $final_score += $score[0];
                 //$final_score = ($final_score / $item_total) * 100;
             }
             $total_score = array($final_score, $item_total);
             $row[] = array($final_score, trim($scoredisplay->display_score($total_score, SCORE_CUSTOM, null, true)));
         } else {
             for ($count = 0; $count < count($this->evals_links); $count++) {
                 $item = $this->evals_links[$count];
                 $score = $item->calc_score($user[0]);
                 $divide = $score[1] == 0 ? 1 : $score[1];
                 $item_value += $score[0] / $divide * $item->get_weight();
                 $item_total += $item->get_weight();
                 $score_denom = $score[1] == 0 ? 1 : $score[1];
                 $score_final = $score[0] / $score_denom * 100;
                 $row[] = array($score_final, trim($scoredisplay->display_score($score, SCORE_CUSTOM, null, true)));
             }
             $total_score = array($item_value, $item_total);
             $score_final = $item_value / $item_total * 100;
             if ($displayWarning) {
                 Display::display_warning_message(Display::display_warning_message($total_score[1]));
             }
             $row[] = array($score_final, trim($scoredisplay->display_score($total_score, SCORE_CUSTOM, null, true)));
         }
         $data[] = $row;
     }
     return $data;
 }
Exemplo n.º 26
0
            header('Location: session_list.php?action=show_message&message=' . urlencode(get_lang('FileImported') . ' ' . $error_message) . '&warn=' . urlencode($warn));
            exit;
        }
    } else {
        $error_message = get_lang('NoInputFile');
    }
}
// Display the header.
Display::display_header($tool_name);
if (count($inserted_in_course) > 1) {
    $msg = get_lang('SeveralCoursesSubscribedToSessionBecauseOfSameVisualCode') . ': ';
    foreach ($inserted_in_course as $code => $title) {
        $msg .= ' ' . $title . ' (' . $title . '),';
    }
    $msg = substr($msg, 0, -1);
    Display::display_warning_message($msg);
}
echo '<div class="actions">';
echo '<a href="../admin/index.php">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('PlatformAdmin'), '', ICON_SIZE_MEDIUM) . '</a>';
echo '</div>';
if (!empty($error_message)) {
    Display::display_normal_message($error_message, false);
}
$form = new FormValidator('import_sessions', 'post', api_get_self(), null, array('enctype' => 'multipart/form-data'));
$form->addElement('hidden', 'formSent', 1);
$form->addElement('file', 'import_file', get_lang('ImportFileLocation'));
$form->addElement('radio', 'file_type', array(get_lang('FileType'), '<a href="example_session.csv" target="_blank">' . get_lang('ExampleCSVFile') . '</a>'), 'CSV', 'csv');
$form->addElement('radio', 'file_type', array(null, '<a href="example_session.xml" target="_blank">' . get_lang('ExampleXMLFile') . '</a>'), 'XML', 'xml');
$form->addElement('checkbox', 'overwrite', null, get_lang('IfSessionExistsUpdate'));
$form->addElement('checkbox', 'delete_users_not_in_list', null, get_lang('DeleteUsersNotInList'));
$form->addElement('checkbox', 'update_course_coaches', null, get_lang('CleanAndUpdateCourseCoaches'));
Exemplo n.º 27
0
    <input type="hidden" name="learnpath_item_id" 		value="<?php 
    echo $learnpath_item_id;
    ?>
" />
    <input type="hidden" name="learnpath_item_view_id"  value="<?php 
    echo $learnpath_item_view_id;
    ?>
" />
<?php 
}
$i = $total_score = $max_score = 0;
//We check if the user attempts before sending to the exercise_result.php
if ($objExercise->selectAttempts() > 0) {
    $attempt_count = Event::get_attempt_count(api_get_user_id(), $objExercise->id, $learnpath_id, $learnpath_item_id, $learnpath_item_view_id);
    if ($attempt_count >= $objExercise->selectAttempts()) {
        Display::display_warning_message(sprintf(get_lang('ReachedMaxAttempts'), $objExercise->selectTitle(), $objExercise->selectAttempts()), false);
        if ($origin != 'learnpath') {
            //we are not in learnpath tool
            Display::display_footer();
        }
        exit;
    }
}
$total_score = 0;
if (!empty($exercise_stat_info)) {
    $total_score = $exercise_stat_info['exe_result'];
}
$max_score = $objExercise->get_max_score();
Display::display_normal_message(get_lang('Saved') . '<br />', false);
// Display and save questions
ExerciseLib::display_question_list_by_attempt($objExercise, $exe_id, true);
Exemplo n.º 28
0
}
Display::display_header();
if (!empty($message)) {
    if (!empty($user_to_show)) {
        $userMessage = null;
        foreach ($user_to_show as $user) {
            if (!is_array($user)) {
                $user = array($user);
            }
            $user = array_filter($user);
            $userMessage .= implode(', ', $user) . "<br />";
        }
        if ($type == 'confirmation') {
            Display::display_confirmation_message($message . ': <br />' . $userMessage, false);
        } else {
            Display::display_warning_message($message . ':  <br />' . $userMessage, false);
        }
    } else {
        $empty_line_msg = $empty_line == 0 ? get_lang('ErrorsWhenImportingFile') : get_lang('ErrorsWhenImportingFile') . ': ' . get_lang('EmptyHeaderLine');
        Display::display_error_message($empty_line_msg);
    }
}
$form->display();
echo get_lang('CSVMustLookLike');
echo '<blockquote><pre>
    username;
    jdoe;
    jmontoya;
</pre>
</blockquote>';
echo get_lang('Or');
Exemplo n.º 29
0
    Display::display_confirmation_message(get_lang('EvaluationEdited'), false);
}
if (isset($_GET['linkedited'])) {
    Display::display_confirmation_message(get_lang('LinkEdited'), false);
}
if (isset($_GET['nolinkitems'])) {
    Display::display_warning_message(get_lang('NoLinkItems'), false);
}
if (isset($_GET['addallcat'])) {
    Display::display_normal_message(get_lang('AddAllCat'), false);
}
if (isset($confirmation_message)) {
    Display::display_confirmation_message($confirmation_message, $filter_confirm_msg);
}
if (isset($warning_message)) {
    Display::display_warning_message($warning_message, $filter_warning_msg);
}
if (isset($move_form)) {
    Display::display_normal_message($move_form->toHtml(), false);
}
// LOAD DATA & DISPLAY TABLE                             -
$is_platform_admin = api_is_platform_admin();
$is_course_admin = api_is_allowed_to_edit();
//load data for category, evaluation and links
if (!isset($_GET['selectcat']) || empty($_GET['selectcat'])) {
    $category = 0;
} else {
    $category = Security::remove_XSS($_GET['selectcat']);
}
// search form
$simple_search_form = new UserForm(UserForm::TYPE_SIMPLE_SEARCH, null, 'simple_search_form', null, api_get_self() . '?selectcat=' . $selectcat);
Exemplo n.º 30
0
    echo '	</td>';
    $question_counter++;
    if ($is_survey_type_1) {
        echo '<td>' . ($row['survey_group_pri'] == 0 ? get_lang('Secondary') : get_lang('Primary')) . '</td>';
        echo '<td>' . ($row['survey_group_pri'] == 0 ? $groups[$row['survey_group_sec1']] . '-' . $groups[$row['survey_group_sec2']] : $groups[$row['survey_group_pri']]) . '</td>';
    }
    echo '</tr>';
}
echo '</table>';
if ($is_survey_type_1) {
    echo '<br /><br /><b>' . get_lang('ManageGroups') . '</b><br /><br />';
    if (in_array($_GET['sendmsg'], array('GroupUpdatedSuccessfully', 'GroupDeletedSuccessfully', 'GroupCreatedSuccessfully'))) {
        echo Display::display_confirmation_message(get_lang($_GET['sendmsg']), false);
    }
    if (in_array($_GET['sendmsg'], array('GroupNeedName'))) {
        echo Display::display_warning_message(get_lang($_GET['sendmsg']), false);
    }
    echo '<table border="0"><tr><td width="100">' . get_lang('Name') . '</td><td>' . get_lang('Description') . '</td></tr></table>';
    echo '<form action="' . api_get_path(WEB_CODE_PATH) . 'survey/survey.php?action=addgroup&survey_id=' . $survey_id . '" method="post">';
    if ($_GET['action'] == 'editgroup') {
        $sql = 'SELECT name,description FROM ' . $table_survey_question_group . ' WHERE id = ' . Database::escape_string($_GET['gid']) . ' AND survey_id = ' . Database::escape_string($survey_id) . ' limit 1';
        $rs = Database::query($sql);
        $editedrow = Database::fetch_array($rs, 'ASSOC');
        echo '<input type="text" maxlength="20" name="name" value="' . $editedrow['name'] . '" size="10" disabled>';
        echo '<input type="text" maxlength="150" name="description" value="' . $editedrow['description'] . '" size="40">';
        echo '<input type="hidden" name="group_id" value="' . Security::remove_XSS($_GET['gid']) . '">';
        echo '<input type="submit" value="' . get_lang('Save') . '"' . '<input type="button" value="' . get_lang('Cancel') . '" onclick="window.location.href = \'survey.php?survey_id=' . Security::remove_XSS($survey_id) . '\';" />';
    } else {
        echo '<input type="text" maxlength="20" name="name" value="" size="10">';
        echo '<input type="text" maxlength="250" name="description" value="" size="80">';
        echo '<input type="submit" value="' . get_lang('Create') . '"';