This commit is contained in:
Xes
2025-08-14 22:37:50 +02:00
parent fb6d5d5926
commit 3641e93527
9156 changed files with 1813532 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
<?php
/* For licensing terms, see /license.txt */
require_once '../inc/global.inc.php';
$allow = api_get_configuration_value('extra');
if (empty($allow)) {
exit;
}
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$ex_user_id = isset($_GET['ex_user_id']) ? (int) $_GET['ex_user_id'] : '';
$mod_no = isset($_GET['mod_no']) ? Database::escape_string($_GET['mod_no']) : '';
$score_ex = isset($_GET['score_ex']) ? Database::escape_string($_GET['score_ex']) : '';
$score_rep1 = isset($_GET['score_rep1']) ? Database::escape_string($_GET['score_rep1']) : '';
$score_rep2 = isset($_GET['score_rep2']) ? Database::escape_string($_GET['score_rep2']) : '';
$coment = isset($_GET['coment']) ? Database::escape_string($_GET['coment']) : '';
$sql = "INSERT INTO $table (exe_user_id, c_id, mod_no, score_ex, score_rep1, score_rep2, coment)
VALUES ($ex_user_id, 0, '$mod_no', '$score_ex', '$score_rep1', '$score_rep2', '$coment')";
Database::query($sql);
header("location: myStudents.php?student=$ex_user_id");
exit;

View File

@@ -0,0 +1,21 @@
<?php
/* For licensing terms, see /license.txt */
require_once '../inc/global.inc.php';
$allow = api_get_configuration_value('extra');
if (empty($allow)) {
exit;
}
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$comment = isset($_POST['inter_coment']) ? Database::escape_string($_POST['inter_coment']) : '';
$date = isset($_POST['date']) ? Database::escape_string($_POST['date']) : '';
$level = isset($_POST['level']) ? Database::escape_string($_POST['level']) : '';
$ex_user_id = isset($_POST['ex_user_id']) ? Database::escape_string($_POST['ex_user_id']) : '';
$sql = "INSERT INTO $table (exe_user_id,c_id,level,exe_date,inter_coment)
VALUES ($ex_user_id, 0, '$level', '$date', '$comment')";
Database::query($sql);
header("location: myStudents.php?student=$ex_user_id");
exit;

View File

@@ -0,0 +1,82 @@
<?php
/* For licensing terms, see /license.txt */
// not used??
exit;
require_once '../inc/global.inc.php';
$allow = api_get_configuration_value('extra');
if (empty($allow)) {
exit;
}
$view = $_REQUEST['view'];
Display::display_header($nameTools, "Tracking");
$title = isset($_POST['title']) ? $_POST['title'] : "";
$je = isset($_POST['je']) ? Security::remove_XSS($_POST['je']) : "";
$me = isset($_POST['me']) ? Security::remove_XSS($_POST['me']) : "";
$ye = isset($_POST['ye']) ? Security::remove_XSS($_POST['ye']) : "";
foreach ($_POST as $index => $valeur) {
$$index = Database::escape_string(trim($valeur));
}
$start_time = "$y-$m-$j";
$end_time = "$ye-$me-$je";
// On v<>rifie si les champs sont vides
if (empty($title)) {
echo '<font color="red">Attention, vous avez oubliez le nom du calendrier</font>';
}
?>
<form action="save_school_calendar.php" method="post" name="save_cal">
<table class='table table-hover table-striped data_table'>
<tr>
<th colspan="3">
<?php echo get_lang('edit_save'); ?>
</th>
<tr>
<th><?php echo get_lang('title_calendar'); ?></th>
<th><?php echo get_lang('period'); ?></th>
<th><?php echo get_lang('action'); ?></th>
</tr>
<td>
<input type=texte name=title value=<?php echo "$title"; ?>/>
</td>
<td>
<input SIZE=25 NAME=period
value=<?php echo "$langFrom", ":", "$start_time", "$langTo", "$end_time"; ?>/>
</td>
<?php
$date1 = strtotime($start_time); //Premiere date
$date2 = strtotime($end_time); //Deuxieme date
$nbjour = ($date2 - $date1) / 60 / 60 / 24; //Nombre de jours entre les deux
$nbcol = 2;
echo "<table border='1'><tr>";
if (0 == $i % $nbcol) {
for ($i = 0; $i <= $nbjour; $i++) {
echo "<td><input type='text' NAME='date_case' size='8' value=".date('Y-m-d', $date1)."> ";
$date1 += 60 * 60 * 24; //On additionne d'un jour (en seconde)
echo '<br>';
echo '</td>';
echo "<td><input type='text' NAME='day_number' size='4' value=".$number."/></td>";
echo "<td><input type='text' NAME='d_title' size='4' value=".$title."/></td>";
$sql4 = "INSERT INTO set_module (cal_name,cal_day_num,cal_date)
VALUES ('$title','$number','".date('Y-m-d', $date1)."') ";
Database::query($sql4);
if ($i % $nbcol == ($nbcol - 1)) {
echo "</tr>";
}
}
}
?>
</tr>
<input type="submit" value="Sauvegarder" name="B1">
</table>
</form>
<?php
Display::display_footer();

97
main/extra/database.php Normal file
View File

@@ -0,0 +1,97 @@
<?php
/* For licensing terms, see /license.txt */
require_once '../inc/global.inc.php';
// database changes
exit;
$sql = "ALTER TABLE track_e_exercises ADD COLUMN coment VARCHAR(255);";
Database::query($sql);
$sql = "ALTER TABLE track_e_exercises ADD COLUMN diff VARCHAR(255);";
Database::query($sql);
$sql = "ALTER TABLE track_e_exercises ADD COLUMN mod_no VARCHAR(255);";
Database::query($sql);
$sql = "ALTER TABLE track_e_exercises ADD COLUMN score_ex VARCHAR(255);";
Database::query($sql);
$sql = "ALTER TABLE track_e_exercises ADD COLUMN score_rep1 VARCHAR(255);";
Database::query($sql);
$sql = "ALTER TABLE track_e_exercises ADD COLUMN score_rep2 VARCHAR(255);";
Database::query($sql);
$sql = "ALTER TABLE track_e_exercises ADD COLUMN inter_coment VARCHAR(255);";
Database::query($sql);
$sql = "ALTER TABLE track_e_exercises ADD COLUMN level VARCHAR(255);";
Database::query($sql);
$sql = "CREATE TABLE IF NOT EXISTS set_module (
`id` int(4) NOT NULL AUTO_INCREMENT,
`cours` varchar(40) NOT NULL,
`module` varchar(40) NOT NULL,
`jours` varchar(6) NOT NULL,
`cal_name` varchar(20) NOT NULL,
`cal_day_num` int(6) NOT NULL,
`cal_date` date NOT NULL,
PRIMARY KEY (`id`)
)";
Database::query($sql);
/*$sql = "CREATE TABLE IF NOT EXISTS `kezprerequisites` (
`c_id` int(11) NOT NULL,
`lp_id` int(11) NOT NULL,
`id` int(11) NOT NULL,
`prereq` int(11) DEFAULT NULL,
`disporder` bigint(20) DEFAULT NULL,
PRIMARY KEY (`c_id`,`lp_id`,`id`)
)";*/
$sql = "CREATE TABLE IF NOT EXISTS `c_cal_dates` (
`c_id` int(11) NOT NULL,
`date` date NOT NULL,
`status` varchar(1) NOT NULL,
`horaire_name` varchar(190) DEFAULT NULL,
UNIQUE KEY `temp` (`c_id`,`date`,`horaire_name`),
UNIQUE KEY `indexunique` (`c_id`,`date`,`horaire_name`),
KEY `idx` (`c_id`)
)";
Database::query($sql);
$sql = "CREATE TABLE IF NOT EXISTS `c_cal_horaire` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`c_id` int(11) NOT NULL,
`name` varchar(190) NOT NULL,
`num_minute` int(11) NOT NULL,
`num_hours` int(11) NOT NULL,
`learnpath_dw` varchar(256) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `c_id` (`c_id`,`name`),
KEY `idx` (`c_id`)
)";
Database::query($sql);
$sql = "CREATE TABLE IF NOT EXISTS `c_cal_set_module` (
`id` int(4) NOT NULL AUTO_INCREMENT,
`c_id` varchar(40) NOT NULL,
`module` varchar(40) NOT NULL,
`minutes` int(6) NOT NULL,
PRIMARY KEY (`id`)
)";
Database::query($sql);
$sql = "CREATE TABLE IF NOT EXISTS `c_cal_temp` (
`c_id` int(11) NOT NULL,
`temp` varchar(250) NOT NULL,
`user` varchar(250) NOT NULL,
KEY `idx` (`c_id`)
)";
Database::query($sql);

View File

@@ -0,0 +1,21 @@
<?php
/* For licensing terms, see /license.txt */
require_once '../inc/global.inc.php';
$allow = api_get_configuration_value('extra');
if (empty($allow)) {
exit;
}
api_block_anonymous_users();
$ex_user_id = isset($_GET['student_id']) ? (int) $_GET['student_id'] : 0;
$num = isset($_GET['num']) ? (int) $_GET['num'] : 0;
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$sql = "DELETE FROM $table WHERE exe_id = $num";
Database::query($sql);
header("location: myStudents.php?student=$ex_user_id");
exit;

69
main/extra/edit_exam.php Normal file
View File

@@ -0,0 +1,69 @@
<?php
/* For licensing terms, see /license.txt */
require_once '../inc/global.inc.php';
$allow = api_get_configuration_value('extra');
if (empty($allow)) {
exit;
}
api_block_anonymous_users();
Display::display_header();
$tbl_stats_exercices = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$num = isset($_GET['num']) ? (int) $_GET['num'] : '';
$student_idd = isset($_GET['student_id']) ? (int) $_GET['student_id'] : '';
?>
<form action="update_exam.php" method="post" name="save_exam">
<table class='table table-hover table-striped data_table'>
<tr>
<th colspan="6">
<?php echo get_lang('edit_save'); ?>
</th>
<tr>
<th><?php echo get_lang('module_no'); ?></th>
<th><?php echo get_lang('result_exam'); ?></th>
<th><?php echo get_lang('result_rep_1'); ?></th>
<th><?php echo get_lang('result_rep_2'); ?></th>
<th><?php echo get_lang('comment'); ?></th>
<th><?php echo get_lang('action'); ?></th>
</tr>
<?php
$sqlexam = "SELECT * FROM $tbl_stats_exercices WHERE exe_id = $num";
$resultexam = Database::query($sqlexam);
while ($a_exam = Database::fetch_array($resultexam)) {
$exe_id = $a_exam['exe_id'];
$mod_no = $a_exam['mod_no'];
$score_ex = $a_exam['score_ex'];
$score_rep1 = $a_exam['score_rep1'];
$score_rep2 = $a_exam['score_rep2'];
$coment = $a_exam['coment'];
echo "
<tr>
<td>
<input type=text name=mod_no size=1 value= ".$a_exam['mod_no'].">
</td>
<td>
<input type=text name=score_ex size=1 value=".$a_exam['score_ex'].">
</td>
<td><input type=text name=score_rep1 size=1 value=".$a_exam['score_rep1']."></td>
<td><input type=text name=score_rep2 size=1 value=".$a_exam['score_rep2']."></td>
<td><textarea name=\"coment\" cols=\"65\" rows=\"2\">$coment</textarea><br /></td>
<INPUT type=hidden name=ex_idd value=\"$exe_id\" />
<INPUT type=hidden name=student_id value=\"$student_idd\" />
<td>
<input type=\"submit\" value=\"".get_lang('Save')."\" name=\"B1\">
</td>
</tr>
";
}
?>
</table>
</form>
<?php
Display::display_footer();

View File

