Code Search for Developers
 
 
  

manage_official_teachers.php from pointcarre at Krugle


Show manage_official_teachers.php syntax highlighted

<?php // $Id: manage_official_teachers.php 401 2006-09-20 09:00:25Z evie_em $
/*
==============================================================================
	Dokeos - elearning and course management software
	Pointcarre - variant of Dokeos

	Copyright (c) Roan Embrechts

	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/
==============================================================================
*/
/**
==============================================================================
* Script to deal with official teachers, those appearing in the
* curriculum databases of the university.
* 
* @package dokeos.admin
==============================================================================
*/
/*
==============================================================================
		INIT SECTION
==============================================================================
*/ 

$langFile='admin';

$cidReset=true;

include('../inc/claro_init_global.inc.php');
api_protect_admin_script();

/*
-----------------------------------------------------------
	Libraries
-----------------------------------------------------------
*/
require_once(api_get_configuration_path()."/add_course.conf.php");
require_once(api_get_library_path()."/add_course.lib.inc.php");
require_once(api_get_library_path()."/fileManage.lib.php");

require_once(api_get_library_path()."/course.lib.php");
require_once('../curriculum/curriculum_database.lib.php');
require_once('../curriculum/curriculum_logic.lib.php');

/*
-----------------------------------------------------------
	Constants
-----------------------------------------------------------
*/
define ("SEE_TEACHER_LIST", "see_teacher_list");
define ("UPDATE_TEACHER_LIST_DISPLAY_OPTIONS", "update_teacher_list_display_options");
define ("UPDATE_TEACHER_LIST", "update_teacher_list");
define ("UPDATE_ASSISTANT_TEACHER_LIST", "update_assistant_teacher_list");
define ("VIEW_SPECIFIC_TEACHER_COURSES", "view_specific_teacher_courses");
define ("CREATE_ONE_OFFICIAL_COURSE", "create_one_official_course");
define("SEE_ALL_TEACHER_ALL_COURSE_LIST", "see_all_teacher_all_course_list");
define("CREATE_COURSES_THAT_DONT_EXIST_YET", "create_non_existing_courses");

/*
-----------------------------------------------------------
	Header
-----------------------------------------------------------
*/
$tool_name = get_lang("ManageTeachersOfficialCurriculum");
$interbredcrump[] = array ("url" => "index.php", "name" => get_lang('AdministrationTools'));
Display::display_header($tool_name);
api_display_tool_title($tool_name);

/*
==============================================================================
		DISPLAY FUNCTIONS
==============================================================================
*/ 

function display_main_options()
{
	echo "The current academic year is set to " . CurriculumLogic::get_current_academic_year() . ". ";
	echo 'What do you want to do?';
	echo '<ul>';
	echo '<li><a href="'.$_SERVER['PHP_SELF'].'?action='.SEE_TEACHER_LIST.'">See a list of official teachers</a></li>';
	echo '<li><a href="'.$_SERVER['PHP_SELF'].'?action='.UPDATE_TEACHER_LIST_DISPLAY_OPTIONS.'">Update the list of official teachers in Pointcarr&#233;</a></li>';
	echo '<li><a href="'.$_SERVER['PHP_SELF'].'?action='.UPDATE_ASSISTANT_TEACHER_LIST.'">Update the list of additional "assistant" teachers (activities table) in Pointcarr&#233;</a></li>';
	echo '<li><a href="'.$_SERVER['PHP_SELF'].'?action='.SEE_ALL_TEACHER_ALL_COURSE_LIST.'">See a list of all official teachers and their official courses</a></li>';
	echo '<li><a href="'.$_SERVER['PHP_SELF'].'?action='.CREATE_COURSES_THAT_DONT_EXIST_YET.'">Create all official courses that don\'t exist yet.</a></li>';
	echo '</ul>';
}

