[svn r14615] add the DRH status (adapted from ucanss development)

skala
Eric Marguin 18 years ago
parent 9dbeaa3b5f
commit b8fc0810ef
  1. 40
      main/admin/user_add.php
  2. 32
      main/admin/user_edit.php
  3. 4
      main/admin/user_list.php
  4. 8
      main/inc/banner.inc.php
  5. 2
      main/inc/lib/main_api.lib.php
  6. 22
      main/inc/lib/tracking.lib.php
  7. 28
      main/inc/lib/usermanager.lib.php
  8. 1
      main/inc/local.inc.php
  9. 28
      main/mySpace/index.php
  10. 15
      main/mySpace/lp_tracking.php
  11. 17
      main/mySpace/myStudents.php
  12. 12
      main/mySpace/student.php

@ -1,4 +1,4 @@
<?php // $Id: user_add.php 13273 2007-09-26 09:50:11Z elixir_julian $
<?php // $Id: user_add.php 14615 2008-03-17 09:53:23Z elixir_inter $
/*
==============================================================================
Dokeos - elearning and course management software
@ -68,6 +68,18 @@ function password_switch_radio_button(form, input){
}
}
function display_drh_list(){
if(document.getElementById("status_select").value=='.STUDENT.')
{
document.getElementById("drh_list").style.display="block";
}
else
{
document.getElementById("drh_list").style.display="none";
document.getElementById("drh_select").options[0].selected="selected";
}
}
//-->
</script>';
@ -127,11 +139,28 @@ $group[] =& HTML_QuickForm::createElement('radio','password_auto',get_lang('Pass
$group[] =& HTML_QuickForm::createElement('radio', 'password_auto','id="radio_user_password"',null,0);
$group[] =& HTML_QuickForm::createElement('password', 'password',null,'onkeydown=password_switch_radio_button(document.user_add,"password[password_auto]")');
$form->addGroup($group, 'password', get_lang('Password'), '');
// Status
$status = array();
$status[COURSEMANAGER] = get_lang('CourseAdmin');
$status[STUDENT] = get_lang('Student');
$form->addElement('select','status',get_lang('Status'),$status);
$status[COURSEMANAGER] = get_lang('Teacher');
$status[STUDENT] = get_lang('Learner');
$status[DRH] = get_lang('Drh');
//$status[ADMINCRFP] = get_lang('AdminCrfp');
$form->addElement('select','status',get_lang('Status'),$status,'id="status_select" onchange="display_drh_list()"');
//drh list (display only if student)
$display = $_POST['status'] == STUDENT ? 'block' : 'none';
$form->addElement('html','<div id="drh_list" style="display:'.$display.';">');
$drh_select = $form->addElement('select','drh_id',get_lang('Drh'),array(),'id="drh_select"');
$drh_list = UserManager :: get_user_list(array('status'=>DRH),array('lastname','firstname'));
$drh_select->addOption('---',0);
foreach($drh_list as $drh)
{
$drh_select->addOption($drh['lastname'].' '.$drh['firstname'],$drh['user_id']);
}
$form->addElement('html', '</div>');
// Platform admin
$group = array();
$group[] =& HTML_QuickForm::createElement('radio', 'platform_admin',null,get_lang('Yes'),1);
@ -201,6 +230,7 @@ if( $form->validate())
$picture = $_FILES['picture'];
$platform_admin = intval($user['admin']['platform_admin']);
$send_mail = intval($user['mail']['send_mail']);
$drh_id = intval($user['drh_id']);
if(count($extAuthSource) > 0 && $user['password']['password_auto'] == '2')
{
$auth_source = $user['password']['auth_source'];
@ -221,7 +251,7 @@ if( $form->validate())
}
$active = intval($user['active']);
$user_id = UserManager::create_user($firstname,$lastname,$status,$email,$username,$password,$official_code,api_get_setting('platformLanguage'),$phone,$picture_uri,$auth_source,$expiration_date,$active);
$user_id = UserManager::create_user($firstname,$lastname,$status,$email,$username,$password,$official_code,api_get_setting('platformLanguage'),$phone,$picture_uri,$auth_source,$expiration_date,$active, $drh_id);
if ($platform_admin)
{
$sql = "INSERT INTO $table_admin SET user_id = '".$user_id."'";

@ -1,4 +1,4 @@
<?php // $Id: user_edit.php 13895 2007-12-03 21:54:45Z yannoo $
<?php // $Id: user_edit.php 14615 2008-03-17 09:53:23Z elixir_inter $
/*
==============================================================================
Dokeos - elearning and course management software
@ -43,6 +43,18 @@ function enable_expiration_date() { //v2.0
document.user_add.radio_expiration_date[0].checked=false;
document.user_add.radio_expiration_date[1].checked=true;
}
function display_drh_list(){
if(document.getElementById("status_select").value=='.STUDENT.')
{
document.getElementById("drh_list").style.display="block";
}
else
{
document.getElementById("drh_list").style.display="none";
document.getElementById("drh_select").options[0].selected="selected";
}
}
//-->
</script>';
@ -148,7 +160,20 @@ $form->addGroup($group, 'password', null, '',false);
$status = array();
$status[COURSEMANAGER] = get_lang('CourseAdmin');
$status[STUDENT] = get_lang('Student');
$form->addElement('select','status',get_lang('Status'),$status);
$status[DRH] = get_lang('Drh');
$status[ADMINCRFP] = get_lang('AdminCrfp');
$form->addElement('select','status',get_lang('Status'),$status,'id="status_select" onchange="display_drh_list()"');
$display = $user_data['status'] == STUDENT || $_POST['status'] == STUDENT ? 'block' : 'none';
$form->addElement('html','<div id="drh_list" style="display:'.$display.';">');
$drh_select = $form->addElement('select','drh_id',get_lang('Drh'),array(),'id="drh_select"');
$drh_list = UserManager :: get_user_list(array('status'=>DRH),array('lastname','firstname'));
$drh_select->addOption('---',0);
foreach($drh_list as $drh)
{
$drh_select->addOption($drh['lastname'].' '.$drh['firstname'],$drh['user_id']);
}
$form->addElement('html', '</div>');
// Platform admin
// Only when changing another user!
@ -240,6 +265,7 @@ if( $form->validate())
$platform_admin = intval($user['platform_admin']);
$send_mail = intval($user['send_mail']);
$reset_password = intval($user['reset_password']);
$drh_id = intval($user['drh_id']);
if ($user['radio_expiration_date']=='1' && ! $user_data['platform_admin'] )
{
$expiration_date=$user['expiration_date'];
@ -270,7 +296,7 @@ if( $form->validate())
$password = $user['password'];
$auth_source = $user['auth_source'];
}
UserManager::update_user($user_id,$firstname,$lastname,$username,$password,$auth_source,$email,$status,$official_code,$phone,$picture_uri,$expiration_date, $active);
UserManager::update_user($user_id,$firstname,$lastname,$username,$password,$auth_source,$email,$status,$official_code,$phone,$picture_uri,$expiration_date, $active, null, $drh_id);
if(api_get_setting('openid_authentication')=='true' && !empty($user['openid']))
{
$up = UserManager::update_openid($user_id,$user['openid']);

@ -1,6 +1,6 @@
<?php
// $Id: user_list.php 14115 2008-01-16 17:23:27Z elixir_inter $
// $Id: user_list.php 14615 2008-03-17 09:53:23Z elixir_inter $
/*
==============================================================================
Dokeos - elearning and course management software
@ -265,7 +265,7 @@ function get_user_data($from, $number_of_items, $column, $direction)
$sql .= " LIMIT $from,$number_of_items";
$res = api_sql_query($sql, __FILE__, __LINE__);
$users = array ();
$status = array(1=>get_lang('Teacher'),5=>get_lang('Student'),6=>get_lang('Anonymous'));
$status = array(1=>get_lang('Teacher'),4=>get_lang('Drh'),5=>get_lang('Student'),6=>get_lang('Anonymous'));
while ($user = mysql_fetch_row($res))
{

@ -262,7 +262,7 @@ if ($_user['user_id'] && !api_is_anonymous())
// Reporting
if (api_get_setting('show_tabs', 'reporting') == 'true')
{
if(api_is_allowed_to_create_course())
if(api_is_allowed_to_create_course() || $_user['status'] == DRH)
{
$navigation['session_my_space'] = $possible_tabs['session_my_space'];
}
@ -273,7 +273,7 @@ if ($_user['user_id'] && !api_is_anonymous())
}
else
{
if(api_is_allowed_to_create_course())
if(api_is_allowed_to_create_course() || $_user['status'] == DRH)
{
$menu_navigation['session_my_space'] = $possible_tabs['session_my_space'];
}
@ -473,7 +473,7 @@ if(api_get_setting('show_navigation_menu') != 'false' && api_get_setting('show_n
*/
function get_tabs()
{
global $_course, $rootAdminWeb;
global $_course, $rootAdminWeb, $_user;
// Campus Homepage
$navigation[SECTION_CAMPUS]['url'] = api_get_path(WEB_PATH).'index.php';
@ -526,7 +526,7 @@ function get_tabs()
}
// Reporting
if(api_is_allowed_to_create_course())
if(api_is_allowed_to_create_course() || $_user['status']==DRH)
{
// Link to my space
$navigation['session_my_space']['url'] = api_get_path(WEB_PATH).'main/mySpace/';

@ -48,6 +48,8 @@
define('STUDENT', 5);
/** global status of a user: course manager */
define('COURSEMANAGER', 1);
define('ADMINCRFP', 3);
define('DRH', 4);
//COURSE VISIBILITY CONSTANTS
/** only visible for course admin */

@ -766,5 +766,27 @@ class Tracking {
return $nb_login;
}
function get_student_followed_by_drh($drh_id) {
$drh_id = intval($drh_id);
$a_students = array ();
$tbl_organism = Database :: get_main_table(TABLE_MAIN_ORGANISM);
$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
$sql = 'SELECT DISTINCT user_id FROM '.$tbl_user.' as user
WHERE drh_id='.$drh_id;
$rs = api_sql_query($sql, __FILE__, __LINE__);
while($user = Database :: fetch_array($rs))
{
$a_students[$user['user_id']] = $user['user_id'];
}
return $a_students;
}
}
?>