@@ -0,0 +1,61 @@
<?php
/* For licensing terms, see /license.txt */
require_once '../inc/global.inc.php';
$allow = api_get_configuration_value('extra');
if (empty($allow)) {
exit;
}
api_block_anonymous_users();
Display::display_header();
$num = isset($_GET['num']) ? (int) $_GET['num'] : 0;
$student_idd = isset($_GET['student_id']) ? (int) $_GET['student_id'] : 0;
$tbl_stats_exercices = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
?>
<form action="update_intervention.php" method="post" name="save_intercention">
<table class='table table-hover table-striped data_table'>
<tr>
<th colspan="4"><?php echo get_lang('Edit'); ?>
<tr>
<th><?php echo get_lang('Level'); ?></th>
<th><?php echo get_lang('Date'); ?></th>
<th><?php echo get_lang('interventions_commentaires'); ?></th>
<th><?php echo get_lang('Action'); ?></th>
</tr>
<?php
$sqlinter = "SELECT * FROM $tbl_stats_exercices WHERE exe_id = $num";
$resultinter = Database::query($sqlinter);
while ($a_inter = Database::fetch_array($resultinter)) {
$level = $a_inter['level'];
$mod_no = $a_inter['mod_no'];
$score_ex = $a_inter['score_ex'];
$inter_coment = stripslashes($a_inter['inter_coment']);
echo "
<tr>
<td> ".$a_inter['level']."
</td>
<td>
".$a_inter['exe_date']."
</td>";
$exe_id = $a_inter['exe_id']; ?>
<td>
<textarea name="inter_coment" cols="65" rows="2">
<?php echo $inter_coment; ?>
</textarea>
</td>
<INPUT type=hidden name=exe_id value= <?php echo "$exe_id"; ?>/>
<INPUT type=hidden name=student_id value= <?php echo "$student_idd"; ?>/>
<td><input type="submit" value="Sauvegarder" name="B1"></td>
</tr>
<?php
}
?>
</table>
</form>
<?php
Display::display_footer();

View File

@@ -0,0 +1,425 @@
<?php
/* For licensing terms, see /license.txt */
require_once '../inc/global.inc.php';
$allow = api_get_configuration_value('extra');
if (empty($allow)) {
exit;
}
$current_course_tool = TOOL_GROUP;
// Notice for unauthorized people.
api_protect_course_script(true);
/* Libraries & config files */
require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
/* MAIN CODE */
$group_id = api_get_group_id();
$user_id = api_get_user_id();
$current_group = GroupManager::get_group_properties($group_id);
// regroup table names for maintenance purpose
if (!api_is_allowed_to_edit(false, true) && !$is_group_member) {
api_not_allowed(true);
}
$tbl_stats_exercices_temp = Database::get_main_table(track_e_exercices_temp);
//on vide la table temp qui recoit les examen complétés
$query = "TRUNCATE TABLE $tbl_stats_exercices_temp ";
$result = Database::query($query);
if (empty($current_group)) {
api_not_allowed(true);
}
$this_section = SECTION_COURSES;
$nameTools = get_lang('suivi_de');
$interbreadcrumb[] = ['url' => 'group.php', 'name' => get_lang('Groups')];
$forums_of_groups = get_forums_of_group($current_group['id']);
$forum_state_public = 0;
if (is_array($forums_of_groups)) {
foreach ($forums_of_groups as $key => $value) {
if ('public' == $value['forum_group_public_private']) {
$forum_state_public = 1;
}
}
}
if (1 != $current_group['doc_state'] &&
1 != $current_group['calendar_state'] &&
1 != $current_group['work_state'] &&
1 != $current_group['announcements_state'] &&
1 != $current_group['wiki_state'] &&
1 != $current_group['chat_state'] &&
1 != $forum_state_public
) {
if (!api_is_allowed_to_edit(null, true) &&
!GroupManager::is_user_in_group($user_id, $group_id)) {
api_not_allowed($print_headers);
}
}
/* Header */
Display::display_header($nameTools.' '.Security::remove_XSS($current_group['name']), 'Group');
Display::display_introduction_section(TOOL_GROUP);
$course_code = api_get_course_id();
$is_course_member = CourseManager::is_user_subscribed_in_real_or_linked_course(
api_get_user_id(),
$course_code
);
/*
* List all the tutors of the current group
*/
$tutors = GroupManager::get_subscribed_tutors($current_group['id']);
$tutor_info = '';
if (count($tutors) == 0) {
$tutor_info = get_lang('GroupNoneMasc');
} else {
isset($origin) ? $my_origin = $origin : $my_origin = '';
$tutor_info .= '<ul class="thumbnails">';
foreach ($tutors as $index => $tutor) {
$tab_user_info = api_get_user_info($tutor['user_id']);
$username = api_htmlentities(sprintf(get_lang('LoginX'), $tab_user_info['username']), ENT_QUOTES);
$image_path = UserManager::get_user_picture_path_by_id($tutor['user_id'], 'web', false, true);
$image_repository = $image_path['dir'];
$existing_image = $image_path['file'];
$completeName = api_get_person_name($tutor['firstname'], $tutor['lastname']);
$photo = '<img src="'.$image_repository.$existing_image.'" alt="'.$completeName.'" width="32" height="32" title="'.$completeName.'" />';
$tutor_info .= '<li><a href="'.api_get_path(
WEB_CODE_PATH
).'user/userInfo.php?origin='.$my_origin.'&amp;uInfo='.$tutor['user_id'].'">'.
$photo.'&nbsp;'.$completeName.'</a></li>';
}
$tutor_info .= '</ul>';
}
echo Display::page_subheader(get_lang('GroupTutors'));
if (!empty($tutor_info)) {
echo $tutor_info;
}
/*
* List all the members of the current group
*/
echo '<div class="actions">';
$now = date('Y-m-d');
echo '&nbsp;Le '.$now.' <a href="#" onclick="window.print()"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang(
'Print'
).'</a>';
echo '&nbsp; <a target="_blank" href="save_diff_all.php"><img src="'.api_get_path(
WEB_IMG_PATH
).'addd.gif" border="0" />'.get_lang('save_diff_all').'</a>';
echo '</div>';
$table = new SortableTable(
'group_users',
'get_number_of_group_users',
'get_group_user_data',
(api_is_western_name_order() xor api_sort_by_first_name()) ? 2 : 1
);
//$table -> display();
$my_cidreq = isset($_GET['cidReq']) ? Security::remove_XSS($_GET['cidReq']) : '';
$my_origin = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : '';
$my_gidreq = isset($_GET['gidReq']) ? Security::remove_XSS($_GET['gidReq']) : '';
$parameters = ['cidReq' => $my_cidreq, 'origin' => $my_origin, 'gidReq' => $my_gidreq];
$table->set_additional_parameters($parameters);
$table->set_header(1, get_lang('OfficialCode'), false, 'align="center"');
if (api_is_western_name_order()) {
$table->set_header(2, get_lang('LastName'));
$table->set_header(3, get_lang('FirstName'));
} else {
$table->set_header(2, get_lang('LastName'));
$table->set_header(3, get_lang('FirstName'));
}
//the order of these calls is important
$table->set_column_filter(2, 'user_name_filter');
$table->set_column_filter(3, 'user_name_filter');
$table->set_header(4, get_lang('Examen'), false);
//the order of these calls is important
$table->set_column_filter(2, 'user_name_filter');
$table->set_column_filter(3, 'user_name_filter');
$table->set_header(4, get_lang('Examen'), false);
$table->set_header(5, get_lang('LatestLogin'), false, 'align="center"');
$table->set_header(6, get_lang('time_tot'), false, 'align="center"');
$table->set_header(7, get_lang('jours_complet'), false, 'align="center"');
$table->set_header(8, get_lang('diff_horaire'), false, 'align="center"');
$table->set_header(9, get_lang('save_diff'), false, 'align="center"');
$table->set_header(10, get_lang('GroupCalendar'), false, 'align="center"');
$table->set_header(11, get_lang('Details'), false);
// Database table definition
$table_group_user = Database::get_course_table(TABLE_GROUP_USER);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
// $tbl_personal_agenda = Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA);
$tbl_personal_agenda = Database::get_main_table(TABLE_PERSONAL_AGENDA);
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_stats_exercices = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$tbl_stats_exercices_temp = Database::get_main_table(track_e_exercices_temp);
$tbl_group_course_info = Database::get_course_table(TABLE_GROUP);
$course_id = api_get_course_int_id();
//on trouve le vrai groupID
$sql = "SELECT iid FROM ".$tbl_group_course_info."
WHERE c_id=".$course_id." and id=".$current_group['id'];
$current_group_result = Database::query($sql);
$current_group = Database::fetch_assoc($current_group_result)['iid'];
//on trouve les user dans le groupe
$sql = "SELECT *
FROM ".$table_user." user, ".$table_group_user." group_rel_user
WHERE group_rel_user.c_id = $course_id AND group_rel_user.user_id = user.user_id
AND group_rel_user.group_id = ".$current_group." order by lastname
";
$result = Database::query($sql);
// Francois Belisle Kezber
// Le TableDisplay contient une fonction qui set les headers... les headers sont plac<61>s dans la Row 0... Ce qui ecrase le contenue
// le la vrai row 0... Il faut donc ajouter un empty record a la row 0 qui se fera ecras<61> par lesh headers plutot que le premier record
// en ajoutant un empty record, ca fonctionne, mais il faut trouver pourquoi les headers ecrasent le premier record
$row = [];
$row[] = $student_datas['official_code'];
$row[] = $student_datas['lastname'];
$row[] = $student_datas['firstname'];
$row[] = substr_replace($exampass, '', '0', '2');
$row[] = $last_connection_date;
$row[] = $time_tot;
$row[] = $Total;
$row[] = '<center>'.$sing.''.$diff.'&nbsp;'.$Days.''.$avertissement.'</font></b></center>';
$row[] = '<center><a target="_blank" href="save_diff.php?student='.$user_in_groupe.'&diff='.$ajout.''.$diff.'"><img src="'.api_get_path(
WEB_IMG_PATH
).'addd.gif" border="0" /></a></center>';
$row[] = '<center><a target="_blank" href="suivi_myagenda.php?user_id='.$user_in_groupe.'&action=view&view=personal&firstname='.$student_datas['firstname'].'&name='.$student_datas['lastname'].'"><img src="'.api_get_path(
WEB_IMG_PATH
).'calendar_week.gif" border="0" /></a></center>';
$row[] = '<center><a target="_blank" href="../mySpace/myStudents.php?student='.$user_in_groupe.'"><img src="'.api_get_path(
WEB_IMG_PATH
).'2rightarrow.gif" border="0" /></a></center>';
$all_datas[] = $row;
foreach ($all_datas as $row) {
$table->addRow($row);
}
while ($resulta = Database::fetch_array($result)) {
$user_in_groupe = $resulta['user_id'];
unset($all_datas);
//on cherche les examens
$sqlexam = "SELECT mod_no
FROM $tbl_stats_exercices
WHERE exe_user_id = '$user_in_groupe'
AND c_id = 0 AND (score_ex = 'SU' || score_rep1 = 'SU' || score_rep2 ='SU')
ORDER BY mod_no ASC";
$resultexam = Database::query($sqlexam);
while ($a_exam = Database::fetch_array($resultexam)) {
$exam = "$exam - $a_exam[0]";
}
Database::query(
"INSERT INTO $tbl_stats_exercices_temp (id, exe_user_id, mod_passed) VALUES('', '$user_in_groupe', '$exam') "
);
//fin de exam
//on compte le nombre de m% dans l'agenda pour chaque module
/*
$sqljtot = "SELECT COUNT( * ) AS TOT
FROM $tbl_personal_agenda
WHERE user = '$user_in_groupe'
And title like 'm%'
";
$resultjt = Database::query($sqljtot);
while($jtot = mysql_fetch_array($resultjt))
{
$jour_realise_tot = ($jour_realise + $jtot['TOT'])/ 2;
}
//fin des jour de l'agenda
*/
$course_code = $_course['id'];
$student_datas = api_get_user_info($user_in_groupe);
// affichage des jours complétés dans les parcours par chaque élève
//on recherche les cours où sont inscrit les user
$sql2 = "SELECT c_id, user_id
FROM course_rel_user
WHERE user_id = '$user_in_groupe'
";
$result2 = Database::query($sql2);
$Total = 0;
while ($a_courses = Database::fetch_array($result2)) {
$Courses_code = $a_courses['c_id'];
$Courses_rel_user_id = $a_courses['user_id'];
//on sort le temps passé dans chaque cours
$sql = "SELECT SUM(UNIX_TIMESTAMP(logout_course_date) - UNIX_TIMESTAMP(login_course_date)) as nb_seconds
FROM track_e_course_access
WHERE UNIX_TIMESTAMP(logout_course_date) > UNIX_TIMESTAMP(login_course_date) AND c_id = $course_id AND user_id = '$user_in_groupe'
";
//echo($sql);
$rs = Database::query($sql);
$row2 = Database::fetch_array($rs);
$nb_secondes = $row2['nb_seconds'];
$time_tot1 += $nb_secondes;
//convertion secondes en temps
$time_tot = api_time_to_hms($time_tot1);
//on sort le c_id avec le code du cours
//$sql8 = "SELECT *
// FROM course
// WHERE id = '$Courses_code'
// ";
// $result8 = Database::query($sql8);
// $course_code_id = Database::fetch_array($result8) ;
$c_id = $Courses_code;
//pours chaque cours dans lequel il est inscrit, on cherche les jours complétés
$Req3 = "SELECT *
FROM c_lp_view
WHERE user_id = '$Courses_rel_user_id'
AND c_id = '$c_id'
";
$res3 = Database::query($Req3);
while ($result3 = Database::fetch_array($res3)) {
$lp_id = $result3['lp_id'];
$lp_id_view = $result3['id'];
$c_id_view = $result3['c_id'];
$Req4 = "SELECT id, lp_id ,title ,item_type
FROM c_lp_item
WHERE lp_id = '$lp_id'
AND title LIKE '(+)%'
AND c_id = '$c_id_view'
AND item_type = 'document'
";
$res4 = Database::query($Req4);
while ($resulta4 = Database::fetch_array($res4)) {
$lp_item_id = $resulta4['id'];
$Req5 = " SELECT Max(id)
FROM c_lp_item_view
WHERE lp_item_id = '$lp_item_id'
AND lp_view_id = '$lp_id_view'
AND c_id = '$c_id_view'
AND status = 'completed'
";
$res5 = Database::query($Req5);
while ($resul5 = Database::fetch_array($res5)) {
$max = $resul5['0'];
$Req6 = "SELECT COUNT( id )
FROM c_lp_item_view
WHERE id = '$max'
AND c_id = '$c_id_view'
";
$res6 = Database::query($Req6);
while ($resultat6 = Database::fetch_array($res6)) {
$Total = $Total + $resultat6[0];
}
}
}
}
}
// fin affichage des jours complétés dans les parcours par chaque élève
// on recherche les exam sauvegardé dans la table temp
$sqlexamtot = "SELECT mod_passed
FROM $tbl_stats_exercices_temp
WHERE exe_user_id = '$user_in_groupe'";
$resultexamtot = Database::query($sqlexamtot);
$a_examtot = Database::fetch_array($resultexamtot);
$exampass = $a_examtot['mod_passed'];
//on trouve le nombre dans l'agenda selon la date d'aujourdhui
//si rien n'est inscrit cette journée dans l'agenda, recule de -1
unset($jour_agenda);
$tour = -1;
while ($jour_agenda == '') {
$tour++;
$date = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - $tour, date("Y")));
$sql4 = "SELECT * FROM $tbl_personal_agenda
WHERE user = '$user_in_groupe' AND
text='Pour le calendrier, ne pas effacer'
AND date like '".$date." %:%'
";
$result4 = Database::query($sql4);
$res4 = Database::fetch_array($result4);
$jour_agenda = $res4['title'];
if ($tour > 300) {
break;
}
}
//on affiche la différence
$diff = $jour_agenda - $Total;
if ($diff > 0) {
$sing = '<b><font color=#CC0000>';
} else {
$sing = '<b><font color=#008000>';
}
if ($diff > 0) {
$avertissement = get_lang('retard');
} else {
$avertissement = get_lang('avance');
}
if ($diff > 0) {
$ajout = '-';
} else {
$ajout = '';
}
$diff = abs($diff);
$last_connection_date = Tracking::get_last_connection_date($user_in_groupe, true);
if ($last_connection_date == '') {
$last_connection_date = get_lang('NoConnexion');
}
// on présente tous les résultats
$row = [];
$row[] = $student_datas['official_code'];
$row[] = $student_datas['lastname'];
$row[] = $student_datas['firstname'];
$row[] = substr_replace($exampass, '', '0', '2');
$row[] = $last_connection_date;
$row[] = $time_tot;
$row[] = $Total;
$row[] = '<center>'.$sing.''.$diff.'&nbsp;'.$Days.''.$avertissement.'</font></b></center>';
$row[] = '<center><a target="_blank" href="save_diff.php?student='.$user_in_groupe.'&diff='.$ajout.''.$diff.'"><img src="'.api_get_path(
WEB_IMG_PATH
).'addd.gif" border="0" /></a></center>';
$row[] = '<center><a target="_blank" href="suivi_myagenda.php?user_id='.$user_in_groupe.'&action=view&view=personal&firstname='.$student_datas['firstname'].'&name='.$student_datas['lastname'].'"><img src="'.api_get_path(
WEB_IMG_PATH
).'calendar_week.gif" border="0" /></a></center>';
$row[] = '<center><a target="_blank" href="../mySpace/myStudents.php?student='.$user_in_groupe.'"><img src="'.api_get_path(
WEB_IMG_PATH
).'2rightarrow.gif" border="0" /></a></center>';
$all_datas[] = $row;
foreach ($all_datas as $row) {
$table->addRow($row);
}
}
$table->display();
echo $precision_time;
/**
* Return user profile link around the given user name.
*
* The parameters use a trick of the sorteable table, where the first param is
* the original value of the column
*
* @param string User name (value of the column at the time of calling)
* @param string URL parameters
* @param array Row of the "sortable table" as it is at the time of function call - we extract the user ID from
* there
*
* @return string HTML link
*/
function user_name_filter($name, $url_params, $row)
{
$tab_user_info = api_get_user_info($row[0]);
$username = api_htmlentities(sprintf(get_lang('LoginX'), $tab_user_info['username']), ENT_QUOTES);
return '<a href="../user/userInfo.php?uInfo='.$row[0].'&amp;'.$url_params.'" title="'.$username.'">'.$name.'</a>';
}
// Footer
$orig = isset($origin) ? $origin : '';
if ('learnpath' != $orig) {
Display::display_footer();
}

