Location: PHPKode > projects > Quadrille multimedia assessment system > quadrille/rept_class_sel.php
<?
/*-------------------------------------------------------------------
   rept_class_sel.php  Ver. $Revision: 1.2 $ 		$Date: 2003/05/21 02:03:31 $ 
*
   Copyright (C) 2000 Hong Kong Baptist University
*
   This file is part of the Quadrille system.
*  This program is free software; it is distributed under the terms of
   the GNU General Public License, either version 2, or (at your option)
*  any later version.

*  This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
*
---------------------------------------------------------------------
*/
?>
<?
require "config_inc.php";
require "global_inc.php";
require "template.php";
include $language_pack;
require "output_inc.php";  
include "qreport_{$lang_name}_inc.php";
include "qreport_inc.php";

/*************/
/* Main Part */
/*************/

        check_expire();

	$role = check_role(); 
	if (($role <>'Adm') && ($role <>'Tea'))
	{
		header("location:login.php?again=1");
	}

      	$user_uid = $cookie[user_uid];
        $temp_cookie[user_uid] = $cookie[user_uid];
        $temp_cookie[password] = $cookie[password];
        $temp_cookie[db_index] = $cookie[db_index];
        $temp_cookie[course_uid] = $cookie[course_uid];
        $temp_cookie[unit_uid] = $cookie[unit_uid];
        set_cookie($temp_cookie);
        insert_header();

        $currentlocation =insert_current_location($cookie["course_uid"],$cookie["unit_uid"],'');

	$row=find_user($user_uid);
	$user_id = $row["ID"];
	$user_name = $row["NAME"];
	$user_role = $row["ROLE"];

	if ($user_role=="Adm")
		$role = $ADMIN;
	else
		$role = $TEACHER;
	$currentlocation = $role ." : ".$user_name." (".$user_id.")";

	$content.= "<p class=\"message\">$REPT_CLASS_SELECT_TITLE</p>";
	
	$p = "SELECT ROLE FROM USER WHERE UID='".$user_uid."'";
	$r = mysql_query($p);
	if (mysql_errno() != 0) 
		header("location:qerror.php?qerr_type=1&qerr_mess=DB_ERR&qerr_messx=".mysql_error());
	$row = mysql_fetch_array($r);
	$userrole = $row['ROLE'];
	if($userrole=="Adm") {
		$q ="SELECT * FROM CLASS";
	}
	else if($userrole=="Tea") {
		$q ="SELECT * FROM CLASS,TEACH_CLASS WHERE CLASS.UID=CLASS_UID AND TEACH_CLASS.USER_UID=$temp_cookie[user_uid]";
	}
	$q.=" order by CLASS.ID";
	$result = mysql_query($q);
	if (mysql_errno() != 0) 
		header("location:qerror.php?qerr_type=1&qerr_mess=DB_ERR&qerr_messx=".mysql_error());
	$nrows = mysql_num_rows($result);
	if ($nrows > 0) 
	{
		$content.=<<<_HTML_
		<form name="form1" method="post" action="rept_course_sel.php">
		<input type=hidden value="basename(__FILE__)" name="fromURL">
		<input type=hidden value="CLASS" name="Addaction">
		<input type="hidden" value="0" name="c_uid">
		<table width="" border="0" cellspacing="4" cellpadding="5">
		<tr>
		<td  class="tableheading">$CLASS_ID</td>
		<td  class="tableheading">$CLASS_NAME</td>
		</tr>
_HTML_;
		$i=0;

                while ($row = mysql_fetch_array($result))
                { 
			$class_id  = $row["ID"];
                        $class_uid  = $row["UID"];
                        $class_name = $row["NAME"];
                      	$class_id_field = "<a href=\"javascript:class_to_course($class_uid);\">".$class_id."</a>";
                      	$class_name_field = "<a href=\"javascript:class_to_course($class_uid);\">".$class_name."</a>";

			if($i%2==0)
				$content.="\n\t\t<tr class=\"tablerowodd\">";
			else
				$content.="\n\t\t<tr class=\"tableroweven\">"; 
			$content.=display_cell($class_id_field ,'');
			$content.="\n\t\t\t";
			$content.=display_cell($class_name_field ,'');
			$content.="\n\t\t</tr>";
			$i++;
		}
		$content.="\n\t</table>";
		$content.="\n</form>";
	}
	else 
	{
		$content.=<<<_HTML_
		<form name="form1" method="post">
		<input type=hidden value="basename(__FILE__)" name="fromURL">
		<p class="error">$NO_CLASS</p>
		</form>
_HTML_;
	}

	$a = array ('BACK_TO_REPORT_LIST' => "report.php");
	$content.=link_line($a,"");

        $java = get_file("javascript/rept.js");

        $html = get_template($template,$template_dir);
        $html=ereg_replace("<BEGIN>JAVASCRIPT<END>",$java,$html);
	$html=ereg_replace("<BEGIN>TITLE<END>",$PAGE_TITLE["REPT_TITLE"],$html);
        $html=ereg_replace("<BEGIN>CURRENTLOCATION<END>",$currentlocation,$html);
        $html=ereg_replace("<BEGIN>CONTENT<END>",$content,$html);
        $html=ereg_replace("<BEGIN>COPYRIGHT<END>",$COPYRIGHT,$html);
        print $html;
        
?>
Return current item: Quadrille multimedia assessment system