Browse Source

Improve data shown in new course progress section on course homepage - refs #7218

Yannick Warnier 10 years ago
parent
commit
13a5fbc5b7
2 changed files with 23 additions and 14 deletions
  1. 18 11
      main/inc/introductionSection.inc.php
  2. 5 3
      main/inc/lib/thematic.lib.php

+ 18 - 11
main/inc/introductionSection.inc.php

@@ -175,21 +175,28 @@ $thematic_description_html = '';
 if ($tool == TOOL_COURSE_HOMEPAGE && !isset($_GET['intro_cmdEdit'])) {
 
 	$thematic = new Thematic();
-	if (api_get_course_setting('display_info_advance_inside_homecourse') == '1') {
-		$information_title = get_lang('InfoAboutLastDoneAdvance');
+    $displayMode = api_get_course_setting('display_info_advance_inside_homecourse');
+	if ($displayMode == '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');
+        $subTitle1 = get_lang('CurrentTopic');
+	} else if($displayMode == '2') {
+        //$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') {
+		//$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);
-	}
+        $subTitle1 = get_lang('CurrentTopic');
+        $subTitle2 = get_lang('NextTopic');
+    }
 
 	if (!empty($thematic_advance_info)) {
 
@@ -254,7 +261,7 @@ if ($tool == TOOL_COURSE_HOMEPAGE && !isset($_GET['intro_cmdEdit'])) {
 		$thematic_description_html.='<div class="span8">
 										<div class="row-fluid">';
 		$thematic_description_html.='<div class="span6 items-progress">
-										<div class="topics">'.get_lang('NextTopics').'</div>
+										<div class="topics">'.$subTitle1.'</div>
 										<p class="title_topics">'.$thematic_info['title'].'</p>
 										<p class="date">'.$thematic_advance_info['start_date'].'</p>
 										<h3 class="title">'.$thematic_advance_info['content'].'</h3>
@@ -280,7 +287,7 @@ if ($tool == TOOL_COURSE_HOMEPAGE && !isset($_GET['intro_cmdEdit'])) {
 			$thematic_advance_info2['start_date'] = api_format_date($thematic_advance_info2['start_date'], DATE_TIME_FORMAT_LONG);
 
 			$thematic_description_html.='<div class="span6 items-progress">
-										<div class="topics">'.get_lang('NextTopics').'</div>
+										<div class="topics">'.$subTitle2.'</div>
 										<p class="title_topics">'.$thematic_info['title'].'</p>
 										<p class="date">'.$thematic_advance_info2['start_date'].'</p>
 										<h3 class="title">'.$thematic_advance_info2['content'].'</h3>

+ 5 - 3
main/inc/lib/thematic.lib.php

@@ -1002,9 +1002,10 @@ class Thematic
 
 	/**
 	 * Get next thematic advance not done from thematic details interface
+     * @param   int Offset (if you want to get an item that is not directly the next)
 	 * @return	int		next thematic advance not done
 	 */
-	public function get_next_thematic_advance_not_done() {
+	public function get_next_thematic_advance_not_done($offset = 1) {
 
 		$thematic_data = $this->get_thematic_list();
 		$thematic_advance_data = $this->get_thematic_advance_list();
@@ -1012,7 +1013,6 @@ class Thematic
 		$next_advance_not_done = 0;
 		if (!empty($thematic_data)) {
 			foreach ($thematic_data as $thematic) {
-				$thematic_id = $thematic['id'];
 				if (!empty($thematic_advance_data[$thematic['id']])) {
 					foreach ($thematic_advance_data[$thematic['id']] as $thematic_advance) {
 						if ($thematic_advance['done_advance'] == 0) {
@@ -1024,7 +1024,9 @@ class Thematic
 		}
 
 		if (!empty($a_thematic_advance_ids)) {
-			$next_advance_not_done = array_shift($a_thematic_advance_ids);
+            for ($i = 0; $i < $offset; $i++) {
+                $next_advance_not_done = array_shift($a_thematic_advance_ids);
+            }
 			$next_advance_not_done = intval($next_advance_not_done);
 		}