2624
main/extra/myStudents.php Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,514 @@
<?php
/* For licensing terms, see /license.txt */
require_once '../inc/global.inc.php';
$allow = api_get_configuration_value('extra');
if (empty($allow)) {
exit;
}
api_block_anonymous_users();
$nameTools = get_lang('MyProgress');
$this_section = 'session_my_progress_ind';
$_user = api_get_user_info();
$tbl_stats_exercices = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$tbl_stats_access = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
Display::display_header($nameTools);
$result = Database::query(
"SELECT DISTINCT session.id as id, name, access_start_date date_start, access_end_date date_end
FROM session_rel_course_rel_user,session
WHERE session_id=session.id AND user_id=".$_user['user_id']."
ORDER BY date_start, date_end, name");
$Sessions = Database::store_result($result);
$Courses = [];
foreach ($Sessions as $enreg) {
$id_session_temp = $enreg['id'];
$sql8 = "SELECT *
FROM course
WHERE code = '$courses_code'
";
$result8 = Database::query($sql8);
$course_code_id = Database::fetch_array($result8);
$c_id = $course_code_id['id'];
$sql = "SELECT DISTINCT c_id,title, CONCAT(lastname, ' ',firstname) coach, username, date_start, date_end, db_name
FROM $tbl_course , $tbl_session_course
LEFT JOIN $tbl_user
ON $tbl_session_course.id_coach = $tbl_user.user_id
INNER JOIN $tbl_session_course_user
ON $tbl_session_course_user.id_session = $tbl_session_course.id_session
AND $tbl_session_course_user.id_user = '".$_user['user_id']."'
INNER JOIN $tbl_session ON $tbl_session.id = $tbl_session_course.id_session
WHERE $tbl_session_course.c_id=$c_id
AND $tbl_session_course.id_session='$id_session_temp'
ORDER BY title";
$result = Database::query($sql);
while ($a_session_courses = Database::fetch_array($result)) {
$a_session_courses['id_session'] = $id_session_temp;
$Courses[$a_session_courses['code']] = $a_session_courses;
}
}
// affichage des jours complétés dans les parcours l'élève
//on recherche les cours où sont inscrit les user
$user_c_id = $_user['user_id'];
$sql2 = "SELECT c_id, user_id
FROM course_rel_user
WHERE user_id = '$user_c_id'
";
$result2 = Database::query($sql2);
$Total = 0;
while ($a_courses = Database::fetch_array($result2)) {
$courses_code = $a_courses['c_id'];
//on sort le c_id avec le code du cours
//$sql8 = "SELECT *
// FROM course
// WHERE code = '$courses_code'
// ";
// $result8 = Database::query($sql8);
// $course_code_id = Database::fetch_array($result8) ;
$c_id = $courses_code;
//pours chaque cours dans lequel il est inscrit, on cherche les jours complétés
$Req1 = "SELECT *
FROM c_lp_view
WHERE user_id = '$user_c_id' AND c_id = '$c_id'
";
$res = Database::query($Req1);
while ($result = Database::fetch_array($res)) {
$lp_id = $result['lp_id'];
$lp_id_view = $result['id'];
$c_id_view = $result['c_id'];
$Req2 = "SELECT id, lp_id ,title ,item_type
FROM c_lp_item
WHERE lp_id = '$lp_id'
AND title LIKE '(+)%'
AND c_id = '$c_id_view'
AND item_type = 'document'
";
$res2 = Database::query($Req2);
while ($resulta = Database::fetch_array($res2)) {
$lp_item_id = $resulta['id'];
$Req3 = " SELECT Max(id)
FROM c_lp_item_view
WHERE
lp_item_id = '$lp_item_id' AND
lp_view_id = '$lp_id_view' AND
c_id = '$c_id_view' AND
status = 'completed'
";
$res3 = Database::query($Req3);
while ($resul = Database::fetch_array($res3)) {
$max = $resul['0'];
$Req4 = "SELECT COUNT( id )
FROM c_lp_item_view
WHERE
id = '$max' AND
c_id = '$c_id_view'
";
$res4 = Database::query($Req4);
while ($resultat = Database::fetch_array($res4)) {
if ($resultat[0] == null) {
$resultat[0] = 0;
}
$Total = $Total + $resultat[0];
}
}
}
}
}
api_display_tool_title($nameTools);
$now = date('Y-m-d');
$tbl_personal_agenda = Database::get_main_table(TABLE_PERSONAL_AGENDA);
//on compte le nombre de m% dans l'agenda pour chaque module
$sqljtot = "SELECT COUNT( * ) AS TOT
FROM $tbl_personal_agenda
WHERE user = '".$_user['user_id']."'
And title like 'm%'
";
$resultjt = Database::query($sqljtot);
$jour_realise = 0;
while ($jtot = Database::fetch_array($resultjt)) {
$jour_realise_tot = ($jour_realise + $jtot['TOT']) / 2;
}
//fin des jour de l'agenda
//on trouve le nombre dans l'agenda selon la date d'aujourdhui
//si rien n'est inscrit cette journée dans l'agenda, recule de -1
$jour_agenda = '';
$tour = -1;
while ($jour_agenda == '') {
$tour++;
$date = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - $tour, date("Y")));
$sql4 = "SELECT title FROM $tbl_personal_agenda
WHERE user = '".$_user['user_id']."' AND
text='Pour le calendrier, ne pas effacer' AND
date like '".$date." %:%' ";
$result4 = Database::query($sql4);
$res4 = Database::fetch_array($result4);
$jour_agenda = $res4['title'];
if ($tour > 300) {
break;
}
}
$diff = $jour_agenda - $Total;
if ($diff > 0) {
$sing = get_lang('retard');
} else {
$sing = get_lang('avance');
}
$diff = abs($diff);
?>
<table class="table table-hover table-striped data_table">
<th rowspan="5">
<?php
//on récupere les points de controle de l'élève
$pt[] = '0';
$pt[] = '0';
$sqlcontrole = "SELECT diff
FROM $tbl_stats_exercices
WHERE exe_user_id = ".$_user['user_id']."
AND diff != ''
ORDER BY exe_date ASC
";
$result = Database::query($sqlcontrole);
while ($ptctl = Database::fetch_array($result)) {
$pt[] = $ptctl['diff'];
}
//graphique de suivi
/*include "../inc/teechartphp/sources/TChart.php";
$chart = new TChart(500, 300);
$chart->getAspect()->setView3D(false);
$chart->getHeader()->setText("Graphique de suivi");
$chart->getAxes()->getLeft()->setMinimumOffset(10);
$chart->getAxes()->getLeft()->setMaximumOffset(10);
$chart->getAxes()->getBottom()->setMinimumOffset(10);
$chart->getAxes()->getBottom()->setMaximumOffset(10);
$line1 = new Line($chart->getChart());
$data = $pt;
$line1->addArray($data);
foreach ($chart->getSeries() as $serie) {
$pointer = $serie->getPointer();
$pointer->setVisible(true);
$pointer->getPen()->setVisible(false);
$pointer->setHorizSize(2);
$pointer->setVertSize(2);
$marks = $serie->getMarks();
$marks->setVisible(true);
$marks->setArrowLength(5);
$marks->getArrow()->setVisible(false);
$marks->setTransparent(true);
}
$x = $_user['user_id'];
$line1->getPointer()->setStyle(PointerStyle::$CIRCLE);
$chart->getLegend()->setVisible(false);
$chart->render("../garbage/$x-image.png");
$rand = rand();
print '<img src="../garbage/'.$x.'-image.png?rand='.$rand.'">';
*/
?>
<tr>
<th align="left" width="412">
<?php echo get_lang('Cumulatif_agenda'); ?>:
<b><font color=#CC0000> <?php echo $jour_realise_tot; ?></font></b>
</th>
</tr>
<tr>
<th align="left">
<?php echo get_lang('Cumulatif'); ?> <b><font color=#CC0000> <?php echo $Total; ?></font></b>
</th>
</tr>
<tr>
<th align="left">
<?php echo get_lang('jours_selon_horaire'); ?>:
<b><font color=#CC0000> <?php echo $jour_agenda; ?><?php echo $Days; ?></font></b>
</th>
</tr>
<tr>
<th align="left">
<?php echo get_lang('diff2'); ?>:
<b><font color=#CC0000> <?php echo $diff; ?><?php echo $Days, $sing; ?></font></b>
</th>
</tr>
</table>
<hr>
<table class='table table-hover table-striped data_table'>
<tr>
<th><?php echo get_lang('level'); ?> </th>
<th>
<?php echo get_lang('lang_date'); ?>
</th>
<th>
<?php echo get_lang('interventions_commentaires'); ?>
</th>
</tr>
<?php
$sqlinter = "SELECT *
FROM $tbl_stats_exercices
WHERE exe_user_id = ".$_user['user_id']."
And level != 0
Order by LEVEL ASC";
$resultinter = Database::query($sqlinter);
$level = '';
while ($a_inter = Database::fetch_array($resultinter)) {
$level = $a_inter['level'];
$mod_no = $a_inter['mod_no'];
$inter_coment = Security::remove_XSS($a_inter['inter_coment']);
$inter_date = substr($a_inter['exe_date'], 0, 11);
echo "
<tr>
<td> ".$a_inter['level']."</td>
<td> $inter_date </td>
<td>$inter_coment</td>";
$exe_id = $a_inter['exe_id'];
}
if ($level == 3) {
echo '<span style="color: red; font-weight: bold;"><img src="../img/anim/pointeranim.gif"align="middle" > ';
echo $limit;
echo '</span>';
}
?>
<p>
</table><br>
<?php
//début de fin des cours prevu
$user_info = api_get_user_info();
$user_id = api_get_user_id();
//On cherche le calendrier pour ce user et le c_id de ce calendrier
$sql = "SELECT *
FROM user
WHERE user_id = '$user_id'
";
$result = Database::query($sql);
$horaire_id = Database::fetch_array($result);
$nom_hor = $horaire_id['official_code'];
$c_id_horaire = strstr($nom_hor, '.');
$c_id_horaire = str_replace(".", "", "$c_id_horaire");
// Courses
echo '<h3>'.get_lang('Course').'</h3>';
echo '<table class="table table-hover table-striped data_table">';
echo '<tr>
<th>'.get_lang('Course').'</th>
<th>'.get_lang('Time').'</th>
<th>'.get_lang('FirstConnexion').'</th>
<th>'.get_lang('Progress').'</th>
<th>'.get_lang('fin_mod_prevue').'</th>
</tr>';
//on recherche les cours où sont inscrit les user
$user_c_id = $_user['user_id'];
$sql2 = "SELECT c_id, user_id
FROM course_rel_user
WHERE user_id = '$user_id'";
$result2 = Database::query($sql2);
while ($a_courses = Database::fetch_array($result2)) {
$courses_code = $a_courses['c_id'];
//on sort le c_id avec le code du cours
$sql8 = "SELECT title, code
FROM course
WHERE id = '$courses_code'";
$result8 = Database::query($sql8);
$course_code_id = Database::fetch_array($result8);
$c_id = $courses_code;
$c_title = $course_code_id['title'];
// Francois Belisle Kezber
// The Tracking Class still uses the course code rather then the course id.
$tracking_c_code = $course_code_id['code'];
// time spent on the course
$time_spent_on_course = api_time_to_hms(Tracking::get_time_spent_on_the_course($user_id, $c_id, $session_id));
// firts connection date
$sql2 = "SELECT STR_TO_DATE(access_date,'%Y-%m-%d')
FROM $tbl_stats_access
WHERE
access_user_id = '$user_id' AND
c_id = '$c_id'
ORDER BY access_id ASC
LIMIT 0,1";
//Francois Belisle Kezber
// mysql fonctions rather then Database::
// conversion to Database::
$rs2 = Database::query($sql2);
$num_rows = Database::num_rows($rs2);
if ($num_rows > 0) {
$rw2 = Database::fetch_array($rs2);
$first_connection_date_to_module = $rw2[0];
}
//pour trouver la date de fin prévue du module
$end_date_module = get_lang('hors_cal');
//on trouve le nombre de jour pour ce module
$sql = "SELECT * FROM c_cal_set_module
where c_id = '$c_id'";
$res = Database::query($sql);
$resulta = Database::fetch_array($res);
$nombre_heure = $resulta['minutes'];
// on trouve le nombre de minute par jour
$sql = "SELECT * FROM c_cal_horaire
where c_id = '$c_id_horaire'
AND name = '$nom_hor'
";
$res = Database::query($sql);
$resulta = Database::fetch_array($res);
$nombre_minutes = (int) $resulta['num_minute'];
//on calcule le nombre de jour par module
$nombre_jours_module = 0;
if (!empty($nombre_minutes)) {
$nombre_jours_module = $nombre_heure * '60' / $nombre_minutes;
}
//on arrondi
$nombre_jours_module = (int) $nombre_jours_module;
//on trouve la date de fin de chaque module AND date = date_format('$first_connection_date_to_module','%Y-%m-%d')
$sql = "SELECT * FROM c_cal_dates
WHERE
horaire_name = '$nom_hor' AND
c_id = '$c_id_horaire' AND
STR_TO_DATE(date,'%Y-%m-%d') >= STR_TO_DATE('$first_connection_date_to_module','%Y-%m-%d')
ORDER BY STR_TO_DATE(date, '%Y-%m-%d') asc
LIMIT $nombre_jours_module, 18446744073709551615
";
$res = Database::query($sql);
//Database::data_seek($res,$nombre_jours_module);
$row = Database::fetch_row($res);
$end_date_module = $row[1];
//fin de trouver la date de fin prévue du module
//progression en %
$t_lp = Database::get_course_table(TABLE_LP_MAIN);
$sql_lp = " SELECT lp.name, lp.id FROM $t_lp lp WHERE c_id = '$c_id' ORDER BY lp.display_order";
$rs_lp = Database::query($sql_lp);
$i = 0;
while ($learnpath = Database::fetch_array($rs_lp)) {
$lp_id = intval($learnpath['id']);
$lp_name = $learnpath['name'];
$any_result = false;
// Get progress in lp
// Francois Belisle Kezber
// Course Code passed rather then course_id
$progress = Tracking::get_avg_student_progress(
$user_c_id, /*$c_id*/
$tracking_c_code,
[$lp_id],
$session_id
);
if ($progress === null) {
$progress = '0%';
} else {
$any_result = true;
}
// Get time in lp
// Francois Belisle Kezber
// Course Code passed rather then course_id
$total_time = Tracking::get_time_spent_in_lp(
$user_c_id, /*$c_id*/
$tracking_c_code,
[$lp_id],
$session_id
);
if (!empty($total_time)) {
$any_result = true;
}
if ($i % 2 == 0) {
$css_class = "row_even";
} else {
$css_class = "row_odd";
}
$i++;
if (is_numeric($progress)) {
$progress = $progress.'%';
} else {
$progress = '-';
}
$data_learnpath[/*$i*/
$lp_id][] = $progress.'%';
}
$warming = '';
$today = date('Y-m-d');
if (isset($end_date_module) && $end_date_module <= $today and $progress != '100%') {
$warming = '<b><font color=#CC0000> '.get_lang('limite_atteinte').'</font></b>';
}
$end_date_module = $end_date_module.$warming;
echo '<tr>
<td >'.$c_title.'</td>
<td >'.$time_spent_on_course.'</td>
<td >'.$first_connection_date_to_module.'</td>
<td >'.$progress.'</td>
<td >'.$end_date_module.'</td>';
echo '</tr>';
}
echo '</table>';
?> </table>
<br/><br/>
<table class='table table-hover table-striped data_table'>
<tr>
<th colspan="6">
<?php
echo get_lang('result_exam');
//echo $_user['name'];
?>
</th>
<tr>
<th><?php echo get_lang('module'); ?></th>
<th><?php echo get_lang('result_exam'); ?></th>
<th><?php echo get_lang('result_rep_1'); ?></th>
<th><?php echo get_lang('result_rep_2'); ?></th>
<th><?php echo get_lang('comment'); ?></th>
</tr>
<?php
$sqlexam = "SELECT *
FROM $tbl_stats_exercices
WHERE exe_user_id = '".$_user['user_id']."'
AND c_id = '0' AND mod_no != '0'
ORDER BY mod_no ASC";
$resultexam = Database::query($sqlexam);
while ($a_exam = Database::fetch_array($resultexam)) {
$ex_id = $a_exam['ex_id'];
$mod_no = $a_exam['mod_no'];
$score_ex = $a_exam['score_ex'];
$score_rep1 = $a_exam['score_rep1'];
$score_rep2 = $a_exam['score_rep2'];
$coment = stripslashes($a_exam['coment']);
echo "
<tr>
<td><center> ".$a_exam['mod_no']."
</td>
<td><center>
".$a_exam['score_ex']."
</td>
<td><center>
".$a_exam['score_rep1']."
</td><center>
<td><center>
".$a_exam['score_rep2']."
</td>
<td>$coment
";
$exe_idd = $a_exam['exe_id']; ?>
</tr>
<?php
}
?>
</table>
<?php
Display::display_footer();

