Ejemplo n.º 1
0
 /**
  * Uses the table generated by get_toc() and returns an HTML-formatted string ready to display
  * @return	string	HTML TOC ready to display
  */
 public function get_html_toc($toc_list = null)
 {
     $is_allowed_to_edit = api_is_allowed_to_edit(null, true, false, false);
     if ($this->debug > 0) {
         error_log('In learnpath::get_html_toc()', 0);
     }
     if (empty($toc_list)) {
         $toc_list = $this->get_toc();
     }
     //$html = '<div id="scorm_title" class="scorm-heading">'.Security::remove_XSS($this->get_name()) . '</div>';
     $html = '<div class="scorm-body">';
     $html .= '<div id="inner_lp_toc" class="inner_lp_toc scrollbar-light">';
     require_once 'resourcelinker.inc.php';
     // Temporary variables.
     $mycurrentitemid = $this->get_current_item_id();
     $color_counter = 0;
     $i = 0;
     foreach ($toc_list as $item) {
         // TODO: Complete this
         $icon_name = array('not attempted' => '../img/notattempted.gif', 'incomplete' => '../img/incomplete.png', 'failed' => '../img/delete.png', 'completed' => '../img/completed.png', 'passed' => '../img/passed.png', 'succeeded' => '../img/succeeded.png', 'browsed' => '../img/completed.png');
         // Style Status
         $class_name = array('not attempted' => 'scorm_not_attempted', 'incomplete' => 'scorm_not_attempted', 'failed' => 'scorm_failed', 'completed' => 'scorm_completed', 'passed' => 'scorm_completed', 'succeeded' => 'scorm_completed', 'browsed' => 'scorm_completed');
         $scorm_color_background = 'row_odd';
         $style_item = '';
         if ($color_counter % 2 == 0) {
             $scorm_color_background = 'row_even';
         }
         $dirTypes = self::getChapterTypes();
         if (in_array($item['type'], $dirTypes)) {
             $scorm_color_background = 'scorm_item_section ';
             $style_item = '';
         }
         if ($item['id'] == $this->current) {
             $scorm_color_background = 'scorm_item_normal ' . $scorm_color_background . ' scorm_highlight';
         } elseif (!in_array($item['type'], $dirTypes)) {
             $scorm_color_background = 'scorm_item_normal ' . $scorm_color_background . ' ';
         }
         $html .= '<div id="toc_' . $item['id'] . '" class="' . $scorm_color_background . ' ' . $class_name[$item['status']] . ' ">';
         // Learning path title
         $title = $item['title'];
         if (empty($title)) {
             $title = rl_get_resource_name(api_get_course_id(), $this->get_id(), $item['id']);
         }
         $title = Security::remove_XSS($title);
         // Learning path personalization
         // build the LP tree
         // The anchor atoc_ will let us center the TOC on the currently viewed item &^D
         $description = $item['description'];
         if (empty($description)) {
             $description = $title;
         }
         if (in_array($item['type'], $dirTypes)) {
             // Chapters
             $html .= '<div class="' . $style_item . ' scorm_section_level_' . $item['level'] . '" title="' . $description . '" >';
         } else {
             $html .= '<div class="' . $style_item . ' scorm_item_level_' . $item['level'] . ' scorm_type_' . learnpath::format_scorm_type_item($item['type']) . '" title="' . $description . '" >';
             $html .= '<a name="atoc_' . $item['id'] . '" />';
         }
         if (in_array($item['type'], $dirTypes)) {
             // Chapter
             // if you want to put an image before, you should use css
             $html .= stripslashes($title);
         } else {
             $this->get_link('http', $item['id'], $toc_list);
             $html .= '<a class="items-list" href="" onClick="switch_item(' . $mycurrentitemid . ',' . $item['id'] . ');' . 'return false;" >' . stripslashes($title) . '</a>';
         }
         $html .= "</div>";
         if ($scorm_color_background != '') {
             $html .= '</div>';
         }
         $color_counter++;
     }
     $html .= "</div>";
     $html .= "</div>";
     return $html;
 }