@ -57,7 +57,7 @@ class UserManager
*
* @todo Add the user language to the parameters
*/
function create_user($firstName, $lastName, $status, $email, $loginName, $password, $official_code = '', $language='', $phone = '', $picture_uri = '', $auth_source = PLATFORM_AUTH_SOURCE, $expiration_date = '0000-00-00 00:00:00', $active = 1)
function create_user($firstName, $lastName, $status, $email, $loginName, $password, $official_code = '', $language='', $phone = '', $picture_uri = '', $auth_source = PLATFORM_AUTH_SOURCE, $expiration_date = '0000-00-00 00:00:00', $active = 1, $drh_id=0)
{
global $_user, $userPasswordCrypted;
@ -98,6 +98,7 @@ class UserManager
language = '".Database::escape_string($language)."',
registration_date = now(),
expiration_date = '".Database::escape_string($expiration_date)."',
drh_id = '".Database::escape_string($drh_id)."',
active = '".Database::escape_string($active)."'";
$result = api_sql_query($sql);
if ($result)
@ -245,7 +246,7 @@ class UserManager
* @param int $creator_id
* @return boolean true if the user information was updated
*/
function update_user($user_id, $firstname, $lastname, $username, $password = null, $auth_source = null, $email, $status, $official_code, $phone, $picture_uri, $expiration_date, $active, $creator_id= null )
function update_user($user_id, $firstname, $lastname, $username, $password = null, $auth_source = null, $email, $status, $official_code, $phone, $picture_uri, $expiration_date, $active, $creator_id= null, $drh_id=0)
{
global $userPasswordCrypted;
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
@ -269,7 +270,8 @@ class UserManager
phone='".Database::escape_string($phone)."',
picture_uri='".Database::escape_string($picture_uri)."',
expiration_date='".Database::escape_string($expiration_date)."',
active='".Database::escape_string($active)."'";
active='".Database::escape_string($active)."',
drh_id=".intval($drh_id);
if(!is_null($creator_id))
{
$sql .= ", creator_id='".Database::escape_string($creator_id)."'";
@ -292,14 +294,27 @@ class UserManager
}
/**
* @param array $conditions a list of condition (exemple : status=>STUDENT)
* @param array $order_by a list of fields on which sort
* @return an array with all users of the platform.
* @todo optional course code parameter, optional sorting parameters...
* @deprecated This function isn't used anywhere in the code.
*/
function get_user_list()
function get_user_list($conditions = array(), $order_by = array())
{
$user_table = Database :: get_main_table(TABLE_MAIN_USER);
$sql_query = "SELECT * FROM $user_table";
if(count($conditions)>0)
{
$sql_query .= ' WHERE ';
foreach($conditions as $field=>$value)
{
$sql_query .= $field.' = '.$value;
}
}
if(count($order_by)>0)
{
$sql_query .= ' ORDER BY '.implode(',',$order_by);
}
$sql_result = api_sql_query($sql_query,__FILE__,__LINE__);
while ($result = Database::fetch_array($sql_result))
{
@ -307,6 +322,9 @@ class UserManager
}
return $return_array;
}
/**
* Get user information
* @param string $username The username

@ -528,6 +528,7 @@ $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
$_user ['language'] = $uData ['language'];
$_user ['auth_source'] = $uData ['auth_source'];
$_user ['theme'] = $uData ['theme'];
$_user ['status'] = $uData ['status'];
$is_platformAdmin = (bool) (! is_null( $uData['is_admin']));
$is_allowedCreateCourse = (bool) ($uData ['status'] == 1);

@ -136,6 +136,12 @@ if(api_is_platform_admin())
$menu_items[] = '<a href="'.api_get_self().'?view=admin">'.get_lang('AdminInterface').'</a>';
}
}
if($_user['status']==DRH)
{
$view = 'drh';
$title = get_lang('DrhInterface');
$menu_items[] = '<a href="'.api_get_self().'?view=drh">'.get_lang('DrhInterface').'</a>';
}
$nb_menu_items = count($menu_items);
if($nb_menu_items>1)
@ -157,14 +163,23 @@ echo '<div align="left" style="float:left"><h4>'.$title.'</h4></div>
</div>
<div class="clear"></div>';
if($isCoach && $view=='coach')
if($_user['status']==DRH && $view=='drh')
{
$a_students = Tracking :: get_student_followed_by_drh($_user['user_id']);
$courses_of_the_platform = CourseManager :: get_real_course_list();
foreach($courses_of_the_platform as $course)
$a_courses[$course['code']] = $course['code'];
}
/****************************************
* Infos about students of the coach
****************************************/
if($isCoach && $view=='coach')
{
$a_students = Tracking :: get_student_followed_by_coach($_user['user_id']);
$a_courses = Tracking :: get_courses_followed_by_coach($_user['user_id']);
}
if($view=='coach' || $view=='drh')
{
$nbStudents = count($a_students);
$totalTimeSpent = 0;
@ -200,6 +215,7 @@ if($isCoach && $view=='coach')
{
if(CourseManager :: is_user_subscribed_in_course($student_id, $course_code, true))
{
$nb_courses_student++;
$nb_posts += Tracking :: count_student_messages($student_id,$course_code);
$nb_assignments += Tracking :: count_student_assignments($student_id,$course_code);
$avgStudentProgress += Tracking :: get_avg_student_progress($student_id,$course_code);
@ -322,7 +338,9 @@ if($isCoach && $view=='coach')
<a href="student.php">'.get_lang('SeeStudentList').'</a>
</div>';
}
}
if($view == 'coach')
{
/****************************************
* Infos about sessions of the coach

@ -12,6 +12,7 @@ include ('../inc/global.inc.php');
include_once(api_get_path(LIBRARY_PATH).'tracking.lib.php');
include_once(api_get_path(LIBRARY_PATH).'export.lib.inc.php');
include_once(api_get_path(LIBRARY_PATH).'course.lib.php');
include_once(api_get_path(LIBRARY_PATH).'usermanager.lib.php');
include_once('../newscorm/learnpath.class.php');
include_once('../newscorm/learnpathItem.class.php');
require_once (api_get_path(LIBRARY_PATH).'export.lib.inc.php');
@ -23,7 +24,13 @@ if($export_csv)
}
$csv_content = array();
if(!api_is_platform_admin() && !CourseManager :: is_course_teacher($_user['user_id'], $_GET['course']) && !Tracking :: is_allowed_to_coach_student($_user['user_id'],$_GET['student_id']))
$user_id = intval($_GET['student_id']);
$user_infos = UserManager :: get_user_info_by_id($user_id);
$name = $user_infos['firstname'].' '.$user_infos['lastname'];
if(!api_is_platform_admin() && !CourseManager :: is_course_teacher($_user['user_id'], $_GET['course']) && !Tracking :: is_allowed_to_coach_student($_user['user_id'],$_GET['student_id']) && $user_infos['drh_id']!==$_user['user_id'])
{
Display::display_header('');
api_not_allowed();
@ -118,7 +125,6 @@ div.description {
Display :: display_header($nameTools);
$user_id = intval($_GET['student_id']);
$lp_id = intval($_GET['lp_id']);
$sql = 'SELECT name
@ -127,11 +133,6 @@ $sql = 'SELECT name
$rs = api_sql_query($sql, __FILE__, __LINE__);
$lp_title = mysql_result($rs, 0, 0);
$sql = 'SELECT lastname, firstname
FROM '.Database::get_main_table(TABLE_MAIN_USER).'
WHERE user_id='.$user_id;
$rs = api_sql_query($sql, __FILE__, __LINE__);
$name = mysql_result($rs, 0, 0).' '.mysql_result($rs, 0, 1);
echo '<div align="left" style="float:left"><h4>'.$_course['title'].' - '.$lp_title.' - '.$name.'</h4></div>
<div align="right">

@ -77,7 +77,7 @@ $csv_content = array();
api_block_anonymous_users();
if(empty($_SESSION['is_allowedCreateCourse']) && !api_is_coach()){
if(empty($_SESSION['is_allowedCreateCourse']) && !api_is_coach() && $_user['status']!=DRH){
api_not_allowed(true);
}
@ -169,6 +169,15 @@ if(!empty($_GET['student']))
$student_id = intval($_GET['student']);
// infos about user
$a_infosUser = UserManager::get_user_info_by_id($student_id);
if($_user['status']==DRH && $a_infosUser['drh_id']!=$_user['user_id'])
{
api_not_allowed();
}
$a_infosUser['name'] = $a_infosUser['firstname'].' '.$a_infosUser['lastname'];
echo '<div align="right">
<a href="#" onclick="window.print()"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a>
<a href="'.api_get_self().'?'.$_SERVER['QUERY_STRING'].'&export=csv"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>
@ -191,9 +200,6 @@ if(!empty($_GET['student']))
}
}
// infos about user
$a_infosUser = UserManager::get_user_info_by_id($_GET['student']);
$a_infosUser['name'] = $a_infosUser['firstname'].' '.$a_infosUser['lastname'];
$avg_student_progress = $avg_student_score = $nb_courses = 0;
@ -899,8 +905,7 @@ if(!empty($_GET['student']))
</th>
</tr>
<?php
if(!api_is_platform_admin()){
if(!api_is_platform_admin() && $_user['status']!=DRH){
// courses followed by user where we are coach
if(!isset($_GET['id_coach'])){
$a_courses = Tracking :: get_courses_followed_by_coach($_user['user_id']);

@ -86,7 +86,7 @@ function sort_users($a, $b)
===============================================================================
*/
if($isCoach || api_is_platform_admin())
if($isCoach || api_is_platform_admin() || $_user['status']==DRH)
{
echo '<div align="left" style="float:left"><h4>'.$title.'</h4></div>
@ -103,9 +103,19 @@ if($isCoach || api_is_platform_admin())
}
if(!isset($_GET['id_session'])){
if($isCoach)
{
$a_courses = Tracking :: get_courses_followed_by_coach($coach_id);
$a_students = Tracking :: get_student_followed_by_coach($coach_id);
}
else if($_user['status']==DRH)
{
$a_students = Tracking :: get_student_followed_by_drh($_user['user_id']);
$courses_of_the_platform = CourseManager :: get_real_course_list();
foreach($courses_of_the_platform as $course)
$a_courses[$course['code']] = $course['code'];
}
}
else{
$a_students = Tracking :: get_student_followed_by_coach_in_a_session($_GET['id_session'], $coach_id);
}

Loading…
Cancel
Save