Adds lib GradebookUtils class to avoid unneeded requires

1.10.x
Julio Montoya 11 years ago
parent d4dcaea5e0
commit 272710bb16
  1. 3
      main/admin/export_certificates.php
  2. 2
      main/attendance/attendance_add.php
  3. 4
      main/attendance/attendance_edit.php
  4. 4
      main/attendance/index.php
  5. 7
      main/exercice/exercice.php
  6. 1
      main/exercice/exercise_report.php
  7. 1
      main/exercice/hotpotatoes_exercise_report.php
  8. 9
      main/forum/editpost.php
  9. 21
      main/forum/forumfunction.inc.php
  10. 1
      main/forum/newthread.php
  11. 7
      main/forum/viewforum.php
  12. 36
      main/gradebook/gradebook.php
  13. 5
      main/gradebook/gradebook_add_cat.php
  14. 5
      main/gradebook/gradebook_add_eval.php
  15. 6
      main/gradebook/gradebook_add_link.php
  16. 5
      main/gradebook/gradebook_add_link_select_course.php
  17. 7
      main/gradebook/gradebook_add_result.php
  18. 8
      main/gradebook/gradebook_add_user.php
  19. 14
      main/gradebook/gradebook_display_certificate.php
  20. 18
      main/gradebook/gradebook_edit_all.php
  21. 5
      main/gradebook/gradebook_edit_cat.php
  22. 5
      main/gradebook/gradebook_edit_eval.php
  23. 8
      main/gradebook/gradebook_edit_link.php
  24. 8
      main/gradebook/gradebook_edit_result.php
  25. 24
      main/gradebook/gradebook_flatview.php
  26. 4
      main/gradebook/gradebook_scoring_system.php
  27. 6
      main/gradebook/gradebook_showlog_eval.php
  28. 6
      main/gradebook/gradebook_showlog_link.php
  29. 5
      main/gradebook/gradebook_statistics.php
  30. 23
      main/gradebook/gradebook_view_result.php
  31. 37
      main/gradebook/index.php
  32. 1101
      main/gradebook/lib/GradebookUtils.php
  33. 9
      main/gradebook/lib/be.inc.php
  34. 14
      main/gradebook/lib/be/category.class.php
  35. 3
      main/gradebook/lib/fe/catform.class.php
  36. 5
      main/gradebook/lib/fe/dataform.class.php
  37. 4
      main/gradebook/lib/fe/displaygradebook.php
  38. 12
      main/gradebook/lib/fe/evalform.class.php
  39. 18
      main/gradebook/lib/fe/flatviewtable.class.php
  40. 15
      main/gradebook/lib/fe/gradebooktable.class.php
  41. 5
      main/gradebook/lib/fe/linkaddeditform.class.php
  42. 5
      main/gradebook/lib/fe/linkform.class.php
  43. 3
      main/gradebook/lib/fe/resulttable.class.php
  44. 3
      main/gradebook/lib/fe/scoredisplayform.class.php
  45. 6
      main/gradebook/lib/fe/userform.class.php
  46. 5
      main/gradebook/lib/fe/usertable.class.php
  47. 1
      main/gradebook/lib/gradebook_data_generator.class.php
  48. 983
      main/gradebook/lib/gradebook_functions.inc.php
  49. 173
      main/gradebook/lib/gradebook_functions_users.inc.php
  50. 2
      main/gradebook/lib/results_data_generator.class.php
  51. 23
      main/gradebook/lib/scoredisplay.class.php
  52. 2
      main/gradebook/lib/user_data_generator.class.php
  53. 5
      main/gradebook/user_info.php
  54. 11
      main/gradebook/user_stats.php
  55. 1
      main/inc/ajax/admin.ajax.php
  56. 3
      main/inc/ajax/gradebook.ajax.php
  57. 26
      main/inc/lib/api.lib.php
  58. 8
      main/inc/lib/attendance.lib.php
  59. 11
      main/inc/lib/certificate.lib.php
  60. 19
      main/inc/lib/course.lib.php
  61. 35
      main/inc/lib/gradebook.lib.php
  62. 8
      main/inc/lib/javascript/ckeditor/config_js.php
  63. 4
      main/inc/lib/usermanager.lib.php
  64. 7
      main/newscorm/learnpath.class.php
  65. 7
      main/survey/create_new_survey.php
  66. 2
      main/work/edit_work.php
  67. 27
      main/work/work.lib.php
  68. 6
      plugin/dashboard/block_daily/block_daily.class.php
  69. 11
      plugin/dashboard/block_evaluation_graph/block_evaluation_graph.class.php
  70. 1
      plugin/dashboard/block_global_info/block_global_info.class.php

@ -13,9 +13,6 @@ $cidReset = true;
require_once '../inc/global.inc.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be.inc.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
Display::display_header(null);
$form = new FormValidator('export_certificate');

