Minor - format code

pull/2487/head
jmontoyaa 8 years ago
parent 33a4ff908c
commit ee625ef1bc
  1. 20
      main/coursecopy/copy_course_session.php
  2. 34
      main/webservices/access_url.php
  3. 9
      plugin/buycourses/src/service_process_confirm.php
  4. 25
      plugin/buycourses/src/service_success.php
  5. 5
      plugin/buycourses/src/services_edit.php
  6. 16
      plugin/buycourses/src/success.php
  7. 14
      plugin/dashboard/block_course/block_course.class.php
  8. 6
      plugin/dashboard/block_daily/block_daily.class.php
  9. 232
      plugin/dashboard/block_evaluation_graph/block_evaluation_graph.class.php
  10. 120
      plugin/dashboard/block_global_info/block_global_info.class.php
  11. 212
      plugin/dashboard/block_session/block_session.class.php
  12. 358
      plugin/dashboard/block_student/block_student.class.php
  13. 195
      plugin/dashboard/block_student_graph/block_student_graph.class.php
  14. 3
      plugin/dashboard/block_teacher/block_teacher.class.php
  15. 157
      plugin/dashboard/block_teacher_graph/block_teacher_graph.class.php

@ -48,8 +48,12 @@ $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
/* FUNCTIONS */
/**
* @param string $name
* @param array $sessions
* @param array $attr
* @return string
*/
function make_select_session_list($name, $sessions, $attr = array())
{
$attributes = '';
@ -83,6 +87,9 @@ function make_select_session_list($name, $sessions, $attr = array())
return $output;
}
/**
* @return string
*/
function display_form()
{
$html = '';
@ -138,6 +145,11 @@ function display_form()
echo $html;
}
/**
* @param int $id_session
* @param string $type
* @return xajaxResponse
*/
function search_courses($id_session, $type)
{
global $tbl_course, $tbl_session_rel_course, $course_list;
@ -221,12 +233,12 @@ function search_courses($id_session, $type)
);
}
}
return $xajax_response;
}
$xajax->processRequests();
/* HTML head extra */
$htmlHeadXtra[] = $xajax->getJavascript(api_get_path(WEB_LIBRARY_PATH).'xajax/');
$htmlHeadXtra[] = '<script>
function checkSelected(id_select,id_radio,id_title,id_destination) {
@ -278,7 +290,7 @@ if (Security::check_token('post') && (
// Clear token
Security::clear_token();
$destination_course = $origin_course = $destination_session = $origin_session = '';
if (isset ($_POST['action']) && $_POST['action'] == 'course_select_form') {
if (isset($_POST['action']) && $_POST['action'] == 'course_select_form') {
$destination_course = $_POST['destination_course'];
$origin_course = $_POST['origin_course'];
$destination_session = $_POST['destination_session'];

@ -62,19 +62,22 @@ function WSHelperVerifyKey($params)
list($ip1, $ip2) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
$ip = trim($ip1);
}
if ($debug)
if ($debug) {
error_log("ip: $ip");
}
// Check if a file that limits access from webservices exists and contains
// the restraining check
if (is_file('webservice-auth-ip.conf.php')) {
include 'webservice-auth-ip.conf.php';
if ($debug)
if ($debug) {
error_log("webservice-auth-ip.conf.php file included");
}
if (!empty($ws_auth_ip)) {
$check_ip = true;
$ip_matches = api_check_ip_in_range($ip, $ws_auth_ip);
if ($debug)
if ($debug) {
error_log("ip_matches: $ip_matches");
}
}
}
@ -91,8 +94,9 @@ function WSHelperVerifyKey($params)
$result = api_is_valid_secret_key($secret_key, $security_key);
//error_log($secret_key.'-'.$security_key);
if ($debug)
if ($debug) {
error_log('WSHelperVerifyKey result: '.intval($result));
}
return $result;
}
@ -114,8 +118,6 @@ $server->soap_defencoding = 'UTF-8';
// Initialize WSDL support
$server->configureWSDL('WSAccessUrl', 'urn:WSAccessUrl');
$server->wsdl->addComplexType(
'portalItem',
'complexType',
@ -135,7 +137,13 @@ $server->wsdl->addComplexType(
'',
'SOAP-ENC:Array',
array(),
array(array('ref'=>'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:portalItem[]')), 'tns:portalItem'
array(
array(
'ref' => 'SOAP-ENC:arrayType',
'wsdl:arrayType' => 'tns:portalItem[]',
),
),
'tns:portalItem'
);
$server->wsdl->addComplexType(
@ -197,7 +205,8 @@ $server->wsdl->addComplexType(
);
// Register the method to expose
$server->register('WSAddUserToPortal', // method name
$server->register(
'WSAddUserToPortal', // method name
array('addUserToPortal' => 'tns:AddUserToPortal'), // input parameters
array('return' => 'xsd:string'), // output parameters
'urn:WSAccessUrl', // namespace
@ -228,7 +237,8 @@ function WSAddUserToPortal($params)
}
// Register the method to expose
$server->register('WSRemoveUserFromPortal', // method name
$server->register(
'WSRemoveUserFromPortal', // method name
array('removeUserFromPortal' => 'tns:AddUserToPortal'), // input parameters
array('return' => 'xsd:string'), // output parameters
'urn:WSAccessUrl', // namespace
@ -271,7 +281,8 @@ $server->wsdl->addComplexType(
);
// Register the method to expose
$server->register('WSGetPortalListFromUser', // method name
$server->register(
'WSGetPortalListFromUser', // method name
array('getPortalListFromUser' => 'tns:getPortalListFromUser'), // input parameters
array('return' => 'tns:portalList'), // output parameters
'urn:WSAccessUrl', // namespace
@ -315,7 +326,8 @@ $server->wsdl->addComplexType(
);
// Register the method to expose
$server->register('WSGetPortalListFromCourse', // method name
$server->register(
'WSGetPortalListFromCourse', // method name
array('getPortalListFromCourse' => 'tns:getPortalListFromCourse'), // input parameters
array('return' => 'tns:portalList'), // output parameters
'urn:WSAccessUrl', // namespace

@ -83,7 +83,14 @@ switch ($serviceSale['payment_type']) {
case BuyCoursesPlugin::PAYMENT_TYPE_TRANSFER:
$transferAccounts = $plugin->getTransferAccounts();
$form = new FormValidator('success', 'POST', api_get_self(), null, null, FormValidator::LAYOUT_INLINE);
$form = new FormValidator(
'success',
'POST',
api_get_self(),
null,
null,
FormValidator::LAYOUT_INLINE
);
if ($form->validate()) {
$formValues = $form->getSubmitValues();

@ -15,7 +15,6 @@ if (!$paypalEnabled) {
}
$serviceSaleId = $_SESSION['bc_service_sale_id'];
$serviceSale = $plugin->getServiceSale($serviceSaleId);
$itemPrice = $serviceSale['price'];
@ -34,8 +33,20 @@ require_once("paypalfunctions.php");
$buyerInformation = GetShippingDetails(urlencode($_SESSION['TOKEN']));
$form = new FormValidator('success', 'POST', api_get_self(), null, null, FormValidator::LAYOUT_INLINE);
$form->addButton('confirm', $plugin->get_lang('ConfirmOrder'), 'check', 'success');
$form = new FormValidator(
'success',
'POST',
api_get_self(),
null,
null,
FormValidator::LAYOUT_INLINE
);
$form->addButton(
'confirm',
$plugin->get_lang('ConfirmOrder'),
'check',
'success'
);
$form->addButtonCancel($plugin->get_lang('CancelOrder'), 'cancel');
if ($form->validate()) {
@ -54,7 +65,6 @@ if ($form->validate()) {
}
$confirmPayments = ConfirmPayment($itemPrice);
if ($confirmPayments['ACK'] !== 'Success') {
$erroMessage = vsprintf(
$plugin->get_lang('ErrorOccurred'),
@ -154,16 +164,17 @@ if ($form->validate()) {
}
$token = isset($_GET['token']) ? Security::remove_XSS($_GET['token']) : null;
if (empty($token)) {
api_not_allowed(true);
}
$interbreadcrumb[] = array("url" => "service_catalog.php", "name" => $plugin->get_lang('ListOfServicesOnSale'));
$interbreadcrumb[] = array(
"url" => "service_catalog.php",
"name" => $plugin->get_lang('ListOfServicesOnSale'),
);
$templateName = $plugin->get_lang('PaymentMethods');
$tpl = new Template($templateName);
$tpl->assign('title', $serviceSale['service']['name']);
$tpl->assign('price', $serviceSale['price']);
$tpl->assign('currency', $serviceSale['currency_id']);

@ -131,21 +131,16 @@ if ($form->validate()) {
$values = $form->getSubmitValues();
if (isset($values['delete_service'])) {
$plugin->deleteService($serviceId);
Display::addFlash(
Display::return_message($plugin->get_lang('ServiceDeleted'), 'error')
);
} else {
$plugin->updateService($values, $serviceId);
Display::addFlash(
Display::return_message($plugin->get_lang('ServiceEdited'), 'success')
);
}
header('Location: configuration.php');
exit;
}

@ -44,7 +44,14 @@ $paypalSignature = $paypalParams['signature'];
require_once("paypalfunctions.php");
$form = new FormValidator('success', 'POST', api_get_self(), null, null, FormValidator::LAYOUT_INLINE);
$form = new FormValidator(
'success',
'POST',
api_get_self(),
null,
null,
FormValidator::LAYOUT_INLINE
);
$form->addButton('confirm', $plugin->get_lang('ConfirmOrder'), 'check', 'success');
$form->addButtonCancel($plugin->get_lang('CancelOrder'), 'cancel');
@ -74,13 +81,12 @@ if ($form->validate()) {
exit;
}
$transactionId = $confirmPayments["PAYMENTINFO_0_TRANSACTIONID"];
$transactionType = $confirmPayments["PAYMENTINFO_0_TRANSACTIONTYPE"];
$transactionId = $confirmPayments['PAYMENTINFO_0_TRANSACTIONID'];
$transactionType = $confirmPayments['PAYMENTINFO_0_TRANSACTIONTYPE'];
switch ($confirmPayments["PAYMENTINFO_0_PAYMENTSTATUS"]) {
switch ($confirmPayments['PAYMENTINFO_0_PAYMENTSTATUS']) {
case 'Completed':
$saleIsCompleted = $plugin->completeSale($sale['id']);
if ($saleIsCompleted && $buyingSession) {
Display::addFlash(
Display::return_message(

@ -7,7 +7,8 @@
*/
/**
* This class is used like controller for this course block plugin,
* the class name must be registered inside path.info file (e.g: controller = "BlockCourse"), so dashboard controller will be instantiate it
* the class name must be registered inside path.info file
* (e.g: controller = "BlockCourse"), so dashboard controller will be instantiate it
* @package chamilo.dashboard
*/
class BlockCourse extends Block
@ -51,7 +52,8 @@ class BlockCourse extends Block
}
/**
* This method return content html containing information about courses and its position for showing it inside dashboard interface
* This method return content html containing information
* about courses and its position for showing it inside dashboard interface
* it's important to use the name 'get_block' for beeing used from dashboard controller
* @return array column and content html
*/
@ -92,10 +94,7 @@ class BlockCourse extends Block
public function get_content_html()
{
$course_data = $this->get_course_information_data();
//$content = '<div style="margin:10px;">';
$content = '<h4>'.get_lang(
'YourCourseList'
).'</h4>';
$content = '<h4>'.get_lang('YourCourseList').'</h4>';
$data_table = null;
if (!empty($course_data)) {
$data_table .= '<table class="data_table" width:"95%">';
@ -172,7 +171,8 @@ class BlockCourse extends Block
if (count($users) > 0) {
$nb_students_in_course = count($users);
$avg_time_spent_in_course = api_time_to_hms(
Tracking::get_time_spent_on_the_course($users, $courseId) / $nb_students_in_course);
Tracking::get_time_spent_on_the_course($users, $courseId) / $nb_students_in_course
);
} else {
$avg_time_spent_in_course = null;
}

@ -66,7 +66,6 @@ class BlockDaily extends Block
*/
public function get_block()
{
global $charset;
$column = 2;
$data = array();
@ -101,10 +100,7 @@ class BlockDaily extends Block
public function get_content_html()
{
$course_data = $this->get_course_information_data();
//$content = '<div style="margin:10px;">';
$content = '<h4>'.get_lang(
'YourCourseList'
).'</h4>';
$content = '<h4>'.get_lang('YourCourseList').'</h4>';
$data_table = null;
if (!empty($course_data)) {
$data_table .= '<table class="data_table" width:"95%">';

@ -5,7 +5,6 @@ use CpChart\Chart\Data as pData;
use CpChart\Chart\Image as pImage;
use CpChart\Chart\Cache as pCache;
/**
* Class BlockEvaluationGraph
* This class is used like controller for this evaluations graph block plugin,
@ -23,59 +22,59 @@ use CpChart\Chart\Cache as pCache;
class BlockEvaluationGraph extends Block
{
private $user_id;
private $courses;
private $sessions;
private $path;
private $permission = array(DRH, SESSIONADMIN);
/**
* Constructor
*/
private $courses;
private $sessions;
private $path;
private $permission = array(DRH, SESSIONADMIN);
/**
* Constructor
*/
public function __construct($user_id)
{
$this->path = 'block_evaluation_graph';
$this->user_id = $user_id;
$this->bg_width = 450;
$this->bg_height = 350;
if ($this->is_block_visible_for_user($user_id)) {
$this->path = 'block_evaluation_graph';
$this->user_id = $user_id;
$this->bg_width = 450;
$this->bg_height = 350;
if ($this->is_block_visible_for_user($user_id)) {
if (!api_is_session_admin()) {
$this->courses = CourseManager::get_courses_followed_by_drh($user_id);
}
$this->sessions = SessionManager::get_sessions_followed_by_drh($user_id);
}
}
}
/**
* This method check if a user is allowed to see the block inside dashboard interface
* @param int User id
* @return bool Is block visible for user
*/
/**
* This method check if a user is allowed to see the block inside dashboard interface
* @param int User id
* @return bool Is block visible for user
*/
public function is_block_visible_for_user($user_id)
{
$user_info = api_get_user_info($user_id);
$user_status = $user_info['status'];
$is_block_visible_for_user = false;
if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) {
$is_block_visible_for_user = true;
}
return $is_block_visible_for_user;
$user_info = api_get_user_info($user_id);
$user_status = $user_info['status'];
$is_block_visible_for_user = false;
if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) {
$is_block_visible_for_user = true;
}
return $is_block_visible_for_user;
}
/**
* This method return content html containing information about sessions and its position for showing it inside dashboard interface
* This method return content html containing
* information about sessions and its position for showing it inside dashboard interface
* it's important to use the name 'get_block' for beeing used from dashboard controller
* @return array column and content html
*/
public function get_block()
{
global $charset;
$column = 1;
$data = array();
$evaluations_base_courses_graph = $this->get_evaluations_base_courses_graph();
$evaluations_courses_in_sessions_graph = $this->get_evaluations_courses_in_sessions_graph();
global $charset;
$column = 1;
$data = array();
$evaluations_base_courses_graph = $this->get_evaluations_base_courses_graph();
$evaluations_courses_in_sessions_graph = $this->get_evaluations_courses_in_sessions_graph();
$html = '<div class="panel panel-default" id="intro">
$html = '<div class="panel panel-default" id="intro">
<div class="panel-heading">
'.get_lang('EvaluationsGraph').'
<div class="pull-right"><a class="btn btn-danger btn-xs" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">
@ -105,43 +104,51 @@ class BlockEvaluationGraph extends Block
}
}
}
$html .= '</div>
</div>';
$html .= '</div>
</div>';
$data['column'] = $column;
$data['content_html'] = $html;
$data['column'] = $column;
$data['content_html'] = $html;
return $data;
}
return $data;
}
/**
* This method return a graph containing informations about evaluations
* This method return a graph containing informations about evaluations
* inside base courses, it's used inside get_block method for showing
* it inside dashboard interface
* @return string img html
*/
* @return string img html
*/
public function get_evaluations_base_courses_graph()
{
$graphs = array();
if (!empty($this->courses)) {
$courses_code = array_keys($this->courses);
foreach ($courses_code as $course_code) {
$cats = Category::load(null, null, $course_code, null, null, null, false);
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'];
$graphs = array();
if (!empty($this->courses)) {
$courses_code = array_keys($this->courses);
foreach ($courses_code as $course_code) {
$cats = Category::load(
null,
null,
$course_code,
null,
null,
null,
false
);
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[] = !empty($evaluation['min']) ? $evaluation['min'] : 0;
$avg[] = $evaluation['avg'];
}
$avg[] = $evaluation['avg'];
}
// Dataset definition
$dataSet = new pData();
$dataSet->addPoints($min, 'Serie3');
@ -283,43 +290,43 @@ class BlockEvaluationGraph extends Block
if (!empty($imgPath)) {
$courses_graph[$course_code] = '<img src="'.$imgPath.'">';
}
}
}
} // end for
}
return $graphs;
}
/**
* This method return a graph containing information about evaluations
}
}
} // end for
}
return $graphs;
}
/**
* 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
*/
* @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'];
}
$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');
@ -331,16 +338,21 @@ class BlockEvaluationGraph extends Block
$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)));
$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;
@ -455,14 +467,14 @@ class BlockEvaluationGraph extends Block
if (!empty($imgPath)) {
$courses_graph[$course_code] = '<img src="'.$imgPath.'">';
}
}
}
}
if (!empty($courses_graph)) {
$graphs[$session_id] = $courses_graph;
}
}
}
return $graphs;
}
}
}
}
if (!empty($courses_graph)) {
$graphs[$session_id] = $courses_graph;
}
}
}
return $graphs;
}
}