function display_official_teacher_list()
{
	$min = 0; $max = 1500;
	$result_array = CurriculumDatabase::get_official_teacher_info_list($min, $max);
	
	/*for ($i = 0; $i < count($result_array); $i++)
	{<a href="../../../v1-pointcarre-stable/claroline/admin/curriculum/vub-titularis.php"></a>
		print_r($result_array[$i]); echo '<br/>';
	}*/
	
	$row = 0;
	$column_header[$row ++] = "teacher code";
	$column_header[$row ++] = "personnel code";
	$column_header[$row ++] = "last name";
	$column_header[$row ++] = "first name";
	$column_header[$row ++] = "view/update courses";
	$properties["width"] = "100%";
	$properties["cellspacing"] = "1";
	
	Display :: display_complex_table_header($properties, $column_header);
	for ($i = 0; $i < count($result_array); $i++)
	{
		$teacher_code = $result_array[$i][0];
		$personnel_code = $result_array[$i][1];
		
		$row = 0;
		$table_row[$row ++] = $teacher_code;
		$table_row[$row ++] = $personnel_code;
		$table_row[$row ++] = $result_array[$i][$row -1];
		$table_row[$row ++] = $result_array[$i][$row -1];
		$table_row[$row ++] = 	$column_header[$row ++] = '<a href="'.$_SERVER['PHP_SELF'].'?action='.VIEW_SPECIFIC_TEACHER_COURSES.'&personnel_code='.$personnel_code.'&teacher_code='.$teacher_code.'">view/update courses</a>';

		Display :: display_table_row($bgcolor, $table_row, true);
	}
	Display :: display_table_footer();
}

