Ver Fonte

教师课程表完成

visuddhinanda há 5 anos atrás
pai
commit
d57579b4ad

+ 1 - 0
app/course/course.php

@@ -1,4 +1,5 @@
 <?PHP
+
 include "../pcdl/html_head.php";
 ?>
 <body>

+ 27 - 37
app/fullcalendar/examples/php/get-date.php

@@ -1,49 +1,39 @@
 <?php
 //
 
-require_once "../../../../path.php";
-require_once "../../../../public/_pdo.php";
+require_once "../../../path.php";
+require_once "../../../public/_pdo.php";
 
-if(isset($_GET["teacher"])){
-    $teacher = " teacher = ? ";
-}
-else{
-    $teacher = " 1= 1";
-}
+function get_teacher_course($teacher_id){
 
-global $PDO;
-PDO_Connect("sqlite:"._FILE_DB_COURSE_);
+		$teacher = "  ";
 
-$query = "select * from course where $teacher  order by create_time DESC limit 0,100";
-if(isset($_GET["teacher"])){
-	$Fetch = PDO_FetchAll($query,array($_GET["teacher"]));
-}
-else{
-	$Fetch = PDO_FetchAll($query);
-}
+	global $PDO;
+	PDO_Connect("sqlite:"._FILE_DB_COURSE_);
+	
+	$query = "select * from course where teacher = ?  order by create_time DESC limit 0,100";
 
-$output = array();
-foreach ($Fetch as $key => $couse) {
-	# code...
-	$query = "select * from lesson where course_id = '{$couse["id"]}'   limit 0,300";
-	$fAllLesson = PDO_FetchAll($query);
-	foreach ($fAllLesson as  $lesson) {
+	$Fetch = PDO_FetchAll($query,array($teacher_id));
+	
+	$output = array();
+	foreach ($Fetch as $key => $couse) {
 		# code...
-		#		"id": "999",
-		#"title": "Dhammacakkha",
-		#"url": "https://www.wikipali.org/app/course/lesson.php?id=6a42e993-8f7e-414a-a291-a4094764f992",
-		#"start": "2020-12-11T08:00:00+06:30",
-		#"end": "2020-12-11T09:30:00+06:30"
-		$start = date("Y-m-d\TH:i:s+00:00",$lesson["date"]/1000);
-		$end = date("Y-m-d\TH:i:s+00:00",$lesson["date"]/1000+$lesson["duration"]);
-		$output[]=array("id"=>$lesson["id"],
-									"title"=>$couse["title"],
-									"url"=>"../../../course/lesson.php?id=".$lesson["id"],
-									"start"=> $start,
-									"end"=>$end
-								);
+		$query = "select * from lesson where course_id = '{$couse["id"]}'   limit 0,300";
+		$fAllLesson = PDO_FetchAll($query);
+		foreach ($fAllLesson as  $lesson) {
+			$start = date("Y-m-d\TH:i:s+00:00",$lesson["date"]/1000);
+			$end = date("Y-m-d\TH:i:s+00:00",$lesson["date"]/1000+$lesson["duration"]);
+			$output[]=array("id"=>$lesson["id"],
+										"title"=>$couse["title"],
+										"url"=>"../../../course/lesson.php?id=".$lesson["id"],
+										"start"=> $start,
+										"end"=>$end
+									);
+		}
 	}
+	return($output);
+	
 }
-echo json_encode($output, JSON_UNESCAPED_UNICODE);
+
 
 ?>

+ 5 - 2
app/fullcalendar/examples/php/get-events.php

@@ -11,6 +11,7 @@
 
 // Require our Event class and datetime utilities
 require dirname(__FILE__) . '/utils.php';
+require_once "./get-date.php";
 
 // Short-circuit if the client did not give us a date range.
 if (!isset($_GET['start']) || !isset($_GET['end'])) {
@@ -30,8 +31,10 @@ if (isset($_GET['timeZone'])) {
 }
 
 // Read and parse our events JSON file into an array of event data arrays.
-$json = file_get_contents(dirname(__FILE__) . '/../json/events.json');
-$input_arrays = json_decode($json, true);
+//$json = file_get_contents(dirname(__FILE__) . '/../json/events.json');
+//$input_arrays = json_decode($json, true);
+//使用cookie传递老师id
+$input_arrays = get_teacher_course($_COOKIE["teacher_id"]);
 
 // Accumulate an output array of event data arrays.
 $output_arrays = array();

+ 4 - 0
app/uhome/course.php

@@ -1,4 +1,8 @@
 <?PHP
+if(isset($_GET["userid"])){
+    setcookie("teacher_id", $_GET["userid"], time()+60*60,"/");
+}
+
 include "../pcdl/html_head.php";
 ?>
 <body>