update merge

1.9.x
Alex 12 years ago
parent 9a987ff8fd
commit 0a6ba7cb8b
  1. 1
      main/admin/calendar.lib.php
  2. 5
      main/admin/course_category.php
  3. 27
      main/admin/session_list.php
  4. 22
      main/announcements/announcements.inc.php
  5. 28
      main/announcements/announcements.php
  6. 86
      main/announcements/resources/js/main.js
  7. 52
      main/calendar/agenda.inc.php
  8. 4
      main/calendar/agenda.php
  9. 80
      main/coursecopy/classes/CourseRestorer.class.php
  10. 91
      main/css/cool_blue/chat.css
  11. 3457
      main/css/cool_blue/default.css
  12. 126
      main/css/cool_blue/frames.css
  13. BIN
      main/css/cool_blue/images/bar_1.gif
  14. BIN
      main/css/cool_blue/images/bar_1m.gif
  15. BIN
      main/css/cool_blue/images/bar_1r.gif
  16. BIN
      main/css/cool_blue/images/bar_1u.gif
  17. BIN
      main/css/cool_blue/images/button_back.jpg
  18. BIN
      main/css/cool_blue/images/button_plus.gif
  19. 6
      main/css/cool_blue/images/index.html
  20. BIN
      main/css/cool_blue/images/shadow.gif
  21. BIN
      main/css/cool_blue/images/tab-left.png
  22. BIN
      main/css/cool_blue/images/tab-repeat.png
  23. BIN
      main/css/cool_blue/images/tab-right.png
  24. BIN
      main/css/cool_blue/images/tab.png
  25. 13
      main/css/cool_blue/learnpath.css
  26. 91
      main/css/cool_blue/online.css
  27. 36
      main/css/cool_blue/print.css
  28. 396
      main/css/cool_blue/scorm.css
  29. 2
      main/css/cool_blue/scormfs.css
  30. 0
      main/css/cool_blue/screen.css
  31. 4
      main/document/document.inc.php
  32. 114
      main/document/downloadfolder.inc.php
  33. 17
      main/exercice/exercise.lib.php
  34. 24
      main/exercice/live_stats.php
  35. 6
      main/exercice/question.class.php
  36. 59
      main/exercice/stats.php
  37. 59
      main/forum/forumfunction.inc.php
  38. 8
      main/forum/iframe_thread.php
  39. 2
      main/forum/newthread.php
  40. 1
      main/forum/reply.php
  41. 11
      main/forum/viewforum.php
  42. 3
      main/forum/viewforumcategory.php
  43. 6
      main/forum/viewthread.php
  44. 46
      main/gradebook/index.php
  45. 225
      main/gradebook/lib/fe/displaygradebook.php
  46. 338
      main/gradebook/lib/fe/gradebooktable.class.php
  47. 6
      main/gradebook/lib/gradebook_functions.inc.php
  48. 188
      main/inc/ajax/model.ajax.php
  49. 4
      main/inc/lib/course.lib.php
  50. 2
      main/inc/lib/display.lib.php
  51. 4
      main/inc/lib/gradebook.lib.php
  52. 41
      main/inc/lib/groupmanager.lib.php
  53. 1032
      main/inc/lib/javascript/jqgrid/js/jquery.jqGrid.min.js
  54. 11
      main/inc/lib/main_api.lib.php
  55. 19
      main/inc/lib/pear/HTML/QuickForm.php
  56. 45
      main/inc/lib/pear/HTML/QuickForm/Rule/CompareDate.php
  57. 72
      main/inc/lib/pear/HTML/QuickForm/Rule/Required.php
  58. 20
      main/inc/lib/pear/HTML/QuickForm/element.php
  59. 10
      main/inc/lib/result_set.class.php
  60. 83
      main/inc/lib/sessionmanager.lib.php
  61. 1
      main/lang/english/help.inc.php
  62. 8
      main/lang/english/tracking.inc.php
  63. 4
      main/lang/english/trad4all.inc.php
  64. 4
      main/lang/french/admin.inc.php
  65. 20
      main/lang/french/tracking.inc.php
  66. 8
      main/lang/french/trad4all.inc.php
  67. 1
      main/lang/french/work.inc.php
  68. 187
      main/social/profile.php
  69. 57
      main/template/default/work/view.tpl
  70. 7
      main/wiki/index.php
  71. 496
      main/wiki/wiki.inc.php
  72. 68
      main/work/download.php
  73. 26
      main/work/edit.php
  74. 46
      main/work/edit_work.php
  75. 52
      main/work/student_work.php
  76. 3
      main/work/upload.php
  77. 2
      main/work/upload_from_template.php
  78. 666
      main/work/work.lib.php
  79. 15
      main/work/work.php
  80. 4
      main/work/work_list.php
  81. 22
      main/work/work_list_all.php

