Esempio n. 1
0
 /**
  * This method is used for thematic advance control (update, insert or listing)
  * render to thematic_advance.php
  * @param 	string	$action
  *
  */
 public function thematic_advance($action)
 {
     $thematic = new Thematic();
     $attendance = new Attendance();
     $data = array();
     $displayHeader = !empty($_REQUEST['display']) && $_REQUEST['display'] === 'no_header' ? false : true;
     // get data for attendance input select
     $attendance_list = $attendance->get_attendances_list();
     $attendance_select = array();
     $attendance_select[0] = get_lang('SelectAnAttendance');
     foreach ($attendance_list as $attendance_id => $attendance_data) {
         $attendance_select[$attendance_id] = $attendance_data['name'];
     }
     $thematic_id = intval($_REQUEST['thematic_id']);
     $thematic_advance_id = isset($_REQUEST['thematic_advance_id']) ? intval($_REQUEST['thematic_advance_id']) : null;
     $thematic_advance_data = array();
     switch ($action) {
         case 'thematic_advance_delete':
             if (!empty($thematic_advance_id)) {
                 if (api_is_allowed_to_edit(null, true)) {
                     $thematic->thematic_advance_destroy($thematic_advance_id);
                 }
                 header('Location: index.php');
                 exit;
             }
             break;
         case 'thematic_advance_list':
             if (!api_is_allowed_to_edit(null, true)) {
                 echo '';
                 exit;
             }
             if (isset($_REQUEST['start_date_type']) && $_REQUEST['start_date_type'] == 1 && empty($_REQUEST['start_date_by_attendance']) || !empty($_REQUEST['duration_in_hours']) && !is_numeric($_REQUEST['duration_in_hours'])) {
                 if ($_REQUEST['start_date_type'] == 1 && empty($_REQUEST['start_date_by_attendance'])) {
                     $start_date_error = true;
                     $data['start_date_error'] = $start_date_error;
                 }
                 if (!empty($_REQUEST['duration_in_hours']) && !is_numeric($_REQUEST['duration_in_hours'])) {
                     $duration_error = true;
                     $data['duration_error'] = $duration_error;
                 }
                 $data['action'] = $_REQUEST['action'];
                 $data['thematic_id'] = $_REQUEST['thematic_id'];
                 $data['attendance_select'] = $attendance_select;
                 if (isset($_REQUEST['thematic_advance_id'])) {
                     $data['thematic_advance_id'] = $_REQUEST['thematic_advance_id'];
                     $thematic_advance_data = $thematic->get_thematic_advance_list($_REQUEST['thematic_advance_id']);
                     $data['thematic_advance_data'] = $thematic_advance_data;
                 }
             } else {
                 if (api_is_allowed_to_edit(null, true)) {
                     $thematic_advance_id = isset($_REQUEST['thematic_advance_id']) ? $_REQUEST['thematic_advance_id'] : null;
                     $thematic_id = $_REQUEST['thematic_id'];
                     $content = isset($_REQUEST['content']) ? $_REQUEST['content'] : null;
                     $duration = isset($_REQUEST['duration_in_hours']) ? $_REQUEST['duration_in_hours'] : null;
                     if (isset($_REQUEST['start_date_type']) && $_REQUEST['start_date_type'] == 2) {
                         $start_date = $_REQUEST['custom_start_date'];
                         $attendance_id = 0;
                     } else {
                         $start_date = isset($_REQUEST['start_date_by_attendance']) ? $_REQUEST['start_date_by_attendance'] : null;
                         $attendance_id = isset($_REQUEST['attendance_select']) ? $_REQUEST['attendance_select'] : null;
                     }
                     $thematic->set_thematic_advance_attributes($thematic_advance_id, $thematic_id, $attendance_id, $content, $start_date, $duration);
                     $affected_rows = $thematic->thematic_advance_save();
                     if ($affected_rows) {
                         // get last done thematic advance before move thematic list
                         $last_done_thematic_advance = $thematic->get_last_done_thematic_advance();
                         // update done advances with de current thematic list
                         if (!empty($last_done_thematic_advance)) {
                             $thematic->update_done_thematic_advances($last_done_thematic_advance);
                         }
                     }
                 }
             }
             break;
         default:
             $thematic_advance_data = $thematic->get_thematic_advance_list($thematic_advance_id);
             break;
     }
     // get calendar select by attendance id
     $calendar_select = array();
     if (!empty($thematic_advance_data)) {
         if (!empty($thematic_advance_data['attendance_id'])) {
             $attendance_calendar = $attendance->get_attendance_calendar($thematic_advance_data['attendance_id']);
             if (!empty($attendance_calendar)) {
                 foreach ($attendance_calendar as $calendar) {
                     $calendar_select[$calendar['date_time']] = $calendar['date_time'];
                 }
             }
         }
     }
     $data['action'] = $action;
     $data['thematic_id'] = $thematic_id;
     $data['thematic_advance_id'] = $thematic_advance_id;
     $data['attendance_select'] = $attendance_select;
     $data['thematic_advance_data'] = $thematic_advance_data;
     $data['calendar_select'] = $calendar_select;
     $layoutName = $displayHeader ? 'layout' : 'layout_no_header';
     // render to the view
     $this->view->set_data($data);
     $this->view->set_layout($layoutName);
     $this->view->set_template('thematic_advance');
     $this->view->render();
 }
    $default['intro_content'] = $intro_content;
    $form->setDefaults($default);
    $introduction_section .= '<div id="courseintro" style="width: 98%">';
    $introduction_section .= $form->return_form();
    $introduction_section .= '</div>';
}
$thematic_description_html = '';
if ($tool == TOOL_COURSE_HOMEPAGE && !isset($_GET['intro_cmdEdit'])) {
    // Only show this if we're on the course homepage and we're not currently editing
    $thematic = new Thematic();
    $displayMode = api_get_course_setting('display_info_advance_inside_homecourse');
    $class1 = '';
    if ($displayMode == '1') {
        // Show only the current course progress step
        // $information_title = get_lang('InfoAboutLastDoneAdvance');
        $last_done_advance = $thematic->get_last_done_thematic_advance();
        $thematic_advance_info = $thematic->get_thematic_advance_list($last_done_advance);
        $subTitle1 = get_lang('CurrentTopic');
        $class1 = ' current';
    } else {
        if ($displayMode == '2') {
            // Show only the two next course progress steps
            // $information_title = get_lang('InfoAboutNextAdvanceNotDone');
            $last_done_advance = $thematic->get_next_thematic_advance_not_done();
            $next_advance_not_done = $thematic->get_next_thematic_advance_not_done(2);
            $thematic_advance_info = $thematic->get_thematic_advance_list($last_done_advance);
            $thematic_advance_info2 = $thematic->get_thematic_advance_list($next_advance_not_done);
            $subTitle1 = $subTitle2 = get_lang('NextTopic');
        } else {
            if ($displayMode == '3') {
                // Show the current and next course progress steps
Esempio n. 3
0
 /**
  * @param string $tool
  * @param array $toolList
  *
  * @return null
  */
 public static function return_introduction_section($tool, $toolList = array())
 {
     $urlGenerator = Container::getRouter();
     $is_allowed_to_edit = api_is_allowed_to_edit();
     $courseInfo = api_get_course_info();
     $introduction_section = null;
     if (api_get_setting('course.enable_tool_introduction') == 'true' || $tool == TOOL_COURSE_HOMEPAGE) {
         $introduction_section = null;
         $TBL_INTRODUCTION = Database::get_course_table(TABLE_TOOL_INTRO);
         $session_id = api_get_session_id();
         $course_id = api_get_course_int_id();
         /* Retrieves the module introduction text, if exist */
         $sql = "SELECT iid, intro_text FROM {$TBL_INTRODUCTION}\n                    WHERE\n                        c_id = {$course_id} AND\n                        tool ='" . Database::escape_string($tool) . "' AND\n                        session_id = '" . intval($session_id) . "'";
         $intro_dbQuery = Database::query($sql);
         $introContent = null;
         $toolId = null;
         if (Database::num_rows($intro_dbQuery) > 0) {
             $row = Database::fetch_array($intro_dbQuery);
             $introContent = $row['intro_text'];
             $toolId = $row['iid'];
         }
         $introContent = CourseHome::replaceTextWithToolUrls($introContent, $toolList);
         /* Determines the correct display */
         $displayIntro = false;
         if ($is_allowed_to_edit) {
             $displayIntro = true;
         }
         $thematicDescription = '';
         if ($tool == TOOL_COURSE_HOMEPAGE) {
             $thematic = new Thematic($courseInfo);
             $thematic->set_course_int_id(api_get_course_int_id());
             if (api_get_course_setting('display_info_advance_inside_homecourse') == '1') {
                 $information_title = get_lang('InfoAboutLastDoneAdvance');
                 $last_done_advance = $thematic->get_last_done_thematic_advance();
                 $thematic_advance_info = $thematic->get_thematic_advance_list($last_done_advance);
             } else {
                 if (api_get_course_setting('display_info_advance_inside_homecourse') == '2') {
                     $information_title = get_lang('InfoAboutNextAdvanceNotDone');
                     $next_advance_not_done = $thematic->get_next_thematic_advance_not_done();
                     $thematic_advance_info = $thematic->get_thematic_advance_list($next_advance_not_done);
                 } else {
                     if (api_get_course_setting('display_info_advance_inside_homecourse') == '3') {
                         $information_title = get_lang('InfoAboutLastDoneAdvanceAndNextAdvanceNotDone');
                         $last_done_advance = $thematic->get_last_done_thematic_advance();
                         $next_advance_not_done = $thematic->get_next_thematic_advance_not_done();
                         $thematic_advance_info = $thematic->get_thematic_advance_list($last_done_advance);
                         $thematic_advance_info2 = $thematic->get_thematic_advance_list($next_advance_not_done);
                     }
                 }
             }
             if (!empty($thematic_advance_info)) {
                 $thematic_advance = get_lang('CourseThematicAdvance') . '&nbsp;' . $thematic->get_total_average_of_thematic_advances() . '%';
                 $thematic_info = $thematic->get_thematic_list($thematic_advance_info['thematic_id']);
                 $thematic_advance_info['start_date'] = api_get_local_time($thematic_advance_info['start_date']);
                 $thematic_advance_info['start_date'] = api_format_date($thematic_advance_info['start_date'], DATE_TIME_FORMAT_LONG);
                 $thematicDescription = '<div class="thematic-postit">
                                               <div class="thematic-postit-top"><h3><a class="thematic-postit-head" style="" href="#"> ' . $thematic_advance . '</h3></a></div>
                                               <div class="thematic-postit-center" style="display:none">';
                 $thematicDescription .= '<div><strong>' . $thematic_info['title'] . '</strong></div>';
                 $thematicDescription .= '<div style="font-size:8pt;"><strong>' . $thematic_advance_info['start_date'] . '</strong></div>';
                 $thematicDescription .= '<div>' . $thematic_advance_info['content'] . '</div>';
                 $thematicDescription .= '<div>' . get_lang('DurationInHours') . ' : ' . $thematic_advance_info['duration'] . '</div>';
                 if (!empty($thematic_advance_info2)) {
                     $thematic_info2 = $thematic->get_thematic_list($thematic_advance_info2['thematic_id']);
                     $thematic_advance_info2['start_date'] = api_get_local_time($thematic_advance_info2['start_date']);
                     $thematic_advance_info2['start_date'] = api_format_date($thematic_advance_info2['start_date'], DATE_TIME_FORMAT_LONG);
                     $thematicDescription .= '<div><strong>' . $thematic_info2['title'] . '</strong></div>';
                     $thematicDescription .= '<div style="font-size:8pt;"><strong>' . $thematic_advance_info2['start_date'] . '</strong></div>';
                     $thematicDescription .= '<div>' . $thematic_advance_info2['content'] . '</div>';
                     $thematicDescription .= '<div>' . get_lang('DurationInHours') . ' : ' . $thematic_advance_info2['duration'] . '</div>';
                     $thematicDescription .= '<br />';
                 }
                 $thematicDescription .= '</div>
                                           <div class="thematic-postit-bottom"></div>
                                           </div>';
             }
         }
         $introduction_section .= '<div id="introduction_block" class="row"><div class="col-md-12">';
         $introduction_section .= $thematicDescription;
         if (!empty($introContent)) {
             $introduction_section .= $introContent;
         }
         $introduction_section .= '</div>';
         if ($displayIntro) {
             if (empty($introContent)) {
                 // Displays "Add intro" commands
                 $introduction_section .= '<div id="introduction_block_action" class="col-md-2 col-md-offset-10">';
                 $em = Database::getManager();
                 $criteria = ['tool' => $tool, 'cId' => api_get_course_int_id()];
                 $toolIntro = $em->getRepository('ChamiloCourseBundle:CToolIntro')->findOneBy($criteria);
                 if ($toolIntro) {
                     $url = $urlGenerator->generate('chamilo_course_ctoolintro_update', array('tool' => $toolIntro->getTool(), 'course' => api_get_course_id(), 'iid' => $toolIntro->getId()));
                 } else {
                     $url = $urlGenerator->generate('chamilo_course_ctoolintro_create', array('tool' => $tool, 'course' => api_get_course_id()));
                 }
                 $introduction_section .= "<a href=\"" . $url . "?" . api_get_cidreq() . "\">";
                 $introduction_section .= Display::return_icon('introduction_add.gif', get_lang('AddIntro')) . ' ';
                 $introduction_section .= "</a>";
                 $introduction_section .= "</div>";
             } else {
                 // Displays "edit intro && delete intro" commands
                 $introduction_section .= '<div id="introduction_block_action" class="col-md-2 col-md-offset-10">';
                 $url = $urlGenerator->generate('chamilo_course_ctoolintro_update', array('tool' => $tool, 'iid' => $toolId, 'course' => api_get_course_id()));
                 $introduction_section .= "<a href=\"" . $url . "?" . api_get_cidreq() . "\">";
                 $introduction_section .= Display::return_icon('edit.png', get_lang('Modify')) . ' ';
                 $introduction_section .= "</a>";
                 $url = $urlGenerator->generate('chamilo_course_ctoolintro_delete', array('iid' => $toolId, 'course' => api_get_course_id()));
                 $introduction_section .= "<a onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'))) . "')) return false;\" href=\"" . $url . "?" . api_get_cidreq() . "\">";
                 $introduction_section .= Display::return_icon('delete.png', get_lang('AddIntro')) . ' ';
                 $introduction_section .= "</a>";
                 $introduction_section .= "</div>";
             }
         }
         $introduction_section .= '</div>';
     }
     return $introduction_section;
     /*$moduleId = $tool;
       if (api_get_setting('course.enable_tool_introduction') == 'true' ||
           $tool == TOOL_COURSE_HOMEPAGE
       ) {
           $introduction_section = null;
           require api_get_path(INCLUDE_PATH).'introductionSection.inc.php';
           return $introduction_section;
       }*/
 }