1.10.x
Yannick Warnier 10 years ago
commit 1d146ac4d0
  1. 1
      .gitignore
  2. 12
      main/admin/course_add.php
  3. 315
      main/admin/course_edit.php
  4. 50
      main/admin/extra_fields.php
  5. 5
      main/admin/index.php
  6. 11
      main/admin/resume_session.php
  7. 667
      main/admin/session_add.php
  8. 622
      main/admin/session_edit.php
  9. 1
      main/admin/user_add.php
  10. 1
      main/admin/user_edit.php
  11. 17
      main/course_home/course_home.php
  12. 4
      main/dropbox/dropbox_init.inc.php
  13. 4
      main/exercice/exercise.lib.php
  14. 4
      main/exercice/exercise_show.php
  15. 5
      main/forum/newthread.php
  16. 2
      main/forum/viewforum.php
  17. 10
      main/gradebook/gradebook_display_certificate.php
  18. 2
      main/gradebook/index.php
  19. 71
      main/inc/lib/CourseField.php
  20. 31
      main/inc/lib/course.lib.php
  21. 2
      main/inc/lib/database.constants.inc.php
  22. 258
      main/inc/lib/extra_field.lib.php
  23. 2
      main/inc/lib/extra_field_option.lib.php
  24. 105
      main/inc/lib/extra_field_value.lib.php
  25. 30
      main/inc/lib/formvalidator/Element/Number.php
  26. 1
      main/inc/lib/formvalidator/FormValidator.class.php
  27. 79
      main/inc/lib/main_api.lib.php
  28. 51
      main/inc/lib/sessionmanager.lib.php
  29. 11
      main/inc/lib/tracking.lib.php
  30. 33
      main/install/db_main.sql
  31. 5
      main/install/migrate-db-1.9.0-1.10.0-pre.sql
  32. 318
      main/mySpace/myStudents.php
  33. 59
      main/newscorm/learnpath.class.php
  34. 184
      main/newscorm/learnpathItem.class.php
  35. 26
      main/newscorm/lp_list.php
  36. 7
      main/newscorm/lp_view.php
  37. 114
      main/session/index.php
  38. 9
      main/tracking/exams.php
  39. 2
      main/work/upload.php
  40. 1
      main/work/work.lib.php
  41. 114
      main/work/work_list.php
  42. 201
      tests/scripts/insert_session_fields.php

1
.gitignore vendored