@ -40,84 +40,84 @@ class BlockGlobalInfo extends Block
/**
* This method check if a user is allowed to see the block inside dashboard interface
* @param int User id
* @return bool Is block visible for user
* @param int User id
* @return bool Is block visible for user
*/
public function is_block_visible_for_user($user_id)
{
$user_info = api_get_user_info($user_id);
$user_status = $user_info['status'];
$is_block_visible_for_user = false;
if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) {
$is_block_visible_for_user = true;
}
return $is_block_visible_for_user;
$user_info = api_get_user_info($user_id);
$user_status = $user_info['status'];
$is_block_visible_for_user = false;
if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) {
$is_block_visible_for_user = true;
}
return $is_block_visible_for_user;
}
/**
* This method return content html containing information about courses and its position for showing it inside dashboard interface
* This method return content html containing information
* about courses and its position for showing it inside dashboard interface
* it's important to use the name 'get_block' for beeing used from dashboard controller
* @return array column and content html
*/
public function get_block()
{
global $charset;
$column = 2;
$data = array();
global $charset;
$column = 2;
$data = array();
$content = $this->get_content_html();
$html = '
<div class="panel panel-default" id="intro">
<div class="panel-heading">'.get_lang('GlobalPlatformInformation').'
<div class="pull-right"><a class="btn btn-danger btn-xs" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">
<em class="fa fa-times"></em>
</a></div>
</div>
<div class="panel-body">
'.$content.'
</div>
</div>
';
$data['column'] = $column;
$data['content_html'] = $html;
$html = '<div class="panel panel-default" id="intro">
<div class="panel-heading">'.get_lang('GlobalPlatformInformation').'
<div class="pull-right"><a class="btn btn-danger btn-xs" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">
<em class="fa fa-times"></em>
</a></div>
</div>
<div class="panel-body">
'.$content.'
</div>
</div>
';
$data['column'] = $column;
$data['content_html'] = $html;
return $data;
return $data;
}
/**
* 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()
{
$global_data = $this->get_global_information_data();
//$content = '<div style="margin:10px;">';
$content = '<h4>'.get_lang('GlobalPlatformInformation').'</h4>';
$data_table = null;
if (!empty($global_data)) {
$data_table = '<table class="table table-bordered" width="95%">';
$i = 1;
foreach ($global_data as $data) {
if ($i % 2 == 0) {
$class_tr = 'row_odd';
} else {
$class_tr = 'row_even';
}
$data_table .= '<tr class="'.$class_tr.'">';
foreach ($data as $cell) {
$data_table .= '<td align="right">'.$cell.'</td>';
}
$data_table .= '</tr>';
$i++;
}
$data_table .= '</table>';
} else {
$data_table .= get_lang('ThereIsNoInformationAboutThePlatform');
}
$content .= $data_table;
//$content .= '</div>';
* 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()
{
$global_data = $this->get_global_information_data();
$content = '<h4>'.get_lang('GlobalPlatformInformation').'</h4>';
$data_table = null;
if (!empty($global_data)) {
$data_table = '<table class="table table-bordered" width="95%">';
$i = 1;
foreach ($global_data as $data) {
if ($i % 2 == 0) {
$class_tr = 'row_odd';
} else {
$class_tr = 'row_even';
}
$data_table .= '<tr class="'.$class_tr.'">';
foreach ($data as $cell) {
$data_table .= '<td align="right">'.$cell.'</td>';
}
$data_table .= '</tr>';
$i++;
}
$data_table .= '</table>';
} else {
$data_table .= get_lang('ThereIsNoInformationAboutThePlatform');
}
$content .= $data_table;
//$content .= '</div>';
return $content;
return $content;
}
/**

@ -15,101 +15,92 @@
class BlockSession extends Block
{
private $user_id;
private $sessions;
private $path;
private $permission = array(DRH, SESSIONADMIN);
private $sessions;
private $path;
private $permission = array(DRH, SESSIONADMIN);
/**
* Constructor
*/
/**
* Constructor
*/
public function __construct($user_id)
{
$this->user_id = $user_id;
$this->path = 'block_session';
if ($this->is_block_visible_for_user($user_id)) {
$this->user_id = $user_id;
$this->path = 'block_session';
if ($this->is_block_visible_for_user($user_id)) {
$this->sessions = SessionManager::get_sessions_followed_by_drh($user_id);
}
}
}
/**
* This method check if a user is allowed to see the block inside dashboard interface
* @param int User id
* @return bool Is block visible for user
*/
/**
* This method check if a user is allowed to see the block inside dashboard interface
* @param int User id
* @return bool Is block visible for user
*/
public function is_block_visible_for_user($user_id)
{
$user_info = api_get_user_info($user_id);
$user_status = $user_info['status'];
$is_block_visible_for_user = false;
if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) {
$is_block_visible_for_user = true;
}
return $is_block_visible_for_user;
$user_info = api_get_user_info($user_id);
$user_status = $user_info['status'];
$is_block_visible_for_user = false;
if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) {
$is_block_visible_for_user = true;
}
return $is_block_visible_for_user;
}
/**
* This method return content html containing information about sessions and its position for showing it inside dashboard interface
* This method return content html containing
* information about sessions and its position for showing it inside dashboard interface
* it's important to use the name 'get_block' for beeing used from dashboard controller
* @return array column and content html
*/
public function get_block()
{
global $charset;
$column = 2;
$data = array();
$content = $this->get_content_html();
$content_html = '
<div class="panel panel-default" id="intro">
<div class="panel-heading">
'.get_lang('SessionsInformation').'
<div class="pull-right"><a class="btn btn-danger btn-xs" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">
<em class="fa fa-times"></em>
</a></div>
</div>
<div class="panel-body">
'.$content.'
</div>
</div>
';
$data['column'] = $column;
$data['content_html'] = $content_html;
return $data;
global $charset;
$column = 2;
$data = array();
$content = $this->get_content_html();
$content_html = '<div class="panel panel-default" id="intro">
<div class="panel-heading">
'.get_lang('SessionsInformation').'
<div class="pull-right"><a class="btn btn-danger btn-xs" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">
<em class="fa fa-times"></em>
</a></div>
</div>
<div class="panel-body">
'.$content.'
</div>
</div>
';
$data['column'] = $column;
$data['content_html'] = $content_html;
return $data;
}
/**
* This method return a content html, it's used inside get_block method for showing it inside dashboard interface
* @return string content html
*/
* 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 (!empty($session['access_start_date'])) {
$dateFrom = api_convert_and_format_date(
$content = '';
$sessions = $this->sessions;
$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 (!empty($session['access_start_date'])) {
$dateFrom = api_convert_and_format_date(
$session['access_start_date'],
DATE_FORMAT_SHORT,
date_default_timezone_get()
@ -121,44 +112,45 @@ class BlockSession extends Block
);
$date = vsprintf(get_lang('FromDateXToDateY'), [$dateFrom, $dateUntil]);
} 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 {
$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>';
}
return $content;
}
/**
* Get number of sessions
* @return int
*/
function get_number_of_sessions()
* Get number of sessions
* @return int
*/
function get_number_of_sessions()
{
return count($this->sessions);
}
return count($this->sessions);
}
}