View File

@@ -0,0 +1,222 @@
<?php
/* For licensing terms, see /license.txt */
require_once '../inc/global.inc.php';
$allow = api_get_configuration_value('extra');
if (empty($allow)) {
exit;
}
$from_myspace = false;
if (isset($_GET['from']) && $_GET['from'] == 'myspace') {
$from_myspace = true;
$this_section = SECTION_TRACKING;
} else {
$this_section = SECTION_COURSES;
}
//$nameTools = get_lang('StudentDetails');
$cidReset = true;
$get_course_code = Security::remove_XSS($_GET['course']);
if (isset($_GET['details'])) {
if (!empty($_GET['origin']) && $_GET['origin'] == 'user_course') {
$course_info = CourseManager::get_course_information($get_course_code);
if (empty($cidReq)) {
$interbreadcrumb[] = [
"url" => api_get_path(WEB_COURSE_PATH).$course_info['directory'],
'name' => $course_info['title'],
];
}
$interbreadcrumb[] = [
"url" => "../user/user.php?cidReq=".$get_course_code,
"name" => get_lang("Users"),
];
} else {
if (!empty($_GET['origin']) && $_GET['origin'] == 'tracking_course') {
$course_info = CourseManager::get_course_information($get_course_code);
if (empty($cidReq)) {
//$interbreadcrumb[] = array ("url" => api_get_path(WEB_COURSE_PATH).$course_info['directory'], 'name' => $course_info['title']);
}
$interbreadcrumb[] = [
"url" => "../tracking/courseLog.php?cidReq=".$get_course_code.'&studentlist=true&id_session='.(empty($_SESSION['id_session']) ? '' : $_SESSION['id_session']),
"name" => get_lang("Tracking"),
];
} else {
if (!empty($_GET['origin']) && $_GET['origin'] == 'resume_session') {
$interbreadcrumb[] = [
'url' => '../admin/index.php',
"name" => get_lang('PlatformAdmin'),
];
$interbreadcrumb[] = [
'url' => "../admin/session_list.php",
"name" => get_lang('SessionList'),
];
$interbreadcrumb[] = [
'url' => "../admin/resume_session.php?id_session=".Security::remove_XSS($_GET['id_session']),
"name" => get_lang('SessionOverview'),
];
} else {
$interbreadcrumb[] = [
"url" => "index.php",
"name" => get_lang('MySpace'),
];
if (isset($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
$interbreadcrumb[] = [
"url" => "student.php?id_coach=".Security::remove_XSS($_GET['id_coach']),
"name" => get_lang("CoachStudents"),
];
$interbreadcrumb[] = [
"url" => "myStudents.php?student=".Security::remove_XSS(
$_GET['student']
).'&id_coach='.Security::remove_XSS($_GET['id_coach']),
"name" => get_lang("StudentDetails"),
];
} else {
$interbreadcrumb[] = [
"url" => "student.php",
"name" => get_lang("MyStudents"),
];
$interbreadcrumb[] = [
"url" => "myStudents.php?student=".Security::remove_XSS($_GET['student']),
"name" => get_lang("StudentDetails"),
];
}
}
}
}
$nameTools = get_lang("DetailsStudentInCourse");
} else {
if (!empty($_GET['origin']) && $_GET['origin'] == 'resume_session') {
$interbreadcrumb[] = [
'url' => '../admin/index.php',
"name" => get_lang('PlatformAdmin'),
];
$interbreadcrumb[] = [
'url' => "../admin/session_list.php",
"name" => get_lang('SessionList'),
];
$interbreadcrumb[] = [
'url' => "../admin/resume_session.php?id_session=".Security::remove_XSS($_GET['id_session']),
"name" => get_lang('SessionOverview'),
];
} else {
$interbreadcrumb[] = [
"url" => "index.php",
"name" => get_lang('MySpace'),
];
if (isset($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
if (isset($_GET['id_session']) && intval($_GET['id_session']) != 0) {
$interbreadcrumb[] = [
"url" => "student.php?id_coach=".Security::remove_XSS(
$_GET['id_coach']
)."&id_session=".$_GET['id_session'],
"name" => get_lang("CoachStudents"),
];
} else {
$interbreadcrumb[] = [
"url" => "student.php?id_coach=".Security::remove_XSS($_GET['id_coach']),
"name" => get_lang("CoachStudents"),
];
}
} else {
$interbreadcrumb[] = [
"url" => "student.php",
"name" => get_lang("MyStudents"),
];
}
}
}
api_block_anonymous_users();
if (!api_is_allowed_to_edit() && !api_is_coach() && !api_is_drh() && !api_is_course_tutor(
) && $_user['status'] != SESSIONADMIN && !api_is_platform_admin(true)) {
api_not_allowed(true);
}
Display::display_header($nameTools);
$tbl_stats_exercices = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
if (isset($_GET['user_id']) && $_GET['user_id'] != '') {
$user_id = intval($_GET['user_id']);
} else {
$user_id = $_user['user_id'];
}
$session_id = isset($_GET['id_session']) ? intval($_GET['id_session']) : 0;
$student_id = (int) $_GET['student'];
// Action behaviour
$check = Security::check_token('get');
if (!empty($student_id)) { // infos about user
$info_user = api_get_user_info($student_id);
}
if (api_is_drh() && !UserManager::is_user_followed_by_drh($student_id, $_user['user_id'])) {
api_not_allowed();
}
$info_user['name'] = api_get_person_name($info_user['firstname'], $info_user['lastname']);
?>
<table class='table table-hover table-striped data_table'>
<tr>
<th colspan="6">
<?php echo get_lang('result_exam_title');
echo $info_user['name']; ?>
</th>
<tr>
<th><?php echo get_lang('module_no'); ?></th>
<th>
<?php echo get_lang('result_exam'); ?>
</th>
<th>
<?php echo get_lang('result_rep_1'); ?>
</th>
<th>
<?php echo get_lang('result_rep_2'); ?>
</th>
<th>
<?php echo get_lang('comment'); ?>
</th>
</tr>
<?php
$sqlexam = "SELECT *
FROM $tbl_stats_exercices
WHERE exe_user_id = $student_id
AND c_id = 0 AND mod_no != '0'
ORDER BY mod_no ASC";
$resultexam = Database::query($sqlexam);
while ($a_exam = Database::fetch_array($resultexam)) {
//$ex_id = $a_exam['ex_id'];
$mod_no = $a_exam['mod_no'];
$score_ex = $a_exam['score_ex'];
$score_rep1 = $a_exam['score_rep1'];
$score_rep2 = $a_exam['score_rep2'];
$coment = stripslashes($a_exam['coment']);
echo "
<tr>
<td> ".$a_exam['mod_no']."
</td>
<td>
".$a_exam['score_ex']."
</td>
<td>
".$a_exam['score_rep1']."
</td>
<td>
".$a_exam['score_rep2']."
</td>
<td>
$coment
</td>
</tr>
";
$exe_idd = $a_exam['exe_id'];
}
?>
</table>
</form>
<strong><?php echo get_lang('imprime_sommaire'); ?> </strong>
<a href="#" onclick="window.print()"><img align="absbottom" src="../img/printmgr.gif" border="0"></a>

View File

@@ -0,0 +1,67 @@
<?php
/* For licensing terms, see /license.txt */
// not used??
exit;
require_once '../inc/global.inc.php';
$allow = api_get_configuration_value('extra');
if (empty($allow)) {
exit;
}
Display::display_header($nameTools, "Tracking");
foreach ($_POST as $index => $valeur) {
$$index = Database::escape_string(trim($valeur));
}
?>
<form action="upgrade_school_calendar.php" method="post" name="upgrade_cal">
<th colspan="6">
<?php echo get_lang('edit_save'); ?>
</th>
<tr>
</th>
</tr>
<?php
echo "<table border='1'><tr>";
if ($i % $nbcol == 0) {
$sqlexam = "SELECT * FROM set_module
WHERE cal_name = '$d_title'";
}
$resultexam = Database::query($sqlexam);
while ($a_exam = Database::fetch_array($resultexam)) {
$name = $a_exam['cal_name'];
$id = $a_exam['id'];
$num = $a_exam['cal_day_num'];
$c_date = $a_exam['cal_date'];
echo "
<td><input type=text name=d_cal_date size=8 value=".$c_date."></td>
<td><input type=text name=d_number size=5 value=".$num."></td>
<td><input type=text name=d_title size=8 value=".$name."></td>
<td><input name=d_id size=8 value=".$id."></td>";
if ($i % $nbcol == ($nbcol - 1)) {
echo "</tr>";
}
}
$nb = count($d_number);
$nbcol = 2;
?>
</td>
</tr>
<input type=hidden name=aaa value=<?php echo serialize(Database::fetch_array($resultexam)); ?>/>
<input type="submit" value="Sauvegarder" name="B1">
<?php
echo $id, $tableau;
?>
</form>
</table>
<?php
Display::display_footer();

View File

@@ -0,0 +1,28 @@
<?php
/* For licensing terms, see /license.txt */
require_once '../inc/global.inc.php';
$allow = api_get_configuration_value('extra');
if (empty($allow)) {
exit;
}
$tbl_stats_exercices = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$ex_idd = isset($_POST['exe_id']) ? (int) $_POST['exe_id'] : '';
$ex_user_id = isset($_POST['ex_user_id']) ? (int) $_POST['ex_user_id'] : '';
$mod_no = isset($_POST['mod_no']) ? Database::escape_string($_POST['mod_no']) : '';
$score_ex = isset($_POST['score_ex']) ? Database::escape_string($_POST['score_ex']) : '';
$score_rep1 = isset($_POST['score_rep1']) ? Database::escape_string($_POST['score_rep1']) : '';
$score_rep2 = isset($_POST['score_rep2']) ? Database::escape_string($_POST['score_rep2']) : '';
$coment = isset($_POST['coment']) ? Database::escape_string($_POST['coment']) : '';
$student_id = isset($_POST['student_id']) ? Database::escape_string($_POST['student_id']) : '';
$sql = "UPDATE $tbl_stats_exercices SET
mod_no='$mod_no', score_ex='$score_ex', score_rep1='$score_rep1', score_rep2='$score_rep2', coment='$coment'
WHERE exe_id = '$ex_idd'
";
Database::query($sql);
header("location:../extra/myStudents.php?student=$student_id");
exit;

View File

@@ -0,0 +1,18 @@
<?php
/* For licensing terms, see /license.txt */
require_once '../inc/global.inc.php';
$allow = api_get_configuration_value('extra');
if (empty($allow)) {
exit;
}
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$ex_id = isset($_POST['exe_id']) ? (int) $_POST['exe_id'] : '';
$student_id = isset($_POST['student_id']) ? (int) $_POST['student_id'] : '';
$inter_coment = isset($_POST['inter_coment']) ? Database::escape_string($_POST['inter_coment']) : '';
$sql = "UPDATE $table SET inter_coment='$inter_coment' WHERE exe_id = $ex_id";
Database::query($sql);
header("location:../extra/myStudents.php?student=$student_id");
exit;

View File

@@ -0,0 +1,39 @@
<?php
/* For licensing terms, see /license.txt */
// not used??
exit;
require_once '../inc/global.inc.php';
$allow = api_get_configuration_value('extra');
if (empty($allow)) {
exit;
}
Display::display_header($nameTools, "Tracking");
foreach ($_POST as $x) {
echo "$x <br />";
}
foreach ($_POST as $index => $valeur) {
$$index = Database::escape_string(trim($valeur));
}
?>
<?php echo get_lang('edit_save'); ?>
<?php
$d_id = (int) $d_id;
$d_number = (int) $d_number;
$sql4 = "UPDATE set_module SET cal_day_num = $d_number WHERE id = $d_id ";
Database::query($sql4);
print_r(
UnserializeApi::unserialize(
'not_allowed_classes',
Security::remove_XSS($_POST['aaa'])
)
);
Display::display_footer();

465
main/extra/userInfo.php Normal file
View File

@@ -0,0 +1,465 @@
<?php
/* For licensing terms, see /license.txt */
require_once '../inc/global.inc.php';
require_once 'userInfoLib.php';
$allow = api_get_configuration_value('extra');
if (empty($allow)) {
exit;
}
$TABLECALHORAIRE = Database::get_course_table(cal_horaire);
$htmlHeadXtra[] = '<script>
function show_image(image,width,height) {
width = parseInt(width) + 20;
height = parseInt(height) + 20;
window_x = window.open(image,\'windowX\',\'width=\'+ width + \', height=\'+ height + \'\');
}
</script>';
$editMainUserInfo = Security::remove_XSS($_REQUEST['editMainUserInfo']);
$uInfo = $editMainUserInfo;
$this_section = SECTION_COURSES;
$nameTools = get_lang('Users');
api_protect_course_script(true);
$tool_info = api_get_tool_information_by_name(TOOL_USER);
if (api_is_anonymous()) {
api_not_allowed(true);
}
//prepare variables used in userInfoLib.php functions
$TBL_USERINFO_DEF = Database::get_course_table(TABLE_USER_INFO_DEF);
$TBL_USERINFO_CONTENT = Database::get_course_table(TABLE_USER_INFO_CONTENT);
if ($tool_info['visibility'] == 1) {
$interbreadcrumb[] = ['url' => 'user.php', 'name' => get_lang('Users')];
}
if ($origin != 'learnpath') { //so we are not in learnpath tool
Display::display_header($nameTools, "User");
$origin = Security::remove_XSS($_GET['origin']);
} else {
?> <link rel="stylesheet" type="text/css" href="<?php echo api_get_path(WEB_CODE_PATH); ?>css/default.css" /> <?php
}
$currentCourse = api_get_course_id();
$current_session_id = api_get_session_id();
/*
* data found in settings are :
* $uid
* $isAdmin
* $isAdminOfCourse
* $_configuration['main_database']
* $currentCourseID
*/
$userIdViewed = Security::remove_XSS($_REQUEST['uInfo']);
/**
* Connection layer between Chamilo and the current script.
*/
$courseCode = api_get_course_id();
$userIdViewer = api_get_user_id(); // id fo the user currently online
$allowedToEditContent = ($userIdViewer == $userIdViewed) || $is_platformAdmin;
$allowedToEditDef = api_is_allowed_to_edit(null, true);
$is_allowedToTrack = api_is_allowed_to_edit(null, true);
$displayMode = "viewContentList";
$removeDef = Security::remove_XSS($_GET['removeDef']);
$editDef = Security::remove_XSS($_GET['editDef']);
$moveUpDef = Security::remove_XSS($_GET['moveUpDef']);
$moveDownDef = Security::remove_XSS($_GET['moveDownDef']);
if ($allowedToEditDef) {
if (!empty($_POST['submitDef'])) {
if (!empty($_POST['id'])) {
edit_cat_def($_POST['id'], $_POST['title'], $_POST['comment'], $_POST['nbline']);
} else {
create_cat_def($_POST['title'], $_POST['comment'], $_POST['nbline']);
}
$displayMode = "viewDefList";
} elseif (!empty($_GET['removeDef'])) {
remove_cat_def($_GET['removeDef'], true);
$displayMode = "viewDefList";
} elseif (!empty($_GET['editDef'])) {
$displayMode = "viewDefEdit";
} elseif (!empty($_POST['addDef'])) {
$displayMode = "viewDefEdit";
} elseif (!empty($_GET['moveUpDef'])) {
move_cat_rank($_GET['moveUpDef'], "up");
$displayMode = "viewDefList";
} elseif (!empty($_GET['moveDownDef'])) {
move_cat_rank($_GET['moveDownDef'], "down");
$displayMode = "viewDefList";
} elseif (!empty($_POST['viewDefList'])) {
$displayMode = "viewDefList";
} elseif (!empty($_GET['editMainUserInfo'])) {
$userIdViewed = strval(intval($_GET['editMainUserInfo']));
$displayMode = "viewMainInfoEdit";
} elseif (!empty($_REQUEST['submitMainUserInfo'])) {
$userIdViewed = strval(intval($_REQUEST['submitMainUserInfo']));
if ($current_session_id) {
} else {
if (!empty($_POST['promoteCourseAdmin']) && $_POST['promoteCourseAdmin']) {
$userProperties['status'] = 1;
} else {
$userProperties['status'] = 5;
}
if (!empty($_POST['promoteTutor']) && $_POST['promoteTutor']) {
$userProperties['tutor'] = 1;
} else {
$userProperties['tutor'] = 0;
}
$userhoraire_name = $_POST['hor_name'];
$course_id = $_course['real_id'];
update_user_course_properties($userIdViewed, $courseCode, $userProperties, $userhoraire_name, $course_id);
}
$displayMode = "viewContentList";
}
}
if ($allowedToEditContent) {
if (isset($_POST['submitContent'])) {
if ($_POST['cntId']) {
// submit a content change
edit_cat_content($_POST['catId'], $userIdViewed, $_POST['content'], $_SERVER['REMOTE_ADDR']);
} else {
// submit a totally new content
fill_new_cat_content($_POST['catId'], $userIdViewed, $_POST['content'], $_SERVER['REMOTE_ADDR']);
}
$displayMode = "viewContentList";
} elseif (!empty($_GET['editContent'])) {
$displayMode = "viewContentEdit";
$userIdViewed = $userIdViewed;
}
}
if (api_is_allowed_to_edit(null, true)) {
echo '<div class="actions">';
if ($origin == 'users') {
echo '<a href="user.php?'.api_get_cidreq().'&origin='.$origin.'">'.
Display::return_icon('back.png', get_lang('BackUser'), '', ICON_SIZE_MEDIUM).'</a>';
} else {
echo '<a href="javascript:history.back(1)">'.
Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM).'</a>';
}
if (!is_numeric($_GET['editMainUserInfo'])) {
if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true') {
echo '<a href="userInfo.php?'.api_get_cidreq(
).'&origin='.$origin.'&editMainUserInfo='.$userIdViewed.'">'.
Display::return_icon('edit.png', get_lang('EditUser'), '', ICON_SIZE_MEDIUM).get_lang(
'EditUser'
).'</a>';
}
} else {
if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true') {
echo '<a href="userInfo.php?'.api_get_cidreq().'&origin='.$origin.'&uInfo='.$userIdViewed.'">'.
Display::return_icon(
'user.png',
get_lang('ViewUser'),
'',
ICON_SIZE_MEDIUM
).get_lang('ViewUser').'</a>';
}
}
echo '<a href="../mySpace/myStudents.php?'.api_get_cidreq().'&origin=user_course&student='.$userIdViewed.'&details=true&course='.$_course['id'].'">'.Display::return_icon('statistics.png', get_lang('UserStatistics'), '', ICON_SIZE_MEDIUM).get_lang('UserStatistics').'</a>';
echo '</div>';
} else {
if ($tool_info['visibility'] == 1) {
echo '<div class="actions">';
if ($origin == 'users') {
echo '<a href="user.php?'.api_get_cidreq().'&origin='.$origin.'">'.
Display::return_icon(
'back.png',
get_lang('BackUser'),
'',
ICON_SIZE_MEDIUM
).'</a>';
} else {
echo '<a href="javascript:history.back(1)">'.Display::return_icon(
'back.png',
get_lang('Back'),
'',
ICON_SIZE_MEDIUM
).'</a>';
}
echo '</div>';
}
}
// get information about user id viewed
$user_info_viewed = api_get_user_info($userIdViewed);
$is_session_course_coach = UserManager::is_session_course_coach(
$userIdViewed,
$_course['sysCode'],
$current_session_id
);
if ($displayMode == "viewDefEdit") {
/* CATEGORIES DEFINITIONS : EDIT */
$catToEdit = get_cat_def($_GET['editDef']);
$edit_heading_form = new FormValidator('edit_heading_form');
$edit_heading_form->addElement('hidden', 'id');
$edit_heading_form->add_textfield('title', get_lang('Title'));
$edit_heading_form->addElement('textarea', 'comment', get_lang('Comment'), ['cols' => 60, 'rows' => 4]);
$possible_line_nrs[1] = '1 '.get_lang('Line');
$possible_line_nrs[3] = '3 '.get_lang('Lines');
$possible_line_nrs[5] = '5 '.get_lang('Lines');
$possible_line_nrs[10] = '10 '.get_lang('Lines');
$possible_line_nrs[15] = '15 '.get_lang('Lines');
$edit_heading_form->addElement('select', 'nbline', get_lang('LineNumber'), $possible_line_nrs);
$edit_heading_form->addElement('submit', 'submitDef', get_lang('Ok'));
$edit_heading_form->setDefaults($catToEdit);
$edit_heading_form->display();
} elseif ($displayMode == "viewDefList") {
$catList = get_cat_def_list();
if ($catList) {
foreach ($catList as $thisCat) {
// displays Title and comments
echo "<p>", "<b>".htmlize($thisCat['title'])."</b><br>\n", "<i>".htmlize($thisCat['comment'])."</i>\n", "</p>";
// displays lines
echo "<blockquote>\n", "<font color=\"gray\">\n";
for ($i = 1; $i <= $thisCat['nbline']; $i++) {
echo "<br>__________________________________________\n";
}
echo "</font>\n", "</blockquote>\n";
// displays commands
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&removeDef=", $thisCat['catId'], "\">", "<img src=\"../img/delete.gif\" border=\"0\" alt=\"".get_lang('Remove')."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset))."')) return false;\">", "</a>", "<a href=\"".api_get_self()."?".api_get_cidreq()."&editDef=", $thisCat['catId'], "\">", "<img src=\"../img/edit.gif\" border=\"0\" alt=\"".get_lang('Edit')."\" />", "</a>", "<a href=\"".api_get_self()."?".api_get_cidreq()."&moveUpDef=", $thisCat['catId'], "\">", "<img src=\"../img/up.gif\" border=\"0\" alt=\"".get_lang('MoveUp')."\">", "</a>", "<a href=\"".api_get_self()."?".api_get_cidreq()."&moveDownDef=", $thisCat['catId'], "\">", "<img src=\"../img/down.gif\" border=\"0\" alt=\"".get_lang('MoveDown')."\">", "</a>\n";
} // end for each
} // end if ($catList)
echo "<center>\n",
"<form method=\"post\" action=\"".api_get_self()."\">",
"<input type=\"submit\" name=\"addDef\" class=\"plus\" value=\"".get_lang('AddNewHeading')."\" />",
"</form>\n",
"<center>\n";
} elseif ($displayMode == 'viewContentEdit') {
/* CATEGORIES CONTENTS : EDIT */
$catToEdit = get_cat_content($userIdViewed, $_GET['editContent']);
$content_heading_form = new FormValidator('content_heading_form');
$content_heading_form->addElement('hidden', 'cntId');
$content_heading_form->addElement('hidden', 'catId');
$content_heading_form->addElement('hidden', 'uInfo');
$content_heading_form->addElement('static', null, $catToEdit['title'], htmlize($catToEdit['comment']));
if ($catToEdit['nbline'] == 1) {
$content_heading_form->addElement('text', 'content', null, ['size' => 80]);
} else {
$content_heading_form->addElement(
'textarea',
'content',
null,
['cols' => 60, 'rows' => $catToEdit['nbline']]
);
}
$content_heading_form->addElement('submit', 'submitContent', get_lang('Ok'));
$defaults = $catToEdit;
$defaults['cntId'] = $catToEdit['contentId'];
$defaults['uInfo'] = $userIdViewed;
$content_heading_form->setDefaults($defaults);
$content_heading_form->display();
} elseif ($displayMode == "viewMainInfoEdit") {
$mainUserInfo = api_get_user_info($userIdViewed);
if ($mainUserInfo) {
($mainUserInfo['status'] == COURSEMANAGER) ? $courseAdminChecked = "checked" : $courseAdminChecked = "";
$image_array = UserManager::get_user_picture_path_by_id($userIdViewed, 'web', false, true);
// get the path,width and height from original picture
$big_image = $image_array['dir'].'big_'.$image_array['file'];
$big_image_size = api_getimagesize($big_image);
$big_image_width = $big_image_size['width'];
$big_image_height = $big_image_size['height'];
$url_big_image = $big_image.'?rnd='.time();
if ($image_array['file'] == 'unknown.jpg') {
echo '<img src="'.$image_array['dir'].$image_array['file'].'" border="1">';
} else {
echo '<input type="image" src="'.$image_array['dir'].$image_array['file'].'" onclick="return show_image(\''.$url_big_image.'\',\''.$big_image_width.'\',\''.$big_image_height.'\');"/>';
}
echo "<form action=\"".api_get_self()."\" method=\"post\">\n",
"<input type=\"hidden\" name=\"submitMainUserInfo\" value=\"$userIdViewed\" />\n",
"<table width=\"80%\" border=\"0\">",
"<tr align=\"center\" bgcolor=\"#E6E6E6\">\n",
"<td align=\"left\">", get_lang('Name'), "</td>\n",
"<td width=\"100px\" align=\"left\">", get_lang('Schedule'), "</td>\n";
echo "</tr>\n",
"<tr align=\"center\">",
"<td align=\"left\"><b>", htmlize(api_get_person_name($mainUserInfo['firstName'], $mainUserInfo['lastName'])), "</b></td>\n",
"<td align=\"left\"><b>", $mainUserInfo['official_code'], "</td>";
//récupérer horaire de l'élève
$course_id = $_course['real_id']; ?>
<SELECT NAME='hor_name'>
<OPTION VALUE='<?php echo $mainUserInfo['official_code']; ?>'><?php echo get_lang('select_calendar_student'); ?></OPTION>
<?php
$sql = "SELECT distinct name FROM $TABLECALHORAIRE
where c_id = $course_id ";
$result2 = Database::query($sql);
while ($row = Database::fetch_array($result2)) {
$horaire_name = $row["name"]; ?>
<OPTION VALUE='<?php echo $horaire_name; ?>'><?php echo "$horaire_name "; ?></OPTION>
<?php
} ?>
</SELECT>
<?php
echo '<p></p> ';
if (!($is_courseAdmin && $_user['user_id'] == $userIdViewed)) {
} else {
echo "<td>", get_lang('CourseManager'), "</td>\n";
}
echo "<td><button class=\"save\" type=\"submit\" name=\"submit\">".get_lang('SaveChanges')."</button></td>\n", "</tr>", "</table>", "</form>\n";
if (api_get_setting('show_email_addresses') == 'true') {
echo "<p>".Display::encrypted_mailto_link($mainUserInfo['email'], $mainUserInfo['email'])."</p>";
}
if (api_get_setting('extended_profile') == 'true') {
// MY PERSONAL OPEN AREA
if (!empty($mainUserInfo['openarea'])) {
echo '<div style="margin-top:10px;" class="actions-message"><strong>'.get_lang('MyPersonalOpenArea').'</strong></div><div>'.$mainUserInfo['openarea'].'</div>';
}
// MY COMPETENCES
if (!empty($mainUserInfo['competences'])) {
echo '<div style="margin-top:10px;" class="actions-message"><strong>'.get_lang('MyCompetences').'</strong></div><div>'.$mainUserInfo['competences'].'</div>';
}
// MY DIPLOMAS
if (!empty($mainUserInfo['diplomas'])) {
echo '<div style="margin-top:10px;" class="actions-message"><strong>'.get_lang('MyDiplomas').'</strong></div><div>'.$mainUserInfo['diplomas'].'</div>';
}
// WHAT I AM ABLE TO TEACH
if (!empty($mainUserInfo['teach'])) {
echo '<div style="margin-top:10px;" class="actions-message"><strong>'.get_lang('MyTeach').'</strong></div><div>'.$mainUserInfo['teach'].'</div>';
}
// MY PRODUCTIONS
if (!empty($mainUserInfo['competences'])) {
echo '<div style="margin-top:10px;" class="actions-message"><strong>'.get_lang('MyProductions').'</strong></div><div>'.UserManager::build_production_list($mainUserInfo['user_id']).'</div>';
}
}
} else {
Display::return_message(get_lang('ThisStudentIsSubscribeThroughASession'));
}
} elseif ($displayMode == "viewContentList") {
// default display
$virtual_course_code = $_GET["virtual_course"];
if (isset($virtual_course_code)) {
$courseCode = $virtual_course_code;
$allowedToEditDef = false;
}
$mainUserInfo = api_get_user_info($userIdViewed);
if ($mainUserInfo) {
$image_array = UserManager::get_user_picture_path_by_id($userIdViewed, 'web', false, true);
// get the path,width and height from original picture
$big_image = $image_array['dir'].'big_'.$image_array['file'];
$big_image_size = api_getimagesize($big_image);
$big_image_width = $big_image_size['width'];
$big_image_height = $big_image_size['height'];
$url_big_image = $big_image.'?rnd='.time();
if ($image_array['file'] == 'unknown.jpg') {
echo '<img src="'.$image_array['dir'].$image_array['file'].'" border="1">';
} else {
echo '<input type="image" src="'.$image_array['dir'].$image_array['file'].'" onclick="return show_image(\''.$url_big_image.'\',\''.$big_image_width.'\',\''.$big_image_height.'\');"/>';
}
// is the user online?
$online = '';
if (user_is_online($userIdViewed)) {
$online = Display::return_icon('online.gif', get_lang('OnLine'), ['style' => 'with="8"; height="8"']);
}
// DISPLAY TABLE HEADING
if ($origin == 'learnpath') {
$allowedToEditDef = false;
$is_allowedToTrack = false;
}
echo "<table width=\"80%\" border=\"0\">",
"<tr align=\"center\" bgcolor=\"#E6E6E6\">\n",
"<td align=\"left\">".get_lang('Name')."</td>\n",
"<td width=\"20%\" align=\"left\">".get_lang('Description')."</td>\n",
"<td width=\"100px\" align=\"left\">", get_lang('OfficialCode'), "</td>\n";
echo "</tr>\n",
"<tr align=\"center\">\n",
"<td align=\"left\"><b>".$online.' '.htmlize(api_get_person_name($mainUserInfo['firstName'], $mainUserInfo['lastName']))."</b></td>\n",
"<td align=\"left\"><b>", $mainUserInfo['official_code'], "</td>";
// DISPLAY TABLE CONTENT
if ($current_session_id) {
if ($user_info_viewed['status'] == COURSEMANAGER) {
echo "<td> - </td>\n";
}
} else {
if ($user_info_viewed['status'] == STUDENT) {
echo "<td> - </td>\n";
} else {
echo "<td> - </td>\n";
}
}
echo "</tr></table>";
if (api_get_setting("show_email_addresses") == "true") {
echo "<p>".Display::encrypted_mailto_link($mainUserInfo['email'], $mainUserInfo['email'])."</p>";
}
if (api_get_setting('extended_profile') == 'true') {
// MY PERSONAL OPEN AREA
if (!empty($mainUserInfo['openarea'])) {
echo '<div style="margin-top:10px;" class="actions-message"><strong>'.get_lang('MyPersonalOpenArea').'</strong></div><div>'.$mainUserInfo['openarea'].'</div>';
}
// MY COMPETENCES
if (!empty($mainUserInfo['competences'])) {
echo '<div style="margin-top:10px;" class="actions-message"><strong>'.get_lang('MyCompetences').'</strong></div><div>'.$mainUserInfo['competences'].'</div>';
}
// MY DIPLOMAS
if (!empty($mainUserInfo['diplomas'])) {
echo '<div style="margin-top:10px;" class="actions-message"><strong>'.get_lang('MyDiplomas').'</strong></div><div>'.$mainUserInfo['diplomas'].'</div>';
}
// WHAT I AM ABLE TO TEACH
if (!empty($mainUserInfo['teach'])) {
echo '<div style="margin-top:10px;" class="actions-message"><strong>'.get_lang('MyTeach').'</strong></div><div>'.$mainUserInfo['teach'].'</div>';
}
// MY PRODUCTIONS
if (!empty($mainUserInfo['competences'])) {
echo '<div style="margin-top:10px;" class="actions-message"><strong>'.get_lang('MyProductions').'</strong></div><div>'.UserManager::build_production_list($mainUserInfo['user_id']).'</div>';
}
}
} else {
Display::return_message(get_lang('ThisStudentIsSubscribeThroughASession'), 'normal');
}
if (api_get_setting('allow_user_headings') == 'true' && $allowedToEditDef) {
// only course administrators see this line
echo "<div align=right>",
"<form method=\"post\" action=\"".api_get_self()."\">",
get_lang('CourseAdministratorOnly')," : ",
"<input type=\"submit\" class=\"save\" name=\"viewDefList\" value=\"".get_lang('DefineHeadings')."\" />",
"</form>",
"<hr noshade size=\"1\" style=\"color:#99CCFF\">",
"</div>\n";
}
$catList = get_course_user_info($userIdViewed);
if ($catList) {
foreach ($catList as $thisCat) {
// Category title
echo "<p><b>", $thisCat['title'], "</b></p>\n";
// Category content
echo "<blockquote>\n";
if ($thisCat['content']) {
echo htmlize($thisCat['content'])."\n";
} else {
echo "....";
}
// Edit command
if ($allowedToEditContent) {
echo "<br /><br />\n",
"<a href=\"".api_get_self()."?".api_get_cidreq(
)."&editContent=", $thisCat['catId'], "&uInfo=", $userIdViewed, "\">",
"<img src=\"../img/edit.gif\" border=\"0\" alt=\"edit\">",
"</a>\n";
}
echo "</blockquote>\n";
}
}
}
Display::display_footer();

