Location: PHPKode > projects > Quadrille multimedia assessment system > quadrille/course_teacher_list.php
<?
/*-------------------------------------------------------------------
   course_teacher_list.php  Ver. $Revision: 1.2 $                 $Date: 2003/05/21 01:54:41 $
*
   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 "global_inc.php";
require "config_inc.php";
require "template.php";
include $language_pack;
include "output_inc.php";
/*************/
/* Main Part */
/*************/
        check_expire();

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

        $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"],'');
        $content = course_teacher_list();
        $java = get_file("javascript/course_teacher_javascript.js");
        $java = ereg_replace("<BEGIN>SELECT_TEACHER_FIRST<END>",$SELECT_TEACHER_FIRST,$java);
        $java =ereg_replace("<BEGIN>CANNOT_DELETE_TEACHER<END>",$CANNOT_DELETE_TEACHER,$java);
        $java =ereg_replace("<BEGIN>USER_ROLE<END>",$user,$java);

        $sql = "SELECT distinct UID,NAME FROM TEACH_COURSE left join USER on
TEACH_COURSE.USER_UID=USER.UID WHERE TEACH_COURSE.COURSE_UID = $cookie[course_uid]";
                $result = mysql_query ($sql);
                $NO_OF_ROWS=mysql_num_rows($result);
        $java = ereg_replace("<BEGIN>NUMBER_OF_LIST_TEACHER<END>","$NO_OF_ROWS",$java);
        //print $java

		$temp_value_to_merge=$java;           //$temp_value_to_merge<-- variable to merge the two $java value

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



                        $temp_value_to_merge.=$java;            //merge  the two value of $java
                        $java=$temp_value_to_merge;             //merge  the two value of $java
		
        $java = get_file("javascript/checkall.js");
        $java = ereg_replace("<BEGIN>HIDDEN_FIELD<END>",user_uid_list,$java);
        //print $java

			$temp_value_to_merge.=$java; 		//merge  the two value of $java
			$java=$temp_value_to_merge; 		//merge  the two value of $java

        $html = get_template($template, $template_dir);
        $html=ereg_replace("<BEGIN>JAVASCRIPT<END>",$java,$html);
        $html=ereg_replace("<BEGIN>TITLE<END>",$PAGE_TITLE["COURSE_TEACHER_LIST"],$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;


/**********************/
/*   Function Part    */
/**********************/

function course_teacher_list()
{ include "config_inc.php";
  include $language_pack;
  global $external_info;
  global $no_user_select;
  $content="";

        $user_role=check_role();

	$sql = "SELECT distinct UID,NAME FROM TEACH_COURSE left join USER on TEACH_COURSE.USER_UID=USER.UID WHERE TEACH_COURSE.COURSE_UID = $cookie[course_uid]";
        $result = mysql_query ($sql);


        if (mysql_num_rows($result)>0) {
//                $content.=insert_link($external_info,'course_teacher');
if(mysql_num_rows($result)>= $nrows_for_two_links){
if($user_role!="Stu"){
                $content.=insert_link($NEW,"course_teacher_add.php",0);
                $content.=insert_link($DELETE,"javascript:delete_course_teacher();",1);
		 //LINK MARKED BY EDDIE ON 9/8
		//$content.=insert_link($BACK_TO_COURSE_INFORMATION,"course_enter.php",1);
		 //LINK ADDED BY EDDIE ON 9/8
$content.=insert_link($BACK_TO_COURSE_INFORMATION,"javascript:enter_course_from_teacher_list();" ,1);
}else{
		 //LINK MARKED BY EDDIE ON 9/8
                //$content.=insert_link($BACK_TO_COURSE_INFORMATION,"course_enter.php",0);
		 //LINK ADDED BY EDDIE ON 9/8
$content.=insert_link($BACK_TO_COURSE_INFORMATION,"javascript:enter_course_from_teacher_list();" ,1);
}//END OF IF
}//END OF IF if(mysql_num_rows($result)>= $nrows_for_two_links)
              //  $content.="</span></span></p>\n\n";
               // $content.=insert_hr();

                $content.="<form name=\"form1\" method=\"post\" action=\"course_teacher_delete.php\">";
//ADD THE HIDDEN FOR THE LINK BACK TO THE COURSE_ENTER PAGE ADDED BY EDDIE ON 9/8
$content.= <<<_HTML_
<input type="hidden" name="course_uid" value=$cookie[course_uid]>
_HTML_;
                $content.="\n\t<table width=\"\" border=\"0\" cellspacing=\"4\" cellpadding=\"5\" >";
                $content.="\n\t\t<tr>";
                if($user_role!="Stu"){
                $content.="\n\t\t\t<td class=\"tableheading\">&nbsp;</td>";
                }
                $content.="\n\t\t\t<td nowrap class=\"tableheading\">$TEACHER_NAME</td>";
                $content.="\n\t\t</tr>";
                $i=0;

                while ($row = mysql_fetch_array($result)) {
                        $user_name  = $row["NAME"];
                        $user_uid   = $row["UID"];

                        if($i%2==0)
                                $content.="\n\t\t<tr class=\"tablerowodd\">";
                        else
                                $content.="\n\t\t<tr class=\"tableroweven\">";
                        if($user_role!="Stu"){
                        $content.="\n\t\t\t<td nowrap>&nbsp;<input type=\"checkbox\" name=\"checkbox\" value=\"$user_uid\">&nbsp;</td>";
                        }
                        $content.=display_cell($user_name,'');
                        $content.="\n\t\t\t";
                        $i++;
                }
                $content.="\n\t</table>";


                if($user_role!="Stu"){
	                $content.="\n\t<input type=\"button\" name=\"clickall\" value=\"$SELECT_ALL\" onclick=\"click_all()\";>";
        	        $content.="\n\t<input type=\"button\" value=\"$CLEAR_FORM\" onclick=\"unclick_all()\";>";
                	$content.="\n\t<input type=\"hidden\" name=\"user_uid_list\">";
	                $content.="\n</form>";
                }

                $content.="\n</form>";
//                $content.=insert_link($external_info,'course_teacher');
                 if($user_role!="Stu"){
//	                 $content.=insert_link($NEW,"course_teacher_add.php",0);
  //      	         $content.=insert_link($DELETE,"javascript:delete_course_teacher();",0);
                 //LINK MARKED BY EDDIE ON 9/8
                //$content.=insert_link($BACK_TO_COURSE_INFORMATION,"course_enter.php",0);
                 //LINK ADDED BY EDDIE ON 9/8
//			$content.=insert_link($BACK_TO_COURSE_INFORMATION,"javascript:enter_course_from_teacher_list();" ,0);
			$a = array( 'NEW'    => "course_teacher_add.php",
			            'DELETE' => "javascript:delete_course_teacher();",
			            'BACK_TO_COURSE_INFORMATION'   => "javascript:enter_course_from_teacher_list();");

			$content.= link_line($a,"");
                 }
		 else{
                 //LINK MARKED BY EDDIE ON 9/8
                //$content.=insert_link($BACK_TO_COURSE_INFORMATION,"course_enter.php",0);
                 //LINK ADDED BY EDDIE ON 9/8
//			$content.=insert_link($BACK_TO_COURSE_INFORMATION,"javascript:enter_course_from_teacher_list();" ,0);
                        $a = array( 'BACK_TO_COURSE_INFORMATION'   => "javascript:enter_course_from_teacher_list();");

                        $content.= link_line($a,"");
 
		}

               // $content.="</span></span></p>\n\n";

        }
        else {
             //   $content.="\n\n<p><font face=\"Arial, Helvetica, sans-serif\" size=\"+1\">";
              //$content.="\n\t<font color=\"#000099\" class=\"link\">";
//                $content.=insert_link($NEW,"course_teacher_add.php",0);
                //$content.="</span></span></p>\n\n";
                //$content.=insert_hr();

//ADD THE HIDDEN VALUE AND FORM FOR THE LINK BACK TO THE COURSE_ENTER PAGE
$content.= <<<_HTML_
<form name="form1" method="post" action="course_teacher_delete.php">
<input type="hidden" name="course_uid" value=$cookie[course_uid]>
</form>
_HTML_;
		
                $content.="\n<br><span class='warning'>$NO_TEACHER</span><br /><br />";
                $a = array( 'NEW'    => "course_teacher_add.php",
                            'BACK_TO_COURSE_INFORMATION'   => "javascript:enter_course_from_teacher_list();");

                $content.= link_line($a,"");

        }
        return $content;
}

?>
Return current item: Quadrille multimedia assessment system