@ -8,57 +8,58 @@
/**
* This class is used like controller for student block plugin,
* the class name must be registered inside path.info file (e.g: controller = "BlockStudent"), so dashboard controller will be instantiate it
* the class name must be registered inside path.info file
* (e.g: controller = "BlockStudent"), so dashboard controller will be instantiate it
* @package chamilo.dashboard
*/
class BlockStudent extends Block
{
private $user_id;
private $students;
private $path;
private $permission = array(DRH);
private $students;
private $path;
private $permission = array(DRH);
/**
* Constructor
*/
/**
* Constructor
*/
public function __construct($user_id)
{
$this->user_id = $user_id;
$this->path = 'block_student';
if ($this->is_block_visible_for_user($user_id)) {
$this->user_id = $user_id;
$this->path = 'block_student';
if ($this->is_block_visible_for_user($user_id)) {
$this->students = UserManager::get_users_followed_by_drh($user_id, STUDENT);
}
}
}
/**
* This method check if a user is allowed to see the block inside dashboard interface
* @param int User id
* @return bool Is block visible for user
*/
* This method check if a user is allowed to see the block inside dashboard interface
* @param int User id
* @return bool Is block visible for user
*/
public function is_block_visible_for_user($user_id)
{
$user_info = api_get_user_info($user_id);
$user_status = $user_info['status'];
$is_block_visible_for_user = false;
if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) {
$is_block_visible_for_user = true;
}
return $is_block_visible_for_user;
$user_info = api_get_user_info($user_id);
$user_status = $user_info['status'];
$is_block_visible_for_user = false;
if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) {
$is_block_visible_for_user = true;
}
return $is_block_visible_for_user;
}
/**
* This method return content html containing information about students and its position for showing it inside dashboard interface
* This method return content html containing information
* about students and its position for showing it inside dashboard interface
* it's important to use the name 'get_block' for beeing used from dashboard controller
* @return array column and content html
*/
public function get_block()
{
global $charset;
$column = 1;
$data = array();
global $charset;
$column = 1;
$data = array();
$student_content_html = $this->get_students_content_html_for_drh();
$html = '<div class="panel panel-default" id="intro">
$html = '<div class="panel panel-default" id="intro">
<div class="panel-heading">
'.get_lang('StudentsInformationsList').'
<div class="pull-right"><a class="btn btn-danger btn-xs" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">
@ -70,173 +71,180 @@ class BlockStudent extends Block
'.$student_content_html.'
</div>
</div>';
$data['column'] = $column;
$data['content_html'] = $html;
return $data;
$data['column'] = $column;
$data['content_html'] = $html;
return $data;
}
/**
* This method return a content html, it's used inside get_block method for showing it inside dashboard interface
* @return string content html
*/
* 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_students_content_html_for_platform_admin()
{
$students = $this->students;
//$content = '<div style="margin:10px;">';
$content = '<h4>'.get_lang('YourStudents').'</h4>';
$students = $this->students;
$content = '<h4>'.get_lang('YourStudents').'</h4>';
$students_table = null;
if (count($students) > 0) {
$students_table .= '<table class="data_table">';
$students_table .= '<tr>
<th width="10%" rowspan="2">'.get_lang('FirstName').'</th>
<th width="10%" rowspan="2">'.get_lang('LastName').'</th>
<th width="30%" colspan="2">'.get_lang('CourseInformation').'</th>
</tr>
<tr>
<th width="10%">'.get_lang('Courses').'</th>
<th width="10%">'.get_lang('Time').'</th>
</tr>';
$i = 1;
foreach ($students as $student) {
$courses_by_user = CourseManager::get_courses_list_by_user_id($student['user_id'], true);
$count_courses = count($courses_by_user);
$rowspan = $count_courses ? $count_courses + 1 : 2;
if ($i % 2 == 0) {
if (count($students) > 0) {
$students_table .= '<table class="data_table">';
$students_table .= '<tr>
<th width="10%" rowspan="2">'.get_lang('FirstName').'</th>
<th width="10%" rowspan="2">'.get_lang('LastName').'</th>
<th width="30%" colspan="2">'.get_lang('CourseInformation').'</th>
</tr>
<tr>
<th width="10%">'.get_lang('Courses').'</th>
<th width="10%">'.get_lang('Time').'</th>
</tr>';
$i = 1;
foreach ($students as $student) {
$courses_by_user = CourseManager::get_courses_list_by_user_id($student['user_id'], true);
$count_courses = count($courses_by_user);
$rowspan = $count_courses ? $count_courses + 1 : 2;
if ($i % 2 == 0) {
$style = ' style="background-color:#F2F2F2" ';
} else {
$style = ' style="background-color:#FFF" ';
}
$students_table .= '<tr '.$style.'>
<td rowspan="'.$rowspan.'">'.$student['firstname'].'</td>
<td rowspan="'.$rowspan.'">'.$student['lastname'].'</td>
</tr>';
// courses information about the student
if (!empty($courses_by_user)) {
foreach ($courses_by_user as $course) {
$course_code = $course['code'];
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];
$course_title = $course['title'];
$time = api_time_to_hms(Tracking::get_time_spent_on_the_course($student['user_id'], $courseId));
$students_table .= '<tr '.$style.'>
<td align="right">'.$course_title.'</td>
<td align="right">'.$time.'</td>
</tr>';
}
} else {
$students_table .= '<tr '.$style.'>
<td align="center" colspan="2"><i>'.get_lang('Empty').'</i></td>
</tr>';
}
$i++;
}
$students_table .= '</table>';
} else {
$students_table .= get_lang('ThereIsNoInformationAboutYourStudents');
}
$content .= $students_table;
if (count($students) > 0) {
$content .= '<div style="text-align:right;margin-top:10px;"><a href="'.api_get_path(WEB_CODE_PATH).'mySpace/index.php?view=admin&display=useroverview">'.get_lang('SeeMore').'</a></div>';
}
//$content .= '</div>';
return $content;
}
public function get_students_content_html_for_drh() {
$attendance = new Attendance();
$students = $this->students;
//$content = '<div style="margin:5px;">';
$content = '<h4>'.get_lang('YourStudents').'</h4>';
$students_table .= '<tr '.$style.'>
<td rowspan="'.$rowspan.'">'.$student['firstname'].'</td>
<td rowspan="'.$rowspan.'">'.$student['lastname'].'</td>
</tr>';
// courses information about the student
if (!empty($courses_by_user)) {
foreach ($courses_by_user as $course) {
$course_code = $course['code'];
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];
$course_title = $course['title'];
$time = api_time_to_hms(Tracking::get_time_spent_on_the_course($student['user_id'], $courseId));
$students_table .= '<tr '.$style.'>
<td align="right">'.$course_title.'</td>
<td align="right">'.$time.'</td>
</tr>';
}
} else {
$students_table .= '<tr '.$style.'>
<td align="center" colspan="2"><i>'.get_lang('Empty').'</i></td>
</tr>';
}
$i++;
}
$students_table .= '</table>';
} else {
$students_table .= get_lang('ThereIsNoInformationAboutYourStudents');
}
$content .= $students_table;
if (count($students) > 0) {
$content .= '<div style="text-align:right;margin-top:10px;"><a href="'.api_get_path(WEB_CODE_PATH).'mySpace/index.php?view=admin&display=useroverview">'.get_lang('SeeMore').'</a></div>';
}
//$content .= '</div>';
return $content;
}
/**
* @return string
*/
public function get_students_content_html_for_drh()
{
$attendance = new Attendance();
$students = $this->students;
$content = '<h4>'.get_lang('YourStudents').'</h4>';
$students_table = null;
if (count($students) > 0) {
$students_table .= '<table class="data_table">';
$students_table .= '<tr>
<th>'.get_lang('User').'</th>
<th>'.get_lang('AttendancesFaults').'</th>
<th>'.get_lang('Evaluations').'</th>
</tr>';
$i = 1;
foreach ($students as $student) {
$student_id = $student['user_id'];
$firstname = $student['firstname'];
$lastname = $student['lastname'];
$username = $student['username'];
// get average of faults in attendances by student
$results_faults_avg = $attendance->get_faults_average_inside_courses($student_id);
if (!empty($results_faults_avg)) {
$attendances_faults_avg = '<a title="'.get_lang('GoToStudentDetails').'" href="'.api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?student='.$student_id.'">'.$results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)</a>';
} else {
$attendances_faults_avg = '0%';
}
$courses_by_user = CourseManager::get_courses_list_by_user_id($student_id, true);
$evaluations_avg = 0;
$score = $weight = 0;
foreach ($courses_by_user as $course) {
$course_code = $course['code'];
$cats = Category::load(null, null, $course_code, null, null, null, false);
$scoretotal = array();
if (isset($cats) && isset($cats[0])) {
$scoretotal = $cats[0]->calc_score($student_id, null, $course_code);
}
if (!empty($scoretotal)) {
$score += $scoretotal[0];
$weight += $scoretotal[1];
}
}
if (!empty($weight)) {
$evaluations_avg = '<a title="'.get_lang('GoToStudentDetails').'" href="'.api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?student='.$student_id.'">'.round($score, 2).'/'.round($weight, 2).'('.round(($score / $weight) * 100, 2).' %)</a>';
}
if ($i % 2 == 0) {
if (count($students) > 0) {
$students_table .= '<table class="data_table">';
$students_table .= '<tr>
<th>'.get_lang('User').'</th>
<th>'.get_lang('AttendancesFaults').'</th>
<th>'.get_lang('Evaluations').'</th>
</tr>';
$i = 1;
foreach ($students as $student) {
$student_id = $student['user_id'];
$firstname = $student['firstname'];
$lastname = $student['lastname'];
$username = $student['username'];
// get average of faults in attendances by student
$results_faults_avg = $attendance->get_faults_average_inside_courses($student_id);
if (!empty($results_faults_avg)) {
$attendances_faults_avg = '<a title="'.get_lang('GoToStudentDetails').'" href="'.api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?student='.$student_id.'">'.$results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)</a>';
} else {
$attendances_faults_avg = '0%';
}
$courses_by_user = CourseManager::get_courses_list_by_user_id($student_id, true);
$evaluations_avg = 0;
$score = $weight = 0;
foreach ($courses_by_user as $course) {
$course_code = $course['code'];
$cats = Category::load(
null,
null,
$course_code,
null,
null,
null,
false
);
$scoretotal = array();
if (isset($cats) && isset($cats[0])) {
$scoretotal = $cats[0]->calc_score($student_id, null, $course_code);
}
if (!empty($scoretotal)) {
$score += $scoretotal[0];
$weight += $scoretotal[1];
}
}
if (!empty($weight)) {
$evaluations_avg = '<a title="'.get_lang('GoToStudentDetails').'" href="'.api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?student='.$student_id.'">'.round($score, 2).'/'.round($weight, 2).'('.round(($score / $weight) * 100, 2).' %)</a>';
}
if ($i % 2 == 0) {
$class_tr = 'row_odd';
} else {
$class_tr = 'row_even';
}
$students_table .= '<tr class="'.$class_tr.'">
<td>'.api_get_person_name($firstname, $lastname).' ('.$username.')</td>
<td>'.$attendances_faults_avg.'</td>
<td>'.$evaluations_avg.'</td>
</tr>';
$i++;
}
$students_table .= '</table>';
} else {
$students_table .= get_lang('ThereIsNoInformationAboutYourStudents');
}
$content .= $students_table;
if (count($students) > 0) {
$content .= '<div style="text-align:right;margin-top:10px;">
$students_table .= '<tr class="'.$class_tr.'">
<td>'.api_get_person_name($firstname, $lastname).' ('.$username.')</td>
<td>'.$attendances_faults_avg.'</td>
<td>'.$evaluations_avg.'</td>
</tr>';
$i++;
}
$students_table .= '</table>';
} else {
$students_table .= get_lang('ThereIsNoInformationAboutYourStudents');
}
$content .= $students_table;
if (count($students) > 0) {
$content .= '<div style="text-align:right;margin-top:10px;">
<a href="'.api_get_path(WEB_CODE_PATH).'mySpace/index.php?view=admin&display=yourstudents">'.get_lang('SeeMore').'</a>
</div>';
}
//$content .= '</div>';
}
//$content .= '</div>';
return $content;
}
return $content;
}
/**
* Get number of students
* @return int
*/
function get_number_of_students()
* Get number of students
* @return int
*/
function get_number_of_students()
{
return count($this->students);
}
return count($this->students);
}
}

