More fixes due the latest changes in CourseManager::create_course see #4068

skala
Julio Montoya 14 years ago
parent bcd4619f28
commit 6390a0ad33
  1. 4
      main/admin/course_add.php
  2. 27
      main/admin/course_list.php
  3. 4
      main/admin/subscribe_user2course.php
  4. 8
      main/course_info/infocours.php
  5. 21
      main/create_course/add_course.php
  6. 32
      main/inc/lib/add_course.lib.inc.php
  7. 2
      main/inc/lib/course.lib.php
  8. 3
      main/inc/lib/main_api.lib.php

@ -17,8 +17,6 @@ $this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
require_once api_get_path(CONFIGURATION_PATH).'add_course.conf.php';
require_once api_get_path(LIBRARY_PATH).'add_course.lib.inc.php';
$table_course = Database::get_main_table(TABLE_MAIN_COURSE);
$tool_name = get_lang('AddCourse');
@ -71,7 +69,7 @@ $form->addRule('visual_code', get_lang('Max'), 'maxlength', $maxlength);
//$form->addElement('select', 'tutor_id', get_lang('CourseTitular'), $teachers, array('style' => 'width:350px', 'class'=>'chzn-select', 'id'=>'tutor_id'));
//$form->applyFilter('tutor_id', 'html_filter');
$form->addElement('select', 'course_teachers', get_lang('CourseTeachers'), $teachers, ' id="course_teachers" class="chzn-select" style="width:350px" multiple="multiple" size="5"');
$form->addElement('select', 'course_teachers', get_lang('CourseTeachers'), $teachers, ' id="course_teachers" class="chzn-select" style="width:350px" multiple="multiple" ');
$form->applyFilter('course_teachers', 'html_filter');
$categories_select = $form->addElement('select', 'category_code', get_lang('CourseFaculty'), $categories, array('style' => 'width:350px', 'class'=>'chzn-select', 'id'=>'category_code'));