/**
* Displays list of all courses connected to a certain teacher.
* reused code from official courses management page of teacher
*
* @todo: link to course dir now uses $rootWeb, convert to api_get_path
*/
function display_list_official_courses_of_specific_teacher($personnel_code, $teacher_code)
{
	$courses_directory = api_get_path(WEB_COURSE_PATH);
	$official_course_table = CurriculumDatabase::get_vub_course_table();
	$teacher_user_id = CurriculumDatabase::get_user_id_number_from_personnel_code($personnel_code);
	if ( isset($teacher_user_id) && $teacher_user_id ) $teacher_exists = true;
	else $teacher_exists = false;
	
	
	$sql_query = "SELECT * FROM " . $official_course_table . " WHERE `titcode` = '".$teacher_code."'";
	$sql_result = api_sql_query($sql_query, __FILE__, __LINE__);
	
	echo "\n<h3>".get_lang("ListOfVubCourses")."</h3>\n";
	
	if ($teacher_code == "0")
	{
		echo "<i>Er zijn geen cursussen gevonden waarvoor u officieel geregistreerd bent als lesgever.</i>\n";
		return;
	}
	
	if ($personnel_code == "0")
	{
		echo "<i>U bent officieel niet geregistreerd als lesgever aan de VUB.</i>\n";
		return;
	}
	
	$bgcolor = Display::display_table_header();
	while ($result = mysql_fetch_array($sql_result))
	{
		$oocode = $result["oocode"];
		$oonaam = $result["naam"];
		$oojaar = $result["oojaar"];
		$studiepunten = $result["sp"];
		$faculty_code = $result["faculteit_afkorting"];
		
		if (CurriculumLogic::course_year_too_old($oojaar)) continue;
		
		if ($bgcolor == "bgcolor='white'") $bgcolor = "bgcolor='".DOKEOSLIGHTGREY."'";
		else if ($bgcolor == "bgcolor='".DOKEOSLIGHTGREY."'") $bgcolor = "bgcolor='white'";	

		$course_exists = CurriculumDatabase::is_course_created($oocode);
		$course_url = $courses_directory . CurriculumDatabase::get_course_directory($oocode) . "/index.php";
		
		if ( !$course_exists )
		{
			//course does not exist yet
			echo	"<tr>\n\n<td valign='top' $bgcolor>\n\n<b>$oonaam</b><br>" . 
			"oocode $oocode, faculteit $faculteit_afkorting, ",
			"$studiepunten studiepunten, academiejaar $oojaar</p></td>\n";
				
			echo "<td valign='top' $bgcolor><i>". get_lang("CourseNotActivated") . "</i>";
			echo '<form method="post" action="'.$_SERVER['PHP_SELF'].'">';
			echo '<input type="hidden" name="teacher_user_id" value="'.$teacher_user_id.'">';
			echo '<input type="hidden" name="personnel_code" value="'.$personnel_code.'">';
			echo '<input type="hidden" name="teacher_code" value="'.$teacher_code.'">';
			echo '<input type="hidden" name="course_code" value="'.$oocode.'">';
			echo '<input type="hidden" name="faculty_code" value="'.$faculty_code.'">';
			if ($teacher_exists)
			{
				echo '<br><input name="'.CREATE_ONE_OFFICIAL_COURSE.'" type="submit" value="'.get_lang("ActivateCourse").'">';
			}
			else
			{
				echo "<i>It cannot be activated because the teacher does not yet exist in Dokeos.</i>";
			}
			echo "</form></td>\n";
			echo "<td valign='top' $bgcolor></td>\n";
		}
		else
		{
			//course exists
			$dokeos_course_code = CurriculumDatabase::get_dokeos_vub_course_code($oocode);
			$is_virtual_course = CourseManager::is_virtual_course_from_visual_code($dokeos_course_code);
			
			echo	"<tr>\n\n<td valign='top' $bgcolor><a href='$course_url'>\n\n<b>$oonaam</b></a><br>" . 
			"oocode $oocode, faculteit $faculteit_afkorting, ",
			"$studiepunten studiepunten, academiejaar $oojaar</p></td>\n";
			
			echo "<td valign='top' $bgcolor><i>" . get_lang("CourseAlreadyActivated") . "</i></td>\n";
			
			if ($is_virtual_course)
			{
				$virtual_course_info = Database::get_course_info_from_code($dokeos_course_code);
				$virtual_course_id = $virtual_course_info["course_id"];
				$target_course_id = $virtual_course_info["target_course_id"];
				$real_course_info = Database::get_course_info_from_id($target_course_id);
				
				echo "<td valign='top' $bgcolor>" . get_lang("ThisIsVirtualCourseMessage") . "<i>" . $real_course_info["title"] . "</i> (" . $real_course_info["official_code"] . "). " . get_lang("CoursesShareStorageSpace");
				
				$break_link_html = "<form method=\"post\" action=\"$PHP_SELF\">";
				$break_link_html .= get_lang("DeleteVirtualCourseInfo");
				$break_link_html .= "<input type=\"hidden\" name=\"virtual_course_id\" value=\"$virtual_course_id\"";
				$break_link_html .= "<input name=\"delete_virtual_course\"  type=\"submit\" value=\"".get_lang("UnlinkVirtualCourse")."\" >";
				$break_link_html .= "</form>";
				echo $break_link_html;
				
				echo "</td>\n";
			}
			else
			{
				$course_link_html  = "<td valign='top' $bgcolor>" . get_lang("LinkCourseToAnotherCourse") . ": ";
				$course_link_html .= "<form method=\"post\" action=\"$PHP_SELF\">";
				$course_link_html .=
				//$user_id = api_get_user_id();
				CourseManager::get_real_course_code_select_html(REAL_COURSE_SELECT_FORM_NAME, false, true, $teacher_user_id);
				$course_link_html .= "<input type=\"hidden\" name=\"dokeos_course_code\" value=\"$dokeos_course_code\"";
				$course_link_html .= "<input name=\"combine_two_courses\"  type=\"submit\" value=\"".get_lang("DoLinkCourse")."\" >";
				$course_link_html .= "</form>";
				$course_link_html .= "</td>\n";
				echo $course_link_html;
			}
		}
		//echo "<td valign='top' $bgcolor>Samenvoegen met andere cursus: </td>"
		echo "</tr>\n";
	}
	Display::display_table_footer();
}


