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

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

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

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

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

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

@ -50,6 +50,6 @@ $interbreadcrumb[]= array (
'name' => get_lang('ViewResult') 'name' => get_lang('ViewResult')
); );
Display :: display_header(get_lang('EditResult')); 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; echo $table;
Display :: display_footer(); Display :: display_footer();

@ -44,7 +44,7 @@ while ($row = Database::fetch_row($result)) {
$list_info[] = $row; $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][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'); $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; $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][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'); $list_info[$key][3]=($info_log[3]==1) ? get_lang('GradebookVisible') : get_lang('GradebookInvisible');
} }
@ -55,7 +55,7 @@ $parameters = array(
'selectcat' => $selectCat, '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_additional_parameters($parameters);
$table->set_header(0, get_lang('GradebookNameLog')); $table->set_header(0, get_lang('GradebookNameLog'));
$table->set_header(1, get_lang('GradebookDescriptionLog')); $table->set_header(1, get_lang('GradebookDescriptionLog'));

@ -30,14 +30,19 @@ if (api_is_allowed_to_edit()) {
$displayscore = ScoreDisplay :: instance(); $displayscore = ScoreDisplay :: instance();
Display::display_header(get_lang('EvaluationStatistics')); 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 //Bad, Regular, Good - User definitions
$displays = $displayscore->get_custom_score_display_settings(); $displays = $displayscore->get_custom_score_display_settings();
if (!$displayscore->is_custom() || empty($displays)) { if (!$displayscore->is_custom() || empty($displays)) {
if (api_is_platform_admin() || api_is_course_admin()) { 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 { } else {
$allresults = Result::load(null,null,$eval[0]->get_id()); $allresults = Result::load(null,null,$eval[0]->get_id());
@ -50,7 +55,12 @@ if (!$displayscore->is_custom() || empty($displays)) {
foreach ($allresults as $result) { foreach ($allresults as $result) {
$score = $result->get_score(); $score = $result->get_score();
if (isset($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]++; $nr_items[$display]++;
$resultcount++; $resultcount++;
} }

@ -79,6 +79,8 @@ if (isset($_GET['editres'])) {
} }
$result->save(); $result->save();
unset($result); 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()); header('Location: gradebook_view_result.php?selecteval=' . $select_eval . '&editresmessage=&'.api_get_cidreq());
exit; exit;
} }
@ -100,7 +102,6 @@ if (isset($_GET['import'])) {
if (!$import_result_form->validate()) { if (!$import_result_form->validate()) {
Display :: display_header(get_lang('Import')); Display :: display_header(get_lang('Import'));
} }
$eval[0]->check_lock_permissions(); $eval[0]->check_lock_permissions();
if ($_POST['formSent']) { if ($_POST['formSent']) {
if (!empty($_FILES['import_file']['name'])) { if (!empty($_FILES['import_file']['name'])) {
@ -175,16 +176,21 @@ if (isset($_GET['import'])) {
} }
} else { } else {
header('Location: ' . api_get_self() . '?import=&selecteval=' . $select_eval . '&importnofile='); header('Location: ' . api_get_self() . '?import=&selecteval=' . $select_eval . '&importnofile=');
Display::addFlash(Display::return_message(get_lang('ImportNoFile'), 'warning', false));
exit; exit;
} }
if ($overwritescore != 0) { if ($overwritescore != 0) {
header('Location: ' . api_get_self() . '?selecteval=' . $select_eval. '&importoverwritescore=' . $overwritescore); header('Location: ' . api_get_self() . '?selecteval=' . $select_eval. '&importoverwritescore=' . $overwritescore);
Display::addFlash(Display::return_message(get_lang('ImportOverWriteScore') . ' ' . $overwritescore));
exit; exit;
} }
if ($nr_results_added == 0) { if ($nr_results_added == 0) {
Display::addFlash(Display::return_message(get_lang('ProblemUploadingFile'), 'warning', false));
header('Location: ' . api_get_self() . '?selecteval=' . $select_eval. '&nothingadded='); header('Location: ' . api_get_self() . '?selecteval=' . $select_eval. '&nothingadded=');
exit; exit;
} }
Display::addFlash(Display::return_message(get_lang('FileUploadComplete'), 'success', false));
header('Location: ' . api_get_self() . '?selecteval=' . $select_eval . '&importok='); header('Location: ' . api_get_self() . '?selecteval=' . $select_eval . '&importok=');
exit; exit;
} }
@ -423,6 +429,7 @@ function confirmationall () {
</script>'; </script>';
if (isset($_GET['deleteall'])) { if (isset($_GET['deleteall'])) {
$eval[0]->delete_results(); $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()); header('Location: '.api_get_path(WEB_CODE_PATH).'gradebook/gradebook_view_result.php?allresdeleted=&selecteval=' . $select_eval.'&'.api_get_cidreq());
exit; exit;
} }
@ -443,10 +450,6 @@ if (isset($_GET['addresultnostudents'])) {
Display :: display_warning_message(get_lang('AddResultNoStudents'), false); Display :: display_warning_message(get_lang('AddResultNoStudents'), false);
} }
if (isset($_GET['editresmessage'])) {
Display :: display_confirmation_message(get_lang('ResultEdited'), false);
}
if (isset($_GET['addresult'])) { if (isset($_GET['addresult'])) {
Display :: display_confirmation_message(get_lang('ResultAdded'), false); Display :: display_confirmation_message(get_lang('ResultAdded'), false);
} }
@ -462,18 +465,10 @@ if (isset($_GET['deleteresult'])) {
if (isset($_GET['editallresults'])) { if (isset($_GET['editallresults'])) {
Display :: display_confirmation_message(get_lang('AllResultsEdited'), false); 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'])) { if (isset($_GET['incorrectdata'])) {
Display :: display_warning_message(get_lang('IncorrectData'), false); Display :: display_warning_message(get_lang('IncorrectData'), false);
} }
if (isset($_GET['nothingadded'])) {
Display :: display_warning_message(get_lang('ProblemUploadingFile'), false);
}
if (isset($_GET['massdelete'])) { if (isset($_GET['massdelete'])) {
Display :: display_confirmation_message(get_lang('ResultsDeleted'), false); Display :: display_confirmation_message(get_lang('ResultsDeleted'), false);
} }
@ -483,18 +478,13 @@ if (isset($_GET['nouser'])) {
if (isset($_GET['overwritemax'])) { if (isset($_GET['overwritemax'])) {
Display :: display_warning_message(get_lang('OverWriteMax'), false); 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'])) { if (isset($_GET['import_user_error'])) {
$userinfo = api_get_user_info($_GET['import_user_error']); $userinfo = api_get_user_info($_GET['import_user_error']);
Display:: display_warning_message( Display:: display_warning_message(
get_lang('UserInfoDoesNotMatch').' '.api_get_person_name($userinfo['firstname'], $userinfo['lastname']) 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'])) { if (isset($_GET['import_score_error'])) {
$userinfo = api_get_user_info($_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'])); 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; $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['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( $interbreadcrumb[] = array(
'url' => 'index.php'.'?selectcat=0&isStudentView=true', 'url' => 'index.php'.'?selectcat=0&isStudentView=true',
'name' => get_lang('ToolGradebook'), 'name' => get_lang('ToolGradebook'),
@ -112,27 +113,37 @@ if (isset($_GET['isStudentView'])) {
} }
} }
if ((isset($_GET['selectcat']) && $_GET['selectcat']>0) && if ($selectCat > 0 && (isset($_SESSION['studentview']) && $_SESSION['studentview']=='true')) {
(isset($_SESSION['studentview']) && $_SESSION['studentview']=='true')
) {
} else { } else {
if (!isset($_GET['selectcat']) && if (empty($selectCat) && (
($_SESSION['studentview']=='studentview') || $_SESSION['studentview']=='studentview') || (isset($_GET['isStudentView']) && $_GET['isStudentView']=='true')
(isset($_GET['isStudentView']) && $_GET['isStudentView']=='true')
) { ) {
Display :: display_header(get_lang('Gradebook')); Display :: display_header(get_lang('Gradebook'));
//Introduction tool: student view //Introduction tool: student view
Display::display_introduction_section(TOOL_GRADEBOOK, array('ToolbarSet' => 'AssessmentsIntroduction')); Display::display_introduction_section(
$addparams=array(); TOOL_GRADEBOOK,
$cats = Category :: load (0, null, null, null, null, null, false); array('ToolbarSet' => 'AssessmentsIntroduction')
$allcat= $cats[0]->get_subcategories($stud_id, $course_code, $session_id); );
$alleval= $cats[0]->get_evaluations($stud_id); $addparams = array();
$alllink= $cats[0]->get_links($stud_id); $cats = Category:: load(0, null, null, null, null, null, false);
$gradebooktable= new GradebookTable($cats[0], $allcat, $alleval,$alllink, $addparams); $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(); $gradebooktable->display();
Display :: display_footer(); Display:: display_footer();
exit; exit;
} }
} }
@ -171,14 +182,16 @@ if (isset($_GET['movecat'])) {
GradebookUtils::block_students(); GradebookUtils::block_students();
$cats= Category :: load($_GET['movecat']); $cats= Category :: load($_GET['movecat']);
if (!isset ($_GET['targetcat'])) { if (!isset ($_GET['targetcat'])) {
$move_form= new CatForm(CatForm :: TYPE_MOVE, $move_form= new CatForm(
CatForm :: TYPE_MOVE,
$cats[0], $cats[0],
'move_cat_form', 'move_cat_form',
null, null,
api_get_self() . '?movecat=' . Security::remove_XSS($_GET['movecat']) api_get_self() . '?movecat=' . Security::remove_XSS($_GET['movecat'])
. '&selectcat=' . Security::remove_XSS($_GET['selectcat'])); . '&selectcat=' . $selectCat
);
if ($move_form->validate()) { 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']) . '&movecat=' . Security::remove_XSS($_GET['movecat'])
. '&targetcat=' . $move_form->exportValue('move_cat')); . '&targetcat=' . $move_form->exportValue('move_cat'));
exit; exit;
@ -189,7 +202,7 @@ if (isset($_GET['movecat'])) {
if (!($course_to_crsind && !isset($_GET['confirm']))) { if (!($course_to_crsind && !isset($_GET['confirm']))) {
$cats[0]->move_to_cat($targetcat[0]); $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; exit;
} }
unset ($targetcat); unset ($targetcat);
@ -203,16 +216,17 @@ if (isset($_GET['moveeval'])) {
$evals= Evaluation :: load($_GET['moveeval']); $evals= Evaluation :: load($_GET['moveeval']);
if (!isset ($_GET['targetcat'])) { if (!isset ($_GET['targetcat'])) {
$move_form= new EvalForm(EvalForm :: TYPE_MOVE, $move_form= new EvalForm(
EvalForm :: TYPE_MOVE,
$evals[0], $evals[0],
null, null,
'move_eval_form', 'move_eval_form',
null, null,
api_get_self() . '?moveeval=' . Security::remove_XSS($_GET['moveeval']) api_get_self() . '?moveeval=' . Security::remove_XSS($_GET['moveeval']). '&selectcat=' . $selectCat
. '&selectcat=' . Security::remove_XSS($_GET['selectcat'])); );
if ($move_form->validate()) { 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']) . '&moveeval=' . Security::remove_XSS($_GET['moveeval'])
. '&targetcat=' . $move_form->exportValue('move_cat')); . '&targetcat=' . $move_form->exportValue('move_cat'));
exit; exit;
@ -223,12 +237,12 @@ if (isset($_GET['moveeval'])) {
if (!($course_to_crsind && !isset($_GET['confirm']))) { if (!($course_to_crsind && !isset($_GET['confirm']))) {
$evals[0]->move_to_cat($targetcat[0]); $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; exit;
} }
unset ($targetcat); unset($targetcat);
} }
unset ($evals); unset($evals);
} }
//move a link //move a link
@ -241,14 +255,14 @@ if (isset($_GET['movelink'])) {
$link[0], $link[0],
'move_link_form', 'move_link_form',
null, 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()) { if ($move_form->validate()) {
$targetcat= Category :: load($move_form->exportValue('move_cat')); $targetcat= Category :: load($move_form->exportValue('move_cat'));
$link[0]->move_to_cat($targetcat[0]); $link[0]->move_to_cat($targetcat[0]);
unset ($link); unset($link);
header('Location: ' . api_get_self(). '?linkmoved=&selectcat=' . Security::remove_XSS($_GET['selectcat'])); header('Location: ' . api_get_self(). '?linkmoved=&selectcat=' . $selectCat);
exit; exit;
} }
} }
@ -408,9 +422,7 @@ if (!empty($course_to_crsind) && !isset($_GET['confirm'])) {
} }
$button = '<form name="confirm" method="post" action="'.api_get_self() .'?confirm=' $button = '<form name="confirm" method="post" action="'.api_get_self() .'?confirm='
.(isset($_GET['movecat']) ? '&movecat=' . Security::remove_XSS($_GET['movecat']) .(isset($_GET['movecat']) ? '&movecat=' . Security::remove_XSS($_GET['movecat'])
: '&moveeval=' . Security::remove_XSS($_GET['moveeval']) ) : '&moveeval=' . Security::remove_XSS($_GET['moveeval'])).'&selectcat=' . $selectCat.'&targetcat=' . Security::remove_XSS($_GET['targetcat']).'">
.'&selectcat=' . Security::remove_XSS($_GET['selectcat'])
.'&targetcat=' . Security::remove_XSS($_GET['targetcat']).'">
<input type="submit" value="'.get_lang('Ok').'"> <input type="submit" value="'.get_lang('Ok').'">
</form>'; </form>';
$warning_message = get_lang('MoveWarning').'<br><br>'.$button; $warning_message = get_lang('MoveWarning').'<br><br>'.$button;
@ -532,24 +544,30 @@ if (isset($_POST['action'])) {
} }
if (isset ($_POST['submit']) && isset ($_POST['keyword'])) { if (isset ($_POST['submit']) && isset ($_POST['keyword'])) {
header('Location: ' . api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat']) header('Location: ' . api_get_self() . '?selectcat=' . $selectCat. '&search='.Security::remove_XSS($_POST['keyword']));
. '&search='.Security::remove_XSS($_POST['keyword']));
exit; exit;
} }
// DISPLAY HEADERS AND MESSAGES // DISPLAY HEADERS AND MESSAGES
if (!isset($_GET['exportpdf'])) { if (!isset($_GET['exportpdf'])) {
if (isset ($_GET['studentoverview'])) { 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')); Display :: display_header(get_lang('FlatView'));
} elseif (isset ($_GET['search'])) { } elseif (isset($_GET['search'])) {
$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('SearchResults')); Display :: display_header(get_lang('SearchResults'));
} elseif(isset ($_GET['selectcat'])) { } elseif(!empty($selectCat)) {
$interbreadcrumb[]= array ( 'url' =>'#','name' => get_lang('ToolGradebook')); $interbreadcrumb[] = array(
if (!isset($_GET['gradebooklist_direction'])) { 'url' => '#',
//$interbreadcrumb[]= array ('url' => $_SESSION['gradebook_dest'].'?selectcat=' . Security::remove_XSS($_GET['selectcat']),'name' => get_lang('Details')); 'name' => get_lang('ToolGradebook')
} );
Display :: display_header(''); Display :: display_header('');
} else { } else {
Display :: display_header(get_lang('ToolGradebook')); Display :: display_header(get_lang('ToolGradebook'));
@ -603,22 +621,15 @@ if (isset ($move_form)){
$is_platform_admin = api_is_platform_admin(); $is_platform_admin = api_is_platform_admin();
$is_course_admin = api_is_allowed_to_edit(null, true); $is_course_admin = api_is_allowed_to_edit(null, true);
$simple_search_form = '';
//load data for category, evaluation and links
if (empty($_GET['selectcat'])) {
$category = 0;
} else {
$category = $_GET['selectcat'];
}
$simple_search_form='';
if (isset($_GET['studentoverview'])) { if (isset($_GET['studentoverview'])) {
//@todo this code also seems to be deprecated ... //@todo this code also seems to be deprecated ...
$cats = Category :: load($category); $cats = Category :: load($selectCat);
$stud_id= (api_is_allowed_to_edit() ? null : $stud_id); $stud_id = (api_is_allowed_to_edit() ? null : $stud_id);
$allcat = $cats[0]->get_subcategories($stud_id, $course_code, $session_id); $allcat = $cats[0]->get_subcategories($stud_id, $course_code, $session_id);
$alleval= $cats[0]->get_evaluations($stud_id, true); $alleval = $cats[0]->get_evaluations($stud_id, true);
$alllink= $cats[0]->get_links($stud_id, true); $alllink = $cats[0]->get_links($stud_id, true);
if (isset ($_GET['exportpdf'])) { if (isset ($_GET['exportpdf'])) {
$datagen = new GradebookDataGenerator($allcat,$alleval, $alllink); $datagen = new GradebookDataGenerator($allcat,$alleval, $alllink);
$header_names = array( $header_names = array(
@ -626,9 +637,14 @@ if (isset($_GET['studentoverview'])) {
get_lang('Description'), get_lang('Description'),
get_lang('Weight'), get_lang('Weight'),
get_lang('Date'), 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(); $newarray = array();
foreach ($data_array as $data) { foreach ($data_array as $data) {
$newarray[] = array_slice($data, 1); $newarray[] = array_slice($data, 1);
@ -709,7 +725,7 @@ if (isset($_GET['studentoverview'])) {
} }
unset($cats); 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 //with this fix the teacher only can view 1 gradebook
if (api_is_platform_admin()) { if (api_is_platform_admin()) {
@ -724,7 +740,7 @@ if (isset($_GET['studentoverview'])) {
} }
// add params to the future links (in the table shown) // 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'])) { if (isset($_GET['studentoverview'])) {
$addparams['studentoverview'] = ''; $addparams['studentoverview'] = '';
@ -740,20 +756,18 @@ $no_qualification = false;
// Show certificate link. // Show certificate link.
$certificate = array(); $certificate = array();
$actionsLeft = ''; $actionsLeft = '';
if ($category != '0') { if (!empty($selectCat)) {
$cat = new Category(); $cat = new Category();
$category_id = intval($_GET['selectcat']); $course_id = CourseManager::get_course_by_category($selectCat);
$course_id = CourseManager::get_course_by_category($category_id); $show_message = $cat->show_message_resource_delete($course_id);
$show_message = $cat->show_message_resource_delete($course_id);
if ($show_message == '') { if ($show_message == '') {
// Student // Student
if (!api_is_allowed_to_edit() && !api_is_excluded_user_type()) { if (!api_is_allowed_to_edit() && !api_is_excluded_user_type()) {
$certificate = Category::register_user_certificate( $certificate = Category::register_user_certificate(
$category_id, $selectCat,
$stud_id $stud_id
); );
if (isset($certificate['pdf_url'])) { if (isset($certificate['pdf_url'])) {
@ -764,17 +778,17 @@ if ($category != '0') {
); );
} }
$currentScore = Category::getCurrentScore($stud_id, $category_id, $course_code, $session_id, true); $currentScore = Category::getCurrentScore($stud_id, $selectCat, $course_code, $session_id, true);
Category::registerCurrentScore($currentScore, $stud_id, $category_id); Category::registerCurrentScore($currentScore, $stud_id, $selectCat);
} }
} }
} }
if (!api_is_allowed_to_edit(null, true)) { if (!api_is_allowed_to_edit(null, true)) {
$actionsLeft .= Display::url( $actionsLeft .= Display::url(
Display::returnFontAwesomeIcon('file-pdf-o') . get_lang('DownloadReportPdf'), Display::returnFontAwesomeIcon('file-pdf-o') . get_lang('DownloadReportPdf'),
api_get_self()."?".api_get_self()."&action=export_table", api_get_self()."?".api_get_self()."&action=export_table",
['class' => 'btn btn-default'] ['class' => 'btn btn-default']
); );
} }
@ -784,38 +798,31 @@ if (api_is_allowed_to_edit(null, true)) {
// Tool introduction // Tool introduction
Display::display_introduction_section(TOOL_GRADEBOOK, array('ToolbarSet' => 'AssessmentsIntroduction')); Display::display_introduction_section(TOOL_GRADEBOOK, array('ToolbarSet' => 'AssessmentsIntroduction'));
if ((isset ($_GET['selectcat']) && $_GET['selectcat']<>0)) { if (((empty($selectCat)) || (isset($_GET['cidReq']) && $_GET['cidReq'] !== '')) ||
// (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'false')
} else { ) {
if (( $cats = Category:: load(
(isset ($_GET['selectcat']) && $_GET['selectcat'] == 0) || ( null,
(isset($_GET['cidReq']) && $_GET['cidReq'] !== '')) null,
) || $course_code,
isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'false' null,
) { null,
$cats = Category:: load( $session_id,
null, false
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().'" />'; echo '<meta http-equiv="refresh" content="0;url='.api_get_self().'?'.api_get_cidreq().'" />';
} else { } else {
$cats = Category::load(null, null, $course_code, null, null, $session_id, false); $cats = Category::load(null, null, $course_code, null, null, $session_id, false);
if (!empty($cats)) { 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_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. // Getting grade models.
@ -870,7 +877,7 @@ if (isset($first_time) && $first_time==1 && api_is_allowed_to_edit(null,true)) {
$allcat = array(); $allcat = array();
/** @var Category $cat */ /** @var Category $cat */
foreach ($cats as $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); $alleval = $cat->get_evaluations($stud_id);
$alllink = $cat->get_links($stud_id, true); $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) && 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 //Showing the grading system
if (!empty($grade_models[$grade_model_id])) { 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()); $courseParams = api_get_cidreq_params($cat->get_course_code(), $cat->get_session_id());
if (api_is_allowed_to_edit(null, true)) { if (api_is_allowed_to_edit(null, true)) {
// Locking button // Locking button
if (api_get_setting('gradebook_locking_enabled') == 'true') { if (api_get_setting('gradebook_locking_enabled') == 'true') {
if ($cat->is_locked()) { if ($cat->is_locked()) {
@ -293,12 +292,10 @@ class GradebookUtils
*/ */
public static function build_edit_icons_eval($eval, $selectcat) 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(); $is_locked = $eval->is_locked();
$eval->get_course_code(); $eval->get_course_code();
$cat = new Category(); $cat = new Category();
$message_eval = $cat->show_message_resource_delete($eval->get_course_code()); $message_eval = $cat->show_message_resource_delete($eval->get_course_code());
$courseParams = api_get_cidreq_params($eval->get_course_code(), $eval->getSessionId()); $courseParams = api_get_cidreq_params($eval->get_course_code(), $eval->getSessionId());
if ($message_eval === false && api_is_allowed_to_edit(null, true)) { if ($message_eval === false && api_is_allowed_to_edit(null, true)) {
@ -516,10 +513,10 @@ class GradebookUtils
global $users; global $users;
global $current_value; global $current_value;
switch ($data) { switch ($data) {
case 'Result' : case 'Result':
$users[] = $user; $users[] = $user;
break; break;
default : default:
$user[$data] = $current_value; $user[$data] = $current_value;
break; break;
} }
@ -533,10 +530,10 @@ class GradebookUtils
global $user; global $user;
global $current_tag; global $current_tag;
switch ($data) { switch ($data) {
case 'Result' : case 'Result':
$user = array(); $user = array();
break; break;
default : default:
$current_tag = $data; $current_tag = $data;
} }
} }
@ -694,8 +691,6 @@ class GradebookUtils
$content_html = DocumentManager::replace_user_info_into_html($user_id, $course_code, $sessionId, $is_preview); $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; $new_content_html = isset($content_html['content']) ? $content_html['content'] : null;
$variables = isset($content_html['variables']) ? $content_html['variables'] : 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'; $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); $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()) public static function get_all_users($evals = array(), $links = array())
{ {
$coursecodes = array(); $coursecodes = array();
$users = array();
// By default add all user in course // By default add all user in course
$coursecodes[api_get_course_id()] = '1'; $coursecodes[api_get_course_id()] = '1';
@ -1163,9 +1157,7 @@ class GradebookUtils
$table_link = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK); $table_link = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$em = Database::getManager(); $em = Database::getManager();
$table_evaluation = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
$tbl_forum_thread = Database:: get_course_table(TABLE_FORUM_THREAD); $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); $tbl_attendance = Database:: get_course_table(TABLE_ATTENDANCE);
$sql = 'UPDATE '.$table_link.' SET weight = '."'".Database::escape_string($weight)."'".' $sql = 'UPDATE '.$table_link.' SET weight = '."'".Database::escape_string($weight)."'".'
@ -1456,5 +1448,4 @@ class GradebookUtils
return $file; return $file;
} }
} }

@ -118,57 +118,6 @@ class DisplayGradebook
echo $header; 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 * Displays the header for the flatview page containing filters
@ -254,155 +203,6 @@ class DisplayGradebook
echo $header; 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 * Displays the header for the gradebook containing the navigation tree and links
* @param Category $catobj * @param Category $catobj
@ -428,7 +228,6 @@ class DisplayGradebook
$show_add_link = true, $show_add_link = true,
$certificateLinkInfo = null $certificateLinkInfo = null
) { ) {
$userId = api_get_user_id(); $userId = api_get_user_id();
$courseCode = api_get_course_id(); $courseCode = api_get_course_id();
$courseId = api_get_course_int_id(); $courseId = api_get_course_int_id();
@ -451,9 +250,6 @@ class DisplayGradebook
$grade_model_id = $catobj->get_grade_model_id(); $grade_model_id = $catobj->get_grade_model_id();
$header = null; $header = null;
//@todo move these in a function
$sum_categories_weight_array = array();
if (isset($catobj) && !empty($catobj)) { if (isset($catobj) && !empty($catobj)) {
$categories = Category::load( $categories = Category::load(
null, null,
@ -463,14 +259,6 @@ class DisplayGradebook
null, null,
$sessionId $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) { if (!$is_course_admin && ($status <> 1 || $sessionStatus == 0) && $selectcat <> 0) {
@ -516,7 +304,7 @@ class DisplayGradebook
} }
// show navigation tree and buttons? // show navigation tree and buttons?
if (($showtree == '1') || (isset($_GET['studentoverview']))) { if ($showtree == '1' || isset($_GET['studentoverview'])) {
$header = '<div class="actions"><table>'; $header = '<div class="actions"><table>';
$header .= '<tr>'; $header .= '<tr>';
if (!$selectcat == '0') { if (!$selectcat == '0') {
@ -566,8 +354,6 @@ class DisplayGradebook
// for course admin & platform admin add item buttons are added to the header // for course admin & platform admin add item buttons are added to the header
$actionsLeft = ''; $actionsLeft = '';
$my_category = $catobj->shows_all_information_an_category($catobj->get_id());
$user_id = api_get_user_id();
$my_api_cidreq = api_get_cidreq(); $my_api_cidreq = api_get_cidreq();
if (api_is_allowed_to_edit(null, true)) { if (api_is_allowed_to_edit(null, true)) {
@ -603,23 +389,23 @@ class DisplayGradebook
if ($my_category['generate_certificates'] == 1) { if ($my_category['generate_certificates'] == 1) {
$actionsLeft .= Display::url( $actionsLeft .= Display::url(
Display::return_icon( Display::return_icon(
'certificate_list.png', 'certificate_list.png',
get_lang('GradebookSeeListOfStudentsCertificates'), get_lang('GradebookSeeListOfStudentsCertificates'),
'', '',
ICON_SIZE_MEDIUM ICON_SIZE_MEDIUM
), ),
"gradebook_display_certificate.php?$my_api_cidreq&cat_id=" . intval($_GET['selectcat']) "gradebook_display_certificate.php?$my_api_cidreq&cat_id=" . $selectcat
); );
} }
$actionsLeft .= Display::url( $actionsLeft .= Display::url(
Display::return_icon( Display::return_icon(
'user.png', 'user.png',
get_lang('GradebookListOfStudentsReports'), get_lang('GradebookListOfStudentsReports'),
'', '',
ICON_SIZE_MEDIUM ICON_SIZE_MEDIUM
), ),
"gradebook_display_summary.php?$my_api_cidreq&selectcat=" . intval($_GET['selectcat']) "gradebook_display_summary.php?$my_api_cidreq&selectcat=" . $selectcat
); );
// Right icons // Right icons
@ -721,13 +507,12 @@ class DisplayGradebook
/** /**
* @param int $userid * @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_id = $userid;
$user = api_get_user_info($user_id); $user = api_get_user_info($user_id);
$catcourse = Category :: load($select_cat); $catcourse = Category :: load($categoryId);
$scoredisplay = ScoreDisplay :: instance(); $scoredisplay = ScoreDisplay :: instance();
$scorecourse = $catcourse[0]->calc_score($user_id); $scorecourse = $catcourse[0]->calc_score($user_id);
@ -743,7 +528,6 @@ class DisplayGradebook
$my_score_denom = ($score[1] == 0) ? 1 : $score[1]; $my_score_denom = ($score[1] == 0) ? 1 : $score[1];
$item_value+=$score[0] / $my_score_denom * $item->get_weight(); $item_value+=$score[0] / $my_score_denom * $item->get_weight();
$item_total+=$item->get_weight(); $item_total+=$item->get_weight();
//$row[] = $scoredisplay->display_score($score,SCORE_DIV_PERCENT);
} }
$item_value = number_format($item_value, 2, '.', ' '); $item_value = number_format($item_value, 2, '.', ' ');
$total_score = array($item_value, $item_total); $total_score = array($item_value, $item_total);

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

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

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

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

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

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

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

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

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

@ -36,16 +36,15 @@ class GradeBookResult
//titles //titles
foreach ($dato[0] as $header_col) { 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 .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($header_col))).';';
} }
} }
$data .="\r\n"; $data .= "\r\n";
$cant_students = count($dato[1]); $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; $column = 0;
foreach($dato[1][$i] as $col_name) { foreach($dato[1][$i] as $col_name) {
$data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($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++) { for ($i = 0; $i < $cant_students; $i++) {
$column = 0; $column = 0;
foreach ($data[1][$i] as $col_name) { 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++; $column++;
} }
$line++; $line++;

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

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

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

@ -94,7 +94,6 @@ if (isset($_GET['action']) && $is_allowed_in_course) {
*/ */
if (api_is_allowed_to_edit(false, true)) { if (api_is_allowed_to_edit(false, true)) {
// Post-actions // Post-actions
if (isset($_POST['action'])) { if (isset($_POST['action'])) {
switch ($_POST['action']) { switch ($_POST['action']) {
@ -165,7 +164,6 @@ Display::display_introduction_section(TOOL_GROUP);
$actionsLeft = ''; $actionsLeft = '';
if (api_is_allowed_to_edit(false, true)) { if (api_is_allowed_to_edit(false, true)) {
$actionsLeft .= '<a href="group_creation.php?'.api_get_cidreq().'">'. $actionsLeft .= '<a href="group_creation.php?'.api_get_cidreq().'">'.
Display::return_icon('add-groups.png', get_lang('NewGroupCreate'), '', ICON_SIZE_MEDIUM).'</a>'; 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'), Display::return_icon('work.png', get_lang('GroupWork'), array(), ICON_SIZE_SMALL) . ' ' . get_lang('GroupWork'),
'', '',
false); false
);
// Calendar settings. // Calendar settings.
$group = array( $group = array(
@ -275,17 +276,17 @@ $currentUrl = api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq();
if ($form->validate()) { if ($form->validate()) {
$values = $form->exportValues(); $values = $form->exportValues();
if ($values['max_member_no_limit'] == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) { if ($values['max_member_no_limit'] == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) {
$max_member = GroupManager::MEMBER_PER_GROUP_NO_LIMIT; $max_member = GroupManager::MEMBER_PER_GROUP_NO_LIMIT;
} else { } else {
$max_member = $values['max_member']; $max_member = $values['max_member'];
} }
$self_reg_allowed = isset($values['self_reg_allowed']) ? $values['self_reg_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; $self_unreg_allowed = isset($values['self_unreg_allowed']) ? $values['self_unreg_allowed'] : 0;
switch ($values['action']) { switch ($values['action']) {
case 'update_settings': case 'update_settings':
GroupManager::update_category( GroupManager::update_category(
$values['id'], $values['id'],
$values['title'], $values['title'],
$values['description'], $values['description'],
@ -304,8 +305,8 @@ if ($form->validate()) {
Display::addFlash(Display::return_message(get_lang('GroupPropertiesModified'))); Display::addFlash(Display::return_message(get_lang('GroupPropertiesModified')));
header("Location: ".$currentUrl."&category=".$values['id']); header("Location: ".$currentUrl."&category=".$values['id']);
exit; exit;
case 'add_category': case 'add_category':
GroupManager :: create_category( GroupManager :: create_category(
$values['title'], $values['title'],
$values['description'], $values['description'],
$values['doc_state'], $values['doc_state'],
@ -323,8 +324,8 @@ if ($form->validate()) {
Display::addFlash(Display::return_message(get_lang('CategoryCreated'))); Display::addFlash(Display::return_message(get_lang('CategoryCreated')));
header("Location: ".$currentUrl); header("Location: ".$currentUrl);
exit; exit;
break; break;
} }
} }
// Else display the form // Else display the form
@ -339,10 +340,10 @@ echo '</div>';
$defaults = $category; $defaults = $category;
$defaults['action'] = $action; $defaults['action'] = $action;
if ($defaults['max_student'] == GroupManager::MEMBER_PER_GROUP_NO_LIMIT) { 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 { } else {
$defaults['max_member_no_limit'] = 1; $defaults['max_member_no_limit'] = 1;
$defaults['max_member'] = $defaults['max_student']; $defaults['max_member'] = $defaults['max_student'];
} }
$form->setDefaults($defaults); $form->setDefaults($defaults);
$form->display(); $form->display();

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

@ -84,31 +84,31 @@ if (!isset ($_GET['origin']) || $_GET['origin'] != 'learnpath') {
$actions = '<a href="group_creation.php?'.api_get_cidreq().'">'. $actions = '<a href="group_creation.php?'.api_get_cidreq().'">'.
Display::return_icon('add.png', get_lang('NewGroupCreate'), '', ICON_SIZE_MEDIUM).'</a>'; Display::return_icon('add.png', get_lang('NewGroupCreate'), '', ICON_SIZE_MEDIUM).'</a>';
if (api_get_setting('allow_group_categories') === 'true') { if (api_get_setting('allow_group_categories') === 'true') {
$actions.= '<a href="group_category.php?'.api_get_cidreq().'&action=add_category">'. $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>'; Display::return_icon('new_folder.png', get_lang('AddCategory'), '', ICON_SIZE_MEDIUM).'</a>';
} else { } else {
$actions.= '<a href="group_category.php?'.api_get_cidreq().'&id=2">'. $actions.= '<a href="group_category.php?'.api_get_cidreq().'&id=2">'.
Display::return_icon('settings.png', get_lang('PropModify'), '', ICON_SIZE_MEDIUM).'</a>'; Display::return_icon('settings.png', get_lang('PropModify'), '', ICON_SIZE_MEDIUM).'</a>';
} }
$actions.= '<a href="import.php?'.api_get_cidreq().'&action=import">'. $actions.= '<a href="import.php?'.api_get_cidreq().'&action=import">'.
Display::return_icon('import_csv.png', get_lang('Import'), '', ICON_SIZE_MEDIUM).'</a>'; 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">'. $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>'; 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">'. $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>'; 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">'. $actions.= '<a href="group_overview.php?'.api_get_cidreq().'&action=export_pdf">'.
Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a>'; Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a>';
$actions.= '<a href="group.php?'.api_get_cidreq().'">'. $actions.= '<a href="group.php?'.api_get_cidreq().'">'.
Display::return_icon('group.png', get_lang('Groups'),'',ICON_SIZE_MEDIUM).'</a>'; Display::return_icon('group.png', get_lang('Groups'),'',ICON_SIZE_MEDIUM).'</a>';
$actions.= '<a href="../user/user.php?'.api_get_cidreq().'">'. $actions.= '<a href="../user/user.php?'.api_get_cidreq().'">'.
Display::return_icon('user.png', get_lang('GoTo').' '.get_lang('Users'), '', ICON_SIZE_MEDIUM).'</a>'; Display::return_icon('user.png', get_lang('GoTo').' '.get_lang('Users'), '', ICON_SIZE_MEDIUM).'</a>';
// Action links // Action links
echo '<div class="actions">'; 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(); $course_id = api_get_course_int_id();
// Query // Query
if (api_get_setting('show_email_addresses') == 'true') { if (api_get_setting('show_email_addresses') === 'true') {
$sql = "SELECT user.id AS col0, $sql = "SELECT user.id AS col0,
".(api_is_western_name_order() ? ".(api_is_western_name_order() ?
"user.firstname AS col1, "user.firstname AS col1,
@ -443,21 +443,20 @@ function get_group_user_data($from, $number_of_items, $column, $direction)
} else { } else {
if (api_is_allowed_to_edit()) { if (api_is_allowed_to_edit()) {
$sql = "SELECT DISTINCT $sql = "SELECT DISTINCT
u.id AS col0, u.id AS col0,
".(api_is_western_name_order() ? ".(api_is_western_name_order() ?
"u.firstname AS col1, "u.firstname AS col1,
u.lastname AS col2," u.lastname AS col2,"
: :
"u.lastname AS col1, "u.lastname AS col1,
u.firstname AS col2," u.firstname AS col2,")."
)." u.email AS col3
u.email AS col3 FROM $table_user u
FROM $table_user u INNER JOIN $table_group_user gu
INNER JOIN $table_group_user gu ON (gu.user_id = u.id) AND gu.c_id = $course_id
ON (gu.user_id = u.id) AND gu.c_id = $course_id WHERE gu.group_id = '".Database::escape_string($current_group['id'])."'
WHERE gu.group_id = '".Database::escape_string($current_group['id'])."' ORDER BY col$column $direction
ORDER BY col$column $direction LIMIT $from, $number_of_items";
LIMIT $from, $number_of_items";
} else { } else {
$sql = "SELECT DISTINCT $sql = "SELECT DISTINCT
user.id AS col0, user.id AS col0,
@ -467,14 +466,14 @@ function get_group_user_data($from, $number_of_items, $column, $direction)
: :
"user.lastname AS col1, "user.lastname AS col1,
user.firstname AS col2 " user.firstname AS col2 "
)." )."
FROM $table_user user, $table_group_user group_rel_user FROM $table_user user, $table_group_user group_rel_user
WHERE WHERE
group_rel_user.c_id = $course_id AND group_rel_user.c_id = $course_id AND
group_rel_user.user_id = user.id AND group_rel_user.user_id = user.id AND
group_rel_user.group_id = '".Database::escape_string($current_group['id'])."' group_rel_user.group_id = '".Database::escape_string($current_group['id'])."'
ORDER BY col$column $direction ORDER BY col$column $direction
LIMIT $from,$number_of_items"; LIMIT $from,$number_of_items";
} }
} }

@ -152,7 +152,7 @@ if (!empty($complete_user_list)) {
if ($orderUserListByOfficialCode === 'true') { if ($orderUserListByOfficialCode === 'true') {
$officialCode = !empty($user['official_code']) ? $user['official_code']." - " : '? - '; $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; $possible_users[$user['user_id']] = $name.$groupNameListToString;
} }

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

@ -7,9 +7,6 @@
* *
* @package chamilo.help * @package chamilo.help
*/ */
/**
* Code
*/
require '../inc/global.inc.php'; require '../inc/global.inc.php';
header('Content-Type: text/html; charset='.api_get_system_encoding()); 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); $point_info = CourseManager::get_course_ranking($course_id, 0);
$ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote'; $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; echo $rating;
break; break;
@ -251,9 +256,7 @@ switch ($action) {
foreach ($coursesData as $courseId => $course) { foreach ($coursesData as $courseId => $course) {
$coachData = SessionManager::getCoachesByCourseSession($sessionId, $courseId); $coachData = SessionManager::getCoachesByCourseSession($sessionId, $courseId);
$coachName = ''; $coachName = '';
if (!empty($coachData)) { if (!empty($coachData)) {
$userResult = Database::select('lastname,firstname', $userTable, array( $userResult = Database::select('lastname,firstname', $userTable, array(
'where' => array( 'where' => array(
@ -262,7 +265,7 @@ switch ($action) {
), 'first'); ), 'first');
$coachName = api_get_person_name($userResult['firstname'], $userResult['lastname']); $coachName = api_get_person_name($userResult['firstname'], $userResult['lastname']);
} }
$courses[] = array( $courses[] = array(
'id' => $courseId, 'id' => $courseId,

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

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

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

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

@ -51,7 +51,7 @@ switch ($action) {
if (api_get_setting('allow_social_tool') === 'true' && api_get_setting('allow_message_tool') === 'true') { if (api_get_setting('allow_social_tool') === 'true' && api_get_setting('allow_message_tool') === 'true') {
// All users // 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) { if ($access_url_id != 0) {
$sql = "SELECT DISTINCT u.user_id as id, u.firstname, u.lastname, u.email $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 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'; require_once '../global.inc.php';
$action = $_GET['a']; $action = $_GET['a'];
switch ($action) { switch ($action) {
case 'access_detail': case 'access_detail':
$user_id = intval($_REQUEST['student']); $user_id = intval($_REQUEST['student']);
@ -36,7 +35,6 @@ switch ($action) {
echo $foo_print; echo $foo_print;
break; break;
case 'access_detail_by_date': case 'access_detail_by_date':
$db = array('is_empty' => true); $db = array('is_empty' => true);
$start_date = isset($_REQUEST['startDate']) ? $_REQUEST['startDate'] : ""; $start_date = isset($_REQUEST['startDate']) ? $_REQUEST['startDate'] : "";

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

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

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

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

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

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

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

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

Loading…
Cancel
Save