@ -44,7 +44,7 @@ if ((api_get_session_id() != 0 && Gradebook::is_active()) || api_get_session_id(
$form->addElement('checkbox', 'attendance_qualify_gradebook', '', get_lang('QualifyAttendanceGradebook'),'onclick="javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}"');
$form->addElement('html','<div id="options_field" style="display:none">');
load_gradebook_select_in_tool($form);
GradebookUtils::load_gradebook_select_in_tool($form);
$form->addElement('text', 'attendance_qualify_title', get_lang('TitleColumnGradebook'));
$form->applyFilter('attendance_qualify_title', 'html_filter');

@ -52,7 +52,7 @@ if (Gradebook::is_active()) {
$form->addElement('checkbox', 'attendance_qualify_gradebook', '', get_lang('QualifyAttendanceGradebook'),'onclick="javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}"');
$form->addElement('html','<div id="options_field" style="display:none">');
}
load_gradebook_select_in_tool($form);
GradebookUtils::load_gradebook_select_in_tool($form);
$form->addElement('text', 'attendance_qualify_title', get_lang('TitleColumnGradebook'));
$form->applyFilter('attendance_qualify_title', 'html_filter');
$form->addElement('text', 'attendance_weight', get_lang('QualifyWeight'),'value="0.00" Style="width:40px" onfocus="javascript: this.select();"');
@ -69,7 +69,7 @@ $default['description'] = Security::remove_XSS($description,STUDENT);
$default['attendance_qualify_title'] = $attendance_qualify_title;
$default['attendance_weight'] = $attendance_weight;
$link_info = is_resource_in_course_gradebook(api_get_course_id(), 7, $attendance_id, api_get_session_id());
$link_info = GradebookUtils::is_resource_in_course_gradebook(api_get_course_id(), 7, $attendance_id, api_get_session_id());
$default['category_id'] = $link_info['category_id'];
$form->setDefaults($default);
$form->display();

@ -21,13 +21,9 @@ $language_file = array(
// including files
require_once '../inc/global.inc.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
require_once api_get_path(LIBRARY_PATH).'attendance.lib.php';
require_once api_get_path(LIBRARY_PATH).'app_view.php';
require_once 'attendance_controller.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/fe/exportgradebook.php';
require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
$current_course_tool = TOOL_ATTENDANCE;

@ -21,8 +21,6 @@ $language_file = array('exercice', 'tracking');
require_once '../inc/global.inc.php';
$current_course_tool = TOOL_QUIZ;
require_once '../gradebook/lib/be.inc.php';
// Setting the tabs
$this_section = SECTION_COURSES;
@ -227,10 +225,9 @@ if ($is_allowedToEdit) {
// deletes an exercise
if ($exercise_action_locked == false) {
$objExerciseTmp->delete();
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
$link_info = is_resource_in_course_gradebook(api_get_course_id(), 1, $exerciseId, api_get_session_id());
$link_info = GradebookUtils::is_resource_in_course_gradebook(api_get_course_id(), 1, $exerciseId, api_get_session_id());
if ($link_info !== false) {
remove_resource_from_course_gradebook($link_info['id']);
GradebookUtils::remove_resource_from_course_gradebook($link_info['id']);
}
Display :: display_confirmation_message(get_lang('ExerciseDeleted'));
}

@ -15,7 +15,6 @@ $language_file = array('exercice');
// including the global library
require_once '../inc/global.inc.php';
require_once '../gradebook/lib/be.inc.php';
// Setting the tabs
$this_section = SECTION_COURSES;

@ -14,7 +14,6 @@ $language_file = array('exercice');
// including the global library
require_once '../inc/global.inc.php';
require_once '../gradebook/lib/be.inc.php';
// Setting the tabs
$this_section = SECTION_COURSES;

@ -27,11 +27,6 @@ $language_file = array('forum', 'group', 'gradebook');
// Including the global initialization file.
require_once '../inc/global.inc.php';
require_once '../gradebook/lib/gradebook_functions.inc.php';
require_once '../gradebook/lib/be/gradebookitem.class.php';
require_once '../gradebook/lib/be/evaluation.class.php';
require_once '../gradebook/lib/be/abstractlink.class.php';
require_once '../gradebook/lib/gradebook_functions.inc.php';
// The section (tabs).
$this_section = SECTION_COURSES;
@ -229,10 +224,10 @@ if (!empty($values) and isset($_POST['SubmitPost'])) {
$weight_calification = $values['weight_calification'];
$description = '';
$session_id = api_get_session_id();
$link_info = is_resource_in_course_gradebook(api_get_course_id(), 5, $id, $session_id);
$link_info = GradebookUtils::is_resource_in_course_gradebook(api_get_course_id(), 5, $id, $session_id);
$link_id = $link_info['id'];
if (!$link_info) {
add_resource_to_course_gradebook(
GradebookUtils::add_resource_to_course_gradebook(
$values['category_id'],
api_get_course_id(),
5,

@ -170,13 +170,12 @@ function handle_forum_and_forumcategories($lp_id = null)
for ($i = 0; $i < count($list_threads); $i++) {
delete_forum_forumcategory_thread('thread', $list_threads[$i]['thread_id']);
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
$link_info = is_resource_in_course_gradebook(api_get_course_id(), 5, intval($list_threads[$i]['thread_id']), api_get_session_id());
$link_info = GradebookUtils::is_resource_in_course_gradebook(api_get_course_id(), 5, intval($list_threads[$i]['thread_id']), api_get_session_id());
if ($link_info !== false) {
remove_resource_from_course_gradebook($link_info['id']);
GradebookUtils::remove_resource_from_course_gradebook($link_info['id']);
}
}
$return_message = delete_forum_forumcategory_thread($get_content, $get_id);
$return_message = GradebookUtils::delete_forum_forumcategory_thread($get_content, $get_id);
Display::display_confirmation_message($return_message, false);
}
@ -2243,7 +2242,7 @@ function store_thread($current_forum, $values)
$maxqualify = $values['numeric_calification'];
$weigthqualify = $values['weight_calification'];
$resourcedescription = '';
add_resource_to_course_gradebook(
GradebookUtils::add_resource_to_course_gradebook(
$values['category_id'],
$coursecode,
$resourcetype,
@ -2426,7 +2425,7 @@ function show_add_post_form($current_forum, $forum_setting, $action = '', $id =
// Thread qualify
if (Gradebook::is_active()) {
//Loading gradebook select
load_gradebook_select_in_tool($form);
GradebookUtils::load_gradebook_select_in_tool($form);
$form->addElement('checkbox', 'thread_qualify_gradebook', '', get_lang('QualifyThreadGradebook'), 'onclick="javascript:if(this.checked==true){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}"');
} else {
$form->addElement('hidden', 'thread_qualify_gradebook', false);
@ -2845,7 +2844,7 @@ function show_edit_post_form($forum_setting, $current_post, $current_thread, $cu
$form->addElement('label', '<strong>'.get_lang('AlterQualifyThread').'</strong>');
$form->addElement('checkbox', 'thread_qualify_gradebook', '', get_lang('QualifyThreadGradebook'), 'onclick="javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}"');
$link_info = is_resource_in_course_gradebook(api_get_course_id(), 5, $_GET['thread'], api_get_session_id());
$link_info = GradebookUtils::is_resource_in_course_gradebook(api_get_course_id(), 5, $_GET['thread'], api_get_session_id());
if (!empty($link_info)) {
$defaults['thread_qualify_gradebook'] = true;
$defaults['category_id'] = $link_info['category_id'];
@ -2865,7 +2864,7 @@ function show_edit_post_form($forum_setting, $current_post, $current_thread, $cu
}
//Loading gradebook select
load_gradebook_select_in_tool($form);
GradebookUtils::load_gradebook_select_in_tool($form);
$form->addElement('text', 'numeric_calification', get_lang('QualificationNumeric'), 'value="'.$current_thread['thread_qualify_max'].'" style="width:40px"');
$form->applyFilter('numeric_calification', 'html_filter');
@ -3004,19 +3003,19 @@ function store_edit_post($values)
$sid = api_get_session_id();
$link_info = is_resource_in_course_gradebook($ccode, 5, $values['thread_id'], $sid);
$link_info = GradebookUtils::is_resource_in_course_gradebook($ccode, 5, $values['thread_id'], $sid);
$link_id = $link_info['id'];
$thread_qualify_gradebook = isset($values['thread_qualify_gradebook']) ? $values['thread_qualify_gradebook'] : null;
if ($thread_qualify_gradebook != 1) {
if ($link_info !== false) {
remove_resource_from_course_gradebook($link_id);
GradebookUtils::remove_resource_from_course_gradebook($link_id);
}
} else {
if ($link_info === false && !$_GET['thread']) {
$weigthqualify = $values['weight_calification'];
add_resource_to_course_gradebook($values['category_id'], $ccode, 5, $values['thread_id'], Database::escape_string(stripslashes($values['calification_notebook_title'])), $weigthqualify, $values['numeric_calification'], null, 0, $sid);
GradebookUtils::add_resource_to_course_gradebook($values['category_id'], $ccode, 5, $values['thread_id'], Database::escape_string(stripslashes($values['calification_notebook_title'])), $weigthqualify, $values['numeric_calification'], null, 0, $sid);
}
}
}

@ -30,7 +30,6 @@ $language_file = array('forum', 'document', 'gradebook');
// Including the global initialization file.
require_once '../inc/global.inc.php';
require_once '../gradebook/lib/gradebook_functions.inc.php';
// The section (tabs).
$this_section = SECTION_COURSES;

@ -147,13 +147,12 @@ if ($my_action == 'delete' AND isset($_GET['content']) AND isset($_GET['id']) AN
$locked = api_resource_is_locked_by_gradebook($_GET['id'], LINK_FORUM_THREAD);
if ($locked == false) {
$message = delete_forum_forumcategory_thread($_GET['content'], $_GET['id']);
$message = GradebookUtils::delete_forum_forumcategory_thread($_GET['content'], $_GET['id']);
// Delete link
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
$link_info = is_resource_in_course_gradebook(api_get_course_id(), 5 , intval($_GET['id']), api_get_session_id());
$link_info = GradebookUtils::is_resource_in_course_gradebook(api_get_course_id(), 5 , intval($_GET['id']), api_get_session_id());
$link_id = $link_info['id'];
if ($link_info !== false) {
remove_resource_from_course_gradebook($link_id);
GradebookUtils::remove_resource_from_course_gradebook($link_id);
}
}
}

@ -20,16 +20,6 @@ if (!empty($_GET['course'])) {
$this_section = SECTION_MYGRADEBOOK;
unset($_GET['course']);
}
require_once 'lib/be.inc.php';
require_once 'lib/scoredisplay.class.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/catform.class.php';
require_once 'lib/fe/evalform.class.php';
require_once 'lib/fe/linkform.class.php';
require_once 'lib/gradebook_data_generator.class.php';
require_once 'lib/fe/gradebooktable.class.php';
require_once 'lib/fe/displaygradebook.php';
require_once 'lib/fe/userform.class.php';
$htmlHeadXtra[] = '<script type="text/javascript">
$(document).ready( function() {
@ -57,7 +47,7 @@ $filter_warning_msg = true;
//this is called when there is no data for the course admin
if (isset ($_GET['createallcategories'])) {
block_students();
GradebookUtils::block_students();
$coursecat= Category :: get_not_created_course_categories(api_get_user_id());
if (!count($coursecat) == 0) {
foreach ($coursecat as $row) {
@ -81,7 +71,7 @@ $selectcat=isset($_GET['selectcat']) ? Security::remove_XSS($_GET['selectcat'])
if (isset ($_GET['movecat'])) {
$move_cat=Security::remove_XSS($_GET['movecat']);
block_students();
GradebookUtils::block_students();
$cats= Category :: load($move_cat);
if (!isset ($_GET['targetcat'])) {
$move_form= new CatForm(CatForm :: TYPE_MOVE,
@ -113,7 +103,7 @@ if (isset ($_GET['movecat'])) {
//move an evaluation
if (isset ($_GET['moveeval'])) {
block_students();
GradebookUtils::block_students();
$get_move_eval=Security::remove_XSS($_GET['moveeval']);
$evals= Evaluation :: load($get_move_eval);
if (!isset ($_GET['targetcat'])) {
@ -149,7 +139,7 @@ if (isset ($_GET['moveeval'])) {
//move a link
if (isset ($_GET['movelink'])) {
block_students();
GradebookUtils::block_students();
$get_move_link=Security::remove_XSS($_GET['movelink']);
$link= LinkFactory :: load($get_move_link);
$move_form= new LinkForm(LinkForm :: TYPE_MOVE, null, $link[0], 'move_link_form', null, api_get_self() . '?movelink=' . $get_move_link . '&selectcat=' . Security::remove_XSS($_GET['selectcat']));
@ -164,7 +154,7 @@ if (isset ($_GET['movelink'])) {
//parameters for categories
if (isset ($_GET['visiblecat'])) {
block_students();
GradebookUtils::block_students();
if (isset ($_GET['set_visible'])) {
$visibility_command= 1;
} else {
@ -184,7 +174,7 @@ if (isset ($_GET['visiblecat'])) {
}
}
if (isset ($_GET['deletecat'])) {
block_students();
GradebookUtils::block_students();
$cats= Category :: load($_GET['deletecat']);
//delete all categories,subcategories and results
if ($cats[0] != null) {
@ -198,7 +188,7 @@ if (isset ($_GET['deletecat'])) {
}
//parameters for evaluations
if (isset ($_GET['visibleeval'])) {
block_students();
GradebookUtils::block_students();
if (isset ($_GET['set_visible'])) {
$visibility_command= 1;
} else {
@ -218,7 +208,7 @@ if (isset ($_GET['visibleeval'])) {
}
}
if (isset ($_GET['deleteeval'])) {
block_students();
GradebookUtils::block_students();
$eval= Evaluation :: load($_GET['deleteeval']);
if ($eval[0] != null) {
$eval[0]->delete_with_results();
@ -228,7 +218,7 @@ if (isset ($_GET['deleteeval'])) {
}
//parameters for links
if (isset ($_GET['visiblelink'])) {
block_students();
GradebookUtils::block_students();
if (isset ($_GET['set_visible'])) {
$visibility_command= 1;
}else {
@ -247,7 +237,7 @@ if (isset ($_GET['visiblelink'])) {
}
}
if (isset ($_GET['deletelink'])) {
block_students();
GradebookUtils::block_students();
//fixing #5229
if (!empty($_GET['deletelink'])) {
$link= LinkFactory :: load($_GET['deletelink']);
@ -261,7 +251,7 @@ if (isset ($_GET['deletelink'])) {
}
$course_to_crsind = isset ($course_to_crsind) ? $course_to_crsind : '';
if ($course_to_crsind && !isset($_GET['confirm'])) {
block_students();
GradebookUtils::block_students();
if (!isset($_GET['movecat']) && !isset($_GET['moveeval'])) {
die ('Error: movecat or moveeval not defined');
}
@ -280,7 +270,7 @@ if ($course_to_crsind && !isset($_GET['confirm'])) {
}
//actions on the sortabletable
if (isset ($_POST['action'])) {
block_students();
GradebookUtils::block_students();
$number_of_selected_items= count($_POST['id']);
if ($number_of_selected_items == '0') {
$warning_message = get_lang('NoItemsSelected');
@ -524,7 +514,7 @@ if (!empty($keyword)) {
}
$category = Category :: load ($_GET['cat_id']);
if ($category[0]->is_certificate_available($user_id)) {
$user= get_user_info_from_id($user_id);
$user = api_get_user_info($user_id);
$scoredisplay = ScoreDisplay :: instance();
$scorecourse = $category[0]->calc_score($user_id);
$scorecourse_display = (isset($scorecourse) ? $scoredisplay->display_score($scorecourse,SCORE_AVERAGE) : get_lang('NoResultsAvailable'));

@ -14,11 +14,8 @@ if ( empty ($course_code ) ) {
$_in_course = false;
}
require_once 'lib/be.inc.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/catform.class.php';
api_block_anonymous_users();
block_students();
GradebookUtils::block_students();
$edit_cat = isset($_REQUEST['editcat']) ? intval($_REQUEST['editcat']) : '';

@ -8,14 +8,11 @@
$language_file = 'gradebook';
require_once '../inc/global.inc.php';
require_once 'lib/be.inc.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/evalform.class.php';
$current_course_tool = TOOL_GRADEBOOK;
api_protect_course_script();
api_block_anonymous_users();
block_students();
GradebookUtils::block_students();
$select_cat = isset($_GET['selectcat']) ? Security::remove_XSS($_GET['selectcat']) : '';
$is_allowedToEdit = $is_courseAdmin;

@ -9,16 +9,12 @@
$language_file = array('gradebook', 'exercice');
require_once '../inc/global.inc.php';
require_once 'lib/be.inc.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/linkform.class.php';
require_once 'lib/fe/linkaddeditform.class.php';
require_once '../forum/forumfunction.inc.php';
$current_course_tool = TOOL_GRADEBOOK;
api_protect_course_script();
api_block_anonymous_users();
block_students();
GradebookUtils::block_students();
$courseCode = isset($_GET['course_code']) ? Security::remove_XSS($_GET['course_code']) : null;
$course_info = api_get_course_info($courseCode);

@ -9,14 +9,11 @@
$language_file = 'gradebook';
//$cidReset = true;
require_once '../inc/global.inc.php';
require_once 'lib/be.inc.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/catform.class.php';
$current_course_tool = TOOL_GRADEBOOK;
api_protect_course_script();
api_block_anonymous_users();
block_students();
GradebookUtils::block_students();
$catadd = new Category();
$catadd->set_user_id(api_get_user_id());

@ -9,16 +9,11 @@
$language_file = 'gradebook';
//$cidReset = true;
require_once '../inc/global.inc.php';
require_once 'lib/be.inc.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/evalform.class.php';
require_once 'lib/fe/displaygradebook.php';
require_once 'lib/scoredisplay.class.php';
$current_course_tool = TOOL_GRADEBOOK;
api_protect_course_script();
api_block_anonymous_users();
block_students();
GradebookUtils::block_students();
$resultadd = new Result();
$resultadd->set_evaluation_id($_GET['selecteval']);

@ -14,14 +14,8 @@ exit;
$language_file = 'gradebook';
require_once '../inc/global.inc.php';
$this_section = SECTION_MYGRADEBOOK;
require_once 'lib/be.inc.php';
require_once 'lib/fe/displaygradebook.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/evalform.class.php';
require_once 'lib/scoredisplay.class.php';
api_block_anonymous_users();
block_students();
GradebookUtils::block_students();
$evaluation= Evaluation :: load($_GET['selecteval']);
$newstudents = $evaluation[0]->get_not_subscribed_students();

@ -16,10 +16,6 @@ api_protect_course_script();
set_time_limit(0);
ini_set('max_execution_time', 0);
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/be.inc.php';
require_once 'lib/gradebook_data_generator.class.php';
//extra javascript functions for in html head:
$htmlHeadXtra[] ="<script>
function confirmation() {
@ -154,21 +150,21 @@ if ($filter) {
if ($form->validate()) {
$officialCode = $form->getSubmitValue('filter');
if ($officialCode == 'all') {
$certificate_list = get_list_users_certificates($cat_id);
$certificate_list = GradebookUtils::get_list_users_certificates($cat_id);
} else {
$userList = UserManager::getUsersByOfficialCode($officialCode);
if (!empty($userList)) {
$certificate_list = get_list_users_certificates(
$certificate_list = GradebookUtils::get_list_users_certificates(
$cat_id,
$userList
);
}
}
} else {
$certificate_list = get_list_users_certificates($cat_id);
$certificate_list = GradebookUtils::get_list_users_certificates($cat_id);
}
} else {
$certificate_list = get_list_users_certificates($cat_id);
$certificate_list = GradebookUtils::get_list_users_certificates($cat_id);
}
echo '<div class="btn-group">';
@ -199,7 +195,7 @@ if (count($certificate_list) == 0 ) {
echo '<tr><td>
<table class="data_table">';
$list_certificate = get_list_gradebook_certificates_by_user_id($value['user_id'], $cat_id);
$list_certificate = GradebookUtils::get_list_gradebook_certificates_by_user_id($value['user_id'], $cat_id);
foreach ($list_certificate as $value_certificate) {
echo '<tr>';
echo '<td width="50%">'.get_lang('Score').' : '.$value_certificate['score_certificate'].'</td>';

@ -15,16 +15,6 @@ $current_course_tool = TOOL_GRADEBOOK;
api_protect_course_script();
require_once 'lib/be.inc.php';
require_once 'lib/scoredisplay.class.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/catform.class.php';
require_once 'lib/fe/evalform.class.php';
require_once 'lib/fe/linkform.class.php';
require_once 'lib/gradebook_data_generator.class.php';
require_once 'lib/fe/gradebooktable.class.php';
require_once 'lib/fe/displaygradebook.php';
api_block_anonymous_users();
if (!api_is_allowed_to_edit()) {
@ -53,7 +43,7 @@ if (!isset($_GET['exportpdf']) and !isset($_GET['export_certificate'])) {
}
}
$course_id = get_course_id_by_link_id($my_selectcat);
$course_id = GradebookUtils::get_course_id_by_link_id($my_selectcat);
$table_link = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$table_evaluation = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
@ -131,7 +121,7 @@ while ($row = Database ::fetch_array($result)) {
Database::query($sql_t);
}
$tempsql = Database::query('SELECT * FROM '.get_table_type_course($row['type']).' WHERE c_id = '.$course_id.' AND '.$table_evaluated[$row['type']][2].' = '.$row['ref_id']);
$tempsql = Database::query('SELECT * FROM '.GradebookUtils::get_table_type_course($row['type']).' WHERE c_id = '.$course_id.' AND '.$table_evaluated[$row['type']][2].' = '.$row['ref_id']);
$resource_name = Database ::fetch_array($tempsql);
if (isset($resource_name['lp_type'])) {
@ -140,7 +130,7 @@ while ($row = Database ::fetch_array($result)) {
$resource_name = $resource_name[1];
}
$output.= '<tr><td>'.build_type_icon_tag($row['type']).'</td><td> '.$resource_name.' '.Display::label($table_evaluated[$row['type']][3],'info').' </td>';
$output.= '<tr><td>'.GradebookUtils::build_type_icon_tag($row['type']).'</td><td> '.$resource_name.' '.Display::label($table_evaluated[$row['type']][3],'info').' </td>';
$output.= '<td><input type="hidden" name="link_'.$row['id'].'" value="'.$resource_name.'" /><input size="10" type="text" name="link['.$row['id'].']" value="'.$item_weight.'"/></td></tr>';
}
@ -159,7 +149,7 @@ while ($row = Database ::fetch_array($sql)) {
$item_weight = trim($_POST['evaluation'][$row['id']]);
}
$type_evaluated = isset($row['type']) ? $table_evaluated[$type_evaluated][3] : null;
$output.= '<tr><td>'.build_type_icon_tag('evalnotempty').'</td><td>'.$row['name'].' '.Display::label(get_lang('Evaluation').$type_evaluated).'</td>';
$output.= '<tr><td>'.GradebookUtils::build_type_icon_tag('evalnotempty').'</td><td>'.$row['name'].' '.Display::label(get_lang('Evaluation').$type_evaluated).'</td>';
$output.= '<td><input type="hidden" name="eval_'.$row['id'].'" value="'.$row['name'].'" /><input type="text" size="10" name="evaluation['.$row['id'].']" value="'.$item_weight.'"/></td></tr>';
}
//by iflorespaz

@ -9,12 +9,9 @@
$language_file = 'gradebook';
require_once '../inc/global.inc.php';
require_once 'lib/be.inc.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/catform.class.php';
api_block_anonymous_users();
block_students();
GradebookUtils::block_students();
$edit_cat = isset($_REQUEST['editcat']) ? intval($_REQUEST['editcat']) : '';

@ -9,11 +9,8 @@
$language_file = 'gradebook';
//$cidReset = true;
require_once '../inc/global.inc.php';
require_once 'lib/be.inc.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/evalform.class.php';
api_block_anonymous_users();
block_students();
GradebookUtils::block_students();
$evaledit = Evaluation :: load($_GET['editeval']);
if ($evaledit[0]->is_locked() && !api_is_platform_admin()) {

@ -9,16 +9,12 @@
$language_file = array('gradebook', 'exercice', 'link');
//$cidReset = true;
require_once '../inc/global.inc.php';
require_once 'lib/be.inc.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/linkform.class.php';
require_once 'lib/fe/linkaddeditform.class.php';
api_block_anonymous_users();
block_students();
GradebookUtils::block_students();
$tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
//selected name of database
$course_id = get_course_id_by_link_id($_GET['editlink']);
$course_id = GradebookUtils::get_course_id_by_link_id($_GET['editlink']);
$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);

@ -6,15 +6,9 @@
*/
$language_file = 'gradebook';
//$cidReset = true;
require_once '../inc/global.inc.php';
require_once 'lib/be.inc.php';
require_once 'lib/fe/displaygradebook.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/evalform.class.php';
require_once 'lib/scoredisplay.class.php';
api_block_anonymous_users();
block_students();
GradebookUtils::block_students();
$select_eval=Security::remove_XSS($_GET['selecteval']);
if (empty($select_eval)) {
api_not_allowed();

@ -12,16 +12,6 @@ $current_course_tool = TOOL_GRADEBOOK;
api_protect_course_script();
require_once 'lib/be.inc.php';
require_once 'lib/fe/dataform.class.php';
require_once 'lib/fe/userform.class.php';
require_once 'lib/flatview_data_generator.class.php';
require_once 'lib/fe/flatviewtable.class.php';
require_once 'lib/fe/displaygradebook.php';
require_once 'lib/fe/exportgradebook.php';
require_once 'lib/scoredisplay.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
api_block_anonymous_users();
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
api_get_user_id(),
@ -29,7 +19,7 @@ $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
);
if (!$isDrhOfCourse) {
block_students();
GradebookUtils::block_students();
}
if (isset ($_POST['submit']) && isset ($_POST['keyword'])) {
@ -97,10 +87,10 @@ if ($simple_search_form->validate() && (empty($keyword))) {
}
if (!empty($keyword)) {
$users = find_students($keyword);
$users = GradebookUtils::find_students($keyword);
} else {
if (isset($alleval) && isset($alllinks)) {
$users = get_all_users($alleval, $alllinks);
$users = GradebookUtils::get_all_users($alleval, $alllinks);
} else {
$users = null;
}
@ -139,7 +129,7 @@ if (isset($_GET['export_pdf']) && $_GET['export_pdf'] == 'category') {
$params['export_pdf'] = true;
if ($cat[0]->is_locked() == true || api_is_platform_admin()) {
Display :: set_header(null, false, false);
export_pdf_flatview(
GradebookUtils::export_pdf_flatview(
$flatviewtable,
$cat,
$users,
@ -173,7 +163,7 @@ if (isset($_GET['exportpdf'])) {
$params['show_official_code'] = true;
$params['export_pdf'] = true;
$params['only_total_category'] = false;
export_pdf_flatview(
GradebookUtils::export_pdf_flatview(
$flatviewtable,
$cat,
$users,
@ -189,7 +179,7 @@ if (isset($_GET['exportpdf'])) {
}
if (isset($_GET['print'])) {
$printable_data = get_printable_data(
$printable_data = GradebookUtils::get_printable_data(
$cat[0],
$users,
$alleval,
@ -218,7 +208,7 @@ if (!empty($_GET['export_report']) && $_GET['export_report'] == 'export_report')
}
require_once 'gradebook_result.class.php';
$printable_data = get_printable_data(
$printable_data = GradebookUtils::get_printable_data(
$cat[0],
$users,
$alleval,

@ -9,10 +9,6 @@
$language_file= 'gradebook';
require_once '../inc/global.inc.php';
require_once 'lib/be.inc.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/scoredisplayform.class.php';
require_once 'lib/scoredisplay.class.php';
api_block_anonymous_users();

@ -8,12 +8,8 @@
$language_file = 'gradebook';
//$cidReset = true;
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'sortable_table.class.php';
require_once 'lib/be.inc.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/evalform.class.php';
api_block_anonymous_users();
block_students();
GradebookUtils::block_students();
$interbreadcrumb[] = array (
'url' => $_SESSION['gradebook_dest'].'?',

@ -9,13 +9,9 @@
$language_file = 'gradebook';
//$cidReset = true;
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'sortable_table.class.php';
require_once 'lib/be.inc.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/evalform.class.php';
api_block_anonymous_users();
block_students();
GradebookUtils::block_students();
$interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?','name' => get_lang('Gradebook'));
$interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat='.Security::remove_XSS($_GET['selectcat']),'name' => get_lang('Details'));

@ -9,11 +9,6 @@
$language_file= array('gradebook','tracking');
require_once '../inc/global.inc.php';
require_once 'lib/be.inc.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/dataform.class.php';
require_once 'lib/scoredisplay.class.php';
require_once 'lib/fe/displaygradebook.php';
api_block_anonymous_users();

@ -9,17 +9,6 @@ $language_file[] = 'gradebook';
require_once '../inc/global.inc.php';
require_once 'lib/be.inc.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/displaygradebook.php';
require_once 'lib/fe/evalform.class.php';
require_once 'lib/fe/dataform.class.php';
require_once 'lib/results_data_generator.class.php';
require_once 'lib/fe/resulttable.class.php';
require_once 'lib/fe/exportgradebook.php';
require_once 'lib/scoredisplay.class.php';
require_once api_get_path(SYS_CODE_PATH) . 'gradebook/lib/gradebook_functions.inc.php';
api_block_anonymous_users();
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
api_get_user_id(),
@ -27,7 +16,7 @@ $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
);
if (!$isDrhOfCourse) {
block_students();
GradebookUtils::block_students();
}
$interbreadcrumb[] = array(
@ -137,7 +126,7 @@ if (isset($_GET['import'])) {
exit;
break;
} else {
overwritescore($allresult->get_id(), $importedresult['score'], $eval[0]->get_max());
GradebookUtils::overwritescore($allresult->get_id(), $importedresult['score'], $eval[0]->get_max());
$overwritescore++;
$added = '1';
}
@ -150,7 +139,7 @@ if (isset($_GET['import'])) {
header('Location: gradebook_view_result.php?selecteval=' . Security::remove_XSS($_GET['selecteval']) . '&incorrectdata=');
exit;
}
$userinfo = get_user_info_from_id($importedresult['user_id']);
$userinfo = api_get_user_info($importedresult['user_id']);
if ($userinfo['lastname'] != $importedresult['lastname'] ||
$userinfo['firstname'] != $importedresult['firstname'] ||
$userinfo['official_code'] != $importedresult['official_code']
@ -328,7 +317,7 @@ if (isset($_GET['export'])) {
// export results to xml or csv file
foreach ($results as $result) {
$userinfo = get_user_info_from_id($result->get_user_id());
$userinfo = api_get_user_info($result->get_user_id());
$data['username'] = $userinfo['username']; //$result->get_user_id();
$data['official_code'] = $userinfo['official_code'];
$data['lastname'] = $userinfo['lastname'];
@ -489,14 +478,14 @@ if (isset($_GET['importoverwritescore'])) {
Display :: display_confirmation_message(get_lang('ImportOverWriteScore') . ' ' . $_GET['importoverwritescore']);
}
if (isset($_GET['import_user_error'])) {
$userinfo = get_user_info_from_id($_GET['import_user_error']);
$userinfo = api_get_user_info($_GET['import_user_error']);
Display :: display_warning_message(get_lang('UserInfoDoesNotMatch') . ' ' . api_get_person_name($userinfo['firstname'], $userinfo['lastname']));
}
if (isset($_GET['allresdeleted'])) {
Display :: display_confirmation_message(get_lang('AllResultDeleted'));
}
if (isset($_GET['import_score_error'])) {
$userinfo = get_user_info_from_id($_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']));
}
if ($file_type == null) { //show the result header

@ -26,17 +26,6 @@ $_SESSION['gradebook_dest'] = 'index.php';
$this_section = SECTION_COURSES;
require_once 'lib/be.inc.php';
require_once 'lib/scoredisplay.class.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/catform.class.php';
require_once 'lib/fe/evalform.class.php';
require_once 'lib/fe/linkform.class.php';
require_once 'lib/gradebook_data_generator.class.php';
require_once 'lib/fe/gradebooktable.class.php';
require_once 'lib/fe/displaygradebook.php';
require_once 'lib/fe/userform.class.php';
/*
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/jqplot/jquery.jqplot.min.css');
$htmlHeadXtra[] = api_get_js('jqplot/jquery.jqplot.min.js');
@ -164,7 +153,7 @@ if ((isset($_GET['selectcat']) && $_GET['selectcat']>0) &&
// ACTIONS
//this is called when there is no data for the course admin
if (isset ($_GET['createallcategories'])) {
block_students();
GradebookUtils::block_students();
$coursecat= Category :: get_not_created_course_categories($stud_id);
if (!count($coursecat) == 0) {
foreach ($coursecat as $row) {
@ -192,7 +181,7 @@ if (isset ($_GET['visiblelog'])) {
//move a category
if (isset ($_GET['movecat'])) {
block_students();
GradebookUtils::block_students();
$cats= Category :: load($_GET['movecat']);
if (!isset ($_GET['targetcat'])) {
$move_form= new CatForm(CatForm :: TYPE_MOVE,
@ -223,7 +212,7 @@ if (isset ($_GET['movecat'])) {
//move an evaluation
if (isset ($_GET['moveeval'])) {
block_students();
GradebookUtils::block_students();
$evals= Evaluation :: load($_GET['moveeval']);
if (!isset ($_GET['targetcat'])) {
@ -257,7 +246,7 @@ if (isset ($_GET['moveeval'])) {
//move a link
if (isset ($_GET['movelink'])) {
block_students();
GradebookUtils::block_students();
$link= LinkFactory :: load($_GET['movelink']);
$move_form = new LinkForm(
LinkForm :: TYPE_MOVE,
@ -279,7 +268,7 @@ if (isset ($_GET['movelink'])) {
//parameters for categories
if (isset ($_GET['visiblecat'])) {
block_students();
GradebookUtils::block_students();
if (isset ($_GET['set_visible'])) {
$visibility_command= 1;
@ -300,7 +289,7 @@ if (isset ($_GET['visiblecat'])) {
}
}
if (isset($_GET['deletecat'])) {
block_students();
GradebookUtils::block_students();
$cats = Category :: load($_GET['deletecat']);
if (isset($cats[0])) {
//delete all categories,subcategories and results
@ -316,7 +305,7 @@ if (isset($_GET['deletecat'])) {
}
//parameters for evaluations
if (isset ($_GET['visibleeval'])) {
block_students();
GradebookUtils::block_students();
if (isset ($_GET['set_visible'])) {
$visibility_command= 1;
} else {
@ -336,7 +325,7 @@ if (isset ($_GET['visibleeval'])) {
}
//parameters for evaluations
if (isset($_GET['lockedeval'])) {
block_students();
GradebookUtils::block_students();
$locked = Security::remove_XSS($_GET['lockedeval']);
if (isset($_GET['typelocked']) && api_is_platform_admin()){
$type_locked = 0;
@ -354,7 +343,7 @@ if (isset($_GET['lockedeval'])) {
}
if (isset ($_GET['deleteeval'])) {
block_students();
GradebookUtils::block_students();
$eval= Evaluation :: load($_GET['deleteeval']);
if ($eval[0] != null) {
$eval[0]->delete_with_results();
@ -364,7 +353,7 @@ if (isset ($_GET['deleteeval'])) {
}
//parameters for links
if (isset ($_GET['visiblelink'])) {
block_students();
GradebookUtils::block_students();
if (isset ($_GET['set_visible'])) {
$visibility_command= 1;
} else {
@ -388,7 +377,7 @@ if (isset ($_GET['visiblelink'])) {
$course_id = api_get_course_int_id();
if (isset ($_GET['deletelink'])) {
block_students();
GradebookUtils::block_students();
$get_delete_link = intval($_GET['deletelink']);
//fixing #5229
if (!empty($get_delete_link)) {
@ -417,7 +406,7 @@ if (isset ($_GET['deletelink'])) {
}
if (!empty($course_to_crsind) && !isset($_GET['confirm'])) {
block_students();
GradebookUtils::block_students();
if (!isset($_GET['movecat']) && !isset($_GET['moveeval'])) {
die ('Error: movecat or moveeval not defined');
@ -452,7 +441,7 @@ switch ($action) {
//actions on the sortabletable
if (isset ($_POST['action'])) {
block_students();
GradebookUtils::block_students();
$number_of_selected_items= count($_POST['id']);
if ($number_of_selected_items == '0') {

File diff suppressed because it is too large Load Diff

@ -1,9 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* include this file to have access to all backend classes
* @author Bert Steppé
* @package chamilo.gradebook
*/
define ('LIMIT', 1000);

@ -1638,15 +1638,15 @@ class Category implements GradebookItem
if (isset($certificate_min_score) &&
$item_total_value >= $certificate_min_score
) {
$my_certificate = get_certificate_by_user_id($cats_course[0]->get_id(), $user_id);
$my_certificate = GradebookUtils::get_certificate_by_user_id($cats_course[0]->get_id(), $user_id);
if (empty($my_certificate)) {
register_user_info_about_certificate(
GradebookUtils::register_user_info_about_certificate(
$category_id,
$user_id,
$my_score_in_gradebook,
api_get_utc_datetime()
);
$my_certificate = get_certificate_by_user_id($cats_course[0]->get_id(), $user_id);
$my_certificate = GradebookUtils::get_certificate_by_user_id($cats_course[0]->get_id(), $user_id);
}
$html = array();
if (!empty($my_certificate)) {
@ -1737,12 +1737,12 @@ class Category implements GradebookItem
$page_format = $params['orientation'] == 'landscape' ? 'A4-L' : 'A4';
$pdf = new PDF($page_format, $params['orientation'], $params);
$certificate_list = get_list_users_certificates($catId, $userList);
$certificate_list = GradebookUtils::get_list_users_certificates($catId, $userList);
$certificate_path_list = array();
if (!empty($certificate_list)) {
foreach ($certificate_list as $index=>$value) {
$list_certificate = get_list_gradebook_certificates_by_user_id(
$list_certificate = GradebookUtils::get_list_gradebook_certificates_by_user_id(
$value['user_id'],
$catId
);
@ -1774,10 +1774,10 @@ class Category implements GradebookItem
*/
public static function deleteAllCertificates($catId)
{
$certificate_list = get_list_users_certificates($catId);
$certificate_list = GradebookUtils::get_list_users_certificates($catId);
if (!empty($certificate_list)) {
foreach ($certificate_list as $index=>$value) {
$list_certificate = get_list_gradebook_certificates_by_user_id($value['user_id'], $catId);
$list_certificate = GradebookUtils::get_list_gradebook_certificates_by_user_id($value['user_id'], $catId);
foreach ($list_certificate as $value_certificate) {
$certificate_obj = new Certificate($value_certificate['id']);
$certificate_obj->delete(true);

@ -1,9 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
require_once dirname(__FILE__).'/../../../inc/global.inc.php';
require_once dirname(__FILE__).'/../be.inc.php';
/**
* Class CatForm
*

@ -1,11 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
require_once dirname(__FILE__).'/../../../inc/global.inc.php';
require_once dirname(__FILE__).'/../be.inc.php';
require_once dirname(__FILE__).'/../gradebook_functions.inc.php';
require_once api_get_path(LIBRARY_PATH) . 'groupmanager.lib.php';
/**
* Extends FormValidator with import and export forms
* @author Stijn Konings

@ -85,7 +85,7 @@ class DisplayGradebook
if ($evalobj->get_course_code() == null) {
$course = get_lang('CourseIndependent');
} else {
$course = get_course_name_from_code($evalobj->get_course_code());
$course = CourseManager::getCourseNameFromCode($evalobj->get_course_code());
}
$evalinfo = '<table width="100%" border="0"><tr><td>';
@ -216,7 +216,7 @@ class DisplayGradebook
if (!$is_course_admin && $status <> 1 && $selectcat <> 0) {
$user_id = api_get_user_id();
$user = get_user_info_from_id($user_id);
$user = api_get_user_info($user_id);
$catcourse = Category :: load($catobj->get_id());
$scoredisplay = ScoreDisplay :: instance();

@ -1,19 +1,15 @@
<?php
/* For licensing terms, see /license.txt */
require_once dirname(__FILE__) . '/../../../inc/global.inc.php';
require_once dirname(__FILE__) . '/../be.inc.php';
require_once dirname(__FILE__) . '/../gradebook_functions.inc.php';
require_once api_get_path(LIBRARY_PATH) . 'groupmanager.lib.php';
$htmlHeadXtra[] = '<script type="text/javascript">
/*$htmlHeadXtra[] = '<script type="text/javascript">
function setFocus(){
$("#evaluation_title").focus();
}
$(document).ready(function () {
setFocus();
});
</script>';
</script>';*/
/**
* Class EvalForm
@ -166,7 +162,7 @@ class EvalForm extends FormValidator
$results_and_users = array();
foreach ($this->result_object as $result) {
$user = get_user_info_from_id($result->get_user_id());
$user = api_get_user_info($result->get_user_id());
$results_and_users[] = array('result' => $result, 'user' => $user);
}
usort($results_and_users, array('EvalForm', 'sort_by_user'));
@ -246,7 +242,7 @@ class EvalForm extends FormValidator
</form>'
);
$tblusers = get_users_in_course($this->evaluation_object->get_course_code());
$tblusers = GradebookUtils::get_users_in_course($this->evaluation_object->get_course_code());
$nr_users = 0;
//extra field for check on maxvalue
$this->addElement('hidden', 'maxvalue', $this->evaluation_object->get_max());

@ -1,8 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
require_once dirname(__FILE__) . '/../../../inc/global.inc.php';
require_once dirname(__FILE__) . '/../be.inc.php';
set_time_limit(0);
use CpChart\Classes\pData as pData;
@ -324,24 +322,24 @@ class FlatViewTable extends SortableTable
// create page navigation if needed
$totalitems = $this->datagen->get_total_items_count();
if ($this->limit_enabled && $totalitems > LIMIT) {
$selectlimit = LIMIT;
if ($this->limit_enabled && $totalitems > GRADEBOOK_ITEM_LIMIT) {
$selectlimit = GRADEBOOK_ITEM_LIMIT;
} else {
$selectlimit = $totalitems;
}
$header = null;
if ($this->limit_enabled && $totalitems > LIMIT) {
if ($this->limit_enabled && $totalitems > GRADEBOOK_ITEM_LIMIT) {
$header .= '<table style="width: 100%; text-align: right; margin-left: auto; margin-right: auto;" border="0" cellpadding="2">'
. '<tbody>'
. '<tr>';
// previous X
$header .= '<td style="width:100%;">';
if ($this->offset >= LIMIT) {
if ($this->offset >= GRADEBOOK_ITEM_LIMIT) {
$header .= '<a href="' . api_get_self()
. '?selectcat=' . Security::remove_XSS($_GET['selectcat'])
. '&offset=' . (($this->offset) - LIMIT)
. '&offset=' . (($this->offset) - GRADEBOOK_ITEM_LIMIT)
. (isset($_GET['search']) ? '&search=' . Security::remove_XSS($_GET['search']) : '') . '">'
. Display::return_icon('action_prev.png', get_lang('PreviousPage'), array(), 32)
. '</a>';
@ -350,13 +348,13 @@ class FlatViewTable extends SortableTable
}
$header .= ' ';
// next X
$calcnext = (($this->offset + (2 * LIMIT)) > $totalitems) ?
($totalitems - (LIMIT + $this->offset)) : LIMIT;
$calcnext = (($this->offset + (2 * GRADEBOOK_ITEM_LIMIT)) > $totalitems) ?
($totalitems - (GRADEBOOK_ITEM_LIMIT + $this->offset)) : GRADEBOOK_ITEM_LIMIT;
if ($calcnext > 0) {
$header .= '<a href="' . api_get_self()
. '?selectcat=' . Security::remove_XSS($_GET['selectcat'])
. '&offset=' . ($this->offset + LIMIT)
. '&offset=' . ($this->offset + GRADEBOOK_ITEM_LIMIT)
. (isset($_GET['search']) ? '&search=' . Security::remove_XSS($_GET['search']) : '') . '">'
. Display::return_icon('action_next.png', get_lang('NextPage'), array(), 32)
. '</a>';

@ -1,9 +1,6 @@
<?php
/* For licensing terms, see license.txt */
require_once dirname(__FILE__).'/../../../inc/global.inc.php';
require_once dirname(__FILE__).'/../be.inc.php';
/**
* GradebookTable Class
* Table to display categories, evaluations and links
@ -352,7 +349,7 @@ class GradebookTable extends SortableTable
// Compare the category weight to the sum of all weights inside the category
if (intval($total_weight) == $category_weight) {
$label = null;
$total = score_badges(array($total_weight.' / '.$category_weight, '100'));
$total = GradebookUtils::score_badges(array($total_weight.' / '.$category_weight, '100'));
} else {
$label = Display::return_icon(
'warning.png',
@ -380,7 +377,7 @@ class GradebookTable extends SortableTable
$main_weight = intval($main_cat[0]->get_weight());
if (intval($total_categories_weight) == $main_weight) {
$total = score_badges(array($total_categories_weight.' / '.$main_weight, '100'));
$total = GradebookUtils::score_badges(array($total_categories_weight.' / '.$main_weight, '100'));
} else {
$total = Display::badge($total_categories_weight.' / '.$main_weight, 'warning');
}
@ -523,7 +520,7 @@ class GradebookTable extends SortableTable
*/
private function build_type_column ($item, $attributes = array())
{
return build_type_icon_tag($item->get_icon_name(), $attributes);
return GradebookUtils::build_type_icon_tag($item->get_icon_name(), $attributes);
}
/**
@ -622,13 +619,13 @@ class GradebookTable extends SortableTable
switch ($item->get_item_type()) {
// category
case 'C' :
return build_edit_icons_cat($item, $this->currentcat);
return GradebookUtils::build_edit_icons_cat($item, $this->currentcat);
// evaluation
case 'E' :
return build_edit_icons_eval($item, $this->currentcat->get_id());
return GradebookUtils::build_edit_icons_eval($item, $this->currentcat->get_id());
// link
case 'L' :
return build_edit_icons_link($item, $this->currentcat->get_id());
return GradebookUtils::build_edit_icons_link($item, $this->currentcat->get_id());
}
}
}

@ -1,11 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
require_once dirname(__FILE__).'/../../../inc/global.inc.php';
require_once dirname(__FILE__).'/../be.inc.php';
require_once dirname(__FILE__).'/../gradebook_functions.inc.php';
require_once api_get_path(LIBRARY_PATH) . 'groupmanager.lib.php';
/**
* Form used to add or edit links
* @author Stijn Konings

@ -1,11 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
require_once dirname(__FILE__).'/../../../inc/global.inc.php';
require_once dirname(__FILE__).'/../be.inc.php';
require_once dirname(__FILE__).'/../gradebook_functions.inc.php';
require_once api_get_path(LIBRARY_PATH) . 'groupmanager.lib.php';
/**
* Class LinkForm
* Forms related to links

@ -1,9 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
require_once dirname(__FILE__).'/../../../inc/global.inc.php';
require_once dirname(__FILE__).'/../be.inc.php';
/**
* Class ResultTable
* Table to display results for an evaluation

@ -1,9 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
require_once dirname(__FILE__).'/../../../inc/global.inc.php';
require_once dirname(__FILE__).'/../gradebook_functions.inc.php';
/**
* Class ScoreDisplayForm
* Form for the score display dialog

@ -1,12 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
require_once dirname(__FILE__).'/../../../inc/global.inc.php';
require_once dirname(__FILE__).'/../be.inc.php';
require_once dirname(__FILE__).'/../gradebook_functions.inc.php';
require_once api_get_path(LIBRARY_PATH) . 'groupmanager.lib.php';
require_once api_get_path(LIBRARY_PATH) . 'formvalidator/FormValidator.class.php';
/**
* Class UserForm
* Extends formvalidator with import and export forms

@ -1,9 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
require_once dirname(__FILE__).'/../../../inc/global.inc.php';
require_once dirname(__FILE__).'/../be.inc.php';
/**
* Class UserTable
* Table to display flat view of a student's evaluations and links
@ -113,7 +110,7 @@ class UserTable extends SortableTable
*/
private function build_type_column($item)
{
return build_type_icon_tag($item->get_icon_name());
return GradebookUtils::build_type_icon_tag($item->get_icon_name());
}
/**

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Class GradebookDataGenerator
* Class to select, sort and transform object data into array data,

@ -1,983 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Script
* @package chamilo.gradebook
*/
/**
* These are functions used in gradebook
*
* @author Stijn Konings <konings.stijn@skynet.be>, Hogeschool Ghent
* @author Julio Montoya <gugli100@gmail.com> adding security functions
* @version april 2007
*/
require_once api_get_path(SYS_CODE_PATH) . 'gradebook/lib/be.inc.php';
require_once 'gradebook_functions_users.inc.php';
/**
* Adds a resource to the unique gradebook of a given course
* @param int
* @param string Course code
* @param int Resource type (use constants defined in linkfactory.class.php)
* @param int Resource ID in the corresponding tool
* @param string Resource name to show in the gradebook
* @param int Resource weight to set in the gradebook
* @param int Resource max
* @param string Resource description
* @param int Visibility (0 hidden, 1 shown)
* @param int Session ID (optional or 0 if not defined)
* @param int
* @return boolean True on success, false on failure
*/
function add_resource_to_course_gradebook(
$category_id,
$course_code,
$resource_type,
$resource_id,
$resource_name = '',
$weight = 0,
$max = 0,
$resource_description = '',
$visible = 0,
$session_id = 0,
$link_id = null
) {
$link = LinkFactory :: create($resource_type);
$link->set_user_id(api_get_user_id());
$link->set_course_code($course_code);
if (empty($category_id)) {
return false;
}
$link->set_category_id($category_id);
if ($link->needs_name_and_description()) {
$link->set_name($resource_name);
} else {
$link->set_ref_id($resource_id);
}
$link->set_weight($weight);
if ($link->needs_max()) {
$link->set_max($max);
}
if ($link->needs_name_and_description()) {
$link->set_description($resource_description);
}
$link->set_visible(empty($visible) ? 0 : 1);
if (!empty($session_id)) {
$link->set_session_id($session_id);
}
$link->add();
return true;
}
/**
* Update a resource weight
* @param int Link/Resource ID
* @param string
* @param float
* @return bool false on error, true on success
*/
function update_resource_from_course_gradebook($link_id, $course_code, $weight)
{
$course_code = Database::escape_string($course_code);
if (!empty($link_id)) {
$link_id = intval($link_id);
$sql = 'UPDATE ' . Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK) . '
SET weight = ' . "'" . Database::escape_string((float) $weight) . "'" . '
WHERE course_code = "' . $course_code . '" AND id = ' . $link_id;
Database::query($sql);
}
return true;
}
/**
* Remove a resource from the unique gradebook of a given course
* @param int Link/Resource ID
* @return bool false on error, true on success
*/
function remove_resource_from_course_gradebook($link_id)
{
if (empty($link_id)) {
return false;
}
// TODO find the corresponding category (the first one for this course, ordered by ID)
$l = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$sql = "DELETE FROM $l WHERE id = ".(int)$link_id;
Database::query($sql);
return true;
}
function block_students()
{
if (!api_is_allowed_to_edit()) {
api_not_allowed();
}
}
/**
* Returns the course name from a given code
* @param string $code
*/
function get_course_name_from_code($code)
{
$tbl_main_categories = Database :: get_main_table(TABLE_MAIN_COURSE);
$sql = 'SELECT title, code
FROM ' . $tbl_main_categories . '
WHERE code = "' . Database::escape_string($code) . '"';
$result = Database::query($sql);
if ($col = Database::fetch_array($result)) {
return $col['title'];
}
}
/**
* Builds an img tag for a gradebook item
* @param string $type value returned by a gradebookitem's get_icon_name()
*/
function build_type_icon_tag($kind, $attributes = array())
{
return Display::return_icon(get_icon_file_name($kind), ' ', $attributes, ICON_SIZE_SMALL);
}
/**
* Returns the icon filename for a gradebook item
* @param string $type value returned by a gradebookitem's get_icon_name()
*/
function get_icon_file_name($type)
{
switch ($type) {
case 'cat':
$icon = 'gradebook.png';
break;
case 'evalempty':
$icon = 'empty_evaluation.png';
break;
case 'evalnotempty':
$icon = 'no_empty_evaluation.png';
break;
case 'exercise':
case LINK_EXERCISE:
$icon = 'quiz.gif';
break;
case 'learnpath':
case LINK_LEARNPATH:
$icon = 'learnpath.png';
break;
case 'studentpublication':
case LINK_STUDENTPUBLICATION:
$icon = 'works.gif';
break;
case 'link':
$icon = 'link.gif';
break;
case 'forum':
case LINK_FORUM_THREAD:
$icon = 'forum.gif';
break;
case 'attendance':
case LINK_ATTENDANCE:
$icon = 'attendance.gif';
break;
case 'survey':
case LINK_SURVEY:
$icon = 'survey.gif';
break;
case 'dropbox':
case LINK_DROPBOX:
$icon = 'dropbox.gif';
break;
default:
$icon = 'link.gif';
break;
}
return $icon;
}
/**
* Builds the course or platform admin icons to edit a category
* @param Category $cat category
* @param Category $selectcat id of selected category
*/
function build_edit_icons_cat($cat, $selectcat)
{
$show_message = $cat->show_message_resource_delete($cat->get_course_code());
$grade_model_id = $selectcat->get_grade_model_id();
$selectcat = $selectcat->get_id();
$modify_icons = null;
if ($show_message === false) {
$visibility_icon = ($cat->is_visible() == 0) ? 'invisible' : 'visible';
$visibility_command = ($cat->is_visible() == 0) ? 'set_visible' : 'set_invisible';
$modify_icons .= '<a class="view_children" data-cat-id="' . $cat->get_id() . '" href="javascript:void(0);">' .
Display::return_icon('view_more_stats.gif', get_lang('Show'), '', ICON_SIZE_SMALL) . '</a>';
if (api_is_allowed_to_edit(null, true)) {
// Locking button
if (api_get_setting('gradebook_locking_enabled') == 'true') {
if ($cat->is_locked()) {
if (api_is_platform_admin()) {
$modify_icons .= '&nbsp;<a onclick="javascript:if (!confirm(\'' . addslashes(get_lang('ConfirmToUnlockElement')) . '\')) return false;" href="' . api_get_self() . '?' . api_get_cidreq() . '&category_id=' . $cat->get_id() . '&action=unlock">' .
Display::return_icon('lock.png', get_lang('UnLockEvaluation'), '', ICON_SIZE_SMALL) . '</a>';
} else {
$modify_icons .= '&nbsp;<a href="#">' . Display::return_icon('lock_na.png', get_lang('GradebookLockedAlert'), '', ICON_SIZE_SMALL) . '</a>';
}
$modify_icons .= '&nbsp;<a href="gradebook_flatview.php?export_pdf=category&selectcat=' . $cat->get_id() . '" >' . Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_SMALL) . '</a>';
} else {
$modify_icons .= '&nbsp;<a onclick="javascript:if (!confirm(\'' . addslashes(get_lang('ConfirmToLockElement')) . '\')) return false;" href="' . api_get_self() . '?' . api_get_cidreq() . '&category_id=' . $cat->get_id() . '&action=lock">' .
Display::return_icon('unlock.png', get_lang('LockEvaluation'), '', ICON_SIZE_SMALL) . '</a>';
$modify_icons .= '&nbsp;<a href="#" >' . Display::return_icon('pdf_na.png', get_lang('ExportToPDF'), '', ICON_SIZE_SMALL) . '</a>';
//$modify_icons .= '&nbsp;<a href="gradebook_flatview.php?export_pdf=category&selectcat=' . $cat->get_id() . '" >'.Display::return_icon('pdf.png', get_lang('ExportToPDF'),'',ICON_SIZE_SMALL).'</a>';
}
}
if (empty($grade_model_id) || $grade_model_id == -1) {
if ($cat->is_locked() && !api_is_platform_admin()) {
$modify_icons .= Display::return_icon('edit_na.png', get_lang('Modify'), '', ICON_SIZE_SMALL);
} else {
$modify_icons .= '<a href="gradebook_edit_cat.php?' .'editcat=' . $cat->get_id() . '&cidReq=' .$cat->get_course_code() . '&id_session='.$cat->get_session_id().'">' .
Display::return_icon(
'edit.png',
get_lang('Modify'),
'',
ICON_SIZE_SMALL
) . '</a>';
}
}
$modify_icons .= '<a href="gradebook_edit_all.php?selectcat=' .$cat->get_id() . '&cidReq=' . $cat->get_course_code() . '&id_session='.$cat->get_session_id().'">' .
Display::return_icon(
'percentage.png',
get_lang('EditAllWeights'),
'',
ICON_SIZE_SMALL
) . '</a>';
$modify_icons .= '<a href="gradebook_flatview.php?selectcat=' .$cat->get_id() . '&cidReq=' . $cat->get_course_code() . '&id_session='.$cat->get_session_id(). '">' .
Display::return_icon(
'stats.png',
get_lang('FlatView'),
'',
ICON_SIZE_SMALL
) . '</a>';
$modify_icons .= '&nbsp;<a href="' . api_get_self() .'?visiblecat=' . $cat->get_id() . '&' .$visibility_command . '=&selectcat=' . $selectcat .'&cidReq=' . $cat->get_course_code() . '&id_session='.$cat->get_session_id(). '">' .
Display::return_icon(
$visibility_icon . '.png',
get_lang('Visible'),
'',
ICON_SIZE_SMALL
) . '</a>';
//no move ability for root categories
if ($cat->is_movable()) {
/* $modify_icons .= '&nbsp;<a href="' . api_get_self() . '?movecat=' . $cat->get_id() . '&amp;selectcat=' . $selectcat . ' &amp;cidReq='.$cat->get_course_code().'">
<img src="../img/icons/22/move.png" border="0" title="' . get_lang('Move') . '" alt="" /></a>'; */
} else {
//$modify_icons .= '&nbsp;<img src="../img/deplacer_fichier_na.gif" border="0" title="' . get_lang('Move') . '" alt="" />';
}
if ($cat->is_locked() && !api_is_platform_admin()) {
$modify_icons .= Display::return_icon('delete_na.png', get_lang('DeleteAll'), '', ICON_SIZE_SMALL);
} else {
$modify_icons .= '&nbsp;<a href="' . api_get_self() . '?deletecat=' . $cat->get_id() . '&amp;selectcat=' . $selectcat . '&amp;cidReq=' . $cat->get_course_code() . '&id_session='.$cat->get_session_id(). '" onclick="return confirmation();">' .
Display::return_icon('delete.png', get_lang('DeleteAll'), '', ICON_SIZE_SMALL) . '</a>';
}
}
return $modify_icons;
}
}
/**
* Builds the course or platform admin icons to edit an evaluation
* @param Evaluation $eval evaluation object
* @param int $selectcat id of selected category
*/
function build_edit_icons_eval($eval, $selectcat)
{
$status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
$is_locked = $eval->is_locked();
$eval->get_course_code();
$cat = new Category();
$message_eval = $cat->show_message_resource_delete($eval->get_course_code());
if ($message_eval === false && api_is_allowed_to_edit(null, true)) {
$visibility_icon = ($eval->is_visible() == 0) ? 'invisible' : 'visible';
$visibility_command = ($eval->is_visible() == 0) ? 'set_visible' : 'set_invisible';
if ($is_locked && !api_is_platform_admin()) {
$modify_icons = Display::return_icon('edit_na.png', get_lang('Modify'), '', ICON_SIZE_SMALL);
} else {
$modify_icons = '<a href="gradebook_edit_eval.php?editeval=' . $eval->get_id() . ' &amp;cidReq=' . $eval->get_course_code() . '&id_session='.$eval->getSessionId(). '">' .
Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
}
$modify_icons .= '&nbsp;<a href="' . api_get_self() . '?visibleeval=' . $eval->get_id() . '&amp;' . $visibility_command . '=&amp;selectcat=' . $selectcat . '&id_session='.$eval->getSessionId(). ' ">' .
Display::return_icon($visibility_icon . '.png', get_lang('Visible'), '', ICON_SIZE_SMALL) . '</a>';
if (api_is_allowed_to_edit(null, true)) {
$modify_icons .= '&nbsp;<a href="gradebook_showlog_eval.php?visiblelog=' . $eval->get_id() . '&amp;selectcat=' . $selectcat . ' &amp;cidReq=' . $eval->get_course_code() . '&id_session='.$eval->getSessionId(). '">' .
Display::return_icon('history.png', get_lang('GradebookQualifyLog'), '', ICON_SIZE_SMALL) . '</a>';
}
/*
if ($locked_status == 0){
$modify_icons .= "&nbsp;<a href=\"javascript:if (confirm('".addslashes(get_lang('AreYouSureToLockedTheEvaluation'))."')) { location.href='".api_get_self().'?lockedeval=' . $eval->get_id() . '&amp;selectcat=' . $selectcat . ' &amp;cidReq='.$eval->get_course_code()."'; }\">".Display::return_icon('unlock.png',get_lang('LockEvaluation'), array(), ICON_SIZE_SMALL)."</a>";
} else {
if (api_is_platform_admin()){
$modify_icons .= "&nbsp;<a href=\"javascript:if (confirm('".addslashes(get_lang('AreYouSureToUnLockedTheEvaluation'))."')) { location.href='".api_get_self().'?lockedeval=' . $eval->get_id() . '&amp;typelocked=&amp;selectcat=' . $selectcat . ' &amp;cidReq='.$eval->get_course_code()."';\">".Display::return_icon('lock.png',get_lang('UnLockEvaluation'), array(), ICON_SIZE_SMALL)."</a>";
} else {
$modify_icons .= '&nbsp;<img src="../img/locked_na.png" border="0" title="' . get_lang('TheEvaluationIsLocked') . '" alt="" />';
}
} */
if ($is_locked && !api_is_platform_admin()) {
$modify_icons .= '&nbsp;' . Display::return_icon('delete_na.png', get_lang('Delete'), '', ICON_SIZE_SMALL);
} else {
$modify_icons .= '&nbsp;<a href="' . api_get_self() . '?deleteeval=' . $eval->get_id() . '&selectcat=' . $selectcat . ' &amp;cidReq=' . $eval->get_course_code() . '&id_session='.$eval->getSessionId(). '" onclick="return confirmation();">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>';
}
return $modify_icons;
}
}
/**
* Builds the course or platform admin icons to edit a link
* @param AbstractLink $link
* @param int $selectcat id of selected category
*/
function build_edit_icons_link($link, $selectcat)
{
$cat = new Category();
$message_link = $cat->show_message_resource_delete($link->get_course_code());
$is_locked = $link->is_locked();
$modify_icons = null;
if (!api_is_allowed_to_edit(null, true)) {
return null;
}
if ($message_link === false) {
$visibility_icon = ($link->is_visible() == 0) ? 'invisible' : 'visible';
$visibility_command = ($link->is_visible() == 0) ? 'set_visible' : 'set_invisible';
if ($is_locked && !api_is_platform_admin()) {
$modify_icons = Display::return_icon('edit_na.png', get_lang('Modify'), '', ICON_SIZE_SMALL);
} else {
$modify_icons = '<a href="gradebook_edit_link.php?editlink=' . $link->get_id() . '&amp;cidReq=' . $link->get_course_code() . '&id_session='.$link->get_session_id().'">' .
Display::return_icon('edit.png', get_lang('Modify'), '', ICON_SIZE_SMALL) . '</a>';
}
//$modify_icons .= '&nbsp;<a href="' . api_get_self() . '?movelink=' . $link->get_id() . '&selectcat=' . $selectcat . '"><img src="../img/deplacer_fichier.gif" border="0" title="' . get_lang('Move') . '" alt="" /></a>';
$modify_icons .= '&nbsp;<a href="' . api_get_self() . '?visiblelink=' . $link->get_id() . '&amp;' . $visibility_command . '=&amp;selectcat=' . $selectcat . '&id_session='.$link->get_session_id(). ' ">' .
Display::return_icon($visibility_icon . '.png', get_lang('Visible'), '', ICON_SIZE_SMALL) . '</a>';
$modify_icons .= '&nbsp;<a href="gradebook_showlog_link.php?visiblelink=' . $link->get_id() . '&amp;selectcat=' . $selectcat . '&amp;cidReq=' . $link->get_course_code() . '&id_session='.$link->get_session_id(). '">' .
Display::return_icon('history.png', get_lang('GradebookQualifyLog'), '', ICON_SIZE_SMALL) . '</a>';
//If a work is added in a gradebook you can only delete the link in the work tool
if ($is_locked && !api_is_platform_admin()) {
$modify_icons .= '&nbsp;' . Display::return_icon('delete_na.png', get_lang('Delete'), '', ICON_SIZE_SMALL);
} else {
$modify_icons .= '&nbsp;<a href="' . api_get_self() . '?deletelink=' . $link->get_id() . '&selectcat=' . $selectcat . ' &amp;cidReq=' . $link->get_course_code() . '&id_session='.$link->get_session_id(). '" onclick="return confirmation();">' .
Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>';
}
return $modify_icons;
}
}
/**
* Checks if a resource is in the unique gradebook of a given course
* @param string Course code
* @param int Resource type (use constants defined in linkfactory.class.php)
* @param int Resource ID in the corresponding tool
* @param int Session ID (optional - 0 if not defined)
* @return int false on error or link ID
*/
function is_resource_in_course_gradebook($course_code, $resource_type, $resource_id, $session_id = 0)
{
$l = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$course_code = Database::escape_string($course_code);
$sql = "SELECT * FROM $l l
WHERE
course_code = '$course_code' AND
type = ".(int)$resource_type . " AND
ref_id = " . (int)$resource_id;
$res = Database::query($sql);
if (Database::num_rows($res) < 1) {
return false;
}
$row = Database::fetch_array($res, 'ASSOC');
return $row;
}
/**
* Remove a resource from the unique gradebook of a given course
* @param int Link/Resource ID
* @return bool false on error, true on success
*/
function get_resource_from_course_gradebook($link_id)
{
if (empty($link_id)) {
return false;
}
// TODO find the corresponding category (the first one for this course, ordered by ID)
$l = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$sql = "SELECT * FROM $l WHERE id = " . (int) $link_id;
$res = Database::query($sql);
$row = array();
if (Database::num_rows($res) > 0) {
$row = Database::fetch_array($res, 'ASSOC');
}
return $row;
}
/**
* Return the database name
* @param int
* @return String
*/
function get_database_name_by_link_id($id_link)
{
$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$sql = 'SELECT db_name FROM ' . $course_table . ' c
INNER JOIN ' . $tbl_grade_links . ' l
ON c.code=l.course_code
WHERE l.id=' . intval($id_link) . ' OR l.category_id=' . intval($id_link);
$res = Database::query($sql);
$my_db_name = Database::fetch_array($res, 'ASSOC');
return $my_db_name['db_name'];
}
/**
* Return the course id
* @param int
* @return String
*/
function get_course_id_by_link_id($id_link)
{
$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_grade_links = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$sql = 'SELECT c.id FROM ' . $course_table . ' c
INNER JOIN ' . $tbl_grade_links . ' l
ON c.code = l.course_code
WHERE l.id=' . intval($id_link) . ' OR l.category_id=' . intval($id_link);
$res = Database::query($sql);
$array = Database::fetch_array($res, 'ASSOC');
return $array['id'];
}
/**
* @param $type
* @return string
*/
function get_table_type_course($type)
{
global $table_evaluated;
return Database::get_course_table($table_evaluated[$type][0]);
}
/**
* @param Category $cat
* @param $users
* @param $alleval
* @param $alllinks
* @param $params
* @param null $mainCourseCategory
* @return array
*/
function get_printable_data($cat, $users, $alleval, $alllinks, $params, $mainCourseCategory = null)
{
$datagen = new FlatViewDataGenerator(
$users,
$alleval,
$alllinks,
$params,
$mainCourseCategory
);
$offset = isset($_GET['offset']) ? $_GET['offset'] : '0';
$offset = intval($offset);
// step 2: generate rows: students
$datagen->category = $cat;
$count = (($offset + 10) > $datagen->get_total_items_count()) ? ($datagen->get_total_items_count() - $offset) : LIMIT;
$header_names = $datagen->get_header_names($offset, $count, true);
$data_array = $datagen->get_data(
FlatViewDataGenerator :: FVDG_SORT_LASTNAME,
0,
null,
$offset,
$count,
true,
true
);
$result = array();
foreach ($data_array as $data) {
$result[] = array_slice($data, 1);
}
$return = array($header_names, $result);
return $return;
}
/**
* XML-parser: handle character data
*/
function character_data($parser, $data)
{
global $current_value;
$current_value = $data;
}
/**
* XML-parser: handle end of element
*/
function element_end($parser, $data)
{
global $user;
global $users;
global $current_value;
switch ($data) {
case 'Result' :
$users[] = $user;
break;
default :
$user[$data] = $current_value;
break;
}
}
/**
* XML-parser: handle start of element
*/
function element_start($parser, $data)
{
global $user;
global $current_tag;
switch ($data) {
case 'Result' :
$user = array();
break;
default :
$current_tag = $data;
}
}
function overwritescore($resid, $importscore, $eval_max)
{
$result = Result :: load($resid);
if ($importscore > $eval_max) {
header('Location: gradebook_view_result.php?selecteval=' . Security::remove_XSS($_GET['selecteval']) . '&overwritemax=');
exit;
}
$result[0]->set_score($importscore);
$result[0]->save();
unset($result);
}
/**
* Read the XML-file
* @param string $file Path to the XML-file
* @return array All user information read from the file
*/
function parse_xml_data($file)
{
global $current_tag;
global $current_value;
global $user;
global $users;
$users = array();
$parser = xml_parser_create();
xml_set_element_handler($parser, 'element_start', 'element_end');
xml_set_character_data_handler($parser, "character_data");
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);
xml_parse($parser, file_get_contents($file));
xml_parser_free($parser);
return $users;
}
/**
* register user info about certificate
* @param int The category id
* @param int The user id
* @param float The score obtained for certified
* @param Datetime The date when you obtained the certificate
* @return void()
*/
function register_user_info_about_certificate($cat_id, $user_id, $score_certificate, $date_certificate)
{
$table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
$sql = 'SELECT COUNT(*) as count FROM ' . $table_certificate . ' gc
WHERE gc.cat_id="' . intval($cat_id) . '" AND user_id="' . intval($user_id) . '" ';
$rs_exist = Database::query($sql);
$row = Database::fetch_array($rs_exist);
if ($row['count'] == 0) {
$sql = 'INSERT INTO ' . $table_certificate . ' (cat_id,user_id,score_certificate,created_at)
VALUES ("' . intval($cat_id) . '","' . intval($user_id) . '","' . Database::escape_string($score_certificate) . '","' . Database::escape_string($date_certificate) . '")';
Database::query($sql);
}
}
/**
* Get date of user certificate
* @param int $cat_id The category id
* @param int $user_id The user id
* @return Datetime The date when you obtained the certificate
*/
function get_certificate_by_user_id($cat_id, $user_id)
{
$table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
$sql = 'SELECT * FROM ' . $table_certificate . '
WHERE cat_id="' . intval($cat_id) . '" AND user_id="' . intval($user_id) . '"';
$result = Database::query($sql);
$row = Database::fetch_array($result, 'ASSOC');
return $row;
}
/**
* Get list of users certificates
* @param int $cat_id The category id
* @param array $userList Only users in this list
* @return array
*/
function get_list_users_certificates($cat_id = null, $userList = array())
{
$table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$sql = 'SELECT DISTINCT u.user_id, u.lastname, u.firstname, u.username
FROM ' . $table_user . ' u
INNER JOIN ' . $table_certificate . ' gc
ON u.user_id=gc.user_id ';
if (!is_null($cat_id) && $cat_id > 0) {
$sql.=' WHERE cat_id=' . intval($cat_id);
}
if (!empty($userList)) {
$userList = array_map('intval', $userList);
$userListCondition = implode("','", $userList);
$sql .= " AND u.user_id IN ('$userListCondition')";
}
$sql.=' ORDER BY u.firstname';
$rs = Database::query($sql);
$list_users = array();
while ($row = Database::fetch_array($rs)) {
$list_users[] = $row;
}
return $list_users;
}
/**
* Gets the certificate list by user id
* @param int $user_id The user id
* @param int $cat_id The category id
* @return array
*/
function get_list_gradebook_certificates_by_user_id($user_id, $cat_id = null)
{
$table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
$sql = 'SELECT gc.score_certificate, gc.created_at, gc.path_certificate, gc.cat_id, gc.user_id, gc.id
FROM ' . $table_certificate . ' gc
WHERE gc.user_id="' . intval($user_id) . '" ';
if (!is_null($cat_id) && $cat_id > 0) {
$sql.=' AND cat_id=' . intval($cat_id);
}
$rs = Database::query($sql);
$list_certificate = array();
while ($row = Database::fetch_array($rs)) {
$list_certificate[] = $row;
}
return $list_certificate;
}
/**
* @param $user_id
* @param $course_code
* @param bool $is_preview
* @param bool $hide_print_button
* @return array
*/
function get_user_certificate_content($user_id, $course_code, $is_preview = false, $hide_print_button = false)
{
// Generate document HTML
$content_html = DocumentManager::replace_user_info_into_html($user_id, $course_code, $is_preview);
$new_content_html = null;
$variables = null;
$contentHead = null;
if (isset($content_html['content'])) {
$new_content = explode('</head>', $content_html['content']);
$new_content_html = $new_content[1];
$contentHead = $new_content[0];
}
if (isset($content_html['variables'])) {
$variables = $content_html['variables'];
}
$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);
$path_image_in_default_course = api_get_path(WEB_CODE_PATH) . 'default_course_document';
$new_content_html = str_replace('/main/default_course_document', $path_image_in_default_course, $new_content_html);
$new_content_html = str_replace(SYS_CODE_PATH . 'img/', api_get_path(WEB_IMG_PATH), $new_content_html);
//add print header
if ($hide_print_button == false) {
$print = '<style media="print" type="text/css">#print_div {visibility:hidden;}</style>';
$print .= '<a href="javascript:window.print();" style="float:right; padding:4px;" id="print_div"><img src="' . api_get_path(WEB_CODE_PATH) . 'img/printmgr.gif" alt="' . get_lang('Print') . '" /> ' . get_lang('Print') . '</a>';
}
// Add header
$new_content_html = $contentHead. $print . '</head>' . $new_content_html;
return array(
'content' => $new_content_html,
'variables' => $variables
);
}
/**
* @param null $course_code
* @param int $gradebook_model_id
* @return mixed
*/
function create_default_course_gradebook($course_code = null, $gradebook_model_id = 0)
{
if (api_is_allowed_to_edit(true, true)) {
if (!isset($course_code) || empty($course_code)) {
$course_code = api_get_course_id();
}
$session_id = api_get_session_id();
$t = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$sql = "SELECT * FROM $t WHERE course_code = '" . Database::escape_string($course_code) . "' ";
if (!empty($session_id)) {
$sql .= " AND session_id = " . (int) $session_id;
} else {
$sql .= " AND (session_id IS NULL OR session_id = 0) ";
}
$sql .= " ORDER BY id";
$res = Database::query($sql);
if (Database::num_rows($res) < 1) {
//there is no unique category for this course+session combination,
$cat = new Category();
if (!empty($session_id)) {
$my_session_id = api_get_session_id();
$s_name = api_get_session_name($my_session_id);
$cat->set_name($course_code . ' - ' . get_lang('Session') . ' ' . $s_name);
$cat->set_session_id($session_id);
} else {
$cat->set_name($course_code);
}
$cat->set_course_code($course_code);
$cat->set_description(null);
$cat->set_user_id(api_get_user_id());
$cat->set_parent_id(0);
$default_weight_setting = api_get_setting('gradebook_default_weight');
$default_weight = isset($default_weight_setting) && !empty($default_weight_setting) ? $default_weight_setting : 100;
$cat->set_weight($default_weight);
$cat->set_grade_model_id($gradebook_model_id);
$cat->set_certificate_min_score(75);
$cat->set_visible(0);
$cat->add();
$category_id = $cat->get_id();
unset($cat);
} else {
$row = Database::fetch_array($res);
$category_id = $row['id'];
}
}
return $category_id;
}
/**
* @param FormValidator $form
*/
function load_gradebook_select_in_tool($form)
{
$course_code = api_get_course_id();
$session_id = api_get_session_id();
create_default_course_gradebook();
// Cat list
$all_categories = Category :: load(null, null, $course_code, null, null, $session_id, false);
$select_gradebook = $form->addElement('select', 'category_id', get_lang('SelectGradebook'));
if (!empty($all_categories)) {
foreach ($all_categories as $my_cat) {
if ($my_cat->get_course_code() == api_get_course_id()) {
$grade_model_id = $my_cat->get_grade_model_id();
if (empty($grade_model_id)) {
if ($my_cat->get_parent_id() == 0) {
//$default_weight = $my_cat->get_weight();
$select_gradebook->addoption(get_lang('Default'), $my_cat->get_id());
$cats_added[] = $my_cat->get_id();
} else {
$select_gradebook->addoption($my_cat->get_name(), $my_cat->get_id());
$cats_added[] = $my_cat->get_id();
}
} else {
$select_gradebook->addoption(get_lang('Select'), 0);
}
}
}
}
}
/**
* @param FlatViewTable $flatviewtable
* @param Category $cat
* @param $users
* @param $alleval
* @param $alllinks
* @param array $params
* @param null $mainCourseCategory
*/
function export_pdf_flatview($flatviewtable, $cat, $users, $alleval, $alllinks, $params = array(), $mainCourseCategory = null)
{
// Getting data
$printable_data = get_printable_data($cat[0], $users, $alleval, $alllinks, $params, $mainCourseCategory);
// HTML report creation first
$course_code = trim($cat[0]->get_course_code());
$displayscore = ScoreDisplay :: instance();
$customdisplays = $displayscore->get_custom_score_display_settings();
$total = array();
if (is_array($customdisplays) && count(($customdisplays))) {
foreach ($customdisplays as $custom) {
$total[$custom['display']] = 0;
}
$user_results = $flatviewtable->datagen->get_data_to_graph2();
foreach ($user_results as $user_result) {
$total[$user_result[count($user_result) - 1][1]]++;
}
}
$parent_id = $cat[0]->get_parent_id();
if (isset($cat[0]) && isset($parent_id)) {
if ($parent_id == 0) {
$grade_model_id = $cat[0]->get_grade_model_id();
} else {
$parent_cat = Category::load($parent_id);
$grade_model_id = $parent_cat[0]->get_grade_model_id();
}
}
$use_grade_model = true;
if (empty($grade_model_id) || $grade_model_id == -1) {
$use_grade_model = false;
}
if ($use_grade_model) {
if ($parent_id == 0) {
$title = api_strtoupper(get_lang('Average')) . '<br />' . get_lang('Detailed');
} else {
$title = api_strtoupper(get_lang('Average')) . '<br />' . $cat[0]->get_description() . ' - (' . $cat[0]->get_name() . ')';
}
} else {
if ($parent_id == 0) {
$title = api_strtoupper(get_lang('Average')) . '<br />' . get_lang('Detailed');
} else {
$title = api_strtoupper(get_lang('Average'));
}
}
$columns = count($printable_data[0]);
$has_data = is_array($printable_data[1]) && count($printable_data[1]) > 0;
$table = new HTML_Table(array('class' => 'data_table'));
$row = 0;
$column = 0;
$table->setHeaderContents($row, $column, get_lang('NumberAbbreviation'));
$column++;
foreach ($printable_data[0] as $printable_data_cell) {
$printable_data_cell = strip_tags($printable_data_cell);
$table->setHeaderContents($row, $column, $printable_data_cell);
$column++;
}
$row++;
if ($has_data) {
$counter = 1;
foreach ($printable_data[1] as &$printable_data_row) {
$column = 0;
$table->setCellContents($row, $column, $counter);
$table->updateCellAttributes($row, $column, 'align="center"');
$column++;
$counter++;
foreach ($printable_data_row as $key => &$printable_data_cell) {
$attributes = array();
$attributes['align'] = 'center';
$attributes['style'] = null;
if ($key === 'name') {
$attributes['align'] = 'left';
}
if ($key === 'total') {
$attributes['style'] = 'font-weight:bold';
}
$table->setCellContents($row, $column, $printable_data_cell);
$table->updateCellAttributes($row, $column, $attributes);
$column++;
}
$table->updateRowAttributes($row, $row % 2 ? 'class="row_even"' : 'class="row_odd"', true);
$row++;
}
} else {
$column = 0;
$table->setCellContents($row, $column, get_lang('NoResults'));
$table->updateCellAttributes($row, $column, 'colspan="' . $columns . '" align="center" class="row_odd"');
}
$params = array(
'filename' => get_lang('FlatView') . '_' . api_get_utc_datetime(),
'pdf_title' => $title,
'course_code' => $course_code,
'add_signatures' => true
);
$page_format = $params['orientation'] == 'landscape' ? 'A4-L' : 'A4';
$pdf = new PDF($page_format, $params['orientation'], $params);
$pdf->html_to_pdf_with_template($table->toHtml());
exit;
}
/**
* @param array $list_values
* @return string
*/
function score_badges($list_values)
{
$counter = 1;
$badges = array();
foreach ($list_values as $value) {
$class = 'info';
if ($counter == 1) {
$class = 'success';
}
$counter++;
$badges[] = Display::badge($value, $class);
}
return Display::badge_group($badges);
}

@ -1,173 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Various user related functions
* @author Julio Montoya <gugli100@gmail.com> adding security functions
* @package chamilo.gradebook
*/
/**
* returns users within a course given by param
* @param int $course_id
*/
function get_users_in_course($course_id)
{
$tbl_course_user = Database:: get_main_table(TABLE_MAIN_COURSE_USER);
$tbl_session_course_user = Database:: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_user = Database:: get_main_table(TABLE_MAIN_USER);
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname ASC' : ' ORDER BY lastname, firstname ASC';
$current_session = api_get_session_id();
$course_id = Database::escape_string($course_id);
if (!empty($current_session)) {
$sql = "SELECT user.user_id, user.username, lastname, firstname, official_code
FROM $tbl_session_course_user as scru, $tbl_user as user
WHERE
scru.id_user=user.user_id AND
scru.status=0 AND
scru.course_code='$course_id' AND
id_session ='$current_session'
$order_clause
";
} else {
$sql = 'SELECT user.user_id, user.username, lastname, firstname, official_code
FROM '.$tbl_course_user.' as course_rel_user, '.$tbl_user.' as user
WHERE
course_rel_user.user_id=user.user_id AND
course_rel_user.status='.STUDENT.' AND
course_rel_user.course_code = "'.$course_id.'" '.
$order_clause;
}
$result = Database::query($sql);
return get_user_array_from_sql_result($result);
}
function get_user_array_from_sql_result($result)
{
$a_students = array();
while ($user = Database::fetch_array($result)) {
if (!array_key_exists($user['user_id'], $a_students)) {
$a_current_student = array ();
$a_current_student[] = $user['user_id'];
$a_current_student[] = $user['username'];
$a_current_student[] = $user['lastname'];
$a_current_student[] = $user['firstname'];
$a_current_student[] = $user['official_code'];
$a_students['STUD'.$user['user_id']] = $a_current_student;
}
}
return $a_students;
}
function get_all_users($evals = array(), $links = array())
{
$coursecodes = array();
$users = array();
foreach ($evals as $eval) {
$coursecode = $eval->get_course_code();
// evaluation in course
if (isset($coursecode) && !empty($coursecode)) {
if (!array_key_exists($coursecode, $coursecodes)) {
$coursecodes[$coursecode] = '1';
$users = array_merge($users, get_users_in_course($coursecode));
}
} else {
// course independent evaluation
$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
$tbl_res = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
$sql = 'SELECT user.user_id, lastname, firstname, user.official_code
FROM '.$tbl_res.' as res, '.$tbl_user.' as user
WHERE
res.evaluation_id = '.intval($eval->get_id()).' AND
res.user_id = user.user_id
';
$sql .= ' ORDER BY lastname, firstname';
if (api_is_western_name_order()) {
$sql .= ' ORDER BY firstname, lastname';
}
$result = Database::query($sql);
$users = array_merge($users, get_user_array_from_sql_result($result));
}
}
foreach ($links as $link) {
// links are always in a course
$coursecode = $link->get_course_code();
if (!array_key_exists($coursecode,$coursecodes)) {
$coursecodes[$coursecode] = '1';
$users = array_merge($users, get_users_in_course($coursecode));
}
}
return $users;
}
/**
* Search students matching a given last name and/or first name
* @author Bert Steppé
*/
function find_students($mask= '')
{
// students shouldn't be here // don't search if mask empty
if (!api_is_allowed_to_edit() || empty ($mask)) {
return null;
}
$mask = Database::escape_string($mask);
$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
$tbl_cru = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$sql = 'SELECT DISTINCT user.user_id, user.lastname, user.firstname, user.email, user.official_code
FROM ' . $tbl_user . ' user';
if (!api_is_platform_admin()) {
$sql .= ', ' . $tbl_cru . ' cru';
}
$sql .= ' WHERE user.status = ' . STUDENT;
$sql .= ' AND (user.lastname LIKE '."'%" . $mask . "%'";
$sql .= ' OR user.firstname LIKE '."'%" . $mask . "%')";
if (!api_is_platform_admin()) {
$sql .= ' AND user.user_id = cru.user_id AND
cru.relation_type <> '.COURSE_RELATION_TYPE_RRHH.' AND
cru.course_code in (
SELECT course_code FROM '.$tbl_cru . '
WHERE
user_id = ' . api_get_user_id() . ' AND
status = ' . COURSEMANAGER . '
)
';
}
$sql .= ' ORDER BY lastname, firstname';
if (api_is_western_name_order()) {
$sql .= ' ORDER BY firstname, lastname';
}
$result = Database::query($sql);
$users = Database::store_result($result);
return $users;
}
/**
* Get user information from a given id
* @param int $userid The userid
* @deprecated replace this function with the api_get_user_info()
* @return array All user information as an associative array
*/
function get_user_info_from_id($userid)
{
$user_table= Database :: get_main_table(TABLE_MAIN_USER);
$sql= 'SELECT * FROM ' . $user_table . ' WHERE user_id=' . intval($userid);
$res= Database::query($sql);
$user= Database::fetch_array($res, 'ASSOC');
return $user;
}

@ -68,7 +68,7 @@ class ResultsDataGenerator
$table = array();
foreach($this->results as $result) {
$user = array();
$info = get_user_info_from_id($result->get_user_id());
$info = api_get_user_info($result->get_user_id());
$user['id'] = $result->get_user_id();
if ($pdf){
$user['username'] = $info['username'];

@ -1,29 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
// Score display types constants
define('SCORE_DIV', 1); // X / Y
define('SCORE_PERCENT', 2); // XX %
define('SCORE_DIV_PERCENT', 3); // X / Y (XX %)
define('SCORE_AVERAGE', 4); // XX %
define('SCORE_DECIMAL', 5); // 0.50 (X/Y)
define('SCORE_BAR', 6); // Uses the Display::bar_progress function
define('SCORE_SIMPLE', 7); // X
//@todo where is number 6?
define('SCORE_IGNORE_SPLIT', 8); // ??
define('SCORE_DIV_PERCENT_WITH_CUSTOM', 9); // X / Y (XX %) - Good!
define('SCORE_CUSTOM', 10); // Good!
define('SCORE_DIV_SIMPLE_WITH_CUSTOM', 11); // X - Good!
define('SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS', 12); // X - Good!
define('SCORE_BOTH', 1);
define('SCORE_ONLY_DEFAULT', 2);
define('SCORE_ONLY_CUSTOM', 3);
/**
* Class ScoreDisplay
* Class to display scores according to the settings made by the platform admin.

@ -277,7 +277,7 @@ class UserDataGenerator
&& isset ($this->coursecodecache[$coursecode])) {
return $this->coursecodecache[$coursecode];
} else {
$name = get_course_name_from_code($coursecode);
$name = CourseManager::getCourseNameFromCode($coursecode);
$this->coursecodecache[$coursecode] = $name;
return $name;
}

@ -23,10 +23,7 @@ if (isset($_GET['userid'])) {
api_not_allowed();
}
require_once 'lib/be.inc.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/userform.class.php';
block_students();
GradebookUtils::block_students();
$form = new UserForm(
UserForm :: TYPE_USER_INFO,

@ -9,13 +9,6 @@
$language_file= 'gradebook';
require_once '../inc/global.inc.php';
require_once 'lib/be.inc.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/userform.class.php';
require_once 'lib/user_data_generator.class.php';
require_once 'lib/fe/usertable.class.php';
require_once 'lib/fe/displaygradebook.php';
require_once 'lib/scoredisplay.class.php';
api_block_anonymous_users();
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
@ -24,7 +17,7 @@ $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
);
if (!$isDrhOfCourse) {
block_students();
GradebookUtils::block_students();
}
$interbreadcrumb[]= array (
'url' => $_SESSION['gradebook_dest'],
@ -58,7 +51,7 @@ if (isset ($_GET['exportpdf'])) {
foreach ($data_array as $data) {
$newarray[] = array_slice($data, 1);
}
$userinfo = get_user_info_from_id($my_user_id);
$userinfo = api_get_user_info($my_user_id);
$html .= get_lang('Results').' : '.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).' ('. api_convert_and_format_date(null, DATE_FORMAT_SHORT). ' ' . api_convert_and_format_date(null, TIME_NO_SEC_FORMAT) .')';
if ($displayscore->is_custom()) {

@ -7,7 +7,6 @@
// Language files that need to be included.
$language_file = array('admin');
require_once '../global.inc.php';
require_once api_get_path(SYS_CODE_PATH).'admin/statistics/statistics.lib.php';
api_protect_admin_script();

@ -6,9 +6,6 @@
require_once '../global.inc.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be.inc.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
api_protect_course_script(true);
$action = $_REQUEST['a'];

@ -345,6 +345,8 @@ define('USER_RELATION_TYPE_BOSS', 8);
//Gradebook link constants
//Please do not change existing values, they are used in the database !
define('GRADEBOOK_ITEM_LIMIT', 1000);
define('LINK_EXERCISE', 1);
define('LINK_DROPBOX', 2);
define('LINK_STUDENTPUBLICATION', 3);
@ -355,6 +357,30 @@ define('LINK_ATTENDANCE', 7);
define('LINK_SURVEY', 8);
define('LINK_HOTPOTATOES', 9);
// Score display types constants
define('SCORE_DIV', 1); // X / Y
define('SCORE_PERCENT', 2); // XX %
define('SCORE_DIV_PERCENT', 3); // X / Y (XX %)
define('SCORE_AVERAGE', 4); // XX %
define('SCORE_DECIMAL', 5); // 0.50 (X/Y)
define('SCORE_BAR', 6); // Uses the Display::bar_progress function
define('SCORE_SIMPLE', 7); // X
//@todo where is number 6?
define('SCORE_IGNORE_SPLIT', 8); // ??
define('SCORE_DIV_PERCENT_WITH_CUSTOM', 9); // X / Y (XX %) - Good!
define('SCORE_CUSTOM', 10); // Good!
define('SCORE_DIV_SIMPLE_WITH_CUSTOM', 11); // X - Good!
define('SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS', 12); // X - Good!
define('SCORE_BOTH', 1);
define('SCORE_ONLY_DEFAULT', 2);
define('SCORE_ONLY_CUSTOM', 3);
//From display.lib.php
define('MAX_LENGTH_BREADCRUMB', 100);

@ -289,10 +289,10 @@ class Attendance
// add link to gradebook
if ($link_to_gradebook && !empty($this->category_id)) {
$description = '';
$link_info = is_resource_in_course_gradebook($course_code,7,$last_id,$session_id);
$link_info = GradebookUtils::is_resource_in_course_gradebook($course_code,7,$last_id,$session_id);
$link_id = $link_info['id'];
if (!$link_info) {
add_resource_to_course_gradebook(
GradebookUtils::add_resource_to_course_gradebook(
$this->category_id,
$course_code,
7,
@ -346,9 +346,9 @@ class Attendance
// add link to gradebook
if ($link_to_gradebook && !empty($this->category_id)) {
$description = '';
$link_id = is_resource_in_course_gradebook($course_code, 7, $attendance_id, $session_id);
$link_id = GradebookUtils::is_resource_in_course_gradebook($course_code, 7, $attendance_id, $session_id);
if (!$link_id) {
add_resource_to_course_gradebook(
GradebookUtils::add_resource_to_course_gradebook(
$this->category_id,
$course_code,
7,

@ -139,10 +139,6 @@ class Certificate extends Model
if (empty($this->certification_user_path) && $this->force_certificate_generation == false) {
return false;
}
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be.inc.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/scoredisplay.class.php';
$params['hide_print_button'] = isset($params['hide_print_button']) ? true : false;
$my_category = Category :: load($this->certificate_data['cat_id']);
@ -175,7 +171,12 @@ class Certificate extends Model
if (is_dir($this->certification_user_path)) {
if (!empty($this->certificate_data)) {
$new_content_html = get_user_certificate_content($this->user_id, $my_category[0]->get_course_code(), false, $params['hide_print_button']);
$new_content_html = GradebookUtils::get_user_certificate_content(
$this->user_id,
$my_category[0]->get_course_code(),
false,
$params['hide_print_button']
);
if ($my_category[0]->get_id() == strval(intval($this->certificate_data['cat_id']))) {
$name = $this->certificate_data['path_certificate'];

@ -108,8 +108,7 @@ class CourseManager
if (api_get_setting('gradebook_enable_grade_model') == 'true') {
//Create gradebook_category for the new course and add a gradebook model for the course
if (isset($params['gradebook_model_id']) && !empty($params['gradebook_model_id']) && $params['gradebook_model_id'] != '-1') {
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
create_default_course_gradebook($course_info['code'], $params['gradebook_model_id']);
GradebookUtils::create_default_course_gradebook($course_info['code'], $params['gradebook_model_id']);
}
}
// If parameter defined, copy the contents from a specific
@ -5339,4 +5338,20 @@ class CourseManager
$row = Database::fetch_array($result);
return $row['count'];
}
/**
* Returns the course name from a given code
* @param string $code
*/
public static function getCourseNameFromCode($code)
{
$tbl_main_categories = Database :: get_main_table(TABLE_MAIN_COURSE);
$sql = 'SELECT title
FROM ' . $tbl_main_categories . '
WHERE code = "' . Database::escape_string($code) . '"';
$result = Database::query($sql);
if ($col = Database::fetch_array($result)) {
return $col['title'];
}
}
}

@ -21,11 +21,14 @@ class Gradebook extends Model
'user_id'
);
/**
* Constructor
*/
public function __construct()
{
$this->table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$this->table_skill = Database::get_main_table(TABLE_MAIN_SKILL);
$this->table_skill_rel_gradebook = Database::get_main_table(TABLE_MAIN_SKILL_REL_GRADEBOOK);
$this->table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$this->table_skill = Database::get_main_table(TABLE_MAIN_SKILL);
$this->table_skill_rel_gradebook = Database::get_main_table(TABLE_MAIN_SKILL_REL_GRADEBOOK);
}
/**
@ -97,8 +100,7 @@ class Gradebook extends Model
$gradebook_id,
$skill_list,
$deleteSkillNotInList = true
)
{
) {
if (!empty($skill_list)) {
//Cleaning skills
@ -169,7 +171,17 @@ class Gradebook extends Model
foreach ($skills as $skill) {
$clean_skill_list[$skill['id']] = $skill['name'];
}
$form->addElement('select', 'skill', get_lang('Skills'), $clean_skill_list, array('width'=>'450px', 'class'=>'chzn-select','multiple' => 'multiple'));
$form->addElement(
'select',
'skill',
get_lang('Skills'),
$clean_skill_list,
array(
'width' => '450px',
'class' => 'chzn-select',
'multiple' => 'multiple'
)
);
$selected_skills = self::get_skills_by_gradebook($gradebook_id);
$clean_selected_skills = array();
@ -182,6 +194,7 @@ class Gradebook extends Model
$form->addElement('style_submit_button', 'submit', get_lang('Add'), 'class="save"');
$form->setDefaults(array('skill'=>$clean_selected_skills));
return $form;
}
@ -192,11 +205,13 @@ class Gradebook extends Model
function get_skills_by_gradebook($gradebook_id)
{
$gradebook_id = intval($gradebook_id);
$sql = "SELECT skill.id, skill.name FROM {$this->table_skill} skill INNER JOIN {$this->table_skill_rel_gradebook} skill_rel_gradebook
ON skill.id = skill_rel_gradebook.skill_id
WHERE skill_rel_gradebook.gradebook_id = $gradebook_id";
$sql = "SELECT skill.id, skill.name FROM {$this->table_skill} skill
INNER JOIN {$this->table_skill_rel_gradebook} skill_rel_gradebook
ON skill.id = skill_rel_gradebook.skill_id
WHERE skill_rel_gradebook.gradebook_id = $gradebook_id";
$result = Database::query($sql);
$result = Database::store_result($result,'ASSOC');
$result = Database::store_result($result, 'ASSOC');
return $result;
}

@ -0,0 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
require_once '../../../global.inc.php';
$template = new Template();
$template->display('default/javascript/editor/ckeditor/config_js.tpl');

@ -4454,10 +4454,6 @@ class UserManager
$session_condition = " AND session_id = $session_id";
}
// Getting gradebook score.
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be.inc.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/scoredisplay.class.php';
$sql = 'SELECT * FROM '.$tbl_grade_certificate.' WHERE cat_id = (SELECT id FROM '.$tbl_grade_category.'
WHERE
course_code = "'.Database::escape_string($course_code).'" '.$session_condition.' LIMIT 1 ) AND

@ -1058,8 +1058,6 @@ class learnpath
api_get_user_id()
);
require_once '../gradebook/lib/be.inc.php';
// Delete link of gradebook tool
//$tbl_grade_link = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
/*$sql = 'SELECT gl.id FROM ' . $tbl_grade_link . ' gl WHERE gl.type="4" AND gl.ref_id="' . $id . '";';
@ -1074,10 +1072,9 @@ class learnpath
$link[0]->delete();
}
}*/
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
$link_info = is_resource_in_course_gradebook(api_get_course_id(), 4 , $id, api_get_session_id());
$link_info = GradebookUtils::is_resource_in_course_gradebook(api_get_course_id(), 4 , $id, api_get_session_id());
if ($link_info !== false) {
remove_resource_from_course_gradebook($link_info['id']);
GradebookUtils::remove_resource_from_course_gradebook($link_info['id']);
}
if (api_get_setting('search_enabled') == 'true') {

@ -25,7 +25,6 @@ $this_section = SECTION_COURSES;
/** @todo check if the starting / is needed. api_get_path probably ends with an / */
//require_once api_get_path(LIBRARY_PATH).'survey.lib.php';
require_once 'survey.lib.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
$htmlHeadXtra[] = '<script>
function advanced_parameters() {
@ -101,7 +100,7 @@ if ($_GET['action'] == 'edit' && isset($survey_id) && is_numeric($survey_id)) {
$defaults['survey_id'] = $survey_id;
$defaults['anonymous'] = $survey_data['anonymous'];
$link_info = is_resource_in_course_gradebook($course_id, $gradebook_link_type, $survey_id, $session_id);
$link_info = GradebookUtils::is_resource_in_course_gradebook($course_id, $gradebook_link_type, $survey_id, $session_id);
$gradebook_link_id = $link_info['id'];
if ($link_info) {
@ -300,7 +299,7 @@ if ($form->validate()) {
$date = time(); // TODO: Maybe time zones implementation is needed here.
$visible = 1; // 1 = visible
$link_info = is_resource_in_course_gradebook(
$link_info = GradebookUtils::is_resource_in_course_gradebook(
$course_id,
$gradebook_link_type,
$survey_id,
@ -308,7 +307,7 @@ if ($form->validate()) {
);
$gradebook_link_id = $link_info['id'];
if (!$gradebook_link_id) {
add_resource_to_course_gradebook(
GradebookUtils::add_resource_to_course_gradebook(
$course_id,
$gradebook_link_type,
$survey_id,

@ -52,7 +52,7 @@ $defaults['new_dir'] = Security::remove_XSS($title);
$there_is_a_end_date = false;
if (Gradebook::is_active()) {
$link_info = is_resource_in_course_gradebook(
$link_info = GradebookUtils::is_resource_in_course_gradebook(
api_get_course_id(),
LINK_STUDENTPUBLICATION,
$workId

@ -15,7 +15,6 @@ use ChamiloSession as Session;
*/
require_once api_get_path(SYS_CODE_PATH).'document/document.inc.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
$addDocumentToWork = api_get_configuration_value('add_document_to_work');
define('ADD_DOCUMENT_TO_WORK', $addDocumentToWork);
@ -335,7 +334,7 @@ function getWorkList($id, $my_folder_data, $add_in_where_query = null)
$group_id = api_get_group_id();
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$linkInfo = is_resource_in_course_gradebook(
$linkInfo = GradebookUtils::is_resource_in_course_gradebook(
api_get_course_id(),
3,
$id,
@ -695,12 +694,11 @@ function display_student_publications_list(
$row[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&origin='.$origin.'&gradebook='.$gradebook.'">'.$icon.'</a>';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
$link_info = is_resource_in_course_gradebook(api_get_course_id(), 3, $workId, api_get_session_id());
$link_info = GradebookUtils::is_resource_in_course_gradebook(api_get_course_id(), 3, $workId, api_get_session_id());
$link_id = $link_info['id'];
$count = 0;
if ($link_info !== false) {
$gradebook_data = get_resource_from_course_gradebook($link_id);
$gradebook_data = GradebookUtils::get_resource_from_course_gradebook($link_id);
$count = $gradebook_data['weight'];
}
if ($count > 0) {
@ -1188,7 +1186,7 @@ function deleteDirWork($id)
WHERE c_id = $course_id AND publication_id = $id";
Database::query($sql);
$link_info = is_resource_in_course_gradebook(
$link_info = GradebookUtils::is_resource_in_course_gradebook(
api_get_course_id(),
3,
$id,
@ -1196,7 +1194,7 @@ function deleteDirWork($id)
);
$link_id = $link_info['id'];
if ($link_info !== false) {
remove_resource_from_course_gradebook($link_id);
GradebookUtils::remove_resource_from_course_gradebook($link_id);
}
return true;
}
@ -4255,12 +4253,7 @@ function updatePublicationAssignment($workId, $params, $courseInfo, $groupId)
if (!empty($params['category_id'])) {
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/gradebookitem.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/evaluation.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/abstractlink.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
$link_info = is_resource_in_course_gradebook(
$link_info = GradebookUtils::is_resource_in_course_gradebook(
$courseInfo['code'],
LINK_STUDENTPUBLICATION,
$workId,
@ -4274,7 +4267,7 @@ function updatePublicationAssignment($workId, $params, $courseInfo, $groupId)
if (isset($params['make_calification']) && $params['make_calification'] == 1) {
if (empty($linkId)) {
add_resource_to_course_gradebook(
GradebookUtils::add_resource_to_course_gradebook(
$params['category_id'],
$courseInfo['code'],
LINK_STUDENTPUBLICATION,
@ -4287,7 +4280,7 @@ function updatePublicationAssignment($workId, $params, $courseInfo, $groupId)
api_get_session_id()
);
} else {
update_resource_from_course_gradebook(
GradebookUtils::update_resource_from_course_gradebook(
$linkId,
$courseInfo['code'],
$params['weight']
@ -4295,7 +4288,7 @@ function updatePublicationAssignment($workId, $params, $courseInfo, $groupId)
}
} else {
// Delete everything of the gradebook for this $linkId
remove_resource_from_course_gradebook($linkId);
GradebookUtils::remove_resource_from_course_gradebook($linkId);
}
}
}
@ -4460,7 +4453,7 @@ function getFormWork($form, $defaults = array())
}
// Loading Gradebook select
load_gradebook_select_in_tool($form);
GradebookUtils::load_gradebook_select_in_tool($form);
$form->addElement('text', 'weight', get_lang('WeightInTheGradebook'));
$form->addElement('html', '</div>');

@ -11,12 +11,10 @@
* required files for getting data
*/
require_once api_get_path(LIBRARY_PATH) . 'attendance.lib.php';
require_once api_get_path(SYS_CODE_PATH) . 'gradebook/lib/be.inc.php';
/**
* This class is used like controller for this course block plugin,
* the class name must be registered inside path.info file (e.g: controller = "BlockDiario"), so dashboard controller will be instantiate it
* the class name must be registered inside path.info file
* (e.g: controller = "BlockDiario"), so dashboard controller will be instantiate it
* @package chamilo.dashboard
*/
class BlockDaily extends Block

@ -1,12 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/gradebookitem.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/evaluation.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/result.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/linkfactory.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/flatview_data_generator.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/category.class.php';
use CpChart\Classes\pData as pData;
use CpChart\Classes\pImage as pImage;
@ -136,7 +129,7 @@ class BlockEvaluationGraph extends Block
if (isset($cats) && isset($cats[0])) {
$alleval = $cats[0]->get_evaluations(null, true, $course_code);
$alllinks = $cats[0]->get_links(null, true);
$users = get_all_users($alleval, $alllinks);
$users = GradebookUtils::get_all_users($alleval, $alllinks);
$datagen = new FlatViewDataGenerator ($users, $alleval, $alllinks);
$evaluation_sumary = $datagen->get_evaluation_sumary_results();
if (!empty($evaluation_sumary)) {
@ -314,7 +307,7 @@ class BlockEvaluationGraph extends Block
if (isset($cats) && isset($cats[0])) {
$alleval = $cats[0]->get_evaluations(null, true, $course_code);
$alllinks = $cats[0]->get_links(null, true);
$users = get_all_users($alleval, $alllinks);
$users = GradebookUtils::get_all_users($alleval, $alllinks);
$datagen = new FlatViewDataGenerator ($users, $alleval, $alllinks);
$evaluation_sumary = $datagen->get_evaluation_sumary_results();
if (!empty($evaluation_sumary)) {

@ -10,7 +10,6 @@
/**
* required files for getting data
*/
require_once api_get_path(SYS_CODE_PATH).'admin/statistics/statistics.lib.php';
/**
* This class is used like controller for this global info block plugin

Loading…
Cancel
Save