diff --git a/main/admin/configure_plugin.php b/main/admin/configure_plugin.php index c37aa3d788..1018550d2d 100644 --- a/main/admin/configure_plugin.php +++ b/main/admin/configure_plugin.php @@ -10,6 +10,9 @@ $language_file = array ('registration','admin'); $cidReset = true; require_once '../inc/global.inc.php'; +// Access restrictions +api_protect_admin_script(); + $plugin_name = $_GET['name']; $plugin_obj = new AppPlugin(); @@ -21,36 +24,41 @@ if (empty($plugin_info)) { $installed_plugins = $plugin_obj->get_installed_plugins(); + if (!in_array($plugin_name, $installed_plugins)) { api_not_allowed(); } global $_configuration; -$content = ''; +$content = null; if (isset($plugin_info['settings_form'])) { - $form = $plugin_info['settings_form']; + $form = $plugin_info['settings_form']; if (isset($form)) { //We override the form attributes $attributes = array('action'=>api_get_self().'?name='.$plugin_name, 'method'=>'POST'); - $form->updateAttributes($attributes); - $content = $form->toHtml(); + $form->updateAttributes($attributes); + $content = Display::page_header($plugin_info['title']); + $content .= $form->toHtml(); } +} else { + $message = Display::return_message(get_lang('NoConfigurationSettingsForThisPlugin'), 'warning'); } -if (isset($form) && $form->validate()) { - $values = $form->exportValues(); - //api_delete_category_settings_by_subkey($plugin_name); - $access_url_id = api_get_current_access_url_id(); - api_delete_settings_params(array('category = ? AND access_url = ? AND subkey = ? AND type = ? and variable <> ?' => - array('Plugins', $access_url_id, $plugin_name, 'setting', "status"))); - foreach ($values as $key => $value) { - $key = Database::escape_string($plugin_name.'_'.$key); - api_add_setting($value, $key, $plugin_name, 'setting', 'Plugins', $plugin_name, null, null, null, $_configuration['access_url'], 1); +if (isset($form)) { + if ($form->validate()) { + $values = $form->exportValues(); + //api_delete_category_settings_by_subkey($plugin_name); + $access_url_id = api_get_current_access_url_id(); + api_delete_settings_params(array('category = ? AND access_url = ? AND subkey = ? AND type = ? and variable <> ?' => + array('Plugins', $access_url_id, $plugin_name, 'setting', "status"))); + foreach ($values as $key => $value) { + $key = Database::escape_string($plugin_name.'_'.$key); + api_add_setting($value, $key, $plugin_name, 'setting', 'Plugins', $plugin_name, null, null, null, $_configuration['access_url'], 1); + } + $message = Display::return_message(get_lang('Updated'), 'success'); } -} else { - $content = Display::return_message(get_lang('NoConfigurationSettingsForThisPlugin'), 'warning'); } $tpl = new Template($tool_name); diff --git a/main/admin/resume_session.php b/main/admin/resume_session.php index a85c016b5b..1495302479 100644 --- a/main/admin/resume_session.php +++ b/main/admin/resume_session.php @@ -122,7 +122,7 @@ if (!empty($message)) { echo $message; } -echo Display::page_subheader(Display::return_icon('session.png', get_lang('Session')).' '.$session['name']); +echo Display::page_header(Display::return_icon('session.png', get_lang('Session')).' '.$session['name']); ?> diff --git a/main/admin/settings.lib.php b/main/admin/settings.lib.php index 8eab0eb7a6..85c4f37f61 100644 --- a/main/admin/settings.lib.php +++ b/main/admin/settings.lib.php @@ -49,7 +49,7 @@ function handle_regions() { /* We display all the possible plugins and the checkboxes */ $plugin_list = array(); - $my_plugin_list = $plugin_obj->get_plugin_blocks(); + $my_plugin_list = $plugin_obj->get_plugin_regions(); foreach($my_plugin_list as $plugin_item) { $plugin_list[$plugin_item] = $plugin_item; } @@ -60,15 +60,17 @@ function handle_regions() { if (file_exists($plugin_info_file)) { $plugin_info = array(); require $plugin_info_file; - echo ''; + if (isset($_GET['name']) && $_GET['name'] == $plugin) { + echo ''; + } else { + echo ''; + } echo ''; } } @@ -117,10 +119,9 @@ function handle_plugins() { echo get_lang('Description'); echo ''; echo ''; - $plugin_list = array(); - $my_plugin_list = $plugin_obj->get_plugin_blocks(); + $my_plugin_list = $plugin_obj->get_plugin_regions(); foreach($my_plugin_list as $plugin_item) { $plugin_list[$plugin_item] = $plugin_item; } @@ -131,7 +132,12 @@ function handle_plugins() { if (file_exists($plugin_info_file)) { $plugin_info = array(); require $plugin_info_file; - echo ''; + if (in_array($plugin, $installed_plugins)) { + echo ''; + } else { + echo ''; + } + //echo ''; echo '
'; echo '

'.$plugin_info['title'].' v'.$plugin_info['version'].'

'; echo '

'.$plugin_info['comment'].'

'; echo '
'; $selected_plugins = $plugin_obj->get_areas_by_plugin($plugin); - - echo Display::select('plugin_'.$plugin.'[]', $plugin_list, $selected_plugins, array('multiple' => 'multiple', 'style' => 'width:500px')); - + echo Display::select('plugin_'.$plugin.'[]', $plugin_list, $selected_plugins, array('multiple' => 'multiple', 'style' => 'width:500px')); echo '
'; //Checkbox if (in_array($plugin, $installed_plugins)) { @@ -149,6 +155,7 @@ function handle_plugins() { echo '
'; if (in_array($plugin, $installed_plugins)) { echo Display::url(get_lang('Configure'), 'configure_plugin.php?name='.$plugin, array('class' => 'btn')); + echo Display::url(get_lang('Regions'), 'settings.php?category=Regions&name='.$plugin, array('class' => 'btn')); } if (file_exists(api_get_path(SYS_PLUGIN_PATH).$plugin.'/readme.txt')) { diff --git a/main/admin/user_add.php b/main/admin/user_add.php index 3fc13c4b3a..b316683824 100644 --- a/main/admin/user_add.php +++ b/main/admin/user_add.php @@ -128,14 +128,24 @@ if (api_get_setting('login_is_email') != 'true') { // Password $group = array(); $auth_sources = 0; //make available wider as we need it in case of form reset (see below) +$nb_ext_auth_source_added = 0; if (count($extAuthSource) > 0) { - $group[] =& HTML_QuickForm::createElement('radio', 'password_auto', null, get_lang('ExternalAuthentication').' ', 2); $auth_sources = array(); foreach($extAuthSource as $key => $info) { - $auth_sources[$key] = $key; + // @todo : make uniform external authentification configuration (ex : cas and external_login ldap) + // Special case for CAS. CAS is activated from Chamilo > Administration > Configuration > CAS + // extAuthSource always on for CAS even if not activated + // same action for file user_edit.php + if (($key == CAS_AUTH_SOURCE && api_get_setting('cas_activate') === 'true') || ($key != CAS_AUTH_SOURCE)) { + $auth_sources[$key] = $key; + $nb_ext_auth_source_added++; + } } - $group[] =& HTML_QuickForm::createElement('select', 'auth_source', null, $auth_sources); - $group[] =& HTML_QuickForm::createElement('static', '', '', '
'); + if ($nb_ext_auth_source_added > 0) { + $group[] =& HTML_QuickForm::createElement('radio', 'password_auto', null, get_lang('ExternalAuthentication').' ', 2); + $group[] =& HTML_QuickForm::createElement('select', 'auth_source', null, $auth_sources); + $group[] =& HTML_QuickForm::createElement('static', '', '', '
'); + } } $group[] =& HTML_QuickForm::createElement('radio', 'password_auto', get_lang('Password'), get_lang('AutoGeneratePassword').'
', 1); $group[] =& HTML_QuickForm::createElement('radio', 'password_auto', 'id="radio_user_password"', null, 0); diff --git a/main/admin/user_edit.php b/main/admin/user_edit.php index bb98a4b915..93da341529 100644 --- a/main/admin/user_edit.php +++ b/main/admin/user_edit.php @@ -158,15 +158,26 @@ if (api_get_setting('login_is_email') != 'true') { // Password $form->addElement('radio', 'reset_password', get_lang('Password'), get_lang('DontResetPassword'), 0); +$nb_ext_auth_source_added = 0; if (count($extAuthSource) > 0) { - $group[] =& HTML_QuickForm::createElement('radio', 'reset_password', null, get_lang('ExternalAuthentication').' ', 3); $auth_sources = array(); foreach($extAuthSource as $key => $info) { - $auth_sources[$key] = $key; + // @todo : make uniform external authentification configuration (ex : cas and external_login ldap) + // Special case for CAS. CAS is activated from Chamilo > Administration > Configuration > CAS + // extAuthSource always on for CAS even if not activated + // same action for file user_add.php + if (($key == CAS_AUTH_SOURCE && api_get_setting('cas_activate') === 'true') || ($key != CAS_AUTH_SOURCE)) { + $auth_sources[$key] = $key; + $nb_ext_auth_source_added++; + } + } + if ($nb_ext_auth_source_added > 0) { + // @todo check the radio button for external authentification and select the external authentification in the menu + $group[] =& HTML_QuickForm::createElement('radio', 'reset_password', null, get_lang('ExternalAuthentication').' ', 3); + $group[] =& HTML_QuickForm::createElement('select', 'auth_source', null, $auth_sources); + $group[] =& HTML_QuickForm::createElement('static', '', '', '
'); + $form->addGroup($group, 'password', null, '', false); } - $group[] =& HTML_QuickForm::createElement('select', 'auth_source', null, $auth_sources); - $group[] =& HTML_QuickForm::createElement('static', '', '', '
'); - $form->addGroup($group, 'password', null, '', false); } $form->addElement('radio', 'reset_password', null, get_lang('AutoGeneratePassword'), 1); $group = array(); diff --git a/main/auth/cas/authcas.php b/main/auth/cas/authcas.php index d8b8fec339..19b34852b4 100644 --- a/main/auth/cas/authcas.php +++ b/main/auth/cas/authcas.php @@ -62,27 +62,41 @@ function cas_is_authenticated() default: $status=5; // Student }*/ - //If the user is in the dokeos database and we are ,not in a logout request, we upgrade his infomration by ldap - if (! $logout){ - $user_table = Database::get_main_table(TABLE_MAIN_USER); - $sql = "SELECT user_id, username, password, auth_source, active, expiration_date ". - "FROM $user_table ". - "WHERE username = '$login' "; - - $result = api_sql_query($sql,__FILE__,__LINE__); - if(mysql_num_rows($result) == 0) { - require_once(api_get_path(SYS_PATH).'main/inc/lib/usermanager.lib.php'); - $rnumber=rand(0,256000); - UserManager::create_user($firstName, $lastName, $status, $email, $login, md5('casplaceholder'.$rnumber), $official_code='',$language='',$phone='',$picture_uri='',$auth_source = PLATFORM_AUTH_SOURCE); - } - else { - $user = mysql_fetch_assoc($result); - $user_id = intval($user['user_id']); - //echo "deb : $status"; - UserManager::update_user ($user_id, $firstname, $lastname, $login, null, null, $email, $status, '', '', '', '', 1, null, 0, null,'') ; - - } - } + if (!$logout){ + // get user info from username + $tab_user_info = UserManager::get_user_info($login); + // user found in the chamilo database + if (is_array($tab_user_info)) { + // if option is on we can update user automatically from ldap server + return $login; + } + // user not found + else { + // if option is on we can add user automatically from ldap server + return false; + } + } +// //If the user is in the dokeos database and we are ,not in a logout request, we upgrade his infomration by ldap +// if (! $logout){ +// $user_table = Database::get_main_table(TABLE_MAIN_USER); +// $sql = "SELECT user_id, username, password, auth_source, active, expiration_date ". +// "FROM $user_table ". +// "WHERE username = '$login' "; +// +// $result = api_sql_query($sql,__FILE__,__LINE__); +// if(mysql_num_rows($result) == 0) { +// require_once(api_get_path(SYS_PATH).'main/inc/lib/usermanager.lib.php'); +// $rnumber=rand(0,256000); +// UserManager::create_user($firstName, $lastName, $status, $email, $login, md5('casplaceholder'.$rnumber), $official_code='',$language='',$phone='',$picture_uri='',$auth_source = PLATFORM_AUTH_SOURCE); +// } +// else { +// $user = mysql_fetch_assoc($result); +// $user_id = intval($user['user_id']); +// //echo "deb : $status"; +// UserManager::update_user ($user_id, $firstname, $lastname, $login, null, null, $email, $status, '', '', '', '', 1, null, 0, null,'') ; +// +// } +// } return($login); } else diff --git a/main/auth/cas/cas_var.inc.php b/main/auth/cas/cas_var.inc.php index d87bb62268..58388eb9e7 100644 --- a/main/auth/cas/cas_var.inc.php +++ b/main/auth/cas/cas_var.inc.php @@ -3,18 +3,19 @@ * In the future, these will be in the database */ require_once('lib/CAS.php'); -define("CAS_VERSION_2_0",'2.0'); -define("SAML_VERSION_1_1", 'S1'); global $cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri; $cas_auth_server = api_get_setting('cas_server'); $cas_auth_uri = api_get_setting('cas_server_uri'); $cas_auth_port = intval(api_get_setting('cas_port')); +switch (api_get_setting('cas_protocol')) { + case 'CAS1': $cas_auth_ver = CAS_VERSION_1_0; break; + case 'CAS2': $cas_auth_ver = CAS_VERSION_2_0; break; + case 'SAML': $cas_auth_ver = SAML_VERSION_1_1; break; + default : $cas_auth_ver = CAS_VERSION_2_0; break; +} $cas_auth_uri = api_get_setting('cas_server_uri'); if ( ! is_string($cas_auth_uri)) $cas_auth_uri = ''; - -$cas_auth_ver = '2.0'; -//$cas_auth_ver = SAML_VERSION_1_1; ?> diff --git a/main/auth/cas/logincas.php b/main/auth/cas/logincas.php index 118abdba20..24672bf0e0 100644 --- a/main/auth/cas/logincas.php +++ b/main/auth/cas/logincas.php @@ -21,5 +21,4 @@ if (!is_object($PHPCAS_CLIENT) ) { phpCAS::setNoCasServerValidation(); } phpCAS::forceAuthentication(); -//echo 'ici'; header('Location: '.api_get_path(WEB_PATH).api_get_setting('page_after_login')); diff --git a/main/course_info/delete_course.php b/main/course_info/delete_course.php old mode 100755 new mode 100644 index d5540c6172..a1ef0d8e67 --- a/main/course_info/delete_course.php +++ b/main/course_info/delete_course.php @@ -15,7 +15,6 @@ $language_file = array('admin', 'course_info'); require_once '../inc/global.inc.php'; -require_once api_get_path(LIBRARY_PATH).'course.lib.php'; require_once '../gradebook/lib/be/gradebookitem.class.php'; require_once '../gradebook/lib/be/category.class.php'; $this_section = SECTION_COURSES; @@ -29,9 +28,7 @@ if (!api_is_allowed_to_edit()) { $tool_name = get_lang('DelCourse'); if (isset($_GET['delete']) && $_GET['delete'] == 'yes') { - CourseManager :: delete_course($_course['sysCode']); - $obj_cat = new Category(); $obj_cat->update_category_delete($_course['sysCode']); @@ -39,15 +36,17 @@ if (isset($_GET['delete']) && $_GET['delete'] == 'yes') { unset($_course); unset($_cid); $noPHP_SELF = true; - $message = get_lang('Course').' "'.$current_course_name.'" ('.$current_course_code.') '.get_lang('HasDel'); + $message = '