@ -15,47 +15,47 @@ use CpChart\Chart\Cache as pCache;
/**
* This class is used like controller for student graph block plugin,
* the class name must be registered inside path.info file (e.g: controller = "BlockStudentGraph"), so dashboard controller will be instantiate it
* the class name must be registered inside path.info file
* (e.g: controller = "BlockStudentGraph"), so dashboard controller will be instantiate it
* @package chamilo.dashboard
*/
class BlockStudentGraph extends Block
{
private $user_id;
private $students;
private $path;
private $permission = array(DRH);
private $students;
private $path;
private $permission = array(DRH);
/**
* Constructor
*/
/**
* Constructor
*/
public function __construct($user_id)
{
$this->user_id = $user_id;
$this->path = 'block_student_graph';
if ($this->is_block_visible_for_user($user_id)) {
/*if (api_is_platform_admin()) {
$this->students = UserManager::get_user_list(array('status' => STUDENT));
} else if (api_is_drh()) {*/
$this->students = UserManager::get_users_followed_by_drh($user_id, STUDENT);
//}
}
$this->user_id = $user_id;
$this->path = 'block_student_graph';
if ($this->is_block_visible_for_user($user_id)) {
/*if (api_is_platform_admin()) {
$this->students = UserManager::get_user_list(array('status' => STUDENT));
} else if (api_is_drh()) {*/
$this->students = UserManager::get_users_followed_by_drh($user_id, STUDENT);
//}
}
}
/**
* This method check if a user is allowed to see the block inside dashboard interface
* @param int User id
* @return bool Is block visible for user
*/
* This method check if a user is allowed to see the block inside dashboard interface
* @param int User id
* @return bool Is block visible for user
*/
public function is_block_visible_for_user($user_id)
{
$user_info = api_get_user_info($user_id);
$user_status = $user_info['status'];
$is_block_visible_for_user = false;
if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) {
$is_block_visible_for_user = true;
}
return $is_block_visible_for_user;
$user_info = api_get_user_info($user_id);
$user_status = $user_info['status'];
$is_block_visible_for_user = false;
if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) {
$is_block_visible_for_user = true;
}
return $is_block_visible_for_user;
}
/**
@ -66,70 +66,66 @@ class BlockStudentGraph extends Block
*/
public function get_block()
{
global $charset;
$column = 1;
$data = array();
$students_attendance_graph = $this->get_students_attendance_graph();
$html = '<div class="panel panel-default" id="intro">
<div class="panel-heading">
'.get_lang('StudentsInformationsGraph').'
<div class="pull-right"><a class="btn btn-danger btn-xs" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">
<em class="fa fa-times"></em>
</a></div>
</div>
<div class="panel-body" align="center">
<div style="padding:10px;"><strong>'.get_lang('AttendancesFaults').'</strong></div>
'.$students_attendance_graph.'
</div>
</div>';
$data['column'] = $column;
$data['content_html'] = $html;
return $data;
global $charset;
$column = 1;
$data = array();
$students_attendance_graph = $this->get_students_attendance_graph();
$html = '<div class="panel panel-default" id="intro">
<div class="panel-heading">
'.get_lang('StudentsInformationsGraph').'
<div class="pull-right"><a class="btn btn-danger btn-xs" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">
<em class="fa fa-times"></em>
</a></div>
</div>
<div class="panel-body" align="center">
<div style="padding:10px;"><strong>'.get_lang('AttendancesFaults').'</strong></div>
'.$students_attendance_graph.'
</div>
</div>';
$data['column'] = $column;
$data['content_html'] = $html;
return $data;
}
/**
* This method return a graph containing information about students evaluation,
* This method return a graph containing information about students evaluation,
* it's used inside get_block method for showing it inside dashboard interface
* @return string img html
*/
* @return string img html
*/
public function get_students_attendance_graph()
{
$students = $this->students;
$attendance = new Attendance();
// get data
$attendances_faults_avg = array();
if (is_array($students) && count($students) > 0) {
foreach ($students as $student) {
$student_id = $student['user_id'];
//$student_info = api_get_user_info($student_id);
// get average of faults in attendances by student
$results_faults_avg = $attendance->get_faults_average_inside_courses($student_id);
if (!empty($results_faults_avg)) {
$attendances_faults_avg[$student['lastname']] = $results_faults_avg['porcent'];
} else {
$attendances_faults_avg[$student['lastname']] = 0;
}
}
}
$students = $this->students;
$attendance = new Attendance();
// get data
$attendances_faults_avg = array();
if (is_array($students) && count($students) > 0) {
foreach ($students as $student) {
$student_id = $student['user_id'];
//$student_info = api_get_user_info($student_id);
// get average of faults in attendances by student
$results_faults_avg = $attendance->get_faults_average_inside_courses($student_id);
if (!empty($results_faults_avg)) {
$attendances_faults_avg[$student['lastname']] = $results_faults_avg['porcent'];
} else {
$attendances_faults_avg[$student['lastname']] = 0;
}
}
}
arsort($attendances_faults_avg);
$usernames = array_keys($attendances_faults_avg);
$faults = array();
foreach ($usernames as $username) {
$faults[] = $attendances_faults_avg[$username];
}
$graph = '';
$img_file = '';
arsort($attendances_faults_avg);
$usernames = array_keys($attendances_faults_avg);
if (is_array($usernames) && count($usernames) > 0) {
$faults = array();
foreach ($usernames as $username) {
$faults[] = $attendances_faults_avg[$username];
}
$graph = '';
$img_file = '';
if (is_array($usernames) && count($usernames) > 0) {
// Defining data
$dataSet = new pData();
$dataSet->addPoints($faults, 'Serie1');
@ -152,14 +148,21 @@ class BlockStudentGraph extends Block
);
// Cache definition
$cachePath = api_get_path(SYS_ARCHIVE_PATH);
$myCache = new pCache(array('CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)));
$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 {
$maxCounts = max(count($usernames), count($faults));
if ($maxCounts < 5) {
$heightSize = 200;
@ -233,19 +236,19 @@ class BlockStudentGraph extends Block
$imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
}
$graph = '<img src="'.$imgPath.'" >';
} else {
$graph = '<p>'.api_convert_encoding(get_lang('GraphicNotAvailable'), 'UTF-8').'</p>';
}
} else {
$graph = '<p>'.api_convert_encoding(get_lang('GraphicNotAvailable'), 'UTF-8').'</p>';
}
return $graph;
}
return $graph;
}
/**
* Get number of students
* @return int
*/
function get_number_of_students()
* Get number of students
* @return int
*/
function get_number_of_students()
{
return count($this->students);
}
return count($this->students);
}
}