@ -35,4 +35,5 @@ searchdb/*
nbproject/*
plugin/bbb/config.vm.php
main/cron/incoming/*

@ -116,6 +116,18 @@ $form->addRule('disk_quota', get_lang('ThisFieldShouldBeNumeric'), 'numeric');
$obj = new GradeModel();
$obj->fill_grade_model_select_in_form($form);
//Extra fields
$extra_field = new CourseField();
$extra = $extra_field->addElements($form);
$htmlHeadXtra[] ='
<script>
$(function() {
'.$extra['jquery_ready_content'].'
});
</script>';
$form->add_progress_bar();
$form->addElement('style_submit_button', 'submit', get_lang('CreateCourse'), 'class="add"');

@ -1,9 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.admin
*/
* @package chamilo.admin
*/
// name of the language file that needs to be included
$language_file = 'admin';
$cidReset = true;
@ -13,23 +12,25 @@ $this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
require_once api_get_path(LIBRARY_PATH).'course_category.lib.php';
require_once api_get_path(LIBRARY_PATH) . 'fileManage.lib.php';
require_once api_get_path(LIBRARY_PATH) . 'course_category.lib.php';
$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/tag/jquery.fcbkcomplete.js" type="text/javascript" language="javascript"></script>';
$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
$course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
$course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$course_code = isset($_GET['course_code']) ? $_GET['course_code'] : $_POST['code'];
$noPHP_SELF = true;
$tool_name = get_lang('ModifyCourseInfo');
$interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array ("url" => "course_list.php", "name" => get_lang('CourseList'));
$interbreadcrumb[] = array("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array("url" => "course_list.php", "name" => get_lang('CourseList'));
// Get all course categories
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
//Get the course infos
$sql = "SELECT * FROM $course_table WHERE code='".Database::escape_string($course_code)."'";
$sql = "SELECT * FROM $course_table WHERE code='" . Database::escape_string($course_code) . "'";
$result = Database::query($sql);
if (Database::num_rows($result) != 1) {
header('Location: course_list.php');
@ -42,7 +43,7 @@ $course_info = api_get_course_info($course_code);
// Get course teachers
$table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname';
$sql = "SELECT user.user_id,lastname,firstname FROM $table_user as user,$table_course_user as course_user WHERE course_user.status='1' AND course_user.user_id=user.user_id AND course_user.course_code='".$course_code."'".$order_clause;
$sql = "SELECT user.user_id,lastname,firstname FROM $table_user as user,$table_course_user as course_user WHERE course_user.status='1' AND course_user.user_id=user.user_id AND course_user.course_code='" . $course_code . "'" . $order_clause;
$res = Database::query($sql);
$course_teachers = array();
while ($obj = Database::fetch_object($res)) {
@ -51,22 +52,22 @@ while ($obj = Database::fetch_object($res)) {
// Get all possible teachers without the course teachers
if (api_is_multiple_url_enabled()) {
$access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$sql = "SELECT u.user_id,lastname,firstname
FROM $table_user as u
INNER JOIN $access_url_rel_user_table url_rel_user
ON (u.user_id=url_rel_user.user_id)
WHERE url_rel_user.access_url_id=".api_get_current_access_url_id()." AND status=1".$order_clause;
$access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$sql = "SELECT u.user_id,lastname,firstname
FROM $table_user as u
INNER JOIN $access_url_rel_user_table url_rel_user
ON (u.user_id=url_rel_user.user_id)
WHERE url_rel_user.access_url_id=" . api_get_current_access_url_id() . " AND status=1" . $order_clause;
} else {
$sql = "SELECT user_id, lastname, firstname
FROM $table_user WHERE status='1'".$order_clause;
FROM $table_user WHERE status='1'" . $order_clause;
}
$res = Database::query($sql);
$teachers = array();
$allTeachers = array();
$platform_teachers[0] = '-- '.get_lang('NoManager').' --';
$platform_teachers[0] = '-- ' . get_lang('NoManager') . ' --';
while ($obj = Database::fetch_object($res)) {
$allTeachers[$obj->user_id] = api_get_person_name($obj->firstname, $obj->lastname);
if (!array_key_exists($obj->user_id, $course_teachers)) {
@ -82,7 +83,7 @@ while ($obj = Database::fetch_object($res)) {
// Case where there is no teacher in the course
if (count($course_teachers) == 0) {
$sql='SELECT tutor_name FROM '.$course_table.' WHERE code="'.$course_code.'"';
$sql = 'SELECT tutor_name FROM ' . $course_table . ' WHERE code="' . $course_code . '"';
$res = Database::query($sql);
$tutor_name = Database::result($res, 0, 0);
$course['tutor_name'] = array_search($tutor_name, $platform_teachers);
@ -90,11 +91,11 @@ if (count($course_teachers) == 0) {
// Build the form
$form = new FormValidator('update_course');
$form->addElement('header', get_lang('Course').' #'.$course_info['real_id'].' '.$course_code);
$form->addElement('header', get_lang('Course') . ' #' . $course_info['real_id'] . ' ' . $course_code);
$form->addElement('hidden', 'code', $course_code);
//title
$form->add_textfield('title', get_lang('Title'), true, array ('class' => 'span6'));
$form->add_textfield('title', get_lang('Title'), true, array('class' => 'span6'));
$form->applyFilter('title', 'html_filter');
$form->applyFilter('title', 'trim');
@ -114,23 +115,23 @@ $group = array(
);
$element_template = <<<EOT
<div class="control-group">
<label>
<!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->{label}
</label>
<div class="controls">
<table cellpadding="0" cellspacing="0">
<tr>
<!-- BEGIN error --><span class="form_error">{error}</span><br /><!-- END error --> <td>{element}</td>
</tr>
</table>
</div>
</div>
<div class="control-group">
<label>
<!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->{label}
</label>
<div class="controls">
<table cellpadding="0" cellspacing="0">
<tr>
<!-- BEGIN error --><span class="form_error">{error}</span><br /><!-- END error --> <td>{element}</td>
</tr>
</table>
</div>
</div>
EOT;
$renderer = $form->defaultRenderer();
$renderer->setElementTemplate($element_template, 'group');
$form->addGroup($group, 'group', get_lang('CourseTeachers'), '</td><td width="80" align="center">'.
$form->addGroup($group, 'group', get_lang('CourseTeachers'), '</td><td width="80" align="center">' .
'<input class="arrowr" style="width:30px;height:30px;padding-right:12px" type="button" onclick="moveItem(document.getElementById(\'platform_teachers\'), document.getElementById(\'course_teachers\'))"><br><br>'.
'<input class="arrowl" style="width:30px;height:30px;padding-left:13px" type="button" onclick="moveItem(document.getElementById(\'course_teachers\'), document.getElementById(\'platform_teachers\'))"></td><td>'
);
@ -156,33 +157,35 @@ if (!empty($coursesInSession)) {
}
}
$groupName = 'session_coaches['.$sessionId.']';
$platformTeacherId = 'platform_teachers_by_session_'.$sessionId;
$coachId = 'coaches_by_session_'.$sessionId;
$groupName = 'session_coaches[' . $sessionId . ']';
$platformTeacherId = 'platform_teachers_by_session_' . $sessionId;
$coachId = 'coaches_by_session_' . $sessionId;
$platformTeacherName = 'platform_teachers_by_session';
$coachName = 'coaches_by_session';
$group = array(
$form->createElement('select', $platformTeacherName, '', $teachers, ' id="'.$platformTeacherId.'" multiple=multiple size="4" style="width:300px;"'),
$form->createElement('select', $coachName, '', $sessionTeachers, ' id="'.$coachId.'" multiple=multiple size="4" style="width:300px;"')
$form->createElement('select', $platformTeacherName, '', $teachers, ' id="' . $platformTeacherId . '" multiple=multiple size="4" style="width:300px;"'),
$form->createElement('select', $coachName, '', $sessionTeachers, ' id="' . $coachId . '" multiple=multiple size="4" style="width:300px;"')
);
$renderer = $form->defaultRenderer();
$renderer->setElementTemplate($element_template, $groupName);
$sessionUrl = api_get_path(WEB_CODE_PATH).'admin/resume_session.php?id_session='.$sessionId;
$form->addGroup($group, $groupName, Display::url($session['name'], $sessionUrl, array('target' => '_blank')).' - '.get_lang('Coaches'), '</td>
$sessionUrl = api_get_path(WEB_CODE_PATH) . 'admin/resume_session.php?id_session=' . $sessionId;
$form->addGroup($group, $groupName,
Display::url($session['name'], $sessionUrl, array('target' => '_blank')) . ' - ' . get_lang('Coaches'),
'</td>
<td width="80" align="center">
<input class="arrowr" style="width:30px;height:30px;padding-right:12px" type="button" onclick="moveItem(document.getElementById(\''.$platformTeacherId.'\'), document.getElementById(\''.$coachId.'\'));">
<input class="arrowr" style="width:30px;height:30px;padding-right:12px" type="button" onclick="moveItem(document.getElementById(\'' . $platformTeacherId . '\'), document.getElementById(\'' . $coachId . '\'));">
<br><br>
<input class="arrowl" style="width:30px;height:30px;padding-left:13px" type="button" onclick="moveItem(document.getElementById(\''.$coachId.'\'), document.getElementById(\''.$platformTeacherId.'\'));">
<input class="arrowl" style="width:30px;height:30px;padding-left:13px" type="button" onclick="moveItem(document.getElementById(\'' . $coachId . '\'), document.getElementById(\'' . $platformTeacherId . '\'));">
</td><td>'
);
}
}
// Category code
$url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=search_category';
$url = api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?a=search_category';
$categoryList = array();
if (!empty($course['category_code'])) {
$data = getCategory($course['category_code']);
@ -212,13 +215,13 @@ $group[]= $form->createElement('radio', 'visibility', null, get_lang('CourseVisi
$form->addGroup($group, '', get_lang('CourseAccess'), '<br />');
$group = array();
$group[]= $form->createElement('radio', 'subscribe', get_lang('Subscription'), get_lang('Allowed'), 1);
$group[]= $form->createElement('radio', 'subscribe', null, get_lang('Denied'), 0);
$group[] = $form->createElement('radio', 'subscribe', get_lang('Subscription'), get_lang('Allowed'), 1);
$group[] = $form->createElement('radio', 'subscribe', null, get_lang('Denied'), 0);
$form->addGroup($group, '', get_lang('Subscription'), '<br />');
$group = array();
$group[]= $form->createElement('radio', 'unsubscribe', get_lang('Unsubscription'), get_lang('AllowedToUnsubscribe'), 1);
$group[]= $form->createElement('radio', 'unsubscribe', null, get_lang('NotAllowedToUnsubscribe'), 0);
$group[] = $form->createElement('radio', 'unsubscribe', get_lang('Unsubscription'), get_lang('AllowedToUnsubscribe'), 1);
$group[] = $form->createElement('radio', 'unsubscribe', null, get_lang('NotAllowedToUnsubscribe'), 0);
$form->addGroup($group, '', get_lang('Unsubscription'), '<br />');
$form->addElement('text', 'disk_quota', array(get_lang('CourseQuota'), null, get_lang('MB')));
@ -227,21 +230,41 @@ $form->addRule('disk_quota', get_lang('ThisFieldShouldBeNumeric'), 'numeric');
$list_course_extra_field = CourseManager::get_course_extra_field_list($course_code);
//@todo this is wrong
foreach ($list_course_extra_field as $extra_field) {
switch ($extra_field['field_type']) {
case CourseManager::COURSE_FIELD_TYPE_CHECKBOX:
$checked = (array_key_exists('extra_field_value', $extra_field) && $extra_field['extra_field_value'] == 1)? array('checked'=>'checked'): '';
$form->addElement('hidden', '_extra_'.$extra_field['field_variable'], 0);
$field_display_text = $extra_field['field_display_text'];
$form->addElement('checkbox', 'extra_'.$extra_field['field_variable'], array(null, get_lang('AllUsersAreAutomaticallyRegistered')), get_lang('SpecialCourse'), $checked);
break;
$specialCourseField = new CourseField();
$specialCourseFieldInfo = $specialCourseField->get_handler_field_info_by_field_variable('special_course');
if (!empty($specialCourseFieldInfo)) {
$specialCourseValue = new ExtraFieldValue('course');
$specialCourseValueInfo = $specialCourseValue->get_values_by_handler_and_field_variable($course_code, 'special_course');
$specialCourseAttributes = array();
if (!empty($specialCourseValueInfo) && $specialCourseValueInfo['field_value'] == 1) {
$specialCourseAttributes['checked'] = '';
}
$form->addElement('hidden', '_extra_special_course', 0);
$form->addElement('checkbox', 'extra_special_course', array(
null, get_lang('AllUsersAreAutomaticallyRegistered')
), get_lang('SpecialCourse'), $specialCourseAttributes);
}
//Extra fields
$extra_field = new CourseField();
$extra = $extra_field->addElements($form, $course_code);
$htmlHeadXtra[] = '
<script>
$(function() {
' . $extra['jquery_ready_content'] . '
});
</script>';
$form->addElement('style_submit_button', 'button', get_lang('ModifyCourseInfo'), 'onclick="valide()"; class="save"');
// Set some default values
$course['disk_quota'] = round(DocumentManager::get_course_quota($course_code) /1024/1024, 1);
$course['disk_quota'] = round(DocumentManager::get_course_quota($course_code) / 1024 / 1024, 1);
$course['title'] = api_html_entity_decode($course['title'], ENT_QUOTES, $charset);
$course['real_code'] = $course['code'];
$course['add_teachers_to_sessions_courses'] = isset($course['add_teachers_to_sessions_courses']) ? $course['add_teachers_to_sessions_courses'] : 0;
@ -283,70 +306,54 @@ if ($form->validate()) {
// Check if the visual code is already used by *another* course
$visual_code_is_used = false;
$warn = get_lang('TheFollowingCoursesAlreadyUseThisVisualCode').':';
$warn = get_lang('TheFollowingCoursesAlreadyUseThisVisualCode') . ':';
if (!empty($visual_code)) {
$list = CourseManager::get_courses_info_from_visual_code($visual_code);
foreach ($list as $course_temp) {
if ($course_temp['code'] != $course_code) {
$visual_code_is_used = true;
$warn .= ' '.$course_temp['title'].' ('.$course_temp['code'].'),';
$visual_code_is_used = true;
$warn .= ' ' . $course_temp['title'] . ' (' . $course_temp['code'] . '),';
}
}
$warn = substr($warn, 0, -1);
}
// an extra field
$extras = array();
foreach ($course as $key => $value) {
if (substr($key, 0, 6) == 'extra_') {
$extras[substr($key, 6)] = $value;
}
if (substr($key, 0, 7) == '_extra_') {
if (!array_key_exists(substr($key, 7), $extras)) {
$extras[substr($key, 7)] = $value;
}
}
$tutor_id = isset($course['tutor_name']) ? $course['tutor_name'] : null;
$tutor_name = isset($platform_teachers[$tutor_id]) ? $platform_teachers[$tutor_id] : null;
$teachers = $course['group']['course_teachers'];
$title = $course['title'];
$category_code = $course['category_code'];
$department_name = $course['department_name'];
$department_url = $course['department_url'];
$course_language = $course['course_language'];
$course['disk_quota'] = $course['disk_quota'] * 1024 * 1024;
$disk_quota = $course['disk_quota'];
$subscribe = $course['subscribe'];
$unsubscribe = $course['unsubscribe'];
$course['course_code'] = $course_code;
if (!stristr($department_url, 'http://')) {
$department_url = 'http://' . $department_url;
}
$tutor_id = isset($course['tutor_name']) ? $course['tutor_name'] : null;
$tutor_name = isset($platform_teachers[$tutor_id]) ? $platform_teachers[$tutor_id] : null;
$teachers = $course['group']['course_teachers'];
$title = $course['title'];
$category_code = $course['category_code'];
$department_name = $course['department_name'];
$department_url = $course['department_url'];
$course_language = $course['course_language'];
$course['disk_quota'] = $course['disk_quota']*1024*1024;
$disk_quota = $course['disk_quota'];
$subscribe = $course['subscribe'];
$unsubscribe = $course['unsubscribe'];
if (!stristr($department_url, 'http://')) {
$department_url = 'http://'.$department_url;
}
$sql = "UPDATE $course_table SET course_language='".Database::escape_string($course_language)."',
title='".Database::escape_string($title)."',
category_code='".Database::escape_string($category_code)."',
tutor_name='".Database::escape_string($tutor_name)."',
visual_code='".Database::escape_string($visual_code)."',
department_name='".Database::escape_string($department_name)."',
department_url='".Database::escape_string($department_url)."',
disk_quota='".Database::escape_string($disk_quota)."',
visibility = '".Database::escape_string($visibility)."',
subscribe = '".Database::escape_string($subscribe)."',
unsubscribe='".Database::escape_string($unsubscribe)."'
WHERE code='".Database::escape_string($course_code)."'";
Database::query($sql);
// update the extra fields
if (count($extras) > 0) {
foreach ($extras as $key => $value) {
CourseManager::update_course_extra_field_value($course_code, $key, $value);
}
}
$sql = "UPDATE $course_table SET course_language='" . Database::escape_string($course_language) . "',
title='" . Database::escape_string($title) . "',
category_code='" . Database::escape_string($category_code) . "',
tutor_name='" . Database::escape_string($tutor_name) . "',
visual_code='" . Database::escape_string($visual_code) . "',
department_name='" . Database::escape_string($department_name) . "',
department_url='" . Database::escape_string($department_url) . "',
disk_quota='" . Database::escape_string($disk_quota) . "',
visibility = '" . Database::escape_string($visibility) . "',
subscribe = '" . Database::escape_string($subscribe) . "',
unsubscribe='" . Database::escape_string($unsubscribe) . "'
WHERE code='" . Database::escape_string($course_code) . "'";
Database::query($sql);
// update the extra fields
$courseFieldValue = new ExtraFieldValue('course');
$courseFieldValue->save_field_values($course);
$addTeacherToSessionCourses = isset($course['add_teachers_to_sessions_courses']) && !empty($course['add_teachers_to_sessions_courses']) ? 1 : 0;
@ -385,31 +392,31 @@ if ($form->validate()) {
}
}
$sql = "INSERT IGNORE INTO ".$course_user_table . " SET
course_code = '".Database::escape_string($course_code). "',
user_id = '".$tutor_id . "',
status = '1',
role = '',
tutor_id='0',
sort='0',
user_course_cat='0'";
Database::query($sql);
$sql = "INSERT IGNORE INTO " . $course_user_table . " SET
course_code = '" . Database::escape_string($course_code) . "',
user_id = '" . $tutor_id . "',
status = '1',
role = '',
tutor_id='0',
sort='0',
user_course_cat='0'";
Database::query($sql);
if (array_key_exists('add_teachers_to_sessions_courses', $course_info)) {
$sql = "UPDATE $course_table SET add_teachers_to_sessions_courses = '$addTeacherToSessionCourses'
WHERE id = ".$course_info['real_id'];
WHERE id = " . $course_info['real_id'];
Database::query($sql);
}
$course_id = $course_info['real_id'];
/*$forum_config_table = Database::get_course_table(TOOL_FORUM_CONFIG_TABLE);
$sql = "UPDATE ".$forum_config_table." SET default_lang='".Database::escape_string($course_language)."' WHERE c_id = $course_id ";*/
if ($visual_code_is_used) {
header('Location: course_list.php?action=show_msg&warn='.urlencode($warn));
} else {
$course_id = $course_info['real_id'];
/* $forum_config_table = Database::get_course_table(TOOL_FORUM_CONFIG_TABLE);
$sql = "UPDATE ".$forum_config_table." SET default_lang='".Database::escape_string($course_language)."' WHERE c_id = $course_id "; */
if ($visual_code_is_used) {
header('Location: course_list.php?action=show_msg&warn=' . urlencode($warn));
} else {
header('Location: course_list.php');
}
exit;
}
exit;
}
Display::display_header($tool_name);
@ -421,38 +428,38 @@ echo '</div>';
echo "<script>
function moveItem(origin , destination) {
for (var i = 0 ; i<origin.options.length ; i++) {
if (origin.options[i].selected) {
destination.options[destination.length] = new Option(origin.options[i].text,origin.options[i].value);
origin.options[i]=null;
i = i-1;
}
}
destination.selectedIndex = -1;
sortOptions(destination.options);
for (var i = 0 ; i<origin.options.length ; i++) {
if (origin.options[i].selected) {
destination.options[destination.length] = new Option(origin.options[i].text,origin.options[i].value);
origin.options[i]=null;
i = i-1;
}
}
destination.selectedIndex = -1;
sortOptions(destination.options);
}
function sortOptions(options) {
newOptions = new Array();
for (i = 0 ; i<options.length ; i++) {
newOptions[i] = options[i];
newOptions = new Array();
for (i = 0 ; i<options.length ; i++) {
newOptions[i] = options[i];
}
newOptions = newOptions.sort(mysort);
options.length = 0;
for (i = 0 ; i < newOptions.length ; i++) {
options[i] = newOptions[i];
}
newOptions = newOptions.sort(mysort);
options.length = 0;
for (i = 0 ; i < newOptions.length ; i++) {
options[i] = newOptions[i];
}
}
function mysort(a, b) {
if (a.text.toLowerCase() > b.text.toLowerCase()) {
return 1;
}
if (a.text.toLowerCase() < b.text.toLowerCase()) {
return -1;
}
return 0;
if (a.text.toLowerCase() > b.text.toLowerCase()) {
return 1;
}
if (a.text.toLowerCase() < b.text.toLowerCase()) {
return -1;
}
return 0;
}
function valide() {

@ -10,10 +10,9 @@ $language_file = array('admin');
$cidReset = true;
$cidReset = true;
require_once '../inc/global.inc.php';
$extraFieldType = isset($_REQUEST['type']) ? $_REQUEST['type'] : null;
$extraFieldType = isset($_REQUEST['type']) ? $_REQUEST['type'] : null;
$this_section = SECTION_PLATFORM_ADMIN;
@ -23,7 +22,7 @@ api_protect_admin_script();
$htmlHeadXtra[] = api_get_jqgrid_js();
// setting breadcrumbs
$interbreadcrumb[]=array('url' => 'index.php','name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$tool_name = null;
@ -40,7 +39,7 @@ $obj = new ExtraField($extraFieldType);
$obj->setupBreadcrumb($interbreadcrumb, $action);
//jqgrid will use this URL to do the selects
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_extra_fields&type='.$extraFieldType;
$url = api_get_path(WEB_AJAX_PATH) . 'model.ajax.php?a=get_extra_fields&type=' . $extraFieldType;
//The order is important you need to check the the $column variable in the model.ajax.php file
$columns = $obj->getJqgridColumnNames();
@ -56,46 +55,47 @@ $extra_params['sortname'] = 'field_order';
$action_links = $obj->getJqgridActionLinks($token);
$htmlHeadXtra[]='<script>
$htmlHeadXtra[] = '<script>
$(function() {
// grid definition see the $obj->display() function
'.Display::grid_js($obj->type.'_fields', $url, $columns, $column_model, $extra_params, array(), $action_links, true).'
' . Display::grid_js($obj->type . '_fields', $url, $columns, $column_model, $extra_params, array(), $action_links,
true) . '
$("#field_type").on("change", function() {
id = $(this).val();
switch(id) {
case "1":
$("#example").html("'.addslashes(Display::return_icon('userfield_text.png')).'");
$("#example").html("' . addslashes(Display::return_icon('userfield_text.png')) . '");
break;
case "2":
$("#example").html("'.addslashes(Display::return_icon('userfield_text_area.png')).'");
$("#example").html("' . addslashes(Display::return_icon('userfield_text_area.png')) . '");
break;
case "3":
$("#example").html("'.addslashes(Display::return_icon('add_user_field_howto.png')).'");
$("#example").html("' . addslashes(Display::return_icon('add_user_field_howto.png')) . '");
break;
case "4":
$("#example").html("'.addslashes(Display::return_icon('userfield_drop_down.png')).'");
$("#example").html("' . addslashes(Display::return_icon('userfield_drop_down.png')) . '");
break;
case "5":
$("#example").html("'.addslashes(Display::return_icon('userfield_multidropdown.png')).'");
$("#example").html("' . addslashes(Display::return_icon('userfield_multidropdown.png')) . '");
break;
case "6":
$("#example").html("'.addslashes(Display::return_icon('userfield_data.png')).'");
$("#example").html("' . addslashes(Display::return_icon('userfield_data.png')) . '");
break;
case "7":
$("#example").html("'.addslashes(Display::return_icon('userfield_date_time.png')).'");
$("#example").html("' . addslashes(Display::return_icon('userfield_date_time.png')) . '");
break;
case "8":
$("#example").html("'.addslashes(Display::return_icon('userfield_doubleselect.png')).'");
$("#example").html("' . addslashes(Display::return_icon('userfield_doubleselect.png')) . '");
break;
case "9":
$("#example").html("'.addslashes(Display::return_icon('userfield_divider.png')).'");
$("#example").html("' . addslashes(Display::return_icon('userfield_divider.png')) . '");
break;
case "10":
$("#example").html("'.addslashes(Display::return_icon('userfield_user_tag.png')).'");
$("#example").html("' . addslashes(Display::return_icon('userfield_user_tag.png')) . '");
break;
case "11":
$("#example").html("'.addslashes(Display::return_icon('userfield_data.png')).'");
$("#example").html("' . addslashes(Display::return_icon('userfield_data.png')) . '");
break;
}
});
@ -112,14 +112,14 @@ switch ($action) {
if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
api_not_allowed();
}
$url = api_get_self().'?type='.$obj->type.'&action='.Security::remove_XSS($_GET['action']);
$url = api_get_self() . '?type=' . $obj->type . '&action=' . Security::remove_XSS($_GET['action']);
$form = $obj->return_form($url, 'add');
// The validation or display
if ($form->validate()) {
//if ($check) {
$values = $form->exportValues();
$res = $obj->save($values);
$res = $obj->save($values);
if ($res) {
Display::display_confirmation_message(get_lang('ItemAdded'));
}
@ -127,8 +127,8 @@ switch ($action) {
$obj->display();
} else {
echo '<div class="actions">';
echo '<a href="'.api_get_self().'?type='.$obj->type.'">'.
Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="' . api_get_self() . '?type=' . $obj->type . '">' .
Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM) . '</a>';
echo '</div>';
$form->addElement('hidden', 'sec_token');
$form->setConstants(array('sec_token' => $token));
@ -137,21 +137,21 @@ switch ($action) {
break;
case 'edit':
// Action handling: Editing
$url = api_get_self().'?type='.$obj->type.'&action='.Security::remove_XSS($_GET['action']).'&id='.intval($_GET['id']);
$url = api_get_self() . '?type=' . $obj->type . '&action=' . Security::remove_XSS($_GET['action']) . '&id=' . intval($_GET['id']);
$form = $obj->return_form($url, 'edit');
// The validation or display
if ($form->validate()) {
//if ($check) {
$values = $form->exportValues();
$res = $obj->update($values);
$res = $obj->update($values);
Display::display_confirmation_message(sprintf(get_lang('ItemUpdated'), $values['field_variable']), false);
//}
$obj->display();
} else {
echo '<div class="actions">';
echo '<a href="'.api_get_self().'?type='.$obj->type.'">'.
Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="' . api_get_self() . '?type=' . $obj->type . '">' .
Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM) . '</a>';
echo '</div>';
$form->addElement('hidden', 'sec_token');
$form->setConstants(array('sec_token' => $token));

@ -182,6 +182,9 @@ if (api_is_platform_admin()) {
if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) {
$items[] = array('url'=>'ldap_import_students.php', 'label' => get_lang('ImportLDAPUsersIntoCourse'));
}
$items[] = array('url'=>'extra_fields.php?type=course', 'label' => get_lang('ManageCourseFields'));
$blocks['courses']['items'] = $items;
$blocks['courses']['extra'] = null;
@ -280,6 +283,8 @@ if (api_is_platform_admin()) {
$items[] = array('url'=>'career_dashboard.php', 'label' => get_lang('CareersAndPromotions'));
}
$items[] = array('url'=>'extra_fields.php?type=session', 'label' => get_lang('ManageSessionFields'));
$blocks['sessions']['items'] = $items;
$blocks['sessions']['extra'] = null;

@ -218,6 +218,17 @@ echo Display::page_subheader(get_lang('GeneralProperties').$url);
</tr>
<?php
$sessionField = new ExtraField('session');
$extraFieldData = $sessionField->getDataAndFormatedValues($sessionId);
foreach ($extraFieldData as $displayExtraField) {
?>
<tr>
<td><?php echo $displayExtraField['text'] ?></td>
<td><?php echo $displayExtraField['value'] ?></td>
</tr>
<?php
}
$multiple_url_is_on = api_get_multiple_access_url();

@ -3,7 +3,6 @@
/**
* @package chamilo.admin
* @todo use formvalidator for the form, remove all the select harcoded values
*/
// name of the language file that needs to be included
@ -86,68 +85,73 @@ $xajax -> processRequests();
$htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
$htmlHeadXtra[] = '
<script type="text/javascript">
$htmlHeadXtra[] = "
<script type=\"text/javascript\">
function fill_coach_field (username) {
document.getElementById("coach_username").value = username;
document.getElementById("ajax_list_coachs").innerHTML = "";
document.getElementById('coach_username').value = username;
document.getElementById('ajax_list_coachs').innerHTML = '';
}
</script>';
$(document).on('ready', function () {
var value = 1;
$('#advanced_parameters').on('click', function() {
$('#options').toggle(function() {
if (value == 1) {
$('#advanced_parameters').addClass('btn-hide');
value = 0;
} else {
$('#advanced_parameters').removeClass('btn-hide');
value = 1;
}
});
});
});
if (isset($_POST['formSent']) && $_POST['formSent']) {
$formSent = 1;
$name = $_POST['name'];
$year_start = $_POST['year_start'];
$month_start = $_POST['month_start'];
$day_start = $_POST['day_start'];
$year_end = $_POST['year_end'];
$month_end = $_POST['month_end'];
$day_end = $_POST['day_end'];
$nb_days_acess_before = $_POST['nb_days_acess_before'];
$nb_days_acess_after = $_POST['nb_days_acess_after'];
$coach_username = $_POST['coach_username'];
$id_session_category = $_POST['session_category'];
$id_visibility = $_POST['session_visibility'];
$end_limit = $_POST['end_limit'];
$start_limit = $_POST['start_limit'];
$duration = isset($_POST['duration']) ? $_POST['duration'] : null;
$description = isset($_POST['description']) ? $_POST['description'] : null;
$showDescription = isset($_POST['show_description']) ? 1 : 0;
function setDisable(select){
document.forms['edit_session'].elements['session_visibility'].disabled = (select.checked) ? true : false;
document.forms['edit_session'].elements['session_visibility'].selectedIndex = 0;
if (empty($end_limit) && empty($start_limit)) {
$nolimit = 1;
} else {
$nolimit = null;
}
document.forms['edit_session'].elements['start_limit'].disabled = (select.checked) ? true : false;
document.forms['edit_session'].elements['start_limit'].checked = false;
document.forms['edit_session'].elements['end_limit'].disabled = (select.checked) ? true : false;
document.forms['edit_session'].elements['end_limit'].checked = false;
$return = SessionManager::create_session(
$name,
$year_start,
$month_start,
$day_start,
$year_end,
$month_end,
$day_end,
$nb_days_acess_before,
$nb_days_acess_after,
$nolimit,
$coach_username,
$id_session_category,
$id_visibility,
$start_limit,
false,
$end_limit,
$duration,
$description,
$showDescription
);
var end_div = document.getElementById('end_date');
end_div.style.display = 'none';
if ($return == strval(intval($return))) {
// integer => no error on session creation
header('Location: add_courses_to_session.php?id_session='.$return.'&add=true&msg=');
exit();
}
var start_div = document.getElementById('start_date');
start_div.style.display = 'none';
}
function disable_endtime(select) {
var end_div = document.getElementById('end_date');
if (end_div.style.display == 'none')
end_div.style.display = 'block';
else
end_div.style.display = 'none';
emptyDuration();
}
function disable_starttime(select) {
var start_div = document.getElementById('start_date');
if (start_div.style.display == 'none')
start_div.style.display = 'block';
else
start_div.style.display = 'none';
emptyDuration();
}
function emptyDuration() {
if ($('#duration').val()) {
$('#duration').val('');
}
}
</script>";
if (isset($_POST['formSent']) && $_POST['formSent']) {
$formSent = 1;
}
global $_configuration;
@ -163,348 +167,261 @@ $thisYear=date('Y');
$thisMonth=date('m');
$thisDay=date('d');
$dayList = array();
for ($i = 1; $i <= 31; $i++) {
$day = sprintf("%02d", $i);
$dayList[$day] = $day;
}
$monthList = array();
for ($i = 1; $i <= 12; $i++) {
$month = sprintf("%02d", $i);
$monthList[$month] = $month;
}
$yearList = array();
for ($i = $thisYear - 5; $i <= ($thisYear + 5); $i++) {
$yearList[$i] = $i;
}
$tool_name = get_lang('AddSession');
Display::display_header($tool_name);
$urlAction = api_get_self();
if (!empty($return)) {
Display::display_error_message($return,false);
$categoriesList = SessionManager::get_all_session_category();
$categoriesOptions = array(
'0' => get_lang('None')
);
if ($categoriesList != false) {
foreach ($categoriesList as $categoryItem) {
$categoriesOptions[$categoryItem['id']] = $categoryItem['name'];
}
}
echo '<div class="actions">';
echo '<a href="../admin/index.php">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'),'',ICON_SIZE_MEDIUM).'</a>';
echo '</div>';
?>
<form class="form-horizontal" method="post" name="form" action="<?php echo api_get_self(); ?>" style="margin:0px;">
<input type="hidden" name="formSent" value="1">
<div class="control-group">
<label class="control-label">
<?php echo get_lang('SessionName') ?>
</label>
<div class="controls">
<input type="text" name="name" class="span4" maxlength="50" value="<?php if($formSent) echo api_htmlentities($name,ENT_QUOTES,$charset); ?>">
</div>
</div>
<div class="control-group">
<label class="control-label">
<?php echo get_lang('CoachName') ?>
</label>
<div class="controls">
function check_session_name($name) {
$session = SessionManager::get_session_by_name($name);
<?php
return empty($session) ? true : false;
}
$sql = 'SELECT COUNT(1) FROM '.$tbl_user.' WHERE status=1';
$form = new FormValidator('add_session', 'post', $urlAction);
$form->addElement('header', $tool_name);
$form->addElement('text', 'name', get_lang('SessionName'), array(
'class' => 'span4',
'maxlength' => 50,
'value' => $formSent ? api_htmlentities($name,ENT_QUOTES,$charset) : ''
));
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('name', get_lang('SessionNameAlreadyExists'), 'callback', 'check_session_name');
$sql = "SELECT COUNT(1) FROM $tbl_user WHERE status = 1";
$rs = Database::query($sql);
$count_users = Database::result($rs, 0, 0);
if (intval($count_users)<50) {
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
$sql="SELECT user_id, lastname,firstname,username FROM $tbl_user WHERE status='1'".$order_clause;
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1){
$sql = 'SELECT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user
INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id)
WHERE access_url_id = '.$access_url_id.' AND status=1'.$order_clause;
}
}
$result = Database::query($sql);
$Coaches = Database::store_result($result);
?>
<select id="coach_username" class="chzn-select" name="coach_username" style="width:350px;" title="<?php echo get_lang('Select'); ?>" >
<option value="0"><?php get_lang('None'); ?></option>
<?php foreach($Coaches as $enreg): ?>
<option value="<?php echo $enreg['username']; ?>"> <?php echo api_get_person_name($enreg['firstname'], $enreg['lastname']).' ('.$enreg['username'].')'; ?></option>
<?php endforeach; ?>
</select>
<?php
echo Display::return_icon('synthese_view.gif',get_lang('ActivityCoach'));
$countUsers = Database::result($rs, 0, 0);
if (intval($countUsers) < 50) {
$orderClause = "ORDER BY ";
$orderClause .= api_sort_by_first_name() ? "firstname, lastname, username" : "lastname, firstname, username";
$sql="SELECT user_id, lastname, firstname, username FROM $tbl_user "
. "WHERE status = '1' "
. $orderClause;
if (api_is_multiple_url_enabled()) {
$userRelAccessUrlTable = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$accessUrlId = api_get_current_access_url_id();
if ($accessUrlId != -1) {
$sql = "SELECT user.user_id, username, lastname, firstname FROM $tbl_user user "
. "INNER JOIN $userRelAccessUrlTable url_user ON (url_user.user_id = user.user_id) "
. "WHERE access_url_id = $accessUrlId AND status = 1 "
. $orderClause;
}
}
$result = Database::query($sql);
$coachesList = Database::store_result($result);
$coachesOptions = array();
foreach($coachesList as $coachItem){
$coachesOptions[$coachItem['username']] = api_get_person_name(
$coachItem['firstname'],
$coachItem['lastname']
).' ('.$coachItem['username'].')';
}
$form->addElement('select', 'coach_username', get_lang('CoachName'), $coachesOptions, array(
'id' => 'coach_username',
'class' => 'chzn-select',
'style' => 'width:350px;'
));
$form->addElement('advanced_settings', Display::return_icon('synthese_view.gif') . ' ' . get_lang('ActivityCoach'));
} else {
?>
<input type="text" name="coach_username" id="coach_username" onkeyup="xajax_search_coachs(document.getElementById('coach_username').value)" /><div id="ajax_list_coachs"></div>
<?php
}
$Categories = SessionManager::get_all_session_category();
?>
</div>
</div>
<div class="control-group">
<label class="control-label" for="description"><?php echo get_lang('Description') ?></label>
<div class="controls">
<?php $fckEditor = new FCKeditor('description'); ?>
<?php $fckEditor->ToolbarSet = 'TrainingDescription'; ?>
<?php echo $fckEditor->CreateHtml(); ?>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input id="show_description" type="checkbox" name="show_description" />
<?php echo get_lang('ShowDescription') ?>
</label>
</div>
</div>
<div class="control-group">
<label class="control-label">
<?php echo get_lang('SessionCategory') ?>
</label>
<div class="controls">
<select id="session_category" class="chzn-select" name="session_category" style="width:350px;" title="<?php echo get_lang('Select'); ?>">
<option value="0"><?php get_lang('None'); ?></option>
<?php
if (!empty($Categories)) {
foreach($Categories as $Rows) { ?>
<option value="<?php echo $Rows['id']; ?>" <?php if($Rows['id'] == $id_session_category) echo 'selected="selected"'; ?>><?php echo $Rows['name']; ?></option>
<?php }
}
?>
</select>
</div>
</div>
<div class="control-group">
<div class="controls">
<a href="javascript://" onclick="if(document.getElementById('options').style.display == 'none'){document.getElementById('options').style.display = 'block';}else{document.getElementById('options').style.display = 'none';}"><?php echo get_lang('DefineSessionOptions') ?></a>
<div style="display: <?php if($formSent && ($nb_days_acess_before!=0 || $nb_days_acess_after!=0)) echo 'block'; else echo 'none'; ?>;" id="options">
<br />
<input type="text" name="nb_days_acess_before" value="<?php echo $nb_days_acess_before; ?>" style="width: 30px;">&nbsp;<?php echo get_lang('DaysBefore') ?><br /><br />
<input type="text" name="nb_days_acess_after" value="<?php echo $nb_days_acess_after; ?>" style="width: 30px;">&nbsp;<?php echo get_lang('DaysAfter') ?>
<br />
</div>
</div>
</div>
<div class="control-group">
<div class="controls">
<label for="start_limit">
<input id="start_limit" type="checkbox" name="start_limit" onchange="disable_starttime(this)" />
<?php echo get_lang('DateStartSession');?>
</label>
<div id="start_date" style="display:none">
<br />
<select name="day_start">
<option value="1">01</option>
<option value="2" <?php if((!$formSent && $thisDay == 2) || ($formSent && $day_start == 2)) echo 'selected="selected"'; ?> >02</option>
<option value="3" <?php if((!$formSent && $thisDay == 3) || ($formSent && $day_start == 3)) echo 'selected="selected"'; ?> >03</option>
<option value="4" <?php if((!$formSent && $thisDay == 4) || ($formSent && $day_start == 4)) echo 'selected="selected"'; ?> >04</option>
<option value="5" <?php if((!$formSent && $thisDay == 5) || ($formSent && $day_start == 5)) echo 'selected="selected"'; ?> >05</option>
<option value="6" <?php if((!$formSent && $thisDay == 6) || ($formSent && $day_start == 6)) echo 'selected="selected"'; ?> >06</option>
<option value="7" <?php if((!$formSent && $thisDay == 7) || ($formSent && $day_start == 7)) echo 'selected="selected"'; ?> >07</option>
<option value="8" <?php if((!$formSent && $thisDay == 8) || ($formSent && $day_start == 8)) echo 'selected="selected"'; ?> >08</option>
<option value="9" <?php if((!$formSent && $thisDay == 9) || ($formSent && $day_start == 9)) echo 'selected="selected"'; ?> >09</option>
<option value="10" <?php if((!$formSent && $thisDay == 10) || ($formSent && $day_start == 10)) echo 'selected="selected"'; ?> >10</option>
<option value="11" <?php if((!$formSent && $thisDay == 11) || ($formSent && $day_start == 11)) echo 'selected="selected"'; ?> >11</option>
<option value="12" <?php if((!$formSent && $thisDay == 12) || ($formSent && $day_start == 12)) echo 'selected="selected"'; ?> >12</option>
<option value="13" <?php if((!$formSent && $thisDay == 13) || ($formSent && $day_start == 13)) echo 'selected="selected"'; ?> >13</option>
<option value="14" <?php if((!$formSent && $thisDay == 14) || ($formSent && $day_start == 14)) echo 'selected="selected"'; ?> >14</option>
<option value="15" <?php if((!$formSent && $thisDay == 15) || ($formSent && $day_start == 15)) echo 'selected="selected"'; ?> >15</option>
<option value="16" <?php if((!$formSent && $thisDay == 16) || ($formSent && $day_start == 16)) echo 'selected="selected"'; ?> >16</option>
<option value="17" <?php if((!$formSent && $thisDay == 17) || ($formSent && $day_start == 17)) echo 'selected="selected"'; ?> >17</option>
<option value="18" <?php if((!$formSent && $thisDay == 18) || ($formSent && $day_start == 18)) echo 'selected="selected"'; ?> >18</option>
<option value="19" <?php if((!$formSent && $thisDay == 19) || ($formSent && $day_start == 19)) echo 'selected="selected"'; ?> >19</option>
<option value="20" <?php if((!$formSent && $thisDay == 20) || ($formSent && $day_start == 20)) echo 'selected="selected"'; ?> >20</option>
<option value="21" <?php if((!$formSent && $thisDay == 21) || ($formSent && $day_start == 21)) echo 'selected="selected"'; ?> >21</option>
<option value="22" <?php if((!$formSent && $thisDay == 22) || ($formSent && $day_start == 22)) echo 'selected="selected"'; ?> >22</option>
<option value="23" <?php if((!$formSent && $thisDay == 23) || ($formSent && $day_start == 23)) echo 'selected="selected"'; ?> >23</option>
<option value="24" <?php if((!$formSent && $thisDay == 24) || ($formSent && $day_start == 24)) echo 'selected="selected"'; ?> >24</option>
<option value="25" <?php if((!$formSent && $thisDay == 25) || ($formSent && $day_start == 25)) echo 'selected="selected"'; ?> >25</option>
<option value="26" <?php if((!$formSent && $thisDay == 26) || ($formSent && $day_start == 26)) echo 'selected="selected"'; ?> >26</option>
<option value="27" <?php if((!$formSent && $thisDay == 27) || ($formSent && $day_start == 27)) echo 'selected="selected"'; ?> >27</option>
<option value="28" <?php if((!$formSent && $thisDay == 28) || ($formSent && $day_start == 28)) echo 'selected="selected"'; ?> >28</option>
<option value="29" <?php if((!$formSent && $thisDay == 29) || ($formSent && $day_start == 29)) echo 'selected="selected"'; ?> >29</option>
<option value="30" <?php if((!$formSent && $thisDay == 30) || ($formSent && $day_start == 30)) echo 'selected="selected"'; ?> >30</option>
<option value="31" <?php if((!$formSent && $thisDay == 31) || ($formSent && $day_start == 31)) echo 'selected="selected"'; ?> >31</option>
</select>
/
<select name="month_start">
<option value="1">01</option>
<option value="2" <?php if((!$formSent && $thisMonth == 2) || ($formSent && $month_start == 2)) echo 'selected="selected"'; ?> >02</option>
<option value="3" <?php if((!$formSent && $thisMonth == 3) || ($formSent && $month_start == 3)) echo 'selected="selected"'; ?> >03</option>
<option value="4" <?php if((!$formSent && $thisMonth == 4) || ($formSent && $month_start == 4)) echo 'selected="selected"'; ?> >04</option>
<option value="5" <?php if((!$formSent && $thisMonth == 5) || ($formSent && $month_start == 5)) echo 'selected="selected"'; ?> >05</option>
<option value="6" <?php if((!$formSent && $thisMonth == 6) || ($formSent && $month_start == 6)) echo 'selected="selected"'; ?> >06</option>
<option value="7" <?php if((!$formSent && $thisMonth == 7) || ($formSent && $month_start == 7)) echo 'selected="selected"'; ?> >07</option>
<option value="8" <?php if((!$formSent && $thisMonth == 8) || ($formSent && $month_start == 8)) echo 'selected="selected"'; ?> >08</option>
<option value="9" <?php if((!$formSent && $thisMonth == 9) || ($formSent && $month_start == 9)) echo 'selected="selected"'; ?> >09</option>
<option value="10" <?php if((!$formSent && $thisMonth == 10) || ($formSent && $month_start == 10)) echo 'selected="selected"'; ?> >10</option>
<option value="11" <?php if((!$formSent && $thisMonth == 11) || ($formSent && $month_start == 11)) echo 'selected="selected"'; ?> >11</option>
<option value="12" <?php if((!$formSent && $thisMonth == 12) || ($formSent && $month_start == 12)) echo 'selected="selected"'; ?> >12</option>
</select>
/
<select name="year_start">
<?php
for ($i=$thisYear-5;$i <= ($thisYear+5);$i++) {
?>
<option value="<?php echo $i; ?>" <?php if((!$formSent && $thisYear == $i) || ($formSent && $year_start == $i)) echo 'selected="selected"'; ?> ><?php echo $i; ?></option>
<?php
$form->addElement('text', 'coach_username', get_lang('CoachName'), array(
'class' => 'span4',
'maxlength' => 50,
'onkeyup' => "xajax_search_coachs(document.getElementById('coach_username').value)",
'id' => 'coach_username'
));
}
?>
</select>
</div>
</div>
</div>
<div class="control-group">
<div class="controls">
<label for="end_limit">
<input id="end_limit" type="checkbox" name="end_limit" onchange="disable_endtime(this)" />
<?php echo get_lang('DateEndSession') ?>
</label>
<div id="end_date" style="display:none">
<br />
<select name="day_end">
<option value="1">01</option>
<option value="2" <?php if((!$formSent && $thisDay == 2) || ($formSent && $day_end == 2)) echo 'selected="selected"'; ?> >02</option>
<option value="3" <?php if((!$formSent && $thisDay == 3) || ($formSent && $day_end == 3)) echo 'selected="selected"'; ?> >03</option>
<option value="4" <?php if((!$formSent && $thisDay == 4) || ($formSent && $day_end == 4)) echo 'selected="selected"'; ?> >04</option>
<option value="5" <?php if((!$formSent && $thisDay == 5) || ($formSent && $day_end == 5)) echo 'selected="selected"'; ?> >05</option>
<option value="6" <?php if((!$formSent && $thisDay == 6) || ($formSent && $day_end == 6)) echo 'selected="selected"'; ?> >06</option>
<option value="7" <?php if((!$formSent && $thisDay == 7) || ($formSent && $day_end == 7)) echo 'selected="selected"'; ?> >07</option>
<option value="8" <?php if((!$formSent && $thisDay == 8) || ($formSent && $day_end == 8)) echo 'selected="selected"'; ?> >08</option>
<option value="9" <?php if((!$formSent && $thisDay == 9) || ($formSent && $day_end == 9)) echo 'selected="selected"'; ?> >09</option>
<option value="10" <?php if((!$formSent && $thisDay == 10) || ($formSent && $day_end == 10)) echo 'selected="selected"'; ?> >10</option>
<option value="11" <?php if((!$formSent && $thisDay == 11) || ($formSent && $day_end == 11)) echo 'selected="selected"'; ?> >11</option>
<option value="12" <?php if((!$formSent && $thisDay == 12) || ($formSent && $day_end == 12)) echo 'selected="selected"'; ?> >12</option>
<option value="13" <?php if((!$formSent && $thisDay == 13) || ($formSent && $day_end == 13)) echo 'selected="selected"'; ?> >13</option>
<option value="14" <?php if((!$formSent && $thisDay == 14) || ($formSent && $day_end == 14)) echo 'selected="selected"'; ?> >14</option>
<option value="15" <?php if((!$formSent && $thisDay == 15) || ($formSent && $day_end == 15)) echo 'selected="selected"'; ?> >15</option>
<option value="16" <?php if((!$formSent && $thisDay == 16) || ($formSent && $day_end == 16)) echo 'selected="selected"'; ?> >16</option>
<option value="17" <?php if((!$formSent && $thisDay == 17) || ($formSent && $day_end == 17)) echo 'selected="selected"'; ?> >17</option>
<option value="18" <?php if((!$formSent && $thisDay == 18) || ($formSent && $day_end == 18)) echo 'selected="selected"'; ?> >18</option>
<option value="19" <?php if((!$formSent && $thisDay == 19) || ($formSent && $day_end == 19)) echo 'selected="selected"'; ?> >19</option>
<option value="20" <?php if((!$formSent && $thisDay == 20) || ($formSent && $day_end == 20)) echo 'selected="selected"'; ?> >20</option>
<option value="21" <?php if((!$formSent && $thisDay == 21) || ($formSent && $day_end == 21)) echo 'selected="selected"'; ?> >21</option>
<option value="22" <?php if((!$formSent && $thisDay == 22) || ($formSent && $day_end == 22)) echo 'selected="selected"'; ?> >22</option>
<option value="23" <?php if((!$formSent && $thisDay == 23) || ($formSent && $day_end == 23)) echo 'selected="selected"'; ?> >23</option>
<option value="24" <?php if((!$formSent && $thisDay == 24) || ($formSent && $day_end == 24)) echo 'selected="selected"'; ?> >24</option>
<option value="25" <?php if((!$formSent && $thisDay == 25) || ($formSent && $day_end == 25)) echo 'selected="selected"'; ?> >25</option>
<option value="26" <?php if((!$formSent && $thisDay == 26) || ($formSent && $day_end == 26)) echo 'selected="selected"'; ?> >26</option>
<option value="27" <?php if((!$formSent && $thisDay == 27) || ($formSent && $day_end == 27)) echo 'selected="selected"'; ?> >27</option>
<option value="28" <?php if((!$formSent && $thisDay == 28) || ($formSent && $day_end == 28)) echo 'selected="selected"'; ?> >28</option>
<option value="29" <?php if((!$formSent && $thisDay == 29) || ($formSent && $day_end == 29)) echo 'selected="selected"'; ?> >29</option>
<option value="30" <?php if((!$formSent && $thisDay == 30) || ($formSent && $day_end == 30)) echo 'selected="selected"'; ?> >30</option>
<option value="31" <?php if((!$formSent && $thisDay == 31) || ($formSent && $day_end == 31)) echo 'selected="selected"'; ?> >31</option>
</select>
/
<select name="month_end">
<option value="1">01</option>
<option value="2" <?php if((!$formSent && $thisMonth == 2) || ($formSent && $month_end == 2)) echo 'selected="selected"'; ?> >02</option>
<option value="3" <?php if((!$formSent && $thisMonth == 3) || ($formSent && $month_end == 3)) echo 'selected="selected"'; ?> >03</option>
<option value="4" <?php if((!$formSent && $thisMonth == 4) || ($formSent && $month_end == 4)) echo 'selected="selected"'; ?> >04</option>
<option value="5" <?php if((!$formSent && $thisMonth == 5) || ($formSent && $month_end == 5)) echo 'selected="selected"'; ?> >05</option>
<option value="6" <?php if((!$formSent && $thisMonth == 6) || ($formSent && $month_end == 6)) echo 'selected="selected"'; ?> >06</option>
<option value="7" <?php if((!$formSent && $thisMonth == 7) || ($formSent && $month_end == 7)) echo 'selected="selected"'; ?> >07</option>
<option value="8" <?php if((!$formSent && $thisMonth == 8) || ($formSent && $month_end == 8)) echo 'selected="selected"'; ?> >08</option>
<option value="9" <?php if((!$formSent && $thisMonth == 9) || ($formSent && $month_end == 9)) echo 'selected="selected"'; ?> >09</option>
<option value="10" <?php if((!$formSent && $thisMonth == 10) || ($formSent && $month_end == 10)) echo 'selected="selected"'; ?> >10</option>
<option value="11" <?php if((!$formSent && $thisMonth == 11) || ($formSent && $month_end == 11)) echo 'selected="selected"'; ?> >11</option>
<option value="12" <?php if((!$formSent && $thisMonth == 12) || ($formSent && $month_end == 12)) echo 'selected="selected"'; ?> >12</option>
</select>
/
<select name="year_end">
<?php
for ($i=$thisYear-5;$i <= ($thisYear+5);$i++) {
?>
<option value="<?php echo $i; ?>" <?php if((!$formSent && ($thisYear+1) == $i) || ($formSent && $year_end == $i)) echo 'selected="selected"'; ?> ><?php echo $i; ?></option>
<?php
}
?>
</select>
<br /> <br />
<?php echo get_lang('SessionVisibility') ?>
<select name="session_visibility" style="width:250px;">
<?php
$visibility_list = array(
SESSION_VISIBLE_READ_ONLY => get_lang('SessionReadOnly'),
SESSION_VISIBLE => get_lang('SessionAccessible'),
SESSION_INVISIBLE => api_ucfirst(get_lang('SessionNotAccessible'))
);
foreach($visibility_list as $key=>$item): ?>
<option value="<?php echo $key; ?>"><?php echo $item; ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
</div>
<div class="control-group">
<label class="control-label">
<?php echo get_lang('SessionDurationTitle') ?> <br />
</label>
<div class="controls">
<input id="duration" type="text" name="duration" class="span1" maxlength="50" value="">
<br />
<?php echo get_lang('SessionDurationDescription') ?>
</div>
</div>
<div class="control-group">
<div class="controls">
<button class="save" type="submit" value="<?php echo get_lang('NextStep') ?>"><?php echo get_lang('NextStep') ?></button>
</div>
</div>
</form>
<script type="text/javascript">
function setDisable(select){
document.form.day_start.disabled = (select.checked) ? true : false;
document.form.month_start.disabled = (select.checked) ? true : false;
document.form.year_start.disabled = (select.checked) ? true : false;
$form->addRule('coach_username', get_lang('ThisFieldIsRequired'), 'required');
$form->add_html('<div id="ajax_list_coachs"></div>');
document.form.day_end.disabled = (select.checked) ? true : false;
document.form.month_end.disabled = (select.checked) ? true : false;
document.form.year_end.disabled = (select.checked) ? true : false;
$form->add_select('session_category', get_lang('SessionCategory'), $categoriesOptions, array(
'id' => 'session_category',
'class' => 'chzn-select',
'style' => 'width:350px;'
));
document.form.session_visibility.disabled = (select.checked) ? true : false;
document.form.session_visibility.selectedIndex = 0;
$form->addElement('advanced_settings','<a class="btn-show" id="advanced_parameters" href="javascript://">'.get_lang('DefineSessionOptions').'</a>');
document.form.start_limit.disabled = (select.checked) ? true : false;
document.form.start_limit.checked = false;
document.form.end_limit.disabled = (select.checked) ? true : false;
document.form.end_limit.checked = false;
$form->addElement('html','<div id="options" style="display:none">');
var end_div = document.getElementById('end_date');
end_div.style.display = 'none';
$form->addElement('text', 'nb_days_acess_before', array('', '', get_lang('DaysBefore')), array(
'style' => 'width: 30px;',
'value' => $nb_days_acess_before
));
var start_div = document.getElementById('start_date');
start_div.style.display = 'none';
}
$form->addElement('text', 'nb_days_acess_after', array('', '', get_lang('DaysAfter')), array(
'style' => 'width: 30px;',
'value' => $nb_days_acess_after
));
function disable_endtime(select) {
var end_div = document.getElementById('end_date');
if (end_div.style.display == 'none')
end_div.style.display = 'block';
else
end_div.style.display = 'none';
$form->addElement('html','</div>');
emptyDuration();
$form->addElement('checkbox', 'start_limit', '', get_lang('DateStartSession'), array(
'onchange' => 'disable_starttime(this)',
'id' => 'start_limit'
));
$form->addElement('html','<div id="start_date" style="display:none">');
$form->addElement('date_picker', 'date_start');
$form->addElement('html','</div>');
$form->addElement('checkbox', 'end_limit', '', get_lang('DateEndSession'), array(
'onchange' => 'disable_endtime(this)',
'id' => 'end_limit'
));
$form->addElement('html','<div id="end_date" style="display:none">');
$form->addElement('date_picker', 'date_end');
$visibilityGroup = array();
$visibilityGroup[] = $form->createElement('advanced_settings', get_lang('SessionVisibility'));
$visibilityGroup[] = $form->createElement('select', 'session_visibility', null, array(
SESSION_VISIBLE_READ_ONLY => get_lang('SessionReadOnly'),
SESSION_VISIBLE => get_lang('SessionAccessible'),
SESSION_INVISIBLE => api_ucfirst(get_lang('SessionNotAccessible'))
));
$form->addGroup($visibilityGroup, 'visibility_group', null, null, false);
$form->addElement('html','</div>');
if (SessionManager::durationPerUserIsEnabled()) {
$form->addElement('text', 'duration', get_lang('SessionDurationTitle'),
array(
'class' => 'span1',
'maxlength' => 50
));
$form->addElement('advanced_settings', get_lang('SessionDurationDescription'));
}
function disable_starttime(select) {
var start_div = document.getElementById('start_date');
if (start_div.style.display == 'none')
start_div.style.display = 'block';
else
start_div.style.display = 'none';
//Extra fields
$extra_field = new ExtraField('session');
$extra = $extra_field->addElements($form, null);
emptyDuration();
$htmlHeadXtra[] ='
<script>
$(function() {
'.$extra['jquery_ready_content'].'
});
</script>';
$form->addElement('button', 'submit', get_lang('NextStep'), array(
'class' => 'save'
));
$formDefaults = array(
'nb_days_acess_before' => $nb_days_acess_before,
'nb_days_acess_after' => $nb_days_acess_after
);
if (!$formSent) {
$formDefaults['date_start'] = "$thisYear-$thisMonth-$thisDay";
$formDefaults['date_end'] = date('Y-m-d', strtotime("$thisYear-$thisMonth-$thisDay +1 year"));
} else {
$formDefaults['name'] = api_htmlentities($name,ENT_QUOTES,$charset);
}
function emptyDuration() {
if ($('#duration').val()) {
$('#duration').val('');
$form->setDefaults($formDefaults);
if ($form->validate()) {
$params = $form->getSubmitValues();
$name = $params['name'];
$startDate = $params['date_start'];
$endDate = $params['date_end'];
$nb_days_acess_before = $params['nb_days_acess_before'];
$nb_days_acess_after = $params['nb_days_acess_after'];
$coach_username = $params['coach_username'];
$id_session_category = $params['session_category'];
$id_visibility = $params['session_visibility'];
$end_limit = isset($params['end_limit']) ? true : false;
$start_limit = isset($params['start_limit']) ? true : false;
$duration = isset($params['duration']) ? $params['duration'] : null;
if (empty($end_limit) && empty($start_limit)) {
$nolimit = 1;
} else {
$nolimit = null;
}
$extraFields = array();
foreach ($params as $key => $value) {
if (strpos($key, 'extra_') === 0) {
$extraFields[$key] = $value;
}
}
$return = SessionManager::create_session(
$name, $startDate, $endDate, $nb_days_acess_before,
$nb_days_acess_after, $nolimit, $coach_username, $id_session_category, $id_visibility, $start_limit,
$end_limit, false, $duration, $extraFields
);
if ($return == strval(intval($return))) {
// integer => no error on session creation
header('Location: add_courses_to_session.php?id_session=' . $return . '&add=true&msg=');
exit();
}
}
</script>
<?php
Display::display_header($tool_name);
if (!empty($return)) {
Display::display_error_message($return,false);
}
echo '<div class="actions">';
echo '<a href="../admin/index.php">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'),'',ICON_SIZE_MEDIUM).'</a>';
echo '</div>';
$form->display();
Display::display_footer();

@ -52,26 +52,257 @@ $end_year_disabled = $end_month_disabled = $end_day_disabled = '';
if (isset($_POST['formSent']) && $_POST['formSent']) {
$formSent = 1;
}
$order_clause = 'ORDER BY ';
$order_clause .= api_sort_by_first_name() ? 'firstname, lastname, username' : 'lastname, firstname, username';
$sql="SELECT user_id,lastname,firstname,username FROM $tbl_user WHERE status='1'".$order_clause;
if (api_is_multiple_url_enabled()) {
$table_access_url_rel_user= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$sql="SELECT DISTINCT u.user_id,lastname,firstname,username FROM $tbl_user u INNER JOIN $table_access_url_rel_user url_rel_user ON (url_rel_user.user_id = u.user_id)
WHERE status='1' AND access_url_id = '$access_url_id' $order_clause";
}
}
$result = Database::query($sql);
$coaches = Database::store_result($result);
$thisYear = date('Y');
$daysOption = array();
for ($i = 1; $i <= 31; $i++) {
$day = sprintf("%02d", $i);
$daysOption[$day] = $day;
}
$monthsOption = array();
for ($i = 1; $i <= 12; $i++) {
$month = sprintf("%02d", $i);
$monthsOption[$month] = $month;
}
$yearsOption = array();
for ($i = $thisYear - 5; $i <= ($thisYear + 5); $i++) {
$yearsOption[$i] = $i;
}
$coachesOption = array(
'' => '----- ' . get_lang('None') . ' -----'
);
foreach ($coaches as $coach) {
$personName = api_get_person_name($coach['firstname'], $coach['lastname']);
$coachesOption[$coach['user_id']] = "$personName ({$coach['username']})";
}
$Categories = SessionManager::get_all_session_category();
$categoriesOption = array(
'0' => get_lang('None')
);
if ($Categories != false) {
foreach ($categoriesList as $categoryItem) {
$categoriesOption[$categoryItem['id']] = $categoryItem['name'];
}
}
$formAction = api_get_self() . '?';
$formAction .= http_build_query(array(
'page' => Security::remove_XSS($_GET['page']),
'id' => $id
));
$form = new FormValidator('edit_session', 'post', $formAction);
$form->addElement('header', $tool_name);
$form->addElement('text', 'name', get_lang('SessionName'), array(
'class' => 'span4',
'maxlength' => 50,
'value' => $formSent ? api_htmlentities($name,ENT_QUOTES,$charset) : ''
));
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('name', get_lang('SessionNameAlreadyExists'), 'callback', 'check_session_name');
$form->addElement('select', 'id_coach', get_lang('CoachName'), $coachesOption, array(
'id' => 'coach_username',
'class' => 'chzn-select',
'style' => 'width:370px;',
'title' => get_lang('Choose')
));
$form->addRule('id_coach', get_lang('ThisFieldIsRequired'), 'required');
$form->add_select('session_category', get_lang('SessionCategory'), $categoriesOption, array(
'id' => 'session_category',
'class' => 'chzn-select',
'style' => 'width:370px;'
));
$form->addElement('advanced_settings','<a class="btn-show" id="show-options" href="#">'.get_lang('DefineSessionOptions').'</a>');
if ($infos['nb_days_access_before_beginning'] != 0 || $infos['nb_days_access_after_end'] != 0) {
$form->addElement('html','<div id="options" style="display:block;">');
} else {
$form->addElement('html','<div id="options" style="display:none;">');
}
$form->addElement('text', 'nb_days_access_before', array('', '', get_lang('DaysBefore')), array(
'style' => 'width: 30px;'
));
$form->addElement('text', 'nb_days_access_after', array('', '', get_lang('DaysAfter')), array(
'style' => 'width: 30px;'
));
$form->addElement('html','</div>');
if ($year_start!="0000") {
$form->addElement('checkbox', 'start_limit', '', get_lang('DateStartSession'), array(
'onchange' => 'disable_starttime(this)',
'id' => 'start_limit',
'checked' => ''
));
$form->addElement('html','<div id="start_date" style="display:block">');
} else {
$form->addElement('checkbox', 'start_limit', '', get_lang('DateStartSession'), array(
'onchange' => 'disable_starttime(this)',
'id' => 'start_limit'
));
$form->addElement('html','<div id="start_date" style="display:none">');
}
$form->addElement('date_picker', 'date_start');
$form->addElement('html','</div>');
if ($year_end != "0000") {
$form->addElement('checkbox', 'end_limit', '', get_lang('DateEndSession'), array(
'onchange' => 'disable_endtime(this)',
'id' => 'end_limit',
'checked' => ''
));
$form->addElement('html','<div id="end_date" style="display:block">');
} else {
$form->addElement('checkbox', 'end_limit', '', get_lang('DateEndSession'), array(
'onchange' => 'disable_endtime(this)',
'id' => 'end_limit'
));
$form->addElement('html','<div id="end_date" style="display:none">');
}
$form->addElement('date_picker', 'date_end');
$name = $_POST['name'];
$year_start = $_POST['year_start'];
$month_start = $_POST['month_start'];
$day_start = $_POST['day_start'];
$year_end = $_POST['year_end'];
$month_end = $_POST['month_end'];
$day_end = $_POST['day_end'];
$nb_days_acess_before = $_POST['nb_days_access_before'];
$nb_days_acess_after = $_POST['nb_days_access_after'];
//$nolimit = $_POST['nolimit'];
$id_coach = $_POST['id_coach'];
$id_session_category = $_POST['session_category'];
$id_visibility = $_POST['session_visibility'];
$duration = isset($_POST['duration']) ? $_POST['duration'] : null;
$description = isset($_POST['description']) ? $_POST['description'] : null;
$showDescription = isset($_POST['show_description']) ? 1 : 0;
$end_limit = $_POST['end_limit'];
$start_limit = $_POST['start_limit'];
$visibilityGroup = array();
$visibilityGroup[] = $form->createElement('advanced_settings', get_lang('SessionVisibility'));
$visibilityGroup[] = $form->createElement('select', 'session_visibility', null, array(
SESSION_VISIBLE_READ_ONLY => get_lang('SessionReadOnly'),
SESSION_VISIBLE => get_lang('SessionAccessible'),
SESSION_INVISIBLE => api_ucfirst(get_lang('SessionNotAccessible'))
), array(
'style' => 'width:250px;'
));
$form->addGroup($visibilityGroup, 'visibility_group', null, null, false);
$form->addElement('html','</div>');
if (array_key_exists('show_description', $infos)) {
$form->addElement('textarea', 'description', get_lang('Description'));
$chkDescriptionAttributes = array();
if (!empty($showDescriptionChecked)) {
$chkDescriptionAttributes['checked'] = '';
}
$form->addElement('checkbox', 'show_description', null, get_lang('ShowDescription'), $chkDescriptionAttributes);
}
if (SessionManager::durationPerUserIsEnabled()) {
$duration = empty($infos['duration']) ? null : $infos['duration'];
$form->addElement('text', 'duration', get_lang('SessionDurationTitle'), array(
'class' => 'span1',
'maxlength' => 50
));
$form->addElement('advanced_settings', get_lang('SessionDurationDescription'));
}
//Extra fields
$extra_field = new ExtraField('session');
$extra = $extra_field->addElements($form, $id);
$htmlHeadXtra[] ='
<script>
$(function() {
'.$extra['jquery_ready_content'].'
});
</script>';
$form->addElement('button', 'submit', get_lang('ModifyThisSession'), array(
'class' => 'save'
));
$formDefaults = array(
'id_coach' => $infos['id_coach'],
'session_category' => $infos['session_category_id'],
'date_start' => $infos['date_start'],
'date_end' => $infos['date_end'],
'session_visibility' => $infos['visibility'],
'description' => array_key_exists('show_description', $infos) ? $infos['description'] : ''
);
if ($formSent) {
$formDefaults['name'] = api_htmlentities($name,ENT_QUOTES,$charset);
$formDefaults['nb_days_access_before'] = api_htmlentities($nb_days_access_before,ENT_QUOTES,$charset);
$formDefaults['nb_days_access_after'] = api_htmlentities($nb_days_access_after,ENT_QUOTES,$charset);
} else {
$formDefaults['name'] = api_htmlentities($infos['name'],ENT_QUOTES,$charset);
$formDefaults['nb_days_access_before'] = api_htmlentities($infos['nb_days_access_before_beginning'],ENT_QUOTES,$charset);
$formDefaults['nb_days_access_after'] = api_htmlentities($infos['nb_days_access_after_end'],ENT_QUOTES,$charset);
}
if (SessionManager::durationPerUserIsEnabled()) {
if ($formSent) {
$formDefaults['duration'] = Security::remove_XSS($duration);
} else {
$formDefaults['duration'] = $duration;
}
}
$form->setDefaults($formDefaults);
if ($form->validate()) {
$params = $form->getSubmitValues();
$name = $params['name'];
$startDate = $params['date_start'];
$endDate = $params['date_end'];
$nb_days_acess_before = $params['nb_days_access_before'];
$nb_days_acess_after = $params['nb_days_acc ess_after'];
$id_coach = $params['id_coach'];
$id_session_category = $params['session_category'];
$id_visibility = $params['session_visibility'];
$duration = isset($params['duration']) ? $params['duration'] : null;
$description = isset($params['description']) ? $params['description'] : null;
$showDescription = isset($params['show_description']) ? 1: 0;
$end_limit = $params['end_limit'];
$start_limit = $params['start_limit'];
if (empty($end_limit) && empty($start_limit)) {
$nolimit = 1;
@ -79,15 +310,19 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
$nolimit = null;
}
$return = SessionManager::edit_session(
$extraFields = array();
foreach ($params as $key => $value) {
if (strpos($key, 'extra_') === 0) {
$extraFields[$key] = $value;
}
}
$return = SessionManager::edit_session(
$id,
$name,
$year_start,
$month_start,
$day_start,
$year_end,
$month_end,
$day_end,
$startDate,
$endDate,
$nb_days_acess_before,
$nb_days_acess_after,
$nolimit,
@ -98,317 +333,25 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
$end_limit,
$description,
$showDescription,
$duration
$duration,
$extraFields
);
if ($return == strval(intval($return))) {
header('Location: resume_session.php?id_session='.$return);
if ($return == strval(intval($return))) {
header('Location: resume_session.php?id_session=' . $return);
exit();
}
}
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
$sql="SELECT user_id,lastname,firstname,username FROM $tbl_user WHERE status='1'".$order_clause;
if (api_is_multiple_url_enabled()) {
$table_access_url_rel_user= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$sql="SELECT DISTINCT u.user_id,lastname,firstname,username FROM $tbl_user u INNER JOIN $table_access_url_rel_user url_rel_user ON (url_rel_user.user_id = u.user_id)
WHERE status='1' AND access_url_id = '$access_url_id' $order_clause";
}
}
$result = Database::query($sql);
$Coaches = Database::store_result($result);
$thisYear = date('Y');
// display the header
Display::display_header($tool_name);
if (!empty($return)) {
Display::display_error_message($return,false);
}
?>
<form class="form-horizontal" method="post" name="form" action="<?php echo api_get_self(); ?>?page=<?php echo Security::remove_XSS($_GET['page']) ?>&id=<?php echo $id; ?>" style="margin:0px;">
<fieldset>
<legend><?php echo $tool_name; ?></legend>
<input type="hidden" name="formSent" value="1">
<div class="control-group">
<label class="control-label">
<?php echo get_lang('SessionName') ?>
</label>
<div class="controls">
<input type="text" name="name" class="span4" maxlength="50" value="<?php if($formSent) echo api_htmlentities($name,ENT_QUOTES,$charset); else echo api_htmlentities($infos['name'],ENT_QUOTES,$charset); ?>">
</div>
</div>
<div class="control-group">
<label class="control-label">
<?php echo get_lang('CoachName') ?>
</label>
<div class="controls">
<select class="chzn-select" name="id_coach" style="width:380px;" title="<?php echo get_lang('Choose'); ?>" >
<option value="">----- <?php echo get_lang('None') ?> -----</option>
<?php foreach($Coaches as $enreg) { ?>
<option value="<?php echo $enreg['user_id']; ?>" <?php if(($enreg['user_id'] == $infos['id_coach']) || ($enreg['user_id'] == $id_coach)) echo 'selected="selected"'; ?>><?php echo api_get_person_name($enreg['firstname'], $enreg['lastname']).' ('.$enreg['username'].')'; ?></option>
<?php
}
unset($Coaches);
$Categories = SessionManager::get_all_session_category();
?>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="description"><?php echo get_lang('Description') ?></label>
<div class="controls">
<?php $fckEditor = new FCKeditor('description'); ?>
<?php $fckEditor->ToolbarSet = 'TrainingDescription'; ?>
<?php $fckEditor->Value = $infos['description'] ; ?>
<?php echo $fckEditor->CreateHtml(); ?>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input id="show_description" type="checkbox" name="show_description" <?php echo $showDescriptionChecked ?> />
<?php echo get_lang('ShowDescription') ?>
</label>
</div>
</div>
<div class="control-group">
<label class="control-label">
<?php echo get_lang('SessionCategory') ?>
</label>
<div class="controls">
<select class="chzn-select" id="session_category" name="session_category" style="width:380px;" title="<?php echo get_lang('Select'); ?>">
<option value="0"><?php get_lang('None'); ?></option>
<?php
if (!empty($Categories)) {
foreach($Categories as $Rows) { ?>
<option value="<?php echo $Rows['id']; ?>" <?php if($Rows['id'] == $infos['session_category_id']) echo 'selected="selected"'; ?>><?php echo $Rows['name']; ?></option>
<?php }
}
?>
</select>
</div>
</div>
<div class="control-group">
<div class="controls">
<a href="javascript://" onclick="if(document.getElementById('options').style.display == 'none'){document.getElementById('options').style.display = 'block';}else{document.getElementById('options').style.display = 'none';}"><?php echo get_lang('DefineSessionOptions') ?></a>
</div>
</div>
<div class="control-group">
<div class="controls">
<div style="display:
<?php
if($formSent){
if($nb_days_access_before!=0 || $nb_days_access_after!=0)
echo 'block';
else echo 'none';
}
else{
if($infos['nb_days_access_before_beginning']!=0 || $infos['nb_days_access_after_end']!=0)
echo 'block';
else
echo 'none';
}
?>
;" id="options">
<input type="text" name="nb_days_access_before" value="<?php if($formSent) echo api_htmlentities($nb_days_access_before,ENT_QUOTES,$charset); else echo api_htmlentities($infos['nb_days_access_before_beginning'],ENT_QUOTES,$charset); ?>" style="width: 30px;">&nbsp;<?php echo get_lang('DaysBefore') ?>
<br />
<br />
<input type="text" name="nb_days_access_after" value="<?php if($formSent) echo api_htmlentities($nb_days_access_after,ENT_QUOTES,$charset); else echo api_htmlentities($infos['nb_days_access_after_end'],ENT_QUOTES,$charset); ?>" style="width: 30px;">&nbsp;<?php echo get_lang('DaysAfter') ?>
</div>
</div>
</div>
<div class="clear"></div>
<div class="control-group">
<div class="controls">
<label for="start_limit">
<input id="start_limit" type="checkbox" name="start_limit" onchange="disable_starttime(this)" <?php if ($year_start!="0000") echo "checked"; ?>/>
<?php echo get_lang('DateStartSession');?>
</label>
<div id="start_date" style="<?php echo ($year_start=="0000") ? "display:none" : "display:block" ; ?>">
<br />
<select name="day_start">
<option value="1">01</option>
<option value="2" <?php if($day_start == 2) echo 'selected="selected"'; ?> >02</option>
<option value="3" <?php if($day_start == 3) echo 'selected="selected"'; ?> >03</option>
<option value="4" <?php if($day_start == 4) echo 'selected="selected"'; ?> >04</option>
<option value="5" <?php if($day_start == 5) echo 'selected="selected"'; ?> >05</option>
<option value="6" <?php if($day_start == 6) echo 'selected="selected"'; ?> >06</option>
<option value="7" <?php if($day_start == 7) echo 'selected="selected"'; ?> >07</option>
<option value="8" <?php if($day_start == 8) echo 'selected="selected"'; ?> >08</option>
<option value="9" <?php if($day_start == 9) echo 'selected="selected"'; ?> >09</option>
<option value="10" <?php if($day_start == 10) echo 'selected="selected"'; ?> >10</option>
<option value="11" <?php if($day_start == 11) echo 'selected="selected"'; ?> >11</option>
<option value="12" <?php if($day_start == 12) echo 'selected="selected"'; ?> >12</option>
<option value="13" <?php if($day_start == 13) echo 'selected="selected"'; ?> >13</option>
<option value="14" <?php if($day_start == 14) echo 'selected="selected"'; ?> >14</option>
<option value="15" <?php if($day_start == 15) echo 'selected="selected"'; ?> >15</option>
<option value="16" <?php if($day_start == 16) echo 'selected="selected"'; ?> >16</option>
<option value="17" <?php if($day_start == 17) echo 'selected="selected"'; ?> >17</option>
<option value="18" <?php if($day_start == 18) echo 'selected="selected"'; ?> >18</option>
<option value="19" <?php if($day_start == 19) echo 'selected="selected"'; ?> >19</option>
<option value="20" <?php if($day_start == 20) echo 'selected="selected"'; ?> >20</option>
<option value="21" <?php if($day_start == 21) echo 'selected="selected"'; ?> >21</option>
<option value="22" <?php if($day_start == 22) echo 'selected="selected"'; ?> >22</option>
<option value="23" <?php if($day_start == 23) echo 'selected="selected"'; ?> >23</option>
<option value="24" <?php if($day_start == 24) echo 'selected="selected"'; ?> >24</option>
<option value="25" <?php if($day_start == 25) echo 'selected="selected"'; ?> >25</option>
<option value="26" <?php if($day_start == 26) echo 'selected="selected"'; ?> >26</option>
<option value="27" <?php if($day_start == 27) echo 'selected="selected"'; ?> >27</option>
<option value="28" <?php if($day_start == 28) echo 'selected="selected"'; ?> >28</option>
<option value="29" <?php if($day_start == 29) echo 'selected="selected"'; ?> >29</option>
<option value="30" <?php if($day_start == 30) echo 'selected="selected"'; ?> >30</option>
<option value="31" <?php if($day_start == 31) echo 'selected="selected"'; ?> >31</option>
</select>
/
<select name="month_start">
<option value="1">01</option>
<option value="2" <?php if($month_start == 2) echo 'selected="selected"'; ?> >02</option>
<option value="3" <?php if($month_start == 3) echo 'selected="selected"'; ?> >03</option>
<option value="4" <?php if($month_start == 4) echo 'selected="selected"'; ?> >04</option>
<option value="5" <?php if($month_start == 5) echo 'selected="selected"'; ?> >05</option>
<option value="6" <?php if($month_start == 6) echo 'selected="selected"'; ?> >06</option>
<option value="7" <?php if($month_start == 7) echo 'selected="selected"'; ?> >07</option>
<option value="8" <?php if($month_start == 8) echo 'selected="selected"'; ?> >08</option>
<option value="9" <?php if($month_start == 9) echo 'selected="selected"'; ?> >09</option>
<option value="10" <?php if($month_start == 10) echo 'selected="selected"'; ?> >10</option>
<option value="11" <?php if($month_start == 11) echo 'selected="selected"'; ?> >11</option>
<option value="12" <?php if($month_start == 12) echo 'selected="selected"'; ?> >12</option>
</select>
/
<select name="year_start">
<?php
for($i=$thisYear-5;$i <= ($thisYear+5);$i++) { ?>
<option value="<?php echo $i; ?>" <?php if($year_start == $i) echo 'selected="selected"'; ?> ><?php echo $i; ?></option>
<?php
}
?>
</select>
</div>
</div>
</div>
<div class="control-group">
<div class="controls">
<label for="end_limit">
<input id="end_limit" type="checkbox" name="end_limit" onchange="disable_endtime(this)" <?php if ($year_end!="0000") echo "checked"; ?>/>
<?php echo get_lang('DateEndSession') ?>
</label>
<div id="end_date" style="<?php echo ($year_end=="0000") ? "display:none" : "display:block" ; ?>">
<br />
<select name="day_end" <?php echo $end_day_disabled; ?> >
<option value="1">01</option>
<option value="2" <?php if($day_end == 2) echo 'selected="selected"'; ?> >02</option>
<option value="3" <?php if($day_end == 3) echo 'selected="selected"'; ?> >03</option>
<option value="4" <?php if($day_end == 4) echo 'selected="selected"'; ?> >04</option>
<option value="5" <?php if($day_end == 5) echo 'selected="selected"'; ?> >05</option>
<option value="6" <?php if($day_end == 6) echo 'selected="selected"'; ?> >06</option>
<option value="7" <?php if($day_end == 7) echo 'selected="selected"'; ?> >07</option>
<option value="8" <?php if($day_end == 8) echo 'selected="selected"'; ?> >08</option>
<option value="9" <?php if($day_end == 9) echo 'selected="selected"'; ?> >09</option>
<option value="10" <?php if($day_end == 10) echo 'selected="selected"'; ?> >10</option>
<option value="11" <?php if($day_end == 11) echo 'selected="selected"'; ?> >11</option>
<option value="12" <?php if($day_end == 12) echo 'selected="selected"'; ?> >12</option>
<option value="13" <?php if($day_end == 13) echo 'selected="selected"'; ?> >13</option>
<option value="14" <?php if($day_end == 14) echo 'selected="selected"'; ?> >14</option>
<option value="15" <?php if($day_end == 15) echo 'selected="selected"'; ?> >15</option>
<option value="16" <?php if($day_end == 16) echo 'selected="selected"'; ?> >16</option>
<option value="17" <?php if($day_end == 17) echo 'selected="selected"'; ?> >17</option>
<option value="18" <?php if($day_end == 18) echo 'selected="selected"'; ?> >18</option>
<option value="19" <?php if($day_end == 19) echo 'selected="selected"'; ?> >19</option>
<option value="20" <?php if($day_end == 20) echo 'selected="selected"'; ?> >20</option>
<option value="21" <?php if($day_end == 21) echo 'selected="selected"'; ?> >21</option>
<option value="22" <?php if($day_end == 22) echo 'selected="selected"'; ?> >22</option>
<option value="23" <?php if($day_end == 23) echo 'selected="selected"'; ?> >23</option>
<option value="24" <?php if($day_end == 24) echo 'selected="selected"'; ?> >24</option>
<option value="25" <?php if($day_end == 25) echo 'selected="selected"'; ?> >25</option>
<option value="26" <?php if($day_end == 26) echo 'selected="selected"'; ?> >26</option>
<option value="27" <?php if($day_end == 27) echo 'selected="selected"'; ?> >27</option>
<option value="28" <?php if($day_end == 28) echo 'selected="selected"'; ?> >28</option>
<option value="29" <?php if($day_end == 29) echo 'selected="selected"'; ?> >29</option>
<option value="30" <?php if($day_end == 30) echo 'selected="selected"'; ?> >30</option>
<option value="31" <?php if($day_end == 31) echo 'selected="selected"'; ?> >31</option>
</select>
/
<select name="month_end" <?php echo $end_month_disabled; ?> >
<option value="1">01</option>
<option value="2" <?php if($month_end == 2) echo 'selected="selected"'; ?> >02</option>
<option value="3" <?php if($month_end == 3) echo 'selected="selected"'; ?> >03</option>
<option value="4" <?php if($month_end == 4) echo 'selected="selected"'; ?> >04</option>
<option value="5" <?php if($month_end == 5) echo 'selected="selected"'; ?> >05</option>
<option value="6" <?php if($month_end == 6) echo 'selected="selected"'; ?> >06</option>
<option value="7" <?php if($month_end == 7) echo 'selected="selected"'; ?> >07</option>
<option value="8" <?php if($month_end == 8) echo 'selected="selected"'; ?> >08</option>
<option value="9" <?php if($month_end == 9) echo 'selected="selected"'; ?> >09</option>
<option value="10" <?php if($month_end == 10) echo 'selected="selected"'; ?> >10</option>
<option value="11" <?php if($month_end == 11) echo 'selected="selected"'; ?> >11</option>
<option value="12" <?php if($month_end == 12) echo 'selected="selected"'; ?> >12</option>
</select>
/
<select name="year_end" <?php echo $end_year_disabled; ?>>
<?php
for($i=$thisYear-5;$i <= ($thisYear+5);$i++) {
?>
<option value="<?php echo $i; ?>" <?php if($year_end == $i) echo 'selected="selected"'; ?> ><?php echo $i; ?></option>
<?php
}
?>
</select>
<br /> <br />
<?php echo get_lang('SessionVisibility') ?> <br />
<select name="session_visibility" style="width:250px;">
<?php
$visibility_list = array(
SESSION_VISIBLE_READ_ONLY => get_lang('SessionReadOnly'),
SESSION_VISIBLE => get_lang('SessionAccessible'),
SESSION_INVISIBLE => api_ucfirst(get_lang('SessionNotAccessible'))
);
foreach($visibility_list as $key=>$item): ?>
<option value="<?php echo $key; ?>" <?php if($key == $infos['visibility']) echo 'selected="selected"'; ?>><?php echo $item; ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
</div>
<?php
if (empty($infos['duration'])) {
$duration = null;
} else {
$duration = $infos['duration'];
}
?>
<div class="control-group">
<label class="control-label">
<?php echo get_lang('SessionDurationTitle') ?> <br />
</label>
<div class="controls">
<input id="duration" type="text" name="duration" class="span1" maxlength="50" value="<?php if($formSent) echo Security::remove_XSS($duration); else echo $duration; ?>">
<br />
<?php echo get_lang('SessionDurationDescription') ?>
</div>
</div>
<div class="control-group">
<div class="controls">
<button class="save" type="submit" value="<?php echo get_lang('ModifyThisSession') ?>"><?php echo get_lang('ModifyThisSession') ?></button>
</div>
</div>
</fieldset>
</form>
$form->display();
?>
<script type="text/javascript">
@ -417,22 +360,13 @@ if (!empty($return)) {
?>
function setDisable(select) {
document.forms['edit_session'].elements['session_visibility'].disabled = (select.checked) ? true : false;
document.forms['edit_session'].elements['session_visibility'].selectedIndex = 0;
document.form.day_start.disabled = (select.checked) ? true : false;
document.form.month_start.disabled = (select.checked) ? true : false;
document.form.year_start.disabled = (select.checked) ? true : false;
document.form.day_end.disabled = (select.checked) ? true : false;
document.form.month_end.disabled = (select.checked) ? true : false;
document.form.year_end.disabled = (select.checked) ? true : false;
document.form.session_visibility.disabled = (select.checked) ? true : false;
document.form.session_visibility.selectedIndex = 0;
document.form.start_limit.disabled = (select.checked) ? true : false;
document.form.start_limit.checked = false;
document.form.end_limit.disabled = (select.checked) ? true : false;
document.form.end_limit.checked = false;
document.forms['edit_session'].elements['start_limit'].disabled = (select.checked) ? true : false;
document.forms['edit_session'].elements['start_limit'].checked = false;
document.forms['edit_session'].elements['end_limit'].disabled = (select.checked) ? true : false;
document.forms['edit_session'].elements['end_limit'].checked = false;
var end_div = document.getElementById('end_date');
end_div.style.display = 'none';
@ -465,6 +399,16 @@ function emptyDuration() {
}
}
$(document).on('ready', function (){
$('#show-options').on('click', function (e) {
e.preventDefault();
var display = $('#options').css('display');
display === 'block' ? $('#options').slideUp() : $('#options').slideDown() ;
});
});
</script>
<?php
Display::display_footer();

@ -199,6 +199,7 @@ $status[STUDENT] = get_lang('Learner');
$status[DRH] = get_lang('Drh');
$status[SESSIONADMIN] = get_lang('SessionsAdmin');
$status[STUDENT_BOSS] = get_lang('RoleStudentBoss');
$status[INVITEE] = get_lang('Invitee');
$form->addElement('select', 'status', get_lang('Profile'), $status, array('id' => 'status_select', 'class'=>'chzn-select', 'onchange' => 'javascript: display_drh_list();'));

@ -212,6 +212,7 @@ $status[STUDENT] = get_lang('Learner');
$status[DRH] = get_lang('Drh');
$status[SESSIONADMIN] = get_lang('SessionsAdmin');
$status[STUDENT_BOSS] = get_lang('RoleStudentBoss');
$status[INVITEE] = get_lang('Invitee');
$form->addElement('select', 'status', get_lang('Profile'), $status, array('id' => 'status_select', 'onchange' => 'javascript: display_drh_list();','class'=>'chzn-select'));

@ -135,9 +135,24 @@ define('TOOL_ADMIN_VISIBLE', 'tooladminvisible');
$user_id = api_get_user_id();
$course_code = api_get_course_id();
$sessionId = api_get_session_id();
$show_message = '';
// Deleting group session
if (api_is_invitee_user()) {
$isInASession = $sessionId > 0;
$isSubscribed = CourseManager::is_user_subscribed_in_course(
$user_id,
$course_code,
$isInASession,
$sessionId
);
if (!$isSubscribed) {
api_not_allowed(true);
}
}
//Deleting group session
Session::erase('toolgroup');
Session::erase('_gid');

@ -165,6 +165,10 @@ $action = isset($_GET['action']) ? $_GET['action'] : null;
$view = isset($_GET['view']) ? Security::remove_XSS($_GET['view']) : null;
$postAction = isset($_POST['action']) ? $_POST['action'] : null;
if (apiIsExcludedUserType()) {
api_not_allowed(true);
}
if (empty($session_id)) {
$is_course_member = CourseManager::is_user_subscribed_in_course($user_id, $course_code, false);
} else {

@ -1291,6 +1291,7 @@ function get_exam_results_data(
(
SELECT u.user_id, firstname, lastname, email, username, ' ' as group_name, '' as group_id, official_code
FROM $TBL_USER u
WHERE u.status NOT IN(" . api_get_users_status_ignored_in_reports('string') . ")
)";
}
@ -1361,6 +1362,7 @@ function get_exam_results_data(
AND tth.exe_cours_id = '" . api_get_course_id()."'
$hotpotatoe_where
$sqlWhereOption
AND user.status NOT IN(" . api_get_users_status_ignored_in_reports('string') . ")
ORDER BY
tth.exe_cours_id ASC,
tth.exe_date DESC";
@ -2861,7 +2863,7 @@ function display_question_list_by_attempt($objExercise, $exe_id, $save_user_resu
}
// Send notification ..
if (!api_is_allowed_to_edit(null,true)) {
if (!api_is_allowed_to_edit(null,true) && !apiIsExcludedUserType()) {
if (api_get_course_setting('email_alert_manager_on_new_quiz') == 1 ) {
$objExercise->send_mail_notification_for_exam($question_list_answers, $origin, $exe_id);
}

@ -91,6 +91,10 @@ $learnpath_item_id = $track_exercise_info['orig_lp_item_id'];
$lp_item_view_id = $track_exercise_info['orig_lp_item_view_id'];
$current_user_id = api_get_user_id();
if (apiIsExcludedUserType(true, $student_id)) {
api_not_allowed(true);
}
$locked = api_resource_is_locked_by_gradebook($exercise_id, LINK_EXERCISE);
if (empty($objExercise)) {

@ -118,6 +118,11 @@ if ($current_forum['forum_of_group'] != 0) {
}
}
// 6. Invited users can't create new threads
if (api_is_invitee_user()) {
api_not_allowed(true);
}
$session_toolgroup = 0;
if ($origin == 'group') {
$session_toolgroup = intval($_SESSION['toolgroup']);

@ -295,7 +295,7 @@ if (api_is_allowed_to_edit(false, true) OR
($current_forum['allow_new_threads'] == 1 AND !isset($_user['user_id']) AND $current_forum['allow_anonymous'] == 1)
) {
if ($current_forum['locked'] <> 1 AND $current_forum['locked'] <> 1) {
if (!api_is_anonymous()) {
if (!api_is_anonymous() && !api_is_invitee_user()) {
if ($my_forum == strval(intval($my_forum))) {
echo '<a href="'.$forumUrl.'newthread.php?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).$origin_string.'">'.
Display::return_icon('new_thread.png',get_lang('NewTopic'),'',ICON_SIZE_MEDIUM).'</a>';

@ -51,7 +51,15 @@ switch ($action) {
break;
case 'generate_all_certificates':
$user_list = CourseManager::get_user_list_from_course_code(api_get_course_id(), api_get_session_id());
Category::generateCertificatesInUserList($cat_id, $user_list);
if (!empty($user_list)) {
foreach ($user_list as $user_info) {
if ($user_info['status'] == INVITEE) {
continue;
}
Category::register_user_certificate($cat_id, $user_info['user_id']);
}
}
break;
case 'delete_all_certificates':
Category::deleteAllCertificates($cat_id);

@ -746,7 +746,7 @@ if ($category != '0') {
if ($show_message == '') {
// Student
if (!api_is_allowed_to_edit()) {
if (!api_is_allowed_to_edit() && !apiIsExcludedUserType()) {
$certificate = Category::register_user_certificate(
$category_id,
$stud_id

@ -0,0 +1,71 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Manage the course extra fields
* @package chamilo.library
*/
/**
* Manage the course extra fields
*
* Add the extra fields to the form excluding the Special Course Field
*/
class CourseField extends ExtraField
{
/**
* Special Course extra field
*/
const SPECIAL_COURSE_FIELD = 'special_course';
/**
* Class constructor
*/
public function __construct()
{
parent::__construct('course');
}
/**
* Add elements to a form
* @param FormValidator $form the form
* @param string $courseCode The course code
* @return array The extra data. Otherwise return false
*/
public function addElements($form, $courseCode = null)
{
if (empty($form)) {
return false;
}
$extra_data = false;
if (!empty($courseCode)) {
$extra_data = self::get_handler_extra_data($courseCode);
if ($form) {
$form->setDefaults($extra_data);
}
}
$extra_fields = $this->get_all(null, 'option_order');
$specilCourseFieldId = -1;
foreach ($extra_fields as $id => $extraField) {
if ($extraField['field_variable'] === self::SPECIAL_COURSE_FIELD) {
$specilCourseFieldId = $id;
}
}
if (isset($extra_fields[$specilCourseFieldId])) {
unset($extra_fields[$specilCourseFieldId]);
}
$extra = $this->set_extra_fields_in_form(
$form, $extra_data, $this->type . '_field', false, false, $extra_fields, $courseCode
);
return $extra;
}
}

@ -36,7 +36,7 @@ class CourseManager
*
* @return mixed false if the course was not created, array with the course info
*/
public static function create_course($params)
public static function create_course($params, $extraFields = array())
{
global $_configuration;
// Check portal limits
@ -130,6 +130,11 @@ class CourseManager
$cr->restore($course_info['id']); //course_info[id] is the course.code value (I know...)
}
$params['course_code'] = $course_info['code'];
$courseFieldValue = new ExtraFieldValue('course');
$courseFieldValue->save_field_values($params);
return $course_info;
}
}
@ -1756,6 +1761,7 @@ class CourseManager
* @param integer $session_id
* @param string $date_from
* @param string $date_to
* @param boolean $includeInvitedUsers Whether include the invited users
* @return array with user id
*/
public static function get_student_list_from_course_code(
@ -1763,7 +1769,8 @@ class CourseManager
$with_session = false,
$session_id = 0,
$date_from = null,
$date_to = null
$date_to = null,
$includeInvitedUsers = true
) {
$session_id = intval($session_id);
$course_code = Database::escape_string($course_code);
@ -1772,8 +1779,14 @@ class CourseManager
if ($session_id == 0) {
// students directly subscribed to the course
$sql = "SELECT * FROM ".Database::get_main_table(TABLE_MAIN_COURSE_USER)."
WHERE course_code = '$course_code' AND status = ".STUDENT;
$sql = "SELECT * FROM ".Database::get_main_table(TABLE_MAIN_COURSE_USER)." cu
INNER JOIN user u ON cu.user_id = u.user_id
WHERE course_code = '$course_code' AND cu.status = ".STUDENT;
if (!$includeInvitedUsers) {
$sql .= " AND u.status != " . INVITEE;
}
$rs = Database::query($sql);
while ($student = Database::fetch_array($rs)) {
$students[$student['user_id']] = $student;
@ -1792,6 +1805,7 @@ class CourseManager
$sql_query = "SELECT * FROM ".Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER)." scu
$joinSession
INNER JOIN $userTable u ON scu.id_user = u.user_id
WHERE scu.course_code = '$course_code' AND scu.status <> 2";
if (!empty($date_from) && !empty($date_to)) {
@ -1804,6 +1818,10 @@ class CourseManager
$sql_query .= ' AND scu.id_session = '.$session_id;
}
if (!$includeInvitedUsers) {
$sql .= " AND u.status != " . INVITEE;
}
$rs = Database::query($sql_query);
while($student = Database::fetch_array($rs)) {
$students[$student['id_user']] = $student;
@ -4626,6 +4644,11 @@ class CourseManager
public static function return_hot_courses($days = 30, $limit = 5)
{
global $_configuration;
if (api_is_invitee_user()) {
return array();
}
$limit = intval($limit);
// Getting my courses

@ -110,8 +110,10 @@ define('TABLE_MAIN_USER_FRIEND_RELATION_TYPE', 'user_friend_relation_type');
// Web services
define('TABLE_MAIN_USER_API_KEY', 'user_api_key');
define('TABLE_MAIN_COURSE_FIELD', 'course_field');
define('TABLE_MAIN_COURSE_FIELD_OPTIONS', 'course_field_options');
define('TABLE_MAIN_COURSE_FIELD_VALUES', 'course_field_values');
define('TABLE_MAIN_SESSION_FIELD', 'session_field');
define('TABLE_MAIN_SESSION_FIELD_OPTIONS', 'session_field_options');
define('TABLE_MAIN_SESSION_FIELD_VALUES', 'session_field_values');
// Message

@ -51,6 +51,10 @@ class ExtraField extends Model
const FIELD_TYPE_SOCIAL_PROFILE = 12;
const FIELD_TYPE_CHECKBOX = 13;
const FIELD_TYPE_MOBILE_PHONE_NUMBER = 14;
const FIELD_TYPE_INTEGER = 15;
const FIELD_TYPE_FILE_IMAGE = 16;
const FIELD_TYPE_FLOAT = 17;
const FIELD_TYPE_FILE = 18;
public $type = 'user'; //or session or course
public $handler_id = 'user_id';
@ -238,6 +242,11 @@ class ExtraField extends Model
$types[self::FIELD_TYPE_TIMEZONE] = get_lang('FieldTypeTimezone');
$types[self::FIELD_TYPE_SOCIAL_PROFILE] = get_lang('FieldTypeSocialProfile');
$types[self::FIELD_TYPE_MOBILE_PHONE_NUMBER] = get_lang('FieldTypeMobilePhoneNumber');
$types[self::FIELD_TYPE_CHECKBOX] = get_lang('FieldTypeCheckbox');
$types[self::FIELD_TYPE_INTEGER] = get_lang('FieldTypeInteger');
$types[self::FIELD_TYPE_FILE_IMAGE] = get_lang('FieldTypeFileImage');
$types[self::FIELD_TYPE_FLOAT] = get_lang('FieldTypeFloat');
$types[self::FIELD_TYPE_FILE] = get_lang('FieldTypeFile');
switch ($handler) {
case 'course':
@ -677,14 +686,22 @@ class ExtraField extends Model
);
}
} else {
$fieldVariable = "extra_{$field_details['field_variable']}";
$checkboxAttributes = array();
if (is_array($extraData) && array_key_exists($fieldVariable, $extraData)) {
$checkboxAttributes['checked'] = true;
}
// We assume that is a switch on/off with 1 and 0 as values
$group[] = $form->createElement(
'checkbox',
'extra_'.$field_details['field_variable'],
null,
//$field_details['field_display_text'].'<br />',
'Yes <br />',
null
get_lang('Yes'),
$checkboxAttributes
);
}
$form->addGroup(
@ -796,7 +813,7 @@ class ExtraField extends Model
// chzn-select doesn't work for sessions??
$form->addElement(
'select',
'extra_'.$field_details['field_variable'],
'extra_' . $field_details['field_variable'],
$field_details['field_display_text'],
$options,
array('id' => 'extra_'.$field_details['field_variable'])
@ -806,8 +823,8 @@ class ExtraField extends Model
$form->addElement(
'textarea',
'extra_'.$field_details['field_variable'].'_comment',
$field_details['field_display_text'].' '.get_lang('Comment')
'extra_' . $field_details['field_variable'] . '_comment',
$field_details['field_display_text'] . ' ' . get_lang('Comment')
);
$extraFieldValue = new ExtraFieldValue($this->type);
@ -823,7 +840,7 @@ class ExtraField extends Model
if ($newEntity) {
$logs = $repoLog->getLogEntries($newEntity);
if (!empty($logs)) {
$html = '<b>'.get_lang('LatestChanges').'</b><br /><br />';
$html = '<b>' . get_lang('LatestChanges') . '</b><br /><br />';
$table = new HTML_Table(array('class' => 'data_table'));
$table->setHeaderContents(0, 0, get_lang('Value'));
@ -853,7 +870,7 @@ class ExtraField extends Model
if (!$admin_permissions) {
if ($field_details['field_visible'] == 0) {
$form->freeze('extra_'.$field_details['field_variable']);
$form->freeze('extra_' . $field_details['field_variable']);
}
}
break;
@ -876,25 +893,17 @@ class ExtraField extends Model
}
break;
case ExtraField::FIELD_TYPE_DATE:
$form->addElement(
'datepickerdate',
'extra_'.$field_details['field_variable'],
$field_details['field_display_text'],
array('form_name' => $form_name)
);
$form->_elements[$form->_elementIndex['extra_'.$field_details['field_variable']]]->setLocalOption(
'minYear',
1900
);
$defaults['extra_'.$field_details['field_variable']] = date('Y-m-d 12:00:00');
if (!isset($form->_defaultValues['extra_'.$field_details['field_variable']])) {
$form->setDefaults($defaults);
}
$form->addElement('date_picker', 'extra_'.$field_details['field_variable'], $field_details['field_display_text']);
//$form->_elements[$form->_elementIndex['extra_'.$field_details[1]]]->setLocalOption('minYear', 1900);
//$defaults['extra_'.$field_details['field_variable']] = date('Y-m-d 12:00:00');
//$form->setDefaults($defaults);
if (!$admin_permissions) {
if ($field_details['field_visible'] == 0) {
$form->freeze('extra_'.$field_details['field_variable']);
}
}
$form->applyFilter('theme', 'trim');
break;
case ExtraField::FIELD_TYPE_DATETIME:
@ -1128,6 +1137,129 @@ EOF;
$form->freeze('extra_'.$field_details['field_variable']);
}
break;
case ExtraField::FIELD_TYPE_INTEGER:
$form->addElement(
'number',
'extra_'.$field_details['field_variable'],
$field_details['field_display_text'],
array('class' => 'span1', 'step' => 1)
);
$form->applyFilter('extra_'.$field_details['field_variable'], 'stripslashes');
$form->applyFilter('extra_'.$field_details['field_variable'], 'trim');
$form->applyFilter('extra_'.$field_details['field_variable'], 'intval');
if (!$admin_permissions) {
if ($field_details['field_visible'] == 0) {
$form->freeze(
'extra_'.$field_details['field_variable']
);
}
}
break;
case ExtraField::FIELD_TYPE_FILE_IMAGE:
$fieldVariable = "extra_{$field_details['field_variable']}";
$fieldTexts = array(
$field_details['field_display_text']
);
if (is_array($extraData) && array_key_exists($fieldVariable, $extraData)) {
if (file_exists(api_get_path(SYS_CODE_PATH) . $extraData[$fieldVariable])) {
$fieldTexts[] = Display::img(
api_get_path(WEB_CODE_PATH) . $extraData[$fieldVariable],
$field_details['field_display_text'],
array('width' => '300')
);
}
}
$form->addElement(
'file',
$fieldVariable,
$fieldTexts,
array('class' => 'span8', 'accept' => 'image/*')
);
$form->applyFilter('extra_'.$field_details['field_variable'], 'stripslashes');
$form->applyFilter('extra_'.$field_details['field_variable'], 'trim');
$allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
$form->addRule(
'extra_'.$field_details['field_variable'],
get_lang('OnlyImagesAllowed') . ' ('.implode(',', $allowed_picture_types).')',
'filetype',
$allowed_picture_types
);
if (!$admin_permissions) {
if ($field_details['field_visible'] == 0) {
$form->freeze(
'extra_'.$field_details['field_variable']
);
}
}
break;
case ExtraField::FIELD_TYPE_FLOAT:
$form->addElement(
'number',
'extra_'.$field_details['field_variable'],
$field_details['field_display_text'],
array('class' => 'span1', 'step' => '0.01')
);
$form->applyFilter('extra_'.$field_details['field_variable'], 'stripslashes');
$form->applyFilter('extra_'.$field_details['field_variable'], 'trim');
$form->applyFilter('extra_'.$field_details['field_variable'], 'floatval');
if (!$admin_permissions) {
if ($field_details['field_visible'] == 0) {
$form->freeze(
'extra_'.$field_details['field_variable']
);
}
}
break;
case ExtraField::FIELD_TYPE_FILE:
require_once api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php';
$fieldVariable = "extra_{$field_details['field_variable']}";
$fieldTexts = array(
$field_details['field_display_text']
);
if (is_array($extraData) && array_key_exists($fieldVariable, $extraData)) {
if (file_exists(api_get_path(SYS_CODE_PATH) . $extraData[$fieldVariable])) {
$fieldTexts[] = Display::url(
api_get_path(WEB_CODE_PATH) . $extraData[$fieldVariable],
api_get_path(WEB_CODE_PATH) . $extraData[$fieldVariable],
array(
'title' => $field_details['field_display_text'],
'target' => '_blank'
)
);
}
}
$form->addElement(
'file',
$fieldVariable,
$fieldTexts,
array('class' => 'span8')
);
$form->applyFilter('extra_'.$field_details['field_variable'], 'stripslashes');
$form->applyFilter('extra_'.$field_details['field_variable'], 'trim');
if (!$admin_permissions) {
if ($field_details['field_visible'] == 0) {
$form->freeze(
'extra_'.$field_details['field_variable']
);
}
}
break;
}
}
}
@ -1751,4 +1883,88 @@ EOF;
'condition_array' => $condition_array
);
}
/**
* Get the extra fields and their formated values
* @param int|string $itemId The item ID (It could be a session_id, course_id or user_id)
* @return array The extra fields data
*/
public function getDataAndFormatedValues($itemId)
{
$valuesData = array();
$fields = $this->get_all();
foreach ($fields as $field) {
if ($field['field_visible'] != '1') {
continue;
}
$fieldValue = new ExtraFieldValue($this->type);
$valueData = $fieldValue->get_values_by_handler_and_field_id($itemId, $field['id'], true);
if (!$valueData) {
continue;
}
$displayedValue = get_lang('None');
switch ($field['field_type']) {
case ExtraField::FIELD_TYPE_CHECKBOX:
if ($valueData !== false && $valueData['field_value'] == '1') {
$displayedValue = get_lang('Yes');
} else {
$displayedValue = get_lang('No');
}
break;
case ExtraField::FIELD_TYPE_DATE:
if ($valueData !== false && !empty($valueData['field_value'])) {
$displayedValue = api_format_date($valueData['field_value'], DATE_FORMAT_LONG_NO_DAY);
}
break;
case ExtraField::FIELD_TYPE_FILE_IMAGE:
if ($valueData !== false && !empty($valueData['field_value'])) {
if (file_exists(api_get_path(SYS_CODE_PATH) . $valueData['field_value'])) {
$image = Display::img(
api_get_path(WEB_CODE_PATH) . $valueData['field_value'],
$field['field_display_text'],
array('width' => '300')
);
$displayedValue = Display::url(
$image,
api_get_path(WEB_CODE_PATH) . $valueData['field_value'],
array('target' => '_blank')
);
}
}
break;
case ExtraField::FIELD_TYPE_FILE:
if ($valueData !== false && !empty($valueData['field_value'])) {
if (file_exists(api_get_path(SYS_CODE_PATH) . $valueData['field_value'])) {
$displayedValue = Display::url(
get_lang('Download'),
api_get_path(WEB_CODE_PATH) . $valueData['field_value'],
array(
'title' => $field['field_display_text'],
'target' => '_blank'
)
);
}
}
break;
default:
$displayedValue = $valueData['field_value'];
break;
}
$valuesData[] = array(
'text' => $field['field_display_text'],
'value' => $displayedValue
);
}
return $valuesData;
}
}

@ -244,7 +244,7 @@ class ExtraFieldOption extends Model
foreach ($list as $option) {
$option_info = self::get_field_option_by_field_and_option($field_id, $option);
// Use URLify only for new items
$optionValue = URLify::filter($option);
$optionValue = replace_dangerous_char($option);
$option = trim($option);
if ($option_info == false) {

@ -114,7 +114,7 @@ class ExtraFieldValue extends Model
// Parse params.
foreach ($params as $key => $value) {
if (substr($key, 0, 6) == 'extra_') {
if (substr($key, 0, 6) == 'extra_' || substr($key, 0, 7) == '_extra_') {
// An extra field.
$field_variable = substr($key, 6);
$extra_field_info = $extra_field->get_handler_field_info_by_field_variable($field_variable);
@ -160,14 +160,98 @@ class ExtraFieldValue extends Model
}
}
break;
case ExtraField::FIELD_TYPE_FILE_IMAGE:
$dirPermissions = api_get_permissions_for_new_directories();
$sysCodePath = api_get_path(SYS_CODE_PATH);
switch ($this->type) {
case 'course':
$fileDir = "upload/courses/";
break;
case 'session':
$fileDir = "upload/sessions/";
break;
case 'user':
$userPath = UserManager::get_user_picture_path_by_id($this->handler_id);
$fileDir = $userPath['dir'];
break;
}
$fileName = ExtraField::FIELD_TYPE_FILE_IMAGE . "_{$params[$this->handler_id]}.png";
if (!file_exists($sysCodePath . $fileDir)) {
mkdir($sysCodePath . $fileDir, $dirPermissions, true);
}
if ($value['error'] == 0) {
$imageExtraField = new Image($value['tmp_name']);
$imageExtraField->send_image($sysCodePath . $fileDir . $fileName, -1, 'png');
$new_params = array(
$this->handler_id => $params[$this->handler_id],
'field_id' => $extra_field_info['id'],
'field_value' => $fileDir . $fileName
);
if ($this->type !== 'session' && $this->type !== 'course') {
$new_params['comment'] = $comment;
}
self::save($new_params);
}
break;
case ExtraField::FIELD_TYPE_FILE:
$dirPermissions = api_get_permissions_for_new_directories();
$sysCodePath = api_get_path(SYS_CODE_PATH);
switch ($this->type) {
case 'course':
$fileDir = "upload/courses/";
break;
case 'session':
$fileDir = "upload/sessions/";
break;
case 'user':
$userPath = UserManager::get_user_picture_path_by_id($this->handler_id);
$fileDir = $userPath['dir'];
break;
}
$cleanedName = replace_dangerous_char($value['name']);
$fileName = ExtraField::FIELD_TYPE_FILE . "_{$params[$this->handler_id]}_$cleanedName";
if (!file_exists($sysCodePath . $fileDir)) {
mkdir($sysCodePath . $fileDir, $dirPermissions, true);
}
if ($value['error'] == 0) {
moveUploadedFile($value, $sysCodePath . $fileDir . $fileName);
$new_params = array(
$this->handler_id => $params[$this->handler_id],
'field_id' => $extra_field_info['id'],
'field_value' => $fileDir . $fileName
);
if ($this->type !== 'session' && $this->type !== 'course') {
$new_params['comment'] = $comment;
}
self::save($new_params);
}
break;
default;
$newParams = array(
$this->handler_id => $params[$this->handler_id],
'field_id' => $extra_field_info['id'],
'field_value' => $value,
'comment' => $comment
$new_params = array(
$this->handler_id => $params[$this->handler_id],
'field_id' => $extra_field_info['id'],
'field_value' => $value
);
self::save($newParams);
if ($this->handler_id !== 'session_id' && $this->handler_id !== 'course_code') {
$new_params['comment'] = $comment;
}
self::save($new_params);
}
}
}
@ -256,7 +340,10 @@ class ExtraFieldValue extends Model
$params['field_value'] = $value_to_insert;
$params['tms'] = api_get_utc_datetime();
$params[$this->author_id] = api_get_user_id();
if ($this->handler_id !== 'session_id' && $this->handler_id !== 'course_code') {
$params[$this->author_id] = api_get_user_id();
}
// Insert
if (empty($field_values)) {
@ -384,7 +471,7 @@ class ExtraFieldValue extends Model
public function get_values_by_handler_and_field_id($item_id, $field_id, $transform = false)
{
$field_id = intval($field_id);
$item_id = intval($item_id);
$item_id = Database::escape_string($item_id);
$sql = "SELECT s.*, field_type FROM {$this->table} s
INNER JOIN {$this->table_handler_field} sf ON (s.field_id = sf.id)

@ -0,0 +1,30 @@
<?php
/* For licensing terms, see /license.txt */
require_once 'HTML/QuickForm/text.php';
/**
* Form element to select a date and hour (with popup datepicker)
*
* Class DatePicker
*/
class Number extends HTML_QuickForm_text
{
/**
* @param string $elementName
* @param string $elementLabel
* @param array $attributes
*/
public function Number($elementName = null, $elementLabel = null, $attributes = null)
{
if (!isset($attributes['id'])) {
$attributes['id'] = $elementName;
}
$attributes['type'] = 'number';
HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes);
$this->_appendName = true;
$this->_type = 'number';
}
}

@ -140,6 +140,7 @@ class FormValidator extends HTML_QuickForm
$this->registerElementType('button', $dir . 'Element/style_submit_button.php', 'HTML_QuickForm_stylesubmitbutton');
$this->registerElementType('captcha', 'HTML/QuickForm/CAPTCHA.php', 'HTML_QuickForm_CAPTCHA');
$this->registerElementType('CAPTCHA_Image', 'HTML/QuickForm/CAPTCHA/Image.php', 'HTML_QuickForm_CAPTCHA_Image');
$this->registerElementType('number', $dir . 'Element/Number.php', 'Number');
$this->registerRule('date', null, 'HTML_QuickForm_Rule_Date', $dir . 'Rule/Date.php');
$this->registerRule('datetime', null, 'DateTimeRule', $dir . 'Rule/DateTimeRule.php');

@ -44,6 +44,7 @@ define('COURSE_STUDENT', 14); //student subscribed in a course
define('SESSION_STUDENT', 15); //student subscribed in a session course
define('COURSE_TUTOR', 16); // student is tutor of a course (NOT in session)
define('STUDENT_BOSS', 17); // student is boss
define('INVITEE', 20);
// Table of status
$_status_list[COURSEMANAGER] = 'teacher'; // 1
@ -51,6 +52,7 @@ $_status_list[SESSIONADMIN] = 'session_admin'; // 3
$_status_list[DRH] = 'drh'; // 4
$_status_list[STUDENT] = 'user'; // 5
$_status_list[ANONYMOUS] = 'anonymous'; // 6
$_status_list[INVITEE] = 'invited'; // 20
// COURSE VISIBILITY CONSTANTS
/** only visible for course admin */
@ -2578,6 +2580,16 @@ function api_is_teacher() {
return isset($_user['status']) && $_user['status'] == COURSEMANAGER;
}
/**
* Checks whether the current user is a invited user
* @return boolean
*/
function api_is_invitee_user() {
global $_user;
return isset($_user['status']) && $_user['status'] == INVITEE;
}
/**
* This function checks whether a session is assigned into a category
* @param int - session id
@ -4682,7 +4694,8 @@ function api_get_status_langvars() {
DRH => get_lang('Drh', ''),
STUDENT => get_lang('Student', ''),
ANONYMOUS => get_lang('Anonymous', ''),
STUDENT_BOSS => get_lang('RoleStudentBoss', '')
STUDENT_BOSS => get_lang('RoleStudentBoss', ''),
INVITEE => get_lang('Invited'),
);
}
@ -4991,7 +5004,7 @@ function & api_get_settings($cat = null, $ordering = 'list', $access_url = 1, $u
/**
* Gets the distinct settings categories
* @param array Array of strings giving the categories we want to exclude
* @param array Array of strings giving the categories we want to excluded
* @param int Access URL. Optional. Defaults to 1
* @return array A list of categories
*/
@ -7528,6 +7541,62 @@ function api_is_student_boss ()
return isset($_user['status']) && $_user['status'] == STUDENT_BOSS;
}
/**
* Check whether the user type should be exclude.
* Such as invited or anonymous users
* @param boolean $checkDB Optional. Whether check the user status
* @param int $userId Options. The user id
* @return boolean
*/
function apiIsExcludedUserType($checkDB = false, $userId = 0)
{
if ($checkDB) {
$userId = empty($userId) ? api_get_user_id() : intval($userId);
if ($userId == 0) {
return true;
}
$userInfo = api_get_user_info($userId);
switch ($userInfo['status']) {
case INVITEE:
//no break;
case ANONYMOUS:
return true;
default:
return false;
}
}
$isInvited = api_is_invitee_user();
$isAnonymous = api_is_anonymous();
if ($isInvited || $isAnonymous) {
return true;
}
return false;
}
/**
* Get the user status to ignore in reports
* @param string $format Optional. The result type (array or string)
* @return array|string
*/
function api_get_users_status_ignored_in_reports($format = 'array')
{
$excludedTypes = array(
INVITEE,
ANONYMOUS
);
if ($format == 'string') {
return implode(', ', $excludedTypes);
}
return $excludedTypes;
}
/**
* Set the Site Use Cookie Warning for 1 year
@ -7560,10 +7629,10 @@ function api_format_time($time, $originFormat = 'php')
$secs = ($time % 60);
if ($originFormat == 'js') {
$scormTime = trim(sprintf("%02d : %02d : %02d", $hours, $mins, $secs));
$formattedTime = trim(sprintf("%02d : %02d : %02d", $hours, $mins, $secs));
} else {
$scormTime = trim(sprintf("%02d$h%02d'%02d\"", $hours, $mins, $secs));
$formattedTime = trim(sprintf("%02d$h%02d'%02d\"", $hours, $mins, $secs));
}
return $scormTime;
return $formattedTime;
}

@ -71,12 +71,8 @@ class SessionManager
* */
public static function create_session(
$sname,
$syear_start,
$smonth_start,
$sday_start,
$syear_end,
$smonth_end,
$sday_end,
$startDate,
$endDate,
$snb_days_acess_before,
$snb_days_acess_after,
$nolimit,
@ -111,12 +107,6 @@ class SessionManager
}
$name = Database::escape_string(trim($sname));
$year_start = intval($syear_start);
$month_start = intval($smonth_start);
$day_start = intval($sday_start);
$year_end = intval($syear_end);
$month_end = intval($smonth_end);
$day_end = intval($sday_end);
$nb_days_acess_before = intval($snb_days_acess_before);
$nb_days_acess_after = intval($snb_days_acess_after);
$id_session_category = intval($id_session_category);
@ -133,8 +123,8 @@ class SessionManager
}
if (empty($nolimit)) {
$date_start = "$year_start-" . (($month_start < 10) ? "0$month_start" : $month_start) . "-" . (($day_start < 10) ? "0$day_start" : $day_start);
$date_end = "$year_end-" . (($month_end < 10) ? "0$month_end" : $month_end) . "-" . (($day_end < 10) ? "0$day_end" : $day_end);
$date_start = Database::escape_string($startDate);
$date_end = Database::escape_string($endDate);
} else {
$id_visibility = 1; // by default session visibility is read only
$date_start = "0000-00-00";
@ -156,10 +146,10 @@ class SessionManager
} elseif (empty($coach_username)) {
$msg = get_lang('CoachIsRequired');
return $msg;
} elseif (!empty($start_limit) && empty($nolimit) && (!$month_start || !$day_start || !$year_start || !checkdate($month_start, $day_start, $year_start))) {
} elseif (!empty($start_limit) && empty($nolimit) && !api_is_valid_date($date_start, 'Y-m-d')) {
$msg = get_lang('InvalidStartDate');
return $msg;
} elseif (!empty($end_limit) && empty($nolimit) && (!$month_end || !$day_end || !$year_end || !checkdate($month_end, $day_end, $year_end))) {
} elseif (!empty($end_limit) && empty($nolimit) && !api_is_valid_date($date_end, 'Y-m-d')) {
$msg = get_lang('InvalidEndDate');
return $msg;
} elseif (!empty($start_limit) && !empty($end_limit) && empty($nolimit) && $date_start >= $date_end) {
@ -217,6 +207,11 @@ class SessionManager
}
if (!empty($session_id)) {
$extraFields['session_id'] = $session_id;
$sessionFieldValue = new ExtraFieldValue('session');
$sessionFieldValue->save_field_values($extraFields);
/*
Sends a message to the user_id = 1
@ -1350,12 +1345,8 @@ class SessionManager
public static function edit_session(
$id,
$name,
$year_start,
$month_start,
$day_start,
$year_end,
$month_end,
$day_end,
$startDate,
$endDate,
$nb_days_acess_before,
$nb_days_acess_after,
$nolimit,
@ -1366,7 +1357,8 @@ class SessionManager
$end_limit = true,
$description = null,
$showDescription = 0,
$duration = null
$duration = null,
$extraFields = array()
) {
$name = trim(stripslashes($name));
$year_start = intval($year_start);
@ -1384,8 +1376,8 @@ class SessionManager
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
if (empty($nolimit)) {
$date_start = "$year_start-" . (($month_start < 10) ? "0$month_start" : $month_start) . "-" . (($day_start < 10) ? "0$day_start" : $day_start);
$date_end = "$year_end-" . (($month_end < 10) ? "0$month_end" : $month_end) . "-" . (($day_end < 10) ? "0$day_end" : $day_end);
$date_start = Database::escape_string($startDate);
$date_end = Database::escape_string($endDate);
} else {
$date_start = "0000-00-00";
$date_end = "0000-00-00";
@ -1411,10 +1403,10 @@ class SessionManager
} elseif (empty($id_coach)) {
$msg = get_lang('CoachIsRequired');
return $msg;
} elseif (!empty($start_limit) && empty($nolimit) && (!$month_start || !$day_start || !$year_start || !checkdate($month_start, $day_start, $year_start))) {
} elseif (!empty($start_limit) && empty($nolimit) && !api_is_valid_date($date_start, 'Y-m-d')) {
$msg = get_lang('InvalidStartDate');
return $msg;
} elseif (!empty($end_limit) && empty($nolimit) && (!$month_end || !$day_end || !$year_end || !checkdate($month_end, $day_end, $year_end))) {
} elseif (!empty($end_limit) && empty($nolimit) && !api_is_valid_date($date_end, 'Y-m-d')) {
$msg = get_lang('InvalidEndDate');
return $msg;
} elseif (!empty($start_limit) && !empty($end_limit) && empty($nolimit) && $date_start >= $date_end) {
@ -1460,6 +1452,11 @@ class SessionManager
'id = ?' => $id
));
$extraFields['session_id'] = $id;
$sessionFieldValue = new ExtraFieldValue('session');
$sessionFieldValue->save_field_values($extraFields);
return $id;
}
}

@ -5878,9 +5878,10 @@ class TrackingCourseLog
* @param $number_of_items
* @param $column
* @param $direction
* @param $includeInvitedUsers boolean Whether include the invited users
* @return array
*/
public static function get_user_data($from, $number_of_items, $column, $direction)
public static function get_user_data($from, $number_of_items, $column, $direction, $includeInvitedUsers = false)
{
global $user_ids, $course_code, $additional_user_profile_info, $export_csv, $is_western_name_order, $csv_content, $session_id;
@ -5916,13 +5917,19 @@ class TrackingCourseLog
$url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'";
}
$invitedUsersCondition = '';
if (!$includeInvitedUsers) {
$invitedUsersCondition = " AND user.status != " . INVITEE;
}
$sql = "SELECT user.user_id as user_id,
user.official_code as col0,
user.lastname as col1,
user.firstname as col2,
user.username as col3
FROM $tbl_user as user $url_table
$condition_user $url_condition";
$condition_user $url_condition $invitedUsersCondition";
if (!in_array($direction, array('ASC','DESC'))) {
$direction = 'ASC';

@ -541,6 +541,7 @@ CREATE TABLE IF NOT EXISTS session_field (
PRIMARY KEY(id)
);
DROP TABLE IF EXISTS session_field_values;
CREATE TABLE IF NOT EXISTS session_field_values(
id int NOT NULL auto_increment,
@ -883,7 +884,7 @@ VALUES
('tool_visible_by_default_at_creation','forums','checkbox','Tools','true','ToolVisibleByDefaultAtCreationTitle','ToolVisibleByDefaultAtCreationComment',NULL,'Forums', 1),
('tool_visible_by_default_at_creation','quiz','checkbox','Tools','true','ToolVisibleByDefaultAtCreationTitle','ToolVisibleByDefaultAtCreationComment',NULL,'Quiz', 1),
('tool_visible_by_default_at_creation','gradebook','checkbox','Tools','true','ToolVisibleByDefaultAtCreationTitle','ToolVisibleByDefaultAtCreationComment',NULL,'Gradebook', 1),
('chamilo_database_version', NULL, 'textfield',NULL, '1.10.0.5','DatabaseVersion','', NULL, NULL, 0);
('chamilo_database_version', NULL, 'textfield',NULL, '1.10.0.6','DatabaseVersion','', NULL, NULL, 0);
UNLOCK TABLES;
/*!40000 ALTER TABLE settings_current ENABLE KEYS */;
@ -2720,7 +2721,7 @@ CREATE TABLE IF NOT EXISTS message_attachment (
INSERT INTO course_field (field_type, field_variable, field_display_text, field_default_value, field_visible, field_changeable) values (10, 'special_course','Special course', 'Yes', 1 , 1);
INSERT INTO course_field (field_type, field_variable, field_display_text, field_default_value, field_visible, field_changeable) values (10, 'special_course','Special course', '', 1 , 1);
--
-- Table structure for table block
@ -3036,7 +3037,6 @@ CREATE TABLE usergroup_rel_question (
);
-- 1.10.x-specific, non-course-related, database changes
<<<<<<< HEAD
-- some changes to previous structure might have been applied to the tables
-- creation statements above to increase efficiency
@ -3064,5 +3064,28 @@ CREATE TABLE IF NOT EXISTS hook_call(
PRIMARY KEY PK_hook_management_hook_call(id)
);
=======
>>>>>>> ilosada-BT9068a
--
-- Table structure for table course_field_options
--
CREATE TABLE course_field_options (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
field_id INT NOT NULL,
option_value TEXT,
option_display_text VARCHAR(64),
option_order INT,
tms DATETIME
);
--
-- Table structure for table session_field_options
--
CREATE TABLE session_field_options (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
field_id INT NOT NULL,
option_value TEXT,
option_display_text VARCHAR(64),
option_order INT,
tms DATETIME
);

@ -20,6 +20,9 @@ ALTER TABLE skill_rel_user ADD INDEX idx_select_cs (course_id, session_id);
CREATE TABLE IF NOT EXISTS hook_observer( id int UNSIGNED NOT NULL AUTO_INCREMENT, class_name varchar(255) UNIQUE, path varchar(255) NOT NULL, plugin_name varchar(255) NULL, PRIMARY KEY PK_hook_management_hook_observer(id));
CREATE TABLE IF NOT EXISTS hook_event( id int UNSIGNED NOT NULL AUTO_INCREMENT, class_name varchar(255) UNIQUE, description varchar(255), PRIMARY KEY PK_hook_management_hook_event(id));
CREATE TABLE IF NOT EXISTS hook_call( id int UNSIGNED NOT NULL AUTO_INCREMENT, hook_event_id int UNSIGNED NOT NULL, hook_observer_id int UNSIGNED NOT NULL, type tinyint NOT NULL, hook_order int UNSIGNED NOT NULL, enabled tinyint NOT NULL, PRIMARY KEY PK_hook_management_hook_call(id));
CREATE TABLE course_field_options (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, field_id INT NOT NULL, option_value TEXT, option_display_text VARCHAR(64), option_order INT, tms DATETIME);
CREATE TABLE session_field_options (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, field_id INT NOT NULL, option_value TEXT, option_display_text VARCHAR(64), option_order INT, tms DATETIME);
ALTER TABLE session ADD COLUMN description TEXT DEFAULT NULL;
ALTER TABLE session ADD COLUMN show_description TINYINT UNSIGNED DEFAULT 0 AFTER description;
@ -30,7 +33,7 @@ ALTER TABLE session ADD COLUMN duration int;
ALTER TABLE session_rel_user ADD COLUMN duration int;
-- Do not move this query
UPDATE settings_current SET selected_value = '1.10.0.5' WHERE variable = 'chamilo_database_version';
UPDATE settings_current SET selected_value = '1.10.0.6' WHERE variable = 'chamilo_database_version';
-- xxCOURSExx

@ -746,194 +746,197 @@ if (!empty($student_id)) {
echo '</table>';
}
} else {
$csv_content[] = array();
$csv_content[] = array(str_replace('&nbsp;', '', $table_title));
$t_lp = Database :: get_course_table(TABLE_LP_MAIN);
// csv export headers
$csv_content[] = array();
$csv_content[] = array(
get_lang('Learnpath'),
get_lang('Time'),
get_lang('AverageScore'),
get_lang('LatestAttemptAverageScore'),
get_lang('Progress'),
get_lang('LastConnexion')
);
if ($user_info['status'] != INVITEE) {
$csv_content[] = array();
$csv_content[] = array(str_replace('&nbsp;', '', $table_title));
$t_lp = Database :: get_course_table(TABLE_LP_MAIN);
// csv export headers
$csv_content[] = array();
$csv_content[] = array(
get_lang('Learnpath'),
get_lang('Time'),
get_lang('AverageScore'),
get_lang('LatestAttemptAverageScore'),
get_lang('Progress'),
get_lang('LastConnexion')
);
if (empty($session_id)) {
$sql_lp = " SELECT lp.name, lp.id FROM $t_lp lp
WHERE session_id = 0 AND c_id = {$info_course['real_id']}
ORDER BY lp.display_order";
} else {
$sql_lp = " SELECT lp.name, lp.id FROM $t_lp lp
WHERE c_id = {$info_course['real_id']}
ORDER BY lp.display_order";
}
$rs_lp = Database::query($sql_lp);
if (Database :: num_rows($rs_lp) > 0) {
?>
<!-- LPs-->
<table class="data_table">
<tr>
<th><?php echo get_lang('Learnpaths');?></th>
<th><?php echo get_lang('Time').' '; Display :: display_icon('info3.gif', get_lang('TotalTimeByCourse'), array ('align' => 'absmiddle', 'hspace' => '3px')); ?></th>
<th><?php echo get_lang('AverageScore').' '; Display :: display_icon('info3.gif', get_lang('AverageIsCalculatedBasedInAllAttempts'), array ( 'align' => 'absmiddle', 'hspace' => '3px')); ?></th>
<th><?php echo get_lang('LatestAttemptAverageScore').' '; Display :: display_icon('info3.gif', get_lang('AverageIsCalculatedBasedInTheLatestAttempts'), array ( 'align' => 'absmiddle', 'hspace' => '3px')); ?></th>
<th><?php echo get_lang('Progress').' '; Display :: display_icon('info3.gif', get_lang('LPProgressScore'), array ('align' => 'absmiddle','hspace' => '3px')); ?></th>
<th><?php echo get_lang('LastConnexion').' '; Display :: display_icon('info3.gif', get_lang('LastTimeTheCourseWasUsed'), array ('align' => 'absmiddle','hspace' => '3px')); ?></th>
<?php
echo '<th>'.get_lang('Details').'</th>';
if (api_is_allowed_to_edit()) {
echo '<th>'.get_lang('ResetLP').'</th>';
}
if (empty($session_id)) {
$sql_lp = " SELECT lp.name, lp.id FROM $t_lp lp
WHERE session_id = 0 AND c_id = {$info_course['real_id']}
ORDER BY lp.display_order";
} else {
$sql_lp = " SELECT lp.name, lp.id FROM $t_lp lp
WHERE c_id = {$info_course['real_id']}
ORDER BY lp.display_order";
}
$rs_lp = Database::query($sql_lp);
if (Database :: num_rows($rs_lp) > 0) {
?>
</tr>
<?php
<!-- LPs-->
<table class="data_table">
<tr>
<th><?php echo get_lang('Learnpaths');?></th>
<th><?php echo get_lang('Time').' '; Display :: display_icon('info3.gif', get_lang('TotalTimeByCourse'), array ('align' => 'absmiddle', 'hspace' => '3px')); ?></th>
<th><?php echo get_lang('AverageScore').' '; Display :: display_icon('info3.gif', get_lang('AverageIsCalculatedBasedInAllAttempts'), array ( 'align' => 'absmiddle', 'hspace' => '3px')); ?></th>
<th><?php echo get_lang('LatestAttemptAverageScore').' '; Display :: display_icon('info3.gif', get_lang('AverageIsCalculatedBasedInTheLatestAttempts'), array ( 'align' => 'absmiddle', 'hspace' => '3px')); ?></th>
<th><?php echo get_lang('Progress').' '; Display :: display_icon('info3.gif', get_lang('LPProgressScore'), array ('align' => 'absmiddle','hspace' => '3px')); ?></th>
<th><?php echo get_lang('LastConnexion').' '; Display :: display_icon('info3.gif', get_lang('LastTimeTheCourseWasUsed'), array ('align' => 'absmiddle','hspace' => '3px')); ?></th>
<?php
echo '<th>'.get_lang('Details').'</th>';
if (api_is_allowed_to_edit()) {
echo '<th>'.get_lang('ResetLP').'</th>';
}
?>
</tr>
<?php
$i = 0;
while ($learnpath = Database :: fetch_array($rs_lp)) {
$i = 0;
while ($learnpath = Database :: fetch_array($rs_lp)) {
$lp_id = intval($learnpath['id']);
$lp_name = $learnpath['name'];
$any_result = false;
$lp_id = intval($learnpath['id']);
$lp_name = $learnpath['name'];
$any_result = false;
// Get progress in lp
$progress = Tracking::get_avg_student_progress(
$student_id,
$course_code,
array($lp_id),
$session_id
);
// Get progress in lp
$progress = Tracking::get_avg_student_progress(
$student_id,
$course_code,
array($lp_id),
$session_id
);
if ($progress === null) {
$progress = '0%';
} else {
$any_result = true;
}
if ($progress === null) {
$progress = '0%';
} else {
$any_result = true;
}
// Get time in lp
$total_time = Tracking::get_time_spent_in_lp(
$student_id,
$course_code,
array($lp_id),
$session_id
);
// Get time in lp
$total_time = Tracking::get_time_spent_in_lp(
$student_id,
$course_code,
array($lp_id),
$session_id
);
if (!empty($total_time)) {
$any_result = true;
}
if (!empty($total_time)) {
$any_result = true;
}
// Get last connection time in lp
$start_time = Tracking::get_last_connection_time_in_lp(
$student_id,
$course_code,
$lp_id,
$session_id
);
// Get last connection time in lp
$start_time = Tracking::get_last_connection_time_in_lp(
$student_id,
$course_code,
$lp_id,
$session_id
);
if (!empty($start_time)) {
$start_time = api_convert_and_format_date($start_time, DATE_TIME_FORMAT_LONG);
} else {
$start_time = '-';
}
if (!empty($start_time)) {
$start_time = api_convert_and_format_date($start_time, DATE_TIME_FORMAT_LONG);
} else {
$start_time = '-';
}
if (!empty($total_time)) $any_result = true;
if (!empty($total_time)) $any_result = true;
// Quiz in lp
$score = Tracking::get_avg_student_score(
$student_id,
$course_code,
array($lp_id),
$session_id
);
// Quiz in lp
$score = Tracking::get_avg_student_score(
$student_id,
$course_code,
array($lp_id),
$session_id
);
// Latest exercise results in a LP
$score_latest = Tracking:: get_avg_student_score(
$student_id,
$course_code,
array($lp_id),
$session_id,
false,
true
);
// Latest exercise results in a LP
$score_latest = Tracking:: get_avg_student_score(
$student_id,
$course_code,
array($lp_id),
$session_id,
false,
true
);
if ($i % 2 == 0) $css_class = "row_even";
else $css_class = "row_odd";
if ($i % 2 == 0) $css_class = "row_even";
else $css_class = "row_odd";
$i++;
$i++;
// csv export content
$csv_content[] = array (
api_html_entity_decode(stripslashes($lp_name), ENT_QUOTES, $charset),
api_time_to_hms($total_time),
$score . '%',
$score_latest . '%',
$progress.'%',
$start_time
);
// csv export content
$csv_content[] = array (
api_html_entity_decode(stripslashes($lp_name), ENT_QUOTES, $charset),
api_time_to_hms($total_time),
$score . '%',
$score_latest . '%',
$progress.'%',
$start_time
);
echo '<tr class="'.$css_class.'">';
echo '<tr class="'.$css_class.'">';
echo Display::tag('td', stripslashes($lp_name));
echo Display::tag('td', api_time_to_hms($total_time));
echo Display::tag('td', stripslashes($lp_name));
echo Display::tag('td', api_time_to_hms($total_time));
if (!is_null($score)) {
if (is_numeric($score)) {
$score = $score.'%';
if (!is_null($score)) {
if (is_numeric($score)) {
$score = $score.'%';
}
}
}
echo Display::tag('td', $score);
echo Display::tag('td', $score);
if (!is_null($score_latest)) {
if (is_numeric($score_latest)) {
$score_latest = $score_latest.'%';
if (!is_null($score_latest)) {
if (is_numeric($score_latest)) {
$score_latest = $score_latest.'%';
}
}
}
echo Display::tag('td', $score_latest);
echo Display::tag('td', $score_latest);
if (is_numeric($progress)) {
$progress = $progress.'%';
} else {
$progress = '-';
}
if (is_numeric($progress)) {
$progress = $progress.'%';
} else {
$progress = '-';
}
echo Display::tag('td', $progress);
//Do not change with api_convert_and_format_date, because this value came from the lp_item_view table
//which implies several other changes not a priority right now
echo Display::tag('td', $start_time);
echo Display::tag('td', $progress);
//Do not change with api_convert_and_format_date, because this value came from the lp_item_view table
//which implies several other changes not a priority right now
echo Display::tag('td', $start_time);
if ($any_result === true) {
$from = '';
if ($from_myspace) {
$from ='&from=myspace';
if ($any_result === true) {
$from = '';
if ($from_myspace) {
$from ='&from=myspace';
}
$link = Display::url(
'<img src="../img/2rightarrow.gif" border="0" />',
'lp_tracking.php?cidReq='.Security::remove_XSS($_GET['course']).'&course='.Security::remove_XSS($_GET['course']).$from.'&origin='.Security::remove_XSS($_GET['origin']).'&lp_id='.$learnpath['id'].'&student_id='.$user_info['user_id'].'&id_session='.$session_id
);
echo Display::tag('td', $link);
}
$link = Display::url(
'<img src="../img/2rightarrow.gif" border="0" />',
'lp_tracking.php?cidReq='.Security::remove_XSS($_GET['course']).'&course='.Security::remove_XSS($_GET['course']).$from.'&origin='.Security::remove_XSS($_GET['origin']).'&lp_id='.$learnpath['id'].'&student_id='.$user_info['user_id'].'&id_session='.$session_id
);
echo Display::tag('td', $link);
}
if (api_is_allowed_to_edit()) {
echo '<td>';
if ($any_result === true) {
echo '<a href="myStudents.php?action=reset_lp&sec_token='.$token.'&cidReq='.Security::remove_XSS($_GET['course']).'&course='.Security::remove_XSS($_GET['course']).'&details='.Security::remove_XSS($_GET['details']).'&origin='.Security::remove_XSS($_GET['origin']).'&lp_id='.$learnpath['id'].'&student='.$user_info['user_id'].'&details=true&id_session='.Security::remove_XSS($_GET['id_session']).'">';
echo Display::return_icon('clean.png',get_lang('Clean'),'',ICON_SIZE_SMALL).'</a>';
echo '</a>';
if (api_is_allowed_to_edit()) {
echo '<td>';
if ($any_result === true) {
echo '<a href="myStudents.php?action=reset_lp&sec_token='.$token.'&cidReq='.Security::remove_XSS($_GET['course']).'&course='.Security::remove_XSS($_GET['course']).'&details='.Security::remove_XSS($_GET['details']).'&origin='.Security::remove_XSS($_GET['origin']).'&lp_id='.$learnpath['id'].'&student='.$user_info['user_id'].'&details=true&id_session='.Security::remove_XSS($_GET['id_session']).'">';
echo Display::return_icon('clean.png',get_lang('Clean'),'',ICON_SIZE_SMALL).'</a>';
echo '</a>';
}
echo '</td>';
echo '</tr>';
}
echo '</td>';
echo '</tr>';
$data_learnpath[$i][] = $lp_name;
$data_learnpath[$i][] = $progress . '%';
}
$data_learnpath[$i][] = $lp_name;
$data_learnpath[$i][] = $progress . '%';
} else {
//echo '<tr><td colspan="6">'.get_lang('NoLearnpath').'</td></tr>';
}
} else {
//echo '<tr><td colspan="6">'.get_lang('NoLearnpath').'</td></tr>';
}
?>
</table>
?>
</table>
<?php } ?>
<!-- line about exercises -->
<?php if ($user_info['status'] != INVITEE) { ?>
<table class="data_table">
<tr>
<th><?php echo get_lang('Exercices'); ?></th>
@ -1045,6 +1048,7 @@ if (!empty($student_id)) {
echo '<tr><td colspan="6">'.get_lang('NoExercise').'</td></tr>';
}
echo '</table>';
}
//@when using sessions we do not show the survey list
if (empty($session_id)) {

@ -204,7 +204,7 @@ class learnpath
$this->last_item_seen = $row['last_item'];
$this->progress_db = $row['progress'];
$this->lp_view_session_id = $row['session_id'];
} else {
} else if (!api_is_invitee_user()) {
if ($this->debug > 2) {
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - NOT Found previous view', 0);
}
@ -351,17 +351,19 @@ class learnpath
}
}
} else {
if (is_object($this->items[$item_id])) {
$this->items[$item_id]->set_status($this->default_status);
}
// Add that row to the lp_item_view table so that we have something to show in the stats page.
$sql = "INSERT INTO $lp_item_view_table (c_id, lp_item_id, lp_view_id, view_count, status)
VALUES ($course_id, ".$item_id . "," . $this->lp_view_id . ", 1, 'not attempted')";
if ($this->debug > 2) {
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - Inserting blank item_view : ' . $sql, 0);
if (!api_is_invitee_user()) {
if (is_object($this->items[$item_id])) {
$this->items[$item_id]->set_status($this->default_status);
}
// Add that row to the lp_item_view table so that we have something to show in the stats page.
$sql = "INSERT INTO $lp_item_view_table (c_id, lp_item_id, lp_view_id, view_count, status)
VALUES ($course_id, ".$item_id . "," . $this->lp_view_id . ", 1, 'not attempted')";
if ($this->debug > 2) {
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - Inserting blank item_view : ' . $sql_ins, 0);
}
$this->items[$item_id]->set_lp_view($this->lp_view_id, $course_id);
Database::query($sql);
}
$this->items[$item_id]->set_lp_view($this->lp_view_id, $course_id);
Database::query($sql);
}
}
}
@ -3611,7 +3613,7 @@ class learnpath
if (Database :: num_rows($res) > 0) {
$row = Database :: fetch_array($res);
$this->lp_view_id = $row['id'];
} else {
} else if (!api_is_invitee_user()) {
// There is no database record, create one.
$sql = "INSERT INTO $lp_view_table (c_id, lp_id,user_id, view_count, session_id) VALUES
($course_id, " . $this->get_id() . "," . $this->get_user_id() . ", 1, $sessionId)";
@ -4190,6 +4192,9 @@ class learnpath
// TODO
// Call autosave method to save the current progress.
//$this->index = 0;
if (api_is_invitee_user()) {
return false;
}
$session_id = api_get_session_id();
$course_id = api_get_course_int_id();
$lp_view_table = Database :: get_course_table(TABLE_LP_VIEW);
@ -4307,7 +4312,7 @@ class learnpath
$session_condition = api_get_session_condition(api_get_session_id(), true, false);
$table = Database :: get_course_table(TABLE_LP_VIEW);
if (isset($this->current)) {
if (isset($this->current) && !api_is_invitee_user()) {
if ($this->debug > 2) {
error_log('New LP - Saving current item (' . $this->current . ') for later review', 0);
}
@ -4324,19 +4329,21 @@ class learnpath
Database::query($sql);
}
// Save progress.
list($progress, $text) = $this->get_progress_bar_text('%');
if ($progress >= 0 && $progress <= 100) {
$progress = (int) $progress;
$sql = "UPDATE $table SET
progress = $progress
WHERE
c_id = ".$course_id." AND
lp_id = " . $this->get_id() . " AND
user_id = " . $this->get_user_id()." ".$session_condition;
// Ignore errors as some tables might not have the progress field just yet.
Database::query($sql);
$this->progress_db = $progress;
if (!api_is_invitee_user()) {
// Save progress.
list($progress, $text) = $this->get_progress_bar_text('%');
if ($progress >= 0 && $progress <= 100) {
$progress = (int) $progress;
$sql = "UPDATE $table SET
progress = $progress
WHERE
c_id = ".$course_id." AND
lp_id = " . $this->get_id() . " AND
user_id = " . $this->get_user_id()." ".$session_condition;
// Ignore errors as some tables might not have the progress field just yet.
Database::query($sql);
$this->progress_db = $progress;
}
}
}

@ -3773,30 +3773,32 @@ class learnpathItem
if ($this->type == 'quiz' && $this->get_prevent_reinit() == 0 &&
$this->get_status() == 'completed'
) {
// We force the item to be restarted.
$this->restart();
$params = array(
"c_id" => $course_id,
"total_time" => $this->get_total_time(),
"start_time" => $this->current_start_time,
"score" => $this->get_score(),
"status" => $this->get_status(false),
"max_score" => $this->get_max(),
"lp_item_id" => $this->db_id,
"lp_view_id" => $this->view_id,
"view_count" => $this->get_attempt_id() ,
"suspend_data" => $this->current_data,
//"max_time_allowed" => ,
"lesson_location" => $this->lesson_location
);
if (self::debug > 2) {
error_log(
'learnpathItem::write_to_db() - Inserting into item_view forced: ' . print_r($params, 1),
0
if (!api_is_invitee_user()) {
// We force the item to be restarted.
$this->restart();
$params = array(
"c_id" => $course_id,
"total_time" => $this->get_total_time(),
"start_time" => $this->current_start_time,
"score" => $this->get_score(),
"status" => $this->get_status(false),
"max_score" => $this->get_max(),
"lp_item_id" => $this->db_id,
"lp_view_id" => $this->view_id,
"view_count" => $this->get_attempt_id() ,
"suspend_data" => $this->current_data,
//"max_time_allowed" => ,
"lesson_location" => $this->lesson_location
);
if (self::debug > 2) {
error_log(
'learnpathItem::write_to_db() - Inserting into item_view forced: ' . print_r($params, 1),
0
);
}
$this->db_item_view_id = Database::insert($item_view_table, $params);
$inserted = true;
}
$this->db_item_view_id = Database::insert($item_view_table, $params);
$inserted = true;
}
$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
@ -3816,45 +3818,49 @@ class learnpathItem
// Depending on what we want (really), we'll update or insert a new row
// now save into DB.
if (!$inserted && Database::num_rows($check_res) < 1) {
$params = array(
"c_id" => $course_id,
"total_time" => $this->get_total_time(),
"start_time" => $this->current_start_time,
"score" => $this->get_score(),
"status" => $this->get_status(false),
"max_score" => $this->get_max(),
"lp_item_id" => $this->db_id,
"lp_view_id" => $this->view_id,
"view_count" => $this->get_attempt_id() ,
"suspend_data" => $this->current_data,
//"max_time_allowed" => ,$this->get_max_time_allowed()
"lesson_location" => $this->lesson_location
);
if (self::debug > 2) {
error_log(
'learnpathItem::write_to_db() - Inserting into item_view forced: ' . print_r($params, 1),
0
if (!api_is_invitee_user()) {
$params = array(
"c_id" => $course_id,
"total_time" => $this->get_total_time(),
"start_time" => $this->current_start_time,
"score" => $this->get_score(),
"status" => $this->get_status(false),
"max_score" => $this->get_max(),
"lp_item_id" => $this->db_id,
"lp_view_id" => $this->view_id,
"view_count" => $this->get_attempt_id() ,
"suspend_data" => $this->current_data,
//"max_time_allowed" => ,$this->get_max_time_allowed()
"lesson_location" => $this->lesson_location
);
}
$this->db_item_view_id = Database::insert($item_view_table, $params);
if (self::debug > 2) {
error_log(
'learnpathItem::write_to_db() - Inserting into item_view forced: ' . print_r($params, 1),
0
);
}
$this->db_item_view_id = Database::insert($item_view_table, $params);
}
} else {
if ($this->type == 'hotpotatoes') {
$params = array(
'total_time' => $this->get_total_time(),
'start_time' => $this->get_current_start_time(),
'score' => $this->get_score(),
'status' => $this->get_status(false),
'max_score' => $this->get_max(),
'suspend_data' => $this->current_data,
'lesson_location' => $this->lesson_location
);
$where = array(
'c_id = ? AND lp_item_id = ? AND lp_view_id = ? AND view_count = ?' =>
array($course_id, $this->db_id, $this->view_id, $this->get_attempt_id())
);
Database::update($item_view_table, $params, $where);
if (!api_is_invitee_user()) {
$params = array(
'total_time' => $this->get_total_time(),
'start_time' => $this->get_current_start_time(),
'score' => $this->get_score(),
'status' => $this->get_status(false),
'max_score' => $this->get_max(),
'suspend_data' => $this->current_data,
'lesson_location' => $this->lesson_location
);
$where = array(
'c_id = ? AND lp_item_id = ? AND lp_view_id = ? AND view_count = ?' =>
array($course_id, $this->db_id, $this->view_id, $this->get_attempt_id())
);
Database::update($item_view_table, $params, $where);
}
} else {
// For all other content types...
if ($this->type == 'quiz') {
@ -3978,36 +3984,40 @@ class learnpathItem
}
if ($this->type == 'sco') {
//IF scorm scorm_update_time has already updated total_time in db
//" . //start_time = ".$this->get_current_start_time().", " . //scorm_init_time does it
////" max_time_allowed = '".$this->get_max_time_allowed()."'," .
$sql = "UPDATE $item_view_table SET
score = " . $this->get_score() . ",
$my_status
max_score = '" . $this->get_max() . "',
suspend_data = '" . Database::escape_string($this->current_data) . "',
lesson_location = '" . $this->lesson_location . "'
WHERE
c_id = $course_id AND
lp_item_id = " . $this->db_id . " AND
lp_view_id = " . $this->view_id . " AND
view_count = " . $this->get_attempt_id();
if (!api_is_invitee_user()) {
//IF scorm scorm_update_time has already updated total_time in db
//" . //start_time = ".$this->get_current_start_time().", " . //scorm_init_time does it
////" max_time_allowed = '".$this->get_max_time_allowed()."'," .
$sql = "UPDATE $item_view_table SET
score = " . $this->get_score() . ",
$my_status
max_score = '" . $this->get_max() . "',
suspend_data = '" . Database::escape_string($this->current_data) . "',
lesson_location = '" . $this->lesson_location . "'
WHERE
c_id = $course_id AND
lp_item_id = " . $this->db_id . "AND
lp_view_id = " . $this->view_id . " AND
view_count = " . $this->get_attempt_id();
}
} else {
//" max_time_allowed = '".$this->get_max_time_allowed()."'," .
$sql = "UPDATE $item_view_table SET
$total_time
start_time = " . $this->get_current_start_time() . ",
score = " . $this->get_score() . ",
$my_status
max_score = '" . $this->get_max() . "',
suspend_data = '" . Database::escape_string($this->current_data) . "',
lesson_location = '" . $this->lesson_location . "'
WHERE
c_id = $course_id AND
lp_item_id = " . $this->db_id . " AND
lp_view_id = " . $this->view_id . " AND
view_count = " . $this->get_attempt_id();
if (!api_is_invitee_user()) {
//" max_time_allowed = '".$this->get_max_time_allowed()."'," .
$sql = "UPDATE $item_view_table SET
$total_time
start_time = " . $this->get_current_start_time() . ",
score = " . $this->get_score() . ",
$my_status
max_score = '" . $this->get_max() . "',
suspend_data = '" . Database::escape_string($this->current_data) . "',
lesson_location = '" . $this->lesson_location . "'
WHERE
c_id = $course_id AND
lp_item_id = " . $this->db_id . " AND
lp_view_id = " . $this->view_id . " AND
view_count = " . $this->get_attempt_id();
}
}
$this->current_start_time = time();
}
@ -4017,7 +4027,9 @@ class learnpathItem
0
);
}
Database::query($sql);
if (!empty($sql)) {
Database::query($sql);
}
}
if (is_array($this->interactions) && count($this->interactions) > 0) {

@ -118,7 +118,9 @@ if (!empty($flat_list)) {
echo '<th width="300px">'.get_lang('AuthoringOptions')."</th>";
} else {
echo '<th width="50%">'.get_lang('Title').'</th>';
echo '<th>'.get_lang('Progress')."</th>";
if (!api_is_invitee_user()) {
echo '<th>'.get_lang('Progress')."</th>";
}
echo '<th>'.get_lang('Actions')."</th>";
}
echo '</tr>';
@ -226,17 +228,25 @@ if (!empty($flat_list)) {
$dsp_debug = '';
$dsp_order = '';
$progress = learnpath::getProgress(
$id,
$userId,
api_get_course_int_id(),
api_get_session_id()
);
$progress = 0;
if (!api_is_invitee_user()) {
$progress = learnpath::getProgress(
$id,
$userId,
api_get_course_int_id(),
api_get_session_id()
);
}
if ($is_allowed_to_edit) {
$dsp_progress = '<td><center>'.$progress.'</center></td>';
} else {
$dsp_progress = '<td>'.learnpath::get_progress_bar($progress, '%').'</td>';
$dsp_progress = "";
if (!api_is_invitee_user()) {
$dsp_progress = '<td>'.learnpath::get_progress_bar($progress, '%').'</td>';
}
}
$dsp_edit = '<td class="td_actions">';

@ -255,7 +255,7 @@ if (!empty($_REQUEST['exeId']) &&
LIMIT 1";
$res_last_attempt = Database::query($sql);
if (Database::num_rows($res_last_attempt)) {
if (Database::num_rows($res_last_attempt) && !api_is_invitee_user()) {
$row_last_attempt = Database::fetch_row($res_last_attempt);
$lp_item_view_id = $row_last_attempt[0];
$sql = "UPDATE $TBL_LP_ITEM_VIEW SET
@ -325,7 +325,10 @@ if (!empty ($lp_theme_css) && !empty ($mycourselptheme) && $mycourselptheme != -
$lp_theme_css = $my_style;
}
$progress_bar = $_SESSION['oLP']->getProgressBar();
$progress_bar = "";
if (!api_is_invitee_user()) {
$progress_bar = $_SESSION['oLP']->getProgressBar();
}
$navigation_bar = $_SESSION['oLP']->get_navigation_bar();
$mediaplayer = $_SESSION['oLP']->get_mediaplayer($autostart);

@ -20,8 +20,17 @@ require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php';
require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php';
require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.class.php';
// Only users who are logged in can proceed.
api_block_anonymous_users();
$session_id = isset($_GET['session_id']) ? intval($_GET['session_id']): null;
$sessionField = new ExtraFieldValue('session');
$valueAllowVisitors = $sessionField->get_values_by_handler_and_field_variable($session_id, 'allow_visitors');
$allowVisitors = $valueAllowVisitors != false;
if (!$allowVisitors) {
// Only users who are logged in can proceed.
api_block_anonymous_users();
}
$this_section = SECTION_COURSES;
$htmlHeadXtra[] = api_get_jqgrid_js();
@ -30,7 +39,6 @@ if (empty($_GET['session_id'])) {
api_not_allowed();
}
$session_id = isset($_GET['session_id']) ? intval($_GET['session_id']): null;
$course_id = isset($_GET['course_id']) ? intval($_GET['course_id']) : null;
$_SESSION['id_session'] = $session_id;
@ -45,7 +53,10 @@ $session_list = SessionManager::get_sessions_by_coach(api_get_user_id());
$course_list = SessionManager::get_course_list_by_session_id($session_id);
// Getting all sessions where I'm subscribed
$new_session_list = UserManager::get_personal_session_course_list(api_get_user_id());
$new_session_list = array();
if (!api_is_anonymous()) {
$new_session_list = UserManager::get_personal_session_course_list(api_get_user_id());
}
$user_course_list = array();
foreach ($new_session_list as $session_item) {
$user_course_list[] = $session_item['code'];
@ -109,7 +120,7 @@ $new_course_list = array();
if (!empty($course_list)) {
foreach ($course_list as $course_data) {
if (in_array($course_data['code'], $user_course_list)) {
if (in_array($course_data['code'], $user_course_list) || api_is_anonymous()) {
$course_data['title'] = Display::url(
$course_data['title'],
api_get_course_url($course_data['code'], $session_id)
@ -197,14 +208,14 @@ if (!empty($course_list)) {
// If the requested session does not exist in my list we stop the script
if (!api_is_platform_admin()) {
if (!in_array($session_id, $my_session_list)) {
if (!api_is_anonymous() && !in_array($session_id, $my_session_list)) {
api_not_allowed(true);
}
}
//If session is not active we stop de script
if (!api_is_allowed_to_session_edit()) {
//api_not_allowed();
api_not_allowed();
}
Display::display_header(get_lang('Session'));
@ -470,34 +481,35 @@ $extra_params_week['autowidth'] = 'true'; //use the width of the parent
$extra_params_week['height'] = '100%';
// MyQCM grid
$column_exercise = array(
get_lang('Status'),
get_lang('ExerciseStartDate'),
get_lang('Course'),
get_lang('Exercise'),
get_lang('Attempts'),
get_lang('Result'),
get_lang('BestResultInCourse'),
get_lang('Ranking')
);
$column_exercise_model = array(
array('name'=>'status', 'index'=>'status', 'width'=>'40', 'align'=>'left', 'sortable'=>'false'),
array('name'=>'date', 'index'=>'date', 'width'=>'130','align'=>'left', 'sortable'=>'true'),
array('name'=>'course', 'index'=>'course', 'width'=>'200','align'=>'left', 'sortable'=>'true', 'wrap_cell' => 'true'),
array('name'=>'exercise', 'index'=>'exercise', 'width'=>'200','align'=>'left', 'sortable'=>'false'),
array('name'=>'attempt', 'index'=>'attempt', 'width'=>'60', 'align'=>'center', 'sortable'=>'true'),
array('name'=>'result', 'index'=>'result', 'width'=>'120','align'=>'center', 'sortable'=>'true'),
array('name'=>'best_result','index'=>'best_result','width'=>'140','align'=>'center', 'sortable'=>'true'),
array('name'=>'position', 'index'=>'position', 'width'=>'55', 'align'=>'center', 'sortable'=>'true')
);
$extra_params_exercise['height'] = '100%';
$extra_params_exercise['autowidth'] = 'true';
//$extra_params_exercise['sortname'] = 'status';
//$extra_params_exercise['sortorder'] = 'desc';
//$extra_params_exercise['grouping'] = 'true';
//$extra_params_exercise['groupingView'] = array('groupField'=>array('course'),'groupColumnShow'=>'false','groupText' => array('<b>'.get_lang('Course').' {0}</b>'));
//$extra_params_exercise['groupingView'] = array('groupField'=>array('course'),'groupColumnShow'=>'false','groupText' => array('<b>'.get_lang('Course').' {0} - {1} Item(s)</b>'));
if (!api_is_anonymous()) {
$column_exercise = array(
get_lang('Status'),
get_lang('ExerciseStartDate'),
get_lang('Course'),
get_lang('Exercise'),
get_lang('Attempts'),
get_lang('Result'),
get_lang('BestResultInCourse'),
get_lang('Ranking')
);
$column_exercise_model = array(
array('name'=>'status', 'index'=>'status', 'width'=>'40', 'align'=>'left', 'sortable'=>'false'),
array('name'=>'date', 'index'=>'date', 'width'=>'130','align'=>'left', 'sortable'=>'true'),
array('name'=>'course', 'index'=>'course', 'width'=>'200','align'=>'left', 'sortable'=>'true', 'wrap_cell' => 'true'),
array('name'=>'exercise', 'index'=>'exercise', 'width'=>'200','align'=>'left', 'sortable'=>'false'),
array('name'=>'attempt', 'index'=>'attempt', 'width'=>'60', 'align'=>'center', 'sortable'=>'true'),
array('name'=>'result', 'index'=>'result', 'width'=>'120','align'=>'center', 'sortable'=>'true'),
array('name'=>'best_result','index'=>'best_result','width'=>'140','align'=>'center', 'sortable'=>'true'),
array('name'=>'position', 'index'=>'position', 'width'=>'55', 'align'=>'center', 'sortable'=>'true')
);
$extra_params_exercise['height'] = '100%';
$extra_params_exercise['autowidth'] = 'true';
//$extra_params_exercise['sortname'] = 'status';
//$extra_params_exercise['sortorder'] = 'desc';
//$extra_params_exercise['grouping'] = 'true';
//$extra_params_exercise['groupingView'] = array('groupField'=>array('course'),'groupColumnShow'=>'false','groupText' => array('<b>'.get_lang('Course').' {0}</b>'));
//$extra_params_exercise['groupingView'] = array('groupField'=>array('course'),'groupColumnShow'=>'false','groupText' => array('<b>'.get_lang('Course').' {0} - {1} Item(s)</b>'));
}
?>
<br />
<script>
@ -534,7 +546,10 @@ $(function() {
echo Display::grid_js('list_default', $url, $columns, $column_model,$extra_params,array(), '');
echo Display::grid_js('list_course', $url_by_course, $columns, $column_model,$extra_params_course,array(),'');
echo Display::grid_js('list_week', $url_week, $column_week, $column_week_model, $extra_params_week,array(),'');
echo Display::grid_js('exercises', '', $column_exercise, $column_exercise_model, $extra_params_exercise, $my_real_array);
if (!api_is_anonymous()) {
echo Display::grid_js('exercises', '', $column_exercise, $column_exercise_model, $extra_params_exercise, $my_real_array);
}
?>
// Generate tabs with jquery-ui
$('#tabs').tabs();
@ -545,22 +560,31 @@ $(function() {
<?php
$courseCode = isset($_GET['course']) ? $_GET['course'] : null;
$my_reporting = Tracking::show_user_progress(api_get_user_id(), $session_id, '#tabs-4', false, false);
if (!empty($my_reporting)) {
$my_reporting .= '<br />'.Tracking::show_course_detail(api_get_user_id(), $courseCode, $session_id);
}
if (empty($my_reporting)) {
$my_reporting = Display::return_message(get_lang('NoDataAvailable'), 'warning');
$my_reporting = '';
if (!api_is_anonymous()) {
$my_reporting = Tracking::show_user_progress(api_get_user_id(), $session_id, '#tabs-4', false, false);
if (!empty($my_reporting)) {
$my_reporting .= '<br />'.Tracking::show_course_detail(api_get_user_id(), $courseCode, $session_id);
}
if (empty($my_reporting)) {
$my_reporting = Display::return_message(get_lang('NoDataAvailable'), 'warning');
}
}
// Main headers
$headers = array(
get_lang('Courses'),
get_lang('LearningPaths'),
get_lang('MyQCM'),
get_lang('MyStatistics')
get_lang('LearningPaths')
);
if (!api_is_anonymous()) {
$headers[] = get_lang('MyQCM');
$headers[] = get_lang('MyStatistics');
}
// Sub headers
$sub_header = array(
get_lang('AllLearningPaths'),

@ -473,13 +473,20 @@ function processStudentList($filter_score, $global, $exercise, $courseInfo, $ses
if (empty($sessionId)) {
$students = CourseManager::get_student_list_from_course_code(
$courseInfo['code'],
false,
0,
null,
null,
false
);
} else {
$students = CourseManager::get_student_list_from_course_code(
$courseInfo['code'],
true,
$sessionId
$sessionId,
null,
null,
false
);
}

@ -48,7 +48,7 @@ allowOnlySubscribedUser($user_id, $work_id, $course_id);
$is_course_member = CourseManager::is_user_subscribed_in_real_or_linked_course($user_id, $course_code, $session_id);
$is_course_member = $is_course_member || api_is_platform_admin();
if ($is_course_member == false) {
if ($is_course_member == false || api_is_invitee_user()) {
api_not_allowed(true);
}

@ -2273,6 +2273,7 @@ function get_work_user_list(
$sql = " $select
FROM $work_condition $user_condition
WHERE $extra_conditions $where_condition $condition_session
AND u.status != " . INVITEE . "
ORDER BY $column $direction";
if (!empty($start) && !empty($limit)) {

@ -73,7 +73,7 @@ Display :: display_header(null);
echo '<div class="actions">';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'&origin='.$origin.'">'.Display::return_icon('back.png', get_lang('BackToWorksList'),'',ICON_SIZE_MEDIUM).'</a>';
if (api_is_allowed_to_session_edit(false, true) && !empty($workId)) {
if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !api_is_invitee_user() ) {
echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/upload.php?'.api_get_cidreq().'&id='.$workId.'&origin='.$origin.'">';
echo Display::return_icon('upload_file.png', get_lang('UploadADocument'), '', ICON_SIZE_MEDIUM).'</a>';
}
@ -112,48 +112,33 @@ $result = getWorkDateValidationStatus($work_data);
echo $result['message'];
$check_qualification = intval($my_folder_data['qualification']);
if (!empty($work_data['enable_qualification']) && !empty($check_qualification)) {
$type = 'simple';
if (!api_is_invitee_user()) {
if (!empty($work_data['enable_qualification']) && !empty($check_qualification)) {
$type = 'simple';
$columns = array(
get_lang('Type'),
get_lang('Title'),
get_lang('Qualification'),
get_lang('Date'),
get_lang('Status'),
get_lang('Actions')
);
$column_model = array(
array('name'=>'type', 'index'=>'file', 'width'=>'5', 'align'=>'left', 'search' => 'false', 'sortable' => 'false'),
array('name'=>'title', 'index'=>'title', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'wrap_cell' => 'true'),
array('name'=>'qualification', 'index'=>'qualification', 'width'=>'10', 'align'=>'left', 'search' => 'true'),
array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'30', 'align'=>'left', 'search' => 'true', 'wrap_cell' => 'true'),
array('name'=>'qualificator_id', 'index'=>'qualificator_id', 'width'=>'20', 'align'=>'left', 'search' => 'true'),
array('name'=>'actions', 'index'=>'actions', 'width'=>'20', 'align'=>'left', 'search' => 'false', 'sortable'=>'false')
);
} else {
$type = 'complex';
$columns = array(
get_lang('Type'),
get_lang('Title'),
get_lang('Date'),
get_lang('Actions')
);
$columns = array(
get_lang('Type'),
get_lang('Title'),
get_lang('Qualification'),
get_lang('Date'),
get_lang('Status'),
get_lang('Actions')
);
$column_model = array(
array('name'=>'type', 'index'=>'file', 'width'=>'5', 'align'=>'left', 'search' => 'false', 'sortable' => 'false'),
array('name'=>'title', 'index'=>'title', 'width'=>'60', 'align'=>'left', 'search' => 'false', 'wrap_cell' => "true"),
array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'30', 'align'=>'left', 'search' => 'true', 'wrap_cell' => 'true', 'sortable'=>'false'),
array('name'=>'actions', 'index'=>'actions', 'width'=>'20', 'align'=>'left', 'search' => 'false', 'sortable'=>'false')
);
$column_model = array(
array('name'=>'type', 'index'=>'file', 'width'=>'5', 'align'=>'left', 'search' => 'false', 'sortable' => 'false'),
array('name'=>'title', 'index'=>'title', 'width'=>'40', 'align'=>'left', 'search' => 'false', 'wrap_cell' => 'true'),
array('name'=>'qualification', 'index'=>'qualification', 'width'=>'10', 'align'=>'left', 'search' => 'true'),
array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'30', 'align'=>'left', 'search' => 'true', 'wrap_cell' => 'true'),
array('name'=>'qualificator_id', 'index'=>'qualificator_id', 'width'=>'20', 'align'=>'left', 'search' => 'true'),
array('name'=>'actions', 'index'=>'actions', 'width'=>'20', 'align'=>'left', 'search' => 'false', 'sortable'=>'false')
);
} else {
$type = 'complex';
if (ALLOW_USER_COMMENTS) {
$columns = array(
get_lang('Type'),
get_lang('Title'),
get_lang('Feedback'),
get_lang('Date'),
get_lang('Actions')
);
@ -161,29 +146,46 @@ if (!empty($work_data['enable_qualification']) && !empty($check_qualification))
$column_model = array(
array('name'=>'type', 'index'=>'file', 'width'=>'5', 'align'=>'left', 'search' => 'false', 'sortable' => 'false'),
array('name'=>'title', 'index'=>'title', 'width'=>'60', 'align'=>'left', 'search' => 'false', 'wrap_cell' => "true"),
array('name'=>'qualification', 'index'=>'qualification', 'width'=>'10', 'align'=>'left', 'search' => 'true'),
array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'30', 'align'=>'left', 'search' => 'true', 'wrap_cell' => 'true', 'sortable'=>'false'),
array('name'=>'actions', 'index'=>'actions', 'width'=>'20', 'align'=>'left', 'search' => 'false', 'sortable'=>'false')
);
if (ALLOW_USER_COMMENTS) {
$columns = array(
get_lang('Type'),
get_lang('Title'),
get_lang('Feedback'),
get_lang('Date'),
get_lang('Actions')
);
$column_model = array(
array('name'=>'type', 'index'=>'file', 'width'=>'5', 'align'=>'left', 'search' => 'false', 'sortable' => 'false'),
array('name'=>'title', 'index'=>'title', 'width'=>'60', 'align'=>'left', 'search' => 'false', 'wrap_cell' => "true"),
array('name'=>'qualification', 'index'=>'qualification', 'width'=>'10', 'align'=>'left', 'search' => 'true'),
array('name'=>'sent_date', 'index'=>'sent_date', 'width'=>'30', 'align'=>'left', 'search' => 'true', 'wrap_cell' => 'true', 'sortable'=>'false'),
array('name'=>'actions', 'index'=>'actions', 'width'=>'20', 'align'=>'left', 'search' => 'false', 'sortable'=>'false')
);
}
}
}
$extra_params = array(
'autowidth' => 'true',
'height' => 'auto',
'sortname' => 'firstname'
);
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_work_user_list&work_id='.$workId.'&type='.$type;
?>
<script>
$(function() {
<?php
echo Display::grid_js('results', $url, $columns, $column_model, $extra_params);
?>
});
</script>
<?php
echo Display::grid_html('results');
$extra_params = array(
'autowidth' => 'true',
'height' => 'auto',
'sortname' => 'firstname'
);
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_work_user_list&work_id='.$workId.'&type='.$type;
?>
<script>
$(function() {
<?php
echo Display::grid_js('results', $url, $columns, $column_model, $extra_params);
?>
});
</script>
<?php
echo Display::grid_html('results');
}
Display :: display_footer();

@ -0,0 +1,201 @@
<?php
/*
* This script insert session extra fields
*/
//exit;
require_once '../../main/inc/global.inc.php';
api_protect_admin_script();
$teachingHours = new ExtraField('session');
$teachingHours->save(array(
'field_type' => ExtraField::FIELD_TYPE_INTEGER,
'field_variable' => 'teaching_hours',
'field_display_text' => get_lang('TeachingHours'),
'field_visible' => 1,
'field_changeable' => 1
));
$cost = new ExtraField('session');
$cost->save(array(
'field_type' => ExtraField::FIELD_TYPE_FLOAT,
'field_variable' => 'cost',
'field_display_text' => get_lang('Cost'),
'field_visible' => 1,
'field_changeable' => 1
));
$vacancies = new ExtraField('session');
$vacancies->save(array(
'field_type' => ExtraField::FIELD_TYPE_INTEGER,
'field_variable' => 'vacancies',
'field_display_text' => get_lang('Vacancies'),
'field_visible' => 1,
'field_changeable' => 1
));
$recommendedNumberOfParticipants = new ExtraField('session');
$recommendedNumberOfParticipants->save(array(
'field_type' => ExtraField::FIELD_TYPE_INTEGER,
'field_variable' => 'recommended_number_of_participants',
'field_display_text' => get_lang('RecommendedNumberOfParticipants'),
'field_visible' => 1,
'field_changeable' => 1
));
$place = new ExtraField('session');
$place->save(array(
'field_type' => ExtraField::FIELD_TYPE_TEXT,
'field_variable' => 'place',
'field_display_text' => get_lang('Place'),
'field_visible' => 1,
'field_changeable' => 1
));
$schedule = new ExtraField('session');
$schedule->save(array(
'field_type' => ExtraField::FIELD_TYPE_TEXT,
'field_variable' => 'schedule',
'field_display_text' => get_lang('Schedule'),
'field_visible' => 1,
'field_changeable' => 1
));
$allowVisitors = new ExtraField('session');
$allowVisitors->save(array(
'field_type' => ExtraField::FIELD_TYPE_CHECKBOX,
'field_variable' => 'allow_visitors',
'field_display_text' => get_lang('AllowVisitors'),
'field_visible' => 1,
'field_changeable' => 1
));
$modeOptions = array(
get_lang('Online'),
get_lang('Presencial'),
get_lang('B-Learning')
);
$mode = new ExtraField('session');
$mode->save(array(
'field_type' => ExtraField::FIELD_TYPE_SELECT,
'field_variable' => 'mode',
'field_display_text' => get_lang('Mode'),
'field_visible' => 1,
'field_changeable' => 1,
'field_options' => implode('; ', $modeOptions)
));
$isInductionSession = new ExtraField('session');
$isInductionSession->save(array(
'field_type' => ExtraField::FIELD_TYPE_CHECKBOX,
'field_variable' => 'is_induccion_session',
'field_display_text' => get_lang('IsInductionSession'),
'field_visible' => 1,
'field_changeable' => 1
));
$isOpenSession = new ExtraField('session');
$isOpenSession->save(array(
'field_type' => ExtraField::FIELD_TYPE_CHECKBOX,
'field_variable' => 'is_open_session',
'field_display_text' => get_lang('IsOpenSession'),
'field_visible' => 1,
'field_changeable' => 1
));
$duration = new ExtraField('session');
$duration->save(array(
'field_type' => ExtraField::FIELD_TYPE_INTEGER,
'field_variable' => 'duration',
'field_display_text' => get_lang('Duration'),
'field_visible' => 1,
'field_changeable' => 1
));
$showStatusOptions = array(
get_lang('Open'),
get_lang('InProcess'),
get_lang('Closed')
);
$showStatus = new ExtraField('session');
$showStatus->save(array(
'field_type' => ExtraField::FIELD_TYPE_SELECT,
'field_variable' => 'show_status',
'field_display_text' => get_lang('ShowStatus'),
'field_visible' => 1,
'field_changeable' => 1,
'field_options' => implode('; ', $showStatusOptions)
));
$publicationStartDate = new ExtraField('session');
$publicationStartDate->save(array(
'field_type' => ExtraField::FIELD_TYPE_DATE,
'field_variable' => 'publication_start_date',
'field_display_text' => get_lang('PublicationStartDate'),
'field_visible' => 1,
'field_changeable' => 1
));
$publicationEndDate = new ExtraField('session');
$publicationEndDate->save(array(
'field_type' => ExtraField::FIELD_TYPE_DATE,
'field_variable' => 'publication_end_date',
'field_display_text' => get_lang('PublicationEndDate'),
'field_visible' => 1,
'field_changeable' => 1
));
$banner = new ExtraField('session');
$banner->save(array(
'field_type' => ExtraField::FIELD_TYPE_FILE_IMAGE,
'field_variable' => 'banner',
'field_display_text' => get_lang('SessionBanner'),
'field_visible' => 1,
'field_changeable' => 1
));
$brochure = new ExtraField('session');
$brochure->save(array(
'field_type' => ExtraField::FIELD_TYPE_FILE,
'field_variable' => 'brochure',
'field_display_text' => get_lang('Brochure'),
'field_visible' => 1,
'field_changeable' => 1
));
$targetOptions = array(
get_lang('Minedu'),
get_lang('Regiones')
);
$target = new ExtraField('session');
$target->save(array(
'field_type' => ExtraField::FIELD_TYPE_SELECT,
'field_variable' => 'target',
'field_display_text' => get_lang('Target'),
'field_visible' => 1,
'field_changeable' => 1,
'field_options' => implode('; ', $targetOptions)
));
$shortDescription = new ExtraField('session');
$shortDescription->save(array(
'field_type' => ExtraField::FIELD_TYPE_TEXT,
'field_variable' => 'short_description',
'field_display_text' => get_lang('ShortSescription'),
'field_visible' => 1,
'field_changeable' => 1
));
$id = new ExtraField('session');
$id->save(array(
'field_type' => ExtraField::FIELD_TYPE_TEXT,
'field_variable' => 'id',
'field_display_text' => get_lang('Id'),
'field_visible' => 1,
'field_changeable' => 1
));
Loading…
Cancel
Save