572
main/extra/userInfoLib.php Normal file
View File

@@ -0,0 +1,572 @@
<?php
/* For licensing terms, see /license.txt*/
/**
* create a new category definition for the user information.
*
* @author - Hugues peeters <peeters@ipm.ucl.ac.be>
* @author - Christophe Gesch<63> <gesche@ipm.ucl.ac.be>
*
* @param string $title - category title
* @param string $comment - title comment
* @param int $nbline - lines number for the field the user will fill
*
* @return bool true if succeed, else bolean false
*/
function create_cat_def($title = "", $comment = "", $nbline = "5")
{
global $TBL_USERINFO_DEF; //taken from userInfo.php
$title = Database::escape_string(trim($title));
$comment = Database::escape_string(trim($comment));
$nbline = strval(intval($nbline));
if (0 == (int) $nbline || empty($title)) {
return false;
}
$sql = "SELECT MAX(rank) as maxRank FROM ".$TBL_USERINFO_DEF;
$result = Database::query($sql);
if ($result) {
$maxRank = Database::fetch_array($result);
}
$maxRank = $maxRank['maxRank'];
$thisRank = $maxRank + 1;
$sql = "INSERT INTO $TBL_USERINFO_DEF SET
title = '$title',
comment = '$comment',
line_count = '$nbline',
rank = '$thisRank'";
Database::query($sql);
return true;
}
/**
* modify the definition of a user information category.
*
* @author - Hugues peeters <peeters@ipm.ucl.ac.be>
* @author - Christophe Gesch<63> <gesche@ipm.ucl.ac.be>
*
* @param int $id - id of the category
* @param string $title - category title
* @param string $comment - title comment
* @param int $nbline - lines number for the field the user will fill
*
* @return - boolean true if succeed, else otherwise
*/
function edit_cat_def($id, $title, $comment, $nbline)
{
global $TBL_USERINFO_DEF;
if (0 == $nbline || 0 == $id) {
return false;
}
$id = strval(intval($id)); //make sure id is integer
$title = Database::escape_string(trim($title));
$comment = Database::escape_string(trim($comment));
$nbline = strval(intval($nbline));
$sql = "UPDATE $TBL_USERINFO_DEF SET
title = '$title',
comment = '$comment',
line_count = '$nbline'
WHERE id = '$id'";
Database::query($sql);
return true;
}
/**
* remove a category from the category list.
*
* @author - Hugues peeters <peeters@ipm.ucl.ac.be>
* @author - Christophe Gesche <gesche@ipm.ucl.ac.be>
*
* @param int $id - id of the category
* or "ALL" for all category
* @param bool $force - FALSE (default) : prevents removal if users have
* already fill this category
* TRUE : bypass user content existence check
*
* @return bool - TRUE if succeed, ELSE otherwise
*/
function remove_cat_def($id, $force = false)
{
$TBL_USERINFO_DEF = Database::get_course_table(TABLE_USER_INFO_DEF);
$TBL_USERINFO_CONTENT = Database::get_course_table(TABLE_USER_INFO_CONTENT);
$id = strval(intval($id));
if ((0 == (int) $id || $id == "ALL") || !is_bool($force)) {
return false;
}
$sqlCondition = " WHERE id = $id";
if (!$force) {
$sql = "SELECT * FROM $TBL_USERINFO_CONTENT $sqlCondition";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
return false;
}
}
$sql = "DELETE FROM $TBL_USERINFO_DEF $sqlCondition";
Database::query($sql);
}
/**
* move a category in the category list.
*
* @author - Hugues peeters <peeters@ipm.ucl.ac.be>
* @author - Christophe Gesch<63> <gesche@ipm.ucl.ac.be>
*
* @param int $id - id of the category
* @param string $direction "up" or "down" :
* "up" decrease the rank of gived $id by switching rank with the just lower
* "down" increase the rank of gived $id by switching rank with the just upper
*
* @return bool true if succeed, else boolean false
*/
function move_cat_rank($id, $direction) // up & down.
{
$TBL_USERINFO_DEF = Database::get_course_table(userinfo_def);
$id = strval(intval($id));
if (0 == (int) $id || !($direction == "up" || $direction == "down")) {
return false;
}
$sql = "SELECT rank FROM $TBL_USERINFO_DEF WHERE id = $id";
$result = Database::query($sql);
if (Database::num_rows($result) < 1) {
return false;
}
$cat = Database::fetch_array($result);
$rank = (int) $cat['rank'];
return move_cat_rank_by_rank($rank, $direction);
}
/**
* move a category in the category list.
*
* @author - Hugues peeters <peeters@ipm.ucl.ac.be>
* @author - Christophe Gesche <gesche@ipm.ucl.ac.be>
*
* @param int $rank - actual rank of the category
* @param string $direction "up" or "down" :
* "up" decrease the rank of gived $rank by switching rank with the just lower
* "down" increase the rank of gived $rank by switching rank with the just upper
*
* @return bool true if succeed, else boolean false
*/
function move_cat_rank_by_rank($rank, $direction) // up & down.
{
$TBL_USERINFO_DEF = Database::get_course_table(userinfo_def);
if (0 == (int) $rank || !($direction == "up" || $direction == "down")) {
return false;
}
if ($direction === "down") {
// thus increase rank ...
$sort = "ASC";
$compOp = ">=";
} else {
// thus decrease rank ...
$sort = "DESC";
$compOp = "<=";
}
// this request find the 2 line to be switched (on rank value)
$sql = "SELECT id, rank FROM $TBL_USERINFO_DEF
WHERE rank $compOp $rank
ORDER BY rank $sort LIMIT 2";
$result = Database::query($sql);
if (Database::num_rows($result) < 2) {
return false;
}
$thisCat = Database::fetch_array($result);
$nextCat = Database::fetch_array($result);
$sql1 = "UPDATE $TBL_USERINFO_DEF SET rank ='".$nextCat['rank'].
"' WHERE id = '".$thisCat['id']."'";
$sql2 = "UPDATE $TBL_USERINFO_DEF SET rank ='".$thisCat['rank'].
"' WHERE id = '".$nextCat['id']."'";
Database::query($sql1);
Database::query($sql2);
return true;
}
/**
* @author Hugues Peeters - peeters@ipm.ucl.ac.be
*
* @param int $user_id
* @param string $course_code
* @param array $properties - should contain 'role', 'status', 'tutor_id'
*
* @return bool true if succeed false otherwise
*/
function update_user_course_properties($user_id, $course_code, $properties, $horaire_name, $course_id)
{
global $tbl_coursUser, $_user;
$sqlChangeStatus = "";
$user_id = (int) $user_id; //filter integer
$course_code = Database::escape_string($course_code);
$course_id = (int) $course_id;
$horaire_name = Database::escape_string($horaire_name);
$status = Database::escape_string($properties['status']);
$tutor = Database::escape_string($properties['tutor']);
if ($user_id != $_user['user_id']) {
$sqlChangeStatus = "status = '$status',";
}
$sql = "UPDATE $tbl_coursUser
SET $sqlChangeStatus
is_tutor = '$tutor'
WHERE user_id = $user_id AND c_id = $course_id";
Database::query($sql);
//update official-code: Horaire
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$sql2 = "UPDATE $table_user
SET official_code = '$horaire_name'
WHERE user_id = $user_id";
Database::query($sql2);
//on récupère l'horaire
$tbl_personal_agenda = Database::get_main_table(TABLE_PERSONAL_AGENDA);
$TABLECALDATES = Database::get_course_table(cal_dates);
$jour = 0;
$sql3 = "SELECT date FROM $TABLECALDATES
WHERE
horaire_name = '$horaire_name' AND
status = 'C' AND
c_id = $course_id
ORDER BY date ";
$result3 = Database::query($sql3);
if (Database::num_rows($result3) == '0') {
return false;
}
//on efface ce qui est déjà inscrit
$sql4 = "DELETE FROM $tbl_personal_agenda
WHERE user = $user_id
AND text = 'Pour le calendrier, ne pas effacer'";
Database::query($sql4);
$sql = "DELETE FROM $tbl_personal_agenda
WHERE user = $user_id AND title = 'Examen*'";
Database::query($sql);
//à chaque date dans l'horaire
while ($res3 = Database::fetch_array($result3)) {
$date = $res3['date'];
//on incrémente les jours de cours
$date = api_get_utc_datetime($date);
$jour = $jour + 1;
//on réinsère le nouvel horaire
$sql = "INSERT ".$tbl_personal_agenda." (user,title,text,date)
VALUES ($user_id, $jour, 'Pour le calendrier, ne pas effacer', '$date')";
Database::query($sql);
// pour les inscrire examens dans agenda
$sql5 = "SELECT date FROM $TABLECALDATES
WHERE horaire_name = '$horaire_name' AND status = 'E'
AND c_id = '$course_id'
ORDER BY date
";
$result5 = Database::query($sql5);
}
//à chaque date dans l'horaire
while ($res5 = Database::fetch_array($result5)) {
$date = $res5['date'];
$date = api_get_utc_datetime($date);
//on réinsère le nouvel horaire
$sql7 = "INSERT $tbl_personal_agenda (user, title, date) VALUES ($user_id, 'Examen*', '$date')";
Database::query($sql7);
}
}
/**
* fill a bloc for information category.
*
* @author - Hugues peeters <peeters@ipm.ucl.ac.be>
* @author - Christophe Gesche <gesche@ipm.ucl.ac.be>
*
* @param $definition_id
* @param $user_id
* @param $user_ip
* @param $content
*
* @return bool true if succeed, else boolean false
*/
function fill_new_cat_content($definition_id, $user_id, $content = "", $user_ip = "")
{
global $TBL_USERINFO_CONTENT;
if (empty($user_ip)) {
$user_ip = $_SERVER['REMOTE_ADDR'];
}
$definition_id = (int) $definition_id;
$user_id = (int) $user_id;
$content = Database::escape_string(trim($content));
$user_ip = Database::escape_string(trim($user_ip));
if (0 == $definition_id || 0 == $user_id || $content == "") {
// Here we should introduce an error handling system...
return false;
}
// Do not create if already exist
$sql = "SELECT id FROM $TBL_USERINFO_CONTENT
WHERE definition_id = '$definition_id'
AND user_id = $user_id";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
return false;
}
$sql = "INSERT INTO $TBL_USERINFO_CONTENT SET
content = '$content',
definition_id = $definition_id,
user_id = $user_id,
editor_ip = '$user_ip',
edition_time = now()";
Database::query($sql);
return true;
}
/**
* Edit a bloc for information category.
*
* @author - Hugues peeters <peeters@ipm.ucl.ac.be>
* @author - Christophe Gesche <gesche@ipm.ucl.ac.be>
*
* @param $definition_id
* @param $user_id
* @param $user_ip DEFAULT $REMOTE_ADDR
* @param $content if empty call delete the bloc
*
* @return bool true if succeed, else boolean false
*/
function edit_cat_content($definition_id, $user_id, $content = "", $user_ip = "")
{
global $TBL_USERINFO_CONTENT;
$definition_id = (int) $definition_id;
$user_id = (int) $user_id;
$content = Database::escape_string(trim($content));
if (empty($user_ip)) {
$user_ip = $_SERVER['REMOTE_ADDR'];
}
$user_ip = Database::escape_string($user_ip);
if (0 == $user_id || 0 == $definition_id) {
return false;
}
if ($content == "") {
return cleanout_cat_content($user_id, $definition_id);
}
$sql = "UPDATE $TBL_USERINFO_CONTENT SET
content = '$content',
editor_ip = '$user_ip',
edition_time = now()
WHERE definition_id = $definition_id AND user_id = $user_id";
Database::query($sql);
return true;
}
/**
* clean the content of a bloc for information category.
*
* @author Hugues peeters <peeters@ipm.ucl.ac.be>
* @author Christophe Gesche <gesche@ipm.ucl.ac.be>
*
* @param $definition_id
* @param $user_id
*
* @return bool true if succeed, else boolean false
*/
function cleanout_cat_content($user_id, $definition_id)
{
global $TBL_USERINFO_CONTENT;
$user_id = (int) $user_id;
$definition_id = (int) $definition_id;
if (0 == $user_id || 0 == $definition_id) {
return false;
}
$sql = "DELETE FROM $TBL_USERINFO_CONTENT
WHERE user_id = $user_id AND definition_id = $definition_id";
Database::query($sql);
return true;
}
/**
* get the user info from the user id.
*
* @author - Hugues Peeters <peeters@ipm.ucl.ac.be>
* @author - Christophe Gesche <gesche@ipm.ucl.ac.be>
*
* @param int $user_id user id as stored in the Dokeos main db
*
* @return array containg user info sort by categories rank
* each rank contains 'title', 'comment', 'content', 'cat_id'
*/
function get_course_user_info($user_id)
{
$TBL_USERINFO_DEF = Database::get_course_table(TABLE_USER_INFO_DEF);
$TBL_USERINFO_CONTENT = Database::get_course_table(TABLE_USER_INFO_CONTENT);
$user_id = (int) $user_id;
$sql = "SELECT cat.id catId, cat.title,
cat.comment , content.content
FROM $TBL_USERINFO_DEF cat LEFT JOIN $TBL_USERINFO_CONTENT content
ON cat.id = content.definition_id AND content.user_id = $user_id
ORDER BY cat.rank, content.id";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
while ($userInfo = Database::fetch_array($result, 'ASSOC')) {
$userInfos[] = $userInfo;
}
return $userInfos;
}
return false;
}
/**
* get the user content of a categories plus the categories definition.
*
* @author - Hugues Peeters <peeters@ipm.ucl.ac.be>
* @author - Christophe Gesche <gesche@ipm.ucl.ac.be>
*
* @param int $userId id of the user
* @param int $catId id of the categories
*
* @return array containing 'catId', 'title', 'comment', 'nbline', 'contentId' and 'content'
*/
function get_cat_content($userId, $catId)
{
$TBL_USERINFO_DEF = Database::get_course_table(TABLE_USER_INFO_DEF);
$TBL_USERINFO_CONTENT = Database::get_course_table(TABLE_USER_INFO_CONTENT);
$userId = (int) $userId;
$catId = (int) $catId;
$sql = "SELECT cat.id catId, cat.title,
cat.comment , cat.line_count,
content.id contentId, content.content
FROM $TBL_USERINFO_DEF cat LEFT JOIN $TBL_USERINFO_CONTENT content
ON cat.id = content.definition_id
AND content.user_id = $userId
WHERE cat.id = $catId ";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
$catContent = Database::fetch_array($result, 'ASSOC');
$catContent['nbline'] = $catContent['line_count'];
return $catContent;
}
return false;
}
/**
* get the definition of a category.
*
* @author Christophe Gesche <gesche@ipm.ucl.ac.be>
* @author Hugues Peeters <peeters@ipm.ucl.ac.be>
*
* @param int $catId - id of the categories
*
* @return array containing 'id', 'title', 'comment', and 'nbline',
*/
function get_cat_def($catId)
{
$TBL_USERINFO_DEF = Database::get_course_table(TABLE_USER_INFO_DEF);
$catId = (int) $catId;
$sql = "SELECT id, title, comment, line_count, rank FROM $TBL_USERINFO_DEF WHERE id = $catId";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
$catDef = Database::fetch_array($result, 'ASSOC');
$catDef['nbline'] = $catDef['line_count'];
return $catDef;
}
return false;
}
/**
* get list of all this course categories.
*
* @author Christophe Gesche <gesche@ipm.ucl.ac.be>
* @author Hugues Peeters <peeters@ipm.ucl.ac.be>
*
* @return array containing a list of arrays.
* And each of these arrays contains
* 'catId', 'title', 'comment', and 'nbline',
*/
function get_cat_def_list()
{
$TBL_USERINFO_DEF = Database::get_course_table(TABLE_USER_INFO_DEF);
$sql = "SELECT id catId, title, comment , line_count
FROM $TBL_USERINFO_DEF
ORDER BY rank";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
while ($cat_def = Database::fetch_array($result, 'ASSOC')) {
$cat_def_list[] = $cat_def;
}
return $cat_def_list;
}
return false;
}
/**
* transform content in a html display.
*
* @author Hugues Peeters <peeters@ipm.ucl.ac.be>
*
* @param string $string string to htmlize
*
* @return string htmlized
*/
function htmlize($string)
{
global $charset;
return nl2br(htmlspecialchars($string, ENT_QUOTES, $charset));
}