Ejemplo n.º 2
0
    /**
     * Uses the table generated by get_toc() and returns an HTML-formatted string ready to display
     * @return	string	HTML TOC ready to display
     */
    public function get_html_toc($toc_list = null)
    {
        global $_configuration;
        $is_allowed_to_edit = api_is_allowed_to_edit(null, true, false, false);

        if ($this->debug > 0) {
            error_log('In learnpath::get_html_toc()', 0);
        }
        if (empty($toc_list)) {
            $toc_list = $this->get_toc();
        }
        $html = '<div id="scorm_title" class="scorm_title">'.Security::remove_XSS($this->get_name()) . '</div>';

        $hide_teacher_icons_lp = isset($_configuration['hide_teacher_icons_lp']) ? $_configuration['hide_teacher_icons_lp'] : true;

        if ($is_allowed_to_edit && $hide_teacher_icons_lp == false) {
            $gradebook = Security :: remove_XSS($_GET['gradebook']);
            if ($this->get_lp_session_id() == api_get_session_id()) {
                $html .= '<div id="actions_lp" class="actions_lp">';
                $html .= '<div class="btn-group">';
                $html .= "<a class='btn' href='lp_controller.php?" . api_get_cidreq()."&amp;gradebook=$gradebook&amp;action=build&amp;lp_id=" . $this->lp_id . "' target='_parent'>" . get_lang('Overview') . "</a>";
                $html .= "<a class='btn' href='lp_controller.php?" . api_get_cidreq()."&amp;action=add_item&amp;type=step&amp;lp_id=" . $this->lp_id . "' target='_parent'>" . get_lang('Edit') . "</a>";
                $html .= '<a class="btn" href="lp_controller.php?'.api_get_cidreq()."&amp;gradebook=$gradebook&amp;action=edit&amp;lp_id=" . $this->lp_id.'">'.get_lang('Settings').'</a>';
                $html .= '</div>';
                $html .= '</div>';
            }
        }
        $html .= '<div id="inner_lp_toc" class="inner_lp_toc">';
        require_once 'resourcelinker.inc.php';

        // Temporary variables.
        $mycurrentitemid = $this->get_current_item_id();
        $color_counter = 0;
        $i = 0;

        foreach ($toc_list as $item) {
            // TODO: Complete this
            $icon_name = array (
                'not attempted' => '../img/notattempted.gif',
                'incomplete'    => '../img/incomplete.png',
                'failed'        => '../img/delete.png',
                'completed'     => '../img/completed.png',
                'passed'        => '../img/passed.png',
                'succeeded'     => '../img/succeeded.png',
                'browsed'       => '../img/completed.png',
            );

            // Style Status

            $class_name = array (
                'not attempted' => 'scorm_not_attempted',
                'incomplete'    => 'scorm_not_attempted',
                'failed'        => 'scorm_failed',
                'completed'     => 'scorm_completed',
                'passed'        => 'scorm_completed',
                'succeeded'     => 'scorm_completed',
                'browsed'       => 'scorm_completed',
            );

            $scorm_color_background = 'scorm_item_2';
            $style_item = '';

            if ($color_counter % 2 == 0) {
                $scorm_color_background = 'scorm_item_1';
            }

            $dirTypes = self::getChapterTypes();

            if (in_array($item['type'], $dirTypes)) {
                $scorm_color_background =' scorm_item_section ';
                $style_item = '';
            }
            if ($item['id'] == $this->current) {
                $scorm_color_background = 'scorm_item_normal scorm_highlight '.$scorm_color_background.' ';
            } elseif (!in_array($item['type'], $dirTypes)) {
                $scorm_color_background = 'scorm_item_normal '.$scorm_color_background.' ';
            }

            $html .= '<div id="toc_' . $item['id'] . '" class="' . $scorm_color_background . ' '.$class_name[$item['status']].' ">';

            // Learning path title
            $title = $item['title'];
            if (empty ($title)) {
                $title = rl_get_resource_name(api_get_course_id(), $this->get_id(), $item['id']);
            }
            $title = Security::remove_XSS($title);

            // Learning path personalization
            // build the LP tree
            // The anchor atoc_ will let us center the TOC on the currently viewed item &^D
            $description = $item['description'];
            if (empty($description)) {
                $description = $title;
            }
            if (in_array($item['type'], $dirTypes)) {
                // Chapters
                $html .= '<div class="'.$style_item.' scorm_section_level_'.$item['level'].'" title="'.$description.'" >';
            } else {
                $html .= '<div class="'.$style_item.' scorm_item_level_'.$item['level'].' scorm_type_'.learnpath::format_scorm_type_item($item['type']).'" title="'.$description.'" >';
                $html .= '<a name="atoc_'.$item['id'].'" />';
            }

            if (in_array($item['type'], $dirTypes)) {
                // Chapter
                // if you want to put an image before, you should use css
                $html .= stripslashes($title);
            } else {
                $this->get_link('http', $item['id'], $toc_list);
                $html .= '<a href="" onClick="switch_item(' .$mycurrentitemid . ',' .$item['id'] . ');' .'return false;" >' . stripslashes($title) . '</a>';
            }
            $html .= "</div>";

            if ($scorm_color_background != '') {
                $html .= '</div>';
            }

            $color_counter++;
        }
        $html .= "</div>";
        return $html;
    }