'index.php',"name" => get_lang('PlatformAdmin')); Display::display_header($tool_name); /* ============================================================================== DISPLAY FUNCTIONS ============================================================================== */ function make_strong($text) { return "" . $text . ""; } /** * Return a list of language directories. * @todo function does not belong here, move to code library, * also see infocours.php and index.php which contain a similar function */ function get_language_folder_list($dirname) { if($dirname[strlen($dirname)-1]!='/') $dirname.='/'; $handle=opendir($dirname); while ($entries = readdir($handle)) { if ($entries=='.' || $entries=='..' || $entries=='CVS') continue; if (is_dir($dirname.$entries)) { $language_list[] = $entries; } } closedir($handle); return $language_list; } /** * Displays a select element (drop down menu) so the user can select * the course language. * @todo function does not belong here, move to (display?) library, * @todo language display used apparently no longer existing array, converted to english for now. * but we should switch to display the real language names. */ function display_language_select($element_name) { global $platformLanguage; //get language list $dirname = api_get_path(SYS_PATH)."main/lang/"; $language_list = get_language_folder_list($dirname); sort($language_list); //build array with strings to display foreach ($language_list as $this_language) { $language_to_display[$this_language] = $this_language; } //sort alphabetically //warning: key,value association needs to be maintained --> asort instead of sort asort($language_to_display); $user_selected_language = $_SESSION["user_language_choice"]; if (! isset($user_selected_language) ) $user_selected_language = $platformLanguage; //display echo ""; } /** * This code creates a select form element to let the user * choose a real course to link to. * * We display the course code, but internally store the course id. */ function display_real_course_code_select($element_name) { $real_course_list = CourseManager::get_real_course_list(); echo "\n"; } function display_create_virtual_course_form() { global $charset; $category_table = Database::get_main_table(TABLE_MAIN_CATEGORY); $message = make_strong(get_lang('AdminCreateVirtualCourse')) . "
" . get_lang('AdminCreateVirtualCourseExplanation') . "
This feature is in development phase, bug reports welcome."; ?>

"; echo ""; echo "
".get_lang('Ex') ; ?>
"; $sql_query = "SELECT code, name FROM $category_table WHERE auth_course_child ='TRUE' ORDER BY tree_pos"; $category_result = api_sql_query($sql_query, __FILE__, __LINE__); while ($current_category = mysql_fetch_array($category_result)) { echo "\n"; } ?>

" . get_lang('Max'); ?>
"; ?>
  • ".get_lang('CreateVirtualCourse')."
  • "; $message .= "
  • ".get_lang('DisplayListVirtualCourses')."
  • "; echo $message; } function display_virtual_course_list() { $course_list = CourseManager::get_virtual_course_list(); if (! is_array($course_list) ) { //there are no virtual courses echo "".get_lang('ThereAreNoVirtualCourses').""; return; } $column_header[] = array(get_lang('Title'),true); $column_header[] = array(get_lang('Code'),true); $column_header[] = array(get_lang('VisualCode'),true); $column_header[] = array(get_lang('LinkedCourseTitle'),true); $column_header[] = array(get_lang('LinkedCourseCode'),true); $table_data = array(); for($i = 0; $i < count($course_list); $i++) { $course_list[$i] = Database::generate_abstract_course_field_names($course_list[$i]); $target_course_code = $course_list[$i]["target_course_code"]; $real_course_info = Database::get_course_info($target_course_code); $row = array(); $row[] = $course_list[$i]["title"]; $row[] = $course_list[$i]["system_code"]; $row[] = $course_list[$i]["visual_code"]; $row[] = $real_course_info["title"]; $row[]= $real_course_info["system_code"]; $table_data[] = $row; } Display::display_sortable_table($column_header,$table_data,array(),array(),array('action'=>$_GET['action'])); } /* ============================================================================== TOOL LOGIC FUNCTIONS ============================================================================== */ /** * Checks all parameters needed to create a virtual course. * If they are all set, the virtual course creation procedure is called. * Call this function instead of create_virtual_course */ function attempt_create_virtual_course($real_course_code, $course_title, $wanted_course_code, $course_language, $course_category) { //better: create parameter list, check the entire list, when false display errormessage CourseManager::check_parameter_or_fail($real_course_code, "Unspecified parameter: real course id."); CourseManager::check_parameter_or_fail($course_title, "Unspecified parameter: course title."); CourseManager::check_parameter_or_fail($wanted_course_code, "Unspecified parameter: wanted course code."); CourseManager::check_parameter_or_fail($course_language, "Unspecified parameter: course language."); CourseManager::check_parameter_or_fail($course_category, "Unspecified parameter: course category."); $message = get_lang('AttemptedCreationVirtualCourse') . "
    "; $message .= get_lang('CourseTitle') . " " . $course_title . "
    "; $message .= get_lang('WantedCourseCode') . " " . $wanted_course_code . "
    "; $message .= get_lang('CourseLanguage') . " " . $course_language . "
    "; $message .= get_lang('CourseFaculty') . " " . $course_category . "
    "; $message .= get_lang('LinkedToRealCourseCode') . " " . $real_course_code . "
    "; Display::display_normal_message($message); $creation_success = CourseManager::create_virtual_course( $real_course_code, $course_title, $wanted_course_code, $course_language, $course_category ); if ($creation_success == true) { Display::display_normal_message( $course_title . " - " . get_lang('CourseCreationSucceeded') ); return true; } return false; } /* ============================================================================== MAIN CODE ============================================================================== */ $action = $_GET["action"]; $attempt_create_virtual_course = $_POST["submit_create_virtual_course"]; //api_display_tool_title($tool_name); if ( isset($attempt_create_virtual_course) && $attempt_create_virtual_course ) { $real_course_code = $_POST[REAL_COURSE_SELECT_FORM_NAME]; $course_title = $_POST[COURSE_TITLE_FORM_NAME]; $wanted_course_code = $_POST[WANTED_COURSE_CODE_FORM_NAME]; $course_language = $_POST[LANGUAGE_SELECT_FORM_NAME]; $course_category = $_POST[COURSE_CATEGORY_FORM_NAME]; $message = get_lang('AttemptedCreationVirtualCourse') . "
    "; $message .= get_lang('CourseTitle') . " " . $course_title . "
    "; $message .= get_lang('WantedCourseCode') . " " . $wanted_course_code . "
    "; $message .= get_lang('CourseLanguage') . " " . $course_language . "
    "; $message .= get_lang('CourseFaculty') . " " . $course_category . "
    "; $message .= get_lang('LinkedToRealCourseCode') . " " . $real_course_code . "
    "; Display::display_normal_message($message); $creation_success = CourseManager::attempt_create_virtual_course($real_course_code, $course_title, $wanted_course_code, $course_language, $course_category); if ($creation_success == true) { Display::display_normal_message( $course_title . " - " . get_lang('CourseCreationSucceeded') ); } else { //should display error message } echo "
    "; } display_main_options(); switch($action) { case CREATE_VIRTUAL_COURSE_OPTION: display_create_virtual_course_form(); break; case DISPLAY_VIRTUAL_COURSE_LIST_OPTION: display_virtual_course_list(); break; } /* ============================================================================== FOOTER ============================================================================== */ Display::display_footer(); ?>