Browse Source

Improving exercise header result

Julio Montoya 13 years ago
parent
commit
a907dabe66
2 changed files with 33 additions and 38 deletions
  1. 15 37
      main/exercice/exercise.class.php
  2. 18 1
      main/inc/lib/display.lib.php

+ 15 - 37
main/exercice/exercise.class.php

@@ -3278,44 +3278,22 @@ class Exercise {
 	}
 
 	function show_exercise_result_header($user_data, $date = null) {
-		$description = '';
+		$array = array();
+                    
+        if (!empty($user_data)) {
+            $array[] = array('title' => get_lang("User"), 'content' => $user_data);
+        }
+        
 		if (!empty($this->description)) {
-			$description = '<tr>
-        		<td style="font-weight:bold" width="10%">
-        			&nbsp;'.get_lang("Description").' :
-        		</td>
-        		<td width="90%">			
-        		'.$this->description.'
-        		</td>
-        	</tr>';
-		}
-		$date_data = '';
-		if (!empty($date)) {
-			$date_data = '<tr>
-        		<td style="font-weight:bold" width="10%">
-        			&nbsp;'.get_lang("Date").' :
-        		</td>
-        		<td width="90%">			
-        		'.$date.'
-        		</td>
-        	</tr>';
-		}
-		$html = '<table width="100%">
-        	<tr>
-        	<td colspan="2">
-        		<h2>'.Display::return_icon('quiz_big.png', get_lang('Result')).' '.$this->exercise.' : '.get_lang('Result').'</h2>
-        	</td>	
-        	</tr>		
-        	<tr>
-        		<td style="font-weight:bold" width="90px">&nbsp;'.get_lang('User').' : </td>
-        		<td>
-        		'.$user_data.'
-                </td>
-            </tr>            
-            '.$date_data.'
-        	'.$description.'
-        </table>
-        <br />';
+            $array[] = array('title' => get_lang("Description"), 'content' => $this->description);
+		}		
+        
+		if (!empty($date)) {			
+             $array[] = array('title' => get_lang("Date"), 'content' => $date);
+		}
+    
+		$html = Display::page_header(Display::return_icon('quiz_big.png', get_lang('Result')).' '.$this->exercise.' : '.get_lang('Result'));
+        $html .= Display::description($array);        
 		return $html;
 	}
 	

+ 18 - 1
main/inc/lib/display.lib.php

@@ -1364,10 +1364,27 @@ class Display {
         return '<div class="page-header"><h1>'.$title.'</h1></div>';
     }
     
-    public function page_subheader($title) {
+    public function page_subheader($title, $second_title = null) {
+        if (!empty($second_title)) {
+            $second_title = Security::remove_XSS($second_title);
+            $title .= "<small> $second_title<small>";
+        }
         return '<div class="page-header"><h2>'.Security::remove_XSS($title).'</h2></div>';
     }
     
+    public function description($list) {
+        $html = null;
+        if (!empty($list)) {
+            $html = '<dl class="dl-horizontal">';
+            foreach ($list as $item) {
+                $html .= '<dt>'.$item['title'].'</dd>';
+                $html .= '<dd>'.$item['content'].'</dt>';
+            }
+            $html .= '</dl>';
+        }
+        return $html;
+    }
+    
     function bar_progress($percentage, $show_percentage = true, $extra_info = null) {
         $percentage = intval($percentage);
         $div = '<div class="progress progress-striped">