/** * This method return a graph containing information about evaluations * inside courses in sessions, it's used inside get_block method for * showing it inside dashboard interface * @return string img html */ public function get_evaluations_courses_in_sessions_graph() { $graphs = array(); if (!empty($this->sessions)) { $session_ids = array_keys($this->sessions); foreach ($session_ids as $session_id) { $courses_code = array_keys(Tracking::get_courses_list_from_session($session_id)); $courses_graph = array(); foreach ($courses_code as $course_code) { $cats = Category::load(null, null, $course_code, null, null, $session_id); if (isset($cats) && isset($cats[0])) { $alleval = $cats[0]->get_evaluations(null, true, $course_code); $alllinks = $cats[0]->get_links(null, true); $users = get_all_users($alleval, $alllinks); $datagen = new FlatViewDataGenerator ($users, $alleval, $alllinks); $evaluation_sumary = $datagen->get_evaluation_sumary_results(); if (!empty($evaluation_sumary)) { $items = array_keys($evaluation_sumary); $max = $min = $avg = array(); foreach ($evaluation_sumary as $evaluation) { $max[] = $evaluation['max']; $min[] = $evaluation['min']; $avg[] = $evaluation['avg']; } // Dataset definition $data_set = new pData; $data_set->AddPoint($max, "Max"); $data_set->AddPoint($avg, "Avg"); $data_set->AddPoint($min, "Min"); $data_set->AddPoint($items, "Items"); $data_set->SetXAxisName(get_lang('EvaluationName')); $data_set->SetYAxisName(get_lang('Percentage')); $data_set->AddAllSeries(); $data_set->RemoveSerie("Items"); $data_set->SetAbsciseLabelSerie("Items"); $graph_id = $this->user_id.'StudentEvaluationGraph'; $cache = new pCache(); // the graph id $data = $data_set->GetData(); if ($cache->IsInCache($graph_id, $data)) { //if we already created the img $img_file = $cache->GetHash($graph_id, $data); } else { // Initialise the graph $angle = -30; $test = new pChart($this->bg_width, $this->bg_height); $test->setFontProperties(api_get_path(LIBRARY_PATH) . 'pchart/fonts/tahoma.ttf', 8); $test->fixHeightByRotation( $data_set->GetData(), $data_set->GetDataDescription(), $angle ); $test->setGraphArea(50, 30, $this->bg_width - 75, $this->bg_height - 75); $test->drawFilledRoundedRectangle( 7, 7, $this->bg_width - 20, $test->YSize - 20, 5, 240, 240, 240 ); $test->drawRoundedRectangle( 5, 5, $this->bg_width - 18, $test->YSize - 18, 5, 230, 230, 230 ); $test->drawGraphArea(255,255,255,TRUE); $test->setFixedScale(0,100,5); $test->drawScale( $data_set->GetData(), $data_set->GetDataDescription(), SCALE_ADDALL, 150, 150, 150, TRUE, $angle, 2, TRUE ); $test->setColorPalette(0,105,221,34); $test->setColorPalette(1,255,135,30); $test->setColorPalette(2,255,0,0); $test->drawGrid(4,TRUE,230,230,230,50); // Draw the 0 line $test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',6); $test->drawTreshold(0,143,55,72,TRUE,TRUE); // Draw the bar graph $test->drawOverlayBarGraph($data_set->GetData(),$data_set->GetDataDescription(), 100); // Finish the graph $test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',8); $test->drawLegend($this->bg_width-80,20,$data_set->GetDataDescription(),255,255,255); $test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',10); $test->setColorPalette(0,50,50,50); $test->setColorPalette(1,50,50,50); $test->setColorPalette(2,50,50,50); $test->writeValues($data_set->GetData(),$data_set->GetDataDescription(),array("Min", "Max", "Avg")); $cache->WriteToCache($graph_id, $data_set->GetData(), $test); ob_start(); $test->Stroke(); ob_end_clean(); $img_file = $cache->GetHash($graph_id, $data_set->GetData()); } if (!empty($img_file)) { $courses_graph[$course_code] = '<img src="'.api_get_path(WEB_ARCHIVE_PATH).$img_file.'">'; } } } } if (!empty($courses_graph)) { $graphs[$session_id] = $courses_graph; } } } return $graphs; }
/** * This method return a content html, it's used inside get_block method for showing it inside dashboard interface * @return string content html */ public function get_content_html() { $content = ''; $sessions = $this->sessions; //$content = '<div style="margin:10px;">'; $content .= '<h4>' . get_lang('YourSessionsList') . '</h4>'; if (count($sessions) > 0) { $sessions_table = '<table class="data_table" width:"95%">'; $sessions_table .= '<tr> <th >' . get_lang('Title') . '</th> <th >' . get_lang('Date') . '</th> <th width="100px">' . get_lang('NbCoursesPerSession') . '</th> </tr>'; $i = 1; foreach ($sessions as $session) { $session_id = intval($session['id']); $title = $session['name']; if ($session['access_start_date'] != '0000-00-00 00:00:00' && $session['access_end_date'] != '0000-00-00 00:00:00') { $date = get_lang('From') . ' ' . api_convert_and_format_date($session['access_start_date'], DATE_FORMAT_SHORT, date_default_timezone_get()) . ' ' . get_lang('To') . ' ' . api_convert_and_format_date($session['access_end_date'], DATE_FORMAT_SHORT, date_default_timezone_get()); } else { $date = ' - '; } $count_courses_in_session = count(Tracking::get_courses_list_from_session($session_id)); if ($i % 2 == 0) { $class_tr = 'row_odd'; } else { $class_tr = 'row_even'; } $sessions_table .= '<tr class="' . $class_tr . '"> <td>' . $title . '</td> <td align="center">' . $date . '</td> <td align="center">' . $count_courses_in_session . '</td> </tr>'; $i++; } $sessions_table .= '</table>'; $content .= $sessions_table; } else { $content .= get_lang('ThereIsNoInformationAboutYourSessions'); } if (count($sessions) > 0) { $content .= '<div style="text-align:right;margin-top:10px;"><a href="' . api_get_path(WEB_CODE_PATH) . 'mySpace/session.php">' . get_lang('SeeMore') . '</a></div>'; } //$content .= '</div>'; return $content; }
} else { $row['details'] = '<a href="' . api_get_self() . '?session_id=' . $session['id'] . '"><img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a>'; } $all_data[] = $row; } echo "<script>\n \$(function() {\n " . Display::grid_js('sessions', null, $columns, $column_model, $extra_params, $all_data) . "\n });\n </script>"; $nb_sessions_past = $nb_sessions_current = 0; $courses = array(); foreach ($sessions as $session) { $visibility = api_get_session_visibility($session['id']); if ($visibility == SESSION_AVAILABLE) { $nb_sessions_current++; } else { $nb_sessions_past++; } $courses = array_merge($courses, Tracking::get_courses_list_from_session($session['id'])); } $nb_courses_per_session = null; $nb_students_per_session = null; if ($count_sessions > 0) { $nb_courses_per_session = round(count($courses) / $count_sessions, 2); $nb_students_per_session = round($nb_students / $count_sessions, 2); } if ($export_csv) { //csv part $csv_content[] = array(get_lang('Sessions', '')); $csv_content[] = array(get_lang('NbActiveSessions', '') . ';' . $nb_sessions_current); $csv_content[] = array(get_lang('NbInactiveSessions', '') . ';' . $nb_sessions_past); //$csv_content[] = array(get_lang('NbFutureSessions', '').';'.$nb_sessions_future); $csv_content[] = array(get_lang('NbCoursesPerSession', '') . ';' . $nb_courses_per_session); $csv_content[] = array(get_lang('NbStudentPerSession', '') . ';' . $nb_students_per_session);
if (api_is_drh() || api_is_session_admin() || api_is_platform_admin()) { $title = ''; if (empty($id_session)) { if (isset($_GET['user_id'])) { $user_id = intval($_GET['user_id']); $user_info = api_get_user_info($user_id); $title = get_lang('AssignedCoursesTo') . ' ' . api_get_person_name($user_info['firstname'], $user_info['lastname']); $courses = CourseManager::get_course_list_of_user_as_course_admin($user_id); } else { $title = get_lang('YourCourseList'); $courses = CourseManager::get_courses_followed_by_drh($_user['user_id']); } } else { $session_name = api_get_session_name($id_session); $title = api_htmlentities($session_name, ENT_QUOTES, $charset) . ' : ' . get_lang('CourseListInSession'); $courses = Tracking::get_courses_list_from_session($id_session); } $a_courses = array_keys($courses); if (!api_is_session_admin()) { $menu_items[] = Display::url(Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . "auth/my_progress.php"); $menu_items[] = Display::url(Display::return_icon('user.png', get_lang('Students'), array(), 32), "index.php?view=drh_students&display=yourstudents"); $menu_items[] = Display::url(Display::return_icon('teacher.png', get_lang('Trainers'), array(), 32), 'teachers.php'); $menu_items[] = Display::return_icon('course_na.png', get_lang('Courses'), array(), 32); $menu_items[] = Display::url(Display::return_icon('session.png', get_lang('Sessions'), array(), 32), 'session.php'); } echo '<div class="actions">'; $nb_menu_items = count($menu_items); if ($nb_menu_items > 1) { foreach ($menu_items as $key => $item) { echo $item; }
/** * This method return a graph containing information about evaluations * inside courses in sessions, it's used inside get_block method for * showing it inside dashboard interface * @return string img html */ public function get_evaluations_courses_in_sessions_graph() { $graphs = array(); if (!empty($this->sessions)) { $session_ids = array_keys($this->sessions); foreach ($session_ids as $session_id) { $courses_code = array_keys(Tracking::get_courses_list_from_session($session_id)); $courses_graph = array(); foreach ($courses_code as $course_code) { $cats = Category::load(null, null, $course_code, null, null, $session_id); if (isset($cats) && isset($cats[0])) { $alleval = $cats[0]->get_evaluations(null, true, $course_code); $alllinks = $cats[0]->get_links(null, true); $users = GradebookUtils::get_all_users($alleval, $alllinks); $datagen = new FlatViewDataGenerator($users, $alleval, $alllinks); $evaluation_sumary = $datagen->get_evaluation_sumary_results(); if (!empty($evaluation_sumary)) { $items = array_keys($evaluation_sumary); $max = $min = $avg = array(); foreach ($evaluation_sumary as $evaluation) { $max[] = $evaluation['max']; $min[] = $evaluation['min']; $avg[] = $evaluation['avg']; } // Dataset definition $dataSet = new pData(); $dataSet->addPoints($min, 'Serie3'); $dataSet->addPoints($avg, 'Serie2'); $dataSet->addPoints($max, 'Serie1'); $dataSet->addPoints($items, 'Labels'); $dataSet->setSerieDescription('Serie1', get_lang('Max')); $dataSet->setSerieDescription('Serie2', get_lang('Avg')); $dataSet->setSerieDescription('Serie3', get_lang('Min')); $dataSet->setAbscissa('Labels'); $dataSet->setAbscissaName(get_lang('EvaluationName')); $dataSet->normalize(100, '%'); $dataSet->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true); // Cache definition $cachePath = api_get_path(SYS_ARCHIVE_PATH); $myCache = new pCache(array('CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1))); $chartHash = $myCache->getHash($dataSet); if ($myCache->isInCache($chartHash)) { $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash; $myCache->saveFromCache($chartHash, $imgPath); $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash; } else { /* Create the pChart object */ $widthSize = $this->bg_width; $heightSize = $this->bg_height; $fontSize = 8; $angle = 50; $myPicture = new pImage($widthSize, $heightSize, $dataSet); /* Turn of Antialiasing */ $myPicture->Antialias = false; /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, $widthSize - 1, $heightSize - 1, array('R' => 0, 'G' => 0, 'B' => 0)); /* Set the default font */ $myPicture->setFontProperties(array('FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', 'FontSize' => 10)); /* Do NOT Write the chart title */ /* Define the chart area */ $myPicture->setGraphArea(50, 30, $widthSize - 20, $heightSize - 100); /* Draw the scale */ $scaleSettings = array('GridR' => 200, 'GridG' => 200, 'GridB' => 200, 'DrawSubTicks' => true, 'CycleBackground' => true, 'Mode' => SCALE_MODE_MANUAL, 'ManualScale' => array('0' => array('Min' => 0, 'Max' => 100)), 'LabelRotation' => $angle); $myPicture->drawScale($scaleSettings); /* Turn on shadow computing */ $myPicture->setShadow(true, array('X' => 1, 'Y' => 1, 'R' => 0, 'G' => 0, 'B' => 0, 'Alpha' => 10)); /* Draw the chart */ $myPicture->setShadow(true, array('X' => 1, 'Y' => 1, 'R' => 0, 'G' => 0, 'B' => 0, 'Alpha' => 10)); $settings = array('DisplayValues' => true, 'DisplaySize' => $fontSize, 'DisplayR' => 0, 'DisplayG' => 0, 'DisplayB' => 0, 'DisplayOrientation' => ORIENTATION_HORIZONTAL, 'Gradient' => false, 'Surrounding' => 30, 'InnerSurrounding' => 25); $myPicture->drawStackedBarChart($settings); $legendSettings = array('Mode' => LEGEND_HORIZONTAL, 'Style' => LEGEND_NOBORDER); $myPicture->drawLegend($widthSize / 2, 15, $legendSettings); /* Write and save into cache */ $myCache->writeToCache($chartHash, $myPicture); $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash; $myCache->saveFromCache($chartHash, $imgPath); $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash; } if (!empty($imgPath)) { $courses_graph[$course_code] = '<img src="' . $imgPath . '">'; } } } } if (!empty($courses_graph)) { $graphs[$session_id] = $courses_graph; } } } return $graphs; }
$courses_in_session = array(); //See #4676 $drh_can_access_all_courses = false; if (api_is_drh() || api_is_platform_admin() || api_is_student_boss()) { $drh_can_access_all_courses = true; } $courses = CourseManager::get_course_list_of_user_as_course_admin(api_get_user_id()); $courses_in_session_by_coach = array(); $sessions_coached_by_user = Tracking::get_sessions_coached_by_user(api_get_user_id()); // RRHH or session admin if (api_is_session_admin() || api_is_drh()) { $courses = CourseManager::get_courses_followed_by_drh(api_get_user_id()); $session_by_session_admin = SessionManager::get_sessions_followed_by_drh(api_get_user_id()); if (!empty($session_by_session_admin)) { foreach ($session_by_session_admin as $session_coached_by_user) { $courses_followed_by_coach = Tracking::get_courses_list_from_session($session_coached_by_user['id']); $courses_in_session_by_coach[$session_coached_by_user['id']] = $courses_followed_by_coach; } } } // Teacher or admin if (!empty($sessions_coached_by_user)) { foreach ($sessions_coached_by_user as $session_coached_by_user) { $sid = intval($session_coached_by_user['id']); $courses_followed_by_coach = Tracking::get_courses_followed_by_coach(api_get_user_id(), $sid); $courses_in_session_by_coach[$sid] = $courses_followed_by_coach; } } $sql = "SELECT c_id\n FROM {$tbl_course_user}\n WHERE\n relation_type <> " . COURSE_RELATION_TYPE_RRHH . " AND\n user_id = " . intval($user_info['user_id']); $rs = Database::query($sql); while ($row = Database::fetch_array($rs)) {
/** * This method return a content html, it's used inside get_block method for showing it inside dashboard interface * @return string content html */ public function get_content_html() { $content = ''; $sessions = $this->sessions; $content = '<div style="margin:10px;">'; $content .= '<h3><font color="#000">' . get_lang('YourSessionsList') . '</font></h3>'; if (count($sessions) > 0) { $sessions_table = '<table class="data_table" width:"95%">'; $sessions_table .= '<tr> <th >' . get_lang('Title') . '</th> <th >' . get_lang('Date') . '</th> <th width="100px">' . get_lang('NbCoursesPerSession') . '</th> </tr>'; $i = 1; foreach ($sessions as $session) { $session_id = intval($session['id']); $title = $session['name']; $date_string = SessionManager::parse_session_dates($session); $count_courses_in_session = count(Tracking::get_courses_list_from_session($session_id)); if ($i % 2 == 0) { $class_tr = 'row_odd'; } else { $class_tr = 'row_even'; } $sessions_table .= '<tr class="' . $class_tr . '"> <td>' . $title . '</td> <td align="center">' . $date_string . '</td> <td align="center">' . $count_courses_in_session . '</td> </tr>'; $i++; } $sessions_table .= '</table>'; $content .= $sessions_table; } else { $content .= get_lang('ThereIsNoInformationAboutYourSessions'); } if (count($sessions) > 0) { $content .= '<div style="text-align:right;margin-top:10px;"><a href="' . api_get_path(WEB_CODE_PATH) . 'mySpace/session.php">' . get_lang('SeeMore') . '</a></div>'; } $content .= '</div>'; return $content; }
$nb_sessions = count($a_sessions); if ($export_csv) { $csv_content = array(); } if ($nb_sessions > 0) { $table = new SortableTable('tracking', 'count_sessions_coached'); $table->set_header(0, get_lang('Title')); $table->set_header(1, get_lang('Date')); $table->set_header(2, get_lang('NbCoursesPerSession')); $table->set_header(3, get_lang('Details'), false); $all_data = array(); foreach ($a_sessions as $session) { $row = array(); $row[] = $session['name']; $row[] = SessionManager::parse_session_dates($session); $row[] = count(Tracking::get_courses_list_from_session($session['id'])); if ($export_csv) { $csv_content[] = $row; } if (isset($_GET['id_coach']) && $_GET['id_coach'] != '') { $row[] = '<a href="student.php?id_session=' . $session['id'] . '&id_coach=' . intval($_GET['id_coach']) . '"><img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a>'; } else { $row[] = '<a href="course.php?id_session=' . $session['id'] . '"><img src="' . api_get_path(WEB_IMG_PATH) . '2rightarrow.gif" border="0" /></a>'; } $all_data[] = $row; } if (!isset($tracking_column)) { $tracking_column = 0; } if ($_GET['tracking_direction'] == 'DESC') { usort($all_data, 'rsort_sessions');
if (api_is_drh() || api_is_session_admin() || api_is_platform_admin()) { $title = ''; if (empty($sessionId)) { if (isset($_GET['user_id'])) { $user_id = intval($_GET['user_id']); $user_info = api_get_user_info($user_id); $title = get_lang('AssignedCoursesTo') . ' ' . api_get_person_name($user_info['firstname'], $user_info['lastname']); $courses = CourseManager::get_course_list_of_user_as_course_admin($user_id); } else { $title = get_lang('YourCourseList'); $courses = CourseManager::get_courses_followed_by_drh(api_get_user_id()); } } else { $session_name = api_get_session_name($sessionId); $title = api_htmlentities($session_name, ENT_QUOTES, $charset) . ' : ' . get_lang('CourseListInSession'); $courses = Tracking::get_courses_list_from_session($sessionId); } $a_courses = array_keys($courses); if (!api_is_session_admin()) { $menu_items[] = Display::url(Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . "auth/my_progress.php"); $menu_items[] = Display::url(Display::return_icon('user.png', get_lang('Students'), array(), ICON_SIZE_MEDIUM), "index.php?view=drh_students&display=yourstudents"); $menu_items[] = Display::url(Display::return_icon('teacher.png', get_lang('Trainers'), array(), ICON_SIZE_MEDIUM), 'teachers.php'); $menu_items[] = Display::url(Display::return_icon('course_na.png', get_lang('Courses'), array(), ICON_SIZE_MEDIUM), '#'); $menu_items[] = Display::url(Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_MEDIUM), 'session.php'); if (api_can_login_as($user_id)) { $link = '<a href="' . api_get_path(WEB_CODE_PATH) . 'admin/user_list.php?action=login_as&user_id=' . $user_id . '&sec_token=' . Security::get_existing_token() . '">' . Display::return_icon('login_as.png', get_lang('LoginAs'), null, ICON_SIZE_MEDIUM) . '</a> '; $menu_items[] = $link; } } $actionsLeft = $actionsRight = ''; $nb_menu_items = count($menu_items);