Minor - Format code

pull/2487/head
jmontoyaa 9 years ago
parent 0c3e44ef5e
commit fbc3241845
  1. 3
      main/gradebook/gradebook.php
  2. 4
      main/gradebook/gradebook_display_summary.php
  3. 34
      main/gradebook/gradebook_edit_all.php
  4. 4
      main/gradebook/gradebook_edit_cat.php
  5. 3
      main/gradebook/gradebook_edit_eval.php
  6. 14
      main/gradebook/gradebook_edit_link.php
  7. 2
      main/gradebook/gradebook_edit_result.php
  8. 2
      main/gradebook/gradebook_showlog_eval.php
  9. 4
      main/gradebook/gradebook_showlog_link.php
  10. 16
      main/gradebook/gradebook_statistics.php
  11. 30
      main/gradebook/gradebook_view_result.php
  12. 195
      main/gradebook/index.php
  13. 17
      main/gradebook/lib/GradebookUtils.php
  14. 246
      main/gradebook/lib/fe/displaygradebook.php
  15. 74
      main/gradebook/lib/fe/gradebooktable.class.php
  16. 340
      main/gradebook/lib/fe/linkaddeditform.class.php
  17. 239
      main/gradebook/lib/fe/linkform.class.php
  18. 309
      main/gradebook/lib/fe/resulttable.class.php
  19. 3
      main/gradebook/lib/fe/scoredisplayform.class.php
  20. 127
      main/gradebook/lib/fe/userform.class.php
  21. 233
      main/gradebook/lib/fe/usertable.class.php
  22. 24
      main/gradebook/lib/flatview_data_generator.class.php
  23. 12
      main/gradebook/lib/gradebook_data_generator.class.php
  24. 13
      main/gradebook/lib/gradebook_result.class.php
  25. 15
      main/gradebook/lib/scoredisplay.class.php
  26. 694
      main/gradebook/lib/user_data_generator.class.php
  27. 2
      main/gradebook/user_stats.php
  28. 2
      main/group/group.php
  29. 35
      main/group/group_category.php
  30. 240
      main/group/group_creation.php
  31. 38
      main/group/group_overview.php
  32. 47
      main/group/group_space.php
  33. 2
      main/group/member_settings.php
  34. 12
      main/group/tutor_settings.php
  35. 3
      main/help/allowed_html_tags.php
  36. 11
      main/inc/ajax/course.ajax.php
  37. 46
      main/inc/ajax/course_home.ajax.php
  38. 1
      main/inc/ajax/dropbox.ajax.php
  39. 3
      main/inc/ajax/gradebook.ajax.php
  40. 11
      main/inc/ajax/lp.ajax.php
  41. 2
      main/inc/ajax/message.ajax.php
  42. 2
      main/inc/ajax/myspace.ajax.php
  43. 2
      main/inc/ajax/online.ajax.php
  44. 8
      main/inc/ajax/sequence.ajax.php
  45. 1
      main/inc/ajax/session.ajax.php
  46. 11
      main/inc/ajax/social.ajax.php
  47. 138
      main/inc/ajax/thematic.ajax.php
  48. 2
      main/inc/ajax/user_manager.ajax.php
  49. 2
      main/inc/ajax/work.ajax.php
  50. 11
      main/inc/lib/gradebook.lib.php

