Browse Source

Added IP information to exercise tracking (as info icon) - refs #3987

Yannick Warnier 12 years ago
parent
commit
f60a60f5c4

+ 2 - 0
main/exercice/exercise.lib.php

@@ -1189,6 +1189,8 @@ function get_exam_results_data($from, $number_of_items, $column, $direction, $ex
 
                         //Admin can always delete the attempt
                         if ($locked == false || api_is_platform_admin()) {
+                            $ip = TrackingUserLog::get_ip_from_user_event($results[$i]['exe_user_id'], $results[$i]['exe_date'], false);
+                            $actions .= '<a href="http://www.whatsmyip.org/ip-geo-location/?ip='.$ip.'" target="_blank"><img src="'.api_get_path(WEB_CODE_PATH).'img/icons/22/info.png" title="'.$ip.'" /></a>';
                             $actions .=' <a href="exercise_report.php?'.api_get_cidreq().'&filter_by_user='.intval($_GET['filter_by_user']).'&filter=' . $filter . '&exerciseId='.$exercise_id.'&delete=delete&did=' . $id . '" onclick="javascript:if(!confirm(\'' . sprintf(get_lang('DeleteAttempt'), $user, $dt) . '\')) return false;">'.Display :: return_icon('delete.png', get_lang('Delete')).'</a>';
                             $actions .='&nbsp;';
                         }

+ 3 - 3
main/exercice/exercise_report.php

@@ -351,8 +351,8 @@ if ($is_allowedToEdit || $is_tutor) {
                             'editoptions' => array('value' => $group_parameters)),
                         array('name'=>'duration',       'index'=>'exe_duration',	'width'=>'30',   'align'=>'left', 'search' => 'true'),
                         array('name'=>'start_date',		'index'=>'start_date',		'width'=>'60',   'align'=>'left', 'search' => 'true'),
-						array('name'=>'exe_date',		'index'=>'exe_date',		'width'=>'60',   'align'=>'left', 'search' => 'true'),
-						array('name'=>'score',			'index'=>'exe_result',	    'width'=>'50',   'align'=>'left', 'search' => 'true'),
+			array('name'=>'exe_date',		'index'=>'exe_date',		'width'=>'60',   'align'=>'left', 'search' => 'true'),
+			array('name'=>'score',			'index'=>'exe_result',	    'width'=>'50',   'align'=>'left', 'search' => 'true'),
                         array('name'=>'status',         'index'=>'revised',			'width'=>'40',   'align'=>'left', 'search' => 'true', 'stype'=>'select',
                               //for the bottom bar
                               'searchoptions' => array(
@@ -482,4 +482,4 @@ $(function() {
 <?php
 
 echo Display::grid_html('results');
-Display :: display_footer();
+Display :: display_footer();

+ 3 - 2
main/inc/lib/tracking.lib.php

@@ -4117,10 +4117,11 @@ class TrackingUserLog {
      * @param int User ID
      * @param string Datetime
      * @param bool Whether to return the IP as a link or just as an IP
+     * @param string If defined and return_as_link if true, will be used as the text to be shown as the link
      * @return string IP address (or false on error)
      * @assert (0,0) === false
      */
-    function get_ip_from_user_event($user_id, $event_date, $return_as_link = false) {
+    function get_ip_from_user_event($user_id, $event_date, $return_as_link = false, $body_replace = null) {
         if (empty($user_id) or empty($event_date)) {
             return false;
         }
@@ -4131,7 +4132,7 @@ class TrackingUserLog {
         if ($res_ip !== false && Database::num_rows($res_ip)>0) {
             $row_ip = Database::fetch_row($res_ip);
             if ($return_as_link) {
-                $ip = Display::url($row_ip[1], 'http://www.whatsmyip.org/ip-geo-location/?ip='.$row_ip[1], array('title'=>get_lang('TraceIP'), 'target'=>'_blank'));
+                $ip = Display::url((empty($body_replace)?$row_ip[1]:$body_replace), 'http://www.whatsmyip.org/ip-geo-location/?ip='.$row_ip[1], array('title'=>get_lang('TraceIP'), 'target'=>'_blank'));
             } else {
                 $ip = $row_ip[1];
             }