@ -2739,6 +2739,7 @@ function is_repeated_event($id,$course=null)
}
return false;
}
/**
* Adds x weeks to a UNIX timestamp
* @param int The timestamp

@ -109,9 +109,14 @@ if ($action == 'add' || $action == 'edit') {
$form->addElement('button', 'submit', $text);
$form->display();
} elseif (api_get_multiple_access_url() && api_get_current_access_url_id() != 1) {
// If multiple URLs and not main URL, prevent edition and inform user
Display::display_warning_message(get_lang('CourseCategoriesAreGlobal'));
}
} else {
// If multiple URLs and not main URL, prevent deletion and inform user
if ($action == 'delete' && api_get_multiple_access_url() && api_get_current_access_url_id() != 1) {
Display::display_warning_message(get_lang('CourseCategoriesAreGlobal'));
}
echo '<div class="actions">';
$link = null;
if (!empty($parentInfo)) {

@ -18,8 +18,8 @@ api_protect_admin_script(true);
//Add the JS needed to use the jqgrid
$htmlHeadXtra[] = api_get_jqgrid_js();
$action = $_REQUEST['action'];
$idChecked = $_REQUEST['idChecked'];
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
$idChecked = isset($_REQUEST['idChecked']) ? $_REQUEST['idChecked'] : null;
if ($action == 'delete') {
SessionManager::delete_session($idChecked);
@ -78,27 +78,37 @@ if (!empty($courseId)) {
if (isset($_REQUEST['keyword'])) {
//Begin with see the searchOper param
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions&_search=true&rows=20&page=1&sidx=&sord=asc&filters=&searchField=name&searchString='.Security::remove_XSS($_REQUEST['keyword']).'&searchOper=bw';
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions&_force_search=true&rows=20&page=1&sidx=&sord=asc&filters=&searchField=s.name&searchString='.Security::remove_XSS($_REQUEST['keyword']).'&searchOper=bw';
}
if (isset($_REQUEST['id_category'])) {
$sessionCategory = SessionManager::get_session_category($_REQUEST['id_category']);
if (!empty($sessionCategory)) {
//Begin with see the searchOper param
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions&_search=true&rows=20&page=1&sidx=&sord=asc&filters=&searchField=category_name&searchString='.Security::remove_XSS($sessionCategory['name']).'&searchOper=bw';
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions&_force_search=true&rows=20&page=1&sidx=&sord=asc&filters=&searchField=sc.name&searchString='.Security::remove_XSS($sessionCategory['name']).'&searchOper=bw';
}
}
//The order is important you need to check the the $column variable in the model.ajax.php file
$columns = array(get_lang('Name'), get_lang('NumberOfCourses'), get_lang('NumberOfUsers'), get_lang('SessionCategoryName'),
get_lang('StartDate'), get_lang('EndDate'), get_lang('Coach'), get_lang('Status'), get_lang('Visibility'), get_lang('Actions'));
$columns = array(
get_lang('Name'),
get_lang('NumberOfCourses'),
get_lang('NumberOfUsers'),
get_lang('SessionCategoryName'),
get_lang('StartDate'),
get_lang('EndDate'),
get_lang('Coach'),
get_lang('Status'),
get_lang('Visibility'),
get_lang('Actions')
);
//Column config
$column_model = array(
array('name'=>'name', 'index'=>'s.name', 'width'=>'160', 'align'=>'left', 'search' => 'true', 'wrap_cell' => "true"),
array('name'=>'nbr_courses', 'index'=>'nbr_courses', 'width'=>'30', 'align'=>'left', 'search' => 'true'),
array('name'=>'nbr_users', 'index'=>'nbr_users', 'width'=>'30', 'align'=>'left', 'search' => 'true'),
array('name'=>'category_name', 'index'=>'category_name', 'width'=>'70', 'align'=>'left', 'search' => 'true'),
array('name'=>'category_name', 'index'=>'sc.name', 'width'=>'70', 'align'=>'left', 'search' => 'true'),
array('name'=>'date_start', 'index'=>'s.date_start', 'width'=>'40', 'align'=>'left', 'search' => 'true'),
array('name'=>'date_end', 'index'=>'s.date_end', 'width'=>'40', 'align'=>'left', 'search' => 'true'),
array('name'=>'coach_name', 'index'=>'coach_name', 'width'=>'80', 'align'=>'left', 'search' => 'false'),
@ -187,8 +197,7 @@ $(function() {
},buttonicon:'ui-icon-document'})
*/
//Adding search options
// Adding search options
var options = {
'stringResult': true,
'autosearch' : true,

@ -572,20 +572,27 @@ class AnnouncementManager
$to_already_selected = array();
}
echo "<table id=\"recipient_list\" style=\"display: none;\">";
echo "<table id=\"recipient_list\" >";
echo '<tr>';
echo '<td>';
echo '<label><input type="checkbox" id="send_to_all_users">'.get_lang('SendToAllUsers') . "</label>";
echo "</td>";
echo '</tr>';
echo '<tr>';
// the form containing all the groups and all the users of the course
echo '<td>';
echo "<strong>" . get_lang('Users') . "</strong><br />";
self::construct_not_selected_select_form($group_list, $user_list, $to_already_selected);
echo "</td>";
// the buttons for adding or removing groups/users
echo '<td valign="middle">';
echo '<button class="arrowr" type="button" onClick="javascript: move(this.form.elements[0], this.form.elements[3])" onClick="javascript: move(this.form.elements[0], this.form.elements[3])"></button>';
echo '<button class="arrowr" type="button" onClick="javascript: move(this.form.elements[1], this.form.elements[4])" onClick="javascript: move(this.form.elements[1], this.form.elements[4])"></button>';
echo '<br /> <br />';
echo '<button class="arrowl" type="button" onClick="javascript: move(this.form.elements[3], this.form.elements[0])" onClick="javascript: move(this.form.elements[3], this.form.elements[0])"></button>';
echo '<button class="arrowl" type="button" onClick="javascript: move(this.form.elements[4], this.form.elements[1])" onClick="javascript: move(this.form.elements[4], this.form.elements[1])"></button>';
echo "</td>";
echo "<td>";
@ -603,10 +610,10 @@ class AnnouncementManager
*/
public static function show_to_form_group($group_id)
{
echo "<table id=\"recipient_list\" style=\"display: none;\">";
echo "<table id=\"recipient_list\" >";
echo "<tr>";
echo "<td>";
echo "<select name=\"not_selected_form[]\" size=5 style=\"width:200px\" multiple>";
echo "<select id=\"not_selected_form\" name=\"not_selected_form[]\" size=5 style=\"width:200px\" multiple>";
$group_users = GroupManager::getStudentsAndTutors($group_id);
foreach ($group_users as $user) {
echo '<option value="' . $user['user_id'] . '" title="' . sprintf(get_lang('LoginX'), $user['username']) . '" >' .
@ -637,7 +644,7 @@ class AnnouncementManager
*/
public static function construct_not_selected_select_form($group_list = null, $user_list = null, $to_already_selected)
{
echo '<select name="not_selected_form[]" size="7" class="span4" multiple>';
echo '<select id="not_selected_form" name="not_selected_form[]" size="7" class="span4" multiple>';
// adding the groups to the select form
if ($group_list) {
foreach ($group_list as $this_group) {
@ -658,7 +665,8 @@ class AnnouncementManager
if ($user_list) {
foreach ($user_list as $this_user) {
if (is_array($to_already_selected)) {
if (!in_array("USER:" . $this_user['user_id'], $to_already_selected)) { // $to_already_selected is the array containing the users (and groups) that are already selected
if (!in_array("USER:" . $this_user['user_id'], $to_already_selected)) {
// $to_already_selected is the array containing the users (and groups) that are already selected
echo "<option value=\"USER:" . $this_user['user_id'] . "\" title='" . sprintf(get_lang('LoginX'), $this_user['username']) . "'>",
"", api_get_person_name($this_user['firstname'], $this_user['lastname']),
"</option>";

@ -53,7 +53,6 @@ $length = '36';
// Database Table Definitions
$tbl_courses = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_sessions = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
$tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
@ -73,8 +72,8 @@ $course_id = api_get_course_int_id();
event_access_tool(TOOL_ANNOUNCEMENT);
/* POST TO */
$safe_emailTitle = $_POST['emailTitle'];
$safe_newContent = $_POST['newContent'];
$safe_emailTitle = isset($_POST['emailTitle']) ? $_POST['emailTitle'] : null;
$safe_newContent = isset($_POST['newContent']) ? $_POST['newContent'] : null;
$content_to_modify = $title_to_modify = '';
@ -98,10 +97,10 @@ if (!empty($_POST['To'])) {
*/
$setting_select_groupusers = true;
if (empty($_POST['To']) and !$_SESSION['select_groupusers']) {
if (empty($_POST['To']) and !isset($_SESSION['select_groupusers'])) {
$_SESSION['select_groupusers'] = "hide";
}
$select_groupusers_status=$_SESSION['select_groupusers'];
$select_groupusers_status = isset($_SESSION['select_groupusers']) ? $_SESSION['select_groupusers']:null;
if (!empty($_POST['To']) and ($select_groupusers_status=="hide")) {
$_SESSION['select_groupusers'] = "show";
}
@ -168,7 +167,7 @@ if (!empty($group_id)) {
$interbreadcrumb[] = array ("url"=>"../group/group_space.php?gidReq=".$group_id, "name"=> get_lang('GroupSpace').' '.$group_properties['name']);
}
$announcement_id = intval($_GET['id']);
$announcement_id = isset($_GET['id']) ? intval($_GET['id']) : null;
$message = null;
if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') {
@ -557,8 +556,10 @@ if (api_is_allowed_to_edit() && $announcement_number > 1) {
if (api_get_group_id() == 0 ) {
if (!$show_actions)
echo '<div class="actions">';
if (!in_array($_GET['action'], array('add', 'modify','view')))
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=delete_all\" onclick=\"javascript:if(!confirm('".get_lang("ConfirmYourChoice")."')) return false;\">".Display::return_icon('delete_announce.png',get_lang('AnnouncementDeleteAll'),'',ICON_SIZE_MEDIUM)."</a>";
if (!isset($_GET['action'])) {
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=delete_all\" onclick=\"javascript:if(!confirm('".get_lang("ConfirmYourChoice")."')) return false;\">".
Display::return_icon('delete_announce.png',get_lang('AnnouncementDeleteAll'),'',ICON_SIZE_MEDIUM)."</a>";
}
} // if announcementNumber > 1
}
@ -605,12 +606,11 @@ if ($display_form) {
if (empty($group_id)) {
echo ' <div class="control-group">
<label class="control-label">'.
Display::return_icon('group.png', get_lang('ModifyRecipientList'), array ('align' => 'absmiddle'),ICON_SIZE_SMALL).'<a href="#" onclick="toggle_sendto();">'.get_lang('SentTo').'</a>
Display::return_icon('group.png', get_lang('ModifyRecipientList'), array ('align' => 'absmiddle'),ICON_SIZE_SMALL).' '.get_lang('SentTo').'
</label>
<div class="controls">';
if (isset($_GET['id']) && is_array($to)) {
echo '<span id="recipient_overview">&nbsp;</span>';
} elseif (isset($_GET['remind_inactive'])) {
if (isset($_GET['remind_inactive'])) {
$email_ann = '1';
$_SESSION['select_groupusers']="show";
$content_to_modify = sprintf(get_lang('RemindInactiveLearnersMailContent'), api_get_setting('siteName'), 7);
@ -640,7 +640,7 @@ if ($display_form) {
$content_to_modify = get_lang('YourAccountIsActiveYouCanLoginAndCheckYourCourses');
}
} else {
echo '<span id="recipient_overview">' . get_lang('Everybody') . '</span>';
//echo '<span id="recipient_overview">' . get_lang('Everybody') . '</span>';
}
AnnouncementManager::show_to_form($to);
echo ' </div>
@ -739,7 +739,7 @@ if ($display_form) {
if (empty($group_id)) {
echo '<input type="hidden" name="submitAnnouncement" value="OK">';
echo '<input type="hidden" name="sec_token" value="'.$stok.'" />';
echo '<button class="btn save" type="button" value="'.' '.get_lang('Send').' '.'" onclick="selectAll(this.form.elements[3],true)" >'.get_lang('ButtonPublishAnnouncement').'</button><br /><br />';
echo '<button class="btn save" type="button" value="'.' '.get_lang('Send').' '.'" onclick="selectAll(this.form.elements[4],true)" >'.get_lang('ButtonPublishAnnouncement').'</button><br /><br />';
} else {
echo '<input type="hidden" name="submitAnnouncement" value="OK">';
echo '<input type="hidden" name="sec_token" value="'.$stok.'" />';

@ -8,6 +8,35 @@ $(function() {
$('.resizable-vertical').resizable({
handles: "n, s"
});
$('#send_to_all_users').click(function() {
var checked = $(this).attr('checked');
if (!checked) {
$('#selectedform option').each(function() {
var val = $(this).val();
var text = $(this).text();
if (val.substr(0 , 4) == 'USER') {
$('#selectedform').find('[value="'+val+'"]').remove();
$('#not_selected_form').append(new Option(text, val));
}
});
}
$('#not_selected_form option').each(function() {
var val = $(this).val();
var text = $(this).text();
if (val.substr(0 , 4) == 'USER') {
if (checked) {
// Add
$('#selectedform').append(new Option(text, val));
$('#not_selected_form').find('[value="'+val+'"]').remove();
}
}
});
});
});
var Announcement = {};
@ -66,7 +95,7 @@ function move_selected_option(from, to){
}
function update_hidden_field(name){
var select = $('#' + name + '_selected');
var options = $("option", select)
//update hidden field
@ -77,7 +106,7 @@ function update_hidden_field(name){
keys.push(option.val());
});
keys = keys.join(',');
var hidden = $('#' + name);
hidden.val(keys);
}
@ -96,9 +125,9 @@ function toggle_list_selector(name)
list.hide();
overview.show();
}
var select = $('#' + name + '_selected');
//update overview
var content = [];
var options = $("option", select)
@ -107,16 +136,17 @@ function toggle_list_selector(name)
option = $(option);
content.push(option.text());
});
content = content.join(', ');
content = (content == '') ? lang.Everybody : content;
overview.text(content);
}
function toggle_sendto()
{
var list = $('#recipient_list');
/*var list = $('#recipient_list');
var overview = $('#recipient_overview');
if(list.css('display') == 'none'){
list.show();
@ -127,11 +157,11 @@ function toggle_sendto()
list.hide();
overview.show();
}
var selected = $('#selectedform');
var content = list_box_content(selected[0])
content = (content == '') ? lang.Everybody : content;
overview.text(content);
overview.text(content);*/
}
function list_box_content(box)
@ -158,7 +188,7 @@ function move(fbox, tbox) {
var arrFboxIsDisabled = []; // if this from checkbox after move is disabled or not
var arrTboxIsDisabled = []; // if this to checkbox after move is disabled or not
var key_value = ""; // key for arrays arrFboxIsDisabled and arrTboxIsDisabled, use associative array key_value is the value of the array element (eg : GROUP:1 or USER:24)
var i;
for (i = 0; i < tbox.options.length; i++) {
arrLookup[tbox.options[i].text] = tbox.options[i].value;
@ -178,8 +208,8 @@ function move(fbox, tbox) {
{
arrTbox[tLength] = fbox.options[i].text;
tLength++;
}
else
}
else
{
arrFbox[fLength] = fbox.options[i].text;
key_value = fbox.options[i].value;
@ -187,14 +217,14 @@ function move(fbox, tbox) {
fLength++;
}
}
arrFbox.sort();
arrTbox.sort();
var arrFboxGroup = [];
var arrFboxUser = [];
var prefix_x;
var x;
for (x = 0; x < arrFbox.length; x++) {
prefix_x = arrFbox[x].substring(0, 2);
@ -204,15 +234,15 @@ function move(fbox, tbox) {
arrFboxUser.push(arrFbox[x]);
}
}
arrFboxGroup.sort();
arrFboxUser.sort();
arrFbox = arrFboxGroup.concat(arrFboxUser);
var arrTboxGroup = [];
var arrTboxUser = [];
var prefix_y;
var y;
for (y = 0; y < arrTbox.length; y++) {
prefix_y = arrTbox[y].substring(0, 2);
@ -222,16 +252,16 @@ function move(fbox, tbox) {
arrTboxUser.push(arrTbox[y]);
}
}
arrTboxGroup.sort();
arrTboxUser.sort();
arrTbox = arrTboxGroup.concat(arrTboxUser);
fbox.length = 0;
tbox.length = 0;
var c;
for (c = 0; c < arrFbox.length; c++)
for (c = 0; c < arrFbox.length; c++)
{
var no = new Option();
no.value = arrLookup[arrFbox[c]];
@ -242,7 +272,7 @@ function move(fbox, tbox) {
}
fbox[c] = no;
}
for (c = 0; c < arrTbox.length; c++)
for (c = 0; c < arrTbox.length; c++)
{
var no = new Option();
no.value = arrLookup[arrTbox[c]];
@ -250,12 +280,12 @@ function move(fbox, tbox) {
key_value = no.value;
if (arrTboxIsDisabled[key_value]) {
no.disabled = "disabled";
}
}
tbox[c] = no;
}
}
function validate()
function validate()
{
"use strict";
var f = document.new_calendar_item;
@ -266,7 +296,7 @@ function validate()
function selectAll(cbList, bSelect, showwarning) {
"use strict";
if (document.getElementById('emailTitle').value == '') {
document.getElementById('msg_error').innerHTML = lang.FieldRequired;
document.getElementById('msg_error').style.display = 'block';
@ -286,11 +316,11 @@ function selectAll(cbList, bSelect, showwarning) {
}
}
function reverseAll(cbList)
function reverseAll(cbList)
{
"use strict";
var i;
for (i = 0; i < cbList.length; i++)
for (i = 0; i < cbList.length; i++)
{
cbList[i].checked = !(cbList[i].checked);
cbList[i].selected = !(cbList[i].selected);
@ -308,4 +338,4 @@ function plus_attachment() {
document.getElementById('plus').innerHTML = '&nbsp;<img style="vertical-align:middle;" src="../img/div_show.gif" alt="" />&nbsp;' + lang.AddAnAttachment;
}
}
// End
// End

@ -1518,8 +1518,11 @@ function load_edit_users($tool, $id)
$TABLE_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
$course_id = api_get_course_int_id();
$sql = "SELECT * FROM $TABLE_ITEM_PROPERTY WHERE c_id = $course_id AND tool='$tool' AND ref='$id'";
$result = Database::query($sql) or die(Database::error());
$sql = "SELECT * FROM $TABLE_ITEM_PROPERTY
WHERE c_id = $course_id AND tool='$tool' AND ref='$id'";
$result = Database::query($sql);
$to = array();
while ($row = Database::fetch_array($result)) {
$to_group = $row['to_group_id'];
switch ($to_group) {
@ -1710,33 +1713,6 @@ function store_edited_agenda_item($event_id, $id_attach, $file_comment)
} else {
edit_agenda_attachment_file($file_comment, $id, $id_attach);
}
// step 2: editing the item_property table (=delete all and add the new destination users/groups)
/*if ($edit_result = true) {
// 2.a. delete everything for the users
$sql_delete = "DELETE FROM ".$TABLE_ITEM_PROPERTY." WHERE c_id = $course_id AND ref='$id' AND tool='".TOOL_CALENDAR_EVENT."'";
$result = Database::query($sql_delete) or die(Database::error());
// 2.b. storing the new users/groups
if (!is_null($to)) { // !is_null($to): when no user is selected we send it to everyone
$send_to = separate_users_groups($to);
// storing the selected groups
if (is_array($send_to['groups'])) {
foreach ($send_to['groups'] as $group) {
api_item_property_update($_course, TOOL_CALENDAR_EVENT, $id, "AgendaModified", api_get_user_id(), $group, '', $start_date, $end_date);
}
}
// storing the selected users
if (is_array($send_to['users'])) {
foreach ($send_to['users'] as $user) {
api_item_property_update($_course, TOOL_CALENDAR_EVENT, $id, "AgendaModified", api_get_user_id(), '', $user, $start_date, $end_date);
}
}
} else {
// the message is sent to everyone, so we set the group to 0
api_item_property_update($_course, TOOL_CALENDAR_EVENT, $id, "AgendaModified", api_get_user_id(), '', '', $start_date, $end_date);
}
}*/
// step 3: update the attachments (=delete all and add those in the session
update_added_resources("Agenda", $id);
@ -1797,11 +1773,9 @@ function delete_agenda_item($id)
}
}
$sql_del = "DELETE FROM $t_agenda_r WHERE cal_id = $id";
$res_del = Database::query($sql_del);
Database::query($sql_del);
}
//$sql = "DELETE FROM ".$TABLEAGENDA." WHERE id='$id'";
//$sql= "UPDATE ".$TABLE_ITEM_PROPERTY." SET visibility='2' WHERE tool='Agenda' and ref='$id'";
//$result = Database::query($sql) or die (Database::error());
api_item_property_update($_course, TOOL_CALENDAR_EVENT, $id, 'delete', api_get_user_id());
// delete the resources that were added to this agenda item
@ -1813,8 +1787,8 @@ function delete_agenda_item($id)
// displaying the result message in the yellow box
Display::display_confirmation_message(get_lang("AgendaDeleteSuccess"));
} // if (isset($id)&&$id&&isset($action)&&$action=="delete")
} // if ($is_allowed_to_edit)
}
}
}
/**
@ -2249,7 +2223,7 @@ function show_add_form($id = '', $type = null)
global $MonthsLong;
$htmlHeadXtra[] = to_javascript();
// the default values for the forms
if ($_GET['originalresource'] !== 'no') {
if (!isset($_GET['originalresource'])) {
$day = date('d');
$month = date('m');
$year = date('Y');
@ -2262,12 +2236,15 @@ function show_add_form($id = '', $type = null)
$end_hours = 17;
$end_minutes = '00';
$repeat = false;
$content = null;
$title = null;
} else {
// we are coming from the resource linker so there might already have been some information in the form.
// When we clicked on the button to add resources we stored every form information into a session and now we
// are doing the opposite thing: getting the information out of the session and putting it into variables to
// display it in the forms.
$form_elements = $_SESSION['formelements'];
$form_elements = isset($_SESSION['formelements']) ? $_SESSION['formelements'] : null;
$day = $form_elements['day'];
$month = $form_elements['month'];
$year = $form_elements['year'];
@ -2281,7 +2258,6 @@ function show_add_form($id = '', $type = null)
$title = $form_elements['title'];
$content = $form_elements['content'];
$id = $form_elements['id'];
$to = $form_elements['to'];
$repeat = $form_elements['repeat'];
}

@ -235,9 +235,9 @@ if (api_is_allowed_to_edit(false, true) OR
$event_start = (int) $_POST['fyear'].'-'.(int) $_POST['fmonth'].'-'.(int) $_POST['fday'].' '.(int) $_POST['fhour'].':'.(int) $_POST['fminute'].':00';
$event_stop = (int) $_POST['end_fyear'].'-'.(int) $_POST['end_fmonth'].'-'.(int) $_POST['end_fday'].' '.(int) $_POST['end_fhour'].':'.(int) $_POST['end_fminute'].':00';
$safe_title = Security::remove_XSS($_POST['title']);
$safe_file_comment = Security::remove_XSS($_POST['file_comment']);
$safe_file_comment = isset($_POST['file_comment']) ? Security::remove_XSS($_POST['file_comment']) : null;
if ($_POST['empty_end_date'] == 'on') {
if (isset($_POST['empty_end_date']) && $_POST['empty_end_date'] == 'on') {
$event_stop = '0000-00-00 00:00:00';
}
$agenda->type = 'course';

@ -2108,22 +2108,88 @@ class CourseRestorer
// check resources inside html from fckeditor tool and copy correct urls into recipient course
$obj->params['description'] = DocumentManager::replace_urls_inside_content_html_from_copy_course($obj->params['description'], $this->course->code, $this->course->destination_path, $this->course->backup_path, $this->course->info['path']);
$id_work = $obj->params['id'];
$obj->params['id'] = null;
$obj->params['c_id'] = $this->destination_course_id;
$last_id = Database::insert($table_work, $obj->params);
// re-create dir
// @todo check security against injection of dir in crafted course backup here!
$path = $obj->params['url'];
$path = '/'.str_replace('/','',substr($path,1));
$destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/work'.$path;
$r = @mkdir($destination_path, $perm);
if ($r === false) {
error_log('Failed creating directory '.$destination_path.' in course restore for work tool');
}
if (!file_exists($destination_path) && is_dir($destination_path)) {
$r = @mkdir($destination_path, $perm);
if ($r === false) {
error_log('Failed creating directory '.$destination_path.' in course restore for work tool');
}
if (is_numeric($last_id)) {
api_item_property_update($this->destination_course_info, 'work', $last_id,"DirectoryCreated", api_get_user_id());
$last_id = Database::insert($table_work, $obj->params);
if (is_numeric($last_id)) {
$sql = 'SELECT *
FROM '.$table_work_assignment.'
WHERE c_id = '.$this->course_origin_id.' AND
publication_id = '.$id_work;
$result = Database::query($sql);
$cant = Database::num_rows($result);
if ($cant > 0) {
$row = Database::fetch_assoc($result);
$expires_date = $row['expires_on'];
$end_date = $row['ends_on'];
$add_to_calendar = $row['add_to_calendar'];
$enable_calification = $row['enable_calification'];
$sql_add_homework = "INSERT INTO $table_work_assignment SET
c_id = $this->destination_course_id ,
expires_on = '$expires_date',
ends_on = '$end_date',
add_to_calendar = '$add_to_calendar',
enable_qualification = '$enable_calification',
publication_id = '$last_id'";
Database::query($sql_add_homework);
}
api_item_property_update($this->destination_course_info, 'work', $last_id,"DirectoryCreated", api_get_user_id());
}
} elseif ($this->file_option == FILE_RENAME) {
$i = 1;
$new_path = $destination_path.'_'.$i;
$folder_exists = file_exists($new_path);
while ($folder_exists) {
$i ++;
$new_path = $destination_path.'_'.$i;
$folder_exists = file_exists($path.$new_path);
}
$r = @mkdir($new_path, $perm);
if ($r === false) {
error_log('Failed creating directory '.$new_path.' in course restore for work tool');
}
$obj->params['url'] .= '_'.$i;
$obj->params['title'] .= '_'.$i;
$last_id = Database::insert($table_work, $obj->params);
if (is_numeric($last_id)) {
$sql = 'SELECT *
FROM '.$table_work_assignment.'
WHERE c_id = '.$this->course_origin_id.' AND
publication_id = '.$id_work;
$result = Database::query($sql);
$cant = Database::num_rows($result);
if ($cant > 0) {
$row = Database::fetch_assoc($result);
$expires_date = $row['expires_on'];
$end_date = $row['ends_on'];
$add_to_calendar = $row['add_to_calendar'];
$enable_calification = $row['enable_calification'];
$sql_add_homework = "INSERT INTO $table_work_assignment SET
c_id = $this->destination_course_id ,
expires_on = '$expires_date',
ends_on = '$end_date',
add_to_calendar = '$add_to_calendar',
enable_qualification = '$enable_calification',
publication_id = '$last_id'";
Database::query($sql_add_homework);
}
api_item_property_update($this->destination_course_info, 'work', $last_id,"DirectoryCreated", api_get_user_id());
}
}
}
}

@ -1,91 +0,0 @@
body {
background-color: #FFFFFF;
color: #000000;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 11px;
margin: 3px;
padding: 0px;
}
td, p, li {
color: #000000;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 11px;
}
a:link {
color: #4171b5;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 11px;
font-weight: bold;
text-decoration: underline;
}
a:visited {
color: #4171b5;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 11px;
font-weight: bold;
text-decoration: underline;
}
a:hover {
color: #FF0000;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 11px;
font-weight: bold;
text-decoration: underline;
}
a:active {
color: #4171b5;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 11px;
font-weight: bold;
text-decoration: underline;
}
a.master:link {
color: #800080;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 11px;
font-weight: bold;
text-decoration: underline;
}
a.master:visited {
color: #800080;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 11px;
font-weight: bold;
text-decoration: underline;
}
a.master:hover {
color: #800080;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 11px;
font-weight: bold;
text-decoration: underline;
}
a.master:active {
color: #800080;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 11px;
font-weight: bold;
text-decoration: underline;
}
form {
margin: 0px;
}
input, select, textarea {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 11px;
}
ul {
list-style-position: inside;
list-style-type: square;
margin-left: 5px;
padding-left: 0px;
}
li {
padding-bottom: 5px;
}
.master {
color: #800080;
}
.question {
color: #FF8600;
}

File diff suppressed because it is too large Load Diff

@ -20,7 +20,7 @@ img {
}
/* End hide from IE5-mac */
/*****************************************************
/*****************************************************
* HEADER STYLES *
*****************************************************/
#header {
@ -55,97 +55,17 @@ img {
float: right;
font-weight: bold;
}
/* Header 2: Containing My Courses, My Profile,... */
#header2 {
font-size: 12px;
padding: 4px;
background-color: #4271B5;
color: #fff;
border-bottom: 1px solid white;
}
#header2 .banner_links {
margin: 0;
}
#header2 a {
text-decoration: none;
color: #fff;
background: transparent;
font-weight:normal;
font-size: 12px;
}
#header2 input.logout {
/* makes an input appear like a link in this header */
margin: 0;
padding: 0;
background-color: transparent;
border: none;
color: #fff;
font-size: 12px;
font-weight:normal;
font-family: verdana, arial, helvetica, sans-serif;
}
#header2 a:hover, #header2 input.logout:hover {
border-bottom: 1px solid #fff;
}
#logout {
float: right;
width:20%;
text-align:right;
}
/* Header 3: Containing breadcrumbs, online users, student/teacher view, help */
#header3 {
position: relative; /* to avoid the IE peekabo bug*/
font-size: 12px;
font-weight: normal;
padding: 4px;
background-color: #90AFDD;
color: #fff;
border-bottom: 1px solid white;
}
#header3 a {
color: #ffffff;
text-decoration: none;
font-weight:normal;
}
#header3 a:hover {
text-decoration: underline;
}
/* Header3Right: online users, student/teacher view, help */
#Header3Right ul {
position: relative; /* to avoid the IE peekabo bug*/
float: right;
width: 50%;
margin: 0;
padding: 0;
list-style-type: none;
text-align: right;
}
#Header3Right ul li {
display: inline;
}
#Header3Right ul li a {
padding: 4px 6px 4px 4px;
color:#fff;
}
/* Header 4: not used */
#header4 {
background-color: #fff;
color: #009;
padding: 4px;
margin-bottom: 2px;
}
#header4 a {
color: #4171b5;
}
#header4 a:hover {
text-decoration: none;
color: #f00;
}
/* The tool shortcuts */
#toolshortcuts {
text-align: right;
}
/*****************************************************
/*****************************************************
* FOOTER STYLES *
*****************************************************/
#footer {
@ -157,7 +77,7 @@ img {
#footer .copyright {
float: right;
}
/*****************************************************
/*****************************************************
* MAIN STYLES *
*****************************************************/
#main {
@ -233,7 +153,7 @@ img {
font-size: 12px;
color: #f00;
}
/*** layout divs for course and tool pages (being tested in some pages) ****/
/*** layout divs for course and tool pages (being tested in some pages) ****/
#contentfloatholder {/* also makes the right "sliding" tab */
/*background: url(../pics/sidebar-r.gif) repeat-y 100% 0;
background: url(../pics/bg_fountain.jpg) no-repeat 100% 0; */
@ -252,11 +172,11 @@ content: ".";
#centerwrap {
float: left;
width: 100%;
margin-right: -95%;/* this needs to be less than 100% for Moz/Mac which thinks
it's empty otherwise. The difference is made up by putting a
margin-right: -95%;/* this needs to be less than 100% for Moz/Mac which thinks
it's empty otherwise. The difference is made up by putting a
negative left margin on the left float:
Note IE/Mac doesn't like this method ~ it wants the 100% so it can
be fed in using IE only CSS below becasue IE/Win also works with the 100% method.
Note IE/Mac doesn't like this method ~ it wants the 100% so it can
be fed in using IE only CSS below becasue IE/Win also works with the 100% method.
*/
}
#center {
@ -325,10 +245,10 @@ content: ".";
color:#4171B5;
display: block;
}
/* --- end of left side definition list menu section --- */
/* --- end of left side definition list menu section --- */
/* various sections in course-home.php file */
#toolremove {
width: 40%;
@ -426,7 +346,7 @@ content: ".";
border: 1px solid #fff;
border-collapse: collapse;
}
/*The caption of the calendar (displays the month and the << and >> links*/
/*The caption of the calendar (displays the month and the << and >> links*/
#agenda_list #title {
background-color: #4171B5;
font-weight: bold;
@ -463,7 +383,7 @@ content: ".";
border: 1px solid #264269;
border-collapse: collapse;
}
/* The cells for the days (1->31) */
/* The cells for the days (1->31) */
#agenda_list .days_week {
height: 40px;
width: 12%;
@ -518,7 +438,7 @@ content: ".";
border: 0px solid #4171B5;
border-collapse: collapse;
}
/*text in the cells: display of agenda items (invisible)*/
/*text in the cells: display of agenda items (invisible)*/
#agenda_list .data_hidden {
background-color: #eee;
text-align: left;
@ -546,7 +466,7 @@ content: ".";
border-collapse: collapse;
color: #999999;
}
/*text in the cells: display of agenda items (highlighted)*/
/*text in the cells: display of agenda items (highlighted)*/
#agenda_list .datanow {
background-color: #FFCC00;
text-align: left;
@ -573,7 +493,7 @@ content: ".";
}
/* ---------------------------------------------------
styles for the mini agenda
-----------------------------------------------------*/
-----------------------------------------------------*/
#smallcalendar {
width: 100%;
margin: 0 auto;
@ -905,7 +825,7 @@ padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;}
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 9px
}
/*****************************************************
/*****************************************************
* DATA TABLE STYLES *
*****************************************************/
.cell_header {
@ -1061,9 +981,9 @@ div.system_announcement_content {
border-left: 1px solid gray;
padding-left: 5px;
}
/* tips Abbr-plugin for FCKeditor */
abbr {
border-bottom: 1px dotted rgb(102, 102, 102);
background-color:#F00;
cursor: help;
}
/* tips Abbr-plugin for FCKeditor */
abbr {
border-bottom: 1px dotted rgb(102, 102, 102);
background-color:#F00;
cursor: help;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 113 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 733 B

@ -1,6 +0,0 @@
<html>
<head>
</head>
<body>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 508 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 184 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 869 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

@ -9,7 +9,7 @@ span.messagesmall {
font-style : italic;
color : Red;
}
/* newscorm/learnpath */
/* newscorm/learnpath */
div.lp_actions {
background:#F8F8F8;
@ -80,7 +80,7 @@ div.lp_tree {
height:100%;
padding:3px 10px 3px 0;
overflow-x : auto;
overflow-y : scroll;
overflow-y : auto;
width:190px;
}
hr {
@ -121,7 +121,8 @@ table.lp_build td {
vertical-align:top;
}
table.lp_build td.tree {
border-right:1px solid #999999;
/* border-right:1px solid #999999;*/
padding-right: 5px;
width:205px;
}
table.lp_build td.workspace {
@ -159,12 +160,12 @@ table.lp_overview th.exercise {
width:50px;
}
table.lp_form input, table.lp_form select, table.lp_form textarea {
background:#F8F8F8;
/* background:#F8F8F8;
border:1px solid #999999;
font-family:Arial, Verdana, Helvetica, sans-serif;
font-size:12px;
padding:1px 2px;
width:300px;
width:300px;*/
}
table.lp_form td.radio input, table.lp_form td.exercise input {
width:auto;
@ -173,7 +174,7 @@ table.lp_form .small_form {
background:#FFFFFF;
}
table.lp_form select {
padding:0;
/* padding:0;*/
}
table.lp_form input.button {
width:75px;

@ -1,91 +0,0 @@
body {
background-color: #FFFFFF;
color: #000000;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 11px;
margin: 3px;
padding: 0px;
}
td, p, li {
color: #000000;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 11px;
}
a:link {
color: #4171b5;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 11px;
font-weight: bold;
text-decoration: underline;
}
a:visited {
color: #4171b5;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 11px;
font-weight: bold;
text-decoration: underline;
}
a:hover {
color: #FF0000;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 11px;
font-weight: bold;
text-decoration: underline;
}
a:active {
color: #4171b5;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 11px;
font-weight: bold;
text-decoration: underline;
}
a.master:link {
color: #800080;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 11px;
font-weight: bold;
text-decoration: underline;
}
a.master:visited {
color: #800080;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 11px;
font-weight: bold;
text-decoration: underline;
}
a.master:hover {
color: #800080;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 11px;
font-weight: bold;
text-decoration: underline;
}
a.master:active {
color: #800080;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 11px;
font-weight: bold;
text-decoration: underline;
}
form {
margin: 0px;
}
input, select, textarea {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 11px;
}
ul {
list-style-position: inside;
list-style-type: square;
margin-left: 5px;
padding-left: 0px;
}
li {
padding-bottom: 5px;
}
.master {
color: #800080;
}
.question {
color: #FF8600;
}

@ -763,26 +763,52 @@ padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;}
padding: 5px;
}
.data_table th {
padding-right: 20px;
/*padding-right: 20px;*/
border: 1px solid gray;
background-color: #E5EDF9;
text-align: left;
}
.data_table tr.row_odd {
background-color: #fafafa;
background-color: #fafafa;
}
.data_table tr.row_odd:hover, .data_table tr.row_even:hover {
background-color: #f0f0f0;
}
.data_table tr.row_even {
background-color: #fff;
background-color: #fff;
}
.data_table td .highlight {
font-weight: bold;
}
.data_table td {
padding: 5px;
vertical-align: top;
padding: 5px;
border-bottom: 1px solid #b0b0b0;
border-right: 1px dotted #e1e1e1;
border-left: 1px dotted #e1e1e1;
text-align: left;
}
.data_table_no_border {
border-collapse: collapse;
border-spacing: 0;
font-size: 12px;
margin-bottom: 15px;
margin-top: 8px;
text-align: left;
width: 100%;
}
.data_table_no_border td {
line-height: normal;
padding: 6px;
text-align: left;
vertical-align: middle;
}
.data_table_no_border .highlight {
font-weight: bold;
}
/* admin page tool list definitions */
.tool_list dt {
font-weight: bold;

@ -162,165 +162,321 @@
.scormpage {
height: 100%;
height: 100%;
}
.scormpage .menu {
width: 180px;
float: left;
margin: 1px;
padding: 0px;
margin-top: 0px;
padding-top: 0px;
font-size: small;
width: 180px;
float: left;
margin: 1px;
padding: 0px;
margin-top: 0px;
padding-top: 0px;
font-size: small;
}
.lp_toc {
background-color: white;
height: 380px;
width: 99%;
border-right: 1px none;
background-color: white;
height: 380px;
width: 99%;
border-right: 1px none;
}
.inner_lp_toc {
overflow: auto;
background-color: white;
height: 210px;
overflow: auto;
background-color: white;
height: 210px;
}
.inner_lp_toc .scorm_item {
font-size: 11px;
margin-left: 10px;
margin-right:10px;
text-decoration: none;
}
.inner_lp_toc .scorm_item A {
font-size: 11px;
margin-right: 1px;
padding-bottom: 2px;
text-decoration: none;
font-weight: normal;
}
.inner_lp_toc .scorm_item A.chapter_module {
font-weight: normal;
margin-right: 10px;
.inner_lp_toc .scorm_item a {
font-weight: normal;
font-size: 12px;
margin-right: 1px;
padding-bottom: 2px;
text-decoration: none;
font-family: Helvetica,Arial,sans-serif;
color: #2F3E46;
}
.inner_lp_toc .scorm_item_highlight {
font-size: 11px;
margin-right: 1px;
padding-bottom: 2px;
text-decoration: none;
font-weight: normal;
background:#aaa;
}
.inner_lp_toc .scorm_item_highlight A {
font-size: 11px;
margin-right: 1px;
text-decoration: none;
font-weight: normal;
.inner_lp_toc .scorm_item a.chapter_module {
font-weight: normal;
margin-right: 10px;
}
.inner_lp_toc .scorm_item_highlight {
border:1px solid #00aad4;
background:#00aad4;
font-weight:normal;
background-image:none;
margin-right: 0px;
padding: 10px 0px 10px 0px;
text-decoration: none;
}
.inner_lp_toc .scorm_item_highlight a {
color:#fff;
margin-right: 1px;
text-decoration: none;
font-weight: normal;
}
.inner_lp_toc .scorm_item_section {
border:1px solid #222;
background:#333;
font-weight:normal;
color:#fff;
text-shadow:0 -1px 1px #000;
background-image:-webkit-gradient(linear,left top,left bottom,from(#555),to(#333));
background-image:-webkit-linear-gradient(top,#555,#333);
background-image:-moz-linear-gradient(top,#555,#333);
background-image:-ms-linear-gradient(top,#555,#333);
background-image:-o-linear-gradient(top,#555,#333);
background-image:linear-gradient(top,#555,#333);
margin-right: 1px;
padding: 10px 0px 10px 0px;
text-decoration: none;
}
.inner_lp_toc .scorm_item {
font-size: 16px;
margin-left: 10px;
margin-right:10px;
text-decoration: none;
border-color: rgba(255, 255, 255, 0.3);
}
.inner_lp_toc .scorm_item_1 {
font-size: 11px;
margin-right: 1px;
padding-bottom: 2px;
text-decoration: none;
font-weight: normal;
background:#ddd;
border-bottom: 1px solid #CCCCCC;
background:#eee;
font-weight:bold;
color:#444;
text-shadow:0 1px 1px #f6f6f6;
background-image:none;
margin-right: 1px;
padding: 10px 0px 10px 0px;
text-decoration: none;
font-weight: normal;
/* background:#FDFDFD; */
}
.inner_lp_toc .scorm_item_2 {
font-size: 11px;
margin-right: 1px;
padding-bottom: 2px;
text-decoration: none;
font-weight: normal;
background:#eee;
.inner_lp_toc .scorm_item_2 {
background-image:none;
border-bottom: 1px solid #CCCCCC;
color: #444444;
font-weight: normal;
margin-right: 1px;
padding: 10px 0px 10px 0px;
text-decoration: none;
font-weight: normal;
}
.inner_lp_toc .scorm_title {
font-weight: bold;
background:#ccc;
font-size: 14px;
color: #444;
font-weight: bold;
background:#ccc;
font-size: 14px;
color: #444;
}
.inner_lp_toc .scorm_title_text {
margin-left: 10px;
margin-left: 10px;
}
.inner_lp_toc .scorm_status_img {
margin:0px;
margin-left: -10px;
width:10px;
margin:0px;
margin-left: -10px;
width:10px;
}
.lp_navigation {
overflow: auto;
background-color: white;
height: 44px;
width:180px;
padding-top: 4px;
padding-bottom:0px;
border: none;
margin-top: -18px;
border-top: 1px dotted black;
border-bottom: 1px dotted black;
overflow: auto;
background-color: white;
height: 44px;
width:180px;
padding-top: 4px;
padding-bottom:0px;
border: none;
margin-top: -18px;
border-top: 1px dotted black;
border-bottom: 1px dotted black;
}
.lp_navigation_elem {
padding-left: 15px;
padding-top: 0px;
padding-left: 15px;
padding-top: 0px;
}
/*.scormpage .menu */
.lp_navigation_elem .progresstext {
margin-top: -20px;
margin-left: 40%;
margin-top: -20px;
}
/*.scormpage .menu */
.lp_navigation_elem .buttons {
margin-left: 0px;
margin-right: 0em;
margin-top: 0.4em;
margin-left: 0px;
margin-right: 0em;
margin-top: 0.4em;
}
.scormpage .menu .notification {
background-color: white;
height: 50px;
background-color: white;
height: 50px;
}
.scormpage .menu .notification .message {
background-color: white;
height: 50px;
width: 180px;
border: none;
background-color: white;
height: 50px;
width: 180px;
border: none;
}
.scormpage .content {
/*float: left;
width: 60%;*/
margin-top: 0px;
padding-top: 0px;
padding-left: 180px;
background-color: white;
/*float: left;
width: 60%;*/
margin-top: 0px;
padding-top: 0px;
padding-left: 180px;
background-color: white;
}
.iframe {
border: 0px solid black;
height: 580px;
width: 95%;
margin: 0px;
padding-right: 0px;
overflow: auto;
vertical-align: top;
border: 0px solid black;
height: 100%;
width: 95%;
margin: 0px;
padding-right: 0px;
overflow: auto;
vertical-align: top;
}
.scormpage .footer {
clear: both;
clear: both;
}
#image_preview {
padding-left: 17px;
}
#author_name {
padding-left: 5px;
padding-top: 5px;
font-size: 11px;
color:#888;
padding-left: 17px;
}
#msg_div_id {
padding-left: 17px;
padding-top: 4px;
}
.scorm_title_text {
margin-left: 10px;
font-weight: bold;
background:#ccc;
font-size: 14px;
color: #444;
width: 89%;
padding: 1px 5px 3px 8px;
padding-left: 17px;
padding-top: 4px;
}
#learning_path_breadcrumb_zone .breadcrumb{
background-image: none;
background-color: #2e75a3;
color: #fff;
text-transform: capitalize;
}
#learning_path_breadcrumb_zone .breadcrumb a{
color: #FFF;
}
#learning_path_breadcrumb_zone .breadcrumb a:hover{
text-decoration: underline;
}
#scorm_title {
font-weight: bold;
background:none;
font-size: 20px;
background-image: none;
color: #0088aa;
padding-top: 5px;
padding-bottom: 15px;
}
#learning_path_main #control {
opacity: 1;
}
.buttons a img:hover{
opacity: 0.7;
}
#author_image{
background-color: #d7eef4;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
border: 1px solid #b4cbff;
margin-top: 10px;
}
#author_icon img{
background-color: #fff;
padding: 5px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
#author_image .progresstext{
font-size: 20px;
color: #0088aa;
font-weight: bold;
}
#learning_path_left_zone #header {
font-size: 14px;
margin-top: 10px;
}
#learning_path_left_zone .no-border{
background: none;
color: #2e75a3;
font-weight: normal;
}
.progress {
height: 18px;
margin-bottom: 18px;
overflow: hidden;
background-color: #f7f7f7;
background-image: -moz-linear-gradient(top, #f5f5f5, #f9f9f9);
background-image: -ms-linear-gradient(top, #f5f5f5, #f9f9f9);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f5f5f5), to(#f9f9f9));
background-image: -webkit-linear-gradient(top, #f5f5f5, #f9f9f9);
background-image: -o-linear-gradient(top, #f5f5f5, #f9f9f9);
background-image: linear-gradient(top, #f5f5f5, #f9f9f9);
background-repeat: repeat-x;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
filter: progid:dximagetransform.microsoft.gradient(startColorstr='#f5f5f5', endColorstr='#f9f9f9', GradientType=0);
-webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
-moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}
.progress-striped .bar {
background-color: #149BDF;
background-size: 40px 40px;
background-image: none;
}
/*STYLES PROCESS LESSION*/
.inner_lp_toc .scrom_completed {
background-image: url("images/blue_arrow.png") !important;
background-position: 250px center !important;
background-repeat: no-repeat;
}
.inner_lp_toc .scorm_item_highlight {
background-color: #00aad4;
background-image: url("images/white_arrow.png") !important;
background-position: 250px center !important;
background-repeat: no-repeat;
border: 1px solid #00aad4;
}
.inner_lp_toc .scorm_item_1 {
background-color: #d7eef4;
background-image: none;
border-bottom-color: #CCCCCC;
border-bottom-style: solid;
border-bottom-width: 1px;
color: #444444;
font-weight: normal;
margin-right: 1px;
padding-bottom: 10px;
padding-left: 0;
padding-right: 0;
padding-top: 10px;
text-shadow: 0 1px 1px #F6F6F6;
}
#learning_path_main #control {
background-image: none;
background-color: #d7eef4;
bottom: 0;
height: 34px;
margin-bottom: auto;
margin-left: auto;
margin-right: auto;
margin-top: auto;
padding-bottom: 8px;
padding-left: 0;
padding-right: 0;
padding-top: 8px;
position: absolute;
text-align: center;
width: 100%;
}

@ -12,7 +12,7 @@
width: 160px;
padding-top: 4px;
padding-bottom:0px;
/*
/*
margin-left: 10px;
margin-right: 10px;
*/

@ -208,7 +208,7 @@ function create_document_link($document_data, $show_as_icon = false, $counter =
$copy_to_myfiles = $open_in_new_window_link = null;
$curdirpath = isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : null;
$send_to = null;
if (!$show_as_icon) {
if ($filetype == 'folder') {
if (api_is_allowed_to_edit() || api_is_platform_admin() || api_get_setting('students_download_folders') == 'true') {
@ -232,7 +232,7 @@ function create_document_link($document_data, $show_as_icon = false, $counter =
if ($filetype == 'file') {
$copy_to_myfiles = '<a href="' . $copy_myfiles_link . '" style="float:right"' . $prevent_multiple_click . '>' . Display::return_icon('briefcase.png', get_lang('CopyToMyFiles'), array(), ICON_SIZE_SMALL) . '&nbsp;&nbsp;</a>';
}
$send_to = '';
if ($filetype == 'file') {
$send_to = Portfolio::share('document', $document_data['id'], array('style' => 'float:right;'));
}

@ -11,14 +11,13 @@
set_time_limit(0);
require_once '../inc/global.inc.php';
api_protect_course_script();
$document_data = DocumentManager::get_document_data_by_id($_GET['id'], api_get_course_id());
$path = $document_data['path'];
$path = $document_data['path'];
$sys_course_path = api_get_path(SYS_COURSE_PATH);
if (empty($path)) {
$path = '/';
}
@ -27,7 +26,7 @@ if (empty($document_data)) {
}
//a student should not be able to download a root shared directory
if (($path == '/shared_folder' || $path=='/shared_folder_session_'.api_get_session_id()) && (!api_is_allowed_to_edit() || !api_is_platform_admin())){
if (($path == '/shared_folder' || $path=='/shared_folder_session_'.api_get_session_id()) && (!api_is_allowed_to_edit() || !api_is_platform_admin())){
echo '<div align="center">';
Display::display_error_message(get_lang('NotAllowedClickBack'));
echo '</div>';
@ -46,9 +45,7 @@ $prop_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
$course_id = api_get_course_int_id();
$session_id = api_get_session_id();
//$to_group_id = api_get_group_id(); variable loaded in document.php
$groupId = api_get_group_id();
// We need this path to clean it out of the zip file
// I'm not using dirname as it gives too much problems (cfr.)
@ -68,23 +65,29 @@ if (api_is_allowed_to_edit()) {
}
$querypath = Database::escape_string($querypath);
// Search for all files that are not deleted => visibility != 2
$sql = "SELECT path FROM $doc_table AS docs, $prop_table AS props
WHERE props.tool ='".TOOL_DOCUMENT."' AND
docs.id = props.ref AND
docs.path LIKE '".$querypath."/%' AND
docs.filetype = 'file' AND props.visibility<>'2' AND
props.to_group_id = ".$to_group_id." AND
props.c_id = ".$course_id." AND
props.id_session IN ('0', '$session_id') AND
docs.c_id = ".$course_id." ";
$sql = "SELECT path
FROM $doc_table AS docs, $prop_table AS props
WHERE
props.tool ='".TOOL_DOCUMENT."' AND
docs.id = props.ref AND
docs.path LIKE '".$querypath."/%' AND
docs.filetype = 'file' AND props.visibility<>'2' AND
props.to_group_id = ".$groupId." AND
props.c_id = ".$course_id." AND
props.id_session IN ('0', '$session_id') AND
docs.c_id = ".$course_id." ";
$query = Database::query($sql);
// Add tem to the zip file
while ($not_deleted_file = Database::fetch_assoc($query)) {
$zip_folder->add($sys_course_path.$_course['path'].'/document'.$not_deleted_file['path'], PCLZIP_OPT_REMOVE_PATH, $sys_course_path.$_course['path'].'/document'.$remove_dir);
}
$zip_folder->add(
$sys_course_path.$_course['path'].'/document'.$not_deleted_file['path'],
PCLZIP_OPT_REMOVE_PATH,
$sys_course_path.$_course['path'].'/document'.$remove_dir
);
}
} else {
// For other users, we need to create a zipfile with only visible files and folders
if ($path == '/') {
$querypath = ''; // To prevent ...path LIKE '//%'... in query
} else {
@ -94,50 +97,57 @@ if (api_is_allowed_to_edit()) {
// So... I do it in a couple of steps:
// 1st: Get all files that are visible in the given path
$querypath = Database::escape_string($querypath);
$query = Database::query("SELECT path FROM $doc_table AS docs, $prop_table AS props
WHERE docs.c_id = $course_id AND
props.c_id = $course_id AND
props.tool = '".TOOL_DOCUMENT."' AND
docs.id = props.ref AND
docs.path LIKE '".$querypath."/%' AND
props.visibility = '1' AND
docs.filetype = 'file' AND
props.id_session IN ('0', '$session_id') AND
props.to_group_id = ".$to_group_id);
$sql = "SELECT path
FROM $doc_table AS docs, $prop_table AS props
WHERE
docs.c_id = $course_id AND
props.c_id = $course_id AND
props.tool = '".TOOL_DOCUMENT."' AND
docs.id = props.ref AND
docs.path LIKE '".$querypath."/%' AND
props.visibility = '1' AND
docs.filetype = 'file' AND
props.id_session IN ('0', '$session_id') AND
props.to_group_id = ".$groupId;
$query = Database::query($sql);
// Add them to an array
while ($all_visible_files = Database::fetch_assoc($query)) {
$all_visible_files_path[] = $all_visible_files['path'];
}
// 2nd: Get all folders that are invisible in the given path
$query2 = Database::query("SELECT path FROM $doc_table AS docs, $prop_table AS props
WHERE docs.c_id = $course_id AND
props.c_id = $course_id AND
props.tool = '".TOOL_DOCUMENT."' AND
docs.id = props.ref AND
docs.path LIKE '".$querypath."/%' AND
props.visibility <> '1' AND
props.id_session IN ('0', '$session_id') AND
docs.filetype = 'folder'");
$sql = "SELECT path
FROM $doc_table AS docs, $prop_table AS props
WHERE
docs.c_id = $course_id AND
props.c_id = $course_id AND
props.tool = '".TOOL_DOCUMENT."' AND
docs.id = props.ref AND
docs.path LIKE '".$querypath."/%' AND
props.visibility <> '1' AND
props.id_session IN ('0', '$session_id') AND
docs.filetype = 'folder'";
$query2 = Database::query($sql);
// If we get invisible folders, we have to filter out these results from all visible files we found
if (Database::num_rows($query2) > 0) {
// Add tem to an array
// Add item to an array
while ($invisible_folders = Database::fetch_assoc($query2)) {
//3rd: Get all files that are in the found invisible folder (these are "invisible" too)
//echo "<br /><br />invisible folders: ".$sys_course_path.$_course['path'].'/document'.$invisible_folders['path'].'<br />';
$query3 = Database::query("SELECT path FROM $doc_table AS docs,$prop_table AS props
WHERE docs.c_id = $course_id AND
props.c_id = $course_id AND
props.tool ='".TOOL_DOCUMENT."' AND
docs.id = props.ref AND
docs.path LIKE '".$invisible_folders['path']."/%' AND
docs.filetype ='file' AND
props.id_session IN ('0', '$session_id') AND
props.visibility ='1'");
//3rd: Get all files that are in the found invisible folder (these are "invisible" too)
$sql = "SELECT path
FROM $doc_table AS docs, $prop_table AS props
WHERE
docs.c_id = $course_id AND
props.c_id = $course_id AND
props.tool ='".TOOL_DOCUMENT."' AND
docs.id = props.ref AND
docs.path LIKE '".$invisible_folders['path']."/%' AND
docs.filetype ='file' AND
props.id_session IN ('0', '$session_id') AND
props.visibility ='1'";
$query3 = Database::query($sql);
// Add tem to an array
while ($files_in_invisible_folder = Database::fetch_assoc($query3)) {
$files_in_invisible_folder_path[] = $files_in_invisible_folder['path'];
//echo '<br /><br />files in invisible folders: '.$sys_course_path.$_course['path'].'/document'.$files_in_invisible_folder['path'].' <b>id '.$files_in_invisible_folder['id'].'</b><br />';
}
}
// Compare the array with visible files and the array with files in invisible folders
@ -163,7 +173,7 @@ $name = ($path == '/') ? 'documents.zip' : $document_data['title'].'.zip';
if (Security::check_abs_path($temp_zip_file, api_get_path(SYS_ARCHIVE_PATH))) {
DocumentManager::file_send_for_download($temp_zip_file, true, $name);
@unlink($temp_zip_file);
@unlink($temp_zip_file);
exit;
}

@ -968,10 +968,6 @@ function get_exam_results_data($from, $number_of_items, $column, $direction, $ex
//@todo replace all this globals
global $documentPath, $filter;
if (empty($extra_where_conditions)) {
$extra_where_conditions = "1 = 1 ";
}
$course_id = api_get_course_int_id();
$course_code = api_get_course_id();
@ -1106,12 +1102,13 @@ function get_exam_results_data($from, $number_of_items, $column, $direction, $ex
FROM $TBL_EXERCICES AS ce
INNER JOIN $sql_inner_join_tbl_track_exercices AS te ON (te.exe_exo_id = ce.id)
INNER JOIN $sql_inner_join_tbl_user AS user ON (user.user_id = exe_user_id)
WHERE $extra_where_conditions AND
te.status != 'incomplete'
AND te.exe_cours_id='" . api_get_course_id() . "' $session_id_and
AND ce.active <>-1
AND ce.c_id=".api_get_course_int_id()."
$exercise_where ";
WHERE
te.status != 'incomplete' AND
te.exe_cours_id='" . api_get_course_id() . "' $session_id_and AND
ce.active <>-1 AND ce.c_id=".api_get_course_int_id()."
$exercise_where
$extra_where_conditions
";
// sql for hotpotatoes tests for teacher / tutor view

@ -21,8 +21,8 @@ $objExercise = new Exercise();
$result = $objExercise->read($exercise_id);
if (!$result) {
api_not_allowed(true);
}
api_not_allowed(true);
}
$interbreadcrumb[] = array ("url" => "exercice.php?gradebook=$gradebook", "name" => get_lang('Exercices'));
$interbreadcrumb[] = array ("url" => "admin.php?exerciseId=$exercise_id","name" => $objExercise->name);
@ -38,7 +38,7 @@ Display::display_header(get_lang('StudentsWhoAreTakingTheExerciseRightNow'));
$minutes = 60;
$url = api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?a=get_live_stats&exercise_id='.$objExercise->id.'&minutes='.$minutes;
//The order is important you need to check the the $column variable in the model.ajax.php file
//The order is important you need to check the the $column variable in the model.ajax.php file
$columns = array(get_lang('FirstName'), get_lang('LastName'), get_lang('Time'), get_lang('QuestionsAlreadyAnswered'), get_lang('Score'));
//Column config
@ -48,20 +48,20 @@ $column_model = array(
array('name'=>'start_date', 'index'=>'start_date', 'width'=>'100', 'align'=>'left'),
array('name'=>'question', 'index'=>'count_questions', 'width'=>'60', 'align'=>'left', 'sortable'=>'false'),
array('name'=>'score', 'index'=>'score', 'width'=>'50', 'align'=>'left','sortable'=>'false'),
);
//Autowidth
);
//Autowidth
$extra_params['autowidth'] = 'true';
//height auto
$extra_params['height'] = 'auto';
//height auto
$extra_params['height'] = 'auto';
/*
//With this function we can add actions to the jgrid (edit, delete, etc)
$action_links = 'function action_formatter(cellvalue, options, rowObject) {
return \'<a href="?action=edit&id=\'+options.rowId+\'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'.
'&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;" href="?action=copy&id=\'+options.rowId+\'">'.Display::return_icon('copy.png',get_lang('Copy'),'',ICON_SIZE_SMALL).'</a>'.
'&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;" href="?action=delete&id=\'+options.rowId+\'">'.Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'.
'\';
'\';
}';
*/
*/
?>
<script>
@ -72,8 +72,8 @@ function refreshGrid() {
}
$(function() {
<?php
echo Display::grid_js('live_stats', $url, $columns, $column_model, $extra_params, array(), $action_links,true);
<?php
echo Display::grid_js('live_stats', $url, $columns, $column_model, $extra_params, array(), null, true);
?>
refreshGrid();
});
@ -85,6 +85,6 @@ echo $actions = Display::div($actions, array('class'=> 'actions'));
//echo Display::page_header($objExercise->name);
//echo Display::page_header(get_lang('StudentsWhoAreTakingTheExerciseRightNow'));
echo Display::grid_html('live_stats');
echo Display::grid_html('live_stats');
Display::display_footer();

@ -1541,12 +1541,10 @@ abstract class Question
* Get course medias
* @param int course id
*/
static function get_course_medias($course_id, $start = 0, $limit = 100, $sidx = "question", $sord = "ASC", $where_condition = array()) {
static function get_course_medias($course_id, $start = 0, $limit = 100, $sidx = "question", $sord = "ASC", $where_condition = array())
{
$table_question = Database::get_course_table(TABLE_QUIZ_QUESTION);
$default_where = array('c_id = ? AND parent_id = 0 AND type = ?' => array($course_id, MEDIA_QUESTION));
if (!empty($where_condition)) {
//$where_condition
}
$result = Database::select('*', $table_question,
array(
'limit' => " $start, $limit",

@ -10,6 +10,7 @@ require_once 'exercise.lib.php';
$this_section = SECTION_COURSES;
$exercise_id = (isset($_GET['exerciseId']) && !empty($_GET['exerciseId'])) ? intval($_GET['exerciseId']) : 0;
$gradebook = isset($gradebook) ? $gradebook : null;
$objExercise = new Exercise();
$result = $objExercise->read($exercise_id);
@ -45,7 +46,7 @@ $headers = array(
if (!empty($question_list)) {
foreach ($question_list as $question_id) {
$question_obj = Question::read($question_id);
$exercise_stats = get_student_stats_by_question($question_id, $exercise_id, api_get_course_id(), api_get_session_id());
$exercise_stats = get_student_stats_by_question($question_id, $exercise_id, api_get_course_id(), api_get_session_id());
$count_users = get_number_students_question_with_answer_count($question_id, $exercise_id, api_get_course_id(), api_get_session_id());
$data[$question_id]['name'] = cut($question_obj->question, 100);
@ -55,9 +56,9 @@ if (!empty($question_list)) {
if ($count_students) {
$percentange = $count_users/$count_students*100;
}
$data[$question_id]['students_who_try_exercise'] = Display::bar_progress($percentange, false, $count_users .' / '.$count_students);
$data[$question_id]['lowest_score'] = round($exercise_stats['min'], 2);
$data[$question_id]['average_score'] = round($exercise_stats['average'], 2);
$data[$question_id]['highest_score'] = round($exercise_stats['max'], 2);
@ -92,7 +93,7 @@ $headers = array(
get_lang('Question'),
get_lang('Answer'),
get_lang('Correct'),
get_lang('NumberStudentWhoSelectedIt')
get_lang('NumberStudentWhoSelectedIt')
);
$data = array();
@ -105,20 +106,20 @@ if (!empty($question_list)) {
$answer = new Answer($question_id);
$answer_count = $answer->selectNbrAnswers();
for ($answer_id = 1; $answer_id <= $answer_count; $answer_id++) {
$answer_info = $answer->selectAnswer($answer_id);
$is_correct = $answer->isCorrect($answer_id);
$correct_answer = $is_correct == 1 ? get_lang('Yes') : get_lang('No');
$real_answer_id = $answer->selectAutoId($answer_id);
//$data[$id]['name'] .=$answer_count;
//Overwriting values depending of the question
switch ($question_obj->type) {
case FILL_IN_BLANKS :
$answer_info_db = $answer_info;
$answer_info = substr($answer_info, 0, strpos($answer_info, '::'));
$correct_answer = $is_correct;
$correct_answer = $is_correct;
$answers = $objExercise->fill_in_blank_answer_to_array($answer_info);
$counter = 0;
foreach ($answers as $answer_item) {
@ -127,36 +128,36 @@ if (!empty($question_list)) {
} else {
$data[$id]['name'] = '-';
}
$data[$id]['answer'] = $answer_item;
$data[$id]['answer'] = $answer_item;
$answer_item = api_substr($answer_item, 1);
$answer_item = api_substr($answer_item, 0, api_strlen($answer_item) -1);
$data[$id]['correct'] = '-';
$count = get_number_students_answer_count($real_answer_id, $question_id, $exercise_id, api_get_course_id(), api_get_session_id(), FILL_IN_BLANKS, $answer_info_db, $answer_item);
$percentange = 0;
if (!empty($count_students)) {
$percentange = $count/$count_students*100;
}
$data[$id]['attempts'] = Display::bar_progress($percentange, false, $count .' / '.$count_students);
$id++;
$counter++;
$counter++;
}
break;
case MATCHING:
if ($is_correct == 0) {
if ($answer_id == 1) {
if ($is_correct == 0) {
if ($answer_id == 1) {
$data[$id]['name'] = cut($question_obj->question, 100);
} else {
$data[$id]['name'] = '-';
}
}
$correct = '';
for ($i = 1; $i <= $answer_count; $i++) {
$is_correct_i = $answer->isCorrect($i);
$is_correct_i = $answer->isCorrect($i);
if ($is_correct_i != 0 && $is_correct_i == $answer_id) {
$correct = $answer->selectAnswer($i);
break;
@ -164,50 +165,50 @@ if (!empty($question_list)) {
}
$data[$id]['answer'] = $correct;
$data[$id]['correct'] = $answer_info;
$count = get_number_students_answer_count($answer_id, $question_id, $exercise_id, api_get_course_id(), api_get_session_id(), MATCHING);
$percentange = 0;
if (!empty($count_students)) {
$percentange = $count/$count_students*100;
}
$data[$id]['attempts'] = Display::bar_progress($percentange, false, $count .' / '.$count_students);
}
}
break;
case HOT_SPOT:
if ($answer_id == 1) {
if ($answer_id == 1) {
$data[$id]['name'] = cut($question_obj->question, 100);
} else {
$data[$id]['name'] = '-';
}
$data[$id]['answer'] = $answer_info;
$data[$id]['correct'] = '-';
$count = get_number_students_answer_hotspot_count($answer_id, $question_id, $exercise_id, api_get_course_id(), api_get_session_id());
$count = get_number_students_answer_hotspot_count($answer_id, $question_id, $exercise_id, api_get_course_id(), api_get_session_id());
$percentange = 0;
if (!empty($count_students)) {
$percentange = $count/$count_students*100;
}
$data[$id]['attempts'] = Display::bar_progress($percentange, false, $count .' / '.$count_students);
$data[$id]['attempts'] = Display::bar_progress($percentange, false, $count .' / '.$count_students);
break;
default:
if ($answer_id == 1) {
if ($answer_id == 1) {
$data[$id]['name'] = cut($question_obj->question, 100);
} else {
$data[$id]['name'] = '-';
}
$data[$id]['answer'] = $answer_info;
$data[$id]['correct'] = $correct_answer;
$count = get_number_students_answer_count($real_answer_id, $question_id, $exercise_id, api_get_course_id(), api_get_session_id());
$percentange = 0;
if (!empty($count_students)) {
$percentange = $count/$count_students*100;
}
$data[$id]['attempts'] = Display::bar_progress($percentange, false, $count .' / '.$count_students);
}
}
$id++;
}
}
}

@ -1526,18 +1526,18 @@ function get_threads($forum_id, $course_code = null)
$table_threads = Database :: get_course_table(TABLE_FORUM_THREAD);
$table_users = Database :: get_main_table(TABLE_MAIN_USER);
$thread_list = array();
// important note: it might seem a little bit awkward that we have 'thread.locked as locked' in the sql statement
// because we also have thread.* in it. This is because thread has a field locked and post also has the same field
// since we are merging these we would have the post.locked value but in fact we want the thread.locked value
// This is why it is added to the end of the field selection
$sql = "SELECT thread.*,
item_properties.*,
users.firstname,
users.lastname,
users.user_id,
thread.locked as locked
// because we also have thread.* in it. This is because thread has a field locked and post also has the same field
// since we are merging these we would have the post.locked value but in fact we want the thread.locked value
// This is why it is added to the end of the field selection
$sql = "SELECT
thread.*,
item_properties.*,
users.firstname,
users.lastname,
users.user_id,
thread.locked as locked
FROM $table_threads thread
INNER JOIN $table_item_property item_properties
ON thread.thread_id=item_properties.ref AND
@ -1553,15 +1553,16 @@ function get_threads($forum_id, $course_code = null)
if (is_allowed_to_edit()) {
// important note: it might seem a little bit awkward that we have 'thread.locked as locked' in the sql statement
// because we also have thread.* in it. This is because thread has a field locked and post also has the same field
// since we are merging these we would have the post.locked value but in fact we want the thread.locked value
// This is why it is added to the end of the field selection
$sql = "SELECT thread.*,
item_properties.*,
users.firstname,
users.lastname,
users.user_id,
thread.locked as locked
// because we also have thread.* in it. This is because thread has a field locked and post also has the same field
// since we are merging these we would have the post.locked value but in fact we want the thread.locked value
//This is why it is added to the end of the field selection
$sql = "SELECT
thread.*,
item_properties.*,
users.firstname,
users.lastname,
users.user_id,
thread.locked as locked
FROM $table_threads thread
INNER JOIN $table_item_property item_properties
ON thread.thread_id=item_properties.ref AND
@ -1576,6 +1577,7 @@ function get_threads($forum_id, $course_code = null)
ORDER BY thread.thread_sticky DESC, thread.thread_date DESC";
}
$result = Database::query($sql);
$thread_list = array();
while ($row = Database::fetch_array($result, 'ASSOC')) {
$thread_list[] = $row;
}
@ -2127,15 +2129,17 @@ function show_add_post_form($action = '', $id = '', $form_values = '')
global $_user;
global $origin;
$gradebook = Security::remove_XSS($_GET['gradebook']);
$gradebook = isset($_GET['gradebook']) ? Security::remove_XSS($_GET['gradebook']) : null;
$action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : null;
// Setting the class and text of the form title and submit button.
if ($_GET['action'] == 'quote') {
if ($action == 'quote') {
$class = 'save';
$text = get_lang('QuoteMessage');
} elseif ($_GET['action'] == 'replythread') {
} elseif ($action == 'replythread') {
$class = 'save';
$text = get_lang('ReplyToThread');
} elseif ($_GET['action'] == 'replymessage') {
} elseif ($action == 'replymessage') {
$class = 'save';
$text = get_lang('ReplyToMessage');
} else {
@ -2146,10 +2150,13 @@ function show_add_post_form($action = '', $id = '', $form_values = '')
// Initialize the object.
$my_thread = isset($_GET['thread']) ? $_GET['thread'] : '';
$my_forum = isset($_GET['forum']) ? $_GET['forum'] : '';
$my_action = isset($_GET['action']) ? $_GET['action'] : '';
$my_post = isset($_GET['post']) ? $_GET['post'] : '';
$my_gradebook = isset($_GET['gradebook']) ? Security::remove_XSS($_GET['gradebook']) : '';
$form = new FormValidator('thread', 'post', api_get_self().'?forum='.Security::remove_XSS($my_forum).'&gradebook='.$gradebook.'&thread='.Security::remove_XSS($my_thread).'&post='.Security::remove_XSS($my_post).'&action='.Security::remove_XSS($my_action).'&origin='.$origin);
$form = new FormValidator(
'thread',
'post',
api_get_self().'?forum='.Security::remove_XSS($my_forum).'&gradebook='.$gradebook.'&thread='.Security::remove_XSS($my_thread).'&post='.Security::remove_XSS($my_post).'&action='.$action.'&origin='.$origin
);
$form->setConstants(array('forum' => '5'));
$form->addElement('header', $text);

@ -54,7 +54,7 @@ require_once 'forumfunction.inc.php';
// but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table.
$current_thread=get_thread_information($_GET['thread']); // Note: this has to be validated that it is an existing thread.
$current_forum=get_forum_information($current_thread['forum_id']); // Note: this has to be validated that it is an existing forum.
$current_forum_category=get_forumcategory_information($current_forum['forum_category']);
$current_forum_category = get_forumcategory_information($current_forum['forum_category']);
/* Is the user allowed here? */
@ -76,8 +76,8 @@ $course_id = api_get_course_int_id();
// but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table.
$sql = "SELECT * FROM $table_posts posts, $table_users users
WHERE
posts.c_id = $course_id AND
WHERE
posts.c_id = $course_id AND
posts.thread_id='".$current_thread['thread_id']."'
AND posts.poster_id=users.user_id
ORDER BY posts.post_id ASC";
@ -108,4 +108,4 @@ echo "</table>";
?>
</body>
</html>
</html>

@ -155,7 +155,7 @@ handle_forum_and_forumcategories();
// Action links
echo '<div class="actions">';
echo '<span style="float:right;">'.search_link().'</span>';
echo '<a href="viewforum.php?origin='.$origin.'&forum='.Security::remove_XSS($_GET['forum']).'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'">'.Display::return_icon('back.png',get_lang('BackToForum'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="viewforum.php?origin='.$origin.'&forum='.Security::remove_XSS($_GET['forum']).'&'.api_get_cidreq().'">'.Display::return_icon('back.png',get_lang('BackToForum'),'',ICON_SIZE_MEDIUM).'</a>';
echo '</div>';
$values = show_add_post_form('newthread', '', isset($_SESSION['formelements']) ? $_SESSION['formelements'] : null);

@ -92,6 +92,7 @@ if ($current_forum['forum_of_group'] != 0) {
}
/* Breadcrumbs */
$gradebook = null;
if (isset($_SESSION['gradebook'])){
$gradebook = Security::remove_XSS($_SESSION['gradebook']);
}

@ -99,7 +99,7 @@ if (!empty($group_id)) {
$my_search = isset($_GET['search']) ? $_GET['search'] : '';
$my_action = isset($_GET['action']) ? $_GET['action'] : '';
$gradebook = null;
if (isset($_SESSION['gradebook'])){
$gradebook = $_SESSION['gradebook'];
}
@ -336,7 +336,7 @@ $counter = 0;
if (is_array($threads)) {
foreach ($threads as $row) {
// Thread who have no replies yet and the only post is invisible should not be displayed to students.
if (api_is_allowed_to_edit(false, true) OR !($row['thread_replies'] == '0' AND $row['visible'] == '0')) {
if (api_is_allowed_to_edit(false, true) OR !($row['thread_replies'] == '0' AND $row['visibility'] == '0')) {
if ($counter % 2 == 0) {
$class = 'row_odd';
} else {
@ -375,7 +375,7 @@ if (is_array($threads)) {
if ($last_post_info) {
$poster_info = api_get_user_info($last_post_info['poster_id']);
$post_date = api_convert_and_format_date($last_post_info['post_date']);
$last_post = $post_date.' '.get_lang('By').' '.display_user_link($last_post_info['poster_id'], $poster_info['complete_name'], '', $poster_info['user_name']);
$last_post = $post_date.' '.get_lang('By').' '.display_user_link($last_post_info['poster_id'], $poster_info['complete_name'], '', $poster_info['username']);
}
/*
if ($row['last_poster_user_id'] == '0') {
@ -407,8 +407,11 @@ if (is_array($threads)) {
echo '<td>'.$last_post.'</td>';
echo '<td class="td_actions">';
// Get attachment id.
$attachment_list = get_attachment($row['post_id']);
if (isset($row['post_id'])) {
$attachment_list = get_attachment($row['post_id']);
}
$id_attach = !empty($attachment_list) ? $attachment_list['id'] : '';
$sql_post_id = "SELECT post_id FROM $table_posts WHERE c_id = $course_id AND post_title='".Database::escape_string($row['thread_title'])."'";

@ -58,6 +58,7 @@ require 'forumconfig.inc.php';
require_once 'forumfunction.inc.php';
/* Header and Breadcrumbs */
$gradebook = null;
if (isset($_SESSION['gradebook'])) {
$gradebook= $_SESSION['gradebook'];
}
@ -94,7 +95,7 @@ if ($origin=='learnpath') {
}
/* ACTIONS */
$whatsnew_post_info = $_SESSION['whatsnew_post_info'];
$whatsnew_post_info = isset($_SESSION['whatsnew_post_info']) ? $_SESSION['whatsnew_post_info'] : null;
/* Is the user allowed here? */

@ -29,10 +29,12 @@ $origin = '';
if (isset($_GET['origin'])) {
$origin = Security::remove_XSS($_GET['origin']);
}
$my_search = null;
$gradebook = null;
/* MAIN DISPLAY SECTION */
/* Retrieving forum and forum categorie information */
/* Retrieving forum and forum category information */
// We are getting all the information about the current forum and forum category.
// Note pcool: I tried to use only one sql statement (and function) for this,
@ -42,7 +44,7 @@ $current_thread = get_thread_information($_GET['thread']);
// Note: This has to be validated that it is an existing forum.
$current_forum = get_forum_information($current_thread['forum_id']);
$current_forum_category = get_forumcategory_information($current_forum['forum_category']);
$whatsnew_post_info = $_SESSION['whatsnew_post_info']; // This variable should be deprecated?
$whatsnew_post_info = isset($_SESSION['whatsnew_post_info']) ? $_SESSION['whatsnew_post_info'] : null; // This variable should be deprecated?
/* Header and Breadcrumbs */

@ -763,20 +763,23 @@ if (api_is_allowed_to_edit(null, true)) {
if (isset($first_time) && $first_time==1 && api_is_allowed_to_edit(null,true)) {
echo '<meta http-equiv="refresh" content="0;url='.api_get_self().'?cidReq='.$course_code.'" />';
} else {
$cats = Category :: load(null, null, $course_code, null, null, $session_id, false); //already init
$cats = Category::load(null, null, $course_code, null, null, $session_id, false);
if (!empty($cats)) {
if ((api_get_setting('gradebook_enable_grade_model') == 'true') &&
(api_is_platform_admin() || (api_is_allowed_to_edit(null, true) &&
api_get_setting('teachers_can_change_grade_model_settings') == 'true'))
) {
if ( (api_get_setting('gradebook_enable_grade_model') == 'true') &&
(api_is_platform_admin() || (api_is_allowed_to_edit(null, true) && api_get_setting('teachers_can_change_grade_model_settings') == 'true'))) {
//Getting grade models
// Getting grade models.
$obj = new GradeModel();
$grade_models = $obj->get_all();
$grade_model_id = $cats[0]->get_grade_model_id();
//No children
if ( (count($cats) == 1 && empty($grade_model_id)) || (count($cats) == 1 && $grade_model_id != -1) ) {
// No children.
if ((count($cats) == 1 && empty($grade_model_id)) ||
(count($cats) == 1 && $grade_model_id != -1)
) {
if (!empty($grade_models)) {
$form_grade = new FormValidator('grade_model_settings');
$obj->fill_grade_model_select_in_form($form_grade, 'grade_model_id', $grade_model_id);
@ -817,20 +820,33 @@ if (isset($first_time) && $first_time==1 && api_is_allowed_to_edit(null,true)) {
}
$i = 0;
foreach ($cats as $cat) {
/** @var Category $cat **/
foreach ($cats as $cat) {
$allcat = $cat->get_subcategories($stud_id, $course_code, $session_id);
$alleval = $cat->get_evaluations($stud_id);
$alllink = $cat->get_links($stud_id,true);
$alllink = $cat->get_links($stud_id);
if ($cat->get_parent_id() != 0 ) {
if ($cat->get_parent_id() != 0) {
$i++;
} else {
//This is the father
//Create gradebook/add gradebook links
DisplayGradebook::display_header_gradebook($cat, 0, $cat->get_id(), $is_course_admin, $is_platform_admin, $simple_search_form, false, true);
if (api_is_allowed_to_edit(null,true) && api_get_setting('gradebook_enable_grade_model') == 'true') {
// This is the father
// Create gradebook/add gradebook links.
DisplayGradebook::display_header_gradebook(
$cat,
0,
$cat->get_id(),
$is_course_admin,
$is_platform_admin,
$simple_search_form,
false,
true
);
if (api_is_allowed_to_edit(null,true) &&
api_get_setting('gradebook_enable_grade_model') == 'true'
) {
//Showing the grading system
if (!empty($grade_models[$grade_model_id])) {
Display::display_normal_message(get_lang('GradeModel').': '.$grade_models[$grade_model_id]['name']);

@ -19,7 +19,7 @@ class DisplayGradebook
*/
static function display_header_result($evalobj, $selectcat, $page) {
if (api_is_allowed_to_edit(null, true)) {
$header = '<div class="actions">';
$header = '<div class="actions">';
if ($page != 'statistics') {
$header .= '<a href="'.Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat=' . $selectcat . '">'. Display::return_icon(('back.png'),get_lang('FolderView'),'',ICON_SIZE_MEDIUM).'</a>';
if ($evalobj->get_course_code() == null) {
@ -27,22 +27,22 @@ class DisplayGradebook
//$header .= '<a href="gradebook_add_user.php?selecteval=' . $evalobj->get_id() . '"><img src="../img/add_user_big.gif" alt="' . get_lang('AddStudent') . '" align="absmiddle" /> ' . get_lang('AddStudent') . '</a>';
} elseif (!$evalobj->has_results()) {
$header .= '<a href="gradebook_add_result.php?selectcat=' . $selectcat . '&selecteval=' . $evalobj->get_id() . '">
'.Display::return_icon('evaluation_rate.png',get_lang('AddResult'),'',ICON_SIZE_MEDIUM) . '</a>';
'.Display::return_icon('evaluation_rate.png',get_lang('AddResult'),'',ICON_SIZE_MEDIUM) . '</a>';
}
if (api_is_platform_admin() || $evalobj->is_locked() == false) {
$header .= '<a href="' . api_get_self() . '?&selecteval=' . $evalobj->get_id() . '&import=">'.Display::return_icon('import_evaluation.png',get_lang('ImportResult'),'',ICON_SIZE_MEDIUM) . '</a>';
$header .= '<a href="' . api_get_self() . '?&selecteval=' . $evalobj->get_id() . '&import=">'.Display::return_icon('import_evaluation.png',get_lang('ImportResult'),'',ICON_SIZE_MEDIUM) . '</a>';
}
if ($evalobj->has_results()) {
$header .= '<a href="' . api_get_self() . '?&selecteval=' . $evalobj->get_id() . '&export=">'.Display::return_icon('export_evaluation.png',get_lang('ExportResult'),'',ICON_SIZE_MEDIUM) . '</a>';
if (api_is_platform_admin() || $evalobj->is_locked() == false) {
$header .= '<a href="gradebook_edit_result.php?selecteval=' . $evalobj->get_id() .'">'.Display::return_icon('edit.png',get_lang('EditResult'),'',ICON_SIZE_MEDIUM).'</a>';
$header .= '<a href="' . api_get_self() . '?&selecteval=' . $evalobj->get_id() . '&deleteall=" onclick="return confirmationall();">'.Display::return_icon('delete.png',get_lang('DeleteResult'),'',ICON_SIZE_MEDIUM).'</a>';
}
}
$header .= '<a href="' . api_get_self() . '?print=&selecteval=' . $evalobj->get_id() . '" target="_blank">'.Display::return_icon('printer.png',get_lang('Print'),'',ICON_SIZE_MEDIUM).'</a>';
} else {
$header .= '<a href="gradebook_view_result.php?selecteval='.Security::remove_XSS($_GET['selecteval']).'"> '.Display::return_icon(('back.png'),get_lang('FolderView'),'',ICON_SIZE_MEDIUM) . '</a>';
@ -57,59 +57,59 @@ class DisplayGradebook
}
$scoredisplay = ScoreDisplay :: instance();
$student_score = '';
if (($evalobj->has_results())){ // TODO this check needed ?
$score = $evalobj->calc_score();
if ($score != null) {
$average= get_lang('Average') . ' :<b> ' .$scoredisplay->display_score($score, SCORE_AVERAGE) . '</b>';
$student_score = $evalobj->calc_score(api_get_user_id());
$student_score = Display::tag('h3', get_lang('Score').': '.$scoredisplay->display_score($student_score, SCORE_DIV_PERCENT));
}
$student_score = Display::tag('h3', get_lang('Score').': '.$scoredisplay->display_score($student_score, SCORE_DIV_PERCENT));
}
}
if (!$evalobj->get_description() == '') {
$description= get_lang('Description') . ' :<b> ' . $evalobj->get_description() . '</b><br>';
}
if ($evalobj->get_course_code() == null) {
$course= get_lang('CourseIndependent');
} else {
$course= get_course_name_from_code($evalobj->get_course_code());
}
$evalinfo= '<table width="100%" border="0"><tr><td>';
$evalinfo .= '<h2>'.$evalobj->get_name().'</h2><hr>';
$evalinfo .= '<h2>'.$evalobj->get_name().'</h2><hr>';
$evalinfo .= $description;
$evalinfo .= get_lang('Course') . ' :<b> ' . $course . '</b><br />';
//'<br>' . get_lang('Weight') . ' :<b> ' . $evalobj->get_weight() . '</b><br>' . get_lang('Visible') . ' :<b> ' . $visible . '</b>
$evalinfo .= get_lang('QualificationNumeric') . ' :<b> ' . $evalobj->get_max() . '</b><br>'.$average;
if (!api_is_allowed_to_edit()) {
$evalinfo .= $student_score;
}
if (!$evalobj->has_results()) {
$evalinfo .= '<br /><i>' . get_lang('NoResultsInEvaluation') . '</i>';
} elseif ($scoredisplay->is_custom() && api_get_self() != '/main/gradebook/gradebook_statistics.php') {
if (api_is_allowed_to_edit(null, true)) {
if ($page != 'statistics') {
if ($page != 'statistics') {
//$evalinfo .= '<br /><br /><a href="gradebook_view_result.php?selecteval='.Security::remove_XSS($_GET['selecteval']).'"> '.Display::return_icon(('evaluation_rate.png'),get_lang('ViewResult'),'',ICON_SIZE_MEDIUM) . '</a>';
}
}
}
if ($page != 'statistics') {
if ($page != 'statistics') {
if (api_is_allowed_to_edit(null, true)) {
$evalinfo .= '<br /><a href="gradebook_statistics.php?selecteval='.Security::remove_XSS($_GET['selecteval']).'"> '.Display::return_icon(('statistics.png'),get_lang('ViewStatistics'),'',ICON_SIZE_MEDIUM).'</a>';
}
}
$evalinfo .= '</td><td><img style="float:right; position:relative;" src="../img/tutorial.gif"></td></table>';
$evalinfo .= '</td><td><img style="float:right; position:relative;" src="../img/tutorial.gif"></td></table>';
echo $evalinfo;
echo $header;
}
/**
* Displays the header for the flatview page containing filters
* @param $catobj
@ -166,9 +166,9 @@ class DisplayGradebook
} else {
$select_cat = $catobj->get_parent_id();
$url = 'gradebook_flatview.php';
}
$header .= '<a href="'.$url.'?'.api_get_cidreq().'&selectcat='.$select_cat.'">'. Display::return_icon('back.png',get_lang('FolderView'),'',ICON_SIZE_MEDIUM).'</a>';
}
$header .= '<a href="'.$url.'?'.api_get_cidreq().'&selectcat='.$select_cat.'">'. Display::return_icon('back.png',get_lang('FolderView'),'',ICON_SIZE_MEDIUM).'</a>';
// this MUST be a GET variable not a POST
if (isset($_GET['show'])) {
@ -181,25 +181,25 @@ class DisplayGradebook
$header .= '<a href="' . api_get_self() . '?export_format=doc&export_report=export_report&selectcat=' . $catobj->get_id() . '">'.Display::return_icon('export_doc.png', get_lang('ExportAsDOC'),'',ICON_SIZE_MEDIUM).'</a>';
$header .= '<a href="' . api_get_self() . '?print=&selectcat=' . $catobj->get_id() . '" target="_blank">'.Display::return_icon('printer.png', get_lang('Print'),'',ICON_SIZE_MEDIUM).'</a>';
$header .= '<a href="' . api_get_self() . '?exportpdf=&selectcat=' . $catobj->get_id() . '" >'.Display::return_icon('pdf.png', get_lang('ExportToPDF'),'',ICON_SIZE_MEDIUM).'</a>';
$header .= '</div>';
$header .= '</div>';
echo $header;
}
}
function display_header_gradebook_per_gradebook($catobj, $showtree, $selectcat, $is_course_admin, $is_platform_admin, $simple_search_form, $show_add_qualification = true, $show_add_link = true) {
// Student
$status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
$objcat = new Category();
$course_id = Database::get_course_by_category($selectcat);
$message_resource=$objcat->show_message_resource_delete($course_id);
if (!$is_course_admin && $status<>1 && $selectcat<>0) {
$user_id = api_get_user_id();
$user= get_user_info_from_id($user_id);
$catcourse= Category :: load($catobj->get_id());
$scoredisplay = ScoreDisplay :: instance();
$scorecourse = $catcourse[0]->calc_score($user_id);
// generating the total score for a course
$allevals= $catcourse[0]->get_evaluations($user_id,true);
$alllinks= $catcourse[0]->get_links($user_id,true);
@ -211,23 +211,23 @@ class DisplayGradebook
$score = $item->calc_score($user_id);
$my_score_denom=($score[1]==0) ? 1 : $score[1];
$item_value+=$score[0]/$my_score_denom*$item->get_weight();
$item_total+=$item->get_weight();
$item_total+=$item->get_weight();
}
$item_value = number_format($item_value, 2, '.', ' ');
$total_score=array($item_value,$item_total);
$scorecourse_display = $scoredisplay->display_score($total_score, SCORE_DIV_PERCENT);
$cattotal = Category :: load(0);
$scoretotal= $cattotal[0]->calc_score(api_get_user_id());
$scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal, SCORE_PERCENT) : get_lang('NoResultsAvailable'));
$scoreinfo = get_lang('StatsStudent') . ' :<b> '.api_get_person_name($user['firstname'], $user['lastname']).'</b><br />';
if ((!$catobj->get_id() == '0') && (!isset ($_GET['studentoverview'])) && (!isset ($_GET['search']))) {
$scoreinfo.= '<h2>'.get_lang('Total') . ' : ' . $scorecourse_display . '</h2>';
}
}
Display :: display_normal_message($scoreinfo, false);
}
// show navigation tree and buttons?
// show navigation tree and buttons?
$header = '<div class="actions"><table border=0>';
if (($showtree == '1') || (isset ($_GET['studentoverview']))) {
$header .= '<tr>';
@ -237,10 +237,10 @@ class DisplayGradebook
$header .= '<td style=" ">' . get_lang('CurrentCategory') . '</td>' .
'<td style=" "><form name="selector"><select name="selectcat" onchange="document.selector.submit()">';
$cats= Category :: load();
$tree= $cats[0]->get_tree();
unset ($cats);
foreach ($tree as $cat) {
for ($i= 0; $i < $cat[2]; $i++) {
$line .= '&mdash;';
@ -274,20 +274,20 @@ class DisplayGradebook
$header .= '</td></tr>';
}
$header.='</table></div>';
// for course admin & platform admin add item buttons are added to the header
$header .= '<div class="actions">';
$my_category = $catobj->shows_all_information_an_category($catobj->get_id());
$user_id = api_get_user_id();
$course_code = $my_category['course_code'];
$status_user = api_get_status_of_user_in_course ($user_id,$course_code);
//$header .= '<a href="gradebook_add_cat.php?'.api_get_cidreq().'&selectcat=0"><img src="../img/folder_new.gif" alt="' . get_lang('AddGradebook') . '" /></a></td>';
if (api_is_allowed_to_edit(null, true)) {
if ($selectcat == '0') {
if ($show_add_qualification === true) {
if ($show_add_qualification === true) {
}
if ($show_add_link) {
//$header .= '<td><a href="gradebook_add_eval.php?'.api_get_cidreq().'"><img src="../img/filenew.gif" alt="' . get_lang('NewEvaluation') . '" /> ' . get_lang('NewEvaluation') . '</a>';
@ -307,45 +307,45 @@ class DisplayGradebook
if ($cats[0]->get_course_code() != null && !$message_resource) {
//$header .= '<td><a href="gradebook_add_link.php?'.api_get_cidreq().'&selectcat=' . $catobj->get_id() . '"><img src="../img/link.gif" alt="' . get_lang('MakeLink') . '" align="absmiddle" /> ' . get_lang('MakeLink') . '</a>';
//$header .= '<td><a href="gradebook_add_link.php?'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() . '">'.Display::return_icon('new_online_evaluation.png', get_lang('MakeLink'),'',ICON_SIZE_MEDIUM).'</a>';
} else {
// $header .= '<td><a href="gradebook_add_link_select_course.php?'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() . '">'.Display::return_icon('new_online_evaluation.png', get_lang('MakeLink'),'',ICON_SIZE_MEDIUM).'</a>';
}
}
if (!$message_resource) {
$myname = $catobj->shows_all_information_an_category($catobj->get_id());
$my_course_id=api_get_course_id();
$my_file= substr($_SESSION['gradebook_dest'],0,5);
$header .= '<td style="vertical-align: top;"><a href="gradebook_flatview.php?'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() . '">'.Display::return_icon('stats.png', get_lang('FlatView'),'',ICON_SIZE_MEDIUM).'</a>';
$header .= '<td style="vertical-align: top;"><a href="gradebook_display_certificate.php?'.$my_api_cidreq.'&amp;cat_id='.(int)$_GET['selectcat'].'">'.Display::return_icon('certificate_list.png', get_lang('GradebookSeeListOfStudentsCertificates'),'',ICON_SIZE_MEDIUM).'</a>';
$visibility_icon = ($catobj->is_visible() == 0) ? 'invisible' : 'visible';
$visibility_command = ($catobj->is_visible() == 0) ? 'set_visible' : 'set_invisible';
//Right icons
$modify_icons = '<a href="gradebook_edit_cat.php?editcat='.$catobj->get_id().'&cidReq='.$catobj->get_course_code().'">'.Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_MEDIUM).'</a>';
//$modify_icons .= '<a href="../document/document.php?curdirpath=/certificates&'.$my_api_cidreq.'&origin=gradebook&selectcat=' . $catobj->get_id() . '">'.
//Display::return_icon('certificate.png', get_lang('AttachCertificate'),'',ICON_SIZE_MEDIUM).'</a>';
//Display::return_icon('certificate.png', get_lang('AttachCertificate'),'',ICON_SIZE_MEDIUM).'</a>';
//hide or delete are not options available
//$modify_icons .= '&nbsp;<a href="' . api_get_self() . '?visiblecat=' . $catobj->get_id() . '&amp;' . $visibility_command . '=&amp;selectcat=0 ">'.Display::return_icon($visibility_icon.'.png', get_lang('Visible'),'',ICON_SIZE_MEDIUM).'</a>';
if ($catobj->get_name() != api_get_course_id()) {
$modify_icons .= '&nbsp;<a href="' . api_get_self() . '?deletecat=' . $catobj->get_id() . '&amp;selectcat=0&amp;cidReq='.$catobj->get_course_code().'" onclick="return confirmation();">'.Display::return_icon('delete.png', get_lang('DeleteAll'),'',ICON_SIZE_MEDIUM).'</a>';
}
}
$header .= Display::div($modify_icons, array('class'=>'right'));
}
}
} elseif (isset ($_GET['search'])) {
$header .= '<b>'.get_lang('SearchResults').' :</b>';
}
$header .= '</div>';
echo $header;
echo $header;
}
/**
* Displays the header for the gradebook containing the navigation tree and links
* @param category_object $currentcat
@ -356,21 +356,30 @@ class DisplayGradebook
* @param boolean Whether to show or not the link to add a new item inside the qualification (we hide it in case of the course-embedded tool where we have only one calification per course or session)
* @return void Everything is printed on screen upon closing
*/
static function display_header_gradebook($catobj, $showtree, $selectcat, $is_course_admin, $is_platform_admin, $simple_search_form, $show_add_qualification = true, $show_add_link = true) {
//student
static function display_header_gradebook(
$catobj,
$showtree,
$selectcat,
$is_course_admin,
$is_platform_admin,
$simple_search_form,
$show_add_qualification = true,
$show_add_link = true
) {
// Student.
$status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
$objcat = new Category();
$course_id = Database::get_course_by_category($selectcat);
$message_resource = $objcat->show_message_resource_delete($course_id);
$grade_model_id = $catobj->get_grade_model_id();
$header = null;
//@todo move these in a function
$sum_categories_weight_array = array();
if (isset($catobj) && !empty($catobj)) {
if (isset($catobj) && !empty($catobj)) {
$categories = Category::load(null, null, null, $catobj->get_id());
if (!empty($categories)) {
foreach ($categories as $category) {
foreach ($categories as $category) {
$sum_categories_weight_array[$category->get_id()] = $category->get_weight();
}
} else {
@ -382,30 +391,30 @@ class DisplayGradebook
$user_id = api_get_user_id();
$catcourse = Category::load($catobj->get_id());
$main_weight = $catcourse[0]->get_weight();
$scoredisplay = ScoreDisplay :: instance();
$scoredisplay = ScoreDisplay :: instance();
// generating the total score for a course
$allevals= $catcourse[0]->get_evaluations($user_id,true);
$alllinks= $catcourse[0]->get_links($user_id,true);
$evals_links = array_merge($allevals, $alllinks);
$item_value =0;
$item_total = 0;
$item_total_value = 0;
$item_total_value = 0;
for ($count=0; $count < count($evals_links); $count++) {
$item = $evals_links[$count];
$score = $item->calc_score($user_id);
$divide = ( ($score[1])==0 ) ? 1 : $score[1];
$sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()];
$sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()];
//$item_value = $score[0]/$divide;
$item_value = $score[0]/$divide*$item->get_weight()*$sub_cat_percentage/$main_weight;
$item_value_total +=$item_value;
}
}
$item_total = $main_weight;
$total_score = array($item_value_total, $item_total);
$total_score = array($item_value_total, $item_total);
$scorecourse_display = $scoredisplay->display_score($total_score, SCORE_DIV_PERCENT);
if ((!$catobj->get_id() == '0') && (!isset ($_GET['studentoverview'])) && (!isset ($_GET['search']))) {
@ -413,10 +422,10 @@ class DisplayGradebook
}
Display :: display_normal_message($scoreinfo, false);
}
// show navigation tree and buttons?
// show navigation tree and buttons?
if (($showtree == '1') || (isset ($_GET['studentoverview']))) {
$header = '<div class="actions"><table>';
$header = '<div class="actions"><table>';
$header .= '<tr>';
if (!$selectcat == '0') {
$header .= '<td><a href="' . api_get_self() . '?selectcat=' . $catobj->get_parent_id() . '">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('RootCat'),'',ICON_SIZE_MEDIUM).'</a></td>';
@ -425,14 +434,14 @@ class DisplayGradebook
'<td><form name="selector"><select name="selectcat" onchange="document.selector.submit()">';
$cats= Category :: load();
$tree= $cats[0]->get_tree();
$tree= $cats[0]->get_tree();
unset ($cats);
foreach ($tree as $cat) {
for ($i= 0; $i < $cat[2]; $i++) {
$line .= '&mdash;';
}
$line=isset($line) ? $line : '';
$line = isset($line) ? $line : '';
if (isset($_GET['selectcat']) && $_GET['selectcat'] == $cat[0]) {
$header .= '<option selected value=' . $cat[0] . '>' . $line . ' ' . $cat[1] . '</option>';
} else {
@ -461,25 +470,25 @@ class DisplayGradebook
}
$header .= '</td></tr>';
$header.='</table></div>';
}
}
// for course admin & platform admin add item buttons are added to the header
$header .= '<div class="actions">';
$my_category = $catobj->shows_all_information_an_category($catobj->get_id());
$user_id = api_get_user_id();
//$course_code = $my_category['course_code'];
//$course_code = $my_category['course_code'];
//$status_user = api_get_status_of_user_in_course ($user_id,$course_code);
if (api_is_allowed_to_edit(null, true)) {
if (empty($grade_model_id) || $grade_model_id == -1) {
$header .= '<a href="gradebook_add_cat.php?'.api_get_cidreq().'&selectcat='.$catobj->get_id().'">'.Display::return_icon('new_folder.png', get_lang('AddGradebook'), array(), ICON_SIZE_MEDIUM).'</a></td>';
$header .= '<a href="gradebook_add_cat.php?'.api_get_cidreq().'&selectcat='.$catobj->get_id().'">'.Display::return_icon('new_folder.png', get_lang('AddGradebook'), array(), ICON_SIZE_MEDIUM).'</a></td>';
}
if ($selectcat == '0') {
if ($show_add_qualification === true) {
if ($show_add_qualification === true) {
}
if ($show_add_link) {
//$header .= '<td><a href="gradebook_add_eval.php?'.api_get_cidreq().'"><img src="../img/filenew.gif" alt="' . get_lang('NewEvaluation') . '" /> ' . get_lang('NewEvaluation') . '</a>';
@ -489,14 +498,14 @@ class DisplayGradebook
//$header .= '<a href="gradebook_add_cat.php?'.api_get_cidreq().'&selectcat=' . $catobj->get_id() . '" ><img src="../img/folder_new.gif" alt="' . get_lang('NewSubCategory') . '" align="absmiddle" /> ' . get_lang('NewSubCategory') . '</a></td>';
}
$my_category = $catobj->shows_all_information_an_category($catobj->get_id());
$my_api_cidreq = api_get_cidreq();
if ($my_api_cidreq=='') {
$my_api_cidreq='cidReq='.$my_category['course_code'];
}
if ($show_add_link && !$message_resource) {
$header .= '<td><a href="gradebook_add_eval.php?'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() . '" >'.Display::return_icon('new_evaluation.png', get_lang('NewEvaluation'),'',ICON_SIZE_MEDIUM).'</a>';
$cats = Category :: load($selectcat);
$cats = Category :: load($selectcat);
if ($cats[0]->get_course_code() != null && !$message_resource) {
//$header .= '<td><a href="gradebook_add_link.php?'.api_get_cidreq().'&selectcat=' . $catobj->get_id() . '"><img src="../img/link.gif" alt="' . get_lang('MakeLink') . '" align="absmiddle" /> ' . get_lang('MakeLink') . '</a>';
$header .= '<td><a href="gradebook_add_link.php?'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() . '">'.Display::return_icon('new_online_evaluation.png', get_lang('MakeLink'),'',ICON_SIZE_MEDIUM).'</a>';
@ -507,50 +516,50 @@ class DisplayGradebook
if (!$message_resource) {
//$myname = $catobj->shows_all_information_an_category($catobj->get_id());
//$my_course_id=api_get_course_id();
//$my_file= substr($_SESSION['gradebook_dest'],0,5);
$header .= '<td style="vertical-align: top;"><a href="gradebook_flatview.php?'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() . '">'.Display::return_icon('stats.png', get_lang('FlatView'),'',ICON_SIZE_MEDIUM).'</a>';
$header .= '<td style="vertical-align: top;"><a href="gradebook_flatview.php?'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() . '">'.Display::return_icon('stats.png', get_lang('FlatView'),'',ICON_SIZE_MEDIUM).'</a>';
$header .= '<td style="vertical-align: top;"><a href="gradebook_display_certificate.php?'.$my_api_cidreq.'&amp;cat_id='.(int)$_GET['selectcat'].'">'.Display::return_icon('certificate_list.png', get_lang('GradebookSeeListOfStudentsCertificates'),'',ICON_SIZE_MEDIUM).'</a>';
//$visibility_icon = ($catobj->is_visible() == 0) ? 'invisible' : 'visible';
//$visibility_command = ($catobj->is_visible() == 0) ? 'set_visible' : 'set_invisible';
//Right icons
$modify_icons = '<a href="gradebook_edit_cat.php?editcat='.$catobj->get_id().'&amp;cidReq='.$catobj->get_course_code().'">'.Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_MEDIUM).'</a>';
$modify_icons .= '<a href="../document/document.php?curdirpath=/certificates&'.$my_api_cidreq.'&origin=gradebook&selectcat=' . $catobj->get_id() . '">'.
Display::return_icon('certificate.png', get_lang('AttachCertificate'),'',ICON_SIZE_MEDIUM).'</a>';
if (empty($categories)) {
$modify_icons .= '<a href="gradebook_edit_all.php?id_session='.api_get_session_id().'&amp;'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() . '">'.Display::return_icon('percentage.png', get_lang('EditAllWeights'),'',ICON_SIZE_MEDIUM).'</a>';
}
}
$score_display_custom = api_get_setting('gradebook_score_display_custom');
if (api_get_setting('teachers_can_change_score_settings') == 'true' && $score_display_custom['my_display_custom'] == 'true') {
$modify_icons .= '<a href="gradebook_scoring_system.php?'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() .'">'.Display::return_icon('ranking.png', get_lang('ScoreEdit'),'',ICON_SIZE_MEDIUM).'</a>';
}
$header .= Display::div($modify_icons, array('class'=>'right'));
$header .= Display::div($modify_icons, array('class'=>'right'));
}
}
} elseif (isset ($_GET['search'])) {
$header .= '<b>'.get_lang('SearchResults').' :</b>';
}
$header .= '</div>';
echo $header;
echo $header;
if (api_is_allowed_to_edit(null, true)) {
$weight = ((intval($catobj->get_weight())>0) ? $catobj->get_weight() : 0);
$weight = ((intval($catobj->get_weight())>0) ? $catobj->get_weight() : 0);
$weight = get_lang('TotalWeight').' : '.$weight;
$min_certification = (intval($catobj->get_certificate_min_score()>0) ? $catobj->get_certificate_min_score() : 0);
$min_certification = get_lang('CertificateMinScore').' : '.$min_certification;
$edit_icon = '<a class="right_link" href="gradebook_edit_cat.php?editcat='.$catobj->get_id().'&amp;cidReq='.$catobj->get_course_code().'">'.Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
//$msg = Display::tag('h3', $weight.' - '.$min_certification);
$msg = Display::tag('h4', $weight.' - '.$min_certification.$edit_icon);
//@todo show description
$description = (($catobj->get_description() == "" || is_null($catobj->get_description())) ? '' : '<strong>'.get_lang('GradebookDescriptionLog').'</strong>'.': '.$catobj->get_description());
$description = (($catobj->get_description() == "" || is_null($catobj->get_description())) ? '' : '<strong>'.get_lang('GradebookDescriptionLog').'</strong>'.': '.$catobj->get_description());
Display::display_normal_message($msg, false);
if (!empty($description)) {
echo Display::div($description, array());
@ -617,7 +626,7 @@ class DisplayGradebook
$item_value = number_format($item_value, 2, '.', ' ');
$total_score=array($item_value,$item_total);
$scorecourse_display = $scoredisplay->display_score($total_score,SCORE_DIV_PERCENT);
//$scorecourse_display = (isset($scorecourse) ? $scoredisplay->display_score($scorecourse,SCORE_AVERAGE) : get_lang('NoResultsAvailable'));
$cattotal = Category :: load(0);
$scoretotal= $cattotal[0]->calc_score($user_id);
@ -633,16 +642,16 @@ class DisplayGradebook
//limit display width to 200px
$img_attributes .= 'width="200" ';
}
$info = '<div class="row"><div class="span3">';
$info = '<div class="row"><div class="span3">';
$info .= '<div class="thumbnail"><img ' . $img_attributes . '/></div>';
$info .= '</div>';
$info .= '</div>';
$info .= '<div class="span6">';
$info .= get_lang('Name') . ' : <a target="_blank" href="'.api_get_path(WEB_CODE_PATH).'social/profile.php?u=' . $userid . '"> ' . api_get_person_name($user['firstname'], $user['lastname']) . '</a><br />';
if (api_get_setting('show_email_addresses') == 'true') {
$info .= get_lang('Email') . ' : <a href="mailto:' . $user['email'] . '">' . $user['email'] . '</a><br />';
}
$info .= get_lang('TotalUser') . ' : <b>' . $scorecourse_display . '</b>';
$info .= '</div>';
$info .= '</div>';
@ -651,6 +660,6 @@ class DisplayGradebook
//$scoreinfo.= '<br />'.get_lang('Total') . ' : <b>' . $scorecourse_display . '</b>';
//$scoreinfo.= '<br />'.get_lang('Total') . ' : <b>' . $scoretotal_display . '</b>';
echo $info;
echo $info;
}
}

@ -17,8 +17,8 @@ require_once dirname(__FILE__).'/../be.inc.php';
* @author Bert Steppé (refactored, optimised)
* @package chamilo.gradebook
*/
class GradebookTable extends SortableTable {
class GradebookTable extends SortableTable
{
private $currentcat;
private $datagen;
private $evals_links;
@ -27,26 +27,26 @@ class GradebookTable extends SortableTable {
/**
* Constructor
*/
function GradebookTable ($currentcat, $cats = array(), $evals = array(), $links = array(), $addparams = null) {
//$status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
parent :: __construct ('gradebooklist', null, null, (api_is_allowed_to_edit()?1:0));
function GradebookTable ($currentcat, $cats = array(), $evals = array(), $links = array(), $addparams = null)
{
parent::__construct ('gradebooklist', null, null, (api_is_allowed_to_edit()?1:0));
$this->evals_links = array_merge($evals, $links);
$this->currentcat = $currentcat;
$this->cats = $cats;
$this->datagen = new GradebookDataGenerator($cats, $evals, $links);
$this->cats = $cats;
$this->datagen = new GradebookDataGenerator($cats, $evals, $links);
if (isset($addparams)) {
$this->set_additional_parameters($addparams);
}
$column= 0;
if (api_is_allowed_to_edit(null, true)) {
$this->set_header($column++,'','','width="25px"');
}
$this->set_header($column++, get_lang('Type'),'','width="35px"');
$this->set_header($column++, get_lang('Name'), false);
$this->set_header($column++, get_lang('Description'), false);
if (api_is_allowed_to_edit(null, true)) {
@ -54,26 +54,21 @@ class GradebookTable extends SortableTable {
} else {
$this->set_header($column++, get_lang('Weight'), false);
$this->set_header($column++, get_lang('Result'), false);
if (!empty($cats)) {
$this->set_header($column++, get_lang('Actions'), false);
}
}
}
//Desactivates the odd/even alt rows in order that the +/- buttons work see #4047
// Deactivates the odd/even alt rows in order that the +/- buttons work see #4047
$this->odd_even_rows_enabled = false;
/*if (api_is_allowed_to_edit(null, true)) {
//$this->set_header($column++, get_lang('CreationDate'),true, 'width="100px"');
} elseif (($status<>1) && !api_is_allowed_to_edit() && (!isset($_GET['selectcat']) || $_GET['selectcat']==0)) {
//$this->set_header($column++, get_lang('Date'),true, 'width="100px"');
}*/
//admins get an edit column
// Admins get an edit column.
if (api_is_allowed_to_edit(null, true)) {
$this->set_header($column++, get_lang('Modify'), false, 'width="195px"');
//actions on multiple selected documents
$this->set_form_actions(array (
// Actions on multiple selected documents.
$this->set_form_actions(array (
'setvisible' => get_lang('SetVisible'),
'setinvisible' => get_lang('SetInvisible'),
'deleted' => get_lang('DeleteSelected')
@ -82,38 +77,49 @@ class GradebookTable extends SortableTable {
if (empty($_GET['selectcat']) && !api_is_allowed_to_edit()) {
$this->set_header($column++, get_lang('Certificates'),false);
} else {
//$evals_links = array_merge($evals, $links);
//$evals_links = array_merge($evals, $links);
//if (count($evals_links)>0) {
//$this->set_header($column++, get_lang('Results'), false);
//}
}
}
}
function get_data() {
/**
* @return GradebookDataGenerator
*/
function get_data()
{
return $this->datagen;
}
/**
* Function used by SortableTable to get total number of items in the table
* @return int
*/
function get_total_number_of_items() {
function get_total_number_of_items()
{
return $this->datagen->get_total_items_count();
}
/**
* Function used by SortableTable to generate the data to display
* @param int $from
* @param int $per_page
* @param int $column
* @param string $direction
* @param int $sort
* @return array|mixed
*/
function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null) {
function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null)
{
//variables load in index.php
global $my_score_in_gradebook, $certificate_min_score;
$scoretotal = 0;
global $certificate_min_score;
// determine sorting type
$col_adjust = (api_is_allowed_to_edit() ? 1 : 0);
// By id
// By id
$this->column = 5;
switch ($this->column) {
// Type
case (0 + $col_adjust) :
@ -130,204 +136,182 @@ class GradebookTable extends SortableTable {
break;
case (4 + $col_adjust) :
$sorting = GradebookDataGenerator :: GDG_SORT_DATE;
case (5 + $col_adjust) :
$sorting = GradebookDataGenerator :: GDG_SORT_ID;
case (5 + $col_adjust) :
$sorting = GradebookDataGenerator :: GDG_SORT_ID;
break;
}
if ($this->direction == 'DESC') {
$sorting |= GradebookDataGenerator :: GDG_SORT_DESC;
} else {
$sorting |= GradebookDataGenerator :: GDG_SORT_ASC;
}
//status of user in course
// Status of user in course.
$user_id = api_get_user_id();
$course_code = api_get_course_id();
$session_id = api_get_session_id();
$status_user = api_get_status_of_user_in_course($user_id, $course_code);
$data_array = $this->datagen->get_data($sorting, $from, $this->per_page);
$data_array = $this->datagen->get_data($sorting, $from, $this->per_page);
// generate the data to display
$sortable_data = array();
$weight_total_links = 0;
$main_categories = array();
$main_cat = Category :: load(null, null, $course_code, null, null, $session_id, false);
$total_categories_weight = 0;
$main_categories = array();
$main_cat = Category::load(null, null, $course_code, null, null, $session_id, false);
$total_categories_weight = 0;
$scoredisplay = ScoreDisplay :: instance();
//Categories
// Categories.
foreach ($data_array as $data) {
// list of items inside the gradebook (exercises, lps, forums, etc)
$row = array();
$item = $item_category = $data[0];
$id = $item->get_id();
//if the item is invisible, wrap it in a span with class invisible
$invisibility_span_open = (api_is_allowed_to_edit() && $item->is_visible() == '0') ? '<span class="invisible">' : '';
$invisibility_span_close = (api_is_allowed_to_edit() && $item->is_visible() == '0') ? '</span>' : '';
// Id
if (api_is_allowed_to_edit(null, true)) {
//id
$row[] = $this->build_id_column($item);
}
//Type
// Type.
$row[] = $this->build_type_column($item);
//Name
// Name.
if (get_class($item) == 'Category') {
$row[] = $invisibility_span_open.'<h3>'.$item->get_name().'</h3>'.$invisibility_span_close;
$main_categories[$item->get_id()]['name'] = $item->get_name();
$main_categories[$item->get_id()]['name'] = $item->get_name();
} else {
$row[] = $invisibility_span_open.$this->build_name_link($item) . $invisibility_span_close;
$main_categories[$item->get_id()]['name'] = $this->build_name_link($item);
$main_categories[$item->get_id()]['name'] = $this->build_name_link($item);
}
$main_categories[$item->get_id()]['weight']= $item->get_weight();
$total_categories_weight += $item->get_weight();
//Description
$row[] = $invisibility_span_open.$data[2].$invisibility_span_close;
//Weight
//$row[] = $invisibility_span_open .Display::tag('h4', $data['3'] .' / '.$this->currentcat->get_weight()).$invisibility_span_close;
//$average = $data['3']/$this->currentcat->get_weight()*100;
// Description.
$row[] = $invisibility_span_open.$data[2].$invisibility_span_close;
// Weight.
$average = $scoredisplay->display_score(array($data['3'], $this->currentcat->get_weight()), SCORE_SIMPLE, SCORE_BOTH, true);
if (api_is_allowed_to_edit(null, true)) {
$row[] = $invisibility_span_open .Display::tag('h4', $average).$invisibility_span_close;
$row[] = $invisibility_span_open .Display::tag('h4', $average).$invisibility_span_close;
} else {
$row[] = $invisibility_span_open .$average.$invisibility_span_close;
$row[] = $invisibility_span_open .$average.$invisibility_span_close;
}
$category_weight = $item->get_weight();
if (api_is_allowed_to_edit(null, true)) {
$weight_total_links += $data[3];
} else {
$cattotal = Category :: load($_GET['selectcat']);
$scoretotal = $cattotal[0]->calc_score(api_get_user_id());
$scoretotal = $cattotal[0]->calc_score(api_get_user_id());
$item_value = $scoredisplay->display_score($scoretotal, SCORE_SIMPLE);
}
//Date
//$row[] = $invisibility_span_open.$data[4].$invisibility_span_close;
//Edit (for admins)
// Edit (for admins).
if (api_is_allowed_to_edit(null, true)) {
$cat = new Category();
$show_message = $cat->show_message_resource_delete($item->get_course_code());
if ($show_message === false) {
$row[] = $this->build_edit_column($item);
$row[] = $this->build_edit_column($item);
}
} else {
//students get the results and certificates columns
if (count($this->evals_links) > 0 && $status_user != 1) {
$value_data = isset($data[4]) ? $data[4] : null;
if (!is_null($value_data)) {
//students get the results and certificates columns
if (count($this->evals_links) > 0 && $status_user != 1) {
$value_data = isset($data[4]) ? $data[4] : null;
if (!is_null($value_data)) {
$row[] = Display::tag('h4', $value_data);
} else {
$row[] = $this->build_edit_column($item);
} else {
$row[] = $this->build_edit_column($item);
}
} else {
$score = $item->calc_score(api_get_user_id());
} else {
$score = $item->calc_score(api_get_user_id());
if (!empty($score[1])) {
$complete_score = $scoredisplay->display_score($score, SCORE_DIV_PERCENT);
$score = $score[0]/$score[1]*$item->get_weight();
$score = $score[0]/$score[1]*$item->get_weight();
$score = $scoredisplay->display_score(array($score, null), SCORE_SIMPLE);
$row[] = Display::tip($score, $complete_score);
} else {
$row[] = '-';
}
if (!empty($this->cats)) {
$row[] = $this->build_edit_column($item);
}
}
}
//Category added
// Category added.
$sortable_data[] = $row;
// Loading childrens
// Loading children
if (get_class($item) == 'Category') {
$stud_id = api_get_user_id();
$course_code = api_get_course_id();
$session_id = api_get_session_id();
$session_id = api_get_session_id();
$parent_id = $item->get_id();
$cats = Category :: load ($parent_id, null, null, null, null, null);
$allcat = $cats[0]->get_subcategories($stud_id, $course_code, $session_id);
$alleval = $cats[0]->get_evaluations($stud_id);
$cats = Category::load($parent_id, null, null, null, null, null);
$allcat = $cats[0]->get_subcategories($stud_id, $course_code, $session_id);
$alleval = $cats[0]->get_evaluations($stud_id);
$alllink = $cats[0]->get_links($stud_id);
$sub_cat_info = new GradebookDataGenerator($allcat, $alleval, $alllink);
$data_array = $sub_cat_info->get_data($sorting, $from, $this->per_page);
$data_array = $sub_cat_info->get_data($sorting, $from, $this->per_page);
$total_weight = 0;
//Links
// Links.
foreach ($data_array as $data) {
$row = array();
$item = $data[0];
$id = $item->get_id();
//if the item is invisible, wrap it in a span with class invisible
$invisibility_span_open = (api_is_allowed_to_edit() && $item->is_visible() == '0') ? '<span class="invisible">' : '';
$invisibility_span_close = (api_is_allowed_to_edit() && $item->is_visible() == '0') ? '</span>' : '';
$invisibility_span_close = (api_is_allowed_to_edit() && $item->is_visible() == '0') ? '</span>' : '';
$main_categories[$parent_id]['children'][$item->get_id()]['name'] = $item->get_name();
$main_categories[$parent_id]['children'][$item->get_id()]['weight'] = $item->get_weight();
if (api_is_allowed_to_edit(null, true)) {
$row[] = $this->build_id_column($item);
}
$row[] = $this->build_type_column($item, array('style' => 'padding-left:5px'));
//Name
// Name.
$row[] = $invisibility_span_open."&nbsp;&nbsp;&nbsp; ".$this->build_name_link($item) . $invisibility_span_close;
//Description
$row[] = $invisibility_span_open.$data[2].$invisibility_span_close;
//Weight
//$weight = $data[3]/$category_weight*$main_cat[0]->get_weight();
/*$weight = $category_weight * $data[3] / $main_cat[0]->get_weight();
$weight = $main_cat[0]->get_weight()*$weight/$category_weight;*/
// Description.
$row[] = $invisibility_span_open.$data[2].$invisibility_span_close;
$weight = $data[3];
//$extra = " - $data[3] $category_weight -".$main_cat[0]->get_weight();
$total_weight += $weight;
$row[] = $invisibility_span_open.$weight.$extra.$invisibility_span_close;
if (api_is_allowed_to_edit(null, true)) {
$row[] = $invisibility_span_open.$weight.$invisibility_span_close;
if (api_is_allowed_to_edit(null, true)) {
//$weight_total_links += intval($data[3]);
} else {
$cattotal = Category :: load($_GET['selectcat']);
$scoretotal = $cattotal[0]->calc_score(api_get_user_id());
$item_value = $scoretotal[0];
$cattotal = Category::load($_GET['selectcat']);
$scoretotal = $cattotal[0]->calc_score(api_get_user_id());
$item_value = $scoretotal[0];
}
//Date
//$row[] = $invisibility_span_open.$data[4].$invisibility_span_close;
//Admins get an edit column
// Admins get an edit column.
if (api_is_allowed_to_edit(null, true)) {
$cat = new Category();
$show_message = $cat->show_message_resource_delete($item->get_course_code());
@ -355,7 +339,7 @@ class GradebookTable extends SortableTable {
$sortable_data[] = $row;
}
//"Warning row"
// "Warning row"
if (!empty($data_array)) {
if (api_is_allowed_to_edit()) {
// Compare the category weight to the sum of all weights inside the category
@ -366,7 +350,14 @@ class GradebookTable extends SortableTable {
$label = Display::return_icon('warning.png', sprintf(get_lang('TotalWeightMustBeX'), $category_weight) );
$total = Display::badge($total_weight.' / '.$category_weight, 'warning');
}
$row = array(null, null, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<h5>".get_lang('SubTotal').'</h5>',null, $total.' '.$label, 'child_of' =>$parent_id);
$row = array(
null,
null,
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<h5>".get_lang('SubTotal').'</h5>',
null,
$total.' '.$label,
'child_of' => $parent_id
);
$sortable_data[] = $row;
}
}
@ -376,6 +367,7 @@ class GradebookTable extends SortableTable {
if (api_is_allowed_to_edit()) {
if (count($main_cat) > 1) {
$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'));
} else {
@ -393,12 +385,15 @@ class GradebookTable extends SortableTable {
if (isset($_GET['selectcat']) && $_GET['selectcat'] > 0 && $view <> 'presence') {
$id_cat = intval($_GET['selectcat']);
$category = Category :: load($id_cat);
//$weight_category = intval($this->build_weight($category[0]));
$weight_category = intval($this->build_weight($category[0]));
$course_code = $this->build_course_code($category[0]);
$weight_total_links = round($weight_total_links);
if ($weight_total_links > $weight_category || $weight_total_links < $weight_category || $weight_total_links > $weight_category) {
if ($weight_total_links > $weight_category ||
$weight_total_links < $weight_category ||
$weight_total_links > $weight_category
) {
$warning_message = sprintf(get_lang('TotalWeightMustBeX'), $weight_category);
$modify_icons = '<a class="right_link" href="gradebook_edit_cat.php?editcat='.$id_cat.'&cidReq='.$course_code.'">'.Display::return_icon('edit.png', $warning_message, array(), ICON_SIZE_SMALL).'</a>';
$warning_message .= $modify_icons;
@ -454,25 +449,29 @@ class GradebookTable extends SortableTable {
}
}
}
}
}
return $sortable_data;
}
// Other functions
private function build_certificate_min_score ($item) {
private function build_certificate_min_score ($item)
{
return $item->get_certificate_min_score();
}
private function build_weight ($item) {
private function build_weight ($item)
{
return $item->get_weight();
}
private function build_course_code ($item) {
private function build_course_code ($item)
{
return $item->get_course_code();
}
private function build_id_column ($item) {
private function build_id_column ($item)
{
switch ($item->get_item_type()) {
// category
case 'C' :
@ -486,18 +485,19 @@ class GradebookTable extends SortableTable {
}
}
private function build_type_column ($item, $attributes = array()) {
private function build_type_column ($item, $attributes = array())
{
return build_type_icon_tag($item->get_icon_name(), $attributes);
}
/**
*
*
* Generate name column
* @param unknown_type $item
* @return string
*/
private function build_name_link ($item) {
//$session_id = api_get_session_id();
private function build_name_link ($item)
{
switch ($item->get_item_type()) {
// category
case 'C' :
@ -511,16 +511,15 @@ class GradebookTable extends SortableTable {
$cat = new Category();
$show_message=$cat->show_message_resource_delete($item->get_course_code());
return '&nbsp;<a href="'.Security::remove_XSS($_SESSION['gradebook_dest']).$prms_uri.'">'
. $item->get_name()
. '</a>'
. ($item->is_course() ? ' &nbsp;[' . $item->get_course_code() . ']'.$show_message : '');
// evaluation
case 'E' :
$cat = new Category();
$cat = new Category();
$course_id = Database::get_course_by_category($_GET['selectcat']);
$show_message = $cat->show_message_resource_delete($course_id);
// course/platform admin can go to the view_results page
@ -530,7 +529,7 @@ class GradebookTable extends SortableTable {
return '&nbsp;'
. '<a href="gradebook_view_result.php?cidReq='.$course_id.'&amp;selecteval=' . $item->get_id() . '">'
. $item->get_name()
. '</a>';
. '</a>';
} else {
return '&nbsp;'
. '<a href="gradebook_view_result.php?cidReq='.$course_id.'&amp;selecteval=' . $item->get_id() . '">'
@ -555,13 +554,13 @@ class GradebookTable extends SortableTable {
}
// link
case 'L' :
$cat = new Category();
$course_id = Database::get_course_by_category($_GET['selectcat']);
$show_message = $cat->show_message_resource_delete($course_id);
$cat = new Category();
$course_id = Database::get_course_by_category($_GET['selectcat']);
$show_message = $cat->show_message_resource_delete($course_id);
$url = $item->get_link();
if (isset($url) && $show_message===false) {
if (isset($url) && $show_message===false) {
$text = '&nbsp;<a href="' . $item->get_link() . '">'
. $item->get_name()
. '</a>';
@ -577,8 +576,9 @@ class GradebookTable extends SortableTable {
return $text;
}
}
private function build_edit_column($item) {
private function build_edit_column($item)
{
switch ($item->get_item_type()) {
// category
case 'C' :

@ -199,11 +199,12 @@ function get_icon_file_name($type) {
* @param object $cat category object
* @param int $selectcat id of selected category
*/
function build_edit_icons_cat($cat, $selectcat) {
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';
@ -258,6 +259,7 @@ function build_edit_icons_cat($cat, $selectcat) {
$modify_icons .= '&nbsp;<a href="' . api_get_self() . '?deletecat=' . $cat->get_id() . '&amp;selectcat=' . $selectcat . '&amp;cidReq=' . $cat->get_course_code() . '" onclick="return confirmation();">' . Display::return_icon('delete.png', get_lang('DeleteAll'), '', ICON_SIZE_SMALL) . '</a>';
}
}
return $modify_icons;
}
}

@ -56,31 +56,32 @@ if (!in_array(
// Search features
$ops = array (
'eq' => '=', //equal
'ne' => '<>', //not equal
'lt' => '<', //less than
'le' => '<=', //less than or equal
'gt' => '>', //greater than
'ge' => '>=', //greater than or equal
'bw' => 'LIKE', //begins with
'bn' => 'NOT LIKE', //doesn't begin with
'in' => 'LIKE', //is in
'ni' => 'NOT LIKE', //is not in
'ew' => 'LIKE', //ends with
'en' => 'NOT LIKE', //doesn't end with
'cn' => 'LIKE', //contains
'nc' => 'NOT LIKE' //doesn't contain
);
//@todo move this in the display_class or somewhere else
function get_where_clause($col, $oper, $val)
function getWhereClause($col, $oper, $val)
{
global $ops;
$ops = array(
'eq' => '=', //equal
'ne' => '<>', //not equal
'lt' => '<', //less than
'le' => '<=', //less than or equal
'gt' => '>', //greater than
'ge' => '>=', //greater than or equal
'bw' => 'LIKE', //begins with
'bn' => 'NOT LIKE', //doesn't begin with
'in' => 'LIKE', //is in
'ni' => 'NOT LIKE', //is not in
'ew' => 'LIKE', //ends with
'en' => 'NOT LIKE', //doesn't end with
'cn' => 'LIKE', //contains
'nc' => 'NOT LIKE' //doesn't contain
);
if (empty($col)) {
return '';
}
if ($oper == 'bw' || $oper == 'bn') {
$val .= '%';
}
@ -91,39 +92,41 @@ function get_where_clause($col, $oper, $val)
$val = '%'.$val.'%';
}
$val = Database::escape_string($val);
return " $col {$ops[$oper]} '$val' ";
}
$where_condition = ""; //if there is no search request sent by jqgrid, $where should be empty
$operation = isset($_REQUEST['oper']) ? $_REQUEST['oper'] : false;
$export_format = isset($_REQUEST['export_format']) ? $_REQUEST['export_format'] : 'csv';
$search_field = isset($_REQUEST['searchField']) ? $_REQUEST['searchField'] : false;
$search_oper = isset($_REQUEST['searchOper']) ? $_REQUEST['searchOper'] : false;
$search_string = isset($_REQUEST['searchString']) ? $_REQUEST['searchString'] : false;
if ($_REQUEST['_search'] == 'true') {
$where_condition = ' 1 = 1 ';
$where_condition_in_form = get_where_clause($search_field, $search_oper, $search_string);
if (!empty($where_condition_in_form)) {
$where_condition .= ' AND '.$where_condition_in_form;
// If there is no search request sent by jqgrid, $where should be empty
$whereCondition = null;
$operation = isset($_REQUEST['oper']) ? $_REQUEST['oper'] : false;
$exportFormat = isset($_REQUEST['export_format']) ? $_REQUEST['export_format'] : 'csv';
$searchField = isset($_REQUEST['searchField']) ? $_REQUEST['searchField'] : false;
$searchOperator = isset($_REQUEST['searchOper']) ? $_REQUEST['searchOper'] : false;
$searchString = isset($_REQUEST['searchString']) ? $_REQUEST['searchString'] : false;
$search = isset($_REQUEST['_search']) ? $_REQUEST['_search'] : false;
$forceSearch = isset($_REQUEST['_force_search']) ? $_REQUEST['_force_search'] : false;
if ($search || $forceSearch) {
$whereConditionInForm = getWhereClause($searchField, $searchOperator, $searchString);
if (!empty($whereConditionInForm)) {
$whereCondition .= ' AND '.$whereConditionInForm;
}
$filters = isset($_REQUEST['filters']) ? json_decode($_REQUEST['filters']) : false;
if (!empty($filters)) {
$where_condition .= ' AND ( ';
$whereCondition .= ' AND ( ';
$counter = 0;
foreach ($filters->rules as $key => $rule) {
$where_condition .= get_where_clause($rule->field, $rule->op, $rule->data);
$whereCondition .= getWhereClause($rule->field, $rule->op, $rule->data);
if ($counter < count($filters->rules) -1) {
$where_condition .= $filters->groupOp;
$whereCondition .= $filters->groupOp;
}
$counter++;
}
$where_condition .= ' ) ';
$whereCondition .= ' ) ';
}
}
@ -180,11 +183,11 @@ switch ($action) {
break;
case 'get_work_teacher':
require_once api_get_path(SYS_CODE_PATH).'work/work.lib.php';
$count = getWorkListTeacher(0, $limit, $sidx, $sord, $where_condition, true);
$count = getWorkListTeacher(0, $limit, $sidx, $sord, $whereCondition, true);
break;
case 'get_work_student':
require_once api_get_path(SYS_CODE_PATH).'work/work.lib.php';
$count = getWorkListStudent(0, $limit, $sidx, $sord, $where_condition, true);
$count = getWorkListStudent(0, $limit, $sidx, $sord, $whereCondition, true);
break;
case 'get_work_user_list_all':
@ -204,8 +207,17 @@ switch ($action) {
$documents = getAllDocumentToWork($work_id, api_get_course_int_id());
if (empty($documents)) {
$where_condition .= " AND u.user_id = ".api_get_user_id();
$count = get_work_user_list(0, $limit, $sidx, $sord, $work_id, $where_condition, null, true);
$whereCondition .= " AND u.user_id = ".api_get_user_id();
$count = get_work_user_list(
0,
$limit,
$sidx,
$sord,
$work_id,
$whereCondition,
null,
true
);
} else {
$count = get_work_user_list_from_documents(
0,
@ -214,7 +226,7 @@ switch ($action) {
$sord,
$work_id,
api_get_user_id(),
$where_condition,
$whereCondition,
true
);
}
@ -232,8 +244,8 @@ switch ($action) {
api_get_group_id(),
0,
$limit,
$sidx,
$sord,
null,
null,
true
);
break;
@ -243,13 +255,9 @@ switch ($action) {
if (isset($_GET['filter_by_user']) && !empty($_GET['filter_by_user'])) {
$filter_user = intval($_GET['filter_by_user']);
if ($where_condition == "") {
$where_condition .= " te.exe_user_id = '$filter_user'" ;
} else {
$where_condition .= " AND te.exe_user_id = '$filter_user'";
}
$whereCondition .= " AND te.exe_user_id = '$filter_user'";
}
$count = get_count_exam_results($exercise_id, $where_condition);
$count = get_count_exam_results($exercise_id, $whereCondition);
break;
case 'get_hotpotatoes_exercise_results':
require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php';
@ -267,9 +275,9 @@ switch ($action) {
case 'get_sessions':
$courseId = isset($_GET['course_id']) && !empty($_GET['course_id']) ? intval($_GET['course_id']) : null;
if (!empty($courseId)) {
$where_condition .= " c.id = $courseId";
$whereCondition .= " AND c.id = $courseId";
}
$count = SessionManager::get_count_admin($where_condition);
$count = SessionManager::get_count_admin($whereCondition);
break;
case 'get_session_lp_progress':
case 'get_session_progress':
@ -377,7 +385,7 @@ $columns = array();
switch ($action) {
case 'get_course_exercise_medias':
$columns = array('question');
$result = Question::get_course_medias($course_id, $start, $limit, $sidx, $sord, $where_condition);
$result = Question::get_course_medias($course_id, $start, $limit, $sidx, $sord, $whereCondition);
break;
case 'get_user_course_report_resumed':
$columns = array(
@ -470,7 +478,7 @@ switch ($action) {
break;
case 'get_user_skill_ranking':
$columns = array('photo', 'firstname', 'lastname', 'skills_acquired', 'currently_learning', 'rank');
$result = $skill->get_user_list_skill_ranking($start, $limit, $sidx, $sord, $where_condition);
$result = $skill->get_user_list_skill_ranking($start, $limit, $sidx, $sord, $whereCondition);
$result = msort($result, 'skills_acquired', 'asc');
$skills_in_course = array();
@ -493,12 +501,13 @@ switch ($action) {
}
break;
case 'get_work_teacher':
$columns = array('type', 'title', 'sent_date', 'expires_on', 'ends_on', 'actions');
$result = getWorkListTeacher($start, $limit, $sidx, $sord, $where_condition);
//$columns = array('type', 'title', 'sent_date', 'expires_on', 'ends_on', 'actions');
$columns = array('type', 'title', 'sent_date', 'expires_on', 'amount', 'actions');
$result = getWorkListTeacher($start, $limit, $sidx, $sord, $whereCondition);
break;
case 'get_work_student':
$columns = array('type', 'title', 'expires_on', 'others', 'actions');
$result = getWorkListStudent($start, $limit, $sidx, $sord, $where_condition);
$result = getWorkListStudent($start, $limit, $sidx, $sord, $whereCondition);
break;
case 'get_work_user_list_all':
if (isset($_GET['type']) && $_GET['type'] == 'simple') {
@ -508,7 +517,7 @@ switch ($action) {
} else {
$columns = array('type', 'firstname', 'lastname', 'title', 'sent_date', 'actions');
}
$result = get_work_user_list($start, $limit, $sidx, $sord, $work_id, $where_condition);
$result = get_work_user_list($start, $limit, $sidx, $sord, $work_id, $whereCondition);
break;
case 'get_work_user_list_others':
if (isset($_GET['type']) && $_GET['type'] == 'simple') {
@ -518,8 +527,8 @@ switch ($action) {
} else {
$columns = array('type', 'firstname', 'lastname', 'title', 'sent_date', 'actions');
}
$where_condition .= " AND u.user_id <> ".api_get_user_id();
$result = get_work_user_list($start, $limit, $sidx, $sord, $work_id, $where_condition);
$whereCondition .= " AND u.user_id <> ".api_get_user_id();
$result = get_work_user_list($start, $limit, $sidx, $sord, $work_id, $whereCondition);
break;
case 'get_work_user_list':
if (isset($_GET['type']) && $_GET['type'] == 'simple') {
@ -533,8 +542,8 @@ switch ($action) {
$documents = getAllDocumentToWork($work_id, api_get_course_int_id());
if (empty($documents)) {
$where_condition .= " AND u.user_id = ".api_get_user_id();
$result = get_work_user_list($start, $limit, $sidx, $sord, $work_id, $where_condition);
$whereCondition .= " AND u.user_id = ".api_get_user_id();
$result = get_work_user_list($start, $limit, $sidx, $sord, $work_id, $whereCondition);
} else {
$result = get_work_user_list_from_documents(
$start,
@ -543,7 +552,7 @@ switch ($action) {
$sord,
$work_id,
api_get_user_id(),
$where_condition
$whereCondition
);
}
break;
@ -556,7 +565,7 @@ switch ($action) {
'firstname', 'lastname', 'username', 'group_name', 'exe_duration', 'start_date', 'exe_date', 'score', 'status', 'lp', 'actions'
);
}
$result = get_exam_results_data($start, $limit, $sidx, $sord, $exercise_id, $where_condition);
$result = get_exam_results_data($start, $limit, $sidx, $sord, $exercise_id, $whereCondition);
break;
case 'get_work_student_list_overview':
if (!api_is_allowed_to_edit()) {
@ -586,7 +595,7 @@ switch ($action) {
} else {
$columns = array('exe_date', 'score', 'actions');
}
$result = get_exam_results_hotpotatoes_data($start, $limit, $sidx, $sord, $hotpot_path, $where_condition);
$result = get_exam_results_hotpotatoes_data($start, $limit, $sidx, $sord, $hotpot_path, $whereCondition);
break;
case 'get_sessions_tracking':
if (api_is_drh()) {
@ -646,7 +655,7 @@ switch ($action) {
$result = SessionManager::get_sessions_admin(
array(
'where' => $where_condition,
'where' => $whereCondition,
'order' => "$sidx $sord",
'limit'=> "$start , $limit"
)
@ -678,7 +687,7 @@ switch ($action) {
$result = SessionManager::get_exercise_progress($sessionId, $courseId, $exerciseId, $answer,
array(
'where' => $where_condition,
'where' => $whereCondition,
'order' => "$sidx $sord",
'limit'=> "$start , $limit"
)
@ -686,8 +695,7 @@ switch ($action) {
break;
case 'get_session_lp_progress':
$sessionId = 0;
if (!empty($_GET['session_id']) && !empty($_GET['course_id']))
{
if (!empty($_GET['session_id']) && !empty($_GET['course_id'])) {
$sessionId = intval($_GET['session_id']);
$courseId = intval($_GET['course_id']);
$course = api_get_course_info_by_id($courseId);
@ -711,7 +719,7 @@ switch ($action) {
$result = SessionManager::get_session_lp_progress($sessionId, $courseId,
array(
'where' => $where_condition,
'where' => $whereCondition,
'order' => "$sidx $sord",
'limit'=> "$start , $limit"
)
@ -719,8 +727,10 @@ switch ($action) {
break;
case 'get_survey_overview':
$sessionId = 0;
if (!empty($_GET['session_id']) && !empty($_GET['course_id']) && !empty($_GET['survey_id']))
{
if (!empty($_GET['session_id']) &&
!empty($_GET['course_id']) &&
!empty($_GET['survey_id'])
) {
$sessionId = intval($_GET['session_id']);
$courseId = intval($_GET['course_id']);
$surveyId = intval($_GET['survey_id']);
@ -744,7 +754,7 @@ switch ($action) {
$result = SessionManager::get_survey_overview($sessionId, $courseId, $surveyId,
array(
'where' => $where_condition,
'where' => $whereCondition,
'order' => "$sidx $sord",
'limit'=> "$start , $limit"
)
@ -799,14 +809,13 @@ switch ($action) {
'surveys_progress' ,
);
$sessionId = 0;
if (!empty($_GET['course_id']) && !empty($_GET['session_id']))
{
if (!empty($_GET['course_id']) && !empty($_GET['session_id'])) {
$sessionId = intval($_GET['session_id']);
$courseId = intval($_GET['course_id']);
}
$result = SessionManager::get_session_progress($sessionId, $courseId,
array(
'where' => $where_condition,
'where' => $whereCondition,
'order' => "$sidx $sord",
'limit'=> "$start , $limit"
)
@ -823,8 +832,7 @@ switch ($action) {
'timeLoggedIn',
);
$sessionId = 0;
if (!empty($_GET['course_id']) && !empty($_GET['session_id']))
{
if (!empty($_GET['course_id']) && !empty($_GET['session_id'])) {
$sessionId = intval($_GET['session_id']);
$courseId = intval($_GET['course_id']);
$studentId = intval($_GET['student_id']);
@ -833,9 +841,15 @@ switch ($action) {
$date_to = intval($_GET['date_to']);
}
$result = SessionManager::get_user_data_access_tracking_overview(intval($sessionId), intval($courseId), intval($studentId), intval($profile), $date_to, $date_from,
$result = SessionManager::get_user_data_access_tracking_overview(
$sessionId,
$courseId,
$studentId,
$profile,
$date_to,
$date_from,
array(
'where' => $where_condition,
'where' => $whereCondition,
'order' => "$sidx $sord",
'limit'=> "$start , $limit"
)
@ -851,7 +865,13 @@ switch ($action) {
$result = Database::select(
'*',
$obj->table,
array('where' => array('parent_id = ? AND c_id = ?' => array('0', $course_id)), 'order'=>"$sidx $sord", 'LIMIT'=> "$start , $limit")
array(
'where' => array(
'parent_id = ? AND c_id = ?' => array('0', $course_id)
),
'order'=>"$sidx $sord",
'LIMIT'=> "$start , $limit"
)
);
$new_result = array();
foreach ($result as $item) {
@ -872,7 +892,7 @@ switch ($action) {
if (!in_array($sidx, $columns)) {
$sidx = 'name';
}
$result = Database::select('*', $obj->table, array('order'=>"$sidx $sord", 'LIMIT'=> "$start , $limit"));
$result = Database::select('*', $obj->table, array('order'=>"$sidx $sord", 'LIMIT'=> "$start , $limit"));
$new_result = array();
foreach ($result as $item) {
if ($item['parent_id'] != 0) {
@ -1092,7 +1112,7 @@ if (in_array($action, $allowed_actions)) {
}
$j++;
}
switch ($export_format) {
switch ($exportFormat) {
case 'xls':
//TODO add date if exists
$file_name = (!empty($action)) ? $action : 'company_report';

@ -1818,10 +1818,6 @@ class CourseManager
return $result_array;
}
/*
GROUP FUNCTIONS
*/
/**
* Get the list of groups from the course
* @param string Course code

@ -108,7 +108,7 @@ class Display
public static function display_no_header()
{
global $tool_name;
global $tool_name, $show_learnpath;
$disable_js_and_css_files = true;
self::$global_template = new Template($tool_name, false, false, $show_learnpath);
//echo self::$global_template->show_header_template();

@ -28,7 +28,8 @@ class Gradebook extends Model {
* @param int $c_id Course integer id, defaults to the current course
* @return boolean
*/
public static function is_active($c_id = null) {
public static function is_active($c_id = null)
{
$name = 'gradebook';
$table = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
$sql = "SELECT * from $table WHERE variable='course_hide_tools' AND subkey='$name'";
@ -39,6 +40,7 @@ class Gradebook extends Model {
if ($inactive) {
return false;
}
$c_id = $c_id ? intval($c_id) : api_get_course_int_id();
$table = Database::get_course_table(TABLE_TOOL_LIST);
$sql = "SELECT * from $table WHERE c_id = $c_id and name='$name'";

@ -937,24 +937,51 @@ class GroupManager
* @param int $start
* @param int $limit
* @param bool $getCount
* @param int $courseId
* @return array list of user id
*/
public static function get_users($group_id, $load_extra_info = false, $start = null, $limit = null, $getCount = false)
{
public static function get_users(
$group_id,
$load_extra_info = false,
$start = null,
$limit = null,
$getCount = false,
$courseId = null,
$column = null,
$direction = null
) {
$group_user_table = Database :: get_course_table(TABLE_GROUP_USER);
$user_table = Database :: get_main_table(TABLE_MAIN_USER);
$group_id = Database::escape_string($group_id);
$course_id = api_get_course_int_id();
$select = " SELECT user_id ";
if (empty($courseId)) {
$courseId = api_get_course_int_id();
} else {
$courseId = intval($courseId);
}
$select = " SELECT g.user_id, firstname, lastname ";
if ($getCount) {
$select = " SELECT count(user_id) count";
$select = " SELECT count(u.user_id) count";
}
$sql = "$select FROM $group_user_table
WHERE c_id = $course_id AND group_id = $group_id";
$sql = "$select
FROM $group_user_table g
INNER JOIN $user_table u
ON (u.user_id = g.user_id)
WHERE c_id = $courseId AND g.group_id = $group_id";
if (!empty($column) && !empty($direction)) {
$column = Database::escape_string($column);
$direction = Database::escape_string($direction);
$sql .= " ORDER BY $column $direction";
}
if (!empty($start) && !empty($limit)) {
$start = intval($start);
$limit = intval($limit);
$sql .= " LIMIT $start, $limit";
}
$res = Database::query($sql);
$users = array();
while ($obj = Database::fetch_object($res)) {

File diff suppressed because it is too large Load Diff

@ -6049,7 +6049,7 @@ function api_get_jquery_libraries_js($libraries) {
}
// jquery datepicker
if (in_array('datepicker',$libraries)) {
if (in_array('datepicker', $libraries)) {
$languaje = 'en-GB';
$platform_isocode = strtolower(api_get_language_isocode());
@ -6061,6 +6061,7 @@ function api_get_jquery_libraries_js($libraries) {
$languaje = $platform_isocode;
}
$js .= api_get_js('jquery-ui/jquery-ui-i18n.min.js');
$script = '<script>
$(function(){
$.datepicker.setDefaults($.datepicker.regional["'.$languaje.'"]);
@ -6068,8 +6069,8 @@ function api_get_jquery_libraries_js($libraries) {
});
</script>
';
$js .= api_get_js('jquery-ui/jquery-ui-i18n.min.js');
$js .= $script; //api_get_js('jquery-ui/ui/i18n/jquery.ui.datepicker-'.$languaje.'.js');
$js .= $script;
}
return $js;
@ -6451,12 +6452,13 @@ function api_get_security_key() {
}
function api_get_datetime_picker_js($htmlHeadXtra) {
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/datetimepicker/jquery-ui-timepicker-addon.js" type="text/javascript" language="javascript"></script>';
$htmlHeadXtra[] = '<link href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/datetimepicker/jquery-ui-timepicker-addon.css" rel="stylesheet" type="text/css" />';
$isocode = api_get_language_isocode();
if ($isocode != 'en') {
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/datetimepicker/localization/jquery-ui-timepicker-'.$isocode.'.js" type="text/javascript" language="javascript"></script>';
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/datetimepicker/i18n/jquery-ui-timepicker-'.$isocode.'.js" type="text/javascript" language="javascript"></script>';
}
return $htmlHeadXtra;
}
@ -6872,6 +6874,7 @@ function api_remove_tags_with_space($in_html, $in_double_quote_replace = true) {
// avoid text stuck together when tags are removed, adding a space after >
$out_res = str_replace (">", "> ", $out_res);
$out_res = strip_tags($out_res);
return $out_res;
}

@ -38,8 +38,7 @@ require_once 'HTML/Common.php';
* HTML_QuickForm::isTypeRegistered()
* @global array $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES']
*/
$GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'] =
array(
$GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'] = array(
'group' => array('HTML/QuickForm/group.php','HTML_QuickForm_group'),
'hidden' => array('HTML/QuickForm/hidden.php','HTML_QuickForm_hidden'),
'reset' => array('HTML/QuickForm/reset.php','HTML_QuickForm_reset'),
@ -132,7 +131,7 @@ define('QUICKFORM_INVALID_DATASOURCE', -9);
*/
class HTML_QuickForm extends HTML_Common
{
// {{{ properties
private $dateTimePickerLibraryAdded;
/**
* Array containing the form fields
@ -294,10 +293,7 @@ class HTML_QuickForm extends HTML_Common
{
HTML_Common::HTML_Common($attributes);
$method = (strtoupper($method) == 'GET') ? 'get' : 'post';
// Modified by Chamilo team, 16-MAR-2010
//$action = ($action == '') ? $_SERVER['PHP_SELF'] : $action;
$action = ($action == '') ? api_get_self() : $action;
//
$target = empty($target) ? array() : array('target' => $target);
$form_id = $formName;
if (isset($attributes['id']) && !empty($attributes['id'])) {
@ -665,11 +661,18 @@ class HTML_QuickForm extends HTML_Common
}
}
$elementName = $elementObject->getName();
$type = $elementObject->getType();
if ($type == 'datetimepicker' && $this->dateTimePickerLibraryAdded == false) {
$elementObject->addLibrary = true;
$this->dateTimePickerLibraryAdded = true;
} else {
$elementObject->addLibrary = false;
}
// Add the element if it is not an incompatible duplicate
if (!empty($elementName) && isset($this->_elementIndex[$elementName])) {
if ($this->_elements[$this->_elementIndex[$elementName]]->getType() == $elementObject->getType()
) {
if ($this->_elements[$this->_elementIndex[$elementName]]->getType() == $elementObject->getType()) {
$this->_elements[] =& $elementObject;
$elKeys = array_keys($this->_elements);
$this->_duplicateIndex[$elementName][] = end($elKeys);

@ -36,44 +36,15 @@ require_once 'HTML/QuickForm/Rule.php';
*/
class HTML_QuickForm_Rule_CompareDate extends HTML_QuickForm_Rule
{
/**
* Possible operators to use
* @var array
* @access private
*/
/*var $_operators = array(
'eq' => '==',
'neq' => '!=',
'gt' => '>',
'gte' => '>=',
'lt' => '<',
'lte' => '<='
);*/
/**
* Returns the operator to use for comparing the values
*
* @access private
* @param string operator name
* @return string operator to use for validation
*/
/*function _findOperator($name)
function validate($values, $options)
{
if (empty($name)) {
return '==';
} elseif (isset($this->_operators[$name])) {
return $this->_operators[$name];
} elseif (in_array($name, $this->_operators)) {
return $name;
if (!is_array($values[0]) && !is_array($values[1])) {
return api_strtotime($values[0]) < api_strtotime($values[1]);
} else {
return '==';
$compareFn = create_function(
'$a, $b', 'return mktime($a[\'H\'],$a[\'i\'],0,$a[\'M\'],$a[\'d\'],$a[\'Y\']) <= mktime($b[\'H\'],$b[\'i\'],0,$b[\'M\'],$b[\'d\'],$b[\'Y\'] );'
);
return $compareFn($values[0], $values[1]);
}
}*/
function validate($values, $options)
{
$compareFn = create_function('$a, $b', 'return mktime($a[\'H\'],$a[\'i\'],0,$a[\'M\'],$a[\'d\'],$a[\'Y\']) <= mktime($b[\'H\'],$b[\'i\'],0,$b[\'M\'],$b[\'d\'],$b[\'Y\'] );');
return $compareFn($values[0], $values[1]);
}
}
}

@ -1,6 +1,6 @@
<?php
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Required elements validation
*
@ -25,8 +25,8 @@
* Abstract base class for QuickForm validation rules
*/
require_once 'HTML/QuickForm/Rule.php';
/**
/**
* Required elements validation
*
* @category HTML
@ -35,29 +35,41 @@ require_once 'HTML/QuickForm/Rule.php';
* @version Release: 3.2.11
* @since 3.2
*/
class HTML_QuickForm_Rule_Required extends HTML_QuickForm_Rule
{
/**
* Checks if an element is empty
*
* @param string $value Value to check
* @param mixed $options Not used yet
* @access public
* @return boolean true if value is not empty
*/
function validate($value, $options = null)
{
if ((string)$value == '') {
return false;
}
return true;
} // end func validate
function getValidationScript($options = null)
{
return array('', "{jsVar} == ''");
} // end func getValidationScript
} // end class HTML_QuickForm_Rule_Required
?>
class HTML_QuickForm_Rule_Required extends HTML_QuickForm_Rule
{
/**
* Checks if an element is empty
*
* @param string $value Value to check
* @param mixed $options Not used yet
* @access public
* @return boolean true if value is not empty
*/
function validate($value, $options = null)
{
// It seems this is a file.
if (is_array($value)) {
if (isset($value['name']) &&
isset($value['type']) &&
isset($value['tmp_name']) &&
isset($value['size']) &&
isset($value['error'])
){
if (empty($value['tmp_name'])) {
return false;
}
}
} else {
if ((string)$value == '') {
return false;
}
}
return true;
}
function getValidationScript($options = null)
{
return array('', "{jsVar} == ''");
}
}

@ -403,10 +403,7 @@ class HTML_QuickForm_element extends HTML_Common
$this->setValue($arg);
}
return true;
} // end func onQuickFormEvent
// }}}
// {{{ accept()
}
/**
* Accepts a renderer
@ -420,10 +417,7 @@ class HTML_QuickForm_element extends HTML_Common
function accept(&$renderer, $required=false, $error=null)
{
$renderer->renderElement($this, $required, $error);
} // end func accept
// }}}
// {{{ _generateId()
}
/**
* Automatically generates and assigns an 'id' attribute for the element.
@ -441,10 +435,7 @@ class HTML_QuickForm_element extends HTML_Common
if (!$this->getAttribute('id')) {
$this->updateAttributes(array('id' => 'qf_' . substr(md5(microtime() . $idx++), 0, 6)));
}
} // end func _generateId
// }}}
// {{{ exportValue()
}
/**
* Returns a 'safe' element's value
@ -495,7 +486,4 @@ class HTML_QuickForm_element extends HTML_Common
}
}
}
// }}}
} // end class HTML_QuickForm_element
?>
}

@ -12,7 +12,7 @@ class ResultSet implements Countable, Iterator
/**
*
* @param string $sql
* @return ResultSet
* @return ResultSet
*/
static function create($sql)
{
@ -36,7 +36,7 @@ class ResultSet implements Countable, Iterator
$this->limit_count = $limit_count;
$this->limit_offset = $limit_offset;
$this->orderby_column = $orderby_column;
$this->orderby_direction = $direction;
$this->orderby_direction = $orderby_direction;
$this->return_type = $return_type;
}
@ -107,7 +107,7 @@ class ResultSet implements Countable, Iterator
*
* @param int $count
* @param int $from
* @return ResultSet
* @return ResultSet
*/
public function limit($count, $from = 0)
{
@ -121,7 +121,7 @@ class ResultSet implements Countable, Iterator
*
* @param int $column
* @param int $dir
* @return ResultSet
* @return ResultSet
*/
public function orderby($column, $dir = 'ASC')
{
@ -190,4 +190,4 @@ class ResultSet implements Countable, Iterator
$this->count = false;
}
}
}

@ -223,7 +223,9 @@ class SessionManager
$extraJoin = null;
if (api_is_session_admin() && api_get_setting('allow_session_admins_to_manage_all_sessions') == 'false') {
if (api_is_session_admin() &&
api_get_setting('allow_session_admins_to_manage_all_sessions') == 'false'
) {
$where .= " AND (
s.session_admin_id = $user_id OR
sru.id_user = '$user_id' AND
@ -253,7 +255,7 @@ class SessionManager
$where_condition
);
} else {
$where_condition = "1 = 1";
$where_condition = " AND 1 = 1";
}
$courseCondition = null;
@ -283,7 +285,7 @@ class SessionManager
INNER JOIN $tbl_user u ON s.id_coach = u.user_id
$courseCondition
$extraJoin
$where AND $where_condition ) as session_table";
$where $where_condition ) as session_table";
if (api_is_multiple_url_enabled()) {
@ -309,13 +311,14 @@ class SessionManager
INNER JOIN $table_access_url_rel_session ar ON ar.session_id = s.id
$courseCondition
$extraJoin
$where AND $where_condition) as session_table";
$where $where_condition) as session_table";
}
}
$result_rows = Database::query($sql);
$row = Database::fetch_array($result_rows);
$num = $row['total_rows'];
return $num;
}
@ -523,16 +526,13 @@ class SessionManager
$where = " WHERE a.course_code = '%s'";
if (!empty($sessionId)) {
$where .= " AND a.session_id = %d
AND q.id = %d";
} else
{
$where .= " AND a.session_id = %d AND q.id = %d";
} else {
$where .= " AND q.title = '%s'";
}
//2 = show all questions (wrong and correct answered)
if ($answer != 2)
{
if ($answer != 2) {
$where .= sprintf(' AND qa.correct = %d', $answer);
}
@ -542,7 +542,7 @@ class SessionManager
}
if (!empty($options['where'])) {
$where .= ' AND '.$options['where'];
$where .= ' '.$options['where'];
}
$order = null;
@ -571,20 +571,18 @@ class SessionManager
INNER JOIN $user u ON u.user_id = a.user_id
$where $order $limit";
if (!empty($sessionId))
{
if (!empty($sessionId)) {
$sql_query = sprintf($sql, $course['code'], $sessionId, $exerciseId);
} else
{
} else {
$sql_query = sprintf($sql, $course['code'], $exercise['title']);
}
$rs = Database::query($sql_query);
while ($row = Database::fetch_array($rs))
{
while ($row = Database::fetch_array($rs)) {
$row['correct'] = ($row['correct'] == 1) ? get_lang('Yes') : get_lang('No');
$data[] = $row;
}
return $data;
}
/**
@ -622,7 +620,7 @@ class SessionManager
}
if (!empty($options['where'])) {
$where .= ' AND '.$options['where'];
$where .= ' '.$options['where'];
}
$order = null;
@ -715,7 +713,7 @@ class SessionManager
}
if (!empty($options['where'])) {
$where .= ' AND '.$options['where'];
$where .= ' '.$options['where'];
}
$order = null;
@ -773,6 +771,7 @@ class SessionManager
}
return $table;
}
/**
* Gets the progress of the given session
* @param int session id
@ -781,7 +780,6 @@ class SessionManager
*/
public static function get_session_progress($sessionId, $courseId, $options)
{
//tables
$session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$user = Database::get_main_table(TABLE_MAIN_USER);
@ -815,7 +813,7 @@ class SessionManager
}
if (!empty($options['where'])) {
$where .= ' AND '.$options['where'];
$where .= ' '.$options['where'];
}
$order = null;
@ -1045,6 +1043,7 @@ class SessionManager
$track_e_course_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
return Database::count_rows($track_e_course_access);
}
/**
* Get the ip, total of clicks, login date and time logged in for all user, in one session
* @todo track_e_course_access table should have ip so we dont have to look for it in track_e_login
@ -1052,8 +1051,8 @@ class SessionManager
* @author César Perales <cesar.perales@beeznest.com>, Beeznest Team
* @version Chamilo 1.9.6
*/
function get_user_data_access_tracking_overview($sessionId, $courseId, $studentId = 0, $profile = '', $date_from = '', $date_to = '', $options) {
global $_configuration;
function get_user_data_access_tracking_overview($sessionId, $courseId, $studentId = 0, $profile = '', $date_from = '', $date_to = '', $options)
{
// database table definition
$user = Database :: get_main_table(TABLE_MAIN_USER);
$course = Database :: get_main_table(TABLE_MAIN_COURSE);
@ -1061,31 +1060,26 @@ class SessionManager
$track_e_course_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
global $export_csv;
if ($export_csv)
{
if ($export_csv) {
$is_western_name_order = api_is_western_name_order(PERSON_NAME_DATA_EXPORT);
} else {
$is_western_name_order = api_is_western_name_order();
}
if (isset($sessionId) && !empty($sessionId))
{
if (isset($sessionId) && !empty($sessionId)) {
$where = sprintf(" WHERE a.session_id = %d", intval($sessionId));
}
if (isset($courseId) && !empty($courseId))
{
if (isset($courseId) && !empty($courseId)) {
$where .= sprintf(" AND c.id = %d", intval($courseId)) ;
}
if (isset($studentId) && !empty($studentId))
{
if (isset($studentId) && !empty($studentId)) {
$where .= sprintf(" AND u.user_id = %d", intval($studentId));
}
if (isset($profile) && !empty($profile))
{
if (isset($profile) && !empty($profile)) {
$where .= sprintf(" AND u.status = %d", intval($profile));
}
if (!empty($date_to) && !empty($date_from))
{
if (!empty($date_to) && !empty($date_from)) {
//FIX THIS
$to = substr($date_to, 0, 4) .'-' . substr($date_to, 4, 2) . '-' . substr($date_to, 6, 2);
$from = substr($date_from, 0, 4) . '-' . substr($date_from, 4, 2) . '-' . substr($date_from, 6, 2);
@ -1098,7 +1092,7 @@ class SessionManager
}
if (!empty($options['where'])) {
$where .= ' AND '.$options['where'];
$where .= ' '.$options['where'];
}
$order = null;
@ -1117,7 +1111,6 @@ class SessionManager
u.lastname,
u.firstname,
")."
a.logout_course_date,
c.title,
c.code,
@ -1130,14 +1123,12 @@ class SessionManager
$clicks = Tracking::get_total_clicks_by_session();
$data = array ();
while ($user = Database::fetch_assoc($result))
{
while ($user = Database::fetch_assoc($result)) {
$data[] = $user;
}
//foreach
foreach ($data as $key => $info)
{
// Foreach
foreach ($data as $key => $info) {
#building array to display
$return[] = array(
'logindate' => $info['login_course_date'],
@ -1149,9 +1140,9 @@ class SessionManager
'timeLoggedIn' => gmdate("H:i:s", strtotime($info['logout_course_date']) - strtotime($info['login_course_date'])),
);
}
//Search for ip, we do less querys if we iterate the final array
foreach ($return as $key => $info)
{
foreach ($return as $key => $info) {
$sql = sprintf("SELECT login_ip FROM $track_e_login WHERE ('%s' BETWEEN login_date AND logout_date)", $info['logindate']); //TODO add select by user too
$result = Database::query($sql);
$ip = Database::fetch_assoc($result);
@ -3240,6 +3231,10 @@ class SessionManager
}
$courses = explode('|', $enreg['Courses']);
// See BT#6449
if (count($courses) >= 2) {
//
}
foreach ($courses as $course) {
$courseArray = bracketsToArray($course);

@ -3,6 +3,7 @@
for more information: see languages.txt in the lang folder.
*/
$langHGlossary = "Glossary help";
$langGlossaryContent = "This tool allows you to create glossary terms for this course, which can then be used from the documents tool";
$langForumContent = "<p> The forum is an discussion tool for asynchronous written work. In contrast to email, a forum is for public, or semi-public, group discussion. </p>To use the Chamilo forum, members can simply use their browser - they do not require separate client software. </p>To organize forums, clickon the Forums tool. Discussions are organized hierarchically according to the following structure: </ p><b> Category> Forum> Topic> Post</ b> </ p> To ensure members can participate in the forum tidily and effectively, it is essential in th first instance to create categories and forums; it's then up to the participants to create topics and posts. By default, the forum contains a single (public) category, an example topic and an example post. You can add forums to the category, change its title or create other categories within which you could then create new forums. (Don't confuse categories and forums, and remember that a category that contains no forum is useless and is not displayed.)</p>\n<p>The forum description might include a list of its members, a definition of its purpose, a target a task, a theme etc.</p><p>Group forums should not be created via the Forum tool but instead via the Groups tool, where you can determinewhether your group forums should be private or public, at the same time providing a location for sharing groups of documents.</p><b> Teaching Tips</ b></ p> A learning forum is not quite the same as the forums you are used to seeing on the internet. For one thing, it is not possible for learners to alter their posts once they have been published as the course is logically archived to allow tracking of what has been said in the past. Furthermore, Chamilo forums allow for specific uses relevant to teaching. For example, some teachers/trainers publish corrections directly within forums in the following way: <li> A learner is asked to post a report directly into the forum, </ li> The teacher corrects it by clicking Edit (yellow pencil) and marking it using the graphics editor (color, underlining, etc.) </ li> Finally, other learners benefit from viewing the corrections was made on the production of one of of them, </ li> Note that the same principle can be applied between learners, but will require his copying/pasting the message of his fellow student because students / trainees can not edit one another's posts. <. li> </ ul>";
$langHForum = "Forum help";
$langHFor = "Forums Help";

@ -16,12 +16,12 @@ $WikiRead = "Wiki pages read";
$WikiRevisions = "Wiki pages revisions";
$WikiTotal = "Total wiki pages";
$AssignmentsProgress = "Assignments progress";
$AssignmentsLeft = "Incomplete assignments";
$AssignmentsDone = "Completed assignments";
$AssignmentsLeft = "Missing assignments";
$AssignmentsDone = "Completed handed in";
$AssignmentsTotal = "Total assignments";
$ForumsProgress = "Forums progress";
$ForumsLeft = "Incomplete forums";
$ForumsDone = "Completed forums";
$ForumsLeft = "Forums not read";
$ForumsDone = "Forums read";
$ForumsTotal = "Total forums";
$ExercisesProgress = "Exercises progress";
$ExercisesLeft = "Incomplete exercises";

@ -2,6 +2,10 @@
/*
for more information: see languages.txt in the lang folder.
*/
$AllowOnlyFiles = "Allow only files";
$AllowOnlyText = "Allow only text";
$AllowFileOrText = "Allow files or online text";
$DocumentType = "Document type";
$SendOnlyAnEmailToMySelfToTest = "Send an email to myself for testing purposes.";
$DeleteAllSelectedAttendances = "Delete all selected attendances";
$AvailableClasses = "Available classes";

@ -3,6 +3,10 @@
for more information: see languages.txt in the lang folder.
*/
$SearchSessions = "Recherche de session.";
$DeleteUsersNotInList = "Désinscrite les apprenants qui ne sont pas dans la liste importée";
$IfSessionExistsUpdate = "Si une session existe, la mettre à jour";
$SearchCourseBySession = "Recherche de cours par session";
$GlobalLinkUseDoubleColumnPrivateToShowPrivately = "Utiliser ::private à la fin du lien pour l'afficher seulement aux utilisateurs identifiés";
$CourseVisibilityHidden = "Invisible - Complètement invisible et inaccessible pour tous les utilisateurs excepté les administrateurs";
$ApplyAllLanguages = "Appliquer ces modifications à toutes les langues disponibles";
$CareerUpdated = "Carrière mise à jour";

@ -2,6 +2,26 @@
/*
for more information: see languages.txt in the lang folder.
*/
$SleepingStudents = "Apprenants sans activité durant les derniers jours";
$SleepingTeachers = "Enseignants sans activité durant les derniers jours";
$InactiveUsers = "Utilisateurs au compte désactivé";
$ActiveUsers = "Utilisateurs actifs";
$SurveysProgress = "Progrès dans les enquêtes";
$SurveysLeft = "Enquêtes non répondues";
$SurveysDone = "Enquêtes répondues";
$SurveysTotal = "Enquêtes totales";
$WikiProgress = "Progrès de lecture des pages de wiki";
$WikiUnread = "Pages de wiki non lues";
$WikiRead = "Pages de wiki lues";
$WikiRevisions = "Révisions des pages de wiki";
$WikiTotal = "Nombre total de pages de wiki";
$AssignmentsProgress = "Progrès dans les tâches";
$AssignmentsLeft = "Tâches non remises";
$AssignmentsDone = "Tâches remises";
$AssignmentsTotal = "Tâches totales";
$ForumsProgress = "Progrès dans les forums";
$ForumsLeft = "Forums non lus";
$ForumsDone = "Forums lus";
$ForumsTotal = "Total des forums";
$ExercisesProgress = "Progrès des exercices";
$ExercisesLeft = "Exercices incomplètes";

@ -2,6 +2,14 @@
/*
for more information: see languages.txt in the lang folder.
*/
$AllowOnlyFiles = "Seulement fichiers";
$AllowOnlyText = "Seulement texte en ligne";
$AllowFileOrText = "Autoriser fichier ou texte en ligne";
$DocumentType = "Type de document";
$SendOnlyAnEmailToMySelfToTest = "M'envoyer un e-mail à des fins de test";
$DeleteAllSelectedAttendances = "Éliminer toutes les présences sélectionnées";
$AvailableClasses = "Classes disponibles";
$RegisteredClasses = "Classes inscrites";
$DeleteItemsNotInFile = "Supprimer les éléments qui ne sont pas dans le fichier";
$ImportGroups = "Importer groupes";
$HereIsYourFeedback = "Voici vos commentaires";

@ -2,6 +2,7 @@
/*
for more information: see languages.txt in the lang folder.
*/
$WorkFileNotUploadedDirXDoesNotExist = "Le travail n'a pas pu être envoyé parce que le répertoire %s n'existe pas";
$FolderDoesntExistsInFileSystem = "Le dossier de destination est introuvable sur le serveur.";
$HandedOutDate = "Date de réception";
$HandedOut = "Remis";

@ -39,12 +39,20 @@ if (isset($_GET['u'])) {
} else {
//checking the relationship between me and my friend
$my_status= SocialManager::get_relation_between_contacts(api_get_user_id(), $user_id);
if (in_array($my_status, array(USER_RELATION_TYPE_PARENT, USER_RELATION_TYPE_FRIEND, USER_RELATION_TYPE_GOODFRIEND))) {
if (in_array($my_status, array(
USER_RELATION_TYPE_PARENT,
USER_RELATION_TYPE_FRIEND,
USER_RELATION_TYPE_GOODFRIEND
))) {
$show_full_profile = true;
}
//checking the relationship between my friend and me
$my_friend_status = SocialManager::get_relation_between_contacts($user_id, api_get_user_id());
if (in_array($my_friend_status, array(USER_RELATION_TYPE_PARENT, USER_RELATION_TYPE_FRIEND, USER_RELATION_TYPE_GOODFRIEND))) {
if (in_array($my_friend_status, array(
USER_RELATION_TYPE_PARENT,
USER_RELATION_TYPE_FRIEND,
USER_RELATION_TYPE_GOODFRIEND
))) {
$show_full_profile = true;
} else {
// im probably not a good friend
@ -256,7 +264,9 @@ $interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('SocialNetwork'
if (isset($_GET['u']) && is_numeric($_GET['u']) && $_GET['u'] != api_get_user_id()) {
$info_user = api_get_user_info($_GET['u']);
$interbreadcrumb[]= array ('url' => '#','name' => api_get_person_name($info_user['firstName'], $info_user['lastName']));
$interbreadcrumb[]= array (
'url' => '#',
'name' => api_get_person_name($info_user['firstName'], $info_user['lastName']));
$nametool = '';
}
if (isset($_GET['u'])) {
@ -305,20 +315,27 @@ if (!empty($user_info['firstname']) || !empty($user_info['lastname'])) {
if ($show_full_profile) {
$personal_info .= '<dl class="dl-horizontal">';
$personal_info .= '<dt>'.get_lang('UserName').'</dt><dd>'. $user_info['username'].' </dd>';
if (!empty($user_info['firstname']) || !empty($user_info['lastname']))
$personal_info .= '<dt>'.get_lang('Name').'</dt><dd>'. api_get_person_name($user_info['firstname'], $user_info['lastname']).'</dd>';
if (!empty($user_info['official_code']))
if (!empty($user_info['firstname']) || !empty($user_info['lastname'])) {
$personal_info .= '<dt>'.get_lang('Name')
.'</dt><dd>'. api_get_person_name($user_info['firstname'], $user_info['lastname']).'</dd>';
}
if (!empty($user_info['official_code'])) {
$personal_info .= '<dt>'.get_lang('OfficialCode').'</dt><dd>'.$user_info['official_code'].'</dd>';
if (!empty($user_info['email']))
if (api_get_setting('show_email_addresses')=='true')
}
if (!empty($user_info['email'])) {
if (api_get_setting('show_email_addresses')=='true') {
$personal_info .= '<dt>'.get_lang('Email').'</dt><dd>'.$user_info['email'].'</dd>';
if (!empty($user_info['phone']))
}
if (!empty($user_info['phone'])) {
$personal_info .= '<dt>'.get_lang('Phone').'</dt><dd>'. $user_info['phone'].'</dd>';
}
$personal_info .= '</dl>';
}
} else {
$personal_info .= '<dl class="dl-horizontal">';
if (!empty($user_info['username']))
if (!empty($user_info['username'])) {
$personal_info .= '<dt>'.get_lang('UserName').'</dt><dd>'. $user_info['username'].'</dd>';
}
$personal_info .= '</dl>';
}
@ -347,9 +364,13 @@ if ($show_full_profile) {
if ($number_friends > $number_of_images) {
if (api_get_user_id() == $user_id) {
$friend_html.= '<div style="float:right;width:20%"><a href="friends.php">'.get_lang('SeeAll').'</a></div>';
$friend_html.= '<div style="float:right;width:20%">'
.'<a href="friends.php">'.get_lang('SeeAll').'</a></div>';
} else {
$friend_html.= '<div style="float:right;width:20%"><a href="'.api_get_path(WEB_CODE_PATH).'social/profile_friends_and_groups.inc.php?view=friends&height=390&width=610&&user_id='.$user_id.'" class="thickbox" title="'.get_lang('SeeAll').'" >'.get_lang('SeeAll').'</a></div>';
$friend_html.= '<div style="float:right;width:20%">'
.'<a href="'.api_get_path(WEB_CODE_PATH).'social/profile_friends_and_groups.inc.php'
.'?view=friends&height=390&width=610&user_id='.$user_id.'"'
.'class="thickbox" title="'.get_lang('SeeAll').'" >'.get_lang('SeeAll').'</a></div>';
}
}
$friend_html.= '</div>'; // close div friend-header
@ -375,12 +396,20 @@ if ($show_full_profile) {
$friend_html.= '<div class="thumbnail">';
// the height = 92 must be the sqme in the image_friend_network span style in default.css
$friends_profile = SocialManager::get_picture_user($friend['friend_user_id'], $friend['image'], 92, USER_IMAGE_SIZE_ORIGINAL);
$friends_profile = SocialManager::get_picture_user(
$friend['friend_user_id'],
$friend['image'],
92,
USER_IMAGE_SIZE_ORIGINAL
);
$friend_html.= '<img src="'.$friends_profile['file'].'" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$name_user.'" />';
$friend_html.= '<img src="'.$friends_profile['file'].'"'
.' id="imgfriend_'.$friend['friend_user_id'].'" title="'.$name_user.'" />';
$friend_html.= '<div class="caption">';
$friend_html.= $status_icon.'<a href="profile.php?u='.$friend['friend_user_id'].'&amp;'.$link_shared.'">';
$friend_html.= $status_icon.'<a href="profile.php?'
.'u='.$friend['friend_user_id']
.'&amp;'.$link_shared.'">';
$friend_html.= $name_user;
$friend_html.= '</a></div>';
$friend_html.= '</div>';
@ -394,7 +423,10 @@ if ($show_full_profile) {
$friend_html .= '<div><h3>'.get_lang('SocialFriend').'</h3></div>';
$friend_html.= '<div id="friend-container" class="social-friend-container">';
$friend_html.= '<div id="friend-header">';
$friend_html.= '<div>'.get_lang('NoFriendsInYourContactList').'<br /><a class="btn" href="'.api_get_path(WEB_PATH).'whoisonline.php">'.get_lang('TryAndFindSomeFriends').'</a></div>';
$friend_html.= '<div>'.get_lang('NoFriendsInYourContactList').'<br />'
.'<a class="btn" href="'.api_get_path(WEB_PATH).'whoisonline.php">'
.get_lang('TryAndFindSomeFriends')
.'</a></div>';
$friend_html.= '</div>'; // close div friend-header
}
$friend_html.= '</div>';
@ -412,10 +444,13 @@ if ($show_full_profile) {
$extra_information_value = '';
foreach($extra_user_data as $key=>$data) {
//Avoding parameters
if (in_array($key, array('mail_notify_invitation','mail_notify_message', 'mail_notify_group_message' ))) continue;
if (in_array($key, array('mail_notify_invitation','mail_notify_message', 'mail_notify_group_message' ))) {
continue;
}
// get display text, visibility and type from user_field table
$field_variable = str_replace('extra_','',$key);
$sql = "SELECT field_display_text,field_visible,field_type,id FROM $t_uf WHERE field_variable ='$field_variable'";
$sql = "SELECT field_display_text,field_visible,field_type,id "
." FROM $t_uf WHERE field_variable ='$field_variable'";
$res_field = Database::query($sql);
$row_field = Database::fetch_row($res_field);
$field_display_text = $row_field[0];
@ -424,9 +459,10 @@ if ($show_full_profile) {
$field_id = $row_field[3];
if ($field_visible == 1) {
if (is_array($data)) {
$extra_information_value .= '<dt>'.ucfirst($field_display_text).'</dt><dd> '.implode(',',$data).'</dd>';
$extra_information_value .= '<dt>'.ucfirst($field_display_text).'</dt>'
.'<dd> '.implode(',',$data).'</dd>';
} else {
if ($field_type == USER_FIELD_TYPE_DOUBLE_SELECT) {
if ($field_type == UserManager::USER_FIELD_TYPE_DOUBLE_SELECT) {
$id_options = explode(';',$data);
$value_options = array();
// get option display text from user_field_options table
@ -436,22 +472,34 @@ if ($show_full_profile) {
$row_options = Database::fetch_row($res_options);
$value_options[] = $row_options[0];
}
$extra_information_value .= '<dt>'.ucfirst($field_display_text).':</dt><dd>'.implode(' ',$value_options).'</dd>';
} elseif($field_type == USER_FIELD_TYPE_TAG ) {
$extra_information_value .= '<dt>'.ucfirst($field_display_text).':</dt>'
.'<dd>'.implode(' ',$value_options).'</dd>';
} elseif ($field_type == UserManager::USER_FIELD_TYPE_TAG ) {
$user_tags = UserManager::get_user_tags($user_id, $field_id);
$tag_tmp = array();
foreach ($user_tags as $tags) {
$tag_tmp[] = '<a class="label label_tag" href="'.api_get_path(WEB_PATH).'main/social/search.php?q='.$tags['tag'].'">'.$tags['tag'].'</a>';
$tag_tmp[] = '<a class="label label_tag"'
.' href="'.api_get_path(WEB_PATH).'main/social/search.php?q='.$tags['tag'].'">'
.$tags['tag']
.'</a>';
}
if (is_array($user_tags) && count($user_tags)>0) {
$extra_information_value .= '<dt>'.ucfirst($field_display_text).':</dt><dd>'.implode('', $tag_tmp).'</dd>';
$extra_information_value .= '<dt>'.ucfirst($field_display_text).':</dt>'
.'<dd>'.implode('', $tag_tmp).'</dd>';
}
} elseif ($field_type == USER_FIELD_TYPE_SOCIAL_PROFILE) {
} elseif ($field_type == UserManager::USER_FIELD_TYPE_SOCIAL_PROFILE) {
$icon_path = UserManager::get_favicon_from_url($data);
$bottom = '0.3';
$bottom = '0.2';
//quick hack for hi5
$domain = parse_url($icon_path, PHP_URL_HOST); if ($domain == 'www.hi5.com' or $domain == 'hi5.com') { $bottom = '0.8'; }
$data = '<a href="'.$data.'"><img src="'.$icon_path.'" alt="ico" style="margin-right:0.5em;margin-bottom:-'.$bottom.'em;" />'.ucfirst($field_display_text).'</a>';
$domain = parse_url($icon_path, PHP_URL_HOST);
if ($domain == 'www.hi5.com' or $domain == 'hi5.com') {
$bottom = '-0.8';
}
$data = '<a href="'.$data.'">'
.'<img src="'.$icon_path.'" alt="icon"'
.' style="margin-right:0.5em;margin-bottom:'.$bottom.'em;" />'
.$field_display_text
.'</a>';
$extra_information_value .= '<dd>'.$data.'</dd>';
} else {
if (!empty($data)) {
@ -486,9 +534,17 @@ if ($show_full_profile) {
$icon = '';
$name = cut($result['name'],CUT_GROUP_NAME,true);
if ($result['relation_type'] == GROUP_USER_PERMISSION_ADMIN) {
$icon = Display::return_icon('social_group_admin.png', get_lang('Admin'), array('style'=>'vertical-align:middle;width:16px;height:16px;'));
$icon = Display::return_icon(
'social_group_admin.png',
get_lang('Admin'),
array('style'=>'vertical-align:middle;width:16px;height:16px;')
);
} elseif ($result['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) {
$icon = Display::return_icon('social_group_moderator.png', get_lang('Moderator'), array('style'=>'vertical-align:middle;width:16px;height:16px;'));
$icon = Display::return_icon(
'social_group_moderator.png',
get_lang('Moderator'),
array('style'=>'vertical-align:middle;width:16px;height:16px;')
);
}
$count_users_group = count(GroupPortalManager::get_all_users_by_group($id));
if ($count_users_group == 1 ) {
@ -500,15 +556,20 @@ if ($show_full_profile) {
$item_name = $url_open.$name.$icon.$url_close;
if ($result['description'] != '') {
//$item_description = '<div class="box_shared_profile_group_description"><p class="social-groups-text4">'.cut($result['description'],100,true).'</p></div>';
//$item_description = '<div class="box_shared_profile_group_description">'
//.'<p class="social-groups-text4">'.cut($result['description'],100,true).'</p></div>';
} else {
//$item_description = '<div class="box_shared_profile_group_description"><span class="social-groups-text2"></span><p class="social-groups-text4"></p></div>';
//$item_description = '<div class="box_shared_profile_group_description">'
//.'<span class="social-groups-text2"></span><p class="social-groups-text4"></p></div>';
}
//$result['picture_uri'] = '<div class="box_shared_profile_group_image"><img class="social-groups-image" src="'.$picture['file'].'" hspace="4" height="50" border="2" align="left" width="50" /></div>';
//$result['picture_uri'] = '<div class="box_shared_profile_group_image">'
//.'<img class="social-groups-image" src="'.$picture['file'].'" hspace="4" height="50"'
//.' border="2" align="left" width="50" /></div>';
$item_actions = '';
if (api_get_user_id() == $user_id) {
//$item_actions = '<div class="box_shared_profile_group_actions"><a href="groups.php?id='.$id.'">'.get_lang('SeeMore').$url_close.'</div>';
}
//if (api_get_user_id() == $user_id) {
//$item_actions = '<div class="box_shared_profile_group_actions"><a href="groups.php?id='.$id.'">'
//.get_lang('SeeMore').$url_close.'</div>';
//}
$grid_my_groups[]= array($item_name,$url_open.$result['picture_uri'].$url_close, $item_actions);
$i++;
}
@ -526,12 +587,28 @@ if ($show_full_profile) {
if ($i > $max_numbers_of_group) {
if (api_get_user_id() == $user_id) {
$my_groups .= '<div class="box_shared_profile_group_actions"><a href="groups.php?#tab_browse-1">'.get_lang('SeeAllMyGroups').'</a></div>';
$my_groups .= '<div class="box_shared_profile_group_actions">'
.'<a href="groups.php?#tab_browse-1">'.get_lang('SeeAllMyGroups').'</a></div>';
} else {
$my_groups .= '<div class="box_shared_profile_group_actions"><a href="'.api_get_path(WEB_CODE_PATH).'social/profile_friends_and_groups.inc.php?view=mygroups&height=390&width=610&&user_id='.$user_id.'" class="thickbox" title="'.get_lang('SeeAll').'" >'.get_lang('SeeAllMyGroups').'</a></div>';
$my_groups .= '<div class="box_shared_profile_group_actions">'
.'<a href="'.api_get_path(WEB_CODE_PATH).'social/profile_friends_and_groups.inc.php'
.'?view=mygroups&height=390&width=610&user_id='.$user_id.'"'
.' class="thickbox" title="'.get_lang('SeeAll').'" >'
.get_lang('SeeAllMyGroups')
.'</a></div>';
}
}
//Display::display_sortable_grid('shared_profile_mygroups', array(), $grid_my_groups, array('hide_navigation'=>true, 'per_page' => 2), $query_vars, false, array(true, true, true,false));
/*
Display::display_sortable_grid(
'shared_profile_mygroups',
array(),
$grid_my_groups,
array('hide_navigation'=>true, 'per_page' => 2),
$query_vars,
false,
array(true, true, true,false)
);
*/
$total = count($grid_my_groups);
$i = 1;
foreach($grid_my_groups as $group) {
@ -552,10 +629,11 @@ if ($show_full_profile) {
//Courses without sessions
$i=1;
foreach ($list as $key=>$value) {
foreach ($list as $key => $value) {
if ( empty($value[2]) ) { //if out of any session
$my_courses .= $value[1];
$my_courses .= '<div id="social_content'.$i.'" class="course_social_content" style="display:none" >s</div>';
$my_courses .= '<div id="social_content'.$i.'"'
.' class="course_social_content" style="display:none" >s</div>';
$i++;
}
}
@ -578,7 +656,7 @@ if ($show_full_profile) {
$file_list = '';
if (is_array($course_list_code) && count($course_list_code)>0) {
foreach ($course_list_code as $course) {
$file_list.= UserManager::get_user_upload_files_by_course($user_id, $course['code'], $resourcetype='images');
$file_list.= UserManager::get_user_upload_files_by_course($user_id,$course['code'],$resourcetype='images');
}
}
@ -599,16 +677,30 @@ if ($show_full_profile) {
$user_invitation_id = $pending_invitations[$i]['user_sender_id'];
$invitations .= '<div id="dpending_'.$user_invitation_id.'" class="friend_invitations">';
$invitations .= '<div style="float:left;width:60px;" >';
$invitations .= '<img style="margin-bottom:5px;" src="'.$list_get_path_web[$i]['dir'].'/'.$list_get_path_web[$i]['file'].'" width="60px">';
$invitations .= '<img style="margin-bottom:5px;"'
.' src="'.$list_get_path_web[$i]['dir'].'/'.$list_get_path_web[$i]['file'].'"'
.' width="60px">';
$invitations .= '</div>';
$invitations .= '<div style="padding-left:70px;">';
$user_invitation_info = api_get_user_info($user_invitation_id);
$invitations .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$user_invitation_id.'">'.api_get_person_name($user_invitation_info['firstname'], $user_invitation_info['lastname']).'</a>';
$invitations .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php'
.'?u='.$user_invitation_id.'">'
.api_get_person_name(
$user_invitation_info['firstname'],
$user_invitation_info['lastname'])
.'</a>';
$invitations .= '<br />';
$invitations .= Security::remove_XSS(cut($pending_invitations[$i]['content'], 50), STUDENT, true);
$invitations .= Security::remove_XSS(
cut($pending_invitations[$i]['content'], 50),
STUDENT,
true
);
$invitations .= '<br />';
$invitations .= '<a id="btn_accepted_'.$user_invitation_id.'" class="btn" onclick="register_friend(this)" href="javascript:void(0)">'.get_lang('SocialAddToFriends').'</a>';
$invitations .= '<a id="btn_accepted_'.$user_invitation_id.'"'
.' class="btn" onclick="register_friend(this)" href="javascript:void(0)">'
.get_lang('SocialAddToFriends')
.'</a>';
$invitations .= '<div id="id_response"></div>';
$invitations .= '</div>';
$invitations .= '</div>';
@ -638,7 +730,8 @@ if ($show_full_profile) {
}
}
if (!empty($user_info['competences']) || !empty($user_info['diplomas']) || !empty($user_info['openarea']) || !empty($user_info['teach']) ) {
if (!empty($user_info['competences']) || !empty($user_info['diplomas'])
|| !empty($user_info['openarea']) || !empty($user_info['teach']) ) {
$more_info .= '<div><h3>'.get_lang('MoreInformation').'</h3></div>';
if (!empty($user_info['competences'])) {

@ -1,49 +1,22 @@
<div class="page-header">
<h2>{{ work.title }}</h2>
<h2>
{{ work.title }}
{% if work.contains_file %}
<a href="{{ work.download_url }}"><img src="{{ "save.png"|icon(22) }}"></a>
{% endif %}
</h2>
</div>
{% if work.description %}
<p>
{{ work.description }}
</p>
{# "UpdatedBy"|get_lang|format(comment.username) #}
{% endif %}
{% if work_comment_enabled %}
<hr>
<h4>
{{ 'Comments' | get_lang }}
</h4>
<hr>
<ul>
{% for comment in comments %}
<li>
<div class="page-header">
<a href="{{ _p.web_code }}">
<img height="24" src="{{ comment.picture }}"/> {{ comment.username }}
</a>- {{ comment.sent_at | api_get_local_time }}
</div>
<p>
{% if comment.comment is not empty %}
{{ comment.comment }}
{% else %}
{{ 'HereIsYourFeedback' | get_lang }}
{% endif %}
</p>
{% if comment.file_url is not empty %}
<p>
<a href="{{ comment.file_url }}">
<img src="{{ "attachment.gif"|icon(32) }}">
{{ comment.file_name_to_show }}
</a>
{% if is_allowed_to_edit %}
<a href="{{ comment.delete_file_url }}">
<img src="{{ "delete.png"|icon(22) }}">
</a>
{% endif %}
</p>
{% endif %}
</li>
{% endfor %}
</ul>
<br />
<hr>
{{ form }}
{% if work.contains_file and work.show_content %}
<p>
{{ work.show_content }}
</p>
{% endif %}
{% include 'default/work/comments.tpl' %}

@ -102,9 +102,11 @@ $view = isset($_GET['view']) ? $_GET['view'] : null;
$wiki->page = $page;
$wiki->action = $action;
/* MAIN CODE */
// Setting wiki data
if (!empty($view)) {
$wiki->setWikiData($view);
}
/* ACTIONS */
$wiki->blockConcurrentEditions(api_get_user_id(), $action);
/* MAIN WIKI AREA */
@ -118,7 +120,6 @@ Display::display_header($tool_name, 'Wiki');
// check last version
if (!empty($view)) {
$wiki->setWikiData($view);
$wiki->checkLastVersion($view);
}

@ -41,6 +41,8 @@ class Wiki
$this->condition_session = api_get_session_condition($this->session_id);
$this->course_id = api_get_course_int_id();
$this->group_id = api_get_group_id();
if (!empty($this->group_id)) {
$this->groupfilter = ' group_id="'.$this->group_id.'"';
}
@ -50,11 +52,11 @@ class Wiki
/**
* Check whether this title is already used
* @param string $paramwk
* @param string $link
* @return bool False if title is already taken
* @author Patrick Cool <patrick.cool@ugent.be>, Ghent University
**/
public function checktitle($paramwk)
public function checktitle($link)
{
$tbl_wiki = $this->tbl_wiki;
$condition_session = $this->condition_session;
@ -64,7 +66,7 @@ class Wiki
$sql = 'SELECT * FROM '.$tbl_wiki.'
WHERE
c_id = '.$course_id.' AND
reflink="'.Database::escape_string($paramwk).'" AND
reflink="'.Database::escape_string($link).'" AND
'.$groupfilter.$condition_session.'';
$result = Database::query($sql);
$numberofresults = Database::num_rows($result);
@ -366,19 +368,38 @@ class Wiki
* @author Juan Carlos Raña <herodoto@telefonica.net>
* @return string Message of success (to be printed on screen)
**/
public function restore_wikipage($r_page_id, $r_reflink, $r_title, $r_content, $r_group_id, $r_assignment, $r_progress, $c_version, $r_version, $r_linksto)
{
public function restore_wikipage(
$r_page_id,
$r_reflink,
$r_title,
$r_content,
$r_group_id,
$r_assignment,
$r_progress,
$c_version,
$r_version,
$r_linksto
) {
$tbl_wiki = $this->tbl_wiki;
$_course = $this->courseInfo;
$r_user_id= api_get_user_id();
$r_dtime = date( "Y-m-d H:i:s" );
$r_user_id = api_get_user_id();
$r_dtime = api_get_utc_datetime();
$r_version = $r_version+1;
$r_comment = get_lang('RestoredFromVersion').': '.$c_version;
$session_id = api_get_session_id();
$course_id = api_get_course_int_id();
$sql="INSERT INTO ".$tbl_wiki." (c_id, page_id, reflink, title, content, user_id, group_id, dtime, assignment, comment, progress, version, linksto, user_ip, session_id) VALUES
$r_page_id = Database::escape_string($r_page_id);
$r_title = Database::escape_string($r_title);
$r_content = Database::escape_string($r_content);
$r_group_id = Database::escape_string($r_group_id);
$r_assignment = Database::escape_string($r_assignment);
$r_progress = Database::escape_string($r_progress);
$r_version = Database::escape_string($r_version);
$r_linksto = Database::escape_string($r_linksto);
$r_comment = Database::escape_string($r_comment);
$sql = "INSERT INTO ".$tbl_wiki." (c_id, page_id, reflink, title, content, user_id, group_id, dtime, assignment, comment, progress, version, linksto, user_ip, session_id) VALUES
($course_id, '".$r_page_id."','".$r_reflink."','".$r_title."','".$r_content."','".$r_user_id."','".$r_group_id."','".$r_dtime."','".$r_assignment."','".$r_comment."','".$r_progress."','".$r_version."','".$r_linksto."','".Database::escape_string($_SERVER['REMOTE_ADDR'])."','".Database::escape_string($session_id)."')";
Database::query($sql);
@ -454,8 +475,8 @@ class Wiki
} else {
$page = str_replace(' ','_',$values['title']);
}
$_clean['reflink'] = Database::escape_string(strip_tags(api_htmlentities($page)));
$_clean['title'] = Database::escape_string(strip_tags(trim($values['title'])));
$_clean['reflink'] = Database::escape_string($page);
$_clean['title'] = Database::escape_string(trim($values['title']));
$_clean['content'] = Database::escape_string($values['content']);
if (api_get_setting('htmlpurifier_wiki') == 'true'){
@ -524,7 +545,7 @@ class Wiki
self::setMessage(Display::display_warning_message(get_lang('GoAndEditMainPage'), false, true));
} else {
$var = $_clean['reflink'];
$group_id = Security::remove_XSS($_GET['group_id']);
$group_id = intval($_GET['group_id']);
if (!self::checktitle($var)) {
return get_lang('WikiPageTitleExist').'<a href="index.php?action=edit&amp;title='.$var.'&group_id='.$group_id.'">'.$values['title'].'</a>';
} else {
@ -702,7 +723,7 @@ class Wiki
$filter = null;
if (isset($_GET['view']) && $_GET['view']) {
$_clean['view']=(int)Database::escape_string($_GET['view']);
$_clean['view'] = Database::escape_string($_GET['view']);
$filter =' AND w.id="'.$_clean['view'].'"';
}
@ -743,19 +764,18 @@ class Wiki
// if both are empty and we are displaying the index page then we display the default text.
if ($row['content']=='' AND $row['title']=='' AND $page=='index') {
if (api_is_allowed_to_edit(false,true) || api_is_platform_admin() || GroupManager :: is_user_in_group(api_get_user_id(), api_get_group_id())) {
if (api_is_allowed_to_edit(false,true) || api_is_platform_admin() || GroupManager::is_user_in_group(api_get_user_id(), api_get_group_id())) {
//Table structure for better export to pdf
$default_table_for_content_Start='<table align="center" border="0"><tr><td align="center">';
$default_table_for_content_End='</td></tr></table>';
$content=$default_table_for_content_Start.sprintf(get_lang('DefaultContent'),api_get_path(WEB_IMG_PATH)).$default_table_for_content_End;
$content = $default_table_for_content_Start.sprintf(get_lang('DefaultContent'),api_get_path(WEB_IMG_PATH)).$default_table_for_content_End;
$title=get_lang('DefaultTitle');
} else {
return self::setMessage(Display::display_normal_message(get_lang('WikiStandBy'), false, true));
}
} else {
$content = Security::remove_XSS(api_html_entity_decode($row['content']), COURSEMANAGERLOWSECURITY);
$title= api_html_entity_decode($row['title']);
$content = Security::remove_XSS($row['content']);
$title = Security::remove_XSS($row['title']);
}
//assignment mode: identify page type
@ -773,7 +793,11 @@ class Wiki
}
//Show page. Show page to all users if isn't hide page. Mode assignments: if student is the author, can view
if ($KeyVisibility=="1" || api_is_allowed_to_edit(false,true) || api_is_platform_admin() || ($row['assignment']==2 && $KeyVisibility=="0" && (api_get_user_id()==$row['user_id']))) {
if ($KeyVisibility == "1" ||
api_is_allowed_to_edit(false,true) ||
api_is_platform_admin() ||
($row['assignment']==2 && $KeyVisibility=="0" && (api_get_user_id()==$row['user_id']))
) {
echo '<div id="wikititle">';
$protect_page = null;
$lock_unlock_protect = null;
@ -797,17 +821,12 @@ class Wiki
$lock_unlock_visibility = null;
//page action: visibility
if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
if (self::check_visibility_page()==1) {
// TODO: FIX This hides the icon eye closed to users of work they can see yours
//if(($row['assignment']==2 && $KeyVisibility=="0" && (api_get_user_id()==$row['user_id']))==false)
//{
//
// }
$visibility_page= Display::return_icon('visible.png', get_lang('ShowPageExtra'),'',ICON_SIZE_SMALL);
if (self::check_visibility_page() == 1) {
$visibility_page= Display::return_icon('visible.png', get_lang('ShowPageExtra'),'', ICON_SIZE_SMALL);
$lock_unlock_visibility='invisible';
} else {
$visibility_page= Display::return_icon('invisible.png', get_lang('HidePageExtra'),'',ICON_SIZE_SMALL);
$visibility_page= Display::return_icon('invisible.png', get_lang('HidePageExtra'),'', ICON_SIZE_SMALL);
$lock_unlock_visibility='visible';
}
}
@ -997,11 +1016,15 @@ class Wiki
$groupfilter = $this->groupfilter;
$course_id = api_get_course_int_id();
$sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' ORDER BY id ASC';
$result=Database::query($sql);
$row=Database::fetch_array($result);
$status_addlock=$row['addlock'];
//change status
$sql = 'SELECT *
FROM '.$tbl_wiki.'
WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
ORDER BY id ASC';
$result = Database::query($sql);
$row = Database::fetch_array($result);
$status_addlock = $row['addlock'];
// Change status
if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
if (isset($_GET['actionpage']) && $_GET['actionpage'] =='lockaddnew' && $status_addlock==1) {
$status_addlock=0;
@ -1010,11 +1033,15 @@ class Wiki
$status_addlock=1;
}
Database::query('UPDATE '.$tbl_wiki.' SET addlock="'.Database::escape_string($status_addlock).'" WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'');
Database::query('UPDATE '.$tbl_wiki.' SET addlock="'.Database::escape_string($status_addlock).'"
WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'');
$sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.' ORDER BY id ASC';
$result=Database::query($sql);
$row=Database::fetch_array($result);
$sql = 'SELECT *
FROM '.$tbl_wiki.'
WHERE c_id = '.$course_id.' AND '.$groupfilter.$condition_session.'
ORDER BY id ASC';
$result = Database::query($sql);
$row = Database::fetch_array($result);
}
return $row['addlock'];
@ -1042,7 +1069,7 @@ class Wiki
$result=Database::query($sql);
$row=Database::fetch_array($result);
$status_editlock=$row['editlock'];
$status_editlock = $row['editlock'];
$id = $row['id'];
///change status
@ -1053,8 +1080,11 @@ class Wiki
if (isset($_GET['actionpage']) && $_GET['actionpage']=='unlock' && $status_editlock==1) {
$status_editlock=0;
}
$sql='UPDATE '.$tbl_wiki.' SET editlock="'.Database::escape_string($status_editlock).'" WHERE c_id = '.$course_id.' AND id="'.$id.'"';
$sql = 'UPDATE '.$tbl_wiki.' SET editlock="'.Database::escape_string($status_editlock).'"
WHERE c_id = '.$course_id.' AND id="'.$id.'"';
Database::query($sql);
$sql='SELECT * FROM '.$tbl_wiki.'
WHERE
c_id = '.$course_id.' AND
@ -1062,8 +1092,9 @@ class Wiki
'.$groupfilter.$condition_session.'
ORDER BY id ASC';
$result=Database::query($sql);
$row=Database::fetch_array($result);
$row = Database::fetch_array($result);
}
//show status
return $row['editlock'];
}
@ -1081,9 +1112,9 @@ class Wiki
$groupfilter = $this->groupfilter;
$course_id = api_get_course_int_id();
$sql='SELECT * FROM '.$tbl_wiki.'
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session.'
ORDER BY id ASC';
$sql = 'SELECT * FROM '.$tbl_wiki.'
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session.'
ORDER BY id ASC';
$result=Database::query($sql);
$row=Database::fetch_array($result);
$status_visibility=$row['visibility'];
@ -1101,9 +1132,12 @@ class Wiki
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session;
Database::query($sql);
//Although the value now is assigned to all (not only the first), these three lines remain necessary. They do that by changing the page state is made when you press the button and not have to wait to change his page
// Although the value now is assigned to all (not only the first), these three lines remain necessary. They do that by changing the page state is made when you press the button and not have to wait to change his page
$sql = 'SELECT * FROM '.$tbl_wiki.'
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session.'
WHERE
c_id = '.$course_id.' AND
reflink="'.Database::escape_string($page).'" AND
'.$groupfilter.$condition_session.'
ORDER BY id ASC';
$result=Database::query($sql);
$row = Database::fetch_array($result);
@ -1132,12 +1166,15 @@ class Wiki
$course_id = api_get_course_int_id();
$sql = 'SELECT * FROM '.$tbl_wiki.'
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session.'
WHERE
c_id = '.$course_id.' AND
reflink="'.Database::escape_string($page).'" AND
'.$groupfilter.$condition_session.'
ORDER BY id ASC';
$result=Database::query($sql);
$row=Database::fetch_array($result);
$status_visibility_disc=$row['visibility_disc'];
$status_visibility_disc = $row['visibility_disc'];
//change status
if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
@ -1149,7 +1186,10 @@ class Wiki
}
$sql = 'UPDATE '.$tbl_wiki.' SET visibility_disc="'.Database::escape_string($status_visibility_disc).'"
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session;
WHERE
c_id = '.$course_id.' AND
reflink="'.Database::escape_string($page).'" AND
'.$groupfilter.$condition_session;
Database::query($sql);
//Although the value now is assigned to all (not only the first), these three lines remain necessary. They do that by changing the page state is made when you press the button and not have to wait to change his page
@ -1159,8 +1199,8 @@ class Wiki
reflink="'.Database::escape_string($page).'" AND
'.$groupfilter.$condition_session.'
ORDER BY id ASC';
$result=Database::query($sql);
$row=Database::fetch_array($result);
$result = Database::query($sql);
$row = Database::fetch_array($result);
}
return $row['visibility_disc'];
}
@ -1179,10 +1219,13 @@ class Wiki
$course_id = api_get_course_int_id();
$sql = 'SELECT * FROM '.$tbl_wiki.'
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session.'
WHERE
c_id = '.$course_id.' AND
reflink="'.Database::escape_string($page).'" AND
'.$groupfilter.$condition_session.'
ORDER BY id ASC';
$result=Database::query($sql);
$row=Database::fetch_array($result);
$result = Database::query($sql);
$row = Database::fetch_array($result);
$status_addlock_disc=$row['addlock_disc'];
@ -1195,8 +1238,8 @@ class Wiki
$status_addlock_disc=0;
}
$sql='UPDATE '.$tbl_wiki.' SET addlock_disc="'.Database::escape_string($status_addlock_disc).'"
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session;
$sql = 'UPDATE '.$tbl_wiki.' SET addlock_disc="'.Database::escape_string($status_addlock_disc).'"
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session;
Database::query($sql);
//Although the value now is assigned to all (not only the first), these three lines remain necessary. They do that by changing the page state is made when you press the button and not have to wait to change his page
@ -1227,7 +1270,6 @@ class Wiki
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session.' ORDER BY id ASC';
$result=Database::query($sql);
$row=Database::fetch_array($result);
$status_ratinglock_disc=$row['ratinglock_disc'];
//change status
@ -1239,13 +1281,21 @@ class Wiki
$status_ratinglock_disc=0;
}
$sql='UPDATE '.$tbl_wiki.' SET ratinglock_disc="'.Database::escape_string($status_ratinglock_disc).'"
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session; //Visibility. Value to all,not only for the first
$sql = 'UPDATE '.$tbl_wiki.' SET ratinglock_disc="'.Database::escape_string($status_ratinglock_disc).'"
WHERE
c_id = '.$course_id.' AND
reflink="'.Database::escape_string($page).'" AND
'.$groupfilter.$condition_session;
//Visibility. Value to all,not only for the first
Database::query($sql);
//Although the value now is assigned to all (not only the first), these three lines remain necessary. They do that by changing the page state is made when you press the button and not have to wait to change his page
$sql='SELECT * FROM '.$tbl_wiki.'
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session.' ORDER BY id ASC';
WHERE
c_id = '.$course_id.' AND
reflink="'.Database::escape_string($page).'" AND
'.$groupfilter.$condition_session.'
ORDER BY id ASC';
$result=Database::query($sql);
$row=Database::fetch_array($result);
}
@ -1289,7 +1339,8 @@ class Wiki
// Change status
if (isset($_GET['actionpage']) && $_GET['actionpage'] =='locknotify' && $status_notify==0) {
$sql = "SELECT id FROM $tbl_wiki_mailcue WHERE c_id = $course_id AND id = $id AND user_id = $userId";
$sql = "SELECT id FROM $tbl_wiki_mailcue
WHERE c_id = $course_id AND id = $id AND user_id = $userId";
$result = Database::query($sql);
$exist = false;
if (Database::num_rows($result)) {
@ -1338,10 +1389,9 @@ class Wiki
$id=$row['id'];
$sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
WHERE c_id = '.$course_id.' AND id="'.$id.'" AND user_id="'.api_get_user_id().'" AND type="D"';
$result=Database::query($sql);
$row=Database::fetch_array($result);
$idm=$row['id'];
$result = Database::query($sql);
$row = Database::fetch_array($result);
$idm = $row['id'];
if (empty($idm)) {
$status_notify_disc=0;
@ -1378,7 +1428,12 @@ class Wiki
$session_id=api_get_session_id();
$sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
WHERE c_id = '.$course_id.' AND user_id="'.api_get_user_id().'" AND type="F" AND group_id="'.$groupId.'" AND session_id="'.$session_id.'"';
WHERE
c_id = '.$course_id.' AND
user_id="'.api_get_user_id().'" AND
type="F" AND
group_id="'.$groupId.'" AND
session_id="'.$session_id.'"';
$result=Database::query($sql);
$row=Database::fetch_array($result);
@ -1400,7 +1455,13 @@ class Wiki
if (isset($_GET['actionpage']) && isset($_GET['actionpage']) && $_GET['actionpage'] =='unlocknotifyall' && $status_notify_all==1) {
$sql ='DELETE FROM '.$tbl_wiki_mailcue.'
WHERE c_id = '.$course_id.' AND user_id="'.api_get_user_id().'" AND type="F" AND group_id="'.$groupId.'" AND session_id="'.$session_id.'" AND c_id = '.$course_id;
WHERE
c_id = '.$course_id.' AND
user_id="'.api_get_user_id().'" AND
type="F" AND
group_id="'.$groupId.'" AND
session_id="'.$session_id.'" AND
c_id = '.$course_id;
Database::query($sql);
$status_notify_all=0;
}
@ -1455,7 +1516,14 @@ class Wiki
if ($row['visibility']==1) {
$allow_send_mail=true; //if visibility off - notify off
$sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
WHERE c_id = '.$course_id.' AND id="'.$id.'" AND type="'.$type.'" OR type="F" AND group_id="'.$groupId.'" AND session_id="'.$session_id.'"'; //type: P=page, D=discuss, F=full.
WHERE
c_id = '.$course_id.' AND
id="'.$id.'" AND
type="'.$type.'" OR
type="F" AND
group_id="'.$groupId.'" AND
session_id="'.$session_id.'"';
//type: P=page, D=discuss, F=full.
$result=Database::query($sql);
$emailtext=get_lang('EmailWikipageModified').' <strong>'.$email_page_name.'</strong> '.get_lang('Wiki');
}
@ -1480,7 +1548,9 @@ class Wiki
$id=$id_or_ref; //$id_or_ref is id from tblwiki
$sql='SELECT * FROM '.$tbl_wiki.' WHERE c_id = '.$course_id.' AND id="'.$id.'" ORDER BY id ASC';
$sql = 'SELECT * FROM '.$tbl_wiki.'
WHERE c_id = '.$course_id.' AND id="'.$id.'"
ORDER BY id ASC';
$result=Database::query($sql);
$row=Database::fetch_array($result);
@ -1489,7 +1559,14 @@ class Wiki
if ($row['visibility_disc']==1) {
$allow_send_mail=true; //if visibility off - notify off
$sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
WHERE c_id = '.$course_id.' AND id="'.$id.'" AND type="'.$type.'" OR type="F" AND group_id="'.$groupId.'" AND session_id="'.$session_id.'"'; //type: P=page, D=discuss, F=full
WHERE
c_id = '.$course_id.' AND
id="'.$id.'" AND
type="'.$type.'" OR
type="F" AND
group_id="'.$groupId.'" AND
session_id="'.$session_id.'"';
//type: P=page, D=discuss, F=full
$result=Database::query($sql);
$emailtext=get_lang('EmailWikiPageDiscAdded').' <strong>'.$email_page_name.'</strong> '.get_lang('Wiki');
}
@ -1527,13 +1604,13 @@ class Wiki
}
$sql = 'SELECT * FROM '.$tbl_wiki_mailcue.'
WHERE c_id = '.$course_id.' AND id="'.$id.'" AND type="F" AND group_id="'.$groupId.'" AND session_id="'.$session_id.'"'; //type: P=page, D=discuss, F=full
WHERE c_id = '.$course_id.' AND id="'.$id.'" AND type="F" AND group_id="'.$groupId.'" AND session_id="'.$session_id.'"';
//type: P=page, D=discuss, F=full
$result=Database::query($sql);
$emailtext=get_lang('EmailWikiPageAdded').' <strong>'.$email_page_name.'</strong> '.get_lang('In').' '. get_lang('Wiki');
} elseif($type=='E') {
$emailtext = get_lang('EmailWikiPageAdded').' <strong>'.$email_page_name.'</strong> '.get_lang('In').' '. get_lang('Wiki');
} elseif ($type=='E') {
$id=0;
$allow_send_mail=true;
//Who is the author?
@ -1589,8 +1666,8 @@ class Wiki
if (empty($data)) {
return false;
}
$wikiTitle = $data['title'];
$wikiContents = $data['content'];
$wikiTitle = $data['title'];
$wikiContents = $data['content'];
$template =
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@ -1813,8 +1890,9 @@ class Wiki
$name = api_get_person_name($o_user_to_add['firstname'], $o_user_to_add['lastname'])." . ".$username;
$photo= '<img src="'.$image_repository.$existing_image.'" alt="'.$name.'" width="40" height="50" align="bottom" title="'.$name.'" />';
$is_tutor_of_group = GroupManager :: is_tutor_of_group($assig_user_id,$groupId); //student is tutor
$is_tutor_and_member = (GroupManager :: is_tutor_of_group($assig_user_id,$groupId) && GroupManager :: is_subscribed($assig_user_id, $groupId)); //student is tutor and member
$is_tutor_of_group = GroupManager::is_tutor_of_group($assig_user_id,$groupId); //student is tutor
$is_tutor_and_member = (GroupManager::is_tutor_of_group($assig_user_id,$groupId) && GroupManager::is_subscribed($assig_user_id, $groupId));
//student is tutor and member
if($is_tutor_and_member) {
$status_in_group=get_lang('GroupTutorAndMember');
@ -1858,7 +1936,14 @@ class Wiki
$values['title']= $title_orig;
$values['comment']=get_lang('AssignmentDesc');
sort($all_students_pages);
$values['content']=$content_orig_A.$content_orig_B.'<br/><div align="center" style="font-size:18px; background-color: #F5F8FB; border:solid; border-color:#E6E6E6">'.get_lang('AssignmentLinkstoStudentsPage').'</div><br/><div style="background-color: #F5F8FB; border:solid; border-color:#E6E6E6"><ol>'.implode($all_students_pages).'</ol></div><br/>';
$values['content']=$content_orig_A.$content_orig_B.'<br/>
<div align="center" style="font-size:18px; background-color: #F5F8FB; border:solid; border-color:#E6E6E6">
'.get_lang('AssignmentLinkstoStudentsPage').'
</div><br/>
<div style="background-color: #F5F8FB; border:solid; border-color:#E6E6E6">
<ol>'.implode($all_students_pages).'</ol>
</div>
<br/>';
$values['assignment']=1;
}
$this->assig_user_id = $assig_user_id;
@ -1888,41 +1973,98 @@ class Wiki
if ($all_vers=='1') {
if ($search_content=='1') {
$sql = "SELECT * FROM ".$tbl_wiki."
WHERE c_id = $course_id AND title LIKE '%".Database::escape_string($search_term)."%' OR content LIKE '%".Database::escape_string($search_term)."%' AND ".$groupfilter.$condition_session."";//search all pages and all versions
WHERE
c_id = $course_id AND
title LIKE '%".Database::escape_string($search_term)."%' OR
content LIKE '%".Database::escape_string($search_term)."%' AND
".$groupfilter.$condition_session."";
//search all pages and all versions
} else {
$sql = "SELECT * FROM ".$tbl_wiki."
WHERE c_id = $course_id AND title LIKE '%".Database::escape_string($search_term)."%' AND ".$groupfilter.$condition_session."";//search all pages and all versions
WHERE
c_id = $course_id AND
title LIKE '%".Database::escape_string($search_term)."%' AND
".$groupfilter.$condition_session."";
//search all pages and all versions
}
} else {
if ($search_content=='1') {
$sql = "SELECT * FROM ".$tbl_wiki." s1
WHERE s1.c_id = $course_id AND title LIKE '%".Database::escape_string($search_term)."%' OR content LIKE '%".Database::escape_string($search_term)."%' AND
id=(SELECT MAX(s2.id) FROM ".$tbl_wiki." s2 WHERE s2.c_id = $course_id AND s1.reflink = s2.reflink AND ".$groupfilter.$condition_session.")";// warning don't use group by reflink because don't return the last version
WHERE
s1.c_id = $course_id AND
title LIKE '%".Database::escape_string($search_term)."%' OR
content LIKE '%".Database::escape_string($search_term)."%' AND
id=(
SELECT MAX(s2.id)
FROM ".$tbl_wiki." s2
WHERE
s2.c_id = $course_id AND
s1.reflink = s2.reflink AND
".$groupfilter.$condition_session.")";
// warning don't use group by reflink because don't return the last version
}
else {
$sql = " SELECT * FROM ".$tbl_wiki." s1
WHERE s1.c_id = $course_id AND title LIKE '%".Database::escape_string($search_term)."%' AND
id=(SELECT MAX(s2.id) FROM ".$tbl_wiki." s2 WHERE s2.c_id = $course_id AND s1.reflink = s2.reflink AND ".$groupfilter.$condition_session.")";// warning don't use group by reflink because don't return the last version
WHERE
s1.c_id = $course_id AND
title LIKE '%".Database::escape_string($search_term)."%' AND
id=(
SELECT MAX(s2.id)
FROM ".$tbl_wiki." s2
WHERE
s2.c_id = $course_id AND
s1.reflink = s2.reflink AND
".$groupfilter.$condition_session.")";
// warning don't use group by reflink because don't return the last version
}
}
} else {
if($all_vers=='1') {
if ($search_content=='1') {
$sql = "SELECT * FROM ".$tbl_wiki."
WHERE c_id = $course_id AND visibility=1 AND title LIKE '%".Database::escape_string($search_term)."%' OR content LIKE '%".Database::escape_string($search_term)."%' AND ".$groupfilter.$condition_session."";//search all pages and all versions
WHERE
c_id = $course_id AND
visibility=1 AND
title LIKE '%".Database::escape_string($search_term)."%' OR
content LIKE '%".Database::escape_string($search_term)."%' AND
".$groupfilter.$condition_session."";
//search all pages and all versions
} else {
$sql = "SELECT * FROM ".$tbl_wiki."
WHERE c_id = $course_id AND visibility=1 AND title LIKE '%".Database::escape_string($search_term)."%' AND ".$groupfilter.$condition_session."";//search all pages and all versions
WHERE
c_id = $course_id AND
visibility=1 AND
title LIKE '%".Database::escape_string($search_term)."%' AND
".$groupfilter.$condition_session."";
//search all pages and all versions
}
} else {
if($search_content=='1') {
$sql = " SELECT * FROM ".$tbl_wiki." s1
WHERE s1.c_id = $course_id AND visibility=1 AND title LIKE '%".Database::escape_string($search_term)."%' OR content LIKE '%".Database::escape_string($search_term)."%' AND
id=(SELECT MAX(s2.id) FROM ".$tbl_wiki." s2 WHERE s2.c_id = $course_id AND s1.reflink = s2.reflink AND ".$groupfilter.$condition_session.")";// warning don't use group by reflink because don't return the last version
$sql = "SELECT * FROM ".$tbl_wiki." s1
WHERE
s1.c_id = $course_id AND
visibility=1 AND
title LIKE '%".Database::escape_string($search_term)."%' OR
content LIKE '%".Database::escape_string($search_term)."%' AND
id=(
SELECT MAX(s2.id)
FROM ".$tbl_wiki." s2
WHERE s2.c_id = $course_id AND
s1.reflink = s2.reflink AND
".$groupfilter.$condition_session.")";
// warning don't use group by reflink because don't return the last version
} else {
$sql = " SELECT * FROM ".$tbl_wiki." s1
WHERE s1.c_id = $course_id AND visibility=1 AND title LIKE '%".Database::escape_string($search_term)."%' AND
id=(SELECT MAX(s2.id) FROM ".$tbl_wiki." s2 WHERE s2.c_id = $course_id AND s1.reflink = s2.reflink AND ".$groupfilter.$condition_session.")";// warning don't use group by reflink because don't return the last version
$sql = "SELECT * FROM ".$tbl_wiki." s1
WHERE
s1.c_id = $course_id AND
visibility=1 AND
title LIKE '%".Database::escape_string($search_term)."%' AND
id=(
SELECT MAX(s2.id) FROM ".$tbl_wiki." s2
WHERE s2.c_id = $course_id AND
s1.reflink = s2.reflink AND
".$groupfilter.$condition_session.")";
// warning don't use group by reflink because don't return the last version
}
}
}
@ -1956,9 +2098,11 @@ class Wiki
$row[] =$ShowAssignment;
if($all_vers=='1') {
$row[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&view='.$obj->id.'&session_id='.api_htmlentities(urlencode($_GET['$session_id'])).'&group_id='.api_htmlentities(urlencode($_GET['group_id'])).'">'.api_htmlentities($obj->title).'</a>';
$row[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&view='.$obj->id.'&session_id='.api_htmlentities(urlencode($_GET['$session_id'])).'&group_id='.api_htmlentities(urlencode($_GET['group_id'])).'">'.
api_htmlentities($obj->title).'</a>';
} else {
$row[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.$obj->title.'</a>';
$row[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
$obj->title.'</a>';
}
$row[] = $obj->user_id <>0 ? '<a href="'.api_get_path(WEB_CODE_PATH).'user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.
@ -1969,7 +2113,8 @@ class Wiki
$row[] = $obj->version;
} else {
if (api_is_allowed_to_edit(false,true)|| api_is_platform_admin()) {
$showdelete=' <a href="'.api_get_self().'?'.api_get_cidreq().'&action=delete&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL);
$showdelete=' <a href="'.api_get_self().'?'.api_get_cidreq().'&action=delete&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL);
}
$row[] = '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=edit&title='.api_htmlentities(urlencode($obj->reflink)).'&group_id='.api_htmlentities($_GET['group_id']).'">'.
Display::return_icon('edit.png', get_lang('EditPage'),'',ICON_SIZE_SMALL).'</a>
@ -1983,7 +2128,17 @@ class Wiki
}
$table = new SortableTableFromArrayConfig($rows, 1, 10,'SearchPages_table','','','ASC');
$table->set_additional_parameters(array('cidReq' => $_GET['cidReq'],'action'=> $_GET['action'], 'group_id'=>Security::remove_XSS($_GET['group_id']),'mode_table'=>'yes2','search_term'=>$search_term, 'search_content'=>$search_content, 'all_vers'=>$all_vers));
$table->set_additional_parameters(
array(
'cidReq' => $_GET['cidReq'],
'action'=> $_GET['action'],
'group_id'=>Security::remove_XSS($_GET['group_id']),
'mode_table'=>'yes2',
'search_term'=>$search_term,
'search_content'=>$search_content,
'all_vers'=>$all_vers
)
);
$table->set_header(0,get_lang('Type'), true, array ('style' => 'width:30px;'));
$table->set_header(1,get_lang('Title'), true);
if ($all_vers=='1') {
@ -2061,7 +2216,11 @@ class Wiki
*/
public function get_date_from_select($prefix)
{
return $_POST[$prefix.'_year'].'-'.self::two_digits($_POST[$prefix.'_month']).'-'.self::two_digits($_POST[$prefix.'_day']).' '.self::two_digits($_POST[$prefix.'_hour']).':'.self::two_digits($_POST[$prefix.'_minute']).':00';
return $_POST[$prefix.'_year'].'-'.
self::two_digits($_POST[$prefix.'_month']).'-'.
self::two_digits($_POST[$prefix.'_day']).' '.
self::two_digits($_POST[$prefix.'_hour']).':'.
self::two_digits($_POST[$prefix.'_minute']).':00';
}
/**
@ -2093,6 +2252,28 @@ class Wiki
return $data;
}
/**
* @param string $refLink
* @return array
*/
public function getLastWikiData($refLink)
{
$tbl_wiki = $this->tbl_wiki;
$groupfilter = $this->groupfilter;
$condition_session = $this->condition_session;
$course_id = api_get_course_int_id();
$sql = 'SELECT * FROM '.$tbl_wiki.'
WHERE
c_id = '.$course_id.' AND
reflink="'.Database::escape_string($refLink).'" AND
'.$groupfilter.$condition_session.'
ORDER BY id DESC';
$result = Database::query($sql);
return Database::fetch_array($result);
}
/**
* Get wiki information
* @param string wiki id
@ -2113,7 +2294,8 @@ class Wiki
}
$title = Database::escape_string($title);
$sql = "SELECT * FROM $tbl_wiki WHERE c_id = $courseId AND reflink = '$title'";
$sql = "SELECT * FROM $tbl_wiki
WHERE c_id = $courseId AND reflink = '$title'";
$result = Database::query($sql);
$data = array();
if (Database::num_rows($result)) {
@ -2170,7 +2352,9 @@ class Wiki
$condition_session = $this->condition_session;
$sql = "SELECT * FROM $tbl_wiki
WHERE c_id = $course_id AND is_editing != '0' ".$condition_session;
WHERE
c_id = $course_id AND
is_editing != '0' ".$condition_session;
$result = Database::query($sql);
return Database::store_result($result, 'ASSOC');
}
@ -2185,8 +2369,13 @@ class Wiki
$condition_session = $this->condition_session;
$isEditing = Database::escape_string($isEditing);
$sql = 'UPDATE '.$tbl_wiki.' SET is_editing="0", time_edit="0000-00-00 00:00:00"
WHERE c_id = '.$course_id.' AND is_editing="'.$isEditing.'" '.$condition_session;
$sql = 'UPDATE '.$tbl_wiki.' SET
is_editing="0",
time_edit="0000-00-00 00:00:00"
WHERE
c_id = '.$course_id.' AND
is_editing="'.$isEditing.'" '.
$condition_session;
Database::query($sql);
}
@ -2280,7 +2469,8 @@ class Wiki
$total_wlinks = $total_wlinks+substr_count($row['content'], "[[");
$total_images = $total_images+substr_count($row['content'], "<img");
$clean_total_flash = preg_replace('/player.swf/', ' ', $row['content']);
$total_flash = $total_flash+substr_count($clean_total_flash, '.swf"');//.swf" end quotes prevent insert swf through flvplayer (is not counted)
$total_flash = $total_flash+substr_count($clean_total_flash, '.swf"');
//.swf" end quotes prevent insert swf through flvplayer (is not counted)
$total_mp3 = $total_mp3+substr_count($row['content'], ".mp3");
$total_flv_p = $total_flv_p+substr_count($row['content'], ".flv");
$total_flv = $total_flv_p/5;
@ -2291,12 +2481,16 @@ class Wiki
//check only last version of all pages (current page)
$sql =' SELECT *, COUNT(*) AS TOTAL_PAGES, SUM(hits) AS TOTAL_VISITS_LV
$sql =' SELECT *, COUNT(*) AS TOTAL_PAGES, SUM(hits) AS TOTAL_VISITS_LV
FROM '.$tbl_wiki.' s1
WHERE s1.c_id = '.$course_id.' AND id=(
SELECT MAX(s2.id)
FROM '.$tbl_wiki.' s2
WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.' AND session_id='.$session_id.')';
SELECT MAX(s2.id)
FROM '.$tbl_wiki.' s2
WHERE
s2.c_id = '.$course_id.' AND
s1.reflink = s2.reflink AND
'.$groupfilter.' AND
session_id='.$session_id.')';
$allpages = Database::query($sql);
while ($row=Database::fetch_array($allpages)) {
$total_pages = $row['TOTAL_PAGES'];
@ -2339,7 +2533,8 @@ class Wiki
$total_wlinks_lv = $total_wlinks_lv+substr_count($row['content'], "[[");
$total_images_lv = $total_images_lv+substr_count($row['content'], "<img");
$clean_total_flash_lv = preg_replace('/player.swf/', ' ', $row['content']);
$total_flash_lv = $total_flash_lv+substr_count($clean_total_flash_lv, '.swf"');//.swf" end quotes prevent insert swf through flvplayer (is not counted)
$total_flash_lv = $total_flash_lv+substr_count($clean_total_flash_lv, '.swf"');
//.swf" end quotes prevent insert swf through flvplayer (is not counted)
$total_mp3_lv = $total_mp3_lv+substr_count($row['content'], ".mp3");
$total_flv_p_lv = $total_flv_p_lv+substr_count($row['content'], ".flv");
$total_flv_lv = $total_flv_p_lv/5;
@ -2362,15 +2557,17 @@ class Wiki
'.$groupfilter.' AND
session_id='.$session_id.'
)';
//Can not use group by because the mark is set in the latest version
// Can not use group by because the mark is set in the latest version
$allpages=Database::query($sql);
while ($row=Database::fetch_array($allpages)) {
$total_editing_now = $row['TOTAL_EDITING_NOW'];
}
//Total hidden pages
// Total hidden pages
$total_hidden=0;
$sql = 'SELECT * FROM '.$tbl_wiki.'
WHERE c_id = '.$course_id.' AND visibility=0 AND '.$groupfilter.$condition_session.'
WHERE c_id = '.$course_id.' AND visibility=0 AND '.$groupfilter.$condition_session.'
GROUP BY reflink';
// or group by page_id. As the mark of hidden places it in all versions of the page, I can use group by to see the first
$allpages=Database::query($sql);
@ -2393,7 +2590,10 @@ class Wiki
// Total empty versions.
$total_empty_content=0;
$sql = 'SELECT * FROM '.$tbl_wiki.'
WHERE c_id = '.$course_id.' AND content="" AND '.$groupfilter.$condition_session.'';
WHERE
c_id = '.$course_id.' AND
content="" AND
'.$groupfilter.$condition_session.'';
$allpages = Database::query($sql);
while ($row=Database::fetch_array($allpages)) {
$total_empty_content = $total_empty_content+1;
@ -3018,16 +3218,14 @@ class Wiki
while ($row=Database::fetch_array($result)) {
$userinfo = api_get_user_info($row['userc_id']);
$username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
if (($userinfo['status'])=="5") {
$author_status=get_lang('Student');
} else {
$author_status=get_lang('Teacher');
}
$user_id=$row['userc_id'];
$name = api_get_person_name($userinfo['firstname'], $userinfo['lastname']);
$user_id = $row['userc_id'];
$name = $userinfo['complete_name'];
if ($user_id<>0) {
$image_path = UserManager::get_user_picture_path_by_id($user_id,'web',false, true);
$image_repository = $image_path['dir'];
@ -3071,7 +3269,7 @@ class Wiki
$imagerating = Display::return_icon('rating/stars_45.gif');
break;
case 10:
$imagerating =Display::return_icon('rating/stars_50.gif');
$imagerating = Display::return_icon('rating/stars_50.gif');
break;
}
echo '<p><table>';
@ -3151,7 +3349,7 @@ class Wiki
}
$row = array();
$row[] =$ShowAssignment.$icon_task;
$row[] = $ShowAssignment.$icon_task;
$row[] = '<a href="'.api_get_self().'?cidReq='.$_course['code'].'&action=showpage&title='.api_htmlentities(urlencode($obj->reflink)).'&session_id='.api_htmlentities($_GET['session_id']).'&group_id='.api_htmlentities($_GET['group_id']).'">
'.api_htmlentities($obj->title).'</a>';
if ($obj->user_id <>0) {
@ -3373,7 +3571,6 @@ class Wiki
while ($obj = Database::fetch_object($allpages)) {
//get author
$userinfo = api_get_user_info($obj->user_id);
$username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES);
//get time
$year = substr($obj->dtime, 0, 4);
@ -3431,9 +3628,9 @@ class Wiki
$_GET['all_vers'] = $_POST['all_vers'];
}
self::display_wiki_search_results(
api_htmlentities($_GET['search_term']),
api_htmlentities($_GET['search_content']),
api_htmlentities($_GET['all_vers'])
$_GET['search_term'],
$_GET['search_content'],
$_GET['all_vers']
);
} else {
@ -3625,24 +3822,29 @@ class Wiki
}
/**
* @param array $current_row
*/
public function restorePage()
{
$userId = api_get_user_id();
$_course = $this->courseInfo;
$current_row = $this->getWikiData();
$last_row = $this->getLastWikiData($this->page);
if (empty($last_row)) {
return false;
}
$PassEdit = false;
//Only teachers and platform admin can edit the index page. Only teachers and platform admin can edit an assignment teacher
if (($current_row['reflink']=='index' ||
$current_row['reflink']=='' ||
$current_row['assignment'] == 1
) &&
/* Only teachers and platform admin can edit the index page.
Only teachers and platform admin can edit an assignment teacher*/
if (($current_row['reflink']=='index' || $current_row['reflink']=='' || $current_row['assignment'] == 1) &&
(!api_is_allowed_to_edit(false,true) && $this->group_id == 0)
) {
self::setMessage(Display::display_normal_message(get_lang('OnlyEditPagesCourseManager'), false, true));
self::setMessage(
Display::display_normal_message(get_lang('OnlyEditPagesCourseManager'), false, true)
);
} else {
$PassEdit = false;
//check if is a wiki group
if ($current_row['group_id'] != 0) {
@ -3653,19 +3855,21 @@ class Wiki
) {
$PassEdit = true;
} else {
self::setMessage(Display::display_normal_message(get_lang('OnlyEditPagesGroupMembers'), false, true));
self::setMessage(
Display::display_normal_message(get_lang('OnlyEditPagesGroupMembers'), false, true)
);
}
} else {
$PassEdit = true;
}
// check if is an assignment
$icon_assignment = null;
if ($current_row['assignment']==1) {
//$icon_assignment = null;
if ($current_row['assignment'] == 1) {
self::setMessage(Display::display_normal_message(get_lang('EditAssignmentWarning'), false, true));
$icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
//$icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'),'',ICON_SIZE_SMALL);
} elseif($current_row['assignment']==2) {
$icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'),'',ICON_SIZE_SMALL);
//$icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'),'',ICON_SIZE_SMALL);
if (($userId == $current_row['user_id'])==false) {
if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) {
$PassEdit = true;
@ -3680,13 +3884,13 @@ class Wiki
//show editor if edit is allowed
if ($PassEdit) {
if ($row['editlock']==1 && (api_is_allowed_to_edit(false,true)==false || api_is_platform_admin()==false)) {
if ($current_row['editlock'] == 1 && (api_is_allowed_to_edit(false,true)==false || api_is_platform_admin()==false)) {
self::setMessage(Display::display_normal_message(get_lang('PageLockedExtra'), false, true));
} else {
if ($last_row['is_editing']!=0 && $last_row['is_editing'] != $userId) {
//checking for concurrent users
// Checking for concurrent users
$timestamp_edit = strtotime($last_row['time_edit']);
$time_editing = time()-$timestamp_edit;
$time_editing = time() - $timestamp_edit;
$max_edit_time = 1200; // 20 minutes
$rest_time = $max_edit_time - $time_editing;
$userinfo = api_get_user_info($last_row['is_editing']);
@ -3699,8 +3903,8 @@ class Wiki
self::restore_wikipage(
$current_row['page_id'],
$current_row['reflink'],
api_htmlentities($current_row['title']),
api_htmlentities($current_row['content']),
$current_row['title'],
$current_row['content'],
$current_row['group_id'],
$current_row['assignment'],
$current_row['progress'],
@ -3736,12 +3940,13 @@ class Wiki
/**
* Check last version
* @param int $view
*/
public function checkLastVersion($view)
{
$tbl_wiki = $this->tbl_wiki;
$course_id = $this->course_id;
$condition_session = $this->course_id;
$condition_session = $this->condition_session;
$groupfilter = $this->groupfilter;
$page = $this->page;
$_course = $this->courseInfo;
@ -3759,13 +3964,20 @@ class Wiki
'.$groupfilter.$condition_session.'
ORDER BY id DESC'; //last version
$result = Database::query($sql);
$last_row = Database::fetch_array($result);
if ($view < $last_row['id']) {
$message = '<center>'.get_lang('NoAreSeeingTheLastVersion').'<br />
'.get_lang("Version").' (
<a href="index.php?cidReq='.$_course['code'].'&action=showpage&amp;title='.api_htmlentities(urlencode($current_row['reflink'])).'&group_id='.$current_row['group_id'].'&session_id='.$current_row['session_id'].'&view='.api_htmlentities($_GET['view']).'" title="'.get_lang('CurrentVersion').'">
'.$current_row['version'].'</a> /
<a href="index.php?cidReq='.$_course['code'].'&action=showpage&amp;title='.api_htmlentities(urlencode($last_row['reflink'])).'&group_id='.$last_row['group_id'].'&session_id='.$last_row['session_id'].'" title="'.get_lang('LastVersion').'">'.$last_row['version'].'</a>) <br />'.get_lang("ConvertToLastVersion").': <a href="index.php?cidReq='.$_course['id'].'&action=restorepage&amp;title='.api_htmlentities(urlencode($last_row['reflink'])).'&group_id='.$last_row['group_id'].'&session_id='.$last_row['session_id'].'&view='.api_htmlentities($_GET['view']).'">'.
'.$current_row['version'].'
</a> /
<a href="index.php?cidReq='.$_course['code'].'&action=showpage&amp;title='.api_htmlentities(urlencode($last_row['reflink'])).'&group_id='.$last_row['group_id'].'&session_id='.$last_row['session_id'].'" title="'.get_lang('LastVersion').'">
'.$last_row['version'].'
</a>) <br />'.get_lang("ConvertToLastVersion").':
<a href="index.php?cidReq='.$_course['id'].'&action=restorepage&amp;title='.api_htmlentities(urlencode($last_row['reflink'])).'&group_id='.$last_row['group_id'].'&session_id='.$last_row['session_id'].'&view='.api_htmlentities($_GET['view']).'">'.
get_lang("Restore").'</a></center>';
self::setMessage(Display::display_warning_message($message, false, true));
}
@ -4568,7 +4780,7 @@ class Wiki
echo ' ( '.get_lang('Progress').': '.api_htmlentities($row['progress']).'%, ';
$comment = $row['comment'];
if (!empty($comment)) {
echo get_lang('Comments').': '.api_htmlentities(api_substr($row['comment'],0,100));
echo get_lang('Comments').': '.api_htmlentities(api_substr($row['comment'], 0, 100));
if (api_strlen($row['comment'])>100) {
echo '... ';
}

@ -26,71 +26,9 @@ if (empty($course_info)) {
api_not_allowed(true);
}
$tbl_student_publication = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
if (!empty($course_info['real_id'])) {
$sql = 'SELECT * FROM '.$tbl_student_publication.'
WHERE c_id = '.$course_info['real_id'].' AND id = "'.$id.'"';
$result = Database::query($sql);
if ($result && Database::num_rows($result)) {
$row = Database::fetch_array($result, 'ASSOC');
$full_file_name = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/'.$row['url'];
$item_info = api_get_item_property_info(api_get_course_int_id(), 'work', $row['id']);
allowOnlySubscribedUser(api_get_user_id(), $row['parent_id'], $course_info['real_id']);
if (empty($item_info)) {
api_not_allowed();
}
/*
field show_score in table course : 0 => New documents are visible for all users
1 => New documents are only visible for the teacher(s)
field visibility in table item_property : 0 => eye closed, invisible for all students
1 => eye open
field accepted in table c_student_publication : 0 => eye closed, invisible for all students
1 => eye open
(we should have visibility == accepted , otherwise there is an inconsistency in the Database)
field value in table c_course_setting : 0 => Allow learners to delete their own publications = NO
1 => Allow learners to delete their own publications = YES
+------------------+------------------------------+----------------------------+
|Can download work?| doc visible for all = 0 | doc visible for all = 1|
+------------------+------------------------------+----------------------------+
| visibility = 0 | editor only | editor only |
| | | |
+------------------+------------------------------+----------------------------+
| visibility = 1 | editor | editor |
| | + owner of the work | + any student |
+------------------+------------------------------+----------------------------+
(editor = teacher + admin + anybody with right api_is_allowed_to_edit)
*/
$work_is_visible = ($item_info['visibility'] == 1 && $row['accepted'] == 1);
$doc_visible_for_all = ($course_info['show_score'] == 1);
$is_editor = api_is_allowed_to_edit(true, true, true);
$student_is_owner_of_work = user_is_author($row['id'], $row['user_id']);
if ($is_editor || ($student_is_owner_of_work) || ($doc_visible_for_all && $work_is_visible)) {
$title = $row['title'];
if (array_key_exists('filename', $row) && !empty($row['filename'])) {
$title = $row['filename'];
}
$title = str_replace(' ', '_', $title);
event_download($title);
if (Security::check_abs_path($full_file_name, api_get_path(SYS_COURSE_PATH).api_get_course_path().'/')) {
DocumentManager::file_send_for_download($full_file_name, true, $title);
}
} else {
api_not_allowed();
}
}
} else {
$result = downloadFile($id, $course_info);
if ($result == false) {
api_not_allowed();
}
exit;

@ -246,28 +246,38 @@ if ($form->validate()) {
}
$htmlHeadXtra[] = to_javascript_work();
Display :: display_header(null);
$tpl = new Template();
$content = null;
if (!empty($work_id)) {
if ($is_allowed_to_edit) {
if (api_resource_is_locked_by_gradebook($work_id, LINK_STUDENTPUBLICATION)) {
echo Display::display_warning_message(get_lang('ResourceLockedByGradebook'));
} else {
$form->display();
$comments = getWorkComments($my_folder_data);
$template = $tpl->get_template('work/comments.tpl');
$tpl->assign('work_comment_enabled', ALLOW_USER_COMMENTS);
$tpl->assign('comments', $comments);
$content .= $form->return_form();
$content .= $tpl->fetch($template);
}
} elseif ($is_author) {
if (empty($work_item['qualificator_id']) || $work_item['qualificator_id'] == 0) {
$form->display();
$content .= $form->return_form();
} else {
Display::display_error_message(get_lang('ActionNotAllowed'));
$content .= Display::return_message(get_lang('ActionNotAllowed'), 'error');
}
} elseif ($student_can_edit_in_session && $has_ended == false) {
$form->display();
$content .= $form->return_form();
} else {
Display::display_error_message(get_lang('ActionNotAllowed'));
$content .= Display::return_message(get_lang('ActionNotAllowed'), 'error');
}
} else {
Display::display_error_message(get_lang('ActionNotAllowed'));
$content .= Display::return_message(get_lang('ActionNotAllowed'), 'error');
}
Display :: display_footer();
$tpl->assign('content', $content);
$tpl->display_one_col_template();

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
$language_file = array('exercice', 'work', 'document', 'admin', 'gradebook');
@ -10,7 +11,6 @@ $lib_path = api_get_path(LIBRARY_PATH);
require_once $lib_path.'fileManage.lib.php';
require_once 'work.lib.php';
// Section (for the tabs)
$this_section = SECTION_COURSES;
@ -19,6 +19,7 @@ if (!api_is_allowed_to_edit()) {
}
$courseInfo = api_get_course_info();
$groupId = api_get_group_id();
$workId = isset($_GET['id']) ? intval($_GET['id']) : null;
$workData = get_work_data_by_id($workId);
$homework = get_work_assignment_by_id($workId);
@ -32,8 +33,6 @@ $htmlHeadXtra[] = to_javascript_work();
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(), 'name' => get_lang('StudentPublications'));
$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Edit'));
Display::display_header();
$form = new FormValidator('edit_dir', 'post', api_get_path(WEB_CODE_PATH).'work/edit_work.php?id='.$workId.'&'. api_get_cidreq());
$form->addElement('header', get_lang('Edit'));
@ -60,9 +59,7 @@ if ($homework['expires_on'] != '0000-00-00 00:00:00') {
$there_is_a_expire_date = true;
$defaults['enableExpiryDate'] = true;
} else {
$homework['expires_on'] = api_get_local_time();
$expires_date_array = convert_date_to_array(api_get_local_time(), 'expires');
$defaults = array_merge($defaults, $expires_date_array);
$homework['expires_on'] = null;
$there_is_a_expire_date = false;
}
@ -70,22 +67,17 @@ if ($homework['ends_on'] != '0000-00-00 00:00:00') {
$homework['ends_on'] = api_get_local_time($homework['ends_on']);
$there_is_a_end_date = true;
$defaults['enableEndDate'] = true;
} else {
$homework['ends_on'] = api_get_local_time();
$expires_date_array = convert_date_to_array(api_get_local_time(), 'ends');
$defaults = array_merge($defaults, $expires_date_array);
$homework['ends_on'] = null;
$there_is_a_end_date = false;
}
if ($there_is_a_end_date) {
$end_date_array = convert_date_to_array($homework['ends_on'], 'ends');
$defaults = array_merge($defaults, $end_date_array);
$defaults['ends_on'] = $homework['ends_on'];
}
if ($there_is_a_expire_date) {
$expires_date_array = convert_date_to_array($homework['expires_on'], 'expires');
$defaults = array_merge($defaults, $expires_date_array);
$defaults['expires_on'] = $homework['expires_on'];
}
$defaults['add_to_calendar'] = isset($homework['add_to_calendar']) ? $homework['add_to_calendar'] : null;
@ -93,31 +85,39 @@ $form = getFormWork($form, $defaults);
$form->addElement('hidden', 'work_id', $workId);
$form->addElement('style_submit_button', 'submit', get_lang('ModifyDirectory'), 'class="save"');
$display_edit_form = true;
if ($form->validate()) {
$params = $form->exportValues();
$workId = $params['work_id'];
$edit_check = false;
$editCheck = false;
$workData = get_work_data_by_id($workId);
if (!empty($workData)) {
$edit_check = true;
$editCheck = true;
} else {
$edit_check = true;
$editCheck = true;
}
if ($edit_check) {
if ($editCheck) {
updateWork($workId, $params, $courseInfo);
updatePublicationAssignment($workId, $params, $courseInfo, $group_id);
updatePublicationAssignment($workId, $params, $courseInfo, $groupId);
updateDirName($workData, $params['new_dir']);
Display::display_confirmation_message(get_lang('FolderEdited'));
$currentUrl = api_get_path(WEB_CODE_PATH).'work/edit_work.php?id='.$workId.'&'.api_get_cidreq();
Session::write('message', Display::return_message(get_lang('FolderEdited'), 'success'));
header('Location: '.$currentUrl);
exit;
} else {
Display::display_warning_message(get_lang('FileExists'));
Session::write('message', Display::return_message(get_lang('FileExists'), 'warning'));
}
}
Display::display_header();
$message = Session::read('message');
echo $message;
Session::erase('message');
$form->display();
Display :: display_footer();

@ -39,15 +39,25 @@ if (!empty($group_id)) {
$show_work = true;
} else {
// you are not a teacher
$show_work = GroupManager::user_has_access($user_id, $group_id, GroupManager::GROUP_TOOL_WORK);
$show_work = GroupManager::user_has_access(
$user_id,
$group_id,
GroupManager::GROUP_TOOL_WORK
);
}
if (!$show_work) {
api_not_allowed();
}
$interbreadcrumb[] = array ('url' => '../group/group.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array ('url' => '../group/group_space.php?gidReq='.$group_id, 'name' => get_lang('GroupSpace').' '.$group_properties['name']);
$interbreadcrumb[] = array(
'url' => '../group/group.php',
'name' => get_lang('Groups')
);
$interbreadcrumb[] = array(
'url' => '../group/group_space.php?gidReq='.$group_id,
'name' => get_lang('GroupSpace').' '.$group_properties['name']
);
} else {
if (!api_is_allowed_to_edit(false, true)) {
api_not_allowed(true);
@ -57,6 +67,15 @@ if (!empty($group_id)) {
$action = isset($_GET['action']) ? $_GET['action'] : null;
switch ($action) {
case 'export_to_pdf':
exportAllWork($studentId, $courseInfo, 'pdf');
break;
exit;
case 'download':
if (api_is_allowed_to_edit()) {
downloadAllFilesPerUser($studentId, $courseInfo);
}
break;
case 'delete_all':
if (api_is_allowed_to_edit()) {
$deletedItems = deleteAllWorkPerUser($studentId, $courseInfo);
@ -74,18 +93,33 @@ switch ($action) {
break;
}
$interbreadcrumb[] = array ('url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(), 'name' => get_lang('StudentPublications'));
$interbreadcrumb[] = array ('url' => '#', 'name' => $userInfo['complete_name']);
$interbreadcrumb[] = array(
'url' => api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
'name' => get_lang('StudentPublications')
);
$interbreadcrumb[] = array(
'url' => '#',
'name' => $userInfo['complete_name']
);
Display :: display_header(null);
$workPerUser = getWorkPerUser($studentId);
echo Session::read('message');
Session::erase('message');
echo '<div class="actions">';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'">'.
Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM).'</a>';
if (api_is_allowed_to_edit()) {
echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/student_work.php?action=export_to_pdf&studentId='.$studentId.'&'.api_get_cidreq().'">'.
Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/student_work.php?action=download&studentId='.$studentId.'&'.api_get_cidreq().'">'.
Display::return_icon('save.png', get_lang('Download'), '', ICON_SIZE_MEDIUM).'</a>';
echo '<a
onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;"
href="'.api_get_path(WEB_CODE_PATH).'work/student_work.php?action=delete_all&studentId='.$studentId.'&'.api_get_cidreq().'">'.
@ -94,13 +128,15 @@ if (api_is_allowed_to_edit()) {
echo '</div>';
$workPerUser = getWorkPerUser($studentId);
$table = new HTML_Table(array('class' => 'data_table'));
$column = 0;
$row = 0;
$headers = array(
get_lang('Title'), get_lang('HandedOutDate'), get_lang('HandOutDateLimit'), get_lang('Score'), get_lang('Actions')
get_lang('Title'),
get_lang('HandedOutDate'),
get_lang('HandOutDateLimit'),
get_lang('Score'),
get_lang('Actions')
);
foreach ($headers as $header) {
$table->setHeaderContents($row, $column, $header);

@ -77,7 +77,7 @@ $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'work/work_list.
$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('UploadADocument'));
$form = new FormValidator('form', 'POST', api_get_self()."?".api_get_cidreq()."&id=".$work_id, '', array('enctype' => "multipart/form-data"));
setWorkUploadForm($form);
setWorkUploadForm($form, $workInfo['allow_text_assignment']);
$form->addElement('hidden', 'id', $work_id);
$form->addElement('hidden', 'sec_token', $token);
@ -85,6 +85,7 @@ $error_message = null;
$succeed = false;
if ($form->validate()) {
if ($student_can_edit_in_session && $check) {
$values = $form->getSubmitValues();
// Process work

@ -62,7 +62,7 @@ $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'work/work_list.
$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('UploadFromTemplate'));
$form = new FormValidator('form', 'POST', api_get_self()."?".api_get_cidreq()."&id=".$work_id, '', array('enctype' => "multipart/form-data"));
setWorkUploadForm($form, false);
setWorkUploadForm($form, $workInfo['allow_text_assignment']);
$form->addElement('hidden', 'document_id', $documentId);
$form->addElement('hidden', 'id', $work_id);
$form->addElement('hidden', 'sec_token', $token);

@ -120,6 +120,7 @@ function settingsForm($defaults)
$form->addGroup($group, '', get_lang('StudentAllowedToDeleteOwnPublication'));
$form->addElement('button', 'submit', get_lang('Save'));
$form->setDefaults($defaults);
return $form->return_form();
}
@ -214,7 +215,7 @@ function get_work_data_by_id($id)
$id = intval($id);
$course_id = api_get_course_int_id();
$work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$sql = "SELECT * FROM $work_table WHERE id = $id AND c_id = $course_id";
$sql = "SELECT * FROM $work_table WHERE id = $id AND c_id = $course_id";
$result = Database::query($sql);
$work = array();
if (Database::num_rows($result)) {
@ -222,6 +223,18 @@ function get_work_data_by_id($id)
if (empty($work['title'])) {
$work['title'] = basename($work['url']);
}
$work['download_url'] = api_get_path(WEB_CODE_PATH).'work/download.php?id='.$work['id'].'&'.api_get_cidreq();
$work['view_url'] = api_get_path(WEB_CODE_PATH).'work/view.php?id='.$work['id'].'&'.api_get_cidreq();
$work['show_url'] = api_get_path(WEB_CODE_PATH).'work/show_file.php?id='.$work['id'].'&'.api_get_cidreq();
if ($work['contains_file']) {
$fileInfo = pathinfo($work['title']);
if (is_array($fileInfo) &&
!empty($fileInfo['extension']) &&
in_array($fileInfo['extension'], array('jpg', 'png', 'gif'))
) {
$work['show_content'] = '<img src="'.$work['show_url'].'"/>';
}
}
}
return $work;
}
@ -375,6 +388,34 @@ function getWorkPerUser($userId)
return $result;
}
function getUniqueStudentAttemptsTotal($workId, $groupId, $course_id, $sessionId)
{
$work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$course_id = intval($course_id);
$workId = intval($workId);
$sessionId = intval($sessionId);
$groupId = intval($groupId);
$sql = "SELECT count(DISTINCT u.user_id)
FROM $work_table w
INNER JOIN $user_table u
ON w.user_id = u.user_id
WHERE
w.c_id = $course_id AND
w.session_id = $sessionId AND
w.parent_id = ".$workId." AND
w.post_group_id = ".$groupId." AND
w.active IN (0, 1)
";
$res_document = Database::query($sql);
$rowCount = Database::fetch_row($res_document);
return $rowCount[0];
}
/**
* @param mixed $workId
* @param int $groupId
@ -558,7 +599,8 @@ function display_student_publications_list($id, $my_folder_data, $work_parents,
// form edit directory
if (!empty($row['has_properties'])) {
$sql = Database::query('SELECT * FROM '.$work_assigment.' WHERE c_id = '.$course_id.' AND id = "'.$row['has_properties'].'" LIMIT 1');
$sql = Database::query('SELECT * FROM '.$work_assigment.'
WHERE c_id = '.$course_id.' AND id = "'.$row['has_properties'].'" LIMIT 1');
$homework = Database::fetch_array($sql);
}
// save original value for later
@ -769,12 +811,12 @@ function showTeacherWorkGrid()
{
$columnModel = array(
//array('name'=>'id', 'index'=>'id', 'width'=>'50', 'align'=>'left', 'hidden' => 'true'),
array('name'=>'type', 'index'=>'type', 'width'=>'50', 'align'=>'left', 'sortable' => 'false'),
array('name'=>'title', 'index'=>'title', 'width'=>'300', 'align'=>'left'),
array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'150', 'align'=>'left'),
array('name'=>'expires_on', 'index'=>'expires_on', 'width'=>'150', 'align'=>'left'),
array('name'=>'end_on', 'index'=>'end_on', 'width'=>'150', 'align'=>'left'),
array('name'=>'actions', 'index'=>'actions', 'width'=>'150', 'align'=>'left', 'sortable'=>'false')
array('name'=>'type', 'index'=>'type', 'width'=>'35', 'align'=>'left', 'sortable' => 'false'),
array('name'=>'title', 'index'=>'title', 'width'=>'300', 'align'=>'left', 'wrap_cell' => "true"),
array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'125', 'align'=>'left'),
array('name'=>'expires_on', 'index'=>'expires_on', 'width'=>'125', 'align'=>'left'),
array('name'=>'amount', 'index'=>'end_on', 'width'=>'110', 'align'=>'left'),
array('name'=>'actions', 'index'=>'actions', 'width'=>'110', 'align'=>'left', 'sortable'=>'false')
);
$token = null;
@ -788,7 +830,7 @@ function showTeacherWorkGrid()
get_lang('Title'),
get_lang('SentDate'),
get_lang('HandOutDateLimit'),
get_lang('HandedOut'),
get_lang('AmountSubmitted'),
get_lang('Actions')
);
@ -1354,59 +1396,31 @@ function to_javascript_work()
return Math.floor(d.getTime()/1000);
}
function validate() {
var expires_day = document.form1.expires_day.value;
var expires_month = document.form1.expires_month.value;
var expires_year = document.form1.expires_year.value;
var expires_hour = document.form1.expires_hour.value;
var expires_minute = document.form1.expires_minute.value;
var expires_date = mktime(expires_hour,expires_minute,0,expires_month,expires_day,expires_year)
var ends_day = document.form1.ends_day.value;
var ends_month = document.form1.ends_month.value;
var ends_year = document.form1.ends_year.value;
var ends_hour = document.form1.ends_hour.value;
var ends_minute = document.form1.ends_minute.value;
var ends_date = mktime(ends_hour,ends_minute,0,ends_month,ends_day,ends_year);
var new_dir = document.form1.new_dir.value;
msg_id1 = document.getElementById("msg_error1");
msg_id2 = document.getElementById("msg_error2");
msg_id3 = document.getElementById("msg_error3");
msg_id4 = document.getElementById("msg_error4");
msg_id5 = document.getElementById("msg_error_weight");
if (new_dir=="") {
msg_id1.style.display ="block";
msg_id1.innerHTML="'.get_lang('FieldRequired', '').'";
msg_id2.innerHTML="";msg_id3.innerHTML="";msg_id4.innerHTML="";msg_id5.innerHTML="";
} else if(document.form1.enableExpiryDate.checked && document.form1.enableEndDate.checked && expires_date > ends_date) {
msg_id2.style.display ="block";
msg_id2.innerHTML="'.get_lang('EndDateCannotBeBeforeTheExpireDate', '').'";
msg_id1.innerHTML="";msg_id3.innerHTML="";msg_id4.innerHTML="";msg_id5.innerHTML="";
} else if (!checkDate(expires_month,expires_day,expires_year)) {
msg_id3.style.display ="block";
msg_id3.innerHTML="'.get_lang('InvalidDate', '').'";
msg_id1.innerHTML="";msg_id2.innerHTML="";msg_id4.innerHTML="";msg_id5.innerHTML="";
} else if (!checkDate(ends_month,ends_day,ends_year)) {
msg_id4.style.display ="block";
msg_id4.innerHTML="'.get_lang('InvalidDate', '').'";
msg_id1.innerHTML="";msg_id2.innerHTML="";msg_id3.innerHTML="";msg_id5.innerHTML="";
} else {
if (document.form1.make_calification.checked) {
var weight = document.form1.weight.value;
if(weight=="") {
msg_id5.style.display ="block";
msg_id5.innerHTML="'.get_lang('WeightNecessary', '').'";
msg_id1.innerHTML="";msg_id2.innerHTML="";msg_id3.innerHTML="";msg_id4.innerHTML="";
return false;
}
}
document.form1.action = "work.php?'. api_get_cidreq().'&origin='.$origin.'&gradebook='.(empty($_GET['gradebook'])?'':'view').'";
document.form1.submit();
}
}
function setFocus() {
$("#work_title").focus();
}
$(document).ready(function () {
setFocus();
$("#expiry_date").click(function() {
var checked = $("#expiry_date").attr("checked");
if (checked) {
$("#option2").show();
$("#option3").show();
$("#end_date").attr("checked", true);
} else {
$("#option2").hide();
$("#option3").hide();
$("#end_date").attr("checked", false);
}
});
$("#end_date").click(function() {
$("#option3").toggle();
});
});
</script>';
return $js;
}
@ -1540,8 +1554,8 @@ function get_count_work($work_id, $onlyMeUserId = null, $notMeUserId = null)
*/
function getWorkListStudent($start, $limit, $column, $direction, $where_condition, $getCount = false)
{
$workTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$workTableAssignment = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
$workTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$workTableAssignment = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
$course_id = api_get_course_int_id();
$session_id = api_get_session_id();
@ -1585,7 +1599,10 @@ function getWorkListStudent($start, $limit, $column, $direction, $where_conditio
";
$sql .= " ORDER BY $column $direction ";
$sql .= " LIMIT $start, $limit";
if (!empty($start) && !empty($limit)) {
$sql .= " LIMIT $start, $limit";
}
$result = Database::query($sql);
@ -1598,13 +1615,10 @@ function getWorkListStudent($start, $limit, $column, $direction, $where_conditio
$url = api_get_path(WEB_CODE_PATH).'work/work_list.php?'.api_get_cidreq();
$urlOthers = api_get_path(WEB_CODE_PATH).'work/work_list_others.php?'.api_get_cidreq().'&id=';
while ($work = Database::fetch_array($result, 'ASSOC')) {
$isSubscribed = userIsSubscribedToWork(api_get_user_id(), $work['id'], $course_id);
if ($isSubscribed == false) {
continue;
}
$work['type'] = Display::return_icon('work.png');
$work['expires_on'] = $work['expires_on'] == '0000-00-00 00:00:00' ? null : api_get_local_time($work['expires_on']);
if (empty($work['title'])) {
@ -1642,9 +1656,9 @@ function getWorkListTeacher($start, $limit, $column, $direction, $where_conditio
$direction = 'desc';
}
$column = !empty($column) ? Database::escape_string($column) : 'sent_date';
$start = intval($start);
$limit = intval($limit);
$column = !empty($column) ? Database::escape_string($column) : 'sent_date';
$start = intval($start);
$limit = intval($limit);
// Get list from database
if ($is_allowed_to_edit) {
@ -1661,12 +1675,11 @@ function getWorkListTeacher($start, $limit, $column, $direction, $where_conditio
w.c_id = $course_id
$condition_session AND
$active_condition AND
(parent_id = 0)
$where_condition AND
(parent_id = 0) AND
post_group_id = '".$group_id."'
$where_condition
ORDER BY $column $direction
LIMIT $start, $limit";
$result = Database::query($sql);
if ($getCount) {
@ -1679,14 +1692,30 @@ function getWorkListTeacher($start, $limit, $column, $direction, $where_conditio
$workId = $work['id'];
$work['type'] = Display::return_icon('work.png');
$work['expires_on'] = $work['expires_on'] == '0000-00-00 00:00:00' ? null : api_get_local_time($work['expires_on']);
$work['ends_on'] = $work['ends_on'] == '0000-00-00 00:00:00' ? null : api_get_local_time($work['ends_on']);
//$work['ends_on'] = $work['ends_on'] == '0000-00-00 00:00:00' ? null : api_get_local_time($work['ends_on']);
$totalUsers = getStudentSubscribedToWork(
$workId,
$course_id,
$group_id,
$session_id,
true
);
$work['amount'] = Display::label(
getUniqueStudentAttemptsTotal($workId, $group_id, $course_id, $session_id).'/'.
$totalUsers,
'success'
);
//$work['amount'] =
if (empty($work['title'])) {
$work['title'] = basename($work['url']);
}
$work['title'] = Display::url($work['title'], $url.'&id='.$workId);
$work['title'] .= ' '.Display::label(get_count_work($work['id']), 'success');
$work['sent_date'] = date_to_str_ago($work['sent_date']).' <br />'.api_get_local_time($work['sent_date']);
$work['sent_date'] = api_get_local_time($work['sent_date']);
$editLink = Display::url(
Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL),
@ -1942,16 +1971,16 @@ function get_work_user_list($start, $limit, $column, $direction, $work_id, $wher
$direction = 'desc';
}
$work_data = get_work_data_by_id($work_id);
$work_data = get_work_data_by_id($work_id);
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$condition_session = api_get_session_condition($session_id);
$locked = api_resource_is_locked_by_gradebook($work_id, LINK_STUDENTPUBLICATION);
if (!empty($work_data)) {
if (!empty($group_id)) {
$extra_conditions = " work.post_group_id = '".intval($group_id)."' "; // set to select only messages posted by the user's group
$extra_conditions = " work.post_group_id = '".intval($group_id)."' ";
// set to select only messages posted by the user's group
} else {
$extra_conditions = " work.post_group_id = '0' ";
}
@ -2004,8 +2033,11 @@ function get_work_user_list($start, $limit, $column, $direction, $work_id, $wher
$sql = " $select
FROM $work_condition $user_condition
WHERE $extra_conditions $where_condition $condition_session
ORDER BY $column $direction
LIMIT $start, $limit";
ORDER BY $column $direction";
if (!empty($start) && !empty($limit)) {
$sql .= "LIMIT $start, $limit";
}
$result = Database::query($sql);
$works = array();
@ -2017,6 +2049,7 @@ function get_work_user_list($start, $limit, $column, $direction, $work_id, $wher
while ($work = Database::fetch_array($result, 'ASSOC')) {
$item_id = $work['id'];
//$workItem = get_work_data_by_id($item_id);
// Get the author ID for that document from the item_property table
$is_author = false;
@ -2054,7 +2087,10 @@ function get_work_user_list($start, $limit, $column, $direction, $work_id, $wher
if ($work['qualification'] == '') {
$qualification_string = Display::label('-');
} else {
$qualification_string = Display::label($work['qualification'], 'info');
$qualification_string = Display::label(
$work['qualification'].' / '.$work_data['qualification'],
'info'
);
}
}
@ -2067,8 +2103,7 @@ function get_work_user_list($start, $limit, $column, $direction, $work_id, $wher
$add_string = Display::label(get_lang('Expired'), 'important');
}
if (
($can_read && $work['accepted'] == '1') ||
if (($can_read && $work['accepted'] == '1') ||
($is_author && in_array($work['accepted'], array('1', '0'))) ||
$is_allowed_to_edit
) {
@ -2091,7 +2126,8 @@ function get_work_user_list($start, $limit, $column, $direction, $work_id, $wher
$link_to_download = null;
// If URL is present then there's a file to download keep BC.
if ($work['contains_file'] || !empty($work['url'])) {
$link_to_download = '<a href="download.php?id='.$item_id.'">'.Display::return_icon('save.png', get_lang('Save'),array(), ICON_SIZE_SMALL).'</a> ';
$link_to_download = '<a href="download.php?id='.$item_id.'&'.api_get_cidreq().'">'.
Display::return_icon('save.png', get_lang('Save'),array(), ICON_SIZE_SMALL).'</a> ';
} else {
//$link_to_download = '<a href="view.php?id='.$item_id.'">'.Display::return_icon('save_na.png', get_lang('Save'),array(), ICON_SIZE_SMALL).'</a> ';
}
@ -2651,15 +2687,30 @@ function getUserToWork($userId, $workId, $courseId)
/**
* @param int $workId
* @param int $courseId
* @param bool $getCount
* @return array
*/
function getAllUserToWork($workId, $courseId)
function getAllUserToWork($workId, $courseId, $getCount = false)
{
$table = Database::get_course_table(TABLE_STUDENT_PUBLICATION_REL_USER);
$params = array(
'work_id = ? and c_id = ?' => array($workId, $courseId)
);
return Database::select('*', $table, array('where' => $params));
if ($getCount) {
$count = 0;
$result = Database::select(
'count(user_id) as count',
$table,
array('where' => $params),
'simple'
);
if (!empty($result)) {
$count = intval($result['count']);
}
return $count;
} else {
return Database::select('*', $table, array('where' => $params));
}
}
/**
@ -2703,6 +2754,45 @@ function userIsSubscribedToWork($userId, $workId, $courseId)
return false;
}
function getStudentSubscribedToWork($workId, $courseId, $groupId = null, $sessionId = null, $getCount = false)
{
$usersInWork = null;
$usersInCourse = null;
if (empty($groupId)) {
$courseInfo = api_get_course_info_by_id($courseId);
$usersInCourse = CourseManager::get_user_list_from_course_code(
$courseInfo['code'],
$sessionId,
null,
null,
null,
$getCount
);
} else {
$usersInCourse = GroupManager::get_users(
$groupId,
false,
null,
null,
$getCount,
$courseId
);
}
if (ADD_DOCUMENT_TO_WORK == true) {
$usersInWork = getAllUserToWork($workId, $courseId, $getCount);
if (empty($usersInWork)) {
return $usersInCourse;
} else {
return $usersInWork;
}
} else {
return $usersInCourse;
}
}
/**
* @param int $userId
* @param int $workId
@ -2773,12 +2863,17 @@ function getAllDocumentsFromWorkToString($workId, $courseInfo)
}
/**
* Returns fckeditor toolbar
* Returns fck editor toolbar
* @return array
*/
function getWorkDescriptionToolbar()
{
return array('ToolbarSet' => 'Work', 'Width' => '100%', 'Height' => '400');
return array(
'ToolbarStartExpanded' => 'true',
'ToolbarSet' => 'Work',
'Width' => '100%',
'Height' => '400'
);
}
/**
@ -3023,20 +3118,37 @@ function getWorkDateValidationStatus($homework) {
/**
* @param FormValidator $form
* @param bool $uploadFile
* @param int $uploadFormType
*/
function setWorkUploadForm($form, $uploadFile = true)
function setWorkUploadForm($form, $uploadFormType = 0)
{
$form->addElement('header', get_lang('UploadADocument'));
$form->addElement('hidden', 'contains_file', 0, array('id'=>'contains_file_id'));
$form->addElement('hidden', 'active', 1);
$form->addElement('hidden', 'accepted', 1);
if ($uploadFile) {
$form->addElement('file', 'file', get_lang('UploadADocument'), 'size="40" onchange="updateDocumentTitle(this.value)"');
$form->add_real_progress_bar('uploadWork', 'file');
}
$form->addElement('text', 'title', get_lang('Title'), array('id' => 'file_upload', 'class' => 'span4'));
$form->add_html_editor('description', get_lang('Description'), false, false, getWorkDescriptionToolbar());
$form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
switch ($uploadFormType) {
case 0:
// File and text.
$form->addElement('file', 'file', get_lang('UploadADocument'), 'size="40" onchange="updateDocumentTitle(this.value)"');
$form->add_real_progress_bar('uploadWork', 'file');
$form->add_html_editor('description', get_lang('Description'), false, false, getWorkDescriptionToolbar());
break;
case 1:
// Only text.
$form->add_html_editor('description', get_lang('Description'), false, false, getWorkDescriptionToolbar());
$form->addRule('description', get_lang('ThisFieldIsRequired'), 'required');
break;
case 2:
// Only file.
$form->addElement('file', 'file', get_lang('UploadADocument'), 'size="40" onchange="updateDocumentTitle(this.value)"');
$form->add_real_progress_bar('uploadWork', 'file');
$form->addRule('file', get_lang('ThisFieldIsRequired'), 'required');
break;
}
$form->addElement('style_submit_button', 'submitWork', get_lang('Send'), array('class'=> 'upload', 'value' => "submitWork"));
}
@ -3372,17 +3484,14 @@ function updateWork($workId, $params, $courseInfo)
* @param int $workId
* @param array $params
* @param array $courseInfo
* @param int $group_id
* @param int $groupId
*/
function updatePublicationAssignment($workId, $params, $courseInfo, $group_id)
function updatePublicationAssignment($workId, $params, $courseInfo, $groupId)
{
$workId = intval($workId);
$table = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
$workTable = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$workId = intval($workId);
$time = time();
$course_id = $courseInfo['real_id'];
// Insert into agenda
@ -3396,7 +3505,7 @@ function updatePublicationAssignment($workId, $params, $courseInfo, $group_id)
$date = $end_date = $time;
if (!empty($params['enableExpiryDate'])) {
$end_date = get_date_from_select('expires', $params);
$end_date = $params['expires_on'];
$date = $end_date;
}
@ -3413,15 +3522,15 @@ function updatePublicationAssignment($workId, $params, $courseInfo, $group_id)
$agenda->type = 'course';
if (empty($agendaId)) {
$agendaId = $agenda->add_event($date, $end_date, 'false', null, $title, $content, array('GROUP:'.$group_id));
$agendaId = $agenda->add_event($date, $end_date, 'false', null, $title, $content, array('GROUP:'.$groupId));
} else {
$agenda->edit_event($agendaId, $end_date, $end_date, 'false', null, $title, $content);
}
}
$qualification = isset($params['qualification']) && !empty($params['qualification']) ? 1 : 0;
$expiryDate = (isset($params['enableExpiryDate']) && $params['enableExpiryDate'] == 1) ? api_get_utc_datetime(get_date_from_select('expires', $params)) : '0000-00-00 00:00:00';
$endDate = ((isset($params['enableEndDate']) && $params['enableEndDate']==1) ? api_get_utc_datetime(get_date_from_select('ends', $params)) : '0000-00-00 00:00:00');
$expiryDate = (isset($params['enableExpiryDate']) && $params['enableExpiryDate'] == 1) ? api_get_utc_datetime($params['expires_on']) : '0000-00-00 00:00:00';
$endDate = ((isset($params['enableEndDate']) && $params['enableEndDate']==1) ? api_get_utc_datetime($params['ends_on']) : '0000-00-00 00:00:00');
$data = get_work_assignment_by_id($workId, $course_id);
@ -3587,6 +3696,11 @@ function deleteWorkItem($item_id, $courseInfo)
*/
function getFormWork($form, $defaults = array())
{
if (!empty($defaults)) {
if (isset($defaults['submit'])) {
unset($defaults['submit']);
}
}
// Create the form that asks for the directory name
$form->addElement('text', 'new_dir', get_lang('AssignmentName'));
$form->addRule('new_dir', get_lang('ThisFieldIsRequired'), 'required');
@ -3600,7 +3714,8 @@ function getFormWork($form, $defaults = array())
get_lang('AdvancedParameters'),
array('style' => 'vertical-align:center')
).
' '.get_lang('AdvancedParameters').'</span></a>'
' '.get_lang('AdvancedParameters').
'</span></a>'
);
if (!empty($defaults) && (isset($defaults['enableEndDate']) || isset($defaults['enableExpiryDate']))) {
@ -3640,50 +3755,64 @@ function getFormWork($form, $defaults = array())
$form->addElement('text', 'weight', get_lang('WeightInTheGradebook'));
$form->addElement('html', '</div>');
$form->addElement('checkbox', 'enableExpiryDate',null,get_lang('EnableExpiryDate'), 'onclick="javascript: if(this.checked){document.getElementById(\'option2\').style.display = \'block\';}else{document.getElementById(\'option2\').style.display = \'none\';}"');
$form->addElement('checkbox', 'enableExpiryDate', null, get_lang('EnableExpiryDate'), 'id="expiry_date"');
if (isset($defaults['enableExpiryDate']) && $defaults['enableExpiryDate']) {
$form->addElement('html', '<div id="option2" style="display: block;">');
} else {
$form->addElement('html', '<div id="option2" style="display: none;">');
}
if (!isset($defaults['expires'])) {
$expires_date_array = convert_date_to_array(api_get_local_time(), 'expires');
$defaults = array_merge($defaults, $expires_date_array);
$currentDate = substr(api_get_local_time(), 0, 10);
if (!isset($defaults['expires_on'])) {
$date = substr($currentDate, 0, 10);
$defaults['expires_on'] = $date.' 23:59';
}
if (!isset($defaults['ends'])) {
$expires_date_array = convert_date_to_array(api_get_local_time(), 'ends');
$defaults = array_merge($defaults, $expires_date_array);
if (!isset($defaults['ends_on'])) {
$date = substr($currentDate, 0, 10);
$defaults['ends_on'] = $date.' 23:59';
}
$form->addGroup(create_group_date_select($form), 'expires', get_lang('ExpiresAt'));
$form->addElement('datetimepicker', 'expires_on', get_lang('ExpiresAt'));
$form->addElement('html', '</div>');
$form->addElement('checkbox', 'enableEndDate', null, get_lang('EnableEndDate'), 'onclick="javascript: if(this.checked){document.getElementById(\'option3\').style.display = \'block\';}else{document.getElementById(\'option3\').style.display = \'none\';}"');
$form->addElement('checkbox', 'enableEndDate', null, get_lang('EnableEndDate'), 'id="end_date"');
if (isset($defaults['enableEndDate']) && $defaults['enableEndDate']) {
if (isset($defaults['enableEndDate']) && $defaults['enableEndDate']) {
$form->addElement('html', '<div id="option3" style="display: block;">');
} else {
} else {
$form->addElement('html', '<div id="option3" style="display: none;">');
}
}
$form->addGroup(create_group_date_select($form), 'ends', get_lang('EndsAt'));
$form->addElement('html', '</div>');
$form->addElement('datetimepicker', 'ends_on', get_lang('EndsAt'));
$form->addElement('html', '</div>');
$form->addElement('checkbox', 'add_to_calendar', null, get_lang('AddToCalendar'));
$form->addElement('select', 'allow_text_assignment', get_lang('DocumentType'), getUploadDocumentType());
$form->addElement('checkbox', 'add_to_calendar', null, get_lang('AddToCalendar'));
$form->addElement('checkbox', 'allow_text_assignment', null, get_lang('AllowTextAssignments'));
$form->addElement('html', '</div>');
$form->addElement('html', '</div>');
if ($defaults['enableExpiryDate'] && $defaults['enableEndDate']) {
$form->addRule(array('expires', 'ends'), get_lang('DateExpiredNotBeLessDeadLine'), 'comparedate');
}
if (!empty($defaults)) {
if (isset($defaults['enableExpiryDate']) && isset($defaults['enableEndDate'])) {
$form->addRule(array('expires_on', 'ends_on'), get_lang('DateExpiredNotBeLessDeadLine'), 'comparedate');
}
if (!empty($defaults)) {
$form->setDefaults($defaults);
}
}
return $form;
return $form;
}
/**
* @return array
*/
function getUploadDocumentType()
{
return array(
0 => get_lang('AllowFileOrText'),
1 => get_lang('AllowOnlyText'),
2 => get_lang('AllowOnlyFiles')
);
}
/**
@ -3808,10 +3937,13 @@ function showStudentList($workId)
get_lang('Works')
);
$order = api_is_western_name_order() ? 'firstname' : 'lastname';
$params = array(
'autowidth' => 'true',
'height' => 'auto',
'rowNum' => 10
'rowNum' => 10,
'sortname' => $order,
'sortorder' => 'asc'
);
$html = '<script>
@ -3837,7 +3969,7 @@ function showStudentList($workId)
* @param int $groupId
* @param int $start
* @param int $limit
* @param $sidx
* @param string $sidx
* @param string $sord
* @param $getCount
* @return array|int
@ -3845,16 +3977,39 @@ function showStudentList($workId)
function getWorkUserList($courseCode, $sessionId, $groupId, $start, $limit, $sidx, $sord, $getCount = false)
{
if (!empty($groupId)) {
$userList = GroupManager::get_users($groupId, false, $start, $limit, $getCount);
$userList = GroupManager::get_users($groupId, false, $start, $limit, $getCount, null, $sidx, $sord);
} else {
$limitString = null;
if (!empty($start) && !empty($limit)) {
$limitString = " LIMIT $start, $limit";
}
$orderBy = null;
if (!empty($sidx) && !empty($sord)) {
$sidx = Database::escape_string($sidx);
$sord = Database::escape_string($sord);
$orderBy = "ORDER BY $sidx $sord";
}
if (empty($sessionId)) {
$userList = CourseManager::get_user_list_from_course_code($courseCode, $sessionId, $limitString, null, STUDENT, $getCount);
$userList = CourseManager::get_user_list_from_course_code(
$courseCode,
$sessionId,
$limitString,
$orderBy ,
STUDENT,
$getCount
);
} else {
$userList = CourseManager::get_user_list_from_course_code($courseCode, $sessionId, $limitString, null, 0, $getCount);
$userList = CourseManager::get_user_list_from_course_code(
$courseCode,
$sessionId,
$limitString,
$orderBy,
0,
$getCount
);
}
if ($getCount == false) {
$userList = array_keys($userList);
@ -3911,3 +4066,242 @@ function getWorkUserListData($workId, $courseCode, $sessionId, $groupId, $start,
}
return $results;
}
/**
* @param int $id
* @param array $course_info
* @param bool $download
* @return bool
*/
function getFile($id, $course_info, $download = true)
{
$file = getFileContents($id, $course_info);
if (!empty($file) && is_array($file)) {
DocumentManager::file_send_for_download(
$file['path'],
$download,
$file['title']
);
}
return false;
}
/**
* @param int $id
* @param array $course_info
* @return bool
*/
function downloadFile($id, $course_info)
{
return getFile($id, $course_info, true);
}
/**
* @param int $id
* @param array $course_info
* @return array|bool
*/
function getFileContents($id, $course_info)
{
$id = intval($id);
if (empty($course_info) || empty($id)) {
return false;
}
$tbl_student_publication = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
if (!empty($course_info['real_id'])) {
$sql = 'SELECT * FROM '.$tbl_student_publication.'
WHERE c_id = '.$course_info['real_id'].' AND id = "'.$id.'"';
$result = Database::query($sql);
if ($result && Database::num_rows($result)) {
$row = Database::fetch_array($result, 'ASSOC');
$full_file_name = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/'.$row['url'];
$item_info = api_get_item_property_info(api_get_course_int_id(), 'work', $row['id']);
allowOnlySubscribedUser(api_get_user_id(), $row['parent_id'], $course_info['real_id']);
if (empty($item_info)) {
api_not_allowed();
}
/*
field show_score in table course :
0 => New documents are visible for all users
1 => New documents are only visible for the teacher(s)
field visibility in table item_property :
0 => eye closed, invisible for all students
1 => eye open
field accepted in table c_student_publication :
0 => eye closed, invisible for all students
1 => eye open
( We should have visibility == accepted, otherwise there is an
inconsistency in the Database)
field value in table c_course_setting :
0 => Allow learners to delete their own publications = NO
1 => Allow learners to delete their own publications = YES
+------------------+-------------------------+------------------------+
|Can download work?| doc visible for all = 0 | doc visible for all = 1|
+------------------+-------------------------+------------------------+
| visibility = 0 | editor only | editor only |
| | | |
+------------------+-------------------------+------------------------+
| visibility = 1 | editor | editor |
| | + owner of the work | + any student |
+------------------+-------------------------+------------------------+
(editor = teacher + admin + anybody with right api_is_allowed_to_edit)
*/
$work_is_visible = ($item_info['visibility'] == 1 && $row['accepted'] == 1);
$doc_visible_for_all = ($course_info['show_score'] == 1);
$is_editor = api_is_allowed_to_edit(true, true, true);
$student_is_owner_of_work = user_is_author($row['id'], $row['user_id']);
if ($is_editor ||
($student_is_owner_of_work) ||
($doc_visible_for_all && $work_is_visible)
) {
$title = $row['title'];
if (array_key_exists('filename', $row) && !empty($row['filename'])) {
$title = $row['filename'];
}
$title = str_replace(' ', '_', $title);
event_download($title);
if (Security::check_abs_path(
$full_file_name,
api_get_path(SYS_COURSE_PATH).api_get_course_path().'/')
) {
return array(
'path' => $full_file_name,
'title' => $title
);
}
}
}
}
return false;
}
/**
* @param int $userId
* @param array $courseInfo
* @param string $format
* @return bool
*/
function exportAllWork($userId, $courseInfo, $format = 'pdf') {
$userInfo = api_get_user_info($userId);
if (empty($userInfo) || empty($courseInfo)) {
return false;
}
$workPerUser = getWorkPerUser($userId);
switch ($format) {
case 'pdf':
if (!empty($workPerUser)) {
require_once api_get_path(LIBRARY_PATH).'pdf.lib.php';
$pdf = new PDF();
$content = null;
foreach ($workPerUser as $work) {
$work = $work['work'];
foreach ($work->user_results as $userResult) {
//var_dump($userResult);exit;
$content .= $userResult['title'];
$content .= $userResult['sent_date'];
$content .= $userResult['qualification'];
$content .= $userResult['description'];
//$content .= getWorkComments($userResult);
}
}
if (!empty($content)) {
$pdf->content_to_pdf(
$content,
null,
replace_dangerous_char($userInfo['complete_name']),
$courseInfo['code']
);
}
}
break;
}
}
/**
* @param int $userId
* @param array $courseInfo
* @return bool
*/
function downloadAllFilesPerUser($userId, $courseInfo)
{
$userInfo = api_get_user_info($userId);
if (empty($userInfo) || empty($courseInfo)) {
return false;
}
require_once api_get_path(LIBRARY_PATH).'pclzip/pclzip.lib.php';
$tempZipFile = api_get_path(SYS_ARCHIVE_PATH).api_get_unique_id().".zip";
$coursePath = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/work/';
$zip = new PclZip($tempZipFile);
$workPerUser = getWorkPerUser($userId);
if (!empty($workPerUser)) {
$files = array();
foreach ($workPerUser as $work) {
$work = $work['work'];
foreach ($work->user_results as $userResult) {
if (empty($userResult['url']) || empty($userResult['contains_file'])) {
continue;
}
$data = getFileContents($userResult['id'], $courseInfo);
if (!empty($data) && isset($data['path'])) {
$files[basename($data['path'])] = array(
'title' => $data['title'],
'path' => $data['path']
);
}
}
}
if (!empty($files)) {
Session::write('files', $files);
foreach ($files as $data) {
$zip->add(
$data['path'],
PCLZIP_OPT_REMOVE_PATH,
$coursePath,
PCLZIP_CB_PRE_ADD,
'preAddAllWorkStudentCallback'
);
}
}
// Start download of created file
$name = basename(replace_dangerous_char($userInfo['complete_name'])).'.zip';
event_download($name.'.zip (folder)');
if (Security::check_abs_path($tempZipFile, api_get_path(SYS_ARCHIVE_PATH))) {
DocumentManager::file_send_for_download($tempZipFile, true, $name);
@unlink($tempZipFile);
exit;
}
}
exit;
}
function preAddAllWorkStudentCallback($p_event, &$p_header)
{
$files = Session::read('files');
if (isset($files[basename($p_header['stored_filename'])])) {
$p_header['stored_filename'] = $files[basename($p_header['stored_filename'])]['title'];
return 1;
}
return 0;
}

@ -35,14 +35,6 @@ $my_folder_data = get_work_data_by_id($work_id);
$curdirpath = '';
$htmlHeadXtra[] = api_get_jqgrid_js();
$htmlHeadXtra[] = to_javascript_work();
$htmlHeadXtra[] = '<script>
function setFocus() {
$("#work_title").focus();
}
$(document).ready(function () {
setFocus();
});
</script>';
$_course = api_get_course_info();
@ -60,12 +52,9 @@ $submitGroupWorkUrl = isset($_REQUEST['submitGroupWorkUrl']) ? Security::rem
$title = isset($_REQUEST['title']) ? $_REQUEST['title'] : '';
$description = isset($_REQUEST['description']) ? $_REQUEST['description'] : '';
$uploadvisibledisabled = isset($_REQUEST['uploadvisibledisabled']) ? Database::escape_string($_REQUEST['uploadvisibledisabled']) : $course_info['show_score'];
$course_dir = api_get_path(SYS_COURSE_PATH).$_course['path'];
$base_work_dir = $course_dir . '/work';
$link_target_parameter = ""; // e.g. "target=\"_blank\"";
$display_list_users_without_publication = isset($_GET['list']) && Security::remove_XSS($_GET['list']) == 'without' ? true : false;
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'list';
@ -190,10 +179,12 @@ switch ($action) {
$form = new FormValidator('form1', 'post', api_get_path(WEB_CODE_PATH).'work/work.php?action=create_dir&'. api_get_cidreq());
$form->addElement('header', get_lang('CreateAssignment'));
$form->addElement('hidden', 'action', 'add');
$form = getFormWork($form, array());
$defaults = isset($_POST) ? $_POST : array();
$form = getFormWork($form, $defaults);
$form->addElement('style_submit_button', 'submit', get_lang('CreateDirectory'));
if ($form->validate()) {
$result = addDir($_POST, $user_id, $_course, $group_id, $id_session);
if ($result) {
$message = Display::return_message(get_lang('DirectoryCreated'), 'success');

@ -70,6 +70,10 @@ if (api_is_allowed_to_session_edit(false, true) && !empty($workId)) {
}
echo '</div>';
if (!empty($my_folder_data['title'])) {
echo Display::page_subheader($my_folder_data['title']);
}
$error_message = Session::read('error_message');
if (!empty($error_message)) {
echo $error_message;

@ -104,8 +104,8 @@ $documentsAddedInWork = getAllDocumentsFromWorkToString($workId, $courseInfo);
echo '<div class="actions">';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'">'.Display::return_icon('back.png', get_lang('BackToWorksList'),'',ICON_SIZE_MEDIUM).'</a>';
if (api_is_allowed_to_session_edit(false, true) && !empty($workId)) {
echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/upload.php?'.api_get_cidreq().'&id='.$workId.'">';
echo Display::return_icon('upload_file.png', get_lang('UploadADocument'), '', ICON_SIZE_MEDIUM).'</a>';
/*echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/upload.php?'.api_get_cidreq().'&id='.$workId.'">';
echo Display::return_icon('upload_file.png', get_lang('UploadADocument'), '', ICON_SIZE_MEDIUM).'</a>';*/
if (ADD_DOCUMENT_TO_WORK) {
echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_document.php?'.api_get_cidreq().'&id='.$workId.'">';
echo Display::return_icon('new_document.png', get_lang('AddDocument'), '', ICON_SIZE_MEDIUM).'</a>';
@ -122,9 +122,17 @@ if (api_is_allowed_to_session_edit(false, true) && !empty($workId)) {
Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'), ICON_SIZE_MEDIUM).'</a>';
}
echo $display_output;
echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/edit_work.php?'.api_get_cidreq().'&id='.$workId.'">';
echo Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM).'</a>';
}
echo '</div>';
if (!empty($my_folder_data['title'])) {
echo Display::page_subheader($my_folder_data['title']);
}
$error_message = Session::read('error_message');
if (!empty($error_message)) {
echo $error_message;
@ -151,14 +159,14 @@ if (!empty($work_data['enable_qualification']) && !empty($check_qualification))
get_lang('Actions')
);
$column_model = array (
array('name'=>'type', 'index'=>'file', 'width'=>'10', 'align'=>'left', 'search' => 'false', 'sortable' => 'false'),
array('name'=>'type', 'index'=>'file', 'width'=>'8', 'align'=>'left', 'search' => 'false', 'sortable' => 'false'),
array('name'=>'firstname', 'index'=>'firstname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
array('name'=>'lastname', 'index'=>'lastname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
array('name'=>'title', 'index'=>'title', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'wrap_cell' => 'true'),
array('name'=>'qualification', 'index'=>'qualification', 'width'=>'20', 'align'=>'left', 'search' => 'true'),
array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'40', 'align'=>'left', 'search' => 'true', 'wrap_cell' => 'true'),
array('name'=>'qualificator_id','index'=>'qualificator_id', 'width'=>'30', 'align'=>'left', 'search' => 'true'),
array('name'=>'actions', 'index'=>'actions', 'width'=>'50', 'align'=>'left', 'search' => 'false', 'sortable'=>'false', )
array('name'=>'qualificator_id','index'=>'qualificator_id', 'width'=>'25', 'align'=>'left', 'search' => 'true'),
array('name'=>'actions', 'index'=>'actions', 'width'=>'30', 'align'=>'left', 'search' => 'false', 'sortable'=>'false', )
);
} else {
$type = 'complex';
@ -173,12 +181,12 @@ if (!empty($work_data['enable_qualification']) && !empty($check_qualification))
);
$column_model = array (
array('name'=>'type', 'index'=>'file', 'width'=>'10', 'align'=>'left', 'search' => 'false', 'sortable' => 'false'),
array('name'=>'type', 'index'=>'file', 'width'=>'8', 'align'=>'left', 'search' => 'false', 'sortable' => 'false'),
array('name'=>'firstname', 'index'=>'firstname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
array('name'=>'lastname', 'index'=>'lastname', 'width'=>'35', 'align'=>'left', 'search' => 'true'),
array('name'=>'title', 'index'=>'title', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'wrap_cell' => "true"),
array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'45', 'align'=>'left', 'search' => 'true', 'wrap_cell' => 'true'),
array('name'=>'actions', 'index'=>'actions', 'width'=>'50', 'align'=>'left', 'search' => 'false', 'sortable'=>'false', 'wrap_cell' => 'true')
array('name'=>'actions', 'index'=>'actions', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'sortable'=>'false', 'wrap_cell' => 'true')
);
}

Loading…
Cancel
Save