Source for file course_virtual.php
Documentation is available at course_virtual.php
<?php // $Id: course_virtual.php 12272 2007-05-03 14:40:45Z elixir_julian $
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2005 Dokeos S.A.
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) Roan Embrechts (Vrije Universiteit Brussel)
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
==============================================================================
==============================================================================
* @author Roan Embrechts - initial admin interface
==============================================================================
==============================================================================
==============================================================================
// name of the language file that needs to be included
$language_file = 'admin';
$extra_lang_file = "create_course";
// global settings initialisation
// also provides access to main api (inc/lib/main_api.lib.php)
include("../inc/global.inc.php");
if (isset ($extra_lang_file)) include(api_get_path(INCLUDE_PATH). "../lang/english/". $extra_lang_file. ".inc.php");
if (isset ($extra_lang_file)) include(api_get_path(INCLUDE_PATH). "../lang/". $language_interface. "/". $extra_lang_file. ".inc.php");
-----------------------------------------------------------
-----------------------------------------------------------
include_once(api_get_path(LIBRARY_PATH) . 'course.lib.php');
-----------------------------------------------------------
-----------------------------------------------------------
define ("CREATE_VIRTUAL_COURSE_OPTION", "create_virtual_course");
define ("DISPLAY_VIRTUAL_COURSE_LIST_OPTION", "display_virtual_course_list");
define ("FORM_ELEMENT_CODE_SIZE", "20");
define ("FORM_ELEMENT_TEXT_SIZE", "60");
define ("SELECT_BOX_SIZE", "10");
define ("COURSE_TITLE_FORM_NAME", "course_title");
define ("LANGUAGE_SELECT_FORM_NAME" , "course_language");
define ("REAL_COURSE_SELECT_FORM_NAME" , "real_course_code");
define ("WANTED_COURSE_CODE_FORM_NAME" , "wanted_course_code");
define ("COURSE_CATEGORY_FORM_NAME" , "course_category");
-----------------------------------------------------------
-----------------------------------------------------------
$tool_name = get_lang('AdminManageVirtualCourses'); // title of the page (should come from the language file)
$interbreadcrumb[]= array('url' => 'index.php',"name" => get_lang('PlatformAdmin'));
==============================================================================
==============================================================================
return "<strong>" . $text . "</strong>";
* 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
if($dirname[strlen($dirname)- 1]!= '/') $dirname.= '/';
while ($entries = readdir($handle))
if ($entries== '.' || $entries== '..' || $entries== 'CVS') continue;
if (is_dir($dirname. $entries))
$language_list[] = $entries;
* Displays a select element (drop down menu) so the user can select
* @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.
global $platformLanguage;
//build array with strings to display
foreach ($language_list as $this_language)
$language_to_display[$this_language] = $this_language;
//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;
echo "<select name=\"$element_name\">";
foreach ($language_to_display as $key => $value)
if ($key == $user_selected_language) $option_end = "selected >";
echo "<option value=\"$key\" $option_end";
* 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.
foreach($real_course_list as $real_course)
$course_code = $real_course["code"];
echo "<option value=\"". $course_code . "\">";
$message = make_strong(get_lang('AdminCreateVirtualCourse')) . "<br/>" . get_lang('AdminCreateVirtualCourseExplanation') . "<br/>This feature is in development phase, bug reports welcome.";
<p> <?php echo $message; ?></p>
<b> <?php echo get_lang('MandatoryFields') ?></b>
echo "<td valign=\"top\">";
$sql_query = "SELECT code, name
WHERE auth_course_child ='TRUE'
$category_result = api_sql_query($sql_query, __FILE__ , __LINE__ );
echo "<option value=\"", $current_category["code"], "\"";
echo ">(", $current_category["code"], ") ", $current_category["name"];
//echo "<input type=\"Text\" name=\"real_course_code\" maxlength=\"".FORM_ELEMENT_CODE_SIZE."\" value=\"" . htmlentities($valueTitular) . "\"/>";
<input type="Submit" name="submit_create_virtual_course" value=" <?php echo get_lang('Ok')?>"/>
//there are no virtual courses
echo "<i>". get_lang('ThereAreNoVirtualCourses'). "</i>";
$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);
for($i = 0; $i < count($course_list); $i++ )
$target_course_code = $course_list[$i]["target_course_code"];
$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"];
==============================================================================
==============================================================================
* 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
//better: create parameter list, check the entire list, when false display errormessage
$message = get_lang('AttemptedCreationVirtualCourse') . "<br/>";
$message .= get_lang('CourseTitle') . " " . $course_title . "<br/>";
$message .= get_lang('WantedCourseCode') . " " . $wanted_course_code . "<br/>";
$message .= get_lang('CourseLanguage') . " " . $course_language . "<br/>";
$message .= get_lang('CourseFaculty') . " " . $course_category . "<br/>";
$message .= get_lang('LinkedToRealCourseCode') . " " . $real_course_code . "<br/>";
if ($creation_success == true)
==============================================================================
==============================================================================
$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 )
$message = get_lang('AttemptedCreationVirtualCourse') . "<br/>";
$message .= get_lang('CourseTitle') . " " . $course_title . "<br/>";
$message .= get_lang('WantedCourseCode') . " " . $wanted_course_code . "<br/>";
$message .= get_lang('CourseLanguage') . " " . $course_language . "<br/>";
$message .= get_lang('CourseFaculty') . " " . $course_category . "<br/>";
$message .= get_lang('LinkedToRealCourseCode') . " " . $real_course_code . "<br/>";
if ($creation_success == true)
//should display error message
==============================================================================
==============================================================================
|