@ -62,7 +62,6 @@ class BlockTeacher extends Block
$column = 1;
$data = array();
$teacher_content_html = $this->get_teachers_content_html_for_drh();
$html = '
<div class="panel panel-default" id="intro">
<div class="panel-heading">
@ -139,8 +138,6 @@ class BlockTeacher extends Block
<a href="'.api_get_path(WEB_CODE_PATH).'mySpace/index.php?view=admin">'.get_lang('SeeMore').'</a></div>';
}
//$content .= '</div>';
return $content;
}

@ -26,32 +26,32 @@ class BlockTeacherGraph extends Block
private $path;
private $permission = array(DRH);
/**
* Controller
*/
/**
* Controller
*/
public function __construct($user_id)
{
$this->user_id = $user_id;
$this->path = 'block_teacher_graph';
if ($this->is_block_visible_for_user($user_id)) {
$this->user_id = $user_id;
$this->path = 'block_teacher_graph';
if ($this->is_block_visible_for_user($user_id)) {
$this->teachers = UserManager::get_users_followed_by_drh($user_id, COURSEMANAGER);
}
}
}
/**
* This method check if a user is allowed to see the block inside dashboard interface
* @param int User id
* @return bool Is block visible for user
*/
* This method check if a user is allowed to see the block inside dashboard interface
* @param int User id
* @return bool Is block visible for user
*/
public function is_block_visible_for_user($user_id)
{
$user_info = api_get_user_info($user_id);
$user_status = $user_info['status'];
$is_block_visible_for_user = false;
if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) {
$is_block_visible_for_user = true;
}
return $is_block_visible_for_user;
$user_info = api_get_user_info($user_id);
$user_status = $user_info['status'];
$is_block_visible_for_user = false;
if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) {
$is_block_visible_for_user = true;
}
return $is_block_visible_for_user;
}
/**
@ -61,11 +61,11 @@ class BlockTeacherGraph extends Block
*/
public function get_block()
{
global $charset;
$column = 1;
$data = array();
$teacher_information_graph = $this->get_teachers_information_graph();
$html = '
global $charset;
$column = 1;
$data = array();
$teacher_information_graph = $this->get_teachers_information_graph();
$html = '
<div class="panel panel-default" id="intro">
<div class="panel-heading">'.get_lang('TeachersInformationsGraph').'
<div class="pull-right"><a class="btn btn-danger btn-xs" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">
@ -77,55 +77,58 @@ class BlockTeacherGraph extends Block
'.$teacher_information_graph.'
</div>
</div>
';
$data['column'] = $column;
$data['content_html'] = $html;
';
return $data;
$data['column'] = $column;
$data['content_html'] = $html;
return $data;
}
/**
* This method return a content html, it's used inside get_block method for showing it inside dashboard interface
* @return string content html
*/
* 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_teachers_information_graph()
{
$teachers = $this->teachers;
$graph = '';
$user_ids = array_keys($teachers);
$a_last_week = get_last_week();
if (is_array($user_ids) && count($user_ids) > 0) {
$dataSet = new pData;
foreach ($user_ids as $user_id) {
$teacher_info = api_get_user_info($user_id);
$username = $teacher_info['username'];
$time_by_days = array();
foreach ($a_last_week as $day) {
// day is received as y-m-d 12:00:00
$start_date = api_get_utc_datetime($day);
$end_date = api_get_utc_datetime($day + (3600 * 24 - 1));
$time_on_platform_by_day = Tracking::get_time_spent_on_the_platform($user_id, 'custom', $start_date, $end_date);
$hours = floor($time_on_platform_by_day / 3600);
$min = floor(($time_on_platform_by_day - ($hours * 3600)) / 60);
$time_by_days[] = $min;
}
$dataSet->addPoints($time_by_days, $username);
}
$last_week = date('Y-m-d', $a_last_week[0]).' '.get_lang('To').' '.date('Y-m-d', $a_last_week[6]);
$days_on_week = array();
foreach ($a_last_week as $weekday) {
$days_on_week[] = date('d/m', $weekday);
}
$dataSet->addPoints($days_on_week, 'Days');
$dataSet->setAbscissaName($last_week);
$dataSet->setAxisName(0, get_lang('Minutes'));
$teachers = $this->teachers;
$graph = '';
$user_ids = array_keys($teachers);
$a_last_week = get_last_week();
if (is_array($user_ids) && count($user_ids) > 0) {
$dataSet = new pData;
foreach ($user_ids as $user_id) {
$teacher_info = api_get_user_info($user_id);
$username = $teacher_info['username'];
$time_by_days = array();
foreach ($a_last_week as $day) {
// day is received as y-m-d 12:00:00
$start_date = api_get_utc_datetime($day);
$end_date = api_get_utc_datetime($day + (3600 * 24 - 1));
$time_on_platform_by_day = Tracking::get_time_spent_on_the_platform(
$user_id,
'custom',
$start_date,
$end_date
);
$hours = floor($time_on_platform_by_day / 3600);
$min = floor(($time_on_platform_by_day - ($hours * 3600)) / 60);
$time_by_days[] = $min;
}
$dataSet->addPoints($time_by_days, $username);
}
$last_week = date('Y-m-d', $a_last_week[0]).' '.get_lang('To').' '.date('Y-m-d', $a_last_week[6]);
$days_on_week = array();
foreach ($a_last_week as $weekday) {
$days_on_week[] = date('d/m', $weekday);
}
$dataSet->addPoints($days_on_week, 'Days');
$dataSet->setAbscissaName($last_week);
$dataSet->setAxisName(0, get_lang('Minutes'));
$dataSet->setAbscissa('Days');
$dataSet->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
@ -138,12 +141,10 @@ class BlockTeacherGraph extends Block
$myCache->saveFromCache($chartHash, $imgPath);
$imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
} else {
/* Create the pChart object */
$widthSize = 440;
$heightSize = 350;
$angle = 50;
$myPicture = new pImage($widthSize, $heightSize, $dataSet);
/* Turn of Antialiasing */
@ -194,20 +195,20 @@ class BlockTeacherGraph extends Block
$imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
}
$graph = '<img src="'.$imgPath.'" >';
} else {
$graph = '<p>'.api_convert_encoding(get_lang('GraphicNotAvailable'), 'UTF-8').'</p>';
}
} else {
$graph = '<p>'.api_convert_encoding(get_lang('GraphicNotAvailable'), 'UTF-8').'</p>';
}
return $graph;
}
return $graph;
}
/**
* Get number of teachers
* @return int
*/
function get_number_of_teachers()
* Get number of teachers
* @return int
*/
function get_number_of_teachers()
{
return count($this->teachers);
}
return count($this->teachers);
}
}

Loading…
Cancel
Save