'.get_lang('Course').' : '.$current_course_name.' ('.$current_course_code.')

'; + $message .=get_lang('HasDel'); $message .= '

'.get_lang('BackHome').' '.api_get_setting('siteName').''; -} else { - $message = '"'.$current_course_name.'" ('.$current_course_code.')

'.get_lang('ByDel').'

'.get_lang('No').'  |  '.get_lang('Yes').'

'; +} else { + $message = '

'.get_lang('Course').' : '.$current_course_name.' ('.$current_course_code.')

'; + $message .= '

'.get_lang('ByDel').'

'.get_lang('No').' '.get_lang('Yes').'

'; $interbreadcrumb[] = array('url' => 'maintenance.php', 'name' => get_lang('Maintenance')); } Display :: display_header($tool_name, 'Settings'); -api_display_tool_title($tool_name); +echo Display::page_header($tool_name); Display::display_warning_message($message, false); /* FOOTER */ diff --git a/main/course_info/maintenance.php b/main/course_info/maintenance.php old mode 100755 new mode 100644 index 77c6b1cb98..c1379d4c1c --- a/main/course_info/maintenance.php +++ b/main/course_info/maintenance.php @@ -16,7 +16,7 @@ $this_section = SECTION_COURSES; $nameTools = get_lang('Maintenance'); api_block_anonymous_users(); Display :: display_header($nameTools); -api_display_tool_title($nameTools); +echo Display::page_header($nameTools); ?> diff --git a/main/coursecopy/classes/CourseRestorer.class.php b/main/coursecopy/classes/CourseRestorer.class.php index b974382247..d7944e3258 100644 --- a/main/coursecopy/classes/CourseRestorer.class.php +++ b/main/coursecopy/classes/CourseRestorer.class.php @@ -1135,7 +1135,7 @@ class CourseRestorer $new_id=0; - if(is_object($question)) { + if (is_object($question)) { if ($question->is_restored()) { return $question->destination_id; } @@ -1158,8 +1158,7 @@ class CourseRestorer extra='".self::DBUTF8escapestring($question->extra)."'"; Database::query($sql); $new_id = Database::insert_id(); - - + if ($question->quiz_type == MATCHING) { // for answer type matching $answerid = 0; $t = array(); @@ -1167,8 +1166,7 @@ class CourseRestorer $t[$answer['position']] = $answer; } foreach ($t as $index => $answer) { - $sql = "INSERT INTO ".$table_ans." SET c_id = ".$this->destination_course_id." , id= '".$index."',question_id = '".$new_id."', answer = '".self::DBUTF8escapestring($answer['answer'])."', correct = '".$answer['correct']."', comment = '".self::DBUTF8escapestring($answer['comment'])."', ponderation='".$answer['ponderation']."', position = '".$answer['position']."', hotspot_coordinates = '".$answer['hotspot_coordinates']."', hotspot_type = '".$answer['hotspot_type']."'"; - + $sql = "INSERT INTO ".$table_ans." SET c_id = ".$this->destination_course_id." , id= '".$index."',question_id = '".$new_id."', answer = '".self::DBUTF8escapestring($answer['answer'])."', correct = '".$answer['correct']."', comment = '".self::DBUTF8escapestring($answer['comment'])."', ponderation='".$answer['ponderation']."', position = '".$answer['position']."', hotspot_coordinates = '".$answer['hotspot_coordinates']."', hotspot_type = '".$answer['hotspot_type']."'"; Database::query($sql); } } else { @@ -1193,13 +1191,14 @@ class CourseRestorer $old_id = $item['id']; unset($item['id']); $item['question_id'] = $new_id; + $item['c_id'] = $this->destination_course_id; $question_option_id = Database::insert($table_options, $item); $old_option_ids[$old_id] = $question_option_id; - } - $new_answers = Database::select('id, correct', $table_ans, array('WHERE' => array('question_id = ? AND c_id = ? '=>array($new_id, $this->destination_course_id)))); + } + $new_answers = Database::select('id, correct', $table_ans, array('WHERE' => array('question_id = ? AND c_id = ? '=>array($new_id, $this->destination_course_id)))); foreach ($new_answers as $answer_item) { $params['correct'] = $old_option_ids[$answer_item['correct']]; - $question_option_id = Database::update($table_ans, $params, array('id = ?'=>$answer_item['id'])); + $question_option_id = Database::update($table_ans, $params, array('id = ? AND c_id = ? '=> array($answer_item['id'], $this->destination_course_id))); } } $this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id; @@ -1291,11 +1290,9 @@ class CourseRestorer $this->course->resources[RESOURCE_SURVEY][$id]->destination_id = $new_id; foreach ($survey->question_ids as $index => $question_id) { $qid = $this->restore_survey_question($question_id, $new_id); - $sql = "UPDATE ".$table_que." " . - "SET survey_id = ".$new_id." WHERE c_id = ".$this->destination_course_id." AND question_id = $qid"; + $sql = "UPDATE ".$table_que." SET survey_id = ".$new_id." WHERE c_id = ".$this->destination_course_id." AND question_id = $qid"; Database::query($sql); - $sql = "UPDATE ".$table_ans." ". - "SET survey_id = ".$new_id." WHERE c_id = ".$this->destination_course_id." AND question_id = $qid"; + $sql = "UPDATE ".$table_ans." SET survey_id = ".$new_id." WHERE c_id = ".$this->destination_course_id." AND question_id = $qid"; Database::query($sql); } diff --git a/main/coursecopy/copy_course.php b/main/coursecopy/copy_course.php index e829b59001..e656d0308f 100644 --- a/main/coursecopy/copy_course.php +++ b/main/coursecopy/copy_course.php @@ -77,40 +77,31 @@ if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form') || (is if (Database::num_rows($res) == 0) { Display::display_normal_message(get_lang('NoDestinationCoursesAvailable')); } else { -?> -
-'; - while ($obj = Database::fetch_object($res)) { - echo ''; - } - echo ''; -?> -
-
- - -
- - -
-
- -
- - -
- - -
- - -
-
- -
-code] = $obj->title; + } + + $form = new FormValidator('copy_course', 'post', 'copy_course.php'); + $form->addElement('header','' ); + $form->addElement('select','destination_course', get_lang('SelectDestinationCourse'), $options); + + $group = array(); + $group[] = $form->createElement('radio', 'copy_option', null, get_lang('FullCopy'), 'full_copy'); + $group[] = $form->createElement('radio', 'copy_option', null, get_lang('LetMeSelectItems'), 'select_items'); + $form->addGroup($group, '', get_lang('SelectOptionForBackup')); + + $group = array(); + $group[] = $form->createElement('radio', 'same_file_name_option', null, get_lang('SameFilenameSkip'), FILE_SKIP); + $group[] = $form->createElement('radio', 'same_file_name_option', null, get_lang('SameFilenameRename'), FILE_RENAME); + $group[] = $form->createElement('radio', 'same_file_name_option', null, get_lang('SameFilenameOverwrite'), FILE_OVERWRITE); + $form->addGroup($group, '', get_lang('SameFilename')); + + $form->addElement('style_submit_button', 'submit', get_lang('CopyCourse'),'class="save"'); + + $form->setDefaults(array('copy_option' =>'select_items','same_file_name_option' => FILE_OVERWRITE)); + $form->display(); + } } diff --git a/main/coursecopy/create_backup.php b/main/coursecopy/create_backup.php old mode 100755 new mode 100644 index 733926144e..b54abae94e --- a/main/coursecopy/create_backup.php +++ b/main/coursecopy/create_backup.php @@ -44,7 +44,7 @@ require_once 'classes/CourseRestorer.class.php'; require_once 'classes/CourseSelectForm.class.php'; // Display the tool title -api_display_tool_title($nameTools); +echo Display::page_header($nameTools); /* MAIN CODE */ @@ -57,38 +57,25 @@ if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form') || (is } $zip_file = CourseArchiver :: write_course($course); Display::display_confirmation_message(get_lang('BackupCreated')); - echo '
'.get_lang('Download').''; - -?> - -'.get_lang('Download').''; } elseif (isset($_POST['backup_option']) && $_POST['backup_option'] == 'select_items') { $cb = new CourseBuilder('partial'); - $course = $cb->build(); - + $course = $cb->build(); CourseSelectForm :: display_form($course); } else { $cb = new CourseBuilder(); $course = $cb->build(); if (!$course->has_resources()) { echo get_lang('NoResourcesToBackup'); - } else { - echo ''.get_lang('SelectOptionForBackup').'

'; - - require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'; + } else { + $form = new FormValidator('create_backup_form', 'post'); - $renderer = $form->defaultRenderer(); - $renderer->setElementTemplate('
{element}
'); + $form->addElement('header',get_lang('SelectOptionForBackup')); + $form->addElement('radio', 'backup_option', '', get_lang('CreateFullBackup'), 'full_backup'); $form->addElement('radio', 'backup_option', '', get_lang('LetMeSelectItems'), 'select_items'); - $form->addElement('html', '
'); + $form->addElement('style_submit_button', null, get_lang('CreateBackup'), 'class="save"'); $form->add_progress_bar(); diff --git a/main/coursecopy/recycle_course.php b/main/coursecopy/recycle_course.php old mode 100755 new mode 100644 index 45864c5b64..2a81f2da72 --- a/main/coursecopy/recycle_course.php +++ b/main/coursecopy/recycle_course.php @@ -37,7 +37,7 @@ require_once 'classes/CourseRecycler.class.php'; require_once 'classes/CourseSelectForm.class.php'; // Display the tool title -api_display_tool_title($nameTools); +echo Display::page_header($nameTools); /* MAIN CODE */ @@ -62,18 +62,17 @@ if ((isset($_POST['action']) && $_POST['action'] == 'course_select_form') || (is echo get_lang('NoResourcesToRecycle'); } else { Display::display_warning_message(get_lang('RecycleWarning'), false); -?> -
- - -
- - -
-
- -
-addElement('header',get_lang('SelectOptionForBackup')); + + $form->addElement('radio', 'recycle_option', null, get_lang('FullRecycle'), 'full_backup'); + $form->addElement('radio', 'recycle_option', null, get_lang('LetMeSelectItems'), 'select_items'); + + $form->addElement('style_submit_button', 'submit', get_lang('RecycleCourse'), 'class="save"'); + $form->setDefaults(array('recycle_option' => 'select_items')); + $form->display(); } } diff --git a/main/css/base.css b/main/css/base.css index 0bf9d9a194..5bc26073a0 100644 --- a/main/css/base.css +++ b/main/css/base.css @@ -19,7 +19,7 @@ select { visibility: visible; } -.label { +form .label { padding: 1px 3px 2px; font-size: 100%; font-weight: normal; @@ -71,12 +71,12 @@ label, input, button, select, textarea, p { form .label { color: #404040; - float: left; - font-size: 13px; + float: left; line-height: 18px; padding-top: 6px; text-align: right; width: 150px; + text-shadow:none; } form .formw { margin-left: 170px; @@ -98,7 +98,7 @@ form .formw input { /* New changes Chamilo 1.9 */ .sidebar-nav { - padding: 20px 0px 0px 20px; + padding: 20px 20px 10px 20px } .well_border { @@ -115,10 +115,13 @@ form .formw input { height:26px; } -#lp_navigation_elem .buttons, -#lp_navigation_elem #progress_bar { - width:130px; - margin:0px 0px 10px 15px; +#lp_navigation_elem .buttons{ + margin-bottom: 5px; +} + +#lp_navigation_elem { + padding-left: 15px; + width: 110px; } * { @@ -793,10 +796,7 @@ button { -opera-shadow: 2px 2px 1px rgba(0, 0, 0, 0.5); -webkit-shadow: 2px 2px 1px rgba(0, 0, 0, 0.5); - box-shadow: 2px 2px 1px rgba(0, 0, 0, 0.5); - - font-weight:bold; - font-size: 105%; + box-shadow: 2px 2px 1px rgba(0, 0, 0, 0.5); } button:hover { @@ -2165,23 +2165,6 @@ div.lp_resource { padding:5px; } -/*LP changes -.lp_resource_element img { - float: left; - margin-bottom: 0; - margin-left: 43px; - margin-right: 43px; - margin-top: 7px; -} -.lp_resource_element a { - float: left; - margin-bottom: 12px; - margin-left: 33px; - margin-right: auto; - margin-top: 15px; - width: 100%; -}*/ - .doc_resource { margin:6px; } @@ -2190,7 +2173,6 @@ div.lp_tree { height: 100%; overflow: auto; padding: 3px 10px 3px 0; - width: 230px; } table.lp_build td.tree { @@ -3209,9 +3191,7 @@ a:active{ } .homepage_notice { - width:90%; - margin-left: 14px; - margin-bottom: 10px; + } .welcome_course li { @@ -3573,3 +3553,22 @@ a.forum_group_link { #online_grid_container .thumbnail .caption { height: 30px; } + +#hide_bar_template { + width: 10px; + display: inline; + float:left; + height: 100%; + padding-bottom: 90em; + margin-bottom: -90em; + cursor:pointer; + background-color:#eee; + margin-left: 0px !important; + background-image: url("../img/hide0.png"); + background-repeat: no-repeat; + background-position: center center; +} + +#hide_bar_template:hover { + background-color:#aaa; +} \ No newline at end of file diff --git a/main/css/base_chamilo.css b/main/css/base_chamilo.css index 458251fd38..1591bcab1c 100755 --- a/main/css/base_chamilo.css +++ b/main/css/base_chamilo.css @@ -67,7 +67,7 @@ ul#navigation { position: fixed; margin: 0px; padding: 0px; - top: 78px; + top: 200px; right: -10px; list-style: none; z-index:9999; @@ -365,9 +365,6 @@ footer a:link, footer a:visited { font-weight: bold; padding-left: 12px; } -.menusection { - width:100%; -} .menusectioncaption { background-color: #8A8A8A; color: #FFFFFF; @@ -379,7 +376,7 @@ footer a:link, footer a:visited { display:block; } .menulist { - margin: 0 20px; + margin: 0px; list-style: none; padding: 0; list-style-image:none; @@ -882,8 +879,7 @@ div.admin_section h4 { .sectioncomment { color: #000000; margin: 5px 5px 5px 0px; - padding: 5px; - font-size: 11px; + padding: 5px; } .sectionvalue { list-style-type: none; @@ -1694,16 +1690,12 @@ span.radio { * BUTTONS * *****************************************************/ button { - margin:2px 5px 3px 3px !important; + /* margin:2px 5px 3px 3px; */ background-color: #F5F5F5; - border-width: 0px; border-color:#EEEEEE #DEDEDE #DEDEDE #EEEEEE; border-style:solid; - border-width:1px; - - font-family: bold arial, verdana, helvetica, sans-serif; - font-size: 100%; + border-width:1px; line-height :130%; text-decoration: none; color: black; diff --git a/main/document/document.php b/main/document/document.php index c593f70e74..5344f2e8e3 100644 --- a/main/document/document.php +++ b/main/document/document.php @@ -145,18 +145,7 @@ switch ($action) { $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id()); // Check whether the document is in the database if (empty($document_data)) { - // File not found! - header('HTTP/1.0 404 Not Found'); - $error404 = ''; - $error404 .= ''; - $error404 .= '404 Not Found'; - $error404 .= ''; - $error404 .= '

Not Found

'; - $error404 .= '

The requested URL was not found on this server.

'; - $error404 .= '
'; - $error404 .= ''; - echo $error404; - exit; + api_not_allowed(); } // Launch event event_download($document_data['url']); @@ -233,11 +222,9 @@ switch ($action) { if (!copy($file, $copyfile)) { $message = Display::return_message(get_lang('CopyFailed'), 'error'); } else { - $message = Display::return_message(get_lang('CopyMade').' '.$file_link, 'confirmation', false); - + $message = Display::return_message(get_lang('CopyMade').' '.$file_link, 'confirmation', false); /*$doc_id = add_document($_course, $copyfile , 'file', filesize($copyfile), $document_info['title']); - api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], null, null, null, null, $session_id);*/ - + api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], null, null, null, null, $session_id);*/ } } } @@ -480,7 +467,6 @@ $htmlHeadXtra[] = ''; //$htmlHeadXtra[] = ''; - $mediaplayer_path = api_get_path(WEB_LIBRARY_PATH).'mediaplayer/player.swf'; //automatic loading the course language for yoxview @@ -518,7 +504,7 @@ foreach ($docs_and_folders as $file) { //errorAlerts: true, //warningAlerts: true, swfPath: "'.$js_path.'jquery-jplayer", - supplied: "m4a, oga, mp3, ogg, wav", + //supplied: "m4a, oga, mp3, ogg, wav", wmode: "window", //solution: "flash, html", // Do not change this setting otherwise cssSelectorAncestor: "#jp_container_'.$count.'", diff --git a/main/exercice/exercise.class.php b/main/exercice/exercise.class.php index 7df0f976bb..6b39f60214 100644 --- a/main/exercice/exercise.class.php +++ b/main/exercice/exercise.class.php @@ -1587,7 +1587,7 @@ class Exercise { if ($this->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT && $this->type == ONE_PER_PAGE) { $html .=''; - $html .= get_lang('ValidateAnswer').''; + $html .= get_lang('EndTest').''; $html .='
'; } else { //User @@ -1597,8 +1597,8 @@ class Exercise { $label = get_lang('ReviewQuestions'); $class = 'btn btn-primary'; } else { - $label = get_lang('ValidateAnswers'); - $class = 'btn btn-sucess'; + $label = get_lang('EndTest'); + $class = 'btn btn-success'; } } else { $label = get_lang('NextQuestion'); @@ -1620,8 +1620,8 @@ class Exercise { $all_label = get_lang('ReviewQuestions'); $class = 'btn btn-primary'; } else { - $all_label = get_lang('ValidateAnswers'); - $class = 'btn btn-sucess'; + $all_label = get_lang('EndTest'); + $class = 'btn btn-success'; } $all_button = ' '.$all_label.''; $all_button .= ' '; @@ -2274,7 +2274,7 @@ class Exercise { // for matching case MATCHING : if ($from_database) { - $sql_answer = 'SELECT id, answer FROM '.$table_ans.' WHERE question_id="'.$questionId.'" AND correct=0'; + $sql_answer = 'SELECT id, answer FROM '.$table_ans.' WHERE c_id = '.$course_id.' AND question_id="'.$questionId.'" AND correct=0'; $res_answer = Database::query($sql_answer); // getting the real answer $real_list =array(); @@ -2282,7 +2282,7 @@ class Exercise { $real_list[$real_answer['id']]= $real_answer['answer']; } $sql_select_answer = 'SELECT id, answer, correct, id_auto FROM '.$table_ans.' - WHERE question_id="'.$questionId.'" AND correct <> 0 ORDER BY id_auto'; + WHERE c_id = '.$course_id.' AND question_id="'.$questionId.'" AND correct <> 0 ORDER BY id_auto'; $res_answers = Database::query($sql_select_answer); $questionScore = 0; @@ -2980,8 +2980,7 @@ class Exercise { if ($answerType == HOT_SPOT || $answerType == HOT_SPOT_ORDER) { // We made an extra table for the answers - if ($show_result) { - + if ($show_result) { if ($origin != 'learnpath') { echo '
'; echo ' @@ -2992,24 +2991,20 @@ class Exercise { '; echo ' - '; - + '; } } } if ($origin != 'learnpath') { if ($show_result) { - echo ''; - //if ($this->type == ALL_ON_ONE_PAGE) { + echo ''; echo '
'; if ($propagate_neg == 0 && $questionScore < 0) { $questionScore = 0; } echo get_lang('Score').": ".show_score($questionScore, $questionWeighting, false, false); echo '
'; - //} - echo '
'; } } } diff --git a/main/exercice/exercise.lib.php b/main/exercice/exercise.lib.php index a6b5829150..abcf450980 100644 --- a/main/exercice/exercise.lib.php +++ b/main/exercice/exercise.lib.php @@ -1130,9 +1130,9 @@ function get_exam_results_data($from, $number_of_items, $column, $direction, $ex } if ($revised) { - $revised = Display::span(get_lang('Validated'), array('class'=>'label_tag success')); + $revised = Display::label(get_lang('Validated'), 'success'); } else { - $revised = Display::span(get_lang('NotValidated'), array('class'=>'label_tag notice')); + $revised = Display::label(get_lang('NotValidated'), 'info'); } if ($is_allowedToEdit || $is_tutor) { diff --git a/main/exercice/exercise_reminder.php b/main/exercice/exercise_reminder.php index c600dc2723..978cb06add 100644 --- a/main/exercice/exercise_reminder.php +++ b/main/exercice/exercise_reminder.php @@ -232,7 +232,7 @@ foreach ($question_list as $questionId) { echo Display::div($table, array('class'=>'span10')); -$exercise_actions = Display::url(get_lang('ValidateAnswers'), 'javascript://', array('onclick'=>'final_submit();', 'class'=>'btn btn-success')); +$exercise_actions = Display::url(get_lang('EndTest'), 'javascript://', array('onclick'=>'final_submit();', 'class'=>'btn btn-success')); $exercise_actions .= ' '.Display::url(get_lang('ReviewQuestions'), 'javascript://', array('onclick'=>'review_questions();','class'=>'btn')); echo Display::div('', array('class'=>'clear')); diff --git a/main/exercice/exercise_result.php b/main/exercice/exercise_result.php index 27795d5958..f6fde7f486 100644 --- a/main/exercice/exercise_result.php +++ b/main/exercice/exercise_result.php @@ -204,8 +204,7 @@ if ($origin != 'learnpath') { } echo show_score($total_score, $total_weight, false, true, true, $objExercise->selectPassPercentage()); echo ''; - } - /* */ + } } // Tracking of results diff --git a/main/exercice/exercise_show.php b/main/exercice/exercise_show.php index 7f675cb908..a28dda611f 100644 --- a/main/exercice/exercise_show.php +++ b/main/exercice/exercise_show.php @@ -607,7 +607,7 @@ if ($origin!='learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) if ($objExercise->selectPropagateNeg() == 0 && $my_total_score_temp < 0) { $my_total_score_temp = 0; } - echo show_score($my_total_score_temp, $totalWeighting, false); + echo show_score($my_total_score_temp, $totalWeighting, false); echo ''; } } diff --git a/main/exercice/multiple_answer_combination.class.php b/main/exercice/multiple_answer_combination.class.php index 365f0d9991..376ddd2d86 100644 --- a/main/exercice/multiple_answer_combination.class.php +++ b/main/exercice/multiple_answer_combination.class.php @@ -134,14 +134,10 @@ class MultipleAnswerCombination extends Question { $form -> add_multiple_required_rule ($boxes_names , get_lang('ChooseAtLeastOneCheckbox') , 'multiple_required'); - - $html_total_score ='
'.get_lang('Score').'
'; - $form -> addElement ('html', $html_total_score); - + //only 1 answer the all deal ... - $form->addElement('text', 'weighting[1]',null, array('class' => "span1", 'value' => '10')); - $form -> addElement ('html', '
'); - + $form->addElement('text', 'weighting[1]', get_lang('Score'), array('class' => "span1", 'value' => '10')); + $navigator_info = api_get_navigator(); global $text, $class, $show_quiz_edition; //ie6 fix @@ -150,12 +146,12 @@ class MultipleAnswerCombination extends Question { $form->addElement('submit', 'lessAnswers', get_lang('LessAnswer'),'class="minus"'); $form->addElement('submit', 'moreAnswers', get_lang('PlusAnswer'),'class="plus"'); - $form->addElement('submit','submitQuestion',$text, 'class="'.$class.'"'); + $form->addElement('submit', 'submitQuestion', $text, 'class="'.$class.'"'); } else { $form->addElement('style_submit_button', 'lessAnswers', get_lang('LessAnswer'),'class="minus"'); $form->addElement('style_submit_button', 'moreAnswers', get_lang('PlusAnswer'),'class="plus"'); - $form->addElement('style_submit_button','submitQuestion',$text, 'class="'.$class.'"'); + $form->addElement('style_submit_button', 'submitQuestion',$text, 'class="'.$class.'"'); // setting the save button here and not in the question class.php diff --git a/main/exercice/overview.php b/main/exercice/overview.php index 0481863d40..f1cc59d69f 100644 --- a/main/exercice/overview.php +++ b/main/exercice/overview.php @@ -80,18 +80,19 @@ if (isset($_GET['preview'])) { $extra_params = '&preview=1'; } +$exercise_stat_info = $objExercise->get_stat_track_exercise_info($learnpath_id, $learnpath_item_id, 0); +$attempt_list = null; +if (isset($exercise_stat_info['exe_id'])) { + $attempt_list = get_all_exercise_event_by_exe_id($exercise_stat_info['exe_id']); +} + //Exercise button //Notice we not add there the lp_item_view__id because is not already generated $exercise_url = api_get_path(WEB_CODE_PATH).'exercice/exercise_submit.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'&origin='.$origin.'&learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.$extra_params; $label = get_lang('StartTest'); -if ($time_control && !empty($clock_expired_time)) { +if ($time_control && !empty($clock_expired_time) || !empty($attempt_list)) { $label = get_lang('ContinueTest'); } -$exercise_stat_info = $objExercise->get_stat_track_exercise_info($learnpath_id, $learnpath_item_id, 0); -$attempt_list = null; -if (isset($exercise_stat_info['exe_id'])) { - $attempt_list = get_all_exercise_event_by_exe_id($exercise_stat_info['exe_id']); -} $exercise_url_button = Display::url($label, $exercise_url, array('class'=>'btn btn-primary btn-large')); @@ -102,7 +103,6 @@ if ($visible_return['value'] == false) { $exercise_url_button = $visible_return['message']; } - //Message "you already try this exercise" $message = ''; @@ -126,17 +126,17 @@ $table_content = ''; if (!empty($attempts)) { $i = $counter; - foreach ($attempts as $attempt_result) { + foreach ($attempts as $attempt_result) { $score = show_score($attempt_result['exe_result'], $attempt_result['exe_weighting']); $attempt_url = api_get_path(WEB_CODE_PATH).'exercice/result.php?'.api_get_cidreq().'&id='.$attempt_result['exe_id'].'&id_session='.api_get_session_id().'&height=500&width=750'; $attempt_link = Display::url(get_lang('Show'), $attempt_url, array('class'=>'ajax btn')); - $teacher_revised = Display::span(get_lang('Validated'), array('class'=>'label_tag success')); + $teacher_revised = Display::label(get_lang('Validated'), 'success'); //$attempt_link = get_lang('NoResult'); //$attempt_link = Display::return_icon('quiz_na.png', get_lang('NoResult'), array(), ICON_SIZE_SMALL); if ($attempt_result['attempt_revised'] == 0) { - $teacher_revised = Display::span(get_lang('NotValidated'), array('class'=>'label_tag notice')); + $teacher_revised = Display::label(get_lang('NotValidated'), 'info'); } $row = array('count' => $i, 'date' => api_convert_and_format_date($attempt_result['start_date'], DATE_TIME_FORMAT_LONG) @@ -167,8 +167,7 @@ if (!empty($attempts)) { case EXERCISE_FEEDBACK_TYPE_EXAM: $header_names = array(get_lang('Attempt'), get_lang('Date'), get_lang('Score')); break; - } - + } $row = 0; $column = 0; foreach ($header_names as $item) { diff --git a/main/gradebook/gradebook_showlog_eval.php b/main/gradebook/gradebook_showlog_eval.php index 0886a7546b..5a61fafab0 100644 --- a/main/gradebook/gradebook_showlog_eval.php +++ b/main/gradebook/gradebook_showlog_eval.php @@ -32,8 +32,7 @@ $interbreadcrumb[] = array ( $this_section = SECTION_COURSES; Display :: display_header(''); -echo Display::page_subheader(get_lang('GradebookQualifyLog')); - +echo Display::page_header(get_lang('GradebookQualifyLog')); $t_linkeval_log = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINKEVAL_LOG); $t_user= Database :: get_main_table(TABLE_MAIN_USER); diff --git a/main/inc/lib/banner.lib.php b/main/inc/lib/banner.lib.php index 4b89d4a134..42b18ed970 100644 --- a/main/inc/lib/banner.lib.php +++ b/main/inc/lib/banner.lib.php @@ -79,7 +79,7 @@ function get_tabs() { $group_pending_invitations = count($group_pending_invitations); } $total_invitations = intval($number_of_new_messages_of_friend) + $group_pending_invitations + intval($count_unread_message); - $total_invitations = (!empty($total_invitations)?' ('.$total_invitations.')':''); + $total_invitations = (!empty($total_invitations) ? Display::badge($total_invitations) :''); $navigation['social']['title'] = get_lang('SocialNetwork'). $total_invitations; } @@ -111,9 +111,8 @@ function get_tabs() { return $navigation; } -function show_header_1($language_file, $nameTools, $theme) { - global $noPHP_SELF; - $_course = api_get_course_info(); +function return_logo($theme) { + $_course = api_get_course_info(); $html = ''; $logo = api_get_path(SYS_CODE_PATH).'css/'.$theme.'/images/header-logo.png'; @@ -146,21 +145,21 @@ function show_header_1($language_file, $nameTools, $theme) { } } - /* Course title section */ + /* // Course title section if (!empty($_cid) and $_cid != -1 and isset($_course)) { //Put the name of the course in the header $html .= '
'; $html .= '
'; } elseif (isset($nameTools) && $language_file != 'course_home') { //Put the name of the user-tools in the header - if (!isset($_user['user_id'])) { + if (!isset($user_id)) { //echo '
'; } elseif (!$noPHP_SELF) { $html .= '
'.$nameTools.'
'; } else { $html .= '
'.$nameTools.'
'; } - } + }*/ return $html; } @@ -221,7 +220,7 @@ function return_navigation_array() { $navigation = array(); $menu_navigation = array(); - $possible_tabs = get_tabs(); + $possible_tabs = get_tabs(); // Campus Homepage if (api_get_setting('show_tabs', 'campus_homepage') == 'true') { @@ -326,7 +325,7 @@ function return_navigation_array() { } function return_menu() { - $navigation = return_navigation_array(); + $navigation = return_navigation_array(); $navigation = $navigation['navigation']; // Displaying the tabs @@ -407,11 +406,11 @@ function return_menu() { $show_bar = true; } - $menu = ''; + $menu = null; // Logout if ($show_bar) { - if (api_get_user_id()) { + if (api_get_user_id() && !api_is_anonymous()) { $login = ''; if (api_is_anonymous()) { $login = get_lang('Anonymous'); @@ -421,6 +420,7 @@ function return_menu() { $logout_link = api_get_path(WEB_PATH).'index.php?logout=logout&uid='.api_get_user_id(); $message_link = null; + if (api_get_setting('allow_message_tool') == 'true') { $message_link = ''.get_lang('Inbox').''; } @@ -446,7 +446,7 @@ function return_menu() { $menu .= $lis; $menu .= ''; } - } + } return $menu; } @@ -465,11 +465,14 @@ function return_breadcrumb($interbreadcrumb, $language_file, $nameTools) { $navigation = array(); // part 1: Course Homepage. If we are in a course then the first breadcrumb is a link to the course homepage // hide_course_breadcrumb the parameter has been added to hide the name of the course, that appeared in the default $interbreadcrumb + $session_name = cut($session_name, MAX_LENGTH_BREADCRUMB); $my_session_name = is_null($session_name) ? '' : ' ('.$session_name.')'; if (!empty($_course) && !isset($_GET['hide_course_breadcrumb'])) { $navigation_item['url'] = $web_course_path . $_course['path'].'/index.php'.(!empty($session_id) ? '?id_session='.$session_id : ''); - + + $course_title = cut($_course['name'], MAX_LENGTH_BREADCRUMB); + switch (api_get_setting('breadcrumbs_course_homepage')) { case 'get_lang': $navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH).'home.png', get_lang('CourseHomepageLink')).' '.get_lang('CourseHomepageLink'); @@ -478,13 +481,13 @@ function return_breadcrumb($interbreadcrumb, $language_file, $nameTools) { $navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH).'home.png', $_course['official_code']).' '.$_course['official_code']; break; case 'session_name_and_course_title': - $navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH).'home.png', $_course['name'].$my_session_name).' '.$_course['name'].$my_session_name; + $navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH).'home.png', $_course['name'].$my_session_name).' '.$course_title.$my_session_name; break; default: if (api_get_setting('use_session_mode') == 'true' && api_get_session_id() != -1 ) { - $navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH).'home.png', $_course['name'].$my_session_name).' '.$_course['name'].$my_session_name; + $navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH).'home.png', $_course['name'].$my_session_name).' '.$course_title.$my_session_name; } else { - $navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH).'home.png', $_course['name']).' '.$_course['name']; + $navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH).'home.png', $_course['name']).' '.$course_title; } break; } @@ -497,6 +500,7 @@ function return_breadcrumb($interbreadcrumb, $language_file, $nameTools) { */ $navigation[] = $navigation_item; } + // part 2: Interbreadcrumbs. If there is an array $interbreadcrumb defined then these have to appear before the last breadcrumb (which is the tool itself) if (isset($interbreadcrumb) && is_array($interbreadcrumb)) { foreach ($interbreadcrumb as $breadcrumb_step) { @@ -529,9 +533,8 @@ function return_breadcrumb($interbreadcrumb, $language_file, $nameTools) { $navigation_item['title'] = get_lang('Gallery'); } //Fixes breadcrumb title now we applied the Security::remove_XSS and we cut the string depending of the MAX_LENGTH_BREADCRUMB value - if (api_strlen($navigation_item['title']) > MAX_LENGTH_BREADCRUMB) { - $navigation_item['title'] = api_substr($navigation_item['title'], 0, MAX_LENGTH_BREADCRUMB).' ...'; - } + + $navigation_item['title'] = cut($navigation_item['title'], MAX_LENGTH_BREADCRUMB); $navigation_item['title'] = Security::remove_XSS($navigation_item['title']); $navigation[] = $navigation_item; } @@ -551,11 +554,9 @@ function return_breadcrumb($interbreadcrumb, $language_file, $nameTools) { foreach ($navigation as $index => $navigation_info) { if (!empty($navigation_info['title'])) { + if ($navigation_info['url'] == '#') { - - - $final_navigation[$index] = ''.$navigation_info['title'].''; - + $final_navigation[$index] = ''.$navigation_info['title'].''; } else { $final_navigation[$index] = ''.$navigation_info['title'].''; } @@ -592,7 +593,7 @@ function return_breadcrumb($interbreadcrumb, $language_file, $nameTools) { } else { $lis.= Display::tag('li', $home_link); } - $html .= Display::tag('ul',$lis, array('class'=>'breadcrumb')); + $html .= Display::tag('ul', $lis, array('class'=>'breadcrumb')); } return $html ; } \ No newline at end of file diff --git a/main/inc/lib/display.lib.php b/main/inc/lib/display.lib.php index fd0e26036f..1e41675413 100644 --- a/main/inc/lib/display.lib.php +++ b/main/inc/lib/display.lib.php @@ -1371,4 +1371,40 @@ class Display { return $div; } + function badge($count) { + $count = intval($count); + if (!empty($count)) { + return ' '.$count.''; + } + return ''; + } + + function label($content, $type = 'default') { + $class = ''; + switch ($type) { + case 'success': + $class = 'label-success'; + break; + case 'warning': + $class = 'label-warning'; + break; + case 'important': + $class = 'label-important'; + break; + case 'info': + $class = 'label-info'; + break; + case 'inverse': + $class = 'label-inverse'; + break; + } + + $html = ''; + if (!empty($content)) { + $html = ''; + $html .= $content; + $html .=''; + } + return $html; + } } //end class Display diff --git a/main/inc/lib/events.lib.inc.php b/main/inc/lib/events.lib.inc.php index c69bd4cf73..0751b991bc 100644 --- a/main/inc/lib/events.lib.inc.php +++ b/main/inc/lib/events.lib.inc.php @@ -833,15 +833,18 @@ function delete_student_lp_events($user_id, $lp_id, $course, $session_id) { $session_id = intval($session_id); //make sure we have the exact lp_view_id - $sqlview = "SELECT id FROM $lp_view_table WHERE c_id = $course_id AND user_id = $user_id AND lp_id = $lp_id AND session_id = $session_id "; + $sqlview = "SELECT id FROM $lp_view_table WHERE c_id = $course_id AND user_id = $user_id AND lp_id = $lp_id AND session_id = $session_id "; $resultview = Database::query($sqlview); - $view = Database::fetch_array($resultview, 'ASSOC'); - $lp_view_id = $view['id']; - $sql_delete = "DELETE FROM $lp_item_view_table WHERE c_id = $course_id AND lp_view_id = $view_id "; - $result = Database::query($sql_delete); + if (Database::num_rows($sqlview)) { + $view = Database::fetch_array($resultview, 'ASSOC'); + $lp_view_id = $view['id']; + + $sql_delete = "DELETE FROM $lp_item_view_table WHERE c_id = $course_id AND lp_view_id = $lp_view_id "; + $result = Database::query($sql_delete); + } - $sql_delete = "DELETE FROM $lp_view_table WHERE c_id = $course_id AND user_id = $user_id AND lp_id= $lp_id AND session_id= $session_id "; + $sql_delete = "DELETE FROM $lp_view_table WHERE c_id = $course_id AND user_id = $user_id AND lp_id= $lp_id AND session_id= $session_id "; $result = Database::query($sql_delete); $select_all_attempts = "SELECT exe_id FROM $track_e_exercises WHERE exe_user_id = $user_id AND session_id= $session_id AND exe_cours_id = '{$course['code']}' AND orig_lp_id = $lp_id"; diff --git a/main/inc/lib/fckeditor/editor/dialog/fck_template.html b/main/inc/lib/fckeditor/editor/dialog/fck_template.html index 3fc92cea2c..4a54f932b3 100644 --- a/main/inc/lib/fckeditor/editor/dialog/fck_template.html +++ b/main/inc/lib/fckeditor/editor/dialog/fck_template.html @@ -194,21 +194,18 @@ function ItemDiv_OnMouseOut() function ItemDiv_OnClick() { - SelectTemplate( this.TplIndex ) ; + SelectTemplate( this.TplIndex ) ; + if (window.top.hide_bar) { + window.top.hide_bar(); + } } function SelectTemplate( index ) { oEditor.FCKUndo.SaveUndoStep() ; - FCK.SetHTML( FCK._Templates[index].Html ) ; + FCK.SetHTML( FCK._Templates[index].Html ) ; } - - - - - + diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php index 4ae440c36f..17ee245716 100644 --- a/main/inc/lib/main_api.lib.php +++ b/main/inc/lib/main_api.lib.php @@ -118,6 +118,8 @@ define('SECTION_GLOBAL', 'global'); // CONSTANT name for local authentication source define('PLATFORM_AUTH_SOURCE', 'platform'); +define('CAS_AUTH_SOURCE', 'cas'); +define('LDAP_AUTH_SOURCE', 'extldap'); // CONSTANT defining the default HotPotatoes files directory define('DIR_HOTPOTATOES','/HotPotatoes_files'); @@ -2563,6 +2565,22 @@ function api_is_anonymous($user_id = null, $db_check = false) { return isset($_user['is_anonymous']) && $_user['is_anonymous'] === true; } +/* + * Returns a not found page + * @todo use smarty to customize the not found page + */ +function api_not_found($print_headers = false) { + $origin = isset($_GET['origin']) ? $_GET['origin'] : ''; + $show_headers = 0; + if ((!headers_sent() || $print_headers) && $origin != 'learnpath') { + $show_headers = 1; + } + $tpl = new Template(null, $show_headers, $show_headers); + $msg = get_lang('NotFound'); + $tpl->assign('content', $msg); + $tpl->display_one_col_template(); +} + /** * Displays message "You are not allowed here..." and exits the entire script. * @param bool Whether or not to print headers (default = false -> does not print them) @@ -3402,7 +3420,7 @@ function api_number_of_plugins($location) { /** * Including the necessary plugins. * @author Patrick Cool , Ghent University - * @deprecated use AppPlugin::get_all_plugin_contents_by_block function + * @deprecated use AppPlugin::get_all_plugin_contents_by_region function */ function api_plugin($location) { global $_plugins; diff --git a/main/inc/lib/plugin.lib.php b/main/inc/lib/plugin.lib.php index e6419f5ea9..3fb51d5bc1 100644 --- a/main/inc/lib/plugin.lib.php +++ b/main/inc/lib/plugin.lib.php @@ -1,7 +1,8 @@ plugin_blocks); - return $this->plugin_blocks; + function get_plugin_regions() { + sort($this->plugin_regions); + return $this->plugin_regions; } - function load_block($block, $main_template) { + function load_region($region, $main_template) { ob_start(); - $this->get_all_plugin_contents_by_block($block, $main_template); - $block_content = ob_get_contents(); + $this->get_all_plugin_contents_by_region($region, $main_template); + $content = ob_get_contents(); ob_end_clean(); - return $block_content; + return $content; } /** @@ -152,35 +153,31 @@ class AppPlugin { * @param smarty obj * @todo improve this function */ - function get_all_plugin_contents_by_block($block, $template) { + function get_all_plugin_contents_by_region($region, $template) { global $_plugins; - if (isset($_plugins[$block]) && is_array($_plugins[$block])) { + if (isset($_plugins[$region]) && is_array($_plugins[$region])) { //if (1) { - foreach ($_plugins[$block] as $plugin_name) { + foreach ($_plugins[$region] as $plugin_name) { //Load the plugin information //The plugin_info variable is available inside the plugin index - $plugin_info = $this->get_plugin_info($plugin_name); + $plugin_info = $this->get_plugin_info($plugin_name); //We also where the plugin is - $plugin_info['current_region'] = $block; + $plugin_info['current_region'] = $region; // Loading the plugin/XXX/index.php file - $plugin_file = api_get_path(SYS_PLUGIN_PATH)."$plugin_name/index.php"; + $plugin_file = api_get_path(SYS_PLUGIN_PATH)."$plugin_name/index.php"; + if (file_exists($plugin_file)) { require $plugin_file; - //We set the $template variable in order to use smarty - if (isset($_template) && !empty($_template)) { - /* - foreach ($_template as $key =>$value) { - $template->assign($plugin_name[$key], $value); - } - */ + //We set the $template variable in order to use Smarty + if (isset($_template) && !empty($_template)) { $template->assign($plugin_name, $_template); } - //Loading the smarty template files if exists + //Loading the Smarty template plugin files if exists $template_list = array(); if (isset($plugin_info) && isset($plugin_info['templates'])) { $template_list = $plugin_info['templates']; @@ -204,31 +201,31 @@ class AppPlugin { * * Loads plugin info * @staticvar array $plugin_data - * @param type $plugin_name - * @param type bool + * @param string plugin name + * @param bool load from DB or from the static array * @todo filter setting_form * @return array */ function get_plugin_info($plugin_name, $forced = false) { static $plugin_data = array(); - if (isset($plugin_data[$plugin_name]) && $forced == false) { + if (isset($plugin_data[$plugin_name]) && $forced == false) { return $plugin_data[$plugin_name]; } else { - $plugin_file = api_get_path(SYS_PLUGIN_PATH)."$plugin_name/plugin.php"; + $plugin_file = api_get_path(SYS_PLUGIN_PATH)."$plugin_name/plugin.php"; $plugin_info = array(); if (file_exists($plugin_file)) { require $plugin_file; - } - $plugin_data[$plugin_name] = $plugin_info; + } //extra options $plugin_settings = api_get_settings_params(array("subkey = ? AND category = ? AND type = ? " => - array($plugin_name, 'Plugins','setting'))); + array($plugin_name, 'Plugins','setting'))); $settings_filtered = array(); foreach ($plugin_settings as $item) { $settings_filtered[$item['variable']] = $item['selected_value']; } - $plugin_info['settings'] = $settings_filtered; + $plugin_info['settings'] = $settings_filtered; + $plugin_data[$plugin_name] = $plugin_info; return $plugin_info; } } diff --git a/main/inc/lib/social.lib.php b/main/inc/lib/social.lib.php index 55a659e10c..b183c946a2 100644 --- a/main/inc/lib/social.lib.php +++ b/main/inc/lib/social.lib.php @@ -556,13 +556,13 @@ class SocialManager extends UserManager { // get count unread message and total invitations $count_unread_message = MessageManager::get_number_of_messages(true); - $count_unread_message = (!empty($count_unread_message)?' ('.$count_unread_message.')':''); + $count_unread_message = (!empty($count_unread_message)? Display::badge($count_unread_message) :''); $number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id()); $group_pending_invitations = GroupPortalManager::get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION,false); $group_pending_invitations = count($group_pending_invitations); $total_invitations = $number_of_new_messages_of_friend + $group_pending_invitations; - $total_invitations = (!empty($total_invitations)?' ('.$total_invitations.')':''); + $total_invitations = (!empty($total_invitations) ? Display::badge($total_invitations) :''); $html = '
'; diff --git a/main/inc/lib/system_announcements.lib.php b/main/inc/lib/system_announcements.lib.php index c72d8bc549..aa76732a4e 100644 --- a/main/inc/lib/system_announcements.lib.php +++ b/main/inc/lib/system_announcements.lib.php @@ -607,7 +607,7 @@ class SystemAnnouncementManager { $announcements = Database::query($sql); $html = ''; if (Database::num_rows($announcements) > 0) { - $html .= '
'; + $html .= '
'; $html .= '

'.get_lang('SystemAnnouncements').'

'; $html .= '
    '; while ($announcement = Database::fetch_object($announcements)) { diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php index ee472909ce..456955dafa 100644 --- a/main/inc/lib/template.lib.php +++ b/main/inc/lib/template.lib.php @@ -2,12 +2,11 @@ /* For licensing terms, see /license.txt */ /* * @author Julio Montoya + * @todo better organization of the class, methods and variables * **/ - /* @todo better organization of the class methods and variables */ - -// Load Smarty library + // Load Smarty library require_once api_get_path(LIBRARY_PATH).'smarty/Smarty.class.php'; require_once api_get_path(LIBRARY_PATH).'course_home.lib.php'; require_once api_get_path(LIBRARY_PATH).'banner.lib.php'; @@ -22,7 +21,7 @@ class Template extends Smarty { var $show_header; var $show_footer; var $help; - var $menu_navigation = array(); + //var $menu_navigation = array(); var $show_learnpath = false; // This is a learnpath section or not? var $plugin = null; var $course_id = null; @@ -53,10 +52,9 @@ class Template extends Smarty { //Setting user variables $this->set_user_parameters(); - - //Setting course id - $course_id = api_get_course_int_id(); - $this->course_id = $course_id; + + //Setting course variables + $this->set_course_parameters(); //header and footer are showed by default $this->set_footer($show_footer); @@ -82,9 +80,9 @@ class Template extends Smarty { //Chamilo plugins $this->plugin = new AppPlugin(); - $plugin_blocks = $this->plugin->get_plugin_blocks(); - foreach ($plugin_blocks as $block) { - $this->set_plugin_block($block); + $plugin_regions = $this->plugin->get_plugin_regions(); + foreach ($plugin_regions as $region) { + $this->set_plugin_region($region); } } @@ -213,8 +211,16 @@ class Template extends Smarty { function get_template($name) { return $this->style.'/'.$name; - } + } + + /* Set course parameters */ + private function set_course_parameters() { + //Setting course id + $course_id = api_get_course_int_id(); + $this->course_id = $course_id; + } + /* Set user parameters */ private function set_user_parameters() { $user_info = array(); $user_info['logged'] = 0; @@ -235,6 +241,7 @@ class Template extends Smarty { $this->assign('_u', $user_info); } + /* Set system parameters */ private function set_system_parameters() { global $_configuration; @@ -243,7 +250,8 @@ class Template extends Smarty { 'web_course' => api_get_path(WEB_COURSE_PATH), 'web_main' => api_get_path(WEB_CODE_PATH), 'web_ajax' => api_get_path(WEB_AJAX_PATH), - 'web_img' => api_get_path(WEB_IMG_PATH) + 'web_img' => api_get_path(WEB_IMG_PATH), + 'web_plugin' => api_get_path(WEB_PLUGIN_PATH) ); $this->assign('_p', $_p); @@ -285,23 +293,24 @@ class Template extends Smarty { $this->assign('css_style', $style_html); $style_print = '@import "'.api_get_path(WEB_CSS_PATH).$this->theme.'/print.css";'."\n"; - $this->assign('css_style_print', $style_print); - $this->assign('style_print', $style_print); - // Header 1 - $header1 = show_header_1($language_file, $nameTools, $this->theme); - $this->assign('header1', $header1); + $this->assign('css_style_print', $style_print); + + // Logo + $logo = return_logo($this->theme); + $this->assign('logo', $logo); } private function set_header_parameters() { $help = $this->help; $nameTools = $this->title; + global $lp_theme_css, $mycoursetheme, $user_theme; - global $httpHeadXtra, $htmlHeadXtra, $_course, $_user, $text_dir, $_user, - $_cid, $interbreadcrumb, $charset, $language_file, $noPHP_SELF; + global $httpHeadXtra, $htmlHeadXtra, $_course, $text_dir, + $interbreadcrumb, $charset, $language_file, $noPHP_SELF; - $navigation = return_navigation_array(); - $this->menu_navigation = $navigation['menu_navigation']; + //$navigation = return_navigation_array(); + //$this->menu_navigation = $navigation['menu_navigation']; global $_configuration; @@ -325,6 +334,7 @@ class Template extends Smarty { $title_list[] = api_get_setting('Institution'); $title_list[] = api_get_setting('siteName'); + if (!empty($course_title)) { $title_list[] = $course_title; } @@ -403,6 +413,7 @@ class Template extends Smarty { $css_file_to_string .= api_get_css($css_file); } + // @todo move this somewhere else if (SHOW_TEXT_NEAR_ICONS == true) { //hack in order to fix the actions buttons $css_file_to_string .= ''; Display::display_reduced_header(); echo ''; } @@ -61,7 +57,7 @@ if ($origin == 'tracking') { } else { $url_suffix = '&lp_id=' . $lp_id; } -if (!empty ($_GET['extend_all'])) { +if (!empty($_GET['extend_all'])) { $extend_all_link = 'fold_view'; $extend_all = 1; } else { @@ -91,6 +87,9 @@ $TBL_QUIZ = Database :: get_course_table(TABLE_QUIZ_TEST); $tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES); $tbl_stats_attempts = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); +//It cames from myspace/lp_tracking.php +$lp_id = intval($lp_id); + $sql = "SELECT max(view_count) FROM $TBL_LP_VIEW WHERE c_id = $course_id AND lp_id = $lp_id AND user_id = '" . $user_id . "' $session_condition"; $res = Database::query($sql); $view = ''; @@ -101,9 +100,7 @@ if (Database :: num_rows($res) > 0) { } $counter = 0; -//error_log('New LP - Querying views for latest attempt: '.$sql, 0); $total_score = 0; -$total_max_score = 0; $total_time = 0; $h = get_lang('h'); @@ -117,8 +114,8 @@ if (!empty($export_csv)) { } // Get attempts of a exercise. -if (isset($_GET['lp_id']) && isset($_GET['my_lp_id'])) { - $clean_lp_item_id = Database::escape_string($_GET['my_lp_id']); +if (isset($_GET['lp_id']) && isset($_GET['lp_item_id'])) { + $clean_lp_item_id = Database::escape_string($_GET['lp_item_id']); $clean_lp_id = Database::escape_string($_GET['lp_id']); $clean_course_code = Database :: escape_string($course_code); $sql_path = "SELECT path FROM $TBL_LP_ITEM WHERE c_id = $course_id AND id = '$clean_lp_item_id' AND lp_id = '$clean_lp_id'"; @@ -134,40 +131,36 @@ if (isset($_GET['lp_id']) && isset($_GET['my_lp_id'])) { WHERE exe_exo_id="' . (int)$row_path['path'] . '" AND status <> "incomplete" AND exe_user_id="' . $student_id . '" AND orig_lp_id = "'.(int)$clean_lp_id.'" AND orig_lp_item_id = "'.(int)$clean_lp_item_id.'" AND exe_cours_id="' . $clean_course_code. '" AND session_id = '.$session_id.' ORDER BY exe_date'; } } + //var_dump($sql_attempts); } +//Show lp items - -if (is_array($list) && count($list) > 0) { +if (is_array($list) && count($list) > 0) { foreach ($list as $my_item_id) { $extend_this = 0; $qry_order = 'DESC'; if ((!empty ($_GET['extend_id']) && $_GET['extend_id'] == $my_item_id) || $extend_all) { $extend_this = 1; $qry_order = 'ASC'; - } + } // Prepare statement to go through each attempt. - if (!empty ($view)) { - $sql = "SELECT iv.status as mystatus, v.view_count as mycount, " . - " iv.score as myscore, iv.total_time as mytime, i.id as myid, i.lp_id as mylpid, iv.lp_view_id as mylpviewid, " . - " i.title as mytitle, i.max_score as mymaxscore, " . - " iv.max_score as myviewmaxscore, " . - " i.item_type as item_type, iv.view_count as iv_view_count, " . - " iv.id as iv_id, path as path" . - " FROM $TBL_LP_ITEM as i, $TBL_LP_ITEM_VIEW as iv, $TBL_LP_VIEW as v" . - " WHERE + if (!empty($view)) { + $sql = "SELECT iv.status as mystatus, v.view_count as mycount, iv.score as myscore, iv.total_time as mytime, i.id as myid, + i.lp_id as mylpid, iv.lp_view_id as mylpviewid, i.title as mytitle, i.max_score as mymaxscore, + iv.max_score as myviewmaxscore, i.item_type as item_type, iv.view_count as iv_view_count, iv.id as iv_id, path as path + FROM $TBL_LP_ITEM as i INNER JOIN $TBL_LP_ITEM_VIEW as iv ON (i.id = iv.lp_item_id ) + INNER JOIN $TBL_LP_VIEW as v ON (iv.lp_view_id = v.id) + WHERE i.c_id = $course_id AND iv.c_id = $course_id AND - v.c_id = $course_id AND - i.id = iv.lp_item_id " . - " AND i.id = $my_item_id " . - " AND iv.lp_view_id = v.id " . - " AND i.lp_id = $lp_id " . - " AND v.user_id = " . $user_id . " " . - " AND v.view_count = $view " . - " AND v.session_id = $session_id " . - " ORDER BY iv.view_count $qry_order "; + v.c_id = $course_id AND i.id = $my_item_id AND + i.lp_id = $lp_id AND + v.user_id = " . $user_id . " AND + v.view_count = $view AND v.session_id = $session_id + ORDER BY iv.view_count $qry_order "; + //var_dump($sql); } else { $sql = "SELECT iv.status as mystatus, v.view_count as mycount, " . " iv.score as myscore, iv.total_time as mytime, i.id as myid, i.lp_id as mylpid, iv.lp_view_id as mylpviewid, " . @@ -187,28 +180,28 @@ if (is_array($list) && count($list) > 0) { " AND v.session_id = $session_id " . " ORDER BY iv.view_count $qry_order "; } - //echo $sql.'
    '; + $result = Database::query($sql); $num = Database :: num_rows($result); $time_for_total = 'NaN'; - - $is_allowed_to_edit = api_is_allowed_to_edit(null, true); - + + //Extend all + extend scorm? if (($extend_this || $extend_all) && $num > 0) { + //var_dump('go'); $row = Database :: fetch_array($result); $result_disabled_ext_all = false; if ($row['item_type'] == 'quiz') { // Check results_disabled in quiz table. $my_path = Database::escape_string($row['path']); - $sql = "SELECT results_disabled FROM $TBL_QUIZ WHERE c_id = $course_id AND id ='".(int)$my_path."'"; + $sql = "SELECT results_disabled FROM $TBL_QUIZ WHERE c_id = $course_id AND id ='".$my_path."'"; $res_result_disabled = Database::query($sql); $row_result_disabled = Database::fetch_row($res_result_disabled); if (Database::num_rows($res_result_disabled) > 0 && (int)$row_result_disabled[0] === 1) { $result_disabled_ext_all = true; } - } + } //echo '
    '; print_r($row); echo '

    '; // If there are several attempts, and the link to extend has been clicked, show each attempt... @@ -232,10 +225,10 @@ if (is_array($list) && count($list) > 0) { $title = Security::remove_XSS($title); $output .= "
" . "" . '" . ''.''.'' . ""; } + $counter++; - do { - $row['iv_view_count']; + do { // Check if there are interactions below. $extend_attempt_link = ''; $extend_this_attempt = 0; @@ -249,18 +242,19 @@ if (is_array($list) && count($list) > 0) { $extend_attempt_link = ''.get_lang('ExtendAttemptView').'' . "\n"; } } - + if (($counter % 2) == 0) { $oddclass = 'row_odd'; } else { $oddclass = 'row_even'; } + $lesson_status = $row['mystatus']; $score = $row['myscore']; + $time_for_total = $row['mytime']; - $time = learnpathItem :: get_scorm_time('js', $row['mytime']); - $type; + $time = learnpathItem :: get_scorm_time('js', $row['mytime']); $scoIdentifier = $row['myid']; if ($score == 0) { $maxscore = $row['mymaxscore']; @@ -277,12 +271,13 @@ if (is_array($list) && count($list) > 0) { $maxscore = $row['mymaxscore']; } } + // Remove "NaN" if any (@todo: locate the source of these NaN) $time = str_replace('NaN', '00' . $h . '00\'00"', $time); - if (($lesson_status == 'completed') || ($lesson_status == 'passed')) { - $color = 'green'; - } else { - $color = 'black'; + if (($lesson_status == 'completed') || ($lesson_status == 'passed')) { + $class_status = 'success'; + } else { + $class_status = 'default'; } $mylanglist = array ( 'completed' => 'ScormCompstatus', @@ -305,14 +300,13 @@ if (is_array($list) && count($list) > 0) { $view_score = $score; } else { $view_score = show_score($score, $maxscore, false); - } - + } } else { $view_score = show_score($score, $maxscore, false); } } $output .= "" . "" . "" . '" - . '\n" . '" . ''; + . '\n" . '" . ''; if (!empty($export_csv)) { $temp = array (); @@ -375,7 +369,9 @@ if (is_array($list) && count($list) > 0) { } while ($row = Database :: fetch_array($result)); } elseif ($num > 0) { - $row = Database :: fetch_array($result); + //Not extended + + $row = Database :: fetch_array($result,'ASSOC'); $my_id = $row['myid']; $my_lp_id = $row['mylpid']; $my_lp_view_id = $row['mylpviewid']; @@ -394,15 +390,16 @@ if (is_array($list) && count($list) > 0) { if (Database::num_rows($res_result_disabled) > 0 && (int)$row_result_disabled[0] === 1) { $result_disabled_ext_all = true; } - } + } - // Check if there are interactions below. - $extend_attempt_link = ''; + // Check if there are interactions below $extend_this_attempt = 0; $inter_num = learnpath::get_interactions_count_from_db($row['iv_id'], $course_id); $objec_num = learnpath::get_objectives_count_from_db($row['iv_id'], $course_id); - if (($inter_num > 0 || $objec_num > 0) && !$extend_all) { + + $extend_attempt_link = ''; + if (($inter_num > 0 || $objec_num > 0)) { if (!empty ($_GET['extend_attempt_id']) && $_GET['extend_attempt_id'] == $row['iv_id']) { // The extend button for this attempt has been clicked. $extend_this_attempt = 1; @@ -412,20 +409,22 @@ if (is_array($list) && count($list) > 0) { $extend_attempt_link = ''.get_lang('ExtendAttemptView').'' . "\n"; } } - + if (($counter % 2) == 0) { $oddclass = 'row_odd'; } else { $oddclass = 'row_even'; } - //$extend_link = 'extend_disabled'; + $extend_link = ''; if ($inter_num > 1) { $extend_link = ''.get_lang('ExtendAttemptView').''; } - $lesson_status = $row['mystatus']; - $score = $row['myscore']; - $subtotal_time = $row['mytime']; + + $lesson_status = $row['mystatus']; + $score = $row['myscore']; + $subtotal_time = $row['mytime']; + //if ($row['mytime'] == 0) { while ($tmp_row = Database :: fetch_array($result)) { $subtotal_time += $tmp_row['mytime']; @@ -441,8 +440,8 @@ if (is_array($list) && count($list) > 0) { $sql_last_attempt = 'SELECT * FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . api_get_user_id() . '" AND orig_lp_id = "'.$lp_id.'" AND orig_lp_item_id = "'.$row['myid'].'" AND exe_cours_id="' . $course_code . '" AND status <> "incomplete" AND session_id = '.$session_id.' ORDER BY exe_date DESC limit 1'; } else { $sql_last_attempt = 'SELECT * FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . $student_id . '" AND orig_lp_id = "'.$lp_id.'" AND orig_lp_item_id = "'.$row['myid'].'" AND exe_cours_id="' . $course_code . '" AND status <> "incomplete" AND session_id = '.$session_id.' ORDER BY exe_date DESC limit 1'; - } - + } + $resultLastAttempt = Database::query($sql_last_attempt); $num = Database :: num_rows($resultLastAttempt); if ($num > 0) { @@ -450,7 +449,8 @@ if (is_array($list) && count($list) > 0) { $id_last_attempt = $rowLA['exe_id']; } } - + + //var_dump($row['path'] .' '.$score); if ($score == 0) { $maxscore = $row['mymaxscore']; } else { @@ -500,6 +500,7 @@ if (is_array($list) && count($list) > 0) { } } } + $time_for_total = $subtotal_time; $time = learnpathItem :: get_scorm_time('js', $subtotal_time); if (empty ($title)) { @@ -508,26 +509,28 @@ if (is_array($list) && count($list) > 0) { // Remove "NaN" if any (@todo: locate the source of these NaN) //$time = str_replace('NaN', '00'.$h.'00\'00"', $time); - if (($lesson_status == 'completed') or ($lesson_status == 'passed')) { - $color = 'green'; + if (($lesson_status == 'completed') or ($lesson_status == 'passed')) { + $class_status = 'success'; } else { - $color = 'black'; + $class_status = 'default'; } + $mylanglist = array ( - 'completed' => 'ScormCompstatus', - 'incomplete' => 'ScormIncomplete', - 'failed' => 'ScormFailed', - 'passed' => 'ScormPassed', - 'browsed' => 'ScormBrowsed', - 'not attempted' => 'ScormNotAttempted', - + 'completed' => 'ScormCompstatus', + 'incomplete' => 'ScormIncomplete', + 'failed' => 'ScormFailed', + 'passed' => 'ScormPassed', + 'browsed' => 'ScormBrowsed', + 'not attempted' => 'ScormNotAttempted' ); + $my_lesson_status = get_lang($mylanglist[$lesson_status]); if ($row['item_type'] != 'dokeos_chapter') { if ($row['item_type'] == 'quiz') { $correct_test_link = ''; $my_url_suffix =''; + if ($origin != 'tracking' && $origin != 'tracking_course') { $my_url_suffix = '&course=' . api_get_course_id() . '&student_id=' . api_get_user_id() . '&lp_id=' . Security::remove_XSS($row['mylpid']); $sql_last_attempt = 'SELECT * FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . api_get_user_id() . '" AND orig_lp_id = "'.$lp_id.'" AND orig_lp_item_id = "'.$row['myid'].'" AND exe_cours_id="' . $course_code . '" AND status <> "incomplete" AND session_id = '.$session_id.' ORDER BY exe_date DESC '; @@ -535,37 +538,38 @@ if (is_array($list) && count($list) > 0) { $my_url_suffix = '&course=' . Security::remove_XSS($_GET['course']) . '&student_id=' . $student_id . '&lp_id=' . Security::remove_XSS($row['mylpid']).'&origin=' . Security::remove_XSS($_GET['origin'].$from_link); $sql_last_attempt = 'SELECT * FROM ' . $tbl_stats_exercices . ' WHERE exe_exo_id="' . $row['path'] . '" AND exe_user_id="' . $student_id . '" AND orig_lp_id = "'.$lp_id.'" AND orig_lp_item_id = "'.$row['myid'].'" AND exe_cours_id="' . Database :: escape_string($_GET['course']) . '" AND status <> "incomplete" AND session_id = '.$session_id.' ORDER BY exe_date DESC '; } - + $resultLastAttempt = Database::query($sql_last_attempt); - $num = Database :: num_rows($resultLastAttempt); + $num = Database :: num_rows($resultLastAttempt); if ($num > 0) { - if (isset($_GET['extend_attempt']) && $_GET['extend_attempt'] == 1 && (isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id) && (isset($_GET['my_lp_id']) && $_GET['my_lp_id'] == $my_id) ) { - $correct_test_link = 'fold_view'; + if (isset($_GET['extend_attempt']) && $_GET['extend_attempt'] == 1 && (isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id) && (isset($_GET['lp_item_id']) && $_GET['lp_item_id'] == $my_id) ) { + $correct_test_link = 'fold_view'; $extend_attempt = 1; } else { - $correct_test_link = 'extend_view'; + $correct_test_link = 'extend_view'; } } else { $correct_test_link = '-'; } } else { $correct_test_link = '-'; - } + } $title = Security::remove_XSS($title); - if ( (isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id ) && (isset($_GET['my_lp_id']) && $_GET['my_lp_id'] == $my_id)) { - $output .= "" . "" . ''; + + if ( (isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id && false) ) { + $output .= ''; $output .= ''; $output .= ""; } else { - if ( (isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id ) && (isset($_GET['my_ext_lp_id']) && $_GET['my_ext_lp_id'] == $my_id)) { + if ( (isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id ) && (isset($_GET['lp_item_id']) && $_GET['lp_item_id'] == $my_id)) { $output .= ""; } else { $output .= ""; } - $output .= "\n" . ''; - $output .= '" . ''; + $output .= '" . '' - . ''; + . ''; if ($origin != 'tracking') { if (!$is_allowed_to_edit && $result_disabled_ext_all) { $output .= ''; @@ -746,8 +753,8 @@ if (!empty($a_my_id)) { $total_time = learnpathItem :: get_scorm_time('js', $total_time); //$total_time = str_replace('NaN', '00:00:00' ,$total_time); $total_time = str_replace('NaN', '00' . $h . '00\'00"', $total_time); -$lp_type = learnpath :: get_type_static($lp_id); -$total_percent = 0; +//$lp_type = learnpath :: get_type_static($lp_id); +//$total_percent = 0; if (!$is_allowed_to_edit && $result_disabled_ext_all) { $final_score = Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting')); diff --git a/main/newscorm/lp_view.php b/main/newscorm/lp_view.php index 5dc0159ae6..a8a3ba8951 100644 --- a/main/newscorm/lp_view.php +++ b/main/newscorm/lp_view.php @@ -21,7 +21,7 @@ $_SESSION['whereami'] = 'lp/view'; $this_section = SECTION_COURSES; if ($lp_controller_touched != 1) { - header('location: lp_controller.php?action=view&item_id='.$_REQUEST['item_id']); + header('location: lp_controller.php?action=view&item_id='.intval($_REQUEST['item_id'])); exit; } @@ -36,6 +36,31 @@ $show_learnpath = true; api_protect_course_script(); +$lp_id = intval($_GET['lp_id']); + +// Check if the learning path is visible for student - (LP requisites) +if (!api_is_allowed_to_edit(null, true) && !learnpath::is_lp_visible_for_student($lp_id, api_get_user_id())) { + api_not_allowed(); +} + +//Checking visibility (eye icon) +$visibility = api_get_item_visibility(api_get_course_info(), TOOL_LEARNPATH, $lp_id, $action, api_get_user_id(), api_get_session_id()); +if (!api_is_allowed_to_edit(null, true) && intval($visibility) == 0 ) { + api_not_allowed(); +} + +if (empty($_SESSION['oLP'])) { + api_not_allowed(); +} + +$debug = 0; + +if ($debug) { error_log('------ Entering lp_view.php -------'); } + +$_SESSION['oLP']->error = ''; +$lp_item_id = $_SESSION['oLP']->get_current_item_id(); +$lp_type = $_SESSION['oLP']->get_type(); + $course_code = api_get_course_id(); $course_id = api_get_course_int_id(); $user_id = api_get_user_id(); @@ -52,35 +77,19 @@ if (api_get_setting('show_glossary_in_documents') == 'ismanual' || api_get_setti '; $htmlHeadXtra[] = ''; $htmlHeadXtra[] = ''; - } -$htmlHeadXtra[] = ''; -$htmlHeadXtra[] = ''; - -$_SESSION['oLP']->error = ''; -$lp_item_id = $_SESSION['oLP']->get_current_item_id(); -$lp_type = $_SESSION['oLP']->get_type(); -$lp_id = intval($_GET['lp_id']); +var dokeos_xajax_handler = window.oxajax; -// Check if the learning path is visible for student - (LP requisites) -if (!api_is_allowed_to_edit(null, true) && !learnpath::is_lp_visible_for_student($lp_id, api_get_user_id())) { - api_not_allowed(); -} +'; -//Checking visibility (eye icon) -$visibility = api_get_item_visibility(api_get_course_info(), TOOL_LEARNPATH, $lp_id, $action, api_get_user_id(), api_get_session_id()); -if (!api_is_allowed_to_edit(null, true) && intval($visibility) == 0 ) { - api_not_allowed(); -} // Prepare variables for the test tool (just in case) - honestly, this should disappear later on. $_SESSION['scorm_view_id'] = $_SESSION['oLP']->get_view_id(); @@ -115,7 +124,7 @@ $htmlHeadXtra[] = ''; @@ -173,26 +182,32 @@ foreach($list as $toc) { } } -$debug = 0; - $autostart = 'true'; // Update status, total_time from lp_item_view table when you finish the exercises in learning path. + +if ($debug) { + error_log('$type_quiz: '.$type_quiz); + error_log('$_REQUEST[exeId]: '.$_REQUEST['exeId']); + error_log('$lp_id: '.$lp_id); + error_log('$_GET[lp_item_id]: '.$_GET['lp_item_id']); +} + if ($type_quiz && !empty($_REQUEST['exeId']) && isset($lp_id) && isset($_GET['lp_item_id'])) { global $src; $_SESSION['oLP']->items[$_SESSION['oLP']->current]->write_to_db(); $TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES); - $TBL_LP_ITEM_VIEW = Database::get_course_table(TABLE_LP_ITEM_VIEW); - //$TBL_LP_VIEW = Database::get_course_table(TABLE_LP_VIEW); + $TBL_LP_ITEM_VIEW = Database::get_course_table(TABLE_LP_ITEM_VIEW); $TBL_LP_ITEM = Database::get_course_table(TABLE_LP_ITEM); - $safe_item_id = Database::escape_string($_GET['lp_item_id']); + $safe_item_id = intval($_GET['lp_item_id']); $safe_id = $lp_id; $safe_exe_id = intval($_REQUEST['exeId']); if ($safe_id == strval(intval($safe_id)) && $safe_item_id == strval(intval($safe_item_id))) { $sql = 'SELECT start_date, exe_date, exe_result, exe_weighting FROM ' . $TBL_TRACK_EXERCICES . ' WHERE exe_id = '.$safe_exe_id; + if ($debug) error_log($sql); $res = Database::query($sql); $row_dates = Database::fetch_array($res); @@ -203,12 +218,13 @@ if ($type_quiz && !empty($_REQUEST['exeId']) && isset($lp_id) && isset($_GET['lp $score = (float)$row_dates['exe_result']; $max_score = (float)$row_dates['exe_weighting']; - $sql_upd_max_score = "UPDATE $TBL_LP_ITEM SET max_score = '$max_score' WHERE c_id = $course_id AND id = '".(int)$safe_item_id."'"; + $sql_upd_max_score = "UPDATE $TBL_LP_ITEM SET max_score = '$max_score' WHERE c_id = $course_id AND id = '".$safe_item_id."'"; if ($debug) error_log($sql_upd_max_score); Database::query($sql_upd_max_score); $sql_last_attempt = "SELECT id FROM $TBL_LP_ITEM_VIEW WHERE c_id = $course_id AND lp_item_id = '$safe_item_id' AND lp_view_id = '".$_SESSION['oLP']->lp_view_id."' order by id desc limit 1"; $res_last_attempt = Database::query($sql_last_attempt); + if ($debug) error_log($sql_last_attempt); if (Database::num_rows($res_last_attempt)) { $row_last_attempt = Database::fetch_row($res_last_attempt); @@ -227,7 +243,7 @@ if ($type_quiz && !empty($_REQUEST['exeId']) && isset($lp_id) && isset($_GET['lp $src = 'blank.php?msg=exerciseFinished'; } else { $src = api_get_path(WEB_CODE_PATH).'exercice/exercise_show.php?id='.$safe_exe_id.'&origin=learnpath&learnpath_id='.$lp_id.'&learnpath_item_id='.$lp_id.'&fb_type='.Security::remove_XSS($_GET['fb_type']); - if ($debug) error_log('Calling URL'.$src); + if ($debug) error_log('Calling URL: '.$src); } $autostart = 'false'; } @@ -322,11 +338,11 @@ if (Database::num_rows($res_media) > 0) { -
-
+
+
-
-
+
+
get_preview_image()!='') { $picture = getimagesize(api_get_path(SYS_COURSE_PATH).api_get_course_path().'/upload/learning_path/images/'.$_SESSION['oLP']->get_preview_image()); @@ -339,15 +355,12 @@ if (Database::num_rows($res_media) > 0) { } ?>
-
-
-
+
-
-
+
diff --git a/main/newscorm/scorm_api.php b/main/newscorm/scorm_api.php index 315a093292..545fba790e 100644 --- a/main/newscorm/scorm_api.php +++ b/main/newscorm/scorm_api.php @@ -1246,20 +1246,21 @@ function update_stats_page() * @param integer Number of items in total * @param string Display mode (absolute 'abs' or percentage '%').Defaults to % */ -function update_progress_bar(nbr_complete, nbr_total, mode) -{ +function update_progress_bar(nbr_complete, nbr_total, mode) { logit_lms('update_progress_bar('+nbr_complete+','+nbr_total+','+mode+')',2); logit_lms('could update with data: '+olms.lms_lp_id+','+olms.lms_view_id+','+olms.lms_user_id,2); - if(mode == ''){mode='%';} - if(nbr_total == 0){nbr_total=1;} + if (mode == ''){mode='%';} + if (nbr_total == 0){nbr_total=1;} var percentage = (nbr_complete/nbr_total)*100; percentage = Math.round(percentage); var pr_text = $("#progress_text"); var progress_bar = $("#progress_bar_value"); - progress_bar.css('width', percentage); - + + + progress_bar.css('width', percentage + "%"); + /* var pr_full = $("#progress_img_full"); var pr_empty = $("#progress_img_empty"); diff --git a/main/template/default/layout/main_header.tpl b/main/template/default/layout/main_header.tpl index 5c229a55fe..f644e77ec2 100644 --- a/main/template/default/layout/main_header.tpl +++ b/main/template/default/layout/main_header.tpl @@ -29,10 +29,11 @@
-
- {* header1 - logo *} +
- {$header1} + {* logo *} + {$logo} + {* plugin_header *} {if !empty($plugin_header_left)}
@@ -76,6 +77,7 @@
{/if}
+ {* menu *} {if $menu}
$extend_link
' . $title . "
$extend_attempt_link' . get_lang('Attempt') . ' ' . $row['iv_view_count'] . "
' . $my_lesson_status . "
' . $view_score . "
'.$time.'
' . Display::label($my_lesson_status, $class_status) . "
' . $view_score . "
'.$time.'
$extend_link
' .$title. '
'.$extend_link.'
'.$title.'
   '.$correct_test_link.'
$extend_link
' .$title. '
' . $my_lesson_status . "
'; - if ($row['item_type'] == 'quiz') { + $output .= '
'.$extend_link.'
'.$title.'
' . Display::label($my_lesson_status, $class_status). "
'; + if ($row['item_type'] == 'quiz') { if (!$is_allowed_to_edit && $result_disabled_ext_all) { $output .= Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting')); } else { @@ -599,8 +603,10 @@ if (is_array($list) && count($list) > 0) { } $counter++; + //var_dump($extend_this_attempt, $extend_all); if ($extend_this_attempt OR $extend_all) { $list1 = learnpath :: get_iv_interactions_array($row['iv_id']); + foreach ($list1 as $id => $interaction) { if (($counter % 2) == 0) { $oddclass = 'row_odd'; @@ -627,7 +633,7 @@ if (is_array($list) && count($list) > 0) { } // Attempts listing by exercise. - if ((isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id) && (isset($_GET['my_lp_id']) && $_GET['my_lp_id'] == $my_id)) { + if ((isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id) && (isset($_GET['lp_item_id']) && $_GET['lp_item_id'] == $my_id) && isset($_GET['extend_attempt'])) { $res_attempts = Database::query($sql_attempts); $num_attempts = Database :: num_rows($res_attempts); @@ -678,7 +684,8 @@ if (is_array($list) && count($list) > 0) { } $output .= '
 '.$extend_attempt_link.'' . get_lang('Attempt') . ' ' . $n . '
' . $my_lesson_status . '
' . $view_score . '
' . $time_attemp . '
' . Display::label($my_lesson_status, $class_status).' +
' . $view_score . '
' . $time_attemp . '
'.get_lang('ShowAttempt').'