official_update_titles_teachers.php from pointcarre at Krugle
Show official_update_titles_teachers.php syntax highlighted
<?php // $Id: official_update_titles_teachers.php 396 2006-09-18 09:30:43Z evie_em $
/*
==============================================================================
Dokeos - elearning and course management software
Pointcarre - variant of Dokeos
Copyright (c) Roan Embrechts (Vrije Universiteit Brussel, VUB)
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.
http://pointcarre.sourceforge.net/
http://www.dokeos.com/
==============================================================================
*/
/**
==============================================================================
* Curriculum administration tool
*
* @package dokeos.admin.curriculum
* @author Roan Embrechts
==============================================================================
*/
/*
==============================================================================
INIT SECTION
==============================================================================
*/
// name of the language file which needs to be included
// 'inc.php' is automatically appended to the file name
$langFile = "admin";
// global settings initialisation
// also provides access to main api (inc/lib/main_api.lib.php)
include("../inc/claro_init_global.inc.php");
api_protect_admin_script();
/*
-----------------------------------------------------------
Constants
-----------------------------------------------------------
*/
define("VUB", "VUB");
define("CHECK_TITLES", "check_titles");
define("CHECK_TEACHER_RIGHTS","check_teacher_rights");
/*
-----------------------------------------------------------
Included libraries
-----------------------------------------------------------
*/
require_once(api_get_library_path()."/course.lib.php");
require_once('../curriculum/curriculum_database.lib.php');
require_once('../curriculum/curriculum_logic.lib.php');
/*
-----------------------------------------------------------
Header
-----------------------------------------------------------
*/
//extra entries in breadcrumb
$interbredcrump[]=array("url" => $rootAdminWeb,"name" => get_lang("AdministrationTools"));
$nameTools = "VUB cursustitels updaten"; // title of the page (should come from the language file)
include(api_get_include_path()."/claro_init_header.inc.php");
/*
==============================================================================
DATABASE AND LOGIC FUNCTIONS
==============================================================================
*/
/**
*/
function check_titles_to_update()
{
global $PHP_SELF;
$course_list = Database::get_course_list();
$count = 0;
foreach($course_list as $course)
{
//print_r($course);
$tool_table = Database::get_course_tool_list_table($course["db_name"]);
$visual_course_code = $course["visual_code"];
$dokeos_course_code = $course["code"];
//cut first three characters
$vub_start = substr($visual_course_code, 0, 3);
$vub_oocode = substr($visual_course_code, 3, strlen($visual_course_code));
$dokeos_course_title = $course["title"];
//only work with VUB courses
if ($vub_start == VUB)
{
$aiv_course_title = CurriculumDatabase::get_official_course_title($vub_oocode);
$official_course_title = $aiv_course_title;
if ($official_course_title == "") continue;
if ($dokeos_course_title != $aiv_course_title)
{
$count++;
$message .= $visual_course_code . " (system code $dokeos_course_code) <br/>";
$message .= "Dokeos title: " . $dokeos_course_title . "<br/>";
$message .= "AIV title: " . $aiv_course_title . "<br/>";
//$message .= "<a href=" . $PHP_SELF . "?update_one_title=true&dokeos_course_code=".$dokeos_course_code.">Update title</a><br/><br/>";
$message .= "<em>Titel aangepast.</em>";
update_one_title($dokeos_course_code);
}
}
}
echo "<p>Er zijn $count cursussen met gewijzigde titels.</p>";
echo '<p>' . $message . '</p>';
}
function update_one_title($dokeos_course_code)
{
$course_info = Database::get_course_info($dokeos_course_code);
$visual_course_code = $course_info["visual_code"];
$vub_start = substr($visual_course_code, 0, 3);
$vub_oocode = substr($visual_course_code, 3, strlen($visual_course_code));
$dokeos_course_title = $course_info["title"];
//only work with official courses, these start with "VUB"
if ($vub_start == VUB)
{
$official_course_title = CurriculumDatabase::get_official_course_title($vub_oocode);
if ($dokeos_course_title != $official_course_title)
{
$message .= "Updating course " . $visual_course_code . " <br/>";
$message .= "from <i>" . $dokeos_course_title . "</i> ";
$message .= "to <i>" . $official_course_title . "</i><br/>";
if (isset($official_course_title) && $official_course_title != "")
{
$official_course_title = addslashes($official_course_title);
Database::update_course_title($dokeos_course_code, $official_course_title);
}
}
}
echo '<p>' . $message . '</p>';
}
/*
==============================================================================
DISPLAY FUNCTIONS
==============================================================================
*/
function display_main_options()
{
echo "The current academic year is set to " . CurriculumLogic::get_current_academic_year() . ".<br/>";
$message = "Deze pagina doet twee zaken: (a) vergelijkt de titels van officiële VUB cursussen in Dokeos met hun titels in de AIV databank,"
. " en (b) kijkt na of de officiële titularissen wel cursusbeheerdersrechten hebben in hun cursussen.<br/>"
. "<a href=\"$PHP_SELF?action=".CHECK_TITLES."\">Klik hier om te zoeken naar te updaten titels.</a><br/>"
. "<a href=\"$PHP_SELF?action=".CHECK_TEACHER_RIGHTS."\">Klik hier om te zoeken naar te updaten titularissen.</a>"
;
echo "<p>" . $message . "</p>";
}
/*
==============================================================================
MAIN CODE
==============================================================================
*/
$action = $_GET["action"];
$update_one_title = $_GET["update_one_title"];
$dokeos_course_code = $_GET["dokeos_course_code"];
$minimum = $_REQUEST["min"];
$maximum = $_REQUEST["max"];
api_display_tool_title($nameTools);
display_main_options();
if ( isset($update_one_title) && ($update_one_title) )
{
update_one_title($dokeos_course_code);
check_titles_to_update();
}
if ( $action == CHECK_TITLES )
{
check_titles_to_update();
}
else if ( $action == CHECK_TEACHER_RIGHTS)
{
CurriculumLogic::display_and_update_teacher_course_status_list();
}
/*
==============================================================================
FOOTER
==============================================================================
*/
include(api_get_include_path()."/claro_init_footer.inc.php");
?>
See more files for this project here