Hacked By AnonymousFox
index.php 0000644 00000011550 15200271737 0006372 0 ustar 00 <?php
/* For licensing terms, see /license.txt */
/**
* Template (front controller in MVC pattern) used for distpaching to the controllers depend on the current action
* @author Batiste Roger <batiste.roger@live.fr>
* @package chamilo.profil
*/
assert_options(ASSERT_BAIL, true); // Make asserts stop code execution when failed (TODO - Remove)
// Require subrole methods
require_once '../inc/global.inc.php';
require_once(api_get_path(SYS_PATH) . 'main/subrole/subrole.php');
require_once(api_get_path(SYS_PATH) . 'main/couple/model.php');
require_once(api_get_path(SYS_PATH) . 'main/formation/utils.php');
// current section
unset($_SESSION['this_section']); //for hmtl editor repository
// protect script
api_block_anonymous_users();
$error_context = "rh/index.php";
$my_user_id = api_get_user_id();
$my_subrole = get_subrole($my_user_id);
$is_admin = ($my_subrole == ADMIN);
$controller = new IndexManager('Profil');
$controller->tpl->assign('is_admin', $is_admin);
$controller->tpl->assign('part', 'rh');
$controller->tpl->assign('web_path', api_get_path(WEB_PATH));
$controller->tpl->assign('my_user_id', $my_user_id);
$controller->tpl->assign('my_subrole', $my_subrole);
$list = rh_list_hp($my_user_id);
//var_dump($list['hps']);
//var_dump($list['stats']); exit;
$controller->tpl->assign('my_hps', $list['hps']);
$controller->tpl->assign('stats', $list['stats']);
// Call to formation's template
$tpl = $controller->tpl->get_template('layout/mm_rh.tpl');
$controller->tpl->display($tpl);
function rh_list_hp ($user_id) {
$sql = "SELECT *, hp.user_id as hp_user_id FROM user JOIN hp ON user.user_id = hp.user_id WHERE company = (SELECT company FROM user WHERE user_id = '$user_id')";
$res = Database::query($sql);
$array = array();
$stats = array('score' => array(0,0,0), 'displayed' => array(0,0,0));
while ($row = Database::fetch_assoc($res)) {
$score = rh_get_score_for_user($row['user_id']);
$row['score'] = intval($score['score']);
$row['displayed'] = intval($score['displayed']);
$score_category = get_category($row['score']);
$stats['score'][$score_category] ++;
$displayed_category = get_category($row['displayed']);
$stats['displayed'][$displayed_category] ++;
// Tutor info
$hp_user_id = $row['user_id'];
$tutor = couple_get_tutor($hp_user_id);
$tutor_info = UserManager::get_user_info_by_id($tutor['tu_user_id']);
$row['tutor'] = array(
'name' => $tutor_info['firstname'],
'email' => $tutor_info['email']
);
$array[] = $row;
}
return array('hps' => $array, 'stats' => $stats);
}
/**
*
* @param type $value Score (or %displayed) that has to be put in a category
* @param type $nb_category_active Number of parts in the pie, excluding the 0 category that represents user who have a score of 0
* @return int
*/
function get_category($value, $nb_cat = 4) {
if ($value == 0) return 0; // 0 is very specific. It means user did not start at all
return ((intval($value) - 1)*$nb_cat/100)%$nb_cat + 1; // The -1 causes 100 to return 2, which is fine
}
function rh_get_score_for_user ($user_id) {
foreach (array(TAB_THEME, TAB_CAS, TAB_VIDEO) as $tab) {
$themes[$tab] = get_scores($tab, $user_id);
}
$total_score_counter = 0;
$total_completed_counter = 0;
$score_counter = 0;
$completed_counter = 0;
foreach ($themes as $theme_tab) {
foreach ($theme_tab as $id_c_id => $c_id) {
foreach ($c_id as $id_lp_id => $lp_id) {
// Determine if this lp uses a max_score
$use_max_score = lp_has_score($id_c_id, $id_lp_id);
foreach ($lp_id as $item_id) {
$total_completed_counter++;
$total_score_counter += intval($use_max_score); // +1 si use_max_score => les lp dépourvus de score ne comptent pas
if (!empty($item_id) && $item_id['status'] == 'completed') {
if ($use_max_score && is_int($item_id['max_score']) && $item_id['max_score'] > 0) {
// N'incrémenter le score counter que si le max_score est positif et pris en compte (use_max_score)
$score_counter += $item_id['score'] / $item_id['max_score'];
}
$completed_counter++;
}
}
}
}
}
return array(
'score' => $total_score_counter > 0 ? round(100 * $score_counter / $total_score_counter) : 0,
'displayed' => $total_completed_counter > 0 ? round(100 * $completed_counter / $total_completed_counter) : 0
);
} eval.php 0000644 00000001465 15200271737 0006216 0 ustar 00 <?php
require_once '../inc/global.inc.php';
require_once(api_get_path(SYS_PATH) . 'main/couple/eval.php');
if (!isset($_GET['id'])) exit;
// TODO SECURE PAGE. ANY USER CAN CALL THAT !!!!!!!
$id = $_GET['id'];
$evals = eval_read_all($id);
if (empty($evals)) {
echo "Nous ne disposons pas encore de données suffisantes concernant cet utilisateur";
exit;
}
$controller = new IndexManager("Impressions");
$controller->tpl->assign('evals', $evals);
$info = UserManager::get_user_info_by_id($id);
$controller->tpl->assign('name', $info['firstname']);
$controller->tpl->assign('my_user_id', api_get_user_id());
$controller->tpl->assign('my_subrole', get_subrole());
$controller->tpl->assign('part', 'rh');
$tpl = $controller->tpl->get_template('layout/mm_graph_eval.tpl');
$controller->tpl->display($tpl);
?>