/**
* Display a number of links to add the official teachers to the Dokeos database.
*/
function update_teacher_list_display_options()
{
	echo '<ul>';
	echo '<li><a href="'.$_SERVER['PHP_SELF'].'?action='.UPDATE_TEACHER_LIST.'&min=0&max=600&is_simulation=true">Add teachers 0 - 500 to Dokeos (simulation)</a> - <a href="'.$_SERVER['PHP_SELF'].'?action='.UPDATE_TEACHER_LIST.'&min=0&max=600&is_simulation=false">Add teachers 0 - 500 to Dokeos (real changes)</a></li>';
	echo '<li><a href="'.$_SERVER['PHP_SELF'].'?action='.UPDATE_TEACHER_LIST.'&min=601&max=1200&is_simulation=true">Add teachers 501 - 1000 to Dokeos (simulation)</a> - <a href="'.$_SERVER['PHP_SELF'].'?action='.UPDATE_TEACHER_LIST.'&min=601&max=1200&is_simulation=false">Add teachers 501 - 1000 to Dokeos (real changes)</a></li>';
	echo '<li><a href="'.$_SERVER['PHP_SELF'].'?action='.UPDATE_TEACHER_LIST.'&min=1201&max=1800&is_simulation=true">Add teachers 1001 - 1500 to Dokeos (simulation)</a> - <a href="'.$_SERVER['PHP_SELF'].'?action='.UPDATE_TEACHER_LIST.'&min=1201&max=1800&is_simulation=false">Add teachers 1001 - 1500 to Dokeos (real changes)</a></li>';
	echo '</ul>';
}


/**
* Display a list of teachers that are in the official database
* but not yet in the Dokeos user table.
*/
function display_list_official_teachers_not_in_dokeos()
{
	Display::display_error_message("The function display_list_official_teachers_not_in_dokeos() is not implemented yet.");
}


/**
* Display a list of teachers that are in the official database
* but not yet in the Dokeos user table.
*/
function display_all_teacher_all_course_list($minimum, $maximum)
{
	$official_teacher_list = CurriculumDatabase::get_official_teacher_info_list($minimum, $maximum);
	
	$number_of_courses_can_be_created = 0;
	
	//for all teachers...
	for ($i = 0; $i < count($official_teacher_list); $i++)
	{
		$teacher_code = $official_teacher_list[$i][0];
		$personnel_code = $official_teacher_list[$i][1];
		$last_name = $official_teacher_list[$i][2];
		$first_name = $official_teacher_list[$i][3];
		
		$teacher_user_id = CurriculumDatabase::get_user_id_number_from_personnel_code($personnel_code);
		if ( isset($teacher_user_id) && $teacher_user_id ) $teacher_exists = true;
		else $teacher_exists = false;
		
		echo "<p>";
		//one line of info about the teacher
		echo $last_name . ', ' . $first_name . ' (' . $teacher_code . ')';
		
		//list all courses of the teacher, one line each
		$number_courses = CurriculumDatabase::get_number_of_courses_of_teacher($teacher_code);
		
		echo " has $number_courses official courses in " . CurriculumLogic::get_current_academic_year() . "<br/> ";
		
		if ($number_courses > 0)
		{
			$course_list_of_teacher = CurriculumDatabase::get_current_courses_of_teacher($teacher_code);
			
			echo '<ul>';
			for ($j = 0; $j < count($course_list_of_teacher); $j++)
			{
				$oocode = $course_list_of_teacher[$j]["oocode"];
				$oonaam = $course_list_of_teacher[$j]["naam"];
				$faculty_code = $course_list_of_teacher[$j]["faculteit_afkorting"];
				$course_exists = CurriculumDatabase::is_course_created($oocode);
				
				echo '<li>';
				echo "$oonaam ($oocode)";
				
				if ( $teacher_exists && !$course_exists )
				{
					echo "<br/>This course can be created: ";
					//display_course_create_form($teacher_user_id, $personnel_code, $teacher_code, $oocode, $faculty_code);
					$number_of_courses_can_be_created++;
					
					//20062007 initial start:
					//auto-create all courses
					$message = CurriculumLogic::attempt_create_one_official_course($teacher_user_id, $personnel_code, $teacher_code, $oocode, $faculty_code);
					Display::display_normal_message($message);
				}
				
				echo '</li>';
			}
			echo '</ul>';
		}
			
		echo "</p>";
	}
	echo "<p>$number_of_courses_can_be_created courses can still be created.</p>";
}