@ -61,12 +61,13 @@ function get_number_of_courses() {
* Get course data to display
*/
function get_course_data($from, $number_of_items, $column, $direction) {
$course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
$users_table = Database :: get_main_table(TABLE_MAIN_USER);
$course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
$users_table = Database :: get_main_table(TABLE_MAIN_USER);
$course_users_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$sql = "SELECT code AS col0, visual_code AS col1, title AS col2, course_language AS col3, category_code AS col4, subscribe AS col5, unsubscribe AS col6, tutor_name as col7, code AS col8, visibility AS col9,directory as col10
$sql = "SELECT code AS col0, title AS col1, visual_code AS col2, course_language AS col3, category_code AS col4, subscribe AS col5, unsubscribe AS col6,
code AS col7, visibility AS col8, directory as col9
FROM $course_table";
//$sql = "SELECT code AS col0, visual_code AS col1, title AS col2, course_language AS col3, category_code AS col4, subscribe AS col5, unsubscribe AS col6, code AS col7, tutor_name as col8, code AS col9, visibility AS col10,directory as col11 FROM $course_table";
global $_configuration;
if ((api_is_platform_admin() || api_is_session_admin()) && $_configuration['multiple_access_urls'] && api_get_current_access_url_id() != -1) {
@ -100,12 +101,12 @@ function get_course_data($from, $number_of_items, $column, $direction) {
$courses = array ();
while ($course = Database::fetch_row($res)) {
// Place colour icons in front of courses.
//$course[1] = '<nobr>'.get_course_visibility_icon($course[9]).'<a href="'.api_get_path(WEB_COURSE_PATH).$course[9].'/index.php">'.$course[1].'</a></nobr>';
$course[1] = '<nobr>'.get_course_visibility_icon($course[9]).'<a href="'.api_get_path(WEB_COURSE_PATH).$course[10].'/index.php">'.$course[1].'</a></nobr>';
$course[1] = '<nobr>'.get_course_visibility_icon($course[8]).'<a href="'.api_get_path(WEB_COURSE_PATH).$course[9].'/index.php">'.$course[1].'</a></nobr>';
$course[5] = $course[5] == SUBSCRIBE_ALLOWED ? get_lang('Yes') : get_lang('No');
$course[6] = $course[6] == UNSUBSCRIBE_ALLOWED ? get_lang('Yes') : get_lang('No');
$course_rem = array($course[0], $course[1], $course[2], $course[3], $course[4], $course[5], $course[6], $course[7], $course[8]);
$course_rem = array($course[0], $course[1], $course[2], $course[3], $course[4], $course[5], $course[6], $course[7]);
$courses[] = $course_rem;
}
return $courses;
@ -264,16 +265,16 @@ if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
$table->set_additional_parameters($parameters);
$table->set_header(0, '', false, 'width="8px"');
$table->set_header(1, get_lang('Code'));
$table->set_header(2, get_lang('Title'));
$table->set_header(1, get_lang('Title'));
$table->set_header(2, get_lang('Code'));
$table->set_header(3, get_lang('Language'), true, 'width="70px"');
$table->set_header(4, get_lang('Category'));
$table->set_header(5, get_lang('SubscriptionAllowed'), true, 'width="60px"');
$table->set_header(6, get_lang('UnsubscriptionAllowed'), false, 'width="50px"');
//$table->set_header(7, get_lang('IsVirtualCourse'));
$table->set_header(7, get_lang('Teacher'));
$table->set_header(8, get_lang('Action'), false, 'width="150px"');
$table->set_column_filter(8, 'modify_filter');
//$table->set_header(7, get_lang('Teacher'));
$table->set_header(7, get_lang('Action'), false, 'width="150px"');
$table->set_column_filter(7, 'modify_filter');
$table->set_form_actions(array('delete_courses' => get_lang('DeleteCourse')), 'course');
$content .= $table->return_table();
}

@ -268,7 +268,7 @@ if (is_array($extra_field_list)) {
</tr>
<tr>
<td width="40%" align="center">
<select name="UserList[]" multiple="multiple" size="20" style="width:230px;">
<select name="UserList[]" multiple="multiple" size="20" style="width:300px;">
<?php
foreach ($db_users as $user) {
?>
@ -282,7 +282,7 @@ if (is_array($extra_field_list)) {
<button type="submit" class="add" value="<?php echo get_lang('AddToThatCourse'); ?> &gt;&gt;"><?php echo get_lang('AddToThatCourse'); ?></button>
</td>
<td width="40%" align="center">
<select name="CourseList[]" multiple="multiple" size="20" style="width:230px;">
<select name="CourseList[]" multiple="multiple" size="20" style="width:300px;">
<?php
foreach ($db_courses as $course) {
?>

@ -137,9 +137,13 @@ $form->add_textfield('title', get_lang('Title'), true, array('size' => '60'));
$form->applyFilter('title', 'trim');
//$form->add_textfield('tutor_name', get_lang('Professors'), true, array ('size' => '60'));
//the teacher doesn't need to change the trainer only the admin can do that
/*
$prof = &$form->addElement('select', 'tutor_name', get_lang('Teacher'), $a_profs, array('style'=>'width:350px', 'class'=>'chzn-select', 'id'=>'tutor_name'));
$form->applyFilter('tutor_name', 'html_filter');
$prof -> setSelected($s_selected_tutor);
* /
/*$visual_code=$form->addElement('text', 'visual_code', get_lang('Code'));
$visual_code->freeze();
@ -153,7 +157,7 @@ $form->add_textfield('department_name', get_lang('Department'), false, array('si
$form->applyFilter('department_name', 'trim');
$form->add_textfield('department_url', get_lang('DepartmentUrl'), false, array('size' => '60'));
$form->addRule('tutor_name', get_lang('ThisFieldIsRequired'), 'required');
//$form->addRule('tutor_name', get_lang('ThisFieldIsRequired'), 'required');
// Picture
@ -437,6 +441,7 @@ if ($form->validate() && is_settings_editable()) {
}
unset($value);
//visual_code = '".$update_values['visual_code']."',
//tutor_name = '".$update_values['tutor_name']."',
$table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$sql = "UPDATE $table_course SET
title = '".$update_values['title']."',
@ -447,7 +452,6 @@ if ($form->validate() && is_settings_editable()) {
visibility = '".$update_values['visibility']."',
subscribe = '".$update_values['subscribe']."',
unsubscribe = '".$update_values['unsubscribe']."',
tutor_name = '".$update_values['tutor_name']."',
legal = '".$update_values['legal']."',
activate_legal = '".$update_values['activate_legal']."',
registration_code = '".$update_values['course_registration_password']."'

@ -27,19 +27,15 @@ require_once '../inc/global.inc.php';
// Section for the tabs.
$this_section = SECTION_COURSES;
// Include configuration file.
require_once api_get_path(CONFIGURATION_PATH).'add_course.conf.php';
// "Course validation" feature. This value affects the way of a new course creation:
// true - the new course is requested only and it is created after approval;
// false - the new course is created immedialely, after filling this form.
$course_validation_feature = api_get_setting('course_validation') == 'true';
// Require additional libraries.
require_once api_get_path(LIBRARY_PATH).'add_course.lib.inc.php';
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
require_once api_get_path(CONFIGURATION_PATH).'course_info.conf.php';
if ($course_validation_feature) {
require_once api_get_path(LIBRARY_PATH).'course_request.lib.php';
require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
@ -96,8 +92,6 @@ $form->addElement('text', 'title', array(get_lang('CourseName'), get_lang('Ex'))
$form->applyFilter('title', 'html_filter');
$form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
$form -> addElement('html','<div class="row">
<div class="label">&nbsp;</div>
<div class="formw">
@ -144,11 +138,11 @@ if ($course_validation_feature) {
}
// Course language.
$form->addElement('select_language', 'course_language', get_lang('Ln'), null, null, array('id' => 'lang_id'));
$form->addElement('select_language', 'course_language', get_lang('Ln'), array(), array('style'=>'width:150px'));
$form->applyFilter('select_language', 'html_filter');
// Exemplary content checkbox.
$form->addElement('checkbox', 'exemplary_content', get_lang('FillWithExemplaryContent'));
$form->addElement('checkbox', 'exemplary_content', null, get_lang('FillWithExemplaryContent'));
if ($course_validation_feature) {
@ -212,10 +206,10 @@ if ($form->validate()) {
$exemplary_content = !empty($course_values['exemplary_content']);
if ($course_validation_feature) {
$description = $course_values['description'];
$objetives = $course_values['objetives'];
$description = $course_values['description'];
$objetives = $course_values['objetives'];
$target_audience = $course_values['target_audience'];
$status = '0';
$status = '0';
}
if ($wanted_code == '') {
@ -233,10 +227,11 @@ if ($form->validate()) {
if (!$course_validation_feature) {
$params = array();
$params['title'] = $title;
$params['exemplary_content'] = $exemplary_content;
$params['wanted_code'] = $wanted_code;
$params['tutor_name'] = $tutor_name;
//$params['tutor_name'] = $tutor_name;
$params['category_code'] = $category_code;
$params['course_language'] = $course_language;

@ -2063,7 +2063,7 @@ function fill_course_repository($course_repository, $fill_with_exemplary_content
if ($fill_with_exemplary_content) {
$img_code_path = api_get_path(SYS_CODE_PATH).'default_course_document/images/';
$img_code_path = api_get_path(SYS_CODE_PATH).'default_course_document/images/';
$audio_code_path = api_get_path(SYS_CODE_PATH).'default_course_document/audio/';
$flash_code_path = api_get_path(SYS_CODE_PATH).'default_course_document/flash/';
$video_code_path = api_get_path(SYS_CODE_PATH).'default_course_document/video/';
@ -2245,8 +2245,7 @@ function fill_Db_course($course_id, $course_repository, $language, $default_docu
$TABLETOOLANNOUNCEMENTS = Database::get_course_table(TABLE_ANNOUNCEMENT);
$TABLEADDEDRESOURCES = Database::get_course_table(TABLE_LINKED_RESOURCES);
$TABLETOOLWORKS = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
//table not found
//$TABLETOOLWORKSUSER = Database::get_course_table(TABLE_TOOL_LIST)$course_db_name . 'stud_pub_rel_user';
$TABLETOOLDOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
$TABLETOOLWIKI = Database::get_course_table(TABLE_WIKI);
@ -2268,6 +2267,7 @@ function fill_Db_course($course_id, $course_repository, $language, $default_docu
include api_get_path(SYS_CODE_PATH) . 'lang/english/create_course.inc.php';
$file_to_include = 'lang/'.$language . '/create_course.inc.php';
if (file_exists($file_to_include)) {
include api_get_path(SYS_CODE_PATH) . $file_to_include;
}
@ -2719,19 +2719,23 @@ function register_course($params) {
$sort = api_max_sort_value('0', api_get_user_id());
$i_course_sort = CourseManager :: userCourseSort($user_id, $code);
$sql = "INSERT INTO ".$TABLECOURSUSER . " SET
course_code = '".Database :: escape_string($code). "',
user_id = '".intval($user_id) . "',
status = '1',
role = '".lang2db(get_lang('Professor')) . "',
tutor_id = '0',
sort = '". ($i_course_sort) . "',
user_course_cat = '0'";
Database::query($sql);
if (!empty($user_id)) {
$sql = "INSERT INTO ".$TABLECOURSUSER . " SET
course_code = '".Database :: escape_string($code). "',
user_id = '".intval($user_id) . "',
status = '1',
role = '".lang2db(get_lang('Professor')) . "',
tutor_id = '0',
sort = '". ($i_course_sort) . "',
user_course_cat = '0'";
Database::query($sql);
}
if (!empty($teachers)) {
foreach ($teachers as $key) {
//just in case
if ($key == $user_id) {
continue;
}
if (empty($key)) {
continue;
}

@ -116,7 +116,7 @@ $coursesRepositories = $_configuration['root_sys'];
*/
class CourseManager {
var $columns = array('code', 'directory', 'db_name', '');
var $columns = array();
/**

@ -1145,6 +1145,7 @@ function api_get_course_info($course_code = null) {
// The real_id is an integer. It is mandatory for future implementations.
$_course['real_id' ] = $course_data['id' ];
$_course['course_language'] = $course_data['course_language'];
}
return $_course;
}
@ -1190,6 +1191,7 @@ function api_get_course_info_by_id($id = null) {
$_course['language' ] = $course_data['course_language'];
$_course['extLink' ]['url' ] = $course_data['department_url' ];
$_course['extLink' ]['name'] = $course_data['department_name'];
$_course['categoryCode' ] = $course_data['faCode' ];
$_course['categoryName' ] = $course_data['faName' ];
@ -1199,6 +1201,7 @@ function api_get_course_info_by_id($id = null) {
$_course['real_id' ] = $course_data['id' ];
$_course['title' ] = $course_data['title' ];
$_course['course_language'] = $course_data['course_language'];
}
return $_course;

Loading…
Cancel
Save