From 13a5fbc5b7fc3656eabcd08cd413e8806bbd7fdb Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Fri, 25 Jul 2014 22:28:48 -0500 Subject: [PATCH] Improve data shown in new course progress section on course homepage - refs #7218 --- main/inc/introductionSection.inc.php | 29 +++++++++++++++++----------- main/inc/lib/thematic.lib.php | 8 +++++--- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/main/inc/introductionSection.inc.php b/main/inc/introductionSection.inc.php index a8beda0651..43e891532e 100755 --- a/main/inc/introductionSection.inc.php +++ b/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.='
'; $thematic_description_html.='
-
'.get_lang('NextTopics').'
+
'.$subTitle1.'

'.$thematic_info['title'].'

'.$thematic_advance_info['start_date'].'

'.$thematic_advance_info['content'].'

@@ -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.='
-
'.get_lang('NextTopics').'
+
'.$subTitle2.'

'.$thematic_info['title'].'

'.$thematic_advance_info2['start_date'].'

'.$thematic_advance_info2['content'].'

diff --git a/main/inc/lib/thematic.lib.php b/main/inc/lib/thematic.lib.php index 6b8baedebc..d7519049d6 100755 --- a/main/inc/lib/thematic.lib.php +++ b/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); }