/**
* Displays a form with a create course button - there is no other output.
*/
function display_course_create_form($teacher_user_id, $personnel_code, $teacher_code, $oocode, $faculty_code)
{
	echo '<form method="post" action="'.$_SERVER['PHP_SELF'].'">';
	echo '<input type="hidden" name="teacher_user_id" value="'.$teacher_user_id.'">';
	echo '<input type="hidden" name="personnel_code" value="'.$personnel_code.'">';
	echo '<input type="hidden" name="teacher_code" value="'.$teacher_code.'">';
	echo '<input type="hidden" name="course_code" value="'.$oocode.'">';
	echo '<input type="hidden" name="faculty_code" value="'.$faculty_code.'">';
	echo '<br><input name="'.CREATE_ONE_OFFICIAL_COURSE.'" type="submit" value="'.get_lang("ActivateCourse").'">';
	echo "</form>\n";
}

/*
==============================================================================
		MAIN CODE
==============================================================================
*/ 

$action = $_REQUEST['action'];
$personnel_code = $_REQUEST['personnel_code'];
$teacher_code = $_REQUEST['teacher_code'];
$course_code = $_REQUEST['course_code'];
$faculty_code = $_REQUEST["faculty_code"];
$create_one_official_course = $_REQUEST[CREATE_ONE_OFFICIAL_COURSE];
$teacher_user_id = $_REQUEST['teacher_user_id'];
$minimum = $_REQUEST["min"];
$maximum = $_REQUEST["max"];
$is_simulation = $_REQUEST['is_simulation'];

if (trim($is_simulation) == "true") $is_simulation = true;
if (trim($is_simulation) == "false") $is_simulation = false;

display_main_options();

if ($action == SEE_TEACHER_LIST)
{
	if (! isset ($minimum)) { $minimum = 0; $maximum = 500; }
	display_official_teacher_list($minimum, $maximum);
}
else if ($action == UPDATE_TEACHER_LIST_DISPLAY_OPTIONS)
{
	$minimum = 0; $maximum = 3000;
	CurriculumLogic::add_teachers_to_dokeos($minimum, $maximum, $is_simulation);
}
else if ($action == VIEW_SPECIFIC_TEACHER_COURSES)
{
	display_list_official_courses_of_specific_teacher($personnel_code, $teacher_code);
}
else if ($action == UPDATE_TEACHER_LIST)
{
	CurriculumLogic::add_teachers_to_dokeos($minimum, $maximum, $is_simulation);
}
else if ($action == UPDATE_ASSISTANT_TEACHER_LIST)
{
	CurriculumLogic::add_assistant_teachers_to_dokeos($is_simulation);
}
else if ($action == SEE_ALL_TEACHER_ALL_COURSE_LIST)
{
	if (! isset ($minimum)) { $minimum = 0; $maximum = 3000; }
	display_all_teacher_all_course_list($minimum, $maximum);
}
else if ($action == CREATE_COURSES_THAT_DONT_EXIST_YET)
{
	CurriculumLogic::create_all_missing_courses();
}


if (isset($create_one_official_course) && $create_one_official_course)
{
	$message = CurriculumLogic::attempt_create_one_official_course($teacher_user_id, $personnel_code, $teacher_code, $course_code, $faculty_code);
	Display::display_normal_message($message);
}

/*
==============================================================================
		FOOTER 
==============================================================================
*/ 
Display::display_footer();
?>



See more files for this project here

pointcarre

Pointcarre - a learning management system based on the Dokeos community releases. No fork, but containing locally developed extensions, features not (yet) in the standard release, integrated plugins...

Project homepage: http://sourceforge.net/projects/pointcarre
Programming language(s): PHP
License: other

  nightly_update/
    nightly_update.php
  class_add.php
  class_edit.php
  class_information.php
  class_list.php
  configure_homepage.php
  course_add.php
  course_category.php
  course_create_content.php
  course_edit.php
  course_information.php
  course_list.php
  course_virtual.php
  curriculum_complete_update.php
  exemple.csv
  exemple.xml
  index.php
  languages.php
  manage_course_tools.php
  manage_official_classes.php
  manage_official_communities.php
  manage_official_personnel.php
  manage_official_students.php
  manage_official_teachers.php
  manage_special_options.php
  official_update_titles_teachers.php
  settings.php
  statistics.php
  subscribe_class2course.php
  subscribe_user2class.php
  subscribe_user2course.php
  system_announcements.php
  user_add.php
  user_edit.php
  user_export.php
  user_import.php
  user_information.php
  user_list.php
  veco_manage_official_data.php