Fixes #5568 requires testing

skala
Julio Montoya 16 years ago
parent e3654cee6f
commit 0f3c892a40
  1. 2
      main/auth/profile.php
  2. 9
      main/inc/lib/usermanager.lib.php
  3. 6
      main/social/profile.php
  4. 77
      main/tracking/courseLog.php

@ -393,7 +393,7 @@ foreach ($extra as $id => $field_details) {
$tag_list = '';
if (is_array($user_tags) && count($user_tags)> 0) {
foreach ($user_tags as $tag) {
$tag_list .= '<option value="'.$tag[0].'" class="selected">'.$tag[0].'</option>';
$tag_list .= '<option value="'.$tag['tag'].'" class="selected">'.$tag['tag'].'</option>';
}
}
$multi_select = '<select id="extra_'.$field_details[1].'" name="extra_'.$field_details[1].'">

@ -2251,7 +2251,7 @@ class UserManager
*
* USER TAGS
*
* Intructions to create a new user tag
* Intructions to create a new user tag by Julio Montoya <gugli100@gmail.com>
*
* 1. Create a new extra field in main/admin/user_fields.php with the "TAG" field type make it available and visible. Called it "books" for example.
* 2. Go to profile main/auth/profile.php There you will see a special input (facebook style) that will show suggestions of tags.
@ -2267,6 +2267,8 @@ class UserManager
* @param int field_id
* @param string how we are going to result value in array or in a string (json)
* @return mixed
* @since Nov 2009
* @version 1.8.6.2
*/
public static function get_tags($tag, $field_id, $return_format='json',$limit=10) {
// database table definition
@ -2330,7 +2332,7 @@ class UserManager
$return = array();
if (Database::num_rows($result)> 0) {
while ($row = Database::fetch_array($result,'ASSOC')) {
$return[$row['id']] = array($row['tag'],$row['count']);
$return[$row['id']] = array('tag'=>$row['tag'],'count'=>$row['count']);
}
}
return $return;
@ -2487,7 +2489,7 @@ class UserManager
//echo '<pre>';var_dump($tags);
if(is_array($tags) && count($tags)>0) {
foreach ($tags as $key=>$tag) {
if ($tag[1]>'0') {
if ($tag['count']>'0') {
$sql = "UPDATE $table_user_tag SET count = count - 1 WHERE id = $key ";
$result = Database::query($sql, __FILE__, __LINE__);
}
@ -2506,6 +2508,7 @@ class UserManager
* @return bool
*/
public function process_tags($tags, $user_id, $field_id) {
//We loop the tags and add it to the DB
if (is_array($tags)) {
foreach($tags as $tag) {

@ -746,7 +746,7 @@ echo '<div id="social-profile-container">';
if (is_array($data)) {
$extra_information_value .= '<strong>'.ucfirst($field_display_text).':</strong> '.implode(',',$data).'<br />';
} else {
if ($field_type == 8) {
if ($field_type == USER_FIELD_TYPE_DOUBLE_SELECT) {
$id_options = explode(';',$data);
$value_options = array();
// get option display text from user_field_options table
@ -757,11 +757,11 @@ echo '<div id="social-profile-container">';
$value_options[] = $row_options[0];
}
$extra_information_value .= '<strong>'.ucfirst($field_display_text).':</strong> '.implode(' ',$value_options).'<br />';
} elseif($field_type == 10) {
} elseif($field_type == USER_FIELD_TYPE_TAG ) {
$user_tags = UserManager::get_user_tags($user_id, $field_id);
$tag_tmp = array();
foreach ($user_tags as $tags) {
$tag_tmp[] = $tags[0];
$tag_tmp[] = $tags['tag'];
}
if (is_array($user_tags) && count($user_tags)>0) {
$extra_information_value .= '<strong>'.ucfirst($field_display_text).':</strong> '.implode(', ',$tag_tmp).'<br />';

@ -119,6 +119,19 @@ Display::display_header($nameTools, 'Tracking');
// getting all the students of the course
$a_students = CourseManager :: get_student_list_from_course_code($_course['id'], true, (empty($_SESSION['id_session']) ? null : $_SESSION['id_session']));
$nbStudents = count($a_students);
// gettting all the additional information of an additional profile field
if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
//$additional_user_profile_info = get_addtional_profile_information_of_field($_GET['additional_profile_field']);
$user_array = array();
foreach($a_students as $key=>$item){
$user_array[] = $key;
}
//fetching only the user that are loaded NOT ALL user in the portal
$additional_user_profile_info = get_addtional_profile_information_of_field_by_user($_GET['additional_profile_field'],$user_array);
}
function count_item_resources() {
$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
@ -271,6 +284,9 @@ function get_tool_name_table($tool) {
'id_tool' => $id_tool);
}
/*
==============================================================================
MAIN CODE
@ -291,7 +307,9 @@ if($_GET['studentlist'] == 'false') {
} elseif ($_GET['studentlist'] == '' || $_GET['studentlist'] == 'true') {
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&export=csv">'.Display::return_icon('csv.gif',get_lang('ExportAsCSV')).get_lang('ExportAsCSV').'</a>';
}
echo display_additional_profile_fields();
if($_GET['studentlist'] == 'true' || empty($_GET['studentlist'])) {
echo display_additional_profile_fields();
}
echo '</div>';
@ -653,7 +671,7 @@ if ($_GET['studentlist'] == 'false') {
$course_code = $_course['id'];
foreach ($a_students as $student_id => $student) {
$student_datas = UserManager :: get_user_info_by_id($student_id);
$avg_time_spent = $avg_student_score = $avg_student_progress = $total_assignments = $total_messages = 0;
$nb_courses_student = 0;
$avg_time_spent = Tracking :: get_time_spent_on_the_course($student_id, $course_code);
@ -685,7 +703,8 @@ if ($_GET['studentlist'] == 'false') {
// we need to display an additional profile field
if (isset($_GET['additional_profile_field']) AND is_numeric($_GET['additional_profile_field'])) {
$row[]=implode($additional_user_profile_info[$student_id]);
if (is_array($additional_user_profile_info[$student_id]))
$row[]=implode(', ', $additional_user_profile_info[$student_id]);
}
if ($export_csv) {
$row[8] = strip_tags($row[8]);
@ -693,8 +712,7 @@ if ($_GET['studentlist'] == 'false') {
unset($row[10]);
$csv_content[] = $row;
}
$all_datas[] = $row;
$all_datas[] = $row;
}
usort($all_datas, 'sort_users');
@ -852,7 +870,7 @@ function get_addtional_profile_information_of_field($field_id){
$sql = "SELECT user.user_id, field.field_value FROM $table_user user, $table_user_field_values field
WHERE user.user_id = field.user_id
AND field.field_id='".Database::escape_string($field_id)."'";
AND field.field_id='".intval($field_id)."'";
$result = api_sql_query($sql,__FILE__,__LINE__);
while($row = Database::fetch_array($result))
{
@ -861,6 +879,53 @@ function get_addtional_profile_information_of_field($field_id){
return $return;
}
/**
* This function gets all the information of a certrain ($field_id) additional profile field for a specific list of users is more efficent than get_addtional_profile_information_of_field() function
* It gets the information of all the users so that it can be displayed in the sortable table or in the csv or xls export
*
* @author Julio Montoya <gugli100@gmail.com>
* @param int field id
* @param array list of user ids
* @return array
* @since Nov 2009
* @version 1.8.6.2
*/
function get_addtional_profile_information_of_field_by_user($field_id, $users){
// Database table definition
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$table_user_field_values = Database::get_main_table(TABLE_MAIN_USER_FIELD_VALUES);
$result = UserManager::get_extra_field_information($field_id);
if (!empty($users)) {
if ($result['field_type'] == USER_FIELD_TYPE_TAG ) {
foreach($users as $user_id) {
$user_result = UserManager::get_user_tags($user_id, $field_id);
$tag_list = array();
foreach($user_result as $item) {
$tag_list[] = $item['tag'];
}
$return[$user_id][] = implode(', ',$tag_list);
}
} else {
$new_user_array = array();
foreach($users as $user_id) {
$new_user_array[]= "'".$user_id."'";
}
$users = implode(',',$new_user_array);
//selecting only the necessary information NOT ALL the user list
$sql = "SELECT user.user_id, field.field_value FROM $table_user user INNER JOIN $table_user_field_values field
ON (user.user_id = field.user_id)
WHERE field.field_id=".intval($field_id)." AND user.user_id IN ($users)";
$result = api_sql_query($sql,__FILE__,__LINE__);
while($row = Database::fetch_array($result)) {
$return[$row['user_id']][] = $row['field_value'];
}
}
}
return $return;
}
/**
* count the number of students in this course (used for SortableTable)
*/

Loading…
Cancel
Save