@ -21,6 +21,8 @@ if (!empty($_GET['course'])) {
unset($_GET['course']);
}
$selectcat = isset($_GET['selectcat']) ? (int) $_GET['selectcat'] : 0;
$htmlHeadXtra[] = '<script>
$(document).ready( function() {
for (i=0;i<$(".actions").length;i++) {
@ -67,7 +69,6 @@ if (isset ($_GET['createallcategories'])) {
exit;
}
//move a category
$selectcat = isset($_GET['selectcat']) ? (int) $_GET['selectcat'] : '';
if (isset($_GET['movecat'])) {
$move_cat = Security::remove_XSS($_GET['movecat']);

@ -1,13 +1,13 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* Script
* @package chamilo.gradebook
*/
use ChamiloSession as Session;
require_once '../inc/global.inc.php';
$current_course_tool = TOOL_GRADEBOOK;

@ -280,22 +280,22 @@ $warning_message = sprintf(get_lang('TotalWeightMustBeX'), $original_total);
Display::display_warning_message($warning_message, false);
?>
<form method="post"
action="gradebook_edit_all.php?<?php echo $my_api_cidreq ?>&selectcat=<?php echo $my_selectcat ?>">
<table class="data_table">
<tr class="row_odd">
<th style="width: 35px;"><?php echo get_lang('Type'); ?></th>
<th><?php echo get_lang('Resource'); ?></th>
<th><?php echo get_lang('Weight'); ?></th>
</tr>
<?php echo $output; ?>
</table>
<input type="hidden" name="submitted" value="1"/>
<br/>
<button class="btn btn-primary" type="submit" name="name"
value="<?php echo get_lang('Save') ?>">
<?php echo get_lang('SaveScoringRules') ?>
</button>
</form>
<form method="post"
action="gradebook_edit_all.php?<?php echo $my_api_cidreq ?>&selectcat=<?php echo $my_selectcat ?>">
<table class="data_table">
<tr class="row_odd">
<th style="width: 35px;"><?php echo get_lang('Type'); ?></th>
<th><?php echo get_lang('Resource'); ?></th>
<th><?php echo get_lang('Weight'); ?></th>
</tr>
<?php echo $output; ?>
</table>
<input type="hidden" name="submitted" value="1"/>
<br/>
<button class="btn btn-primary" type="submit" name="name"
value="<?php echo get_lang('Save') ?>">
<?php echo get_lang('SaveScoringRules') ?>
</button>
</form>
<?php
Display:: display_footer();

@ -36,7 +36,7 @@ if ($form->validate()) {
$cat->set_id($values['hid_id']);
$cat->set_name($values['name']);
if (empty ($values['course_code'])) {
if (empty($values['course_code'])) {
$cat->set_course_code(null);
} else {
$cat->set_course_code($values['course_code']);
@ -66,7 +66,7 @@ if ($form->validate()) {
$cat->set_certificate_min_score($values['certif_min_score']);
}
if (empty ($values['visible'])) {
if (empty($values['visible'])) {
$visible = 0;
} else {
$visible = 1;

@ -36,9 +36,8 @@ if ($form->validate()) {
$final_weight = $values['weight_mask'];
$eval->set_weight($final_weight);
$eval->set_max($values['max']);
if (empty ($values['visible'])) {
if (empty($values['visible'])) {
$visible = 0;
} else {
$visible = 1;

@ -28,7 +28,15 @@ $linkedit = isset($_GET['editlink']) ? Security::remove_XSS($_GET['editlink']):'
$session_id = api_get_session_id();
if ($session_id == 0) {
$cats = Category :: load(null, null, $course_code, null, null, $session_id, false); //already init
$cats = Category:: load(
null,
null,
$course_code,
null,
null,
$session_id,
false
); //already init
} else {
$cats = Category :: load_session_categories(null, $session_id);
}
@ -44,9 +52,7 @@ $form = new LinkAddEditForm(
if ($form->validate()) {
$values = $form->exportValues();
$parent_cat = Category :: load($values['select_gradebook']);
$final_weight = $values['weight_mask'];
$link->set_weight($final_weight);
if (!empty($values['select_gradebook'])) {
@ -103,7 +109,7 @@ $interbreadcrumb[] = array(
'name' => get_lang('Gradebook')
);
$htmlHeadXtra[] = '<script type="text/javascript">
$htmlHeadXtra[] = '<script>
$(document).ready( function() {
$("#hide_category_id").change(function() {
$("#hide_category_id option:selected").each(function () {

@ -50,6 +50,6 @@ $interbreadcrumb[]= array (
'name' => get_lang('ViewResult')
);
Display :: display_header(get_lang('EditResult'));
DisplayGradebook::display_header_result($evaluation[0],null,0,0);
DisplayGradebook::display_header_result($evaluation[0], null, 0, 0);
echo $table;
Display :: display_footer();

@ -44,7 +44,7 @@ while ($row = Database::fetch_row($result)) {
$list_info[] = $row;
}
foreach($list_info as $key => $info_log) {
foreach ($list_info as $key => $info_log) {
$list_info[$key][5]=($info_log[5]) ? api_convert_and_format_date($info_log[5]) : 'N/A';
$list_info[$key][3]=($info_log[3]==1) ? get_lang('GradebookVisible') : get_lang('GradebookInvisible');
}

@ -45,7 +45,7 @@ while ($row=Database::fetch_row($result)) {
$list_info[] = $row;
}
foreach($list_info as $key => $info_log) {
foreach ($list_info as $key => $info_log) {
$list_info[$key][5]=($info_log[5]) ? api_convert_and_format_date($info_log[5]) : 'N/A';
$list_info[$key][3]=($info_log[3]==1) ? get_lang('GradebookVisible') : get_lang('GradebookInvisible');
}
@ -55,7 +55,7 @@ $parameters = array(
'selectcat' => $selectCat,
);
$table = new SortableTableFromArrayConfig($list_info, 1,20,'gradebooklink');
$table = new SortableTableFromArrayConfig($list_info, 1, 20, 'gradebooklink');
$table->set_additional_parameters($parameters);
$table->set_header(0, get_lang('GradebookNameLog'));
$table->set_header(1, get_lang('GradebookDescriptionLog'));

@ -30,14 +30,19 @@ if (api_is_allowed_to_edit()) {
$displayscore = ScoreDisplay :: instance();
Display::display_header(get_lang('EvaluationStatistics'));
DisplayGradebook::display_header_result($eval[0], $currentcat[0]->get_id(), 0, 'statistics');
DisplayGradebook::display_header_result(
$eval[0],
$currentcat[0]->get_id(),
0,
'statistics'
);
//Bad, Regular, Good - User definitions
$displays = $displayscore->get_custom_score_display_settings();
if (!$displayscore->is_custom() || empty($displays)) {
if (api_is_platform_admin() || api_is_course_admin()) {
Display :: display_error_message(get_lang('PleaseEnableScoringSystem'),false);
Display :: display_error_message(get_lang('PleaseEnableScoringSystem'), false);
}
} else {
$allresults = Result::load(null,null,$eval[0]->get_id());
@ -50,7 +55,12 @@ if (!$displayscore->is_custom() || empty($displays)) {
foreach ($allresults as $result) {
$score = $result->get_score();
if (isset($score)) {
$display = $displayscore->display_score(array($score, $eval[0]->get_max()), SCORE_CUSTOM, SCORE_ONLY_CUSTOM, true);
$display = $displayscore->display_score(
array($score, $eval[0]->get_max()),
SCORE_CUSTOM,
SCORE_ONLY_CUSTOM,
true
);
$nr_items[$display]++;
$resultcount++;
}

@ -79,6 +79,8 @@ if (isset($_GET['editres'])) {
}
$result->save();
unset($result);
Display::addFlash(Display::return_message(get_lang('ResultEdited'), 'normal', false));
header('Location: gradebook_view_result.php?selecteval=' . $select_eval . '&editresmessage=&'.api_get_cidreq());
exit;
}
@ -100,7 +102,6 @@ if (isset($_GET['import'])) {
if (!$import_result_form->validate()) {
Display :: display_header(get_lang('Import'));
}
$eval[0]->check_lock_permissions();
if ($_POST['formSent']) {
if (!empty($_FILES['import_file']['name'])) {
@ -175,16 +176,21 @@ if (isset($_GET['import'])) {
}
} else {
header('Location: ' . api_get_self() . '?import=&selecteval=' . $select_eval . '&importnofile=');
Display::addFlash(Display::return_message(get_lang('ImportNoFile'), 'warning', false));
exit;
}
if ($overwritescore != 0) {
header('Location: ' . api_get_self() . '?selecteval=' . $select_eval. '&importoverwritescore=' . $overwritescore);
Display::addFlash(Display::return_message(get_lang('ImportOverWriteScore') . ' ' . $overwritescore));
exit;
}
if ($nr_results_added == 0) {
Display::addFlash(Display::return_message(get_lang('ProblemUploadingFile'), 'warning', false));
header('Location: ' . api_get_self() . '?selecteval=' . $select_eval. '&nothingadded=');
exit;
}
Display::addFlash(Display::return_message(get_lang('FileUploadComplete'), 'success', false));
header('Location: ' . api_get_self() . '?selecteval=' . $select_eval . '&importok=');
exit;
}
@ -423,6 +429,7 @@ function confirmationall () {
</script>';
if (isset($_GET['deleteall'])) {
$eval[0]->delete_results();
Display::addFlash(Display::return_message(get_lang('AllResultDeleted')));
header('Location: '.api_get_path(WEB_CODE_PATH).'gradebook/gradebook_view_result.php?allresdeleted=&selecteval=' . $select_eval.'&'.api_get_cidreq());
exit;
}
@ -443,10 +450,6 @@ if (isset($_GET['addresultnostudents'])) {
Display :: display_warning_message(get_lang('AddResultNoStudents'), false);
}
if (isset($_GET['editresmessage'])) {
Display :: display_confirmation_message(get_lang('ResultEdited'), false);
}
if (isset($_GET['addresult'])) {
Display :: display_confirmation_message(get_lang('ResultAdded'), false);
}
@ -462,18 +465,10 @@ if (isset($_GET['deleteresult'])) {
if (isset($_GET['editallresults'])) {
Display :: display_confirmation_message(get_lang('AllResultsEdited'), false);
}
if (isset($_GET['importok'])) {
Display :: display_confirmation_message(get_lang('FileUploadComplete'), false);
}
if (isset($_GET['importnofile'])) {
Display :: display_warning_message(get_lang('ImportNoFile'), false);
}
if (isset($_GET['incorrectdata'])) {
Display :: display_warning_message(get_lang('IncorrectData'), false);
}
if (isset($_GET['nothingadded'])) {
Display :: display_warning_message(get_lang('ProblemUploadingFile'), false);
}
if (isset($_GET['massdelete'])) {
Display :: display_confirmation_message(get_lang('ResultsDeleted'), false);
}
@ -483,18 +478,13 @@ if (isset($_GET['nouser'])) {
if (isset($_GET['overwritemax'])) {
Display :: display_warning_message(get_lang('OverWriteMax'), false);
}
if (isset($_GET['importoverwritescore'])) {
Display :: display_confirmation_message(get_lang('ImportOverWriteScore') . ' ' . $_GET['importoverwritescore']);
}
if (isset($_GET['import_user_error'])) {
$userinfo = api_get_user_info($_GET['import_user_error']);
Display:: display_warning_message(
get_lang('UserInfoDoesNotMatch').' '.api_get_person_name($userinfo['firstname'], $userinfo['lastname'])
);
}
if (isset($_GET['allresdeleted'])) {
Display :: display_confirmation_message(get_lang('AllResultDeleted'));
}
if (isset($_GET['import_score_error'])) {
$userinfo = api_get_user_info($_GET['import_score_error']);
Display :: display_warning_message(get_lang('ScoreDoesNotMatch') . ' ' . api_get_person_name($userinfo['firstname'], $userinfo['lastname']));

@ -101,10 +101,11 @@ if (empty($cats)) {
$first_time = 1;
}
$_GET['selectcat'] = $cats[0]->get_id();
$selectCat = (int) $cats[0]->get_id();
$_GET['selectcat'] = $selectCat;
if (isset($_GET['isStudentView'])) {
if ((isset($_GET['selectcat']) && $_GET['selectcat'] > 0) && (isset($_SESSION['studentview']) && $_SESSION['studentview'] == 'true')) {
if ($selectCat > 0 && (isset($_SESSION['studentview']) && $_SESSION['studentview'] == 'true')) {
$interbreadcrumb[] = array(
'url' => 'index.php'.'?selectcat=0&isStudentView=true',
'name' => get_lang('ToolGradebook'),
@ -112,27 +113,37 @@ if (isset($_GET['isStudentView'])) {
}
}
if ((isset($_GET['selectcat']) && $_GET['selectcat']>0) &&
(isset($_SESSION['studentview']) && $_SESSION['studentview']=='true')
) {
if ($selectCat > 0 && (isset($_SESSION['studentview']) && $_SESSION['studentview']=='true')) {
} else {
if (!isset($_GET['selectcat']) &&
($_SESSION['studentview']=='studentview') ||
(isset($_GET['isStudentView']) && $_GET['isStudentView']=='true')
if (empty($selectCat) && (
$_SESSION['studentview']=='studentview') || (isset($_GET['isStudentView']) && $_GET['isStudentView']=='true')
) {
Display :: display_header(get_lang('Gradebook'));
//Introduction tool: student view
Display::display_introduction_section(TOOL_GRADEBOOK, array('ToolbarSet' => 'AssessmentsIntroduction'));
$addparams=array();
$cats = Category :: load (0, null, null, null, null, null, false);
$allcat= $cats[0]->get_subcategories($stud_id, $course_code, $session_id);
$alleval= $cats[0]->get_evaluations($stud_id);
$alllink= $cats[0]->get_links($stud_id);
$gradebooktable= new GradebookTable($cats[0], $allcat, $alleval,$alllink, $addparams);
Display::display_introduction_section(
TOOL_GRADEBOOK,
array('ToolbarSet' => 'AssessmentsIntroduction')
);
$addparams = array();
$cats = Category:: load(0, null, null, null, null, null, false);
$allcat = $cats[0]->get_subcategories(
$stud_id,
$course_code,
$session_id
);
$alleval = $cats[0]->get_evaluations($stud_id);
$alllink = $cats[0]->get_links($stud_id);
$gradebooktable = new GradebookTable(
$cats[0],
$allcat,
$alleval,
$alllink,
$addparams
);
$gradebooktable->display();
Display :: display_footer();
Display:: display_footer();
exit;
}
}
@ -171,14 +182,16 @@ if (isset($_GET['movecat'])) {
GradebookUtils::block_students();
$cats= Category :: load($_GET['movecat']);
if (!isset ($_GET['targetcat'])) {
$move_form= new CatForm(CatForm :: TYPE_MOVE,
$move_form= new CatForm(
CatForm :: TYPE_MOVE,
$cats[0],
'move_cat_form',
null,
api_get_self() . '?movecat=' . Security::remove_XSS($_GET['movecat'])
. '&selectcat=' . Security::remove_XSS($_GET['selectcat']));
. '&selectcat=' . $selectCat
);
if ($move_form->validate()) {
header('Location: ' . api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat'])
header('Location: ' . api_get_self() . '?selectcat=' . $selectCat
. '&movecat=' . Security::remove_XSS($_GET['movecat'])
. '&targetcat=' . $move_form->exportValue('move_cat'));
exit;
@ -189,7 +202,7 @@ if (isset($_GET['movecat'])) {
if (!($course_to_crsind && !isset($_GET['confirm']))) {
$cats[0]->move_to_cat($targetcat[0]);
header('Location: ' . api_get_self() . '?categorymoved=&selectcat=' . Security::remove_XSS($_GET['selectcat']));
header('Location: ' . api_get_self() . '?categorymoved=&selectcat=' . $selectCat);
exit;
}
unset ($targetcat);
@ -203,16 +216,17 @@ if (isset($_GET['moveeval'])) {
$evals= Evaluation :: load($_GET['moveeval']);
if (!isset ($_GET['targetcat'])) {
$move_form= new EvalForm(EvalForm :: TYPE_MOVE,
$move_form= new EvalForm(
EvalForm :: TYPE_MOVE,
$evals[0],
null,
'move_eval_form',
null,
api_get_self() . '?moveeval=' . Security::remove_XSS($_GET['moveeval'])
. '&selectcat=' . Security::remove_XSS($_GET['selectcat']));
api_get_self() . '?moveeval=' . Security::remove_XSS($_GET['moveeval']). '&selectcat=' . $selectCat
);
if ($move_form->validate()) {
header('Location: ' .api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat'])
header('Location: ' .api_get_self() . '?selectcat='.$selectCat
. '&moveeval=' . Security::remove_XSS($_GET['moveeval'])
. '&targetcat=' . $move_form->exportValue('move_cat'));
exit;
@ -223,12 +237,12 @@ if (isset($_GET['moveeval'])) {
if (!($course_to_crsind && !isset($_GET['confirm']))) {
$evals[0]->move_to_cat($targetcat[0]);
header('Location: ' . api_get_self() . '?evaluationmoved=&selectcat=' . Security::remove_XSS($_GET['selectcat']));
header('Location: ' . api_get_self() . '?evaluationmoved=&selectcat=' . $selectCat);
exit;
}
unset ($targetcat);
unset($targetcat);
}
unset ($evals);
unset($evals);
}
//move a link
@ -241,14 +255,14 @@ if (isset($_GET['movelink'])) {
$link[0],
'move_link_form',
null,
api_get_self() . '?movelink=' . $_GET['movelink'] . '&selectcat=' . Security::remove_XSS($_GET['selectcat'])
api_get_self() . '?movelink=' . $_GET['movelink'] . '&selectcat=' . $selectCat
);
if ($move_form->validate()) {
$targetcat= Category :: load($move_form->exportValue('move_cat'));
$link[0]->move_to_cat($targetcat[0]);
unset ($link);
header('Location: ' . api_get_self(). '?linkmoved=&selectcat=' . Security::remove_XSS($_GET['selectcat']));
unset($link);
header('Location: ' . api_get_self(). '?linkmoved=&selectcat=' . $selectCat);
exit;
}
}
@ -408,9 +422,7 @@ if (!empty($course_to_crsind) && !isset($_GET['confirm'])) {
}
$button = '<form name="confirm" method="post" action="'.api_get_self() .'?confirm='
.(isset($_GET['movecat']) ? '&movecat=' . Security::remove_XSS($_GET['movecat'])
: '&moveeval=' . Security::remove_XSS($_GET['moveeval']) )
.'&selectcat=' . Security::remove_XSS($_GET['selectcat'])
.'&targetcat=' . Security::remove_XSS($_GET['targetcat']).'">
: '&moveeval=' . Security::remove_XSS($_GET['moveeval'])).'&selectcat=' . $selectCat.'&targetcat=' . Security::remove_XSS($_GET['targetcat']).'">
<input type="submit" value="'.get_lang('Ok').'">
</form>';
$warning_message = get_lang('MoveWarning').'<br><br>'.$button;
@ -532,24 +544,30 @@ if (isset($_POST['action'])) {
}
if (isset ($_POST['submit']) && isset ($_POST['keyword'])) {
header('Location: ' . api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat'])
. '&search='.Security::remove_XSS($_POST['keyword']));
header('Location: ' . api_get_self() . '?selectcat=' . $selectCat. '&search='.Security::remove_XSS($_POST['keyword']));
exit;
}
// DISPLAY HEADERS AND MESSAGES
if (!isset($_GET['exportpdf'])) {
if (isset ($_GET['studentoverview'])) {
$interbreadcrumb[]= array ('url' => $_SESSION['gradebook_dest'].'?selectcat=' . Security::remove_XSS($_GET['selectcat']),'name' => get_lang('ToolGradebook'));
$interbreadcrumb[] = array(
'url' => $_SESSION['gradebook_dest'].'?selectcat='.$selectCat,
'name' => get_lang('ToolGradebook')
);
Display :: display_header(get_lang('FlatView'));
} elseif (isset ($_GET['search'])) {
$interbreadcrumb[]= array ('url' => $_SESSION['gradebook_dest'].'?selectcat=' . Security::remove_XSS($_GET['selectcat']),'name' => get_lang('ToolGradebook'));
} elseif (isset($_GET['search'])) {
$interbreadcrumb[] = array(
'url' => $_SESSION['gradebook_dest'].'?selectcat='.$selectCat,
'name' => get_lang('ToolGradebook')
);
Display :: display_header(get_lang('SearchResults'));
} elseif(isset ($_GET['selectcat'])) {
$interbreadcrumb[]= array ( 'url' =>'#','name' => get_lang('ToolGradebook'));
if (!isset($_GET['gradebooklist_direction'])) {
//$interbreadcrumb[]= array ('url' => $_SESSION['gradebook_dest'].'?selectcat=' . Security::remove_XSS($_GET['selectcat']),'name' => get_lang('Details'));
}
} elseif(!empty($selectCat)) {
$interbreadcrumb[] = array(
'url' => '#',
'name' => get_lang('ToolGradebook')
);
Display :: display_header('');
} else {
Display :: display_header(get_lang('ToolGradebook'));
@ -603,22 +621,15 @@ if (isset ($move_form)){
$is_platform_admin = api_is_platform_admin();
$is_course_admin = api_is_allowed_to_edit(null, true);
//load data for category, evaluation and links
if (empty($_GET['selectcat'])) {
$category = 0;
} else {
$category = $_GET['selectcat'];
}
$simple_search_form='';
$simple_search_form = '';
if (isset($_GET['studentoverview'])) {
//@todo this code also seems to be deprecated ...
$cats = Category :: load($category);
$stud_id= (api_is_allowed_to_edit() ? null : $stud_id);
$cats = Category :: load($selectCat);
$stud_id = (api_is_allowed_to_edit() ? null : $stud_id);
$allcat = $cats[0]->get_subcategories($stud_id, $course_code, $session_id);
$alleval= $cats[0]->get_evaluations($stud_id, true);
$alllink= $cats[0]->get_links($stud_id, true);
$alleval = $cats[0]->get_evaluations($stud_id, true);
$alllink = $cats[0]->get_links($stud_id, true);
if (isset ($_GET['exportpdf'])) {
$datagen = new GradebookDataGenerator($allcat,$alleval, $alllink);
$header_names = array(
@ -626,9 +637,14 @@ if (isset($_GET['studentoverview'])) {
get_lang('Description'),
get_lang('Weight'),
get_lang('Date'),
get_lang('Results'),
get_lang('Results')
);
$data_array = $datagen->get_data(
GradebookDataGenerator :: GDG_SORT_NAME,
0,
null,
true
);
$data_array = $datagen->get_data(GradebookDataGenerator :: GDG_SORT_NAME,0,null,true);
$newarray = array();
foreach ($data_array as $data) {
$newarray[] = array_slice($data, 1);
@ -709,7 +725,7 @@ if (isset($_GET['studentoverview'])) {
}
unset($cats);
}
$cats = Category::load($category, null, null, null, null, null, false);
$cats = Category::load($selectCat, null, null, null, null, null, false);
//with this fix the teacher only can view 1 gradebook
if (api_is_platform_admin()) {
@ -724,7 +740,7 @@ if (isset($_GET['studentoverview'])) {
}
// add params to the future links (in the table shown)
$addparams = array('selectcat' => $cats[0]->get_id());
$addparams = array('selectcat' => $selectCat);
if (isset($_GET['studentoverview'])) {
$addparams['studentoverview'] = '';
@ -740,20 +756,18 @@ $no_qualification = false;
// Show certificate link.
$certificate = array();
$actionsLeft = '';
if ($category != '0') {
if (!empty($selectCat)) {
$cat = new Category();
$category_id = intval($_GET['selectcat']);
$course_id = CourseManager::get_course_by_category($category_id);
$show_message = $cat->show_message_resource_delete($course_id);
$course_id = CourseManager::get_course_by_category($selectCat);
$show_message = $cat->show_message_resource_delete($course_id);
if ($show_message == '') {
// Student
if (!api_is_allowed_to_edit() && !api_is_excluded_user_type()) {
$certificate = Category::register_user_certificate(
$category_id,
$selectCat,
$stud_id
);
if (isset($certificate['pdf_url'])) {
@ -764,17 +778,17 @@ if ($category != '0') {
);
}
$currentScore = Category::getCurrentScore($stud_id, $category_id, $course_code, $session_id, true);
Category::registerCurrentScore($currentScore, $stud_id, $category_id);
$currentScore = Category::getCurrentScore($stud_id, $selectCat, $course_code, $session_id, true);
Category::registerCurrentScore($currentScore, $stud_id, $selectCat);
}
}
}
if (!api_is_allowed_to_edit(null, true)) {
$actionsLeft .= Display::url(
Display::returnFontAwesomeIcon('file-pdf-o') . get_lang('DownloadReportPdf'),
api_get_self()."?".api_get_self()."&action=export_table",
['class' => 'btn btn-default']
Display::returnFontAwesomeIcon('file-pdf-o') . get_lang('DownloadReportPdf'),
api_get_self()."?".api_get_self()."&action=export_table",
['class' => 'btn btn-default']
);
}
@ -784,38 +798,31 @@ if (api_is_allowed_to_edit(null, true)) {
// Tool introduction
Display::display_introduction_section(TOOL_GRADEBOOK, array('ToolbarSet' => 'AssessmentsIntroduction'));
if ((isset ($_GET['selectcat']) && $_GET['selectcat']<>0)) {
//
} else {
if ((
(isset ($_GET['selectcat']) && $_GET['selectcat'] == 0) || (
(isset($_GET['cidReq']) && $_GET['cidReq'] !== ''))
) ||
isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'false'
) {
$cats = Category:: load(
null,
null,
$course_code,
null,
null,
$session_id,
false
);
}
if (((empty($selectCat)) || (isset($_GET['cidReq']) && $_GET['cidReq'] !== '')) ||
(isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'false')
) {
$cats = Category:: load(
null,
null,
$course_code,
null,
null,
$session_id,
false
);
}
}
if (isset($first_time) && $first_time==1 && api_is_allowed_to_edit(null,true)) {
if (isset($first_time) && $first_time == 1 && api_is_allowed_to_edit(null,true)) {
echo '<meta http-equiv="refresh" content="0;url='.api_get_self().'?'.api_get_cidreq().'" />';
} else {
$cats = Category::load(null, null, $course_code, null, null, $session_id, false);
if (!empty($cats)) {
if ((api_get_setting('gradebook_enable_grade_model') == 'true') &&
if ((api_get_setting('gradebook_enable_grade_model') === 'true') &&
(
api_is_platform_admin() || (api_is_allowed_to_edit(null, true) &&
api_get_setting('teachers_can_change_grade_model_settings') == 'true')
api_get_setting('teachers_can_change_grade_model_settings') === 'true')
)
) {
// Getting grade models.
@ -870,7 +877,7 @@ if (isset($first_time) && $first_time==1 && api_is_allowed_to_edit(null,true)) {
$allcat = array();
/** @var Category $cat */
foreach ($cats as $cat) {
$allcat = $cat->get_subcategories($stud_id, $course_code, $session_id);
$allcat = $cat->get_subcategories($stud_id, $course_code, $session_id);
$alleval = $cat->get_evaluations($stud_id);
$alllink = $cat->get_links($stud_id, true);
@ -892,7 +899,7 @@ if (isset($first_time) && $first_time==1 && api_is_allowed_to_edit(null,true)) {
);
if (api_is_allowed_to_edit(null,true) &&
api_get_setting('gradebook_enable_grade_model') == 'true'
api_get_setting('gradebook_enable_grade_model') === 'true'
) {
//Showing the grading system
if (!empty($grade_models[$grade_model_id])) {

@ -219,7 +219,6 @@ class GradebookUtils
$courseParams = api_get_cidreq_params($cat->get_course_code(), $cat->get_session_id());
if (api_is_allowed_to_edit(null, true)) {
// Locking button
if (api_get_setting('gradebook_locking_enabled') == 'true') {
if ($cat->is_locked()) {
@ -293,12 +292,10 @@ class GradebookUtils
*/
public static function build_edit_icons_eval($eval, $selectcat)
{
$status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
$is_locked = $eval->is_locked();
$eval->get_course_code();
$cat = new Category();
$message_eval = $cat->show_message_resource_delete($eval->get_course_code());
$courseParams = api_get_cidreq_params($eval->get_course_code(), $eval->getSessionId());
if ($message_eval === false && api_is_allowed_to_edit(null, true)) {
@ -516,10 +513,10 @@ class GradebookUtils
global $users;
global $current_value;
switch ($data) {
case 'Result' :
case 'Result':
$users[] = $user;
break;
default :
default:
$user[$data] = $current_value;
break;
}
@ -533,10 +530,10 @@ class GradebookUtils
global $user;
global $current_tag;
switch ($data) {
case 'Result' :
case 'Result':
$user = array();
break;
default :
default:
$current_tag = $data;
}
}
@ -694,8 +691,6 @@ class GradebookUtils
$content_html = DocumentManager::replace_user_info_into_html($user_id, $course_code, $sessionId, $is_preview);
$new_content_html = isset($content_html['content']) ? $content_html['content'] : null;
$variables = isset($content_html['variables']) ? $content_html['variables'] : null;
$contentHead = null;
$path_image = api_get_path(WEB_COURSE_PATH) . api_get_course_path($course_code) . '/document/images/gallery';
$new_content_html = str_replace('../images/gallery', $path_image, $new_content_html);
@ -1055,7 +1050,6 @@ class GradebookUtils
public static function get_all_users($evals = array(), $links = array())
{
$coursecodes = array();
$users = array();
// By default add all user in course
$coursecodes[api_get_course_id()] = '1';
@ -1163,9 +1157,7 @@ class GradebookUtils
$table_link = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$em = Database::getManager();
$table_evaluation = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
$tbl_forum_thread = Database:: get_course_table(TABLE_FORUM_THREAD);
$tbl_work = Database:: get_course_table(TABLE_STUDENT_PUBLICATION);
$tbl_attendance = Database:: get_course_table(TABLE_ATTENDANCE);
$sql = 'UPDATE '.$table_link.' SET weight = '."'".Database::escape_string($weight)."'".'
@ -1456,5 +1448,4 @@ class GradebookUtils
return $file;
}
}

@ -118,57 +118,6 @@ class DisplayGradebook
echo $header;
}
/**
* Displays the header for the flatview page containing filters
* @param $catobj
* @param $showeval
* @param $showlink
*/
public function display_header_flatview($catobj, $showeval, $showlink, $simple_search_form)
{
$header = '<table border="0" cellpadding="5">';
$header .= '<td style="vertical-align: top;"><a href="' . Security::remove_XSS($_SESSION['gradebook_dest']) . '?selectcat=' . Security::remove_XSS($_GET['selectcat']) . '">' . Display::return_icon('gradebook.gif') . get_lang('Gradebook') . '</a></td>';
$header .= '<td style="vertical-align: top;">' . get_lang('FilterCategory') . '</td><td style="vertical-align: top;"><form name="selector"><select name="selectcat" onchange="document.selector.submit()">';
$cats = Category :: load();
$tree = $cats[0]->get_tree();
unset($cats);
foreach ($tree as $cat) {
for ($i = 0; $i < $cat[2]; $i++) {
$line .= '&mdash;';
}
if ($_GET['selectcat'] == $cat[0]) {
$header .= '<option selected="selected" value=' . $cat[0] . '>' . $line . ' ' . $cat[1] . '</option>';
} else {
$header .= '<option value=' . $cat[0] . '>' . $line . ' ' . $cat[1] . '</option>';
}
$line = '';
}
$header .= '</td></select></form>';
if (!$catobj->get_id() == '0') {
$header .= '<td style="vertical-align: top;"><a href="' . api_get_self() . '?selectcat=' . $catobj->get_parent_id() . '">';
$header .= Display::return_icon('gradebook.gif', get_lang('Up'));
$header .= '</a></td>';
}
$header .= '<td style="vertical-align: top;">' . $simple_search_form->toHtml() . '</td>';
$header .= '<td style="vertical-align: top;">
<a href="' . api_get_self() . '?exportpdf=&offset=' . Security::remove_XSS($_GET['offset']) . '&search=' . Security::remove_XSS($_GET['search']) . '&selectcat=' . $catobj->get_id() . '">
'.Display::return_icon('pdf.png', get_lang('ExportPDF'), [], ICON_SIZE_MEDIUM).'
' . get_lang('ExportPDF') . '</a>';
$header .= '<td style="vertical-align: top;">
<a href="' . api_get_self() . '?print=&selectcat=' . $catobj->get_id() . '" target="_blank">
'.Display::return_icon('printer.png', get_lang('Print'), [], ICON_SIZE_MEDIUM).'
' . get_lang('Print') . '</a>';
$header .= '</td></tr></table>';
if (!$catobj->get_id() == '0') {
$header .= '<table border="0" cellpadding="5"><tr><td><form name="itemfilter" method="post" action="' . api_get_self() . '?selectcat=' . $catobj->get_id() . '">
<input type="checkbox" name="showeval" onclick="document.itemfilter.submit()" ' . (($showeval == '1') ? 'checked' : '') . '>Show Evaluations &nbsp;';
$header .= '<input type="checkbox" name="showlink" onclick="document.itemfilter.submit()" ' . (($showlink == '1') ? 'checked' : '') . '>' . get_lang('ShowLinks') . '</form></td></tr></table>';
}
if (isset($_GET['search'])) {
$header .= '<b>' . get_lang('SearchResults') . ' :</b>';
}
echo $header;
}
/**
* Displays the header for the flatview page containing filters
@ -254,155 +203,6 @@ class DisplayGradebook
echo $header;
}
/**
* @param Category $catobj
* @param $showtree
* @param $selectcat
* @param $is_course_admin
* @param $is_platform_admin
* @param $simple_search_form
* @param bool $show_add_qualification
* @param bool $show_add_link
*/
public function display_header_gradebook_per_gradebook($catobj, $showtree, $selectcat, $is_course_admin, $is_platform_admin, $simple_search_form, $show_add_qualification = true, $show_add_link = true)
{
// Student
$status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
$objcat = new Category();
$course_id = CourseManager::get_course_by_category($selectcat);
$message_resource = $objcat->show_message_resource_delete($course_id);
if (!$is_course_admin && $status <> 1 && $selectcat <> 0) {
$user_id = api_get_user_id();
$user = api_get_user_info($user_id);
$catcourse = Category :: load($catobj->get_id());
$scoredisplay = ScoreDisplay :: instance();
$scorecourse = $catcourse[0]->calc_score($user_id);
// generating the total score for a course
$allevals = $catcourse[0]->get_evaluations($user_id, true);
$alllinks = $catcourse[0]->get_links($user_id, true);
$evals_links = array_merge($allevals, $alllinks);
$item_value = 0;
$item_total = 0;
for ($count = 0; $count < count($evals_links); $count++) {
$item = $evals_links[$count];
$score = $item->calc_score($user_id);
$my_score_denom = ($score[1] == 0) ? 1 : $score[1];
$item_value+=$score[0] / $my_score_denom * $item->get_weight();
$item_total+=$item->get_weight();
}
$item_value = number_format($item_value, 2, '.', ' ');
$total_score = array($item_value, $item_total);
$scorecourse_display = $scoredisplay->display_score($total_score, SCORE_DIV_PERCENT);
$cattotal = Category :: load(0);
$scoretotal = $cattotal[0]->calc_score(api_get_user_id());
$scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal, SCORE_PERCENT) : get_lang('NoResultsAvailable'));
$scoreinfo = get_lang('StatsStudent') . ' :<b> ' . api_get_person_name($user['firstname'], $user['lastname']) . '</b><br />';
if ((!$catobj->get_id() == '0') && (!isset($_GET['studentoverview'])) && (!isset($_GET['search']))) {
$scoreinfo.= '<h2>' . get_lang('Total') . ' : ' . $scorecourse_display . '</h2>';
}
Display :: display_normal_message($scoreinfo, false);
}
// show navigation tree and buttons?
$header = '<div class="actions"><table border=0>';
if (($showtree == '1') || (isset($_GET['studentoverview']))) {
$header .= '<tr>';
if (!$selectcat == '0') {
$header .= '<td style=" "><a href="' . api_get_self() . '?selectcat=' . $catobj->get_parent_id() . '">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('RootCat'), '', ICON_SIZE_MEDIUM) . '</a></td>';
}
$header .= '<td style=" ">' . get_lang('CurrentCategory') . '</td>' .
'<td style=" "><form name="selector"><select name="selectcat" onchange="document.selector.submit()">';
$cats = Category :: load();
$tree = $cats[0]->get_tree();
unset($cats);
foreach ($tree as $cat) {
for ($i = 0; $i < $cat[2]; $i++) {
$line .= '&mdash;';
}
$line = isset($line) ? $line : '';
if (isset($_GET['selectcat']) && $_GET['selectcat'] == $cat[0]) {
$header .= '<option selected value=' . $cat[0] . '>' . $line . ' ' . $cat[1] . '</option>';
} else {
$header .= '<option value=' . $cat[0] . '>' . $line . ' ' . $cat[1] . '</option>';
}
$line = '';
}
$header .= '</select></form></td>';
if (!empty($simple_search_form) && $message_resource === false) {
$header .= '<td style="vertical-align: top;">' . $simple_search_form->toHtml() . '</td>';
} else {
$header .= '<td></td>';
}
if ($is_course_admin && $message_resource === false && $_GET['selectcat'] != 0) {
} elseif (!(isset($_GET['studentoverview']))) {
} else {
$header .= '<td style="vertical-align: top;"><a href="' . api_get_self() . '?' . api_get_cidreq() . '&studentoverview=&exportpdf=&selectcat=' . $catobj->get_id() . '" target="_blank">
'.Display::return_icon('pdf.png', get_lang('ExportPDF'), [], ICON_SIZE_MEDIUM).'
' . get_lang('ExportPDF') . '</a>';
}
$header .= '</td></tr>';
}
$header.='</table></div>';
// for course admin & platform admin add item buttons are added to the header
$header .= '<div class="actions">';
$my_category = $catobj->shows_all_information_an_category($catobj->get_id());
$user_id = api_get_user_id();
$course_code = $my_category['course_code'];
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];
$status_user = api_get_status_of_user_in_course($user_id, $courseId);
if (api_is_allowed_to_edit(null, true)) {
if ($selectcat == '0') {
} else {
$my_category = $catobj->shows_all_information_an_category($catobj->get_id());
$my_api_cidreq = api_get_cidreq();
if ($my_api_cidreq == '') {
$my_api_cidreq = 'cidReq=' . $my_category['course_code'];
}
if (!$message_resource) {
$myname = $catobj->shows_all_information_an_category($catobj->get_id());
$my_course_id = api_get_course_id();
$my_file = substr($_SESSION['gradebook_dest'], 0, 5);
$header .= '<td style="vertical-align: top;"><a href="gradebook_flatview.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' .
Display::return_icon('stats.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM) . '</a>';
$header .= '<td style="vertical-align: top;"><a href="gradebook_display_certificate.php?' . $my_api_cidreq . '&amp;cat_id=' . (int) $_GET['selectcat'] . '">' .
Display::return_icon('certificate_list.png', get_lang('GradebookSeeListOfStudentsCertificates'), '', ICON_SIZE_MEDIUM) . '</a>';
$visibility_icon = ($catobj->is_visible() == 0) ? 'invisible' : 'visible';
$visibility_command = ($catobj->is_visible() == 0) ? 'set_visible' : 'set_invisible';
//Right icons
$modify_icons = '<a href="gradebook_edit_cat.php?editcat=' . $catobj->get_id() . '&cidReq=' . $catobj->get_course_code() . '&id_session='.$catobj->get_session_id(). '">' . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM) . '</a>';
if ($catobj->get_name() != api_get_course_id()) {
$modify_icons .= '&nbsp;<a href="' . api_get_self() . '?deletecat=' . $catobj->get_id() . '&amp;selectcat=0&amp;cidReq=' . $catobj->get_course_code() . '" onclick="return confirmation();">' . Display::return_icon('delete.png', get_lang('DeleteAll'), '', ICON_SIZE_MEDIUM) . '</a>';
}
$header .= Display::div($modify_icons, array('class' => 'right'));
}
}
} elseif (isset($_GET['search'])) {
$header .= '<b>' . get_lang('SearchResults') . ' :</b>';
}
$header .= '</div>';
echo $header;
}
/**
* Displays the header for the gradebook containing the navigation tree and links
* @param Category $catobj
@ -428,7 +228,6 @@ class DisplayGradebook
$show_add_link = true,
$certificateLinkInfo = null
) {
$userId = api_get_user_id();
$courseCode = api_get_course_id();
$courseId = api_get_course_int_id();
@ -451,9 +250,6 @@ class DisplayGradebook
$grade_model_id = $catobj->get_grade_model_id();
$header = null;
//@todo move these in a function
$sum_categories_weight_array = array();
if (isset($catobj) && !empty($catobj)) {
$categories = Category::load(
null,
@ -463,14 +259,6 @@ class DisplayGradebook
null,
$sessionId
);
if (!empty($categories)) {
foreach ($categories as $category) {
$sum_categories_weight_array[$category->get_id()] = $category->get_weight();
}
} else {
$sum_categories_weight_array[$catobj->get_id()] = $catobj->get_weight();
}
}
if (!$is_course_admin && ($status <> 1 || $sessionStatus == 0) && $selectcat <> 0) {
@ -516,7 +304,7 @@ class DisplayGradebook
}
// show navigation tree and buttons?
if (($showtree == '1') || (isset($_GET['studentoverview']))) {
if ($showtree == '1' || isset($_GET['studentoverview'])) {
$header = '<div class="actions"><table>';
$header .= '<tr>';
if (!$selectcat == '0') {
@ -566,8 +354,6 @@ class DisplayGradebook
// for course admin & platform admin add item buttons are added to the header
$actionsLeft = '';
$my_category = $catobj->shows_all_information_an_category($catobj->get_id());
$user_id = api_get_user_id();
$my_api_cidreq = api_get_cidreq();
if (api_is_allowed_to_edit(null, true)) {
@ -603,23 +389,23 @@ class DisplayGradebook
if ($my_category['generate_certificates'] == 1) {
$actionsLeft .= Display::url(
Display::return_icon(
'certificate_list.png',
get_lang('GradebookSeeListOfStudentsCertificates'),
'',
ICON_SIZE_MEDIUM
),
"gradebook_display_certificate.php?$my_api_cidreq&cat_id=" . intval($_GET['selectcat'])
'certificate_list.png',
get_lang('GradebookSeeListOfStudentsCertificates'),
'',
ICON_SIZE_MEDIUM
),
"gradebook_display_certificate.php?$my_api_cidreq&cat_id=" . $selectcat
);
}
$actionsLeft .= Display::url(
Display::return_icon(
'user.png',
get_lang('GradebookListOfStudentsReports'),
'',
ICON_SIZE_MEDIUM
),
"gradebook_display_summary.php?$my_api_cidreq&selectcat=" . intval($_GET['selectcat'])
'user.png',
get_lang('GradebookListOfStudentsReports'),
'',
ICON_SIZE_MEDIUM
),
"gradebook_display_summary.php?$my_api_cidreq&selectcat=" . $selectcat
);
// Right icons
@ -721,13 +507,12 @@ class DisplayGradebook
/**
* @param int $userid
*/
public static function display_header_user($userid)
public static function display_header_user($userid, $categoryId)
{
$select_cat = intval($_GET['selectcat']);
$user_id = $userid;
$user = api_get_user_info($user_id);
$catcourse = Category :: load($select_cat);
$catcourse = Category :: load($categoryId);
$scoredisplay = ScoreDisplay :: instance();
$scorecourse = $catcourse[0]->calc_score($user_id);
@ -743,7 +528,6 @@ class DisplayGradebook
$my_score_denom = ($score[1] == 0) ? 1 : $score[1];
$item_value+=$score[0] / $my_score_denom * $item->get_weight();
$item_total+=$item->get_weight();
//$row[] = $scoredisplay->display_score($score,SCORE_DIV_PERCENT);
}
$item_value = number_format($item_value, 2, '.', ' ');
$total_score = array($item_value, $item_total);

@ -113,7 +113,8 @@ class GradebookTable extends SortableTable
if ($this->teacherView) {
$this->set_header($column++, get_lang('Modify'), false, 'width="195px"');
// Actions on multiple selected documents.
$this->set_form_actions(array(
$this->set_form_actions(
array(
'setvisible' => get_lang('SetVisible'),
'setinvisible' => get_lang('SetInvisible'),
'deleted' => get_lang('DeleteSelected')
@ -169,21 +170,22 @@ class GradebookTable extends SortableTable
switch ($this->column) {
// Type
case (0 + $col_adjust) :
case (0 + $col_adjust):
$sorting = GradebookDataGenerator :: GDG_SORT_TYPE;
break;
case (1 + $col_adjust) :
case (1 + $col_adjust):
$sorting = GradebookDataGenerator :: GDG_SORT_NAME;
break;
case (2 + $col_adjust) :
case (2 + $col_adjust):
$sorting = GradebookDataGenerator :: GDG_SORT_DESCRIPTION;
break;
case (3 + $col_adjust) :
case (3 + $col_adjust):
$sorting = GradebookDataGenerator :: GDG_SORT_WEIGHT;
break;
case (4 + $col_adjust) :
case (4 + $col_adjust):
$sorting = GradebookDataGenerator :: GDG_SORT_DATE;
case (5 + $col_adjust) :
break;
case (5 + $col_adjust):
$sorting = GradebookDataGenerator :: GDG_SORT_ID;
break;
}
@ -210,13 +212,13 @@ class GradebookTable extends SortableTable
}
if (empty($this->studentList)) {
$studentList = CourseManager::get_user_list_from_course_code(
$course_code,
$session_id,
null,
null,
$statusToFilter
);
$studentList = CourseManager::get_user_list_from_course_code(
$course_code,
$session_id,
null,
null,
$statusToFilter
);
$this->studentList = $studentList;
}
@ -233,7 +235,6 @@ class GradebookTable extends SortableTable
// generate the data to display
$sortable_data = array();
$weight_total_links = 0;
$main_categories = array();
$main_cat = Category::load(
null,
null,
@ -301,7 +302,7 @@ class GradebookTable extends SortableTable
$weight = $scoredisplay->display_score(
array(
$data['3'],
$this->currentcat->get_weight(),
$this->currentcat->get_weight()
),
SCORE_SIMPLE,
SCORE_BOTH,
@ -433,7 +434,6 @@ class GradebookTable extends SortableTable
// Links.
foreach ($data_array2 as $data) {
$row = array();
$item = $data[0];
@ -579,7 +579,6 @@ class GradebookTable extends SortableTable
if ($this->teacherView) {
// Total for teacher.
if (count($main_cat) > 1) {
if (intval($total_categories_weight) == $main_weight) {
$total = GradebookUtils::score_badges(
array(
@ -668,7 +667,7 @@ class GradebookTable extends SortableTable
$totalResult,
$totalRanking,
$totalBest,
$totalAverage,
$totalAverage
);
} else {
$row = array(
@ -679,7 +678,7 @@ class GradebookTable extends SortableTable
$totalResult,
$totalRanking,
$totalBest,
$totalAverage,
$totalAverage
);
}
@ -697,9 +696,7 @@ class GradebookTable extends SortableTable
) {
$id_cat = intval($_GET['selectcat']);
$category = Category::load($id_cat);
$weight_category = intval($this->build_weight($category[0]));
$course_code = $this->build_course_code($category[0]);
$weight_total_links = round($weight_total_links);
@ -755,7 +752,7 @@ class GradebookTable extends SortableTable
is_array($course_codes)
) {
$warning_message = '';
for ($x = 0; $x<count($weight_categories);$x++) {
for ($x = 0; $x < count($weight_categories); $x++) {
$weight_category = intval($weight_categories[$x]);
$certificate_min_score = intval($certificate_min_scores[$x]);
$course_code = $course_codes[$x];
@ -768,7 +765,7 @@ class GradebookTable extends SortableTable
}
if (!empty($warning_message)) {
Display::display_warning_message($warning_message,false);
Display::display_warning_message($warning_message, false);
}
}
}
@ -813,11 +810,8 @@ class GradebookTable extends SortableTable
/* Add a border to the picture */
$pChart->drawRectangle(0,0,$xSize-10,$ySize-10,array("R"=>0,"G"=>0,"B"=>0));
$pChart->drawText(10,16,get_lang('Results'),array("FontSize"=>11,"Align"=> TEXT_ALIGN_BOTTOMMIDDLE));
$pChart->setGraphArea(50, 30, $xSize-50, $ySize-50);
$pChart->setFontProperties(
array(
'FontName' => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
@ -840,7 +834,15 @@ class GradebookTable extends SortableTable
/* Draw the line chart */
$pChart->drawLineChart();
$pChart->drawPlotChart(array("DisplayValues"=>TRUE,"PlotBorder"=>TRUE,"BorderSize"=>2,"Surrounding"=>-60,"BorderAlpha"=>80));
$pChart->drawPlotChart(
array(
"DisplayValues" => true,
"PlotBorder" => true,
"BorderSize" => 2,
"Surrounding" => -60,
"BorderAlpha" => 80,
)
);
/* Write the chart legend */
$pChart->drawLegend(
@ -910,13 +912,13 @@ class GradebookTable extends SortableTable
{
switch ($item->get_item_type()) {
// category
case 'C' :
case 'C':
return 'CATE' . $item->get_id();
// evaluation
case 'E' :
case 'E':
return 'EVAL' . $item->get_id();
// link
case 'L' :
case 'L':
return 'LINK' . $item->get_id();
}
}
@ -944,7 +946,7 @@ class GradebookTable extends SortableTable
switch ($item->get_item_type()) {
// category
case 'C' :
case 'C':
$prms_uri='?selectcat=' . $item->get_id() . '&amp;view='.$view;
if (isset($_GET['isStudentView'])) {
@ -960,7 +962,7 @@ class GradebookTable extends SortableTable
. '</a>'
. ($item->is_course() ? ' &nbsp;[' . $item->get_course_code() . ']'.$show_message : '');
// evaluation
case 'E' :
case 'E':
$cat = new Category();
$course_id = CourseManager::get_course_by_category($categoryId);
$show_message = $cat->show_message_resource_delete($course_id);
@ -1035,13 +1037,13 @@ class GradebookTable extends SortableTable
{
switch ($item->get_item_type()) {
// category
case 'C' :
case 'C':
return GradebookUtils::build_edit_icons_cat($item, $this->currentcat);
// evaluation
case 'E' :
case 'E':
return GradebookUtils::build_edit_icons_eval($item, $this->currentcat->get_id());
// link
case 'L' :
case 'L':
return GradebookUtils::build_edit_icons_link($item, $this->currentcat->get_id());
}
}

@ -9,108 +9,106 @@
*/
class LinkAddEditForm extends FormValidator
{
const TYPE_ADD = 1;
const TYPE_ADD = 1;
const TYPE_EDIT = 2;
/**
* Constructor
* To add link, define category_object and link_type
* To edit link, define link_object
*/
public function __construct(
$form_type,
$category_object,
$link_type,
$link_object,
$form_name,
$action = null
) {
parent :: __construct($form_name, 'post', $action);
// set or create link object
if (isset($link_object)) {
$link = $link_object;
} elseif (isset($link_type) && isset($category_object)) {
$link = LinkFactory :: create ($link_type);
$link->set_course_code(api_get_course_id());
$link->set_category_id($category_object[0]->get_id());
} else {
die ('LinkAddEditForm error: define link_type/category_object or link_object');
}
$defaults = array();
$this->addElement('hidden', 'zero', 0);
if (!empty($_GET['editlink'])) {
$this->addElement('header', '', get_lang('EditLink'));
}
// ELEMENT: name
if ($form_type == self :: TYPE_ADD || $link->is_allowed_to_change_name()) {
if ($link->needs_name_and_description()) {
$this->addText('name', get_lang('Name'), true, array('size'=>'40', 'maxlength'=>'40'));
} else {
$select = $this->addElement('select', 'select_link', get_lang('ChooseItem'));
foreach ($link->get_all_links() as $newlink) {
$select->addoption($newlink[1],$newlink[0]);
}
}
} else {
$this->addElement('label',get_lang('Name'), '<span class="freeze">'.$link->get_name().' ['.$link->get_type_name().']</span>');
$this->addElement('hidden','name_link',$link->get_name(),array('id'=>'name_link'));
}
if (count($category_object) == 1) {
$this->addElement('hidden', 'select_gradebook', $category_object[0]->get_id());
} else {
$select_gradebook = $this->addElement(
'select',
'select_gradebook',
get_lang('SelectGradebook'),
array(),
array('id' => 'hide_category_id')
);
$this->addRule('select_gradebook', get_lang('ThisFieldIsRequired'), 'nonzero');
$default_weight = 0;
if (!empty($category_object)) {
foreach ($category_object as $my_cat) {
if ($my_cat->get_course_code() == api_get_course_id()) {
$grade_model_id = $my_cat->get_grade_model_id();
if (empty($grade_model_id)) {
if ($my_cat->get_parent_id() == 0 ) {
$default_weight = $my_cat->get_weight();
$select_gradebook->addoption(get_lang('Default'), $my_cat->get_id());
} else {
$select_gradebook->addoption($my_cat->get_name(), $my_cat->get_id());
}
} else {
$select_gradebook->addoption(get_lang('Select'), 0);
}
if ($link->get_category_id() == $my_cat->get_id()) {
$default_weight = $my_cat->get_weight();
}
}
}
}
}
$this->addText(
'weight_mask',
array(get_lang('Weight'), null, ' [0 .. <span id="max_weight">'.$category_object[0]->get_weight().'</span>] '),
true,
array(
'size' => '4',
'maxlength' => '5',
'class' => 'span1'
)
);
$this->addElement('hidden', 'weight');
/*
/**
* Constructor
* To add link, define category_object and link_type
* To edit link, define link_object
*/
public function __construct(
$form_type,
$category_object,
$link_type,
$link_object,
$form_name,
$action = null
) {
parent :: __construct($form_name, 'post', $action);
// set or create link object
if (isset($link_object)) {
$link = $link_object;
} elseif (isset($link_type) && isset($category_object)) {
$link = LinkFactory :: create ($link_type);
$link->set_course_code(api_get_course_id());
$link->set_category_id($category_object[0]->get_id());
} else {
die ('LinkAddEditForm error: define link_type/category_object or link_object');
}
$defaults = array();
$this->addElement('hidden', 'zero', 0);
if (!empty($_GET['editlink'])) {
$this->addElement('header', '', get_lang('EditLink'));
}
// ELEMENT: name
if ($form_type == self :: TYPE_ADD || $link->is_allowed_to_change_name()) {
if ($link->needs_name_and_description()) {
$this->addText('name', get_lang('Name'), true, array('size'=>'40', 'maxlength'=>'40'));
} else {
$select = $this->addElement('select', 'select_link', get_lang('ChooseItem'));
foreach ($link->get_all_links() as $newlink) {
$select->addoption($newlink[1],$newlink[0]);
}
}
} else {
$this->addElement('label',get_lang('Name'), '<span class="freeze">'.$link->get_name().' ['.$link->get_type_name().']</span>');
$this->addElement('hidden','name_link',$link->get_name(),array('id'=>'name_link'));
}
if (count($category_object) == 1) {
$this->addElement('hidden', 'select_gradebook', $category_object[0]->get_id());
} else {
$select_gradebook = $this->addElement(
'select',
'select_gradebook',
get_lang('SelectGradebook'),
array(),
array('id' => 'hide_category_id')
);
$this->addRule('select_gradebook', get_lang('ThisFieldIsRequired'), 'nonzero');
$default_weight = 0;
if (!empty($category_object)) {
foreach ($category_object as $my_cat) {
if ($my_cat->get_course_code() == api_get_course_id()) {
$grade_model_id = $my_cat->get_grade_model_id();
if (empty($grade_model_id)) {
if ($my_cat->get_parent_id() == 0 ) {
$default_weight = $my_cat->get_weight();
$select_gradebook->addoption(get_lang('Default'), $my_cat->get_id());
} else {
$select_gradebook->addoption($my_cat->get_name(), $my_cat->get_id());
}
} else {
$select_gradebook->addoption(get_lang('Select'), 0);
}
if ($link->get_category_id() == $my_cat->get_id()) {
$default_weight = $my_cat->get_weight();
}
}
}
}
}
$this->addText(
'weight_mask',
array(get_lang('Weight'), null, ' [0 .. <span id="max_weight">'.$category_object[0]->get_weight().'</span>] '),
true,
array(
'size' => '4',
'maxlength' => '5',
'class' => 'span1'
)
);
$this->addElement('hidden', 'weight');
/*
// ELEMENT: weight
$this->addText('weight', array(get_lang('Weight'), null, '/ <span id="max_weight">'.$default_weight.'</span>'), true, array (
@ -119,76 +117,76 @@ class LinkAddEditForm extends FormValidator
'class' => 'span1'
));*/
$this->addRule('weight_mask',get_lang('OnlyNumbers'),'numeric');
$this->addRule(array ('weight_mask', 'zero'), get_lang('NegativeValue'), 'compare', '>=');
if ($form_type == self :: TYPE_EDIT) {
$parent_cat = Category :: load($link->get_category_id());
if ($parent_cat[0]->get_parent_id() == 0) {
$values['weight'] = $link->get_weight();
} else {
$cat = Category :: load($parent_cat[0]->get_parent_id());
//$global_weight = $cat[0]->get_weight();
//$values['weight'] = $link->get_weight()/$parent_cat[0]->get_weight()*$global_weight;
//var_dump($global_weight, $link->get_weight(), $parent_cat[0]->get_weight());
//$weight = $parent_cat[0]->get_weight()* $link->get_weight() / $global_weight;
//$values['weight'] = $weight;
$values['weight'] = $link->get_weight() ;
}
$defaults['weight_mask'] = $values['weight'] ;
$defaults['select_gradebook'] = $link->get_category_id();
}
// ELEMENT: max
if ($link->needs_max()) {
if ($form_type == self :: TYPE_EDIT && $link->has_results()) {
$this->addText('max', get_lang('QualificationNumeric'), false, array ('size' => '4','maxlength' => '5', 'disabled' => 'disabled'));
} else {
$this->addText('max', get_lang('QualificationNumeric'), true, array ('size' => '4','maxlength' => '5'));
$this->addRule('max', get_lang('OnlyNumbers'), 'numeric');
$this->addRule(array ('max', 'zero'), get_lang('NegativeValue'), 'compare', '>=');
}
if ($form_type == self :: TYPE_EDIT) {
$defaults['max'] = $link->get_max();
}
}
// ELEMENT: description
if ($link->needs_name_and_description()) {
$this->addElement('textarea', 'description', get_lang('Description'), array ('rows' => '3','cols' => '34'));
if ($form_type == self :: TYPE_EDIT) {
$defaults['description'] = $link->get_description();
}
}
// ELEMENT: visible
$visible = ($form_type == self :: TYPE_EDIT && $link->is_visible()) ? '1' : '0';
$this->addElement('checkbox', 'visible', null, get_lang('Visible'), $visible);
if ($form_type == self :: TYPE_EDIT) {
$defaults['visible'] = $link->is_visible();
}
// ELEMENT: add results
if ($form_type == self :: TYPE_ADD && $link->needs_results()) {
$this->addElement('checkbox', 'addresult', get_lang('AddResult'));
}
// submit button
if ($form_type == self :: TYPE_ADD) {
$this->addButtonCreate(get_lang('CreateLink'));
} else {
$this->addButtonUpdate(get_lang('LinkMod'));
}
if ($form_type == self :: TYPE_ADD) {
$setting = api_get_setting('tool_visible_by_default_at_creation');
$visibility_default = 1;
if (isset($setting['gradebook']) && $setting['gradebook'] == 'false') {
$visibility_default = 0;
}
$defaults['visible'] = $visibility_default;
}
// set default values
$this->setDefaults($defaults);
$this->addRule('weight_mask',get_lang('OnlyNumbers'),'numeric');
$this->addRule(array ('weight_mask', 'zero'), get_lang('NegativeValue'), 'compare', '>=');
if ($form_type == self :: TYPE_EDIT) {
$parent_cat = Category :: load($link->get_category_id());
if ($parent_cat[0]->get_parent_id() == 0) {
$values['weight'] = $link->get_weight();
} else {
$cat = Category :: load($parent_cat[0]->get_parent_id());
//$global_weight = $cat[0]->get_weight();
//$values['weight'] = $link->get_weight()/$parent_cat[0]->get_weight()*$global_weight;
//var_dump($global_weight, $link->get_weight(), $parent_cat[0]->get_weight());
//$weight = $parent_cat[0]->get_weight()* $link->get_weight() / $global_weight;
//$values['weight'] = $weight;
$values['weight'] = $link->get_weight() ;
}
$defaults['weight_mask'] = $values['weight'] ;
$defaults['select_gradebook'] = $link->get_category_id();
}
// ELEMENT: max
if ($link->needs_max()) {
if ($form_type == self :: TYPE_EDIT && $link->has_results()) {
$this->addText('max', get_lang('QualificationNumeric'), false, array ('size' => '4','maxlength' => '5', 'disabled' => 'disabled'));
} else {
$this->addText('max', get_lang('QualificationNumeric'), true, array ('size' => '4','maxlength' => '5'));
$this->addRule('max', get_lang('OnlyNumbers'), 'numeric');
$this->addRule(array ('max', 'zero'), get_lang('NegativeValue'), 'compare', '>=');
}
if ($form_type == self :: TYPE_EDIT) {
$defaults['max'] = $link->get_max();
}
}
// ELEMENT: description
if ($link->needs_name_and_description()) {
$this->addElement('textarea', 'description', get_lang('Description'), array ('rows' => '3','cols' => '34'));
if ($form_type == self :: TYPE_EDIT) {
$defaults['description'] = $link->get_description();
}
}
// ELEMENT: visible
$visible = ($form_type == self :: TYPE_EDIT && $link->is_visible()) ? '1' : '0';
$this->addElement('checkbox', 'visible', null, get_lang('Visible'), $visible);
if ($form_type == self :: TYPE_EDIT) {
$defaults['visible'] = $link->is_visible();
}
// ELEMENT: add results
if ($form_type == self :: TYPE_ADD && $link->needs_results()) {
$this->addElement('checkbox', 'addresult', get_lang('AddResult'));
}
// submit button
if ($form_type == self :: TYPE_ADD) {
$this->addButtonCreate(get_lang('CreateLink'));
} else {
$this->addButtonUpdate(get_lang('LinkMod'));
}
if ($form_type == self :: TYPE_ADD) {
$setting = api_get_setting('tool_visible_by_default_at_creation');
$visibility_default = 1;
if (isset($setting['gradebook']) && $setting['gradebook'] == 'false') {
$visibility_default = 0;
}
$defaults['visible'] = $visibility_default;
}
// set default values
$this->setDefaults($defaults);
}
}

@ -10,133 +10,138 @@
*/
class LinkForm extends FormValidator
{
const TYPE_CREATE = 1;
const TYPE_MOVE = 2;
/** @var Category */
private $category_object;
private $link_object;
private $extra;
const TYPE_CREATE = 1;
const TYPE_MOVE = 2;
/** @var Category */
private $category_object;
private $link_object;
private $extra;
/**
* Builds a form containing form items based on a given parameter
* @param int form_type 1=choose link
* @param obj cat_obj the category object
* @param string form name
* @param method
* @param action
*/
public function __construct(
$form_type,
$category_object,
$link_object,
$form_name,
$method = 'post',
$action = null,
$extra = null
) {
parent :: __construct($form_name, $method, $action);
/**
* Builds a form containing form items based on a given parameter
* @param int form_type 1=choose link
* @param obj cat_obj the category object
* @param string form name
* @param method
* @param action
*/
public function __construct(
$form_type,
$category_object,
$link_object,
$form_name,
$method = 'post',
$action = null,
$extra = null
) {
parent :: __construct($form_name, $method, $action);
if (isset ($category_object)) {
$this->category_object = $category_object;
} else {
if (isset($link_object)) {
$this->link_object = $link_object;
}
}
if (isset ($category_object)) {
$this->category_object = $category_object;
} else {
if (isset($link_object)) {
$this->link_object = $link_object;
}
}
if (isset ($extra)) {
$this->extra = $extra;
}
if ($form_type == self :: TYPE_CREATE) {
$this->build_create();
} elseif ($form_type == self :: TYPE_MOVE) {
$this->build_move();
}
}
if (isset ($extra)) {
$this->extra = $extra;
}
if ($form_type == self :: TYPE_CREATE) {
$this->build_create();
} elseif ($form_type == self :: TYPE_MOVE) {
$this->build_move();
}
}
protected function build_move()
{
$renderer =& $this->defaultRenderer();
$renderer->setCustomElementTemplate('<span>{element}</span> ');
$this->addElement('static',null,null,'"'.$this->link_object->get_name().'" ');
$this->addElement('static',null,null,get_lang('MoveTo').' : ');
$select = $this->addElement('select','move_cat',null,null);
$line = '';
foreach ($this->link_object->get_target_categories() as $cat) {
for ($i=0;$i<$cat[2];$i++) {
$line .= '&mdash;';
}
$select->addoption($line.' '.$cat[1],$cat[0]);
$line = '';
}
$this->addElement('submit', null, get_lang('Ok'));
}
protected function build_move()
{
$renderer =& $this->defaultRenderer();
$renderer->setCustomElementTemplate('<span>{element}</span> ');
$this->addElement(
'static',
null,
null,
'"'.$this->link_object->get_name().'" '
);
$this->addElement('static', null, null, get_lang('MoveTo').' : ');
$select = $this->addElement('select', 'move_cat', null, null);
$line = '';
foreach ($this->link_object->get_target_categories() as $cat) {
for ($i = 0; $i < $cat[2]; $i++) {
$line .= '&mdash;';
}
$select->addoption($line.' '.$cat[1], $cat[0]);
$line = '';
}
$this->addElement('submit', null, get_lang('Ok'));
}
/**
* Builds the form
*/
protected function build_create()
{
$this->addElement('header', get_lang('MakeLink'));
$select = $this->addElement(
'select',
'select_link',
get_lang('ChooseLink'),
null,
array('onchange' => 'document.create_link.submit()')
);
/**
* Builds the form
*/
protected function build_create()
{
$this->addElement('header', get_lang('MakeLink'));
$select = $this->addElement(
'select',
'select_link',
get_lang('ChooseLink'),
null,
array('onchange' => 'document.create_link.submit()')
);
$linkTypes = LinkFactory::get_all_types();
$linkTypes = LinkFactory::get_all_types();
$select->addoption('['.get_lang('ChooseLink').']', 0);
$select->addoption('['.get_lang('ChooseLink').']', 0);
$courseCode = $this->category_object->get_course_code();
$courseCode = $this->category_object->get_course_code();
foreach ($linkTypes as $linkType) {
// The hot potatoe link will be added "inside" the exercise option.
if ($linkType == LINK_HOTPOTATOES) {
continue;
}
$link = $this->createLink($linkType, $courseCode);
// disable this element if the link works with a dropdownlist
// and if there are no links left
if (!$link->needs_name_and_description() && count($link->get_all_links()) == '0') {
$select->addoption($link->get_type_name(), $linkType, 'disabled');
} else {
if ($link->get_type() == LINK_EXERCISE) {
// Adding exercise
$select->addoption($link->get_type_name(), $linkType);
// Adding hot potatoes
$linkHot = $this->createLink(LINK_HOTPOTATOES, $courseCode);
$select->addoption(
'&nbsp;&nbsp;&nbsp;'.$linkHot->get_type_name(),
LINK_HOTPOTATOES
);
} else {
$select->addoption($link->get_type_name(), $linkType);
}
}
}
foreach ($linkTypes as $linkType) {
// The hot potatoe link will be added "inside" the exercise option.
if ($linkType == LINK_HOTPOTATOES) {
continue;
}
$link = $this->createLink($linkType, $courseCode);
// disable this element if the link works with a dropdownlist
// and if there are no links left
if (!$link->needs_name_and_description() && count($link->get_all_links()) == '0') {
$select->addoption($link->get_type_name(), $linkType, 'disabled');
} else {
if ($link->get_type() == LINK_EXERCISE) {
// Adding exercise
$select->addoption($link->get_type_name(), $linkType);
// Adding hot potatoes
$linkHot = $this->createLink(LINK_HOTPOTATOES, $courseCode);
$select->addoption(
'&nbsp;&nbsp;&nbsp;'.$linkHot->get_type_name(),
LINK_HOTPOTATOES
);
} else {
$select->addoption($link->get_type_name(), $linkType);
}
}
}
if (isset($this->extra)) {
$this->setDefaults(array('select_link' => $this->extra));
}
}
if (isset($this->extra)) {
$this->setDefaults(array('select_link' => $this->extra));
}
}
/**
* @param integer $link
* @param null|string $courseCode
* @return AttendanceLink|DropboxLink|ExerciseLink|ForumThreadLink|LearnpathLink|null|StudentPublicationLink|SurveyLink
*/
private function createLink($link, $courseCode)
{
$link = LinkFactory::create($link);
if (!empty($courseCode)) {
$link->set_course_code($courseCode);
} elseif(!empty($_GET['course_code'])) {
$link->set_course_code(Database::escape_string($_GET['course_code'], null, false));
}
/**
* @param integer $link
* @param null|string $courseCode
* @return AttendanceLink|DropboxLink|ExerciseLink|ForumThreadLink|LearnpathLink|null|StudentPublicationLink|SurveyLink
*/
private function createLink($link, $courseCode)
{
$link = LinkFactory::create($link);
if (!empty($courseCode)) {
$link->set_course_code($courseCode);
} elseif(!empty($_GET['course_code'])) {
$link->set_course_code(Database::escape_string($_GET['course_code'], null, false));
}
return $link;
}
return $link;
}
}

@ -10,166 +10,165 @@
*/
class ResultTable extends SortableTable
{
private $datagen;
private $evaluation;
private $allresults;
private $iscourse;
/**
* Constructor
*/
private $datagen;
private $evaluation;
private $allresults;
private $iscourse;
/**
* Constructor
*/
public function __construct($evaluation, $results = array(), $iscourse, $addparams = null,$forprint = false)
{
parent :: __construct('resultlist', null, null, (api_is_western_name_order() xor api_sort_by_first_name()) ? 2 : 1);
$this->datagen = new ResultsDataGenerator($evaluation, $results, true);
$this->evaluation = $evaluation;
$this->iscourse = $iscourse;
$this->forprint = $forprint;
if (isset ($addparams)) {
$this->set_additional_parameters($addparams);
}
$scoredisplay = ScoreDisplay :: instance();
$column= 0;
if ($this->iscourse == '1') {
$this->set_header($column++, '', false);
$this->set_form_actions(array (
'delete' => get_lang('Delete')
));
}
if (api_is_western_name_order()) {
$this->set_header($column++, get_lang('FirstName'));
$this->set_header($column++, get_lang('LastName'));
} else {
$this->set_header($column++, get_lang('LastName'));
$this->set_header($column++, get_lang('FirstName'));
}
$this->set_header($column++, get_lang('Score'));
if ($scoredisplay->is_custom()) {
$this->set_header($column++, get_lang('Display'));
}
if (!$this->forprint) {
$this->set_header($column++, get_lang('Modify'),false);
}
{
parent :: __construct('resultlist', null, null, (api_is_western_name_order() xor api_sort_by_first_name()) ? 2 : 1);
$this->datagen = new ResultsDataGenerator($evaluation, $results, true);
$this->evaluation = $evaluation;
$this->iscourse = $iscourse;
$this->forprint = $forprint;
if (isset ($addparams)) {
$this->set_additional_parameters($addparams);
}
$scoredisplay = ScoreDisplay :: instance();
$column= 0;
if ($this->iscourse == '1') {
$this->set_header($column++, '', false);
$this->set_form_actions(array (
'delete' => get_lang('Delete')
));
}
if (api_is_western_name_order()) {
$this->set_header($column++, get_lang('FirstName'));
$this->set_header($column++, get_lang('LastName'));
} else {
$this->set_header($column++, get_lang('LastName'));
$this->set_header($column++, get_lang('FirstName'));
}
$this->set_header($column++, get_lang('Score'));
if ($scoredisplay->is_custom()) {
$this->set_header($column++, get_lang('Display'));
}
if (!$this->forprint) {
$this->set_header($column++, get_lang('Modify'),false);
}
}
/**
* Function used by SortableTable to get total number of items in the table
*/
public function get_total_number_of_items ()
/**
* Function used by SortableTable to get total number of items in the table
*/
public function get_total_number_of_items ()
{
return $this->datagen->get_total_results_count();
}
/**
* Function used by SortableTable to generate the data to display
*/
public function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null) {
$is_western_name_order = api_is_western_name_order();
$scoredisplay = ScoreDisplay :: instance();
// determine sorting type
$col_adjust = $this->iscourse == '1' ? 1 : 0;
switch ($this->column) {
// first name or last name
case (0 + $col_adjust):
if ($is_western_name_order) {
$sorting = ResultsDataGenerator :: RDG_SORT_FIRSTNAME;
} else {
$sorting = ResultsDataGenerator :: RDG_SORT_LASTNAME;
}
break;
return $this->datagen->get_total_results_count();
}
/**
* Function used by SortableTable to generate the data to display
*/
public function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null) {
$is_western_name_order = api_is_western_name_order();
$scoredisplay = ScoreDisplay :: instance();
// determine sorting type
$col_adjust = $this->iscourse == '1' ? 1 : 0;
switch ($this->column) {
// first name or last name
case (0 + $col_adjust):
if ($is_western_name_order) {
$sorting = ResultsDataGenerator :: RDG_SORT_FIRSTNAME;
} else {
$sorting = ResultsDataGenerator :: RDG_SORT_LASTNAME;
}
break;
// first name or last name
case (1 + $col_adjust):
if ($is_western_name_order) {
$sorting = ResultsDataGenerator :: RDG_SORT_LASTNAME;
} else {
$sorting = ResultsDataGenerator :: RDG_SORT_FIRSTNAME;
}
break;
case (1 + $col_adjust):
if ($is_western_name_order) {
$sorting = ResultsDataGenerator :: RDG_SORT_LASTNAME;
} else {
$sorting = ResultsDataGenerator :: RDG_SORT_FIRSTNAME;
}
break;
//Score
case (2 + $col_adjust):
$sorting = ResultsDataGenerator :: RDG_SORT_SCORE;
break;
case (3 + $col_adjust):
$sorting = ResultsDataGenerator :: RDG_SORT_MASK;
break;
}
if ($this->direction == 'DESC') {
$sorting |= ResultsDataGenerator :: RDG_SORT_DESC;
} else {
$sorting |= ResultsDataGenerator :: RDG_SORT_ASC;
}
$data_array = $this->datagen->get_data($sorting, $from, $this->per_page);
// generate the data to display
$sortable_data = array();
foreach ($data_array as $item) {
$row = array ();
if ($this->iscourse == '1') {
$row[] = $item['result_id'];
}
if ($is_western_name_order) {
$row[] = $item['firstname'];
$row[] = $item['lastname'];
} else {
$row[] = $item['lastname'];
$row[] = $item['firstname'];
}
$row[] = Display::bar_progress($item['percentage_score'], false, $item['score']);
case (2 + $col_adjust):
$sorting = ResultsDataGenerator :: RDG_SORT_SCORE;
break;
case (3 + $col_adjust):
$sorting = ResultsDataGenerator :: RDG_SORT_MASK;
break;
}
if ($this->direction == 'DESC') {
$sorting |= ResultsDataGenerator :: RDG_SORT_DESC;
} else {
$sorting |= ResultsDataGenerator :: RDG_SORT_ASC;
}
$data_array = $this->datagen->get_data($sorting, $from, $this->per_page);
// generate the data to display
$sortable_data = array();
foreach ($data_array as $item) {
$row = array ();
if ($this->iscourse == '1') {
$row[] = $item['result_id'];
}
if ($is_western_name_order) {
$row[] = $item['firstname'];
$row[] = $item['lastname'];
} else {
$row[] = $item['lastname'];
$row[] = $item['firstname'];
}
$row[] = Display::bar_progress($item['percentage_score'], false, $item['score']);
//$row[] = Display::bar_progress($item['percentage_score'], true);
if ($scoredisplay->is_custom()) {
$row[] = $item['display'];
}
if (!$this->forprint) {
$row[] = $this->build_edit_column ($item);
}
$sortable_data[] = $row;
}
return $sortable_data;
}
private function build_edit_column ($item)
{
$status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
$locked_status = $this->evaluation->get_locked();
if (api_is_allowed_to_edit(null, true) && $locked_status == 0) {
//api_is_course_admin()
$edit_column = '<a href="' . api_get_self() . '?editres=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id().'&'.api_get_cidreq().'">'.
Display::return_icon('edit.png', get_lang('Modify'),'','22').'</a>';
$edit_column .= ' <a href="' . api_get_self() . '?delete_mark=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id().'&'.api_get_cidreq().'">'.
Display::return_icon('delete.png', get_lang('Delete'),'','22').'</a>';
}
if ($this->evaluation->get_course_code() == null) {
$edit_column .= '&nbsp;<a href="' . api_get_self() . '?resultdelete=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id() . '" onclick="return confirmationuser();">';
$edit_column .= Display::return_icon('delete.png', get_lang('Delete'));
$edit_column .= '</a>';
$edit_column .= '&nbsp;<a href="user_stats.php?userid=' . $item['id'] . '&selecteval=' . $this->evaluation->get_id() . '&'.api_get_cidreq().'">';
$edit_column .= Display::return_icon('statistics.gif', get_lang('Statistics'));
$edit_column .= '</a>';
}
// Evaluation's origin is a link
if ($this->evaluation->get_category_id() < 0) {
$link = LinkFactory::get_evaluation_link($this->evaluation->get_id());
$doc_url = $link->get_view_url($item['id']);
if ($doc_url != null) {
$edit_column .= '&nbsp;<a href="'. $doc_url . '" target="_blank">';
$edit_column .= Display::return_icon('link.gif', get_lang('OpenDocument')).'</a>';
}
}
return $edit_column;
}
if ($scoredisplay->is_custom()) {
$row[] = $item['display'];
}
if (!$this->forprint) {
$row[] = $this->build_edit_column ($item);
}
$sortable_data[] = $row;
}
return $sortable_data;
}
private function build_edit_column ($item)
{
$status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
$locked_status = $this->evaluation->get_locked();
if (api_is_allowed_to_edit(null, true) && $locked_status == 0) {
//api_is_course_admin()
$edit_column = '<a href="' . api_get_self() . '?editres=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id().'&'.api_get_cidreq().'">'.
Display::return_icon('edit.png', get_lang('Modify'),'','22').'</a>';
$edit_column .= ' <a href="' . api_get_self() . '?delete_mark=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id().'&'.api_get_cidreq().'">'.
Display::return_icon('delete.png', get_lang('Delete'),'','22').'</a>';
}
if ($this->evaluation->get_course_code() == null) {
$edit_column .= '&nbsp;<a href="' . api_get_self() . '?resultdelete=' . $item['result_id'] . '&selecteval=' . $this->evaluation->get_id() . '" onclick="return confirmationuser();">';
$edit_column .= Display::return_icon('delete.png', get_lang('Delete'));
$edit_column .= '</a>';
$edit_column .= '&nbsp;<a href="user_stats.php?userid=' . $item['id'] . '&selecteval=' . $this->evaluation->get_id() . '&'.api_get_cidreq().'">';
$edit_column .= Display::return_icon('statistics.gif', get_lang('Statistics'));
$edit_column .= '</a>';
}
// Evaluation's origin is a link
if ($this->evaluation->get_category_id() < 0) {
$link = LinkFactory::get_evaluation_link($this->evaluation->get_id());
$doc_url = $link->get_view_url($item['id']);
if ($doc_url != null) {
$edit_column .= '&nbsp;<a href="'. $doc_url . '" target="_blank">';
$edit_column .= Display::return_icon('link.gif', get_lang('OpenDocument')).'</a>';
}
}
return $edit_column;
}
}

@ -146,7 +146,8 @@ class ScoreDisplayForm extends FormValidator
}
}
function validate() {
public function validate()
{
return parent :: validate();
}
}

@ -9,71 +9,72 @@
*/
class UserForm extends FormValidator
{
const TYPE_USER_INFO= 1;
const TYPE_SIMPLE_SEARCH = 3;
/**
* Builds a form containing form items based on a given parameter
* @param int form_type 1 = user_info
* @param user array
* @param string form name
* @param method
* @param action
*/
public function __construct($form_type, $user, $form_name, $method= 'post', $action= null)
{
parent :: __construct($form_name, $method, $action);
$this->form_type= $form_type;
if (isset ($user)) {
$this->user_info= $user;
}
if (isset ($result_object)) {
$this->result_object= $result_object;
}
if ($this->form_type == self :: TYPE_USER_INFO) {
$this->build_user_info_form();
}
elseif ($this->form_type == self :: TYPE_SIMPLE_SEARCH) {
$this->build_simple_search();
}
$this->setDefaults();
}
const TYPE_USER_INFO= 1;
const TYPE_SIMPLE_SEARCH = 3;
protected function build_simple_search()
{
if (isset($_GET['search']) && (!empty($_GET['search']))) {
$this->setDefaults(array(
'keyword' => Security::remove_XSS($_GET['search'])
));
}
$renderer =& $this->defaultRenderer();
$renderer->setCustomElementTemplate('<span>{element}</span> ');
$this->addElement('text','keyword','');
$this->addButtonSearch(get_lang('Search'), 'submit');
}
/**
* Builds a form containing form items based on a given parameter
* @param int form_type 1 = user_info
* @param user array
* @param string form name
* @param method
* @param action
*/
public function __construct($form_type, $user, $form_name, $method= 'post', $action= null)
{
parent :: __construct($form_name, $method, $action);
$this->form_type= $form_type;
if (isset ($user)) {
$this->user_info= $user;
}
if (isset ($result_object)) {
$this->result_object= $result_object;
}
if ($this->form_type == self :: TYPE_USER_INFO) {
$this->build_user_info_form();
}
elseif ($this->form_type == self :: TYPE_SIMPLE_SEARCH) {
$this->build_simple_search();
}
$this->setDefaults();
}
protected function build_user_info_form()
{
if (api_is_western_name_order()) {
$this->addElement('static', 'fname', get_lang('FirstName'), $this->user_info['firstname']);
$this->addElement('static', 'lname', get_lang('LastName'), $this->user_info['lastname']);
} else {
$this->addElement('static', 'lname', get_lang('LastName'), $this->user_info['lastname']);
$this->addElement('static', 'fname', get_lang('FirstName'), $this->user_info['firstname']);
}
$this->addElement('static', 'uname', get_lang('UserName'), $this->user_info['username']);
$this->addElement('static', 'email', get_lang('Email'), '<a href="mailto:' . $this->user_info['email'] . '">' . $this->user_info['email'] . '</a>');
$this->addElement('static', 'ofcode', get_lang('OfficialCode'), $this->user_info['official_code']);
$this->addElement('static', 'phone', get_lang('Phone'), $this->user_info['phone']);
$this->addButtonSave(get_lang('Back'), 'submit');
}
protected function build_simple_search()
{
if (isset($_GET['search']) && (!empty($_GET['search']))) {
$this->setDefaults(array(
'keyword' => Security::remove_XSS($_GET['search'])
));
}
$renderer =& $this->defaultRenderer();
$renderer->setCustomElementTemplate('<span>{element}</span> ');
$this->addElement('text','keyword','');
$this->addButtonSearch(get_lang('Search'), 'submit');
}
function display()
{
parent :: display();
}
protected function build_user_info_form()
{
if (api_is_western_name_order()) {
$this->addElement('static', 'fname', get_lang('FirstName'), $this->user_info['firstname']);
$this->addElement('static', 'lname', get_lang('LastName'), $this->user_info['lastname']);
} else {
$this->addElement('static', 'lname', get_lang('LastName'), $this->user_info['lastname']);
$this->addElement('static', 'fname', get_lang('FirstName'), $this->user_info['firstname']);
}
$this->addElement('static', 'uname', get_lang('UserName'), $this->user_info['username']);
$this->addElement('static', 'email', get_lang('Email'), '<a href="mailto:' . $this->user_info['email'] . '">' . $this->user_info['email'] . '</a>');
$this->addElement('static', 'ofcode', get_lang('OfficialCode'), $this->user_info['official_code']);
$this->addElement('static', 'phone', get_lang('Phone'), $this->user_info['phone']);
$this->addButtonSave(get_lang('Back'), 'submit');
}
function setDefaults($defaults= array(), $filter = null)
{
parent :: setDefaults($defaults, $filter);
}
function display()
{
parent :: display();
}
function setDefaults($defaults= array(), $filter = null)
{
parent :: setDefaults($defaults, $filter);
}
}

@ -10,128 +10,129 @@
*/
class UserTable extends SortableTable
{
private $userid;
private $datagen;
private $userid;
private $datagen;
/**
* Constructor
*/
public function __construct($userid, $evals = array(), $links = array(), $addparams = null)
{
parent :: __construct ('userlist', null, null, 0);
$this->userid = $userid;
$this->datagen = new UserDataGenerator($userid, $evals, $links);
if (isset($addparams)) {
$this->set_additional_parameters($addparams);
}
$column = 0;
$this->set_header($column++, get_lang('Type'));
$this->set_header($column++, get_lang('Evaluation'));
$this->set_header($column++, get_lang('Course'));
$this->set_header($column++, get_lang('Category'));
$this->set_header($column++, get_lang('EvaluationAverage'));
$this->set_header($column++, get_lang('Result'));
/**
* Constructor
*/
public function __construct($userid, $evals = array(), $links = array(), $addparams = null)
{
parent :: __construct('userlist', null, null, 0);
$this->userid = $userid;
$this->datagen = new UserDataGenerator($userid, $evals, $links);
if (isset($addparams)) {
$this->set_additional_parameters($addparams);
}
$column = 0;
$this->set_header($column++, get_lang('Type'));
$this->set_header($column++, get_lang('Evaluation'));
$this->set_header($column++, get_lang('Course'));
$this->set_header($column++, get_lang('Category'));
$this->set_header($column++, get_lang('EvaluationAverage'));
$this->set_header($column++, get_lang('Result'));
$scoredisplay = ScoreDisplay :: instance();
if ($scoredisplay->is_custom()) {
$this->set_header($column++, get_lang('Display'));
}
}
$scoredisplay = ScoreDisplay :: instance();
if ($scoredisplay->is_custom()) {
$this->set_header($column++, get_lang('Display'));
}
}
/**
* Function used by SortableTable to get total number of items in the table
*/
function get_total_number_of_items()
{
return $this->datagen->get_total_items_count();
}
/**
* Function used by SortableTable to get total number of items in the table
*/
function get_total_number_of_items()
{
return $this->datagen->get_total_items_count();
}
/**
* Function used by SortableTable to generate the data to display
*/
public function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null)
{
$scoredisplay = ScoreDisplay :: instance();
/**
* Function used by SortableTable to generate the data to display
*/
public function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null)
{
$scoredisplay = ScoreDisplay :: instance();
// determine sorting type
switch ($this->column) {
// Type
case 0:
$sorting = UserDataGenerator :: UDG_SORT_TYPE;
break;
case 1:
$sorting = UserDataGenerator :: UDG_SORT_NAME;
break;
case 2:
$sorting = UserDataGenerator :: UDG_SORT_COURSE;
break;
case 3:
$sorting = UserDataGenerator :: UDG_SORT_CATEGORY;
break;
case 4:
$sorting = UserDataGenerator :: UDG_SORT_AVERAGE;
break;
case 5:
$sorting = UserDataGenerator :: UDG_SORT_SCORE;
break;
case 6:
$sorting = UserDataGenerator :: UDG_SORT_MASK;
break;
}
if ($this->direction == 'DESC') {
$sorting |= UserDataGenerator :: UDG_SORT_DESC;
} else {
$sorting |= UserDataGenerator :: UDG_SORT_ASC;
}
$data_array = $this->datagen->get_data($sorting, $from, $this->per_page);
// generate the data to display
$sortable_data = array();
foreach ($data_array as $data) {
if ($data[2]!="") {//filter by course removed
$row = array ();
$row[] = $this->build_type_column($data[0]);
$row[] = $this->build_name_link($data[0]);
$row[] = $data[2];
$row[] = $data[3];
$row[] = $data[4];
$row[] = $data[5];
if ($scoredisplay->is_custom())
$row[] = $data[6];
$sortable_data[] = $row;
}
}
// determine sorting type
switch ($this->column) {
// Type
case 0:
$sorting = UserDataGenerator :: UDG_SORT_TYPE;
break;
case 1:
$sorting = UserDataGenerator :: UDG_SORT_NAME;
break;
case 2:
$sorting = UserDataGenerator :: UDG_SORT_COURSE;
break;
case 3:
$sorting = UserDataGenerator :: UDG_SORT_CATEGORY;
break;
case 4:
$sorting = UserDataGenerator :: UDG_SORT_AVERAGE;
break;
case 5:
$sorting = UserDataGenerator :: UDG_SORT_SCORE;
break;
case 6:
$sorting = UserDataGenerator :: UDG_SORT_MASK;
break;
}
if ($this->direction == 'DESC') {
$sorting |= UserDataGenerator :: UDG_SORT_DESC;
} else {
$sorting |= UserDataGenerator :: UDG_SORT_ASC;
}
$data_array = $this->datagen->get_data($sorting, $from, $this->per_page);
// generate the data to display
$sortable_data = array();
foreach ($data_array as $data) {
if ($data[2]!="") {//filter by course removed
$row = array ();
$row[] = $this->build_type_column($data[0]);
$row[] = $this->build_name_link($data[0]);
$row[] = $data[2];
$row[] = $data[3];
$row[] = $data[4];
$row[] = $data[5];
if ($scoredisplay->is_custom()) {
$row[] = $data[6];
}
$sortable_data[] = $row;
}
}
return $sortable_data;
}
return $sortable_data;
}
/**
* @param $item
* @return string
*/
private function build_type_column($item)
{
return GradebookUtils::build_type_icon_tag($item->get_icon_name());
}
/**
* @param $item
* @return string
*/
private function build_type_column($item)
{
return GradebookUtils::build_type_icon_tag($item->get_icon_name());
}
/**
* @param $item
* @return string
*/
private function build_name_link($item)
{
switch ($item->get_item_type()) {
// evaluation
case 'E' :
return '&nbsp;'
. '<a href="gradebook_view_result.php?selecteval=' . $item->get_id() . '">'
. $item->get_name()
. '</a>';
// link
case 'L' :
return '&nbsp;<a href="' . $item->get_link() . '">'
. $item->get_name()
. '</a>'
. '&nbsp;[' . $item->get_type_name() . ']';
}
}
/**
* @param $item
* @return string
*/
private function build_name_link($item)
{
switch ($item->get_item_type()) {
// evaluation
case 'E':
return '&nbsp;'
. '<a href="gradebook_view_result.php?selecteval=' . $item->get_id() . '">'
. $item->get_name()
. '</a>';
// link
case 'L':
return '&nbsp;<a href="' . $item->get_link() . '">'
. $item->get_name()
. '</a>'
. '&nbsp;[' . $item->get_type_name() . ']';
}
}
}

@ -165,14 +165,13 @@ class FlatViewDataGenerator
// Means there are any subcategory
foreach ($allcat as $sub_cat) {
$sub_cat_weight = round(100 * $sub_cat->get_weight() / $main_weight, 1);
$add_weight = " $sub_cat_weight %";
$mainHeader = Display::url(
$sub_cat->get_name(),
api_get_self().'?selectcat='.$sub_cat->get_id().'&'.api_get_cidreq()
).$add_weight;
$sub_cat->get_name(),
api_get_self().'?selectcat='.$sub_cat->get_id().'&'.api_get_cidreq()
).$add_weight;
if (api_get_setting('gradebook_detailed_admin_view') === 'true') {
@ -209,7 +208,7 @@ class FlatViewDataGenerator
(isset($this->params['only_total_category']) &&
$this->params['only_total_category'] == false)
) {
for ($count=0; ($count < $items_count ) && ($items_start + $count < count($this->evals_links)); $count++) {
for ($count = 0; ($count < $items_count) && ($items_start + $count < count($this->evals_links)); $count++) {
/** @var AbstractLink $item */
$item = $this->evals_links[$count + $items_start];
$weight = round(100 * $item->get_weight() / $main_weight, 1);
@ -523,6 +522,7 @@ class FlatViewDataGenerator
}
$item_value_total += $item_value;
}
if ($convert_using_the_global_weight) {
//$item_total = $main_weight;
}
@ -716,7 +716,7 @@ class FlatViewDataGenerator
foreach ($selected_users as $user) {
$row = array ();
for ($count=0;$count < count($this->evals_links); $count++) {
for ($count = 0; $count < count($this->evals_links); $count++) {
$item = $this->evals_links [$count];
$score = $item->calc_score($user[0]);
$porcent_score = isset($score[1]) && $score[1] > 0 ? ($score[0]*100)/$score[1] :0;
@ -731,7 +731,7 @@ class FlatViewDataGenerator
$tmp = array();
foreach ($items as $item => $value) {
$tmp[] = $item;
if (in_array($item,$tmp)) {
if (in_array($item, $tmp)) {
$data_by_item[$item][$uid] = $value;
}
}
@ -784,7 +784,7 @@ class FlatViewDataGenerator
$item_value = 0;
$item_total = 0;
for ($count=0;$count < count($this->evals_links); $count++) {
for ($count = 0; $count < count($this->evals_links); $count++) {
$item = $this->evals_links[$count];
$score = $item->calc_score($user[0]);
@ -803,6 +803,7 @@ class FlatViewDataGenerator
$row[] = $score_final;
$data[] = $row;
}
return $data;
}
@ -840,7 +841,6 @@ class FlatViewDataGenerator
$parent_id = $this->category->get_parent_id();
if ($parent_id == 0 && !empty($allcat)) {
foreach ($allcat as $sub_cat) {
$score = $sub_cat->calc_score($user[0]);
$real_score = $score;
@ -866,7 +866,7 @@ class FlatViewDataGenerator
trim($scoredisplay->display_score($total_score, SCORE_CUSTOM, null, true))
);
} else {
for ($count=0;$count < count($this->evals_links); $count++) {
for ($count = 0; $count < count($this->evals_links); $count++) {
$item = $this->evals_links [$count];
$score = $item->calc_score($user[0]);
$divide = ($score[1]) == 0 ? 1 : $score[1];
@ -880,9 +880,9 @@ class FlatViewDataGenerator
$total_score=array($item_value,$item_total);
$score_final = ($item_value / $item_total) * 100;
if ($displayWarning) {
Display::display_warning_message( Display::display_warning_message($total_score[1]));
Display::display_warning_message($total_score[1]);
}
$row[] =array ($score_final, trim($scoredisplay->display_score($total_score, SCORE_CUSTOM, null, true)));
$row[] = array($score_final, trim($scoredisplay->display_score($total_score, SCORE_CUSTOM, null, true)));
}
$data[] = $row;

@ -210,15 +210,13 @@ class GradebookDataGenerator
if (!empty($score['score'][0])) {
$invalidateResults = false;
}
}
$rankingStudentList[$user['user_id']] = $score['score'][0];
}
$scoreDisplay = ScoreDisplay::instance();
$score = AbstractLink::getCurrentUserRanking($userId, $rankingStudentList);
$row['ranking'] = $scoreDisplay->display_score($score, SCORE_DIV, SCORE_BOTH, true);
if ($invalidateResults) {
$row['ranking'] = null;
}
@ -321,7 +319,7 @@ class GradebookDataGenerator
if (!empty($score)) {
switch ($item->get_item_type()) {
// category
case 'C' :
case 'C':
if ($score != null) {
if ($forceSimpleResult) {
return
@ -349,8 +347,8 @@ class GradebookDataGenerator
}
break;
// evaluation and link
case 'E' :
case 'L' :
case 'E':
case 'L':
//if ($parentId == 0) {
$scoreWeight = [
($score[1] > 0) ? $score[0] / $score[1] * $item->get_weight() : 0,
@ -502,7 +500,7 @@ class GradebookDataGenerator
}
if ($timestamp1 == $timestamp2) {
return $this->sort_by_name($item1,$item2);
return $this->sort_by_name($item1, $item2);
} else {
return ($timestamp1 < $timestamp2 ? -1 : 1);
}

@ -36,16 +36,15 @@ class GradeBookResult
//titles
foreach ($dato[0] as $header_col) {
if(!empty($header_col)) {
if (!empty($header_col)) {
$data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($header_col))).';';
}
}
$data .="\r\n";
$data .= "\r\n";
$cant_students = count($dato[1]);
//print_r($data); exit();
for($i=0;$i<$cant_students;$i++) {
for ($i = 0; $i < $cant_students; $i++) {
$column = 0;
foreach($dato[1][$i] as $col_name) {
$data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($col_name))).';';
@ -101,7 +100,11 @@ class GradeBookResult
for ($i = 0; $i < $cant_students; $i++) {
$column = 0;
foreach ($data[1][$i] as $col_name) {
$worksheet->SetCellValueByColumnAndRow($line,$column, html_entity_decode(strip_tags($col_name)));
$worksheet->SetCellValueByColumnAndRow(
$line,
$column,
html_entity_decode(strip_tags($col_name))
);
$column++;
}
$line++;

@ -62,7 +62,6 @@ class ScoreDisplay
}
// Loading portal settings + using standard functions.
$value = api_get_setting('gradebook_score_display_coloring');
$value = $value['my_display_coloring'];
@ -342,23 +341,23 @@ class ScoreDisplay
private function display_default($score, $type)
{
switch ($type) {
case SCORE_DIV : // X / Y
case SCORE_DIV: // X / Y
return $this->display_as_div($score);
case SCORE_PERCENT : // XX %
case SCORE_PERCENT: // XX %
return $this->display_as_percent($score);
case SCORE_DIV_PERCENT : // X / Y (XX %)
case SCORE_DIV_PERCENT: // X / Y (XX %)
return $this->display_as_div($score).' (' . $this->display_as_percent($score) . ')';
case SCORE_AVERAGE : // XX %
case SCORE_AVERAGE: // XX %
return $this->display_as_percent($score);
case SCORE_DECIMAL : // 0.50 (X/Y)
case SCORE_DECIMAL: // 0.50 (X/Y)
return $this->display_as_decimal($score);
case SCORE_DIV_PERCENT_WITH_CUSTOM : // X / Y (XX %) - Good!
case SCORE_DIV_PERCENT_WITH_CUSTOM: // X / Y (XX %) - Good!
$custom = $this->display_custom($score);
if (!empty($custom)) {
$custom = ' - '.$custom;
}
return $this->display_as_div($score).' (' . $this->display_as_percent($score) . ')'.$custom;
case SCORE_DIV_SIMPLE_WITH_CUSTOM : // X - Good!
case SCORE_DIV_SIMPLE_WITH_CUSTOM: // X - Good!
$custom = $this->display_custom($score);
if (!empty($custom)) {

@ -10,28 +10,28 @@
*/
class UserDataGenerator
{
// Sorting types constants
const UDG_SORT_TYPE = 1;
const UDG_SORT_NAME = 2;
const UDG_SORT_COURSE = 4;
const UDG_SORT_CATEGORY = 8;
const UDG_SORT_AVERAGE = 16;
const UDG_SORT_SCORE = 32;
const UDG_SORT_MASK = 64;
const UDG_SORT_ASC = 128;
const UDG_SORT_DESC = 256;
private $items;
private $userid;
private $coursecodecache;
private $categorycache;
private $scorecache;
private $avgcache;
public function __construct($userid, $evals = array(), $links = array())
{
// Sorting types constants
const UDG_SORT_TYPE = 1;
const UDG_SORT_NAME = 2;
const UDG_SORT_COURSE = 4;
const UDG_SORT_CATEGORY = 8;
const UDG_SORT_AVERAGE = 16;
const UDG_SORT_SCORE = 32;
const UDG_SORT_MASK = 64;
const UDG_SORT_ASC = 128;
const UDG_SORT_DESC = 256;
private $items;
private $userid;
private $coursecodecache;
private $categorycache;
private $scorecache;
private $avgcache;
public function __construct($userid, $evals = array(), $links = array())
{
$this->userid = $userid;
$evals_filtered = array();
$result = array();
@ -62,330 +62,330 @@ class UserDataGenerator
$this->avgcache = null;
}
/**
* Get total number of items (rows)
*/
public function get_total_items_count()
{
return count($this->items);
}
/**
* Get actual array data
* @return array 2-dimensional array - each array contains the elements:
* 0: eval/link object
* 1: item name
* 2: course name
* 3: category name
* 4: average score
* 5: student's score
* 6: student's score as custom display (only if custom scoring enabled)
*/
public function get_data($sorting = 0, $start = 0, $count = null, $ignore_score_color = false)
{
// do some checks on count, redefine if invalid value
if (!isset($count)) {
$count = count ($this->items) - $start;
}
if ($count < 0) {
$count = 0;
}
$allitems = $this->items;
// sort users array
if ($sorting & self :: UDG_SORT_TYPE) {
usort($allitems, array('UserDataGenerator', 'sort_by_type'));
}elseif ($sorting & self :: UDG_SORT_NAME) {
usort($allitems, array('UserDataGenerator', 'sort_by_name'));
} elseif ($sorting & self :: UDG_SORT_COURSE) {
usort($allitems, array('UserDataGenerator', 'sort_by_course'));
} elseif ($sorting & self :: UDG_SORT_CATEGORY) {
usort($allitems, array('UserDataGenerator', 'sort_by_category'));
} elseif ($sorting & self :: UDG_SORT_AVERAGE) {
// if user sorts on average scores, first calculate them and cache them
foreach ($allitems as $item) {
$this->avgcache[$item->get_item_type() . $item->get_id()]= $item->calc_score();
}
usort($allitems, array('UserDataGenerator', 'sort_by_average'));
} elseif ($sorting & self :: UDG_SORT_SCORE) {
// if user sorts on student's scores, first calculate them and cache them
foreach ($allitems as $item) {
$this->scorecache[$item->get_item_type() . $item->get_id()]
= $item->calc_score($this->userid);
}
usort($allitems, array('UserDataGenerator', 'sort_by_score'));
} elseif ($sorting & self :: UDG_SORT_MASK) {
// if user sorts on student's masks, first calculate scores and cache them
foreach ($allitems as $item) {
$this->scorecache[$item->get_item_type() . $item->get_id()]
= $item->calc_score($this->userid);
}
usort($allitems, array('UserDataGenerator', 'sort_by_mask'));
}
if ($sorting & self :: UDG_SORT_DESC) {
$allitems = array_reverse($allitems);
}
// select the items we have to display
$visibleitems = array_slice($allitems, $start, $count);
// fill score cache if not done yet
if (!isset ($this->scorecache)) {
foreach ($visibleitems as $item) {
$this->scorecache[$item->get_item_type() . $item->get_id()]
= $item->calc_score($this->userid);
}
}
// generate the data to display
$scoredisplay = ScoreDisplay :: instance();
$data = array();
foreach ($visibleitems as $item) {
$row = array ();
$row[] = $item;
$row[] = $item->get_name();
$row[] = $this->build_course_name($item);
$row[] = $this->build_category_name($item);
$row[] = $this->build_average_column($item, $ignore_score_color);
$row[] = $this->build_result_column($item, $ignore_score_color);
if ($scoredisplay->is_custom())
$row[] = $this->build_mask_column($item, $ignore_score_color);
$data[] = $row;
}
return $data;
}
/**
* @param $item1
* @param $item2
* @return int
*/
function sort_by_type($item1, $item2)
{
if ($item1->get_item_type() == $item2->get_item_type()) {
return $this->sort_by_name($item1,$item2);
} else {
return ($item1->get_item_type() < $item2->get_item_type() ? -1 : 1);
}
}
/**
* @param $item1
* @param $item2
* @return int
*/
function sort_by_course($item1, $item2)
{
$name1 = api_strtolower($this->get_course_name_from_code_cached($item1->get_course_code()));
$name2 = api_strtolower($this->get_course_name_from_code_cached($item2->get_course_code()));
return api_strnatcmp($name1, $name2);
}
/**
* @param $item1
* @param $item2
* @return int
*/
function sort_by_category($item1, $item2)
{
$cat1 = $this->get_category_cached($item1->get_category_id());
$cat2 = $this->get_category_cached($item2->get_category_id());
$name1 = api_strtolower($this->get_category_name_to_display($cat1));
$name2 = api_strtolower($this->get_category_name_to_display($cat2));
return api_strnatcmp($name1, $name2);
}
/**
* @param $item1
* @param $item2
* @return int
*/
function sort_by_name($item1, $item2)
{
return api_strnatcmp($item1->get_name(),$item2->get_name());
}
/**
* @param $item1
* @param $item2
* @return int
*/
function sort_by_average($item1, $item2)
{
$score1 = $this->avgcache[$item1->get_item_type() . $item1->get_id()];
$score2 = $this->avgcache[$item2->get_item_type() . $item2->get_id()];
return $this->compare_scores($score1, $score2);
}
/**
* @param $item1
* @param $item2
* @return int
*/
function sort_by_score($item1, $item2)
{
$score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()];
$score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()];
return $this->compare_scores($score1, $score2);
}
/**
* @param $item1
* @param $item2
* @return int
*/
function sort_by_mask($item1, $item2)
{
$score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()];
$score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()];
return ScoreDisplay :: compare_scores_by_custom_display($score1, $score2);
}
/**
* @param $score1
* @param $score2
* @return int
*/
function compare_scores($score1, $score2)
{
if (!isset($score1)) {
return (isset($score2) ? 1 : 0);
} elseif (!isset($score2)) {
return -1;
} elseif (($score1[0]/$score1[1]) == ($score2[0]/$score2[1])) {
return 0;
} else {
return (($score1[0]/$score1[1]) < ($score2[0]/$score2[1]) ? -1 : 1);
}
}
/**
* @param $item
* @return mixed
*/
private function build_course_name($item)
{
return $this->get_course_name_from_code_cached($item->get_course_code());
}
/**
* @param $item
* @return string
*/
private function build_category_name($item)
{
$cat = $this->get_category_cached($item->get_category_id());
return $this->get_category_name_to_display($cat);
}
/**
* @param $item
* @param $ignore_score_color
* @return string
*/
private function build_average_column($item, $ignore_score_color)
{
if (isset($this->avgcache)) {
$avgscore = $this->avgcache[$item->get_item_type() . $item->get_id()];
} else {
$avgscore = $item->calc_score();
}
$scoredisplay = ScoreDisplay :: instance();
$displaytype = SCORE_AVERAGE;
/*if ($ignore_score_color)
$displaytype |= SCORE_IGNORE_SPLIT;
/**
* Get total number of items (rows)
*/
public function get_total_items_count()
{
return count($this->items);
}
/**
* Get actual array data
* @return array 2-dimensional array - each array contains the elements:
* 0: eval/link object
* 1: item name
* 2: course name
* 3: category name
* 4: average score
* 5: student's score
* 6: student's score as custom display (only if custom scoring enabled)
*/
public function get_data($sorting = 0, $start = 0, $count = null, $ignore_score_color = false)
{
// do some checks on count, redefine if invalid value
if (!isset($count)) {
$count = count ($this->items) - $start;
}
if ($count < 0) {
$count = 0;
}
$allitems = $this->items;
// sort users array
if ($sorting & self :: UDG_SORT_TYPE) {
usort($allitems, array('UserDataGenerator', 'sort_by_type'));
}elseif ($sorting & self :: UDG_SORT_NAME) {
usort($allitems, array('UserDataGenerator', 'sort_by_name'));
} elseif ($sorting & self :: UDG_SORT_COURSE) {
usort($allitems, array('UserDataGenerator', 'sort_by_course'));
} elseif ($sorting & self :: UDG_SORT_CATEGORY) {
usort($allitems, array('UserDataGenerator', 'sort_by_category'));
} elseif ($sorting & self :: UDG_SORT_AVERAGE) {
// if user sorts on average scores, first calculate them and cache them
foreach ($allitems as $item) {
$this->avgcache[$item->get_item_type() . $item->get_id()]= $item->calc_score();
}
usort($allitems, array('UserDataGenerator', 'sort_by_average'));
} elseif ($sorting & self :: UDG_SORT_SCORE) {
// if user sorts on student's scores, first calculate them and cache them
foreach ($allitems as $item) {
$this->scorecache[$item->get_item_type() . $item->get_id()]
= $item->calc_score($this->userid);
}
usort($allitems, array('UserDataGenerator', 'sort_by_score'));
} elseif ($sorting & self :: UDG_SORT_MASK) {
// if user sorts on student's masks, first calculate scores and cache them
foreach ($allitems as $item) {
$this->scorecache[$item->get_item_type() . $item->get_id()]
= $item->calc_score($this->userid);
}
usort($allitems, array('UserDataGenerator', 'sort_by_mask'));
}
if ($sorting & self :: UDG_SORT_DESC) {
$allitems = array_reverse($allitems);
}
// select the items we have to display
$visibleitems = array_slice($allitems, $start, $count);
// fill score cache if not done yet
if (!isset ($this->scorecache)) {
foreach ($visibleitems as $item) {
$this->scorecache[$item->get_item_type() . $item->get_id()]
= $item->calc_score($this->userid);
}
}
// generate the data to display
$scoredisplay = ScoreDisplay :: instance();
$data = array();
foreach ($visibleitems as $item) {
$row = array ();
$row[] = $item;
$row[] = $item->get_name();
$row[] = $this->build_course_name($item);
$row[] = $this->build_category_name($item);
$row[] = $this->build_average_column($item, $ignore_score_color);
$row[] = $this->build_result_column($item, $ignore_score_color);
if ($scoredisplay->is_custom())
$row[] = $this->build_mask_column($item, $ignore_score_color);
$data[] = $row;
}
return $data;
}
/**
* @param $item1
* @param $item2
* @return int
*/
function sort_by_type($item1, $item2)
{
if ($item1->get_item_type() == $item2->get_item_type()) {
return $this->sort_by_name($item1,$item2);
} else {
return ($item1->get_item_type() < $item2->get_item_type() ? -1 : 1);
}
}
/**
* @param $item1
* @param $item2
* @return int
*/
function sort_by_course($item1, $item2)
{
$name1 = api_strtolower($this->get_course_name_from_code_cached($item1->get_course_code()));
$name2 = api_strtolower($this->get_course_name_from_code_cached($item2->get_course_code()));
return api_strnatcmp($name1, $name2);
}
/**
* @param $item1
* @param $item2
* @return int
*/
function sort_by_category($item1, $item2)
{
$cat1 = $this->get_category_cached($item1->get_category_id());
$cat2 = $this->get_category_cached($item2->get_category_id());
$name1 = api_strtolower($this->get_category_name_to_display($cat1));
$name2 = api_strtolower($this->get_category_name_to_display($cat2));
return api_strnatcmp($name1, $name2);
}
/**
* @param $item1
* @param $item2
* @return int
*/
function sort_by_name($item1, $item2)
{
return api_strnatcmp($item1->get_name(),$item2->get_name());
}
/**
* @param $item1
* @param $item2
* @return int
*/
function sort_by_average($item1, $item2)
{
$score1 = $this->avgcache[$item1->get_item_type() . $item1->get_id()];
$score2 = $this->avgcache[$item2->get_item_type() . $item2->get_id()];
return $this->compare_scores($score1, $score2);
}
/**
* @param $item1
* @param $item2
* @return int
*/
function sort_by_score($item1, $item2)
{
$score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()];
$score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()];
return $this->compare_scores($score1, $score2);
}
/**
* @param $item1
* @param $item2
* @return int
*/
function sort_by_mask($item1, $item2)
{
$score1 = $this->scorecache[$item1->get_item_type() . $item1->get_id()];
$score2 = $this->scorecache[$item2->get_item_type() . $item2->get_id()];
return ScoreDisplay :: compare_scores_by_custom_display($score1, $score2);
}
/**
* @param $score1
* @param $score2
* @return int
*/
function compare_scores($score1, $score2)
{
if (!isset($score1)) {
return (isset($score2) ? 1 : 0);
} elseif (!isset($score2)) {
return -1;
} elseif (($score1[0]/$score1[1]) == ($score2[0]/$score2[1])) {
return 0;
} else {
return (($score1[0]/$score1[1]) < ($score2[0]/$score2[1]) ? -1 : 1);
}
}
/**
* @param $item
* @return mixed
*/
private function build_course_name($item)
{
return $this->get_course_name_from_code_cached($item->get_course_code());
}
/**
* @param $item
* @return string
*/
private function build_category_name($item)
{
$cat = $this->get_category_cached($item->get_category_id());
return $this->get_category_name_to_display($cat);
}
/**
* @param $item
* @param $ignore_score_color
* @return string
*/
private function build_average_column($item, $ignore_score_color)
{
if (isset($this->avgcache)) {
$avgscore = $this->avgcache[$item->get_item_type() . $item->get_id()];
} else {
$avgscore = $item->calc_score();
}
$scoredisplay = ScoreDisplay :: instance();
$displaytype = SCORE_AVERAGE;
/*if ($ignore_score_color)
$displaytype |= SCORE_IGNORE_SPLIT;
*/
return $scoredisplay->display_score($avgscore, $displaytype);
}
/**
* @param $item
* @param $ignore_score_color
* @return string
*/
private function build_result_column($item, $ignore_score_color)
{
$studscore = $this->scorecache[$item->get_item_type() . $item->get_id()];
$scoredisplay = ScoreDisplay :: instance();
$displaytype = SCORE_DIV_PERCENT;
if ($ignore_score_color) {
$displaytype |= SCORE_IGNORE_SPLIT;
}
return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_DEFAULT);
}
/**
* @param $item
* @param $ignore_score_color
* @return string
*/
private function build_mask_column($item, $ignore_score_color)
{
$studscore = $this->scorecache[$item->get_item_type() . $item->get_id()];
$scoredisplay = ScoreDisplay :: instance();
$displaytype = SCORE_DIV_PERCENT;
if ($ignore_score_color) {
$displaytype |= SCORE_IGNORE_SPLIT;
}
return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_CUSTOM);
}
/**
* @param $coursecode
* @return mixed
*/
private function get_course_name_from_code_cached($coursecode)
{
if (isset ($this->coursecodecache)
&& isset ($this->coursecodecache[$coursecode])) {
return $this->coursecodecache[$coursecode];
} else {
$name = CourseManager::getCourseNameFromCode($coursecode);
$this->coursecodecache[$coursecode] = $name;
return $name;
}
}
/**
* @param $category_id
* @return null
*/
private function get_category_cached($category_id)
{
if (isset ($this->categorycache)
&& isset ($this->categorycache[$category_id])) {
return $this->categorycache[$category_id];
}else {
$cat = Category::load($category_id);
if (isset($cat)){
$this->categorycache[$category_id] = $cat[0];
return $cat[0];
}else
return null;
}
}
/**
* @param $cat
* @return string
*/
private function get_category_name_to_display($cat)
{
if (isset($cat)) {
if ($cat->get_parent_id() == '0' || $cat->get_parent_id() == null){
return '';
} else {
return $cat->get_name();
}
} else {
return '';
}
}
return $scoredisplay->display_score($avgscore, $displaytype);
}
/**
* @param $item
* @param $ignore_score_color
* @return string
*/
private function build_result_column($item, $ignore_score_color)
{
$studscore = $this->scorecache[$item->get_item_type() . $item->get_id()];
$scoredisplay = ScoreDisplay :: instance();
$displaytype = SCORE_DIV_PERCENT;
if ($ignore_score_color) {
$displaytype |= SCORE_IGNORE_SPLIT;
}
return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_DEFAULT);
}
/**
* @param $item
* @param $ignore_score_color
* @return string
*/
private function build_mask_column($item, $ignore_score_color)
{
$studscore = $this->scorecache[$item->get_item_type() . $item->get_id()];
$scoredisplay = ScoreDisplay :: instance();
$displaytype = SCORE_DIV_PERCENT;
if ($ignore_score_color) {
$displaytype |= SCORE_IGNORE_SPLIT;
}
return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_CUSTOM);
}
/**
* @param $coursecode
* @return mixed
*/
private function get_course_name_from_code_cached($coursecode)
{
if (isset ($this->coursecodecache) && isset ($this->coursecodecache[$coursecode])) {
return $this->coursecodecache[$coursecode];
} else {
$name = CourseManager::getCourseNameFromCode($coursecode);
$this->coursecodecache[$coursecode] = $name;
return $name;
}
}
/**
* @param $category_id
* @return null
*/
private function get_category_cached($category_id)
{
if (isset ($this->categorycache) && isset ($this->categorycache[$category_id])) {
return $this->categorycache[$category_id];
} else {
$cat = Category::load($category_id);
if (isset($cat)) {
$this->categorycache[$category_id] = $cat[0];
return $cat[0];
} else {
return null;
}
}
}
/**
* @param $cat
* @return string
*/
private function get_category_name_to_display($cat)
{
if (isset($cat)) {
if ($cat->get_parent_id() == '0' || $cat->get_parent_id() == null) {
return '';
} else {
return $cat->get_name();
}
} else {
return '';
}
}
}

@ -115,6 +115,6 @@ $actions.='</div>';
Display :: display_header(get_lang('ResultsPerUser'));
echo $actions;
DisplayGradebook :: display_header_user($_GET['userid']);
DisplayGradebook :: display_header_user($_GET['userid'], $category[0]->get_id());
$user_table->display();
Display :: display_footer();

@ -94,7 +94,6 @@ if (isset($_GET['action']) && $is_allowed_in_course) {
*/
if (api_is_allowed_to_edit(false, true)) {
// Post-actions
if (isset($_POST['action'])) {
switch ($_POST['action']) {
@ -165,7 +164,6 @@ Display::display_introduction_section(TOOL_GROUP);
$actionsLeft = '';
if (api_is_allowed_to_edit(false, true)) {
$actionsLeft .= '<a href="group_creation.php?'.api_get_cidreq().'">'.
Display::return_icon('add-groups.png', get_lang('NewGroupCreate'), '', ICON_SIZE_MEDIUM).'</a>';

@ -188,7 +188,8 @@ $form->addGroup(
'',
Display::return_icon('work.png', get_lang('GroupWork'), array(), ICON_SIZE_SMALL) . ' ' . get_lang('GroupWork'),
'',
false);
false
);
// Calendar settings.
$group = array(
@ -275,17 +276,17 @@ $currentUrl = api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq();
if ($form->validate()) {
$values = $form->exportValues();
if ($values['max_member_no_limit'] == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) {
$max_member = GroupManager::MEMBER_PER_GROUP_NO_LIMIT;
} else {
$max_member = $values['max_member'];
}
$max_member = GroupManager::MEMBER_PER_GROUP_NO_LIMIT;
} else {
$max_member = $values['max_member'];
}
$self_reg_allowed = isset($values['self_reg_allowed']) ? $values['self_reg_allowed'] : 0;
$self_unreg_allowed = isset($values['self_unreg_allowed']) ? $values['self_unreg_allowed'] : 0;
$self_reg_allowed = isset($values['self_reg_allowed']) ? $values['self_reg_allowed'] : 0;
$self_unreg_allowed = isset($values['self_unreg_allowed']) ? $values['self_unreg_allowed'] : 0;
switch ($values['action']) {
case 'update_settings':
GroupManager::update_category(
switch ($values['action']) {
case 'update_settings':
GroupManager::update_category(
$values['id'],
$values['title'],
$values['description'],
@ -304,8 +305,8 @@ if ($form->validate()) {
Display::addFlash(Display::return_message(get_lang('GroupPropertiesModified')));
header("Location: ".$currentUrl."&category=".$values['id']);
exit;
case 'add_category':
GroupManager :: create_category(
case 'add_category':
GroupManager :: create_category(
$values['title'],
$values['description'],
$values['doc_state'],
@ -323,8 +324,8 @@ if ($form->validate()) {
Display::addFlash(Display::return_message(get_lang('CategoryCreated')));
header("Location: ".$currentUrl);
exit;
break;
}
break;
}
}
// Else display the form
@ -339,10 +340,10 @@ echo '</div>';
$defaults = $category;
$defaults['action'] = $action;
if ($defaults['max_student'] == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) {
$defaults['max_member_no_limit'] = GroupManager::MEMBER_PER_GROUP_NO_LIMIT;
$defaults['max_member_no_limit'] = GroupManager::MEMBER_PER_GROUP_NO_LIMIT;
} else {
$defaults['max_member_no_limit'] = 1;
$defaults['max_member'] = $defaults['max_student'];
$defaults['max_member_no_limit'] = 1;
$defaults['max_member'] = $defaults['max_student'];
}
$form->setDefaults($defaults);
$form->display();

@ -52,10 +52,10 @@ if (isset($_POST['action'])) {
exit;
break;
case 'create_subgroups':
GroupManager::create_subgroups(
$_POST['base_group'],
$_POST['number_of_groups']
);
GroupManager::create_subgroups(
$_POST['base_group'],
$_POST['number_of_groups']
);
Display::addFlash(Display::return_message(get_lang('GroupsAdded')));
header("Location: ".$currentUrl);
exit;
@ -146,25 +146,25 @@ if (isset($_POST['number_of_groups'])) {
</tr>
EOT;
$renderer->setCustomElementTemplate($element_template);
$renderer->setCustomElementTemplate($element_template);
$form->addElement('header', $nameTools);
$form->addElement('hidden', 'action');
$form->addElement('hidden', 'number_of_groups');
$defaults = array();
// Table heading
$group_el = array();
$group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupName').'</b>');
$form->addElement('hidden', 'action');
$form->addElement('hidden', 'number_of_groups');
$defaults = array();
// Table heading
$group_el = array();
$group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupName').'</b>');
if (api_get_setting('allow_group_categories') === 'true') {
$group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupCategory').'</b>');
}
$group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupPlacesThis').'</b>');
$form->addGroup($group_el, 'groups', null, "</td><td>", false);
// Checkboxes
if ($_POST['number_of_groups'] > 1) {
$group_el = array ();
$group_el[] = $form->createElement('static', null, null, ' ');
if (api_get_setting('allow_group_categories') === 'true') {
if (api_get_setting('allow_group_categories') === 'true') {
$group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupCategory').'</b>');
}
$group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupPlacesThis').'</b>');
$form->addGroup($group_el, 'groups', null, "</td><td>", false);
// Checkboxes
if ($_POST['number_of_groups'] > 1) {
$group_el = array ();
$group_el[] = $form->createElement('static', null, null, ' ');
if (api_get_setting('allow_group_categories') === 'true') {
$group_el[] = $form->createElement(
'checkbox',
'same_category',
@ -172,7 +172,7 @@ EOT;
get_lang('SameForAll'),
array('onclick' => "javascript: switch_state('category');")
);
}
}
$group_el[] = $form->createElement(
'checkbox',
'same_places',
@ -180,13 +180,13 @@ EOT;
get_lang('SameForAll'),
array('onclick' => "javascript: switch_state('places');")
);
$form->addGroup($group_el, 'groups', null, '</td><td>', false);
}
// Properties for all groups
for ($group_number = 0; $group_number < $_POST['number_of_groups']; $group_number ++) {
$group_el = array();
$group_el[] = $form->createElement('text', 'group_'.$group_number.'_name');
if (api_get_setting('allow_group_categories') === 'true') {
$form->addGroup($group_el, 'groups', null, '</td><td>', false);
}
// Properties for all groups
for ($group_number = 0; $group_number < $_POST['number_of_groups']; $group_number ++) {
$group_el = array();
$group_el[] = $form->createElement('text', 'group_'.$group_number.'_name');
if (api_get_setting('allow_group_categories') === 'true') {
$group_el[] = $form->createElement(
'select',
'group_'.$group_number.'_category',
@ -194,7 +194,7 @@ EOT;
$cat_options,
array('id' => 'category_'.$group_number)
);
} else {
} else {
$group_el[] = $form->createElement('hidden', 'group_'.$group_number.'_category', 0);
$defaults['group_'.$group_number.'_category'] = array_keys($cat_options)[0];
}
@ -205,110 +205,110 @@ EOT;
array('class' => 'span1', 'id' => 'places_'.$group_number)
);
if ($_POST['number_of_groups'] < 10000) {
if ($group_id < 10) {
$prev = '000';
} elseif ($group_id < 100) {
$prev = '00';
} elseif ($group_id<1000) {
$prev = '0';
} else {
$prev = '';
}
}
if ($_POST['number_of_groups'] < 10000) {
if ($group_id < 10) {
$prev = '000';
} elseif ($group_id < 100) {
$prev = '00';
} elseif ($group_id<1000) {
$prev = '0';
} else {
$prev = '';
}
}
$defaults['group_'.$group_number.'_name'] = get_lang('GroupSingle').' '.$prev.$group_id ++;
$form->addGroup($group_el, 'group_'.$group_number, null, '</td><td>', false);
}
$defaults['action'] = 'create_groups';
$defaults['number_of_groups'] = intval($_POST['number_of_groups']);
$form->setDefaults($defaults);
$form->addButtonCreate(get_lang('CreateGroup'), 'submit');
$defaults['group_'.$group_number.'_name'] = get_lang('GroupSingle').' '.$prev.$group_id ++;
$form->addGroup($group_el, 'group_'.$group_number, null, '</td><td>', false);
}
$defaults['action'] = 'create_groups';
$defaults['number_of_groups'] = intval($_POST['number_of_groups']);
$form->setDefaults($defaults);
$form->addButtonCreate(get_lang('CreateGroup'), 'submit');
$form->display();
}
} else {
/*
* Show form to generate new groups
*/
$create_groups_form = new FormValidator('create_groups', 'post', api_get_self().'?'.api_get_cidreq());
$create_groups_form->addElement('header', $nameTools);
/*
* Show form to generate new groups
*/
$create_groups_form = new FormValidator('create_groups', 'post', api_get_self().'?'.api_get_cidreq());
$create_groups_form->addElement('header', $nameTools);
$create_groups_form->addText('number_of_groups',get_lang('NumberOfGroupsToCreate'),null,array('value'=>'1'));
$create_groups_form->addButton('submit', get_lang('ProceedToCreateGroup'),'plus','primary');
$defaults = array();
$defaults['number_of_groups'] = 1;
$create_groups_form->setDefaults($defaults);
$create_groups_form->display();
$defaults = array();
$defaults['number_of_groups'] = 1;
$create_groups_form->setDefaults($defaults);
$create_groups_form->display();
/*
* Show form to generate subgroups
*/
if (api_get_setting('allow_group_categories') === 'true' && count(GroupManager :: get_group_list()) > 0) {
$base_group_options = array ();
$groups = GroupManager :: get_group_list();
foreach ($groups as $index => $group) {
$number_of_students = GroupManager :: number_of_students($group['id']);
if ($number_of_students > 0) {
$base_group_options[$group['id']] = $group['name'].' ('.$number_of_students.' '.get_lang('Users').')';
}
}
if (count($base_group_options) > 0) {
$create_subgroups_form = new FormValidator('create_subgroups', 'post', api_get_self().'?'.api_get_cidreq());
/*
* Show form to generate subgroups
*/
if (api_get_setting('allow_group_categories') === 'true' && count(GroupManager :: get_group_list()) > 0) {
$base_group_options = array ();
$groups = GroupManager :: get_group_list();
foreach ($groups as $index => $group) {
$number_of_students = GroupManager :: number_of_students($group['id']);
if ($number_of_students > 0) {
$base_group_options[$group['id']] = $group['name'].' ('.$number_of_students.' '.get_lang('Users').')';
}
}
if (count($base_group_options) > 0) {
$create_subgroups_form = new FormValidator('create_subgroups', 'post', api_get_self().'?'.api_get_cidreq());
$create_subgroups_form->addElement('header', get_lang('CreateSubgroups'));
$create_subgroups_form->addElement('html', get_lang('CreateSubgroupsInfo'));
$create_subgroups_form->addElement('hidden', 'action');
$group_el = array();
$group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('CreateNumberOfGroups'));
$group_el[] = $create_subgroups_form->createElement('text', 'number_of_groups', null, array('size' => 3));
$group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('WithUsersFrom'));
$group_el[] = $create_subgroups_form->createElement('select', 'base_group', null, $base_group_options);
$group_el[] = $create_subgroups_form->createElement('button', 'submit', get_lang('Ok'));
$create_subgroups_form->addGroup($group_el, 'create_groups', null, null, false);
$defaults = array();
$defaults['action'] = 'create_subgroups';
$create_subgroups_form->setDefaults($defaults);
$create_subgroups_form->display();
}
}
$create_subgroups_form->addElement('hidden', 'action');
$group_el = array();
$group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('CreateNumberOfGroups'));
$group_el[] = $create_subgroups_form->createElement('text', 'number_of_groups', null, array('size' => 3));
$group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('WithUsersFrom'));
$group_el[] = $create_subgroups_form->createElement('select', 'base_group', null, $base_group_options);
$group_el[] = $create_subgroups_form->createElement('button', 'submit', get_lang('Ok'));
$create_subgroups_form->addGroup($group_el, 'create_groups', null, null, false);
$defaults = array();
$defaults['action'] = 'create_subgroups';
$create_subgroups_form->setDefaults($defaults);
$create_subgroups_form->display();
}
}
/*
* Show form to generate groups from classes subscribed to the course
*/
/*
* Show form to generate groups from classes subscribed to the course
*/
$options['where'] = array(" usergroup.course_id = ? " => api_get_course_int_id());
$obj = new UserGroup();
$classes = $obj->getUserGroupInCourse($options);
if (count($classes) > 0) {
echo '<b>'.get_lang('GroupsFromClasses').'</b>';
echo '<blockquote>';
echo '<p>'.get_lang('GroupsFromClassesInfo').'</p>';
echo '<ul>';
foreach ($classes as $index => $class) {
$number_of_users = count($obj->get_users_by_usergroup($class['id']));
echo '<li>';
echo $class['name'];
echo ' ('.$number_of_users.' '.get_lang('Users').')';
echo '</li>';
}
echo '</ul>';
if (count($classes) > 0) {
echo '<b>'.get_lang('GroupsFromClasses').'</b>';
echo '<blockquote>';
echo '<p>'.get_lang('GroupsFromClassesInfo').'</p>';
echo '<ul>';
foreach ($classes as $index => $class) {
$number_of_users = count($obj->get_users_by_usergroup($class['id']));
echo '<li>';
echo $class['name'];
echo ' ('.$number_of_users.' '.get_lang('Users').')';
echo '</li>';
}
echo '</ul>';
$create_class_groups_form = new FormValidator('create_class_groups_form', 'post', api_get_self().'?'.api_get_cidreq());
$create_class_groups_form->addElement('hidden', 'action');
if (api_get_setting('allow_group_categories') === 'true') {
$group_categories = GroupManager :: get_categories();
$cat_options = array();
foreach ($group_categories as $index => $category) {
$cat_options[$category['id']] = $category['title'];
}
$create_class_groups_form->addElement('select', 'group_category', null, $cat_options);
} else {
$create_class_groups_form->addElement('hidden', 'group_category');
}
$create_class_groups_form->addElement('submit', 'submit', get_lang('Ok'));
$defaults['group_category'] = GroupManager::DEFAULT_GROUP_CATEGORY;
$defaults['action'] = 'create_class_groups';
$create_class_groups_form->setDefaults($defaults);
$create_class_groups_form->display();
echo '</blockquote>';
}
$create_class_groups_form = new FormValidator('create_class_groups_form', 'post', api_get_self().'?'.api_get_cidreq());
$create_class_groups_form->addElement('hidden', 'action');
if (api_get_setting('allow_group_categories') === 'true') {
$group_categories = GroupManager :: get_categories();
$cat_options = array();
foreach ($group_categories as $index => $category) {
$cat_options[$category['id']] = $category['title'];
}
$create_class_groups_form->addElement('select', 'group_category', null, $cat_options);
} else {
$create_class_groups_form->addElement('hidden', 'group_category');
}
$create_class_groups_form->addElement('submit', 'submit', get_lang('Ok'));
$defaults['group_category'] = GroupManager::DEFAULT_GROUP_CATEGORY;
$defaults['action'] = 'create_class_groups';
$create_class_groups_form->setDefaults($defaults);
$create_class_groups_form->display();
echo '</blockquote>';
}
}
Display :: display_footer();

@ -84,31 +84,31 @@ if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') {
$actions = '<a href="group_creation.php?'.api_get_cidreq().'">'.
Display::return_icon('add.png', get_lang('NewGroupCreate'), '', ICON_SIZE_MEDIUM).'</a>';
if (api_get_setting('allow_group_categories') === 'true') {
$actions.= '<a href="group_category.php?'.api_get_cidreq().'&action=add_category">'.
Display::return_icon('new_folder.png', get_lang('AddCategory'), '', ICON_SIZE_MEDIUM).'</a>';
} else {
$actions.= '<a href="group_category.php?'.api_get_cidreq().'&id=2">'.
Display::return_icon('settings.png', get_lang('PropModify'), '', ICON_SIZE_MEDIUM).'</a>';
}
$actions.= '<a href="import.php?'.api_get_cidreq().'&action=import">'.
Display::return_icon('import_csv.png', get_lang('Import'), '', ICON_SIZE_MEDIUM).'</a>';
if (api_get_setting('allow_group_categories') === 'true') {
$actions.= '<a href="group_category.php?'.api_get_cidreq().'&action=add_category">'.
Display::return_icon('new_folder.png', get_lang('AddCategory'), '', ICON_SIZE_MEDIUM).'</a>';
} else {
$actions.= '<a href="group_category.php?'.api_get_cidreq().'&id=2">'.
Display::return_icon('settings.png', get_lang('PropModify'), '', ICON_SIZE_MEDIUM).'</a>';
}
$actions.= '<a href="import.php?'.api_get_cidreq().'&action=import">'.
Display::return_icon('import_csv.png', get_lang('Import'), '', ICON_SIZE_MEDIUM).'</a>';
$actions.= '<a href="group_overview.php?'.api_get_cidreq().'&action=export_all&type=csv">'.
Display::return_icon('export_csv.png', get_lang('Export'), '', ICON_SIZE_MEDIUM).'</a>';
$actions.= '<a href="group_overview.php?'.api_get_cidreq().'&action=export_all&type=csv">'.
Display::return_icon('export_csv.png', get_lang('Export'), '', ICON_SIZE_MEDIUM).'</a>';
$actions.= '<a href="group_overview.php?'.api_get_cidreq().'&action=export&type=xls">'.
Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).'</a>';
$actions.= '<a href="group_overview.php?'.api_get_cidreq().'&action=export&type=xls">'.
Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM).'</a>';
$actions.= '<a href="group_overview.php?'.api_get_cidreq().'&action=export_pdf">'.
Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a>';
$actions.= '<a href="group_overview.php?'.api_get_cidreq().'&action=export_pdf">'.
Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a>';
$actions.= '<a href="group.php?'.api_get_cidreq().'">'.
Display::return_icon('group.png', get_lang('Groups'),'',ICON_SIZE_MEDIUM).'</a>';
$actions.= '<a href="group.php?'.api_get_cidreq().'">'.
Display::return_icon('group.png', get_lang('Groups'),'',ICON_SIZE_MEDIUM).'</a>';
$actions.= '<a href="../user/user.php?'.api_get_cidreq().'">'.
Display::return_icon('user.png', get_lang('GoTo').' '.get_lang('Users'), '', ICON_SIZE_MEDIUM).'</a>';
$actions.= '<a href="../user/user.php?'.api_get_cidreq().'">'.
Display::return_icon('user.png', get_lang('GoTo').' '.get_lang('Users'), '', ICON_SIZE_MEDIUM).'</a>';
// Action links
echo '<div class="actions">';

@ -422,7 +422,7 @@ function get_group_user_data($from, $number_of_items, $column, $direction)
$course_id = api_get_course_int_id();
// Query
if (api_get_setting('show_email_addresses') == 'true') {
if (api_get_setting('show_email_addresses') === 'true') {
$sql = "SELECT user.id AS col0,
".(api_is_western_name_order() ?
"user.firstname AS col1,
@ -443,21 +443,20 @@ function get_group_user_data($from, $number_of_items, $column, $direction)
} else {
if (api_is_allowed_to_edit()) {
$sql = "SELECT DISTINCT
u.id AS col0,
".(api_is_western_name_order() ?
"u.firstname AS col1,
u.lastname AS col2,"
:
"u.lastname AS col1,
u.firstname AS col2,"
)."
u.email AS col3
FROM $table_user u
INNER JOIN $table_group_user gu
ON (gu.user_id = u.id) AND gu.c_id = $course_id
WHERE gu.group_id = '".Database::escape_string($current_group['id'])."'
ORDER BY col$column $direction
LIMIT $from, $number_of_items";
u.id AS col0,
".(api_is_western_name_order() ?
"u.firstname AS col1,
u.lastname AS col2,"
:
"u.lastname AS col1,
u.firstname AS col2,")."
u.email AS col3
FROM $table_user u
INNER JOIN $table_group_user gu
ON (gu.user_id = u.id) AND gu.c_id = $course_id
WHERE gu.group_id = '".Database::escape_string($current_group['id'])."'
ORDER BY col$column $direction
LIMIT $from, $number_of_items";
} else {
$sql = "SELECT DISTINCT
user.id AS col0,
@ -467,14 +466,14 @@ function get_group_user_data($from, $number_of_items, $column, $direction)
:
"user.lastname AS col1,
user.firstname AS col2 "
)."
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.id AND
group_rel_user.group_id = '".Database::escape_string($current_group['id'])."'
ORDER BY col$column $direction
LIMIT $from,$number_of_items";
)."
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.id AND
group_rel_user.group_id = '".Database::escape_string($current_group['id'])."'
ORDER BY col$column $direction
LIMIT $from,$number_of_items";
}
}

@ -152,7 +152,7 @@ if (!empty($complete_user_list)) {
if ($orderUserListByOfficialCode === 'true') {
$officialCode = !empty($user['official_code']) ? $user['official_code']." - " : '? - ';
$name = $officialCode." ".api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')';
$name = $officialCode.' '.api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')';
}
$possible_users[$user['user_id']] = $name.$groupNameListToString;
}

@ -19,13 +19,13 @@ $current_course_tool = TOOL_GROUP;
api_protect_course_script(true);
$group_id = api_get_group_id();
$current_group = GroupManager :: get_group_properties($group_id);
$current_group = GroupManager::get_group_properties($group_id);
$nameTools = get_lang('EditGroup');
$interbreadcrumb[] = array ('url' => 'group.php?'.api_get_cidreq(), 'name' => get_lang('Groups'));
$interbreadcrumb[] = array ('url' => 'group_space.php?'.api_get_cidreq(), 'name' => $current_group['name']);
$is_group_member = GroupManager :: is_tutor_of_group(api_get_user_id(), $group_id);
$is_group_member = GroupManager::is_tutor_of_group(api_get_user_id(), $group_id);
if (!api_is_allowed_to_edit(false, true) && !$is_group_member) {
api_not_allowed(true);
@ -97,9 +97,6 @@ function sort_users($user_a, $user_b)
}
}
/* MAIN CODE */
$htmlHeadXtra[] = '<script>
$(document).ready( function() {
$("#max_member").on("focus", function() {
@ -126,12 +123,11 @@ $userGroup = new UserGroup();
$orderUserListByOfficialCode = api_get_setting('order_user_list_by_official_code');
if (!empty($complete_user_list)) {
usort($complete_user_list, 'sort_users');
foreach ($complete_user_list as $index => $user) {
//prevent invitee users add to groups or tutors - see #8091
if ($user['status'] != INVITEE) {
$officialCode = !empty($user['official_code']) ? ' - '.$user['official_code'] : null;
$groups = $userGroup->getUserGroupListByUser($user['user_id']);
$groupNameListToString = '';
if (!empty($groups)) {
@ -146,7 +142,7 @@ if (!empty($complete_user_list)) {
if ($orderUserListByOfficialCode === 'true') {
$officialCode = !empty($user['official_code']) ? $user['official_code']." - " : '? - ';
$name = $officialCode." ".api_get_person_name(
$name = $officialCode.' '.api_get_person_name(
$user['firstname'],
$user['lastname']
).' ('.$user['username'].')';

@ -7,9 +7,6 @@
*
* @package chamilo.help
*/
/**
* Code
*/
require '../inc/global.inc.php';
header('Content-Type: text/html; charset='.api_get_system_encoding());

@ -18,7 +18,12 @@ switch ($action) {
}
$point_info = CourseManager::get_course_ranking($course_id, 0);
$ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote';
$rating = Display::return_rating_system('star_'.$course_id, $ajax_url.'&amp;course_id='.$course_id, $point_info, false);
$rating = Display::return_rating_system(
'star_'.$course_id,
$ajax_url.'&amp;course_id='.$course_id,
$point_info,
false
);
echo $rating;
break;
@ -251,9 +256,7 @@ switch ($action) {
foreach ($coursesData as $courseId => $course) {
$coachData = SessionManager::getCoachesByCourseSession($sessionId, $courseId);
$coachName = '';
if (!empty($coachData)) {
$userResult = Database::select('lastname,firstname', $userTable, array(
'where' => array(
@ -262,7 +265,7 @@ switch ($action) {
), 'first');
$coachName = api_get_person_name($userResult['firstname'], $userResult['lastname']);
}
}
$courses[] = array(
'id' => $courseId,

@ -63,12 +63,12 @@ switch ($action) {
echo json_encode($response_data);
}
break;
case 'show_course_information' :
require_once '../global.inc.php';
case 'show_course_information' :
require_once '../global.inc.php';
// Get the name of the database course.
$tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
$course_info = api_get_course_info($_GET['code']);
// Get the name of the database course.
$tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
$course_info = api_get_course_info($_GET['code']);
if (
api_get_setting('course_catalog_hide_private') === 'true' &&
@ -78,24 +78,24 @@ switch ($action) {
break;
}
$sql = "SELECT * FROM $tbl_course_description
WHERE c_id = ".$course_info['real_id']." AND session_id = 0
ORDER BY id";
$result = Database::query($sql);
if (Database::num_rows($result) > 0 ) {
while ($description = Database::fetch_object($result)) {
$descriptions[$description->id] = $description;
}
$sql = "SELECT * FROM $tbl_course_description
WHERE c_id = ".$course_info['real_id']." AND session_id = 0
ORDER BY id";
$result = Database::query($sql);
if (Database::num_rows($result) > 0 ) {
while ($description = Database::fetch_object($result)) {
$descriptions[$description->id] = $description;
}
// Function that displays the details of the course description in html.
echo CourseManager::get_details_course_description_html(
echo CourseManager::get_details_course_description_html(
$descriptions,
api_get_system_encoding(),
false
);
} else {
echo get_lang('NoDescription');
}
break;
} else {
echo get_lang('NoDescription');
}
break;
case 'session_courses_lp_default':
/**
* @todo this functions need to belong to a class or a special
@ -110,7 +110,7 @@ switch ($action) {
$sidx = isset($_REQUEST['sidx']) && !empty($_REQUEST['sidx']) ? $_REQUEST['sidx'] : 'id';
$sord = $_REQUEST['sord']; //asc or desc
if (!in_array($sord, array('asc','desc'))) {
$sord = 'desc';
$sord = 'desc';
}
$session_id = intval($_REQUEST['session_id']);
$course_id = intval($_REQUEST['course_id']);
@ -124,7 +124,7 @@ switch ($action) {
$my_session_list[] = $item['id_session'];
}
if (!in_array($session_id, $my_session_list)) {
break;
break;
}
}
@ -473,7 +473,7 @@ switch ($action) {
$response = new stdClass();
$i =0;
foreach ($temp as $key=>$row) {
foreach ($temp as $key => $row) {
$row = $row['cell'];
if (!empty($row)) {
if ($key >= $start && $key < ($start + $limit)) {
@ -499,7 +499,7 @@ switch ($action) {
echo json_encode($response);
break;
default:
echo '';
default:
echo '';
}
exit;

@ -43,7 +43,6 @@ switch ($action) {
$json = array();
if (!empty($result)) {
$json['name'] = Display::url(
api_htmlentities($result->title),
api_htmlentities(api_get_path(WEB_CODE_PATH).'dropbox/index.php?'.api_get_cidreq()),

@ -24,5 +24,6 @@ switch ($action) {
break;
default:
echo '';
}
break;
}
exit;

@ -65,7 +65,6 @@ switch ($action) {
break;
case 'update_lp_item_order':
if (api_is_allowed_to_edit(null, true)) {
$new_order = $_POST['new_order'];
$sections = explode('^', $new_order);
$new_array = array();
@ -85,7 +84,7 @@ switch ($action) {
foreach ($tab_parents_id as $parent_id) {
$Same_parent_LP_item_list = $LP_item_list->get_item_with_same_parent($parent_id);
$previous_item_id = 0;
for ($i=0; $i < count($Same_parent_LP_item_list->list);$i++) {
for ($i=0; $i < count($Same_parent_LP_item_list->list); $i++) {
$item_id = $Same_parent_LP_item_list->list[$i]->id;
// display_order
$display_order = $i + 1;
@ -104,10 +103,10 @@ switch ($action) {
foreach ($LP_item_list->list as $LP_item) {
$params = array();
$params['display_order'] = $LP_item->display_order;
$params['previous_item_id'] = $LP_item->previous_item_id;
$params['next_item_id'] = $LP_item->next_item_id;
$params['parent_item_id'] = $LP_item->parent_item_id;
$params['display_order'] = $LP_item->display_order;
$params['previous_item_id'] = $LP_item->previous_item_id;
$params['next_item_id'] = $LP_item->next_item_id;
$params['parent_item_id'] = $LP_item->parent_item_id;
Database::update(
$tbl_lp_item,

@ -51,7 +51,7 @@ switch ($action) {
if (api_get_setting('allow_social_tool') === 'true' && api_get_setting('allow_message_tool') === 'true') {
// All users
if (api_get_setting('allow_send_message_to_all_platform_users') === 'true' || api_is_platform_admin() ) {
if (api_get_setting('allow_send_message_to_all_platform_users') === 'true' || api_is_platform_admin()) {
if ($access_url_id != 0) {
$sql = "SELECT DISTINCT u.user_id as id, u.firstname, u.lastname, u.email
FROM $tbl_user u LEFT JOIN $tbl_access_url_rel_user r ON u.user_id = r.user_id

@ -6,7 +6,6 @@
require_once '../global.inc.php';
$action = $_GET['a'];
switch ($action) {
case 'access_detail':
$user_id = intval($_REQUEST['student']);
@ -36,7 +35,6 @@ switch ($action) {
echo $foo_print;
break;
case 'access_detail_by_date':
$db = array('is_empty' => true);
$start_date = isset($_REQUEST['startDate']) ? $_REQUEST['startDate'] : "";

@ -4,7 +4,7 @@ require_once '../global.inc.php';
$action = $_GET['a'];
switch($action) {
switch ($action) {
case 'load_online_user':
if (isset($_SESSION['who_is_online_counter'])) {
$_SESSION['who_is_online_counter']++;

@ -1,16 +1,14 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Responses to AJAX calls
*/
use Chamilo\CoreBundle\Entity\Sequence;
use Chamilo\CoreBundle\Entity\SequenceResource;
use Fhaculty\Graph\Graph;
use Fhaculty\Graph\Vertex;
/**
* Responses to AJAX calls
*/
require_once '../global.inc.php';
$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;

@ -136,7 +136,6 @@ switch ($action) {
$entityManager = Database::getManager();
$usersRepo = $entityManager->getRepository('ChamiloUserBundle:User');
$users = $usersRepo->searchUsersByStatus($_GET['q'], COURSEMANAGER);
foreach ($users as $user) {

@ -46,7 +46,7 @@ switch ($action) {
if (isset($_GET['denied_friend_id'])) {
SocialManager::invitation_denied($_GET['denied_friend_id'], $current_user_id);
Display::display_confirmation_message(api_xml_http_response_encode(get_lang('InvitationDenied')));
header('Location: ' . api_get_path(WEB_CODE_PATH) . 'social/invitations.php');
}
break;
@ -65,7 +65,7 @@ switch ($action) {
echo '';
break;
}
$user_id = api_get_user_id();
$user_id = api_get_user_id();
$name_search= Security::remove_XSS($_POST['search_name_q']);
$number_friends = 0;
@ -77,11 +77,10 @@ switch ($action) {
$friend_html = '';
$number_of_images = 8;
$number_friends = count($friends);
if ($number_friends != 0) {
$number_loop = ($number_friends/$number_of_images);
$loop_friends = ceil($number_loop);
$number_loop = ($number_friends/$number_of_images);
$loop_friends = ceil($number_loop);
$j=0;
for ($k=0; $k<$loop_friends; $k++) {
if ($j==$number_of_images) {
@ -237,7 +236,7 @@ switch ($action) {
echo $html;
break;
case 'voteMsg':
break;
default:
echo '';
}

@ -80,79 +80,79 @@ switch ($action) {
$return = $thematic->get_thematic_advance_div($thematic_advance_data);
echo $return[$_REQUEST['thematic_id']][$_REQUEST['thematic_advance_id']];*/
break;
case 'get_datetime_by_attendance':
$attendance_id = intval($_REQUEST['attendance_id']);
$thematic_advance_id = intval($_REQUEST['thematic_advance_id']);
case 'get_datetime_by_attendance':
$attendance_id = intval($_REQUEST['attendance_id']);
$thematic_advance_id = intval($_REQUEST['thematic_advance_id']);
$label = '';
$input_select = '';
if (!empty($attendance_id)) {
$attendance = new Attendance();
$thematic = new Thematic();
$thematic_list = $thematic->get_thematic_list();
$label = '';
$input_select = '';
if (!empty($attendance_id)) {
$attendance = new Attendance();
$thematic = new Thematic();
$thematic_list = $thematic->get_thematic_list();
$my_list = $thematic_list_temp = array();
foreach ($thematic_list as $item) {
$my_list = $thematic->get_thematic_advance_by_thematic_id($item['id']);
$thematic_list_temp = array_merge($my_list, $thematic_list_temp);
}
$new_thematic_list = array();
$my_list = $thematic_list_temp = array();
foreach ($thematic_list as $item) {
$my_list = $thematic->get_thematic_advance_by_thematic_id($item['id']);
$thematic_list_temp = array_merge($my_list, $thematic_list_temp);
}
$new_thematic_list = array();
foreach($thematic_list_temp as $item) {
if (!empty($item['attendance_id']) ) {
$new_thematic_list[$item['id']] = array('attendance_id' =>$item['attendance_id'], 'start_date'=>$item['start_date']);
}
}
foreach($thematic_list_temp as $item) {
if (!empty($item['attendance_id']) ) {
$new_thematic_list[$item['id']] = array('attendance_id' =>$item['attendance_id'], 'start_date'=>$item['start_date']);
}
}
$attendance_calendar = $attendance->get_attendance_calendar($attendance_id);
$attendance_calendar = $attendance->get_attendance_calendar($attendance_id);
$label = get_lang('StartDate');
if (!empty($attendance_calendar)) {
$input_select .= '<select id="start_date_select_calendar" name="start_date_by_attendance" size="5">';
foreach ($attendance_calendar as $calendar) {
$selected = null;
$insert = true;
//checking if was already taken
foreach ($new_thematic_list as $key => $thematic_item) {
//if ($calendar['db_date_time'] == $thematic_item['start_date'] && $calendar['attendance_id'] == $thematic_item['attendance_id'] ) {
if ($calendar['db_date_time'] == $thematic_item['start_date'] ) {
$insert = false;
if ($thematic_advance_id == $key) {
$insert = true;
$selected = 'selected';
}
break;
}
}
if ($insert == true) {
$input_select .= '<option '.$selected.' value="'.$calendar['date_time'].'">'.$calendar['date_time'].'</option>';
}
}
$input_select .= '</select>';
} else {
$input_select .= '<em>'.get_lang('ThereAreNoRegisteredDatetimeYet').'</em>';
}
}
?>
<div class="form-group">
<label class="col-sm-2 control-label"><?php echo $label ?></label>
<div class="col-sm-10"><?php echo $input_select ?></div>
</div>
<?php
break;
case 'update_done_thematic_advance':
$thematic_advance_id = intval($_GET['thematic_advance_id']);
$total_average = 0;
if (!empty($thematic_advance_id)) {
$thematic = new Thematic();
$affected_rows = $thematic->update_done_thematic_advances($thematic_advance_id);
//if ($affected_rows) {
$total_average = $thematic->get_total_average_of_thematic_advances(api_get_course_id(), api_get_session_id());
//}
}
echo $total_average;
break;
default:
echo '';
$label = get_lang('StartDate');
if (!empty($attendance_calendar)) {
$input_select .= '<select id="start_date_select_calendar" name="start_date_by_attendance" size="5">';
foreach ($attendance_calendar as $calendar) {
$selected = null;
$insert = true;
//checking if was already taken
foreach ($new_thematic_list as $key => $thematic_item) {
//if ($calendar['db_date_time'] == $thematic_item['start_date'] && $calendar['attendance_id'] == $thematic_item['attendance_id'] ) {
if ($calendar['db_date_time'] == $thematic_item['start_date'] ) {
$insert = false;
if ($thematic_advance_id == $key) {
$insert = true;
$selected = 'selected';
}
break;
}
}
if ($insert == true) {
$input_select .= '<option '.$selected.' value="'.$calendar['date_time'].'">'.$calendar['date_time'].'</option>';
}
}
$input_select .= '</select>';
} else {
$input_select .= '<em>'.get_lang('ThereAreNoRegisteredDatetimeYet').'</em>';
}
}
?>
<div class="form-group">
<label class="col-sm-2 control-label"><?php echo $label ?></label>
<div class="col-sm-10"><?php echo $input_select ?></div>
</div>
<?php
break;
case 'update_done_thematic_advance':
$thematic_advance_id = intval($_GET['thematic_advance_id']);
$total_average = 0;
if (!empty($thematic_advance_id)) {
$thematic = new Thematic();
$affected_rows = $thematic->update_done_thematic_advances($thematic_advance_id);
//if ($affected_rows) {
$total_average = $thematic->get_total_average_of_thematic_advances(api_get_course_id(), api_get_session_id());
//}
}
echo $total_average;
break;
default:
echo '';
}
exit;

@ -49,7 +49,6 @@ switch ($action) {
echo '</div>';
if (api_get_setting('allow_message_tool') == 'true') {
echo '<script>';
echo '
$("#send_message_link").on("click", function() {
@ -125,7 +124,6 @@ switch ($action) {
break;
case 'active_user':
if (api_is_platform_admin() && api_global_admin_can_edit_admin($_GET['user_id'])) {
$user_id = intval($_GET['user_id']);
$status = intval($_GET['status']);

@ -104,7 +104,6 @@ switch ($action) {
);
if (isset($resultUpload['url']) && !empty($resultUpload['url'])) {
$title = isset($resultUpload['filename']) && !empty($resultUpload['filename']) ? $resultUpload['filename'] : get_lang('Untitled');
$url = Database::escape_string($resultUpload['url']);
$title = Database::escape_string($title);
@ -148,7 +147,6 @@ switch ($action) {
header('Content-Type: application/json');
echo json_encode($json);
}
break;
default:
echo '';

@ -114,17 +114,18 @@ class Gradebook extends Model
$clean_gradebook = array();
if (!empty($skill_gradebooks_source)) {
foreach($skill_gradebooks_source as $source) {
foreach ($skill_gradebooks_source as $source) {
$clean_gradebook[] = $source['skill_id'];
}
}
//Cleaning skills
$skill_list = array_map('intval', $skill_list);
$skill_list = array_filter($skill_list);
if (!empty($skill_list)) {
$skill_list = array_map('intval', $skill_list);
$skill_list = array_filter($skill_list);
}
if (!empty($skill_list)) {
if (!empty($clean_gradebook)) {
$skill_to_remove = array_diff($clean_gradebook, $skill_list);
}
@ -132,7 +133,7 @@ class Gradebook extends Model
foreach ($skill_list as $skill_id) {
$params = array();
$params['gradebook_id'] = $gradebook_id;
$params['skill_id'] = $skill_id;
$params['skill_id'] = $skill_id;
if (!$skill_gradebook->exists_gradebook_skill($gradebook_id, $skill_id)) {
$skill_gradebook->save($params);
}

Loading…
Cancel
Save