Browse Source

added post-it inside introduction section about a course, and show progress icon into courses list for a user - partial CT#578

Cristian Fasanando 15 years ago
parent
commit
a249616238
2 changed files with 57 additions and 10 deletions
  1. 22 4
      main/inc/introductionSection.inc.php
  2. 35 6
      user_portal.php

+ 22 - 4
main/inc/introductionSection.inc.php

@@ -24,7 +24,8 @@
 ==============================================================================
 */
 
-include_once(api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
+require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
+require_once api_get_path(LIBRARY_PATH).'course_description.lib.php';
 
 /*
 -----------------------------------------------------------
@@ -161,12 +162,29 @@ if ($intro_dispForm) {
 	echo '</div>';
 }
 
+$course_description = new CourseDescription();
+$course_description->set_session_id(api_get_session_id());
+$thematic_description = $course_description->get_data_by_description_type(8);
+
+$thematic_description_html = '';
+if (!empty($thematic_description)) {
+	$thematic_description_html = '<td valign="bottom" width="260px"><div class="thematic-postit">
+							  <div class="thematic-postit-top">'.Display::return_icon('postit_top.jpg').'</div>
+							  <div class="thematic-postit-center">
+							  	<h3>'.get_lang('ThematicAdvance').'&nbsp;'.$course_description->get_progress_porcent(false,8).'</h3>
+								'.$thematic_description['description_title'].'
+								<p>'.$thematic_description['description_content'].'</p>
+							  </div>
+							  <div  class="thematic-postit-bottom">'.Display::return_icon('postit_bottom.jpg').'</div>
+							  </div></td>';
+}
+
 if ($intro_dispDefault) {
 	//$intro_content = make_clickable($intro_content); // make url in text clickable
 	$intro_content = text_filter($intro_content); // parse [tex] codes
-	if (!empty($intro_content))	{
-		echo "<table align='center' style='width: 80%;'><tr><td>$intro_content</td></tr></table>";
-	}
+	if (!empty($intro_content) || !empty($thematic_description_html))	{
+		echo "<table align='center' style='width: 80%;'><tr><td>$intro_content</td>$thematic_description_html</tr></table>";
+	} 
 }
 
 if ($intro_dispCommand) {

+ 35 - 6
user_portal.php

@@ -315,11 +315,12 @@ function display_especial_courses ($user_id) {
 					}
 					if (($course['status'] == 5 && !api_is_coach()) || empty($course['status'])) {
 						$status_icon=Display::return_icon('course.gif', get_lang('Course')).' '.Display::return_icon('students.gif', get_lang('Status').': '.get_lang('Student'),array('style'=>'width:11px; height:11px'));
-					}
+					} 
+					$progress_thematic_icon = get_thematic_progress_icon($course['db_name']);
 					echo "\t<tr>\n";
 					echo "\t\t<td>\n";
 					$course_title = '<a href="'.api_get_path(WEB_COURSE_PATH).$course['directory'].'/?id_session=0">'.$course['title'].'</a>';
-					echo "<div style=\"float:left;margin-right:10px;\">".$status_icon."</div><span style=\"font-size:135%;\">".$course_title."</span><br />";					
+					echo "<div style=\"float:left;margin-right:10px;\">".$status_icon."</div><span style=\"font-size:135%;\">".$course_title."</span>&nbsp;&nbsp;<span>$progress_thematic_icon</span><br />";					
 					if (api_get_setting('display_coursecode_in_courselist') == 'true') {
 						echo $course['visual_code'];
 					}
@@ -426,11 +427,12 @@ function display_courses_in_category($user_category_id) {
 		}
 		if (($course['status'] == 5 && !api_is_coach()) || empty($course['status'])) {
 			$status_icon=Display::return_icon('course.gif', get_lang('Course')).' '.Display::return_icon('students.gif', get_lang('Status').': '.get_lang('Student'),array('style'=>'width:11px; height:11px'));
-		}
+		}				
+		$progress_thematic_icon = get_thematic_progress_icon($course['db_name']);			
 		echo "\t<tr>\n";
 		echo "\t\t<td>\n";
 		$course_title = '<a href="'.api_get_path(WEB_COURSE_PATH).$course['directory'].'/?id_session=0">'.$course['title'].'</a>';
-		echo "<div style=\"float:left;margin-right:10px;\">".$status_icon."</div><span style=\"font-size:135%;\">".$course_title."</span><br />";
+		echo "<div style=\"float:left;margin-right:10px;\">".$status_icon."</div><span style=\"font-size:135%;\">".$course_title."</span>&nbsp;&nbsp;<span>$progress_thematic_icon </span><br />";
 		if (api_get_setting('display_coursecode_in_courselist') == 'true') {
 			echo $course['visual_code'];
 		}
@@ -452,6 +454,31 @@ function display_courses_in_category($user_category_id) {
 -----------------------------------------------------------
 */
 
+/**
+ * get icon showing thematic progress for a course
+ * @param string 	Course database name
+ * @param int		Session id (optional)
+ * @return string   img html
+ */
+ function get_thematic_progress_icon($course_dbname,$session_id = 0) {
+ 	$tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION,$course_dbname);
+ 	$session_id = intval($session_id);
+	$sql = "SELECT progress FROM $tbl_course_description WHERE description_type = 8 AND session_id = '$session_id' ";
+	$rs  = Database::query($sql, __FILE__, __LINE__);
+	$img = '';
+	$title = '0%';
+	$image = 'level_0.png';
+	if (Database::num_rows($rs) > 0) {
+		$row = Database::fetch_array($rs);		
+		$progress = $row['progress'];
+		$image = 'level_'.$progress.'.png';
+		$title = $row['progress'].'%';	
+	} 
+	$img = Display::return_icon($image,get_lang('ThematicAdvance'),array('style'=>'vertical-align:middle')).'&nbsp;'.$title;			
+	return $img;	
+ }
+		
+
 /**
  * Warning: this function defines a global.
  * @todo use the correct get_path function
@@ -687,6 +714,8 @@ function get_logged_user_course_html($course, $session_id = 0, $class='courses')
 	} else {
 		$result .= $course_display_title." "." ".get_lang('CourseClosed')."";
 	}
+	$progress_thematic_icon = get_thematic_progress_icon($course_database,$session_id);
+	$result .= '&nbsp;&nbsp;<span>'.$progress_thematic_icon.'</span>';			
 	// show the course_code and teacher if chosen to display this
 	if (api_get_setting('display_coursecode_in_courselist') == 'true' || api_get_setting('display_teacher_in_courselist') == 'true') {
 		$result .= '<br />';
@@ -1175,8 +1204,8 @@ if ( is_array($courses_tree) ) {
 		// sessions and courses that are not in a session category
 
 			if (!isset($_GET['history'])) { // check if it's not history trainnign session list
-				echo display_especial_courses(api_get_user_id());
-				echo display_courses(api_get_user_id());
+				display_especial_courses(api_get_user_id());
+				display_courses(api_get_user_id());
 			}
 			//independent sessions
 			foreach ($category['sessions'] as $session) {