manage_official_students.php from pointcarre at Krugle
Show manage_official_students.php syntax highlighted
<?php // $Id: manage_official_students.php 490 2006-10-19 12:41:52Z 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 students, 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_STUDENT_LIST", "see_student_list");
define("UPDATE_STUDENT_LIST_DISPLAY_OPTIONS", "update_student_list_display_options");
define("UPDATE_STUDENT_LIST", "update_student_list");
define("VIEW_SPECIFIC_STUDENT_COURSES", "view_specific_teacher_courses");
define("SEE_ALL_STUDENT_ALL_COURSE_LIST", "see_all_teacher_all_course_list");
define("UPDATE_STUDENT_COURSE_WEB_REGISTRATIONS", "update_student_course_web_registrations");
define("UPDATE_STUDENT_COURSE_OFFICIAL_REGISTRATIONS", "update_student_course_official_registrations");
define("UNSUBSCRIBE_UNOFFICIAL_STUDENT_COURSE_REGISTRATIONS", "unsubscribe_students");
define("CLEAR_COURSE_FROM_NOT_OFFICIAL_STUDENTS", "clear_course_from_unoffocial_students");
define("CONFIRMED_CLEAR_COURSE_FROM_NOT_OFFICIAL_STUDENTS", "confirmed_clear_course_from_unoffocial_students");
define("CLEAR_COURSE_ALL_USERS", "clear_course_all_users");
define("CONFIRMED_CLEAR_COURSE_ALL_USERS", "confirmed_clear_course_all_users");
define("UNSUBSCRIBE_ALL_STUDENTS_OFFICIAL_COURSES", "unsubscribe_all_students_official_courses");
/*
-----------------------------------------------------------
Header
-----------------------------------------------------------
*/
$tool_name = get_lang("ManageStudentsOfficialCurriculum");
$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 'What do you want to do?';
echo '<ul>';
echo '<li><a href="'.$_SERVER['PHP_SELF'].'?action='.SEE_STUDENT_LIST.'">See a list of official students</a></li>';
echo '<li><a href="'.$_SERVER['PHP_SELF'].'?action='.UPDATE_STUDENT_LIST.'">Update the list of students in Pointcarré</a></li>';
echo '<li><a href="'.$_SERVER['PHP_SELF'].'?action='.UPDATE_STUDENT_COURSE_WEB_REGISTRATIONS.'">Update the student course web registrations</a></li>';
//echo '<li>Update the student course web registrations (disabled)</li>';
echo '<li><a href="'.$_SERVER['PHP_SELF'].'?action='.UPDATE_STUDENT_COURSE_OFFICIAL_REGISTRATIONS.'">Update the student course official registrations</a></li>';
echo '<li><a href="'.$_SERVER['PHP_SELF'].'?action='.CLEAR_COURSE_FROM_NOT_OFFICIAL_STUDENTS.'">Clear course - remove unofficial students</a></li>';//echo '<li><a href="'.$_SERVER['PHP_SELF'].'?action='.UNSUBSCRIBE_UNOFFICIAL_STUDENT_COURSE_REGISTRATIONS.'">Unsubscribe official students from courses they do not officially follow this year.</a></li>';
//echo '<li><a href="'.$_SERVER['PHP_SELF'].'?action='.UNSUBSCRIBE_ALL_STUDENTS_OFFICIAL_COURSES.'">Unsubscribe all students from official courses</a></li>';
echo '<li><a href="'.$_SERVER['PHP_SELF'].'?action='.CLEAR_COURSE_ALL_USERS.'">Clear course - remove all students</a></li>';
echo '<li>Unsubscribe all students from official courses (disabled)</li>';
echo '</ul>';
}
function display_official_student_list()
{
$min = 0; $max = 10000;
$result_array = CurriculumDatabase::get_official_student_info_list($min, $max);
$row = 0;
$column_header[$row ++] = "Rolnummer";
$column_header[$row ++] = "Voornaam";
$column_header[$row ++] = "Achternaam";
$column_header[$row ++] = "Email";
$column_header[$row ++] = "Login";
$column_header[$row ++] = "Aangemaakt";
//$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++)
{
$student_number = $result_array[$i]["student_number"];
$last_name = $result_array[$i]["last_name"];
$first_name = $result_array[$i]["first_name"];
$email = $result_array[$i]["email"];
$login = CurriculumDatabase::get_student_login_from_student_number($student_number);
if ( $login == '')
{
$login = "<font color=\"red\">No login</font>";
$student_exists = false;
}
else
{
$student_exists = CurriculumDatabase::login_exists_in_dokeos($login);
}
if ($student_exists) $student_exists_output = "<font color=\"green\">Yes</font>";
else $student_exists_output = "<font color=\"red\">No</font>";
$row = 0;
$table_row[$row ++] = $student_number;
$table_row[$row ++] = $last_name;
$table_row[$row ++] = $first_name;
$table_row[$row ++] = $email;
$table_row[$row ++] = $login;
$table_row[$row ++] = $student_exists_output;
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 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)
{
echo '<ul>';
echo '<li><a href="'.$_SERVER['PHP_SELF'].'?action='.SEE_ALL_TEACHER_ALL_COURSE_LIST.'&min=0&max=500">Show teachers 0 - 500 and their courses</a>';
echo '<li><a href="'.$_SERVER['PHP_SELF'].'?action='.SEE_ALL_TEACHER_ALL_COURSE_LIST.'&min=501&max=1000&is_simulation=true">Show teachers 501 - 1000 and their courses</a></li>';
echo '<li><a href="'.$_SERVER['PHP_SELF'].'?action='.SEE_ALL_TEACHER_ALL_COURSE_LIST.'&min=1001&max=1500&is_simulation=true">Show teachers 1001 - 1500 and their courses</a></li>';
echo '</ul>';
$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 2005-2006<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 )
{
display_course_create_form($teacher_user_id, $personnel_code, $teacher_code, $oocode, $faculty_code);
$number_of_courses_can_be_created++;
}
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'];
$confirmed_clear_course_unofficial_students = $_REQUEST[CONFIRMED_CLEAR_COURSE_FROM_NOT_OFFICIAL_STUDENTS];
$confirmed_clear_course_all_users = $_REQUEST[CONFIRMED_CLEAR_COURSE_ALL_USERS];
if (trim($is_simulation) == "true") $is_simulation = true;
if (trim($is_simulation) == "false") $is_simulation = false;
display_main_options();
if ($action == SEE_STUDENT_LIST)
{
if (! isset ($minimum)) { $minimum = 0; $maximum = 10000; }
display_official_student_list($minimum, $maximum);
}
else if ($action == VIEW_SPECIFIC_STUDENT_COURSES)
{
display_list_official_courses_of_specific_teacher($personnel_code, $teacher_code);
}
else if ($action == UPDATE_STUDENT_LIST)
{
$is_simulation = false;
CurriculumLogic::update_student_list($is_simulation);
}
else if ($action == UPDATE_STUDENT_COURSE_WEB_REGISTRATIONS)
{
$is_simulation = false;
CurriculumLogic::update_student_course_web_registration($is_simulation);
}
else if ($action == UPDATE_STUDENT_COURSE_OFFICIAL_REGISTRATIONS)
{
$is_simulation = false;
CurriculumLogic::update_student_course_official_registration($is_simulation);
}
else if ($action == CLEAR_COURSE_FROM_NOT_OFFICIAL_STUDENTS)
{
echo "\nClear non-official students from which course? (enter a course code):";
echo '<form method="post" action="'.$_SERVER['PHP_SELF'].'">';
echo '<input type="text" name="course_code" value="VUBxxxx">';
echo '<br><input name="'.CONFIRMED_CLEAR_COURSE_FROM_NOT_OFFICIAL_STUDENTS.'" type="submit" value="Clear course">';
echo "</form>\n";
}
else if ($action == CLEAR_COURSE_ALL_USERS)
{
echo "\nClear all users from which course? (enter a course code):";
echo '<form method="post" action="'.$_SERVER['PHP_SELF'].'">';
echo '<input type="text" name="course_code" value="VUBxxxx">';
echo '<br><input name="'.CONFIRMED_CLEAR_COURSE_ALL_USERS.'" type="submit" value="Clear course">';
echo "</form>\n";
}else if ($action == UNSUBSCRIBE_UNOFFICIAL_STUDENT_COURSE_REGISTRATIONS)
{
$is_simulation = false;
CurriculumLogic::unsubscribe_official_students_from_unofficial_courses($is_simulation);
}
else if ($action == UNSUBSCRIBE_ALL_STUDENTS_OFFICIAL_COURSES)
{
$is_simulation = true;
CurriculumLogic::unsubscribe_all_students_official_courses($is_simulation);
}
if (isset($confirmed_clear_course_unofficial_students) && $confirmed_clear_course_unofficial_students)
{
CurriculumLogic::clear_course_from_unofficial_students($course_code);
}
if (isset($confirmed_clear_course_all_users) && $confirmed_clear_course_all_users)
{
CurriculumLogic::clear_course_from_all_users($course_code);
}
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