Browse Source

add tpl courses_progress, fix thematic controller

Alex Aragon 8 years ago
parent
commit
e6281cde91

+ 26 - 15
main/course_progress/thematic.php

@@ -16,34 +16,37 @@ $url_token = "&sec_token=".$token;
 $user_info = api_get_user_info();
 $params = '&'.api_get_cidreq();
 
-if (api_is_allowed_to_edit(null, true)) {
-    echo '<div class="actions">';
+$tpl = new Template(get_lang('ThematicControl'));
 
+$toolbar = null;
+if (api_is_allowed_to_edit(null, true)) {
+    
     switch ($action) {
         case 'thematic_add':
         case 'thematic_import_select':
-            echo '<a href="index.php?'.api_get_cidreq().'">'.
+            $actionLeft = '<a href="index.php?'.api_get_cidreq().'">'.
                 Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('ThematicDetails'), '', ICON_SIZE_MEDIUM).'</a>';
             break;
         case 'thematic_list':
-            echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_add'.$url_token.'">'.
+            $actionLeft = '<a href="index.php?'.api_get_cidreq().'&action=thematic_add'.$url_token.'">'.
                 Display::return_icon('new_course_progress.png', get_lang('NewThematicSection'), '', ICON_SIZE_MEDIUM).'</a>';
             break;
         case 'thematic_details':
-            echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_add'.$url_token.'">'.
+            $actionLeft = '<a href="index.php?'.api_get_cidreq().'&action=thematic_add'.$url_token.'">'.
                 Display::return_icon('new_course_progress.png', get_lang('NewThematicSection'), '', ICON_SIZE_MEDIUM).'</a>';
-            echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_import_select'.$url_token.'">'.
+            $actionLeft .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_import_select'.$url_token.'">'.
                 Display::return_icon('import_csv.png', get_lang('ImportThematic'), '', ICON_SIZE_MEDIUM).'</a>';
-            echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_export'.$url_token.'">'.
+            $actionLeft .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_export'.$url_token.'">'.
                 Display::return_icon('export_csv.png', get_lang('ExportThematic'), '', ICON_SIZE_MEDIUM).'</a>';
-            echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_export_pdf'.$url_token.'">'.
+            $actionLeft .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_export_pdf'.$url_token.'">'.
                 Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a>';
             break;
         default:
-            echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_add'.$url_token.'">'.
+            $actionLeft = '<a href="index.php?'.api_get_cidreq().'&action=thematic_add'.$url_token.'">'.
                 Display::return_icon('new_course_progress.png', get_lang('NewThematicSection'), '', ICON_SIZE_MEDIUM).'</a>';
     }
-    echo '</div>';
+    
+    $toolbar= Display::toolbarAction('thematic-bar', array(0 => $actionLeft));
 }
 
 if ($action == 'thematic_list') {
@@ -70,7 +73,7 @@ if ($action == 'thematic_list') {
 
 } elseif ($action == 'thematic_details') {
     if (isset($_GET['thematic_plan_save_message']) && $_GET['thematic_plan_save_message'] == 'ok') {
-        Display::display_confirmation_message(get_lang('ThematicSectionHasBeenCreatedSuccessfull'));
+        $message = Display::display_confirmation_message(get_lang('ThematicSectionHasBeenCreatedSuccessfull'), false, true);
     }
 
     if (isset($last_id) && $last_id) {
@@ -88,10 +91,10 @@ if ($action == 'thematic_list') {
     if (!empty($thematic_id)) {
     } else {
         // display information
-        $message = '<strong>'.get_lang('Information').'</strong><br />';
-        $message .= get_lang('ThematicDetailsDescription');
-        Display::display_normal_message($message, false);
-        echo '<br />';
+        $text = '<h4>'.get_lang('Information').'</h4>';
+        $text .= get_lang('ThematicDetailsDescription');
+        $message = Display::return_message($text,'info', false);
+        
     }
 
     // Display thematic data
@@ -304,3 +307,11 @@ if ($action == 'thematic_list') {
     $form->addButtonImport(get_lang('Import'), 'SubmitImport');
     $form->display();
 }
+
+$tpl->assign('actions', $toolbar);
+$tpl->assign('message', $message);
+$tpl->assign('data',$data);
+$tpl->assign('score_progress', $score);
+$tpl->assign('thamatic', $thematic);
+$thematicLayout = $tpl->get_template('course_progress/progress.tpl');
+$tpl->display($thematicLayout);

+ 4 - 0
main/course_progress/thematic_controller.php

@@ -328,6 +328,7 @@ class ThematicController
         $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');
@@ -403,6 +404,7 @@ class ThematicController
                     $data['next_description_type'] = $thematic->get_next_description_type($_POST['thematic_id']);
 
                     // render to the view
+                    
                     $this->view->set_data($data);
                     $this->view->set_layout('layout');
                     $this->view->set_template('thematic_plan');
@@ -445,6 +447,7 @@ class ThematicController
         $data['thematic_data'] = $thematic->get_thematic_list($thematic_id);
 
         //render to the view
+        
         $this->view->set_data($data);
         $this->view->set_layout('layout');
         $this->view->set_template('thematic_plan');
@@ -530,6 +533,7 @@ class ThematicController
         $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');

+ 14 - 0
main/template/default/course_progress/progress.tpl

@@ -0,0 +1,14 @@
+{% extends template ~ "/layout/layout_1_col.tpl" %}
+
+{% block content %}
+{{ data | var_dump }}
+<div id="course-progress" class="thematic">
+    <div class="row">
+        <div class="col-md-12">
+            <div class="score-progress">
+                <h2>{{ 'Progress' | get_lang }}: <span id="div_result">{{ score_progress }}</span> %</h2>
+            </div>
+        </div>
+    </div>
+</div>
+{% endblock %}

+ 1 - 3
main/template/default/layout/page_body.tpl

@@ -1,7 +1,5 @@
 {% if actions != '' %}
-    <div class="actions">
-        {{ actions }}
-    </div>
+    {{ actions }}
 {% endif %}
 {{ flash_messages }}
 <span id="js_alerts"></span>