Location: PHPKode > projects > Quadrille multimedia assessment system > quadrille/rept_group_sel.php
<?
/*-------------------------------------------------------------------
   rept_group_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_GROUP_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") {
		$query ="SELECT * FROM GROUP_INFO";
	} else {
		$query ="SELECT * FROM GROUP_INFO , USER_IN_GROUP WHERE USER_IN_GROUP.USER_UID = $user_uid and USER_IN_GROUP.GROUP_UID = GROUP_INFO.UID";
	}
	$query.=" order by NAME";
	$result = mysql_query($query);
	if (mysql_errno() != 0) 
		header("location:qerror.php?qerr_type=1&qerr_mess=DB_ERR&qerr_messx=".mysql_error());
	$no_of_row = mysql_num_rows($result);
	
	if ($no_of_row >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="GROUP" name="Addaction">
		<input type="hidden" value="0" name="g_uid">
		<table width="" border="0" cellspacing="4" cellpadding="5">
		<tr>
		<td  class="tableheading">$GROUP_ID</td>
		<td  class="tableheading">$GROUP_NAME</td>
		</tr>
_HTML_;
		$i=0;
	
		while ($row = mysql_fetch_array($result))
		{ 
			$group_id  = $row["ID"];
			$group_uid  = $row["UID"];
			$group_name = $row["NAME"];
			$group_id_field = "<a href=\"javascript:group_to_course($group_uid);\">".$group_id."</a>";
			$group_name_field = "<a href=\"javascript:group_to_course($group_uid);\">".$group_name."</a>";
			if($i%2==0)
				$content.="\n\t\t<tr class=\"tablerowodd\">";
			else
				$content.="\n\t\t<tr class=\"tableroweven\">"; 
						
			$content.=display_cell($group_id_field,'');
			$content.="\n\t\t\t";
			$content.=display_cell($group_name_field,'');			
			$content.="\n\t\t</tr>";
			$i++;
		}
		$content.="\n\t</table>";
	}
	else 
	{
		$content.="<form name=\"form1\">";
		$content.= "<p class=\"error\">$NO_GROUP</p>";
	}
	$content.="\n</form>";
	
	$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