<?php

// required headers
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods:GET, POST, PUT, DELETE, PATCH, OPTIONS");
header("Access-Control-Max-Age: 3600");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");

use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;
//including the required files

require_once '../lib/slim/vendor/autoload.php';
require_once '../includes/db.php';

//Creating a slim instance

$app = new \Slim\App([
    "settings"  => [
        "determineRouteBeforeAppMiddleware" => true,
    ]
]);

define('DB_SERVER', '182.50.133.88');
define('DB_USERNAME', 'exam');
define('DB_PASSWORD', '123456');
define('DB_NAME', 'Restax_api_data');

$app->add(function ($req, $res, $next) {
    $response = $next($req, $res);
    return $response
            ->withHeader('Access-Control-Allow-Origin','*')
            ->withHeader('Access-Control-Allow-Headers', 'X-Custom-Header, X-Auth-Token, Content-Type, Accept, Origin, Authorization')
			->withHeader('Access-Control-Request-Methods', 'GET, POST, PUT, DELETE')
            ->withHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS, HEADER');


});
// This is the middleware
// It will add the Access-Control-Allow-Methods header to every request

$app->add(function($request, $response, $next) {
    $route = $request->getAttribute("route");

    $methods = [];

    if (!empty($route)) {
        $pattern = $route->getPattern();

        foreach ($this->router->getRoutes() as $route) {
            if ($pattern === $route->getPattern()) {
                $methods = array_merge_recursive($methods, $route->getMethods());
            }
        }
        //Methods holds all of the HTTP Verbs that a particular route handles.
    } else {
        $methods[] = $request->getMethod();
    }

    $response = $next($request, $response);

    return $response->withHeader("Access-Control-Allow-Methods", implode(",", $methods));
});



                                                                                                                                  //course configuration page1                                                                                                                                 //fetch_course_data
$app->get('/fetch/course', function (Request $request, Response $response) use ($app) {

 
/* Attempt to connect to MySQL database */
$con = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
$response=array();

$sql="SELECT * FROM course";
$result=mysqli_query($con,$sql);
    while ($row[]=mysqli_fetch_assoc($result)) {  
      $user=$row;
    }
    echo json_encode($user);
  


});


                                                                                                                              //add_course_data
$app->post('/insert/course', function (Request $request, response $response) use ($app) {

 

$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);     
$name=$request->getParsedBody()['course_name'];
		
$response=array();


$sqll="(SELECT * FROM course WHERE course_name='$name')";
$res= $con->query($sqll);
if($res->num_rows>0)
{
$response1=array('status' => "true",'Message' => "data already exist");
echo json_encode($response1);
}

else{
$sql="INSERT INTO course(course_name) VALUES ('$name')";

$res= $con->query($sql);
	
if($res==true)
{

		$data=array(
	
	"name"=>$name,
	);
	    $message=$data;
		
	$response=array('status' => "true",'Message' => "Data inserted successfully",'course' => $message);
echo json_encode($response);
        
}
        else{
          $response=array('status' => "false",'Message' => " insert data failed");
         echo json_encode($response);
        }   
		
	
}
});

                                                                                                                                               //UPDATE_COURSE
$app->put('/update/course/{course_id}', function (Request $request, response $response) use ($app) {

 header("Access-Control-Allow-Origin: *");
 header("Access-Control-Allow-Methods:GET, POST, PUT, DELETE, PATCH, OPTIONS");

$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

$course_id = $request->getAttribute('course_id');


	$course_name=$request->getParsedBody()['course_name'];
	
	
	
	$sql= ("UPDATE course SET course_name='$course_name' WHERE course_id=$course_id");	
	
 if($con->query($sql)){
		$data=array(
"course_id" => $course_id,
	"course_name"=>$course_name,
	);
	    $message=$data;
	

	
	$response=array('status' => "true",'Message' => "Data updated successfully",'course' => $message);
echo json_encode($response);
        
}
        else{
          $response=array('status' => "false",'Message' => " update data failed");
         echo json_encode($response);
        }   
		
	

});
 

                                                                                                                                                   //DELETE_COURSE

$app->delete('/delete/course/{course_id}', function (Request $request, response $response) use ($app) {

 

$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

$course_id = $request->getAttribute('course_id');

	$sql="delete from course where course_id=$course_id";	
	
 if($con->query($sql)){
		$data=array(
"course_id" => $course_id,

	);
	    $message=$data;
	

	
	$response=array('status' => "true",'Message' => "Data deleted successfully",'course' => $message);
echo json_encode($response);
        
}
        else{
          $response=array('status' => "false",'Message' => " delete data failed");
         echo json_encode($response);
        }   
		
	

});


                                                                                                                                               // page2

                                                                                                                                   //course_dropsown
$app->get('/fetch/department/{course_id}', function (Request $request, Response $response) use ($app) {
/* Attempt to connect to MySQL database */
$con = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
$response=array();

$course_id = $request->getAttribute('course_id');


$sql="SELECT dept_id, dept_name, dept_shortcode FROM department WHERE course_id=$course_id";
$result=mysqli_query($con,$sql);
    while ($row[]=mysqli_fetch_assoc($result)) {  
      $cors=$row;
    }
    echo json_encode($cors);
  
});
                                                                                                                                        //getcoursename/dropdown

$app->get('/course', function (Request $request) use ($app) {

 
/* Attempt to connect to MySQL database */
$con = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

$sql="SELECT course_name FROM course";
$result=mysqli_query($con,$sql);
    while ($row[]=mysqli_fetch_assoc($result)) {  
      $user=$row;
    }
    echo json_encode($user);
  


});


                                                                                                                                              //fetch_dept_data
$app->get('/fetch/dept', function (Request $request) use ($app) {

 
/* Attempt to connect to MySQL database */
$con = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
$response=array();
$sql="SELECT dept_id, course_id, dept_name, dept_shortcode FROM department";
$result=mysqli_query($con,$sql);
    while ($row[]=mysqli_fetch_assoc($result)) {  
      $user=$row;
    }
    echo json_encode($user); 
		
	

});


 
                                                                                                                                                  //add_dept_data
$app->post('/insert/dept', function (Request $request, response $response) use ($app) {

 

$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

     $course_id=$request->getParsedBody()['course_id'];
		$dept_name=$request->getParsedBody()['dept_name'];
		$dept_shortcode=$request->getParsedBody()['dept_shortcode'];
		
$response=array();

$sqll="(SELECT * FROM department WHERE  dept_name='$dept_name' OR dept_shortcode='$dept_shortcode')";
$res= $con->query($sqll);
if($res->num_rows>0)
{
$response1=array('status' => "true",'Message' => "data already exist");
echo json_encode($response1);
}

else{
$sql="INSERT INTO department(course_id,dept_name,dept_shortcode) VALUES ('$course_id','$dept_name','$dept_shortcode')";

$res= $con->query($sql);
	
if($res==true)
{
		$data=array(
	"course_id"=>$course_id,
	"dept_name"=>$dept_name,
	"dept_shortcode"=>$dept_shortcode,
	
	);
	    $message=$data;
	

	
	$response=array('status' => "true",'Message' => "Data inserted successfully",'department' => $message);
echo json_encode($response);
        
}
        else{
          $response=array('status' => "false",'Message' => " insert data failed");
         echo json_encode($response);
        }   
		
}

});


                                                                                                                                                    //UPDATE_DEPT
$app->put('/update/dept/{dept_id}', function (Request $request, response $response) use ($app) {

 

$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);



        $dept_id = $request->getAttribute ('dept_id');
		$dept_name=$request->getParsedBody() ['dept_name'];
		$dept_shortcode=$request->getParsedBody() ['dept_shortcode'];
	
			
	$sql= ("UPDATE department SET dept_name='$dept_name', dept_shortcode='$dept_shortcode' WHERE dept_id=$dept_id");	
	
 if($con->query($sql)){
		$data=array(
"dept_id" => $dept_id,
	"dept_name"=>$dept_name,
	"dept_shortcode"=>$dept_shortcode,
	);
	    $message=$data;
	

	
	$response=array('status' => "true",'Message' => "Data updated successfully",'course' => $message);
echo json_encode($response);
        
}
        else{
          $response=array('status' => "false",'Message' => " update data failed");
         echo json_encode($response);
        }   
		


});
 

                                                                                                                                                 //DELETE_DEPT

$app->DELETE('/delete/dept/{dept_id}', function (Request $request, response $response) use ($app) {


$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

$dept_id = $request->getAttribute ('dept_id');

	$sql="delete from department where dept_id=$dept_id";	
	
	
	
 if($con->query($sql)){
		$data=array(
"dept_id" => $dept_id,
	
	);
	    $message=$data;
	

	
	$response=array('status' => "true",'Message' => "Data deleted successfully",'department' => $message);
echo json_encode($response);
        
}
        else{
          $response=array('status' => "false",'Message' => " delete data failed");
         echo json_encode($response);
        }   
		
	

});



                                                                                                                                             //page3
																																			 
																																			 
																																			 
		                                                                                                                                   //from_course
$app->get('/get/code/{course_id}', function (Request $request, Response $response) use ($app) {
/* Attempt to connect to MySQL database */
$con = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
$response=array();

$course_id = $request->getAttribute('course_id');


$sql="SELECT course_id, dept_id,dept_shortcode FROM department WHERE course_id=$course_id";
$result=mysqli_query($con,$sql);
    while ($row[]=mysqli_fetch_assoc($result)) {  
      $cors=$row;
    }
    echo json_encode($cors);
  
});																			 
			
			                                                                                                                                 //from_shortcode
$app->get('/get/level/{dept_id}', function (Request $request, Response $response) use ($app) {
/* Attempt to connect to MySQL database */
$con = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
$response=array();

$dept_id = $request->getAttribute('dept_id');


$sql="SELECT * FROM level WHERE dept_id=$dept_id";
$result=mysqli_query($con,$sql);
    while ($row[]=mysqli_fetch_assoc($result)) {  
      $corss=$row;
    }
    echo json_encode($corss);
  
});																			 
				


                                                                                                                                        //fetch_LEVEL
$app->get('/fetch/level', function (Request $request) use ($app) {

 
/* Attempt to connect to MySQL database */
$con = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
$response=array();
$sql="SELECT * FROM level";
$result=mysqli_query($con,$sql);
    while ($row[]=mysqli_fetch_assoc($result)) {  
      $user=$row;
    }
    echo json_encode($user); 
	
	

});



                                                                                                                                          //add_LEVEL
$app->post('/insert/level', function (Request $request, response $response) use ($app) {

 

$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

     $dept_id=$request->getParsedBody()['dept_id'];
		$level_name=$request->getParsedBody()['level_name'];
		$level_shortcode=$request->getParsedBody()['level_shortcode'];
		$year=$request->getParsedBody()['year'];
		$terms=$request->getParsedBody()['terms'];
	
		
$response=array();


$sqll="(SELECT * FROM level WHERE  level_name='$level_name' OR level_shortcode='$level_shortcode')";
$res= $con->query($sqll);
if($res->num_rows>0)
{
$response1=array('status' => "true",'Message' => "data already exist");
echo json_encode($response1);
}

else{
$sql="INSERT INTO level(dept_id,level_name,level_shortcode,year,terms) VALUES ('$dept_id','$level_name','$level_shortcode','$year','$terms')";

$res= $con->query($sql);
	
if($res==true)
{
		$data=array(
	"dept_id"=>$dept_id,
	"level_name"=>$level_name,
	"level_shortcode"=>$level_shortcode,
	"year"=>$year,
	"terms"=>$terms,
	);
	    $message=$data;
	

	
	$response=array('status' => "true",'Message' => "Data inserted successfully",'level' => $message);
echo json_encode($response);
        
}
        else{
          $response=array('status' => "false",'Message' => " insert data failed");
         echo json_encode($response);
        }   
		
}

});

                                                                                                                                         //UPDATE_LEVEL
$app->put('/update/level/{level_id}', function (Request $request, response $response) use ($app) {

 

$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);



        $level_id = $request->getAttribute ('level_id');
		$level_name=$request->getParsedBody ()['level_name'];
		$level_shortcode=$request->getParsedBody ()['level_shortcode'];
		$year=$request->getParsedBody() ['year'];
		$terms=$request->getParsedBody() ['terms'];
		
					
	$sql= ("UPDATE level SET level_name='$level_name', level_shortcode='$level_shortcode' , year='$year' , terms='$terms' WHERE level_id=$level_id");	
	
 if($con->query($sql)){
		$data=array(
"level_id" => $level_id,
	"level_name"=>$level_name,
	"level_shortcode"=>$level_shortcode,
	"year"=>$year,
	"terms"=>$terms,
	);
	    $message=$data;
	

	
	$response=array('status' => "true",'Message' => "Data updated successfully",'level' => $message);
echo json_encode($response);
        
}
        else{
          $response=array('status' => "false",'Message' => " update data failed");
         echo json_encode($response);
        }   
		
	

});
 

                                                                                                                                           //DELETE_LEVEL

$app->DELETE('/delete/level/{level_id}', function (Request $request, response $response) use ($app) {

 
$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

$level_id = $request->getAttribute ('level_id');	
	$sql="delete from level where level_id= $level_id";	
	
	
	
 if($con->query($sql)){
		$data=array(
    "level_id" => $level_id,

	);
	    $message=$data;
	

	
	$response=array('status' => "true",'Message' => "Data deleted successfully",'level' => $message);
echo json_encode($response);
        
}
        else{
          $response=array('status' => "false",'Message' => " delete data failed");
         echo json_encode($response);
        }   
		
	

});


		                                                                                                                             //page4      //from_shortcode
$app->get('/get/year/{dept_id}', function (Request $request, Response $response) use ($app) {
/* Attempt to connect to MySQL database */
$con = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
$response=array();

$dept_id = $request->getAttribute('dept_id');


$sql="SELECT year FROM level WHERE dept_id=$dept_id";
$result=mysqli_query($con,$sql);
    while ($row[]=mysqli_fetch_assoc($result)) {  
      $cors=$row;
    }
    echo json_encode($cors);
  
});	

		                                                                                                                             //page4      //from_year
$app->get('/get/terms/{dept_id}', function (Request $request, Response $response) use ($app) {
/* Attempt to connect to MySQL database */
$con = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
$response=array();

$dept_id = $request->getAttribute('dept_id');


$sql="SELECT terms FROM level WHERE dept_id=$dept_id";
$result=mysqli_query($con,$sql);
    while ($row[]=mysqli_fetch_assoc($result)) {  
      $cors=$row;
    }
    echo json_encode($cors);
  
});	







                                                                                                                         /////////Seating Configuration Module3/////   page1


										                                                                                                          //insert_set_papers
$app->post('/insert/setpapers', function (Request $request, response $response) use ($app) {

$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
        $course_id=$request->getParsedBody()['course_id'];
        $level_id=$request->getParsedBody()['level_id'];
		$dept_id=$request->getParsedBody()['dept_id'];		
		$year=$request->getParsedBody()['year'];
		$term=$request->getParsedBody()['term'];
		$papers_shortcode=$request->getParsedBody()['papers_shortcode'];
		$paper_name=$request->getParsedBody()['paper_name'];
		$credits=$request->getParsedBody()['credits'];
		$type=$request->getParsedBody()['type'];
		
$response=array();

$sqll="(SELECT * FROM set_papers WHERE  papers_shortcode='$papers_shortcode' OR paper_name='$paper_name')";
$res= $con->query($sqll);
if($res->num_rows>0)
{
$response1=array('status' => "true",'Message' => "data already exist");
echo json_encode($response1);
}

else{
$sql="INSERT INTO set_papers(course_id,level_id,dept_id,year,term,papers_shortcode,paper_name,credits,type) VALUES ('$course_id','$level_id','$dept_id','$year','$term','$papers_shortcode','$paper_name','$credits','$type')";

$res= $con->query($sql);
	
if($res==true)
{
		$data=array(
	"course_id"=>$course_id,
	"level_id"=>$level_id,
	"dept_id"=>$dept_id,
	"year"=>$year,
	"term"=>$term,
	"papers_shortcode"=>$papers_shortcode,
	"paper_name"=>$paper_name,
	"credits"=>$credits,
	"type"=>$type,
	
	);
	    $message=$data;

	$response=array('status' => "true",'Message' => "Data inserted successfully",'set_papers' => $message);
echo json_encode($response);
        
}
        else{
          $response=array('status' => "false",'Message' => " insert data failed");
         echo json_encode($response);
        }   
		
	
}
});

                                                                                                                                             //UPDATE_SETPAPERS
$app->put('/update/setpapers/{papers_id}', function (Request $request, response $response) use ($app) {

 

$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);



        $papers_id = $request->getAttribute('papers_id');
	    $papers_shortcode=$request->getParsedBody()['papers_shortcode'];
		$paper_name=$request->getParsedBody()['paper_name'];
		$credits=$request->getParsedBody()['credits'];
		
				
	$sql= ("UPDATE set_papers SET papers_shortcode='$papers_shortcode' , paper_name='$paper_name' , credits='$credits' WHERE papers_id=$papers_id");	
	
 if($con->query($sql)){
		$data=array(
"papers_id" => $papers_id,
	
	"papers_shortcode"=>$papers_shortcode,
	"paper_name"=>$paper_name,
	"credits"=>$credits,
	);
	    $message=$data;
	

	
	$response=array('status' => "true",'Message' => "Data updated successfully",'setpapers' => $message);
echo json_encode($response);
        
}
        else{
          $response=array('status' => "false",'Message' => " update data failed");
         echo json_encode($response);
        }   
		
	

});

                                                                                                                                             //DELETE_SET_PAPERS

$app->DELETE('/delete/setpapers/{papers_id}', function (Request $request, response $response) use ($app) {

 

$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

$papers_id = $request->getAttribute('papers_id');

	$sql="delete from set_papers where papers_id='$papers_id'";	
	
 if($con->query($sql)){
		$data=array(
    "papers_id" => $papers_id,
	);
	    $message=$data;
	

	
	$response=array('status' => "true",'Message' => "Data deleted successfully",'setpapers' => $message);
echo json_encode($response);
        
}
        else{
          $response=array('status' => "false",'Message' => " delete data failed");
         echo json_encode($response);
        }   
		
	

});
  



///curriculum setup
 $app->get('/fetch/level/year/{dept_id}/{level_id}/{year}/{term}', function(Request $request) use ($app) {
    include '../function/curriculam/levelfetch.php';
});
$app->get('/fetch/level/year/{dept_id}/{level_id}/{year}', function(Request $request) use ($app) {
    include '../function/curriculam/levelfetch.php';
});
$app->get('/fetch/level/year/{dept_id}/{level_id}', function(Request $request) use ($app) {
    include '../function/curriculam/levelfetch.php';
});
$app->get('/fetch/level/year/{dept_id}', function(Request $request) use ($app) {
    include '../function/curriculam/levelfetch.php';
});

$app->get('/fetch/level/set_papers', function(Request $request) use ($app) {
    include '../function/curriculam/levelfetch.php';
});          



//set_classes_dd

$app->get('/fetch/set_classes_dd/{course_id}', function (Request $request, Response $response) use ($app) {
	include '../function/season/set_classes/set_classes_dd.php';	
});

//fetch_by
$app->get('/fetch/set_classes/{course_id}/{dept_id}/{level_id}/{year}', function (Request $request, Response $response) use ($app) {
	include '../function/season/set_classes/fetch_by.php';
});
$app->get('/fetch/set_classes/{course_id}/{dept_id}/{level_id}', function (Request $request, Response $response) use ($app) {
	include '../function/season/set_classes/fetch_by.php';
});
$app->get('/fetch/set_classes/{course_id}/{dept_id}', function (Request $request, Response $response) use ($app) {
	include '../function/season/set_classes/fetch_by.php';
});
$app->get('/fetch/set_classes/{course_id}', function (Request $request, Response $response) use ($app) {
	include '../function/season/set_classes/fetch_by.php';
});
$app->get('/fetch/set_classes', function (Request $request, Response $response) use ($app) {
	include '../function/season/set_classes/fetch_by.php';
});

//set_students


$app->get('/fetch_by/set_students/{course_id}/{session_id}/{dept_id}/{level_id}/{year}/{term}/{section}', function (Request $request, Response $response) use ($app) {
	include '../function/season/set_students/fetch_by.php';
});


$app->get('/fetch_by/set_students/{course_id}/{session_id}/{dept_id}/{level_id}/{year}/{term}', function (Request $request, Response $response) use ($app) {
	include '../function/season/set_students/fetch_by.php';
});
$app->get('/fetch_by/set_students/{course_id}/{session_id}/{dept_id}/{level_id}/{year}', function (Request $request, Response $response) use ($app) {
	include '../function/season/set_students/fetch_by.php';
});

$app->get('/fetch_by/set_students/{course_id}/{session_id}/{dept_id}/{level_id}', function (Request $request, Response $response) use ($app) {
	include '../function/season/set_students/fetch_by.php';
});
$app->get('/fetch_by/set_students/{course_id}/{session_id}/{dept_id}', function (Request $request, Response $response) use ($app) {
	include '../function/season/set_students/fetch_by.php';
});
$app->get('/fetch_by/set_students/{course_id}/{session_id}', function (Request $request, Response $response) use ($app) {
	include '../function/season/set_students/fetch_by.php';
});
$app->get('/fetch_by/set_students/{course_id}', function (Request $request, Response $response) use ($app) {
	include '../function/season/set_students/fetch_by.php';
});
$app->get('/fetch_by/set_students', function (Request $request, Response $response) use ($app) {
	include '../function/season/set_students/fetch_by.php';
});


///fetch_by_student_pool
$app->get('/fetch_by/student_pool/{course_id}/{session_id}/{dept_id}/{level_id}/{year}/{term}/{section}', function (Request $request, Response $response) use ($app) {
	include '../function/season/students_pool/fetch_by.php';
});


$app->get('/fetch_by/student_pool/{course_id}/{session_id}/{dept_id}/{level_id}/{year}/{term}', function (Request $request, Response $response) use ($app) {
	include '../function/season/students_pool/fetch_by.php';
});
$app->get('/fetch_by/student_pool/{course_id}/{session_id}/{dept_id}/{level_id}/{year}', function (Request $request, Response $response) use ($app) {
	include '../function/season/students_pool/fetch_by.php';
});

$app->get('/fetch_by/student_pool/{course_id}/{session_id}/{dept_id}/{level_id}', function (Request $request, Response $response) use ($app) {
	include '../function/season/students_pool/fetch_by.php';
});
$app->get('/fetch_by/student_pool/{course_id}/{session_id}/{dept_id}', function (Request $request, Response $response) use ($app) {
	include '../function/season/students_pool/fetch_by.php';
});
$app->get('/fetch_by/student_pool/{course_id}/{session_id}', function (Request $request, Response $response) use ($app) {
	include '../function/season/students_pool/fetch_by.php';
});
$app->get('/fetch_by/student_pool/{course_id}', function (Request $request, Response $response) use ($app) {
	include '../function/season/students_pool/fetch_by.php';
});
$app->get('/fetch_by/student_pool', function (Request $request, Response $response) use ($app) {
	include '../function/season/students_pool/fetch_by.php';
});

//suman studens pool
//Get Course
$app->get('/student_pool/getdata', function(Request $request) use ($app) {
    include '../functions/student/student_pool_dropdown_fetch.php';
});

//Get department
$app->get('/student_pool/getdata/{course_id}', function(Request $request) use ($app) {
    include '../functions/student/student_pool_dropdown_fetch.php';
});

//Get level Name
$app->get('/student_pool/getdata/{course_id}/{dept_id}', function(Request $request) use ($app) {
    include '../functions/student/student_pool_dropdown_fetch.php';
});

//Get level Name
$app->get('/student_pool/getdata/{course_id}/{dept_id}/{level_id}', function(Request $request) use ($app) {
    include '../functions/student/student_pool_dropdown_fetch.php';
});
//
//student_pool



$app->get('/get/count_student/{course_id}/{session_id}/{dept_id}/{level_id}/{year}/{term}/{section}', function (Request $request) use ($app) {
include '../function/season/students_pool/students_pool.php';
});

$app->get('/get/count_student/{course_id}/{session_id}/{dept_id}/{level_id}/{year}/{term}', function (Request $request) use ($app) {
include '../function/season/students_pool/students_pool.php';
});

$app->get('/get/count_student/{course_id}/{session_id}/{dept_id}/{level_id}/{year}', function (Request $request) use ($app) {
include '../function/season/students_pool/students_pool.php';
});

$app->get('/get/count_student/{course_id}/{session_id}/{dept_id}/{level_id}', function (Request $request) use ($app) {
include '../function/season/students_pool/students_pool.php';
});

$app->get('/get/count_student/{course_id}/{session_id}/{dept_id}', function (Request $request) use ($app) {
	include '../function/season/students_pool/students_pool.php';
});

$app->get('/get/count_student/{course_id}/{session_id}', function (Request $request) use ($app) {
	include '../function/season/students_pool/students_pool.php';
});
$app->get('/get/count_student/{course_id}', function (Request $request) use ($app) {
	include '../function/season/students_pool/students_pool.php';
});
$app->get('/get/count_student', function (Request $request) use ($app) {
	include '../function/season/students_pool/students_pool.php';
});

                                                                                                                                       ///total_students

$app->get('/total_students/{course_id}/{session_id}/{dept_id}/{level_id}/{year}/{term}/{section}', function (Request $request) use ($app) {
include '../function/season/totalstudents.php';
});

$app->get('/total_students/{course_id}/{session_id}/{dept_id}/{level_id}/{year}/{term}', function (Request $request) use ($app) {
include '../function/season/totalstudents.php';
});

$app->get('/total_students/{course_id}/{session_id}/{dept_id}/{level_id}/{year}', function (Request $request) use ($app) {
include '../function/season/totalstudents.php';
});

$app->get('/total_students/{course_id}/{session_id}/{dept_id}/{level_id}', function (Request $request) use ($app) {
include '../function/season/totalstudents.php';
});

$app->get('/total_students/{course_id}/{session_id}/{dept_id}', function (Request $request) use ($app) {
include '../function/season/totalstudents.php';
});

$app->get('/total_students/{course_id}/{session_id}', function (Request $request) use ($app) {
include '../function/season/totalstudents.php';
});

$app->get('/total_students/{course_id}', function (Request $request) use ($app) {
include '../function/season/totalstudents.php';
});

$app->get('/total_students', function (Request $request) use ($app) {
include '../function/season/totalstudents.php';
});



                                                                                                                                        ///all_clear_students
$app->get('/all_clear_students/{course_id}/{session_id}/{dept_id}/{level_id}/{year}/{term}/{section}', function (Request $request) use ($app) {
include '../function/season/all_clear_students.php';
});

$app->get('/all_clear_students/{course_id}/{session_id}/{dept_id}/{level_id}/{year}/{term}', function (Request $request) use ($app) {
include '../function/season/all_clear_students.php';
});

$app->get('/all_clear_students/{course_id}/{session_id}/{dept_id}/{level_id}/{year}', function (Request $request) use ($app) {
include '../function/season/all_clear_students.php';
});

$app->get('/all_clear_students/{course_id}/{session_id}/{dept_id}/{level_id}', function (Request $request) use ($app) {
include '../function/season/all_clear_students.php';
});

$app->get('/all_clear_students/{course_id}/{session_id}/{dept_id}', function (Request $request) use ($app) {
include '../function/season/all_clear_students.php';
});

$app->get('/all_clear_students/{course_id}/{session_id}', function (Request $request) use ($app) {
include '../function/season/all_clear_students.php';
});

$app->get('/all_clear_students/{course_id}', function (Request $request) use ($app) {
include '../function/season/all_clear_students.php';
});

$app->get('/all_clear_students', function (Request $request) use ($app) {
include '../function/season/all_clear_students.php';
});



                                                                                                                                         ///detained_students
$app->get('/detained_students/{course_id}/{session_id}/{dept_id}/{level_id}/{year}/{term}/{section}', function (Request $request) use ($app) {
include '../function/season/detained_students.php';
});

$app->get('/detained_students/{course_id}/{session_id}/{dept_id}/{level_id}/{year}/{term}', function (Request $request) use ($app) {
include '../function/season/detained_students.php';
});

$app->get('/detained_students/{course_id}/{session_id}/{dept_id}/{level_id}/{year}', function (Request $request) use ($app) {
include '../function/season/detained_students.php';
});

$app->get('/detained_students/{course_id}/{session_id}/{dept_id}/{level_id}', function (Request $request) use ($app) {
include '../function/season/detained_students.php';
});

$app->get('/detained_students/{course_id}/{session_id}/{dept_id}', function (Request $request) use ($app) {
include '../function/season/detained_students.php';
});

$app->get('/detained_students/{course_id}/{session_id}', function (Request $request) use ($app) {
include '../function/season/detained_students.php';
});

$app->get('/detained_students/{course_id}', function (Request $request) use ($app) {
include '../function/season/detained_students.php';
});

$app->get('/detained_students', function (Request $request) use ($app) {
include '../function/season/detained_students.php';
});


                                                                                                                                    ///buffered_students
$app->get('/buffered_students/{course_id}/{session_id}/{dept_id}/{level_id}/{year}/{term}/{section}', function (Request $request) use ($app) {
include '../function/season/buffered_students.php';
});

$app->get('/buffered_students/{course_id}/{session_id}/{dept_id}/{level_id}/{year}/{term}', function (Request $request) use ($app) {
include '../function/season/buffered_students.php';
});

$app->get('/buffered_students/{course_id}/{session_id}/{dept_id}/{level_id}/{year}', function (Request $request) use ($app) {
include '../function/season/buffered_students.php';
});

$app->get('/buffered_students/{course_id}/{session_id}/{dept_id}/{level_id}', function (Request $request) use ($app) {
include '../function/season/buffered_students.php';
});

$app->get('/buffered_students/{course_id}/{session_id}/{dept_id}', function (Request $request) use ($app) {
include '../function/season/buffered_students.php';
});

$app->get('/buffered_students/{course_id}/{session_id}', function (Request $request) use ($app) {
include '../function/season/buffered_students.php';
});

$app->get('/buffered_students/{course_id}', function (Request $request) use ($app) {
include '../function/season/buffered_students.php';
});

$app->get('/buffered_students', function (Request $request) use ($app) {
include '../function/season/buffered_students.php';
});


///insert_students
$app->post('/insert/total_students', function (Request $request, response $response) use ($app) {
include '../function/season/insert.php';	
});

///update_students
$app->put('/update/total_students/{id}', function (Request $request, response $response) use ($app) {
include '../function/season/update.php';	
});


///delete_students
$app->delete('/delete/total_students/{id}', function (Request $request, response $response) use ($app) {
	include '../function/season/delete.php';	
});


                                  
								  /////SEATING_CONFIGURATION
								  $app->get('/fetchcf/{block_id}', function (Request $request) use ($app) {
	include '../function/seating_configuration/fetchcf.php';	
}); 
								  $app->get('/fetchcf', function (Request $request) use ($app) {
	include '../function/seating_configuration/fetchcf.php';	
});
///set_blocks////seating_configuration
$app->get('/fetch/set_blocks', function (Request $request) use ($app) {
	include '../function/seating_configuration/set_blocks/fetch_blocks.php';	
});
$app->post('/insert/set_blocks', function (Request $request, response $response) use ($app) {
	include '../function/seating_configuration/set_blocks/insert_blocks.php';		
});
$app->put('/update/set_blocks/{block_id}', function (Request $request, response $response) use ($app) {
	include '../function/seating_configuration/set_blocks/update_blocks.php';		
});
$app->DELETE('/delete/set_blocks/{block_id}', function (Request $request, response $response) use ($app) {
	include '../function/seating_configuration/set_blocks/delete_blocks.php';		
});

///set_rooms////seating_configuration
$app->get('/set_rooms/{block_id}/{floors}', function (Request $request, response $response) use ($app) {
	include '../function/seating_configuration/set_rooms.php';	
});

$app->get('/set_rooms/{block_id}', function (Request $request, response $response) use ($app) {
	include '../function/seating_configuration/set_rooms.php';	
});
$app->get('/set_rooms', function (Request $request, response $response) use ($app) {
	include '../function/seating_configuration/set_rooms.php';	
});

$app->post('/insert/set_rooms', function (Request $request, response $response) use ($app) {
	include '../function/seating_configuration/insert_room.php';	
});
$app->put('/update/set_rooms/{room_id}', function (Request $request, response $response) use ($app) {
	include '../function/seating_configuration/update_room.php';	
});
$app->delete('/delete/set_rooms/{room_id}', function (Request $request, response $response) use ($app) {
	include '../function/seating_configuration/delete_room.php';	
});

//set_seats
$app->post('/insert/set_seats', function (Request $request, response $response) use ($app) {
	include '../function/seating_configuration/set_seats/insert.php';	
});

//exam_pre_ops
//assign_papers 
$app->get('/fetch/assign_papers/{course_id}/{season_id}/{exams_id}/{dept_id}/{level_id}/{year}/{term}/{type}/{papers_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/assign_papers/assign_papers.php';	
});

$app->get('/fetch/assign_papers/{course_id}/{season_id}/{exams_id}/{dept_id}/{level_id}/{year}/{term}/{type}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/assign_papers/assign_papers.php';	
});

$app->get('/fetch/assign_papers/{course_id}/{season_id}/{exams_id}/{dept_id}/{level_id}/{year}/{term}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/assign_papers/assign_papers.php';	
});

$app->get('/fetch/assign_papers/{course_id}/{season_id}/{exams_id}/{dept_id}/{level_id}/{year}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/assign_papers/assign_papers.php';	
});
$app->get('/fetch/assign_papers/{course_id}/{season_id}/{exams_id}/{dept_id}/{level_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/assign_papers/assign_papers.php';	
});
$app->get('/fetch/assign_papers/{course_id}/{season_id}/{exams_id}/{dept_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/assign_papers/assign_papers.php';	
});
$app->get('/fetch/assign_papers/{course_id}/{season_id}/{exams_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/assign_papers/assign_papers.php';	
});
$app->get('/fetch/assign_papers/{course_id}/{season_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/assign_papers/assign_papers.php';	
});
$app->get('/fetch/assign_papers/{course_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/assign_papers/assign_papers.php';	
});
$app->get('/fetch/assign_papers', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/assign_papers/assign_papers.php';	
});
//insert_assign_papers
$app->post('/add/assign_papers', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/assign_papers/insert.php';	
});
//
//insert_proctors_sheet
$app->post('/add/proctors_sheet', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/proctors_sheet/insert.php';	
});
//fetch_proctors_sheet
// $app->get('/fetch/proctors_sheet/{course_id}/{season_id}/{exams_id}', function (Request $request, response $response) use ($app) {
// 	include '../function/exam_pre_ops/proctors_sheet/fetch.php';	
// });
// $app->get('/fetch/proctors_sheet/{course_id}/{season_id}', function (Request $request, response $response) use ($app) {
// 	include '../function/exam_pre_ops/proctors_sheet/fetch.php';	
// });
// $app->get('/fetch/proctors_sheet/{course_id}', function (Request $request, response $response) use ($app) {
// 	include '../function/exam_pre_ops/proctors_sheet/fetch.php';	
// });
// $app->get('/fetch/proctors_sheet', function (Request $request, response $response) use ($app) {
// 	include '../function/exam_pre_ops/proctors_sheet/fetch.php';	
// });

///create_slots
//fetch_by
$app->get('/fetch_by/create_slots/{course_id}/{season_id}/{exams_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/create_slots/fetch_by.php';	
});
$app->get('/fetch_by/create_slots/{course_id}/{season_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/create_slots/fetch_by.php';	
});
$app->get('/fetch_by/create_slots/{course_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/create_slots/fetch_by.php';	
});
$app->get('/fetch_by/create_slots', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/create_slots/fetch_by.php';	
});


//fetch slots recorrect
$app->get('/fetch/create_slots_rc/{course_id}/{season_id}/{exams_id}/{paper}/{slots}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/create_slots/fetch_create_slots_rc.php';	
});
$app->get('/fetch/create_slots_rc/{course_id}/{season_id}/{exams_id}/{paper}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/create_slots/fetch_create_slots_rc.php';	
});
$app->get('/fetch/create_slots_rc/{course_id}/{season_id}/{exams_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/create_slots/fetch_create_slots_rc.php';	
});
$app->get('/fetch/create_slots_rc/{course_id}/{season_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/create_slots/fetch_create_slots_rc.php';	
});
$app->get('/fetch/create_slots_rc/{course_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/create_slots/fetch_create_slots_rc.php';	
});
$app->get('/fetch/create_slots_rc', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/create_slots/fetch_create_slots_rc.php';	
});


//get slots

$app->get('/fetch/get_slots/{paper_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/create_slots/get_slots.php';	
});



//fetch
$app->get('/fetch/create_slots/{course_id}/{season_id}/{exams_id}/{paper}/{slots}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/create_slots/fetch_create_slots.php';	
});
$app->get('/fetch/create_slots/{course_id}/{season_id}/{exams_id}/{paper}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/create_slots/fetch_create_slots.php';	
});
$app->get('/fetch/create_slots/{course_id}/{season_id}/{exams_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/create_slots/fetch_create_slots.php';	
});
$app->get('/fetch/create_slots/{course_id}/{season_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/create_slots/fetch_create_slots.php';	
});
$app->get('/fetch/create_slots/{course_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/create_slots/fetch_create_slots.php';	
});
$app->get('/fetch/create_slots', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/create_slots/fetch_create_slots.php';	
});

//insert_slots
$app->post('/insert/create_slots', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/create_slots/insert.php';	
});
//update_slots
$app->put('/update/create_slots/{id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/create_slots/update.php';	
});
//delete_slots
$app->delete('/delete/create_slots/{id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/create_slots/delete.php';	
});

//assign_pwt
//fetch_staff_number
$app->get('/fetch/staff_number/{course_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/assign_pwt/fetch_staff_number.php';	
});

//assign_pwt-list
//fetch_staff_number
$app->get('/fetch/staff_number/{course_id}/{paper_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/assign_pwt/fetch_staff_number_list.php';	
});

$app->get('/fetch/assign_pwt/{course_id}/{season_id}/{exams_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/assign_pwt/fetch_assign_pwt.php';	
});

$app->get('/fetch/assign_pwt/{course_id}/{season_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/assign_pwt/fetch_assign_pwt.php';	
});


$app->get('/fetch/assign_pwt/{course_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/assign_pwt/fetch_assign_pwt.php';	
});

$app->get('/fetch/assign_pwt', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/assign_pwt/fetch_assign_pwt.php';	
});

//insert_assign_pwt
$app->post('/insert/assign_pwt', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/assign_pwt/insert.php';	
});
//update_assign_pwt
$app->put('/update/assign_pwt/{id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/assign_pwt/update.php';	
});
//delete_assign_pwt
$app->delete('/delete/assign_pwt/{id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/assign_pwt/delete.php';	
});


//seating_arrangement

$app->get('/set/seating_arrangement/{set_blocks_block_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/seating_arrangement/seat_arrangement.php';	
});

$app->get('/set/seating_arrangement', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/seating_arrangement/seat_arrangement.php';	
});
//insert_seating_arrangement
$app->post('/add/seating_arrangement', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/seating_arrangement/insert.php';	
});

//set&assign_proctors

$app->get('/set&assign_proctors/{course_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/set&assign_proctors/set_assign_proctors.php';	
});
//insert
$app->post('/insert/set&assign_proctors', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/set&assign_proctors/insert.php';	
});

//set_syllabus

$app->get('/fetch/set_syllabus/{course_id}/{season_id}/{exams_id}/{paper}/{slots}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/setsyllabus/set_syllabus.php';	
});
$app->get('/fetch/set_syllabus/{course_id}/{season_id}/{exams_id}/{paper}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/setsyllabus/set_syllabus.php';	
});
$app->get('/fetch/set_syllabus/{course_id}/{season_id}/{exams_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/setsyllabus/set_syllabus.php';	
});
$app->get('/fetch/set_syllabus/{course_id}/{season_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/setsyllabus/set_syllabus.php';	
});
$app->get('/fetch/set_syllabus/{course_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/setsyllabus/set_syllabus.php';	
});
$app->get('/fetch/set_syllabus', function (Request $request, response $response) use ($app) {
	include '../function/exam_pre_ops/setsyllabus/set_syllabus.php';	
});
//fetch_units
$app->get('/get/ddunits/{set_papers_id}', function (Request $request, Response $response) use ($app) {
include '../function/exam_pre_ops/setsyllabus/fetch_units.php';	
});
//fetch_chapter
$app->get('/get/ddchapter/{unit_id}', function (Request $request, Response $response) use ($app) {
	include '../function/exam_pre_ops/setsyllabus/fetch_chapter.php';
});
//fetch_main_topics
$app->get('/get/ddmaintopics/{chapter_id}', function (Request $request, Response $response) use ($app) {
	include '../function/exam_pre_ops/setsyllabus/fetch_main_topics.php';
});
//fetch_sub_topics
$app->get('/get/ddsubtopics/{main_topics_id}', function (Request $request, Response $response) use ($app) {
	include '../function/exam_pre_ops/setsyllabus/fetch_sub_topics.php';
});




//PWT
///DASHBOARD
$app->get('/fetch/dashboard/{course_id}', function (Request $request, response $response) use ($app) {
	include '../function/pwt/pwt_dashboard/fetch.php';	
});

//set_syllabus
$app->get('/get/set_syllabus/{course_id}/{season_id}/{exams_id}/{paper}/{slots}', function (Request $request, response $response) use ($app) {
	include '../function/pwt/set_syllabus/set_syllabus.php';	
});
$app->get('/get/set_syllabus/{course_id}/{season_id}/{exams_id}/{paper}', function (Request $request, response $response) use ($app) {
	include '../function/pwt/set_syllabus/set_syllabus.php';	
});
$app->get('/get/set_syllabus/{course_id}/{season_id}/{exams_id}', function (Request $request, response $response) use ($app) {
	include '../function/pwt/set_syllabus/set_syllabus.php';	
});
$app->get('/get/set_syllabus/{course_id}/{season_id}', function (Request $request, response $response) use ($app) {
	include '../function/pwt/set_syllabus/set_syllabus.php';	
});
$app->get('/get/set_syllabus/{course_id}', function (Request $request, response $response) use ($app) {
	include '../function/pwt/set_syllabus/set_syllabus.php';	
});
$app->get('/get/set_syllabus', function (Request $request, response $response) use ($app) {
	include '../function/pwt/set_syllabus/set_syllabus.php';	
});
//fetch_units
$app->get('/get/dunits/{set_papers_id}', function (Request $request, Response $response) use ($app) {
include '../function/pwt/set_syllabus/fetch_units.php';	
});
//fetch_chapter
$app->get('/get/dchapter/{unit_id}', function (Request $request, Response $response) use ($app) {
	include '../function/pwt/set_syllabus/fetch_chapter.php';
});
//fetch_main_topics
$app->get('/get/dmaintopics/{chapter_id}', function (Request $request, Response $response) use ($app) {
	include '../function/pwt/set_syllabus/fetch_main_topics.php';
});
//fetch_sub_topics
$app->get('/get/dsubtopics/{main_topics_id}', function (Request $request, Response $response) use ($app) {
	include '../function/pwt/set_syllabus/fetch_sub_topics.php';
});

//set_students

///dropdown_fetch
$app->get('/ddfetch_by/{course_id}/{season_id}/{exams_id}/{paper}/{slots}', function (Request $request, response $response) use ($app) {
	include '../function/pwt/set_students/fetch_by.php';	
});
$app->get('/ddfetch_by/{course_id}/{season_id}/{exams_id}/{paper}', function (Request $request, response $response) use ($app) {
	include '../function/pwt/set_students/fetch_by.php';	
});
$app->get('/ddfetch_by/{course_id}/{season_id}/{exams_id}', function (Request $request, response $response) use ($app) {
	include '../function/pwt/set_students/fetch_by.php';	
});
$app->get('/ddfetch_by/{course_id}/{season_id}', function (Request $request, response $response) use ($app) {
	include '../function/pwt/set_students/fetch_by.php';	
});
$app->get('/ddfetch_by/{course_id}', function (Request $request, response $response) use ($app) {
	include '../function/pwt/set_students/fetch_by.php';	
});
$app->get('/ddfetch_by', function (Request $request, response $response) use ($app) {
	include '../function/pwt/set_students/fetch_by.php';	
});

//fetch_students
$app->get('/fetchstud/{course_id}', function (Request $request, response $response) use ($app) {
	include '../function/pwt/set_students/fetch_students.php';	
});
$app->get('/fetchstud', function (Request $request, response $response) use ($app) {
	include '../function/pwt/set_students/fetch_students.php';	
});

///insert
$app->post('/insert/setstudents/pwt', function (Request $request, Response $response) use ($app) {
  include '../function/pwt/set_students/insert.php';
});

//set_sections
//insert_set_sections
$app->post('/add/set_sections', function (Request $request, response $response) use ($app) {
	include '../function/pwt/set_sections/insert.php';	
});
//fetch_set_sections
$app->get('/fetch/set_sections/{paper_id}', function (Request $request, response $response) use ($app) {
	include '../function/pwt/set_sections/fetch.php';	
});
$app->get('/fetch/set_sections', function (Request $request, response $response) use ($app) {
	include '../function/pwt/set_sections/fetch.php';	
});
//fetch_by
$app->get('/fetch_by/set_sections', function (Request $request, response $response) use ($app) {
	include '../function/pwt/set_sections/fetch_by.php';	
});
//update_set_sections
$app->put('/update/set_sections/{id}', function (Request $request, response $response) use ($app) {
	include '../function/pwt/set_sections/update.php';	
});
//delete_set_sections
$app->delete('/delete/set_sections/{id}', function (Request $request, response $response) use ($app) {
	include '../function/pwt/set_sections/delete.php';	
});



//set_Q_papers
//

$app->get('/fetch/pwtQ_papers/{id}', function (Request $request, response $response) use ($app) {
	include '../function/pwt/set_Q_papers/pwtQ_papers.php';	
});

$app->get('/fetch/set_Q_papers/{set_sections_id}', function (Request $request, response $response) use ($app) {
	include '../function/pwt/set_Q_papers/fetch.php';	
});
$app->get('/fetch/set_Q_papers', function (Request $request, response $response) use ($app) {
	include '../function/pwt/set_Q_papers/fetch.php';	
});

//get question paper
$app->get('/fetch/get_Q_papers/{set_sections_id}', function (Request $request, response $response) use ($app) {
	include '../function/pwt/set_Q_papers/get_question.php';	
});


//insert_set_Q_papers
$app->post('/insert/set_Q_papers', function (Request $request, response $response) use ($app) {
	include '../function/pwt/set_Q_papers/insert.php';	
});
//update_set_Q_papers
$app->put('/update/set_Q_papers/{id}', function (Request $request, response $response) use ($app) {
	include '../function/pwt/set_Q_papers/update.php';	
});
//delete_set_Q_papers
$app->delete('/delete/set_Q_papers/{id}', function (Request $request, response $response) use ($app) {
	include '../function/pwt/set_Q_papers/delete.php';	
});


//question_pattern
//insert_question_pattern
$app->post('/add/question_pattern', function (Request $request, response $response) use ($app) {
	include '../function/pwt/question_pattern/insert.php';	
});
//fetch_question_pattern
$app->get('/fetch/question_pattern/{set_sections_id}/{set_Q_papers_id}', function (Request $request, response $response) use ($app) {
	include '../function/pwt/question_pattern/fetch.php';	
});
$app->get('/fetch/question_pattern/{set_sections_id}', function (Request $request, response $response) use ($app) {
	include '../function/pwt/question_pattern/fetch.php';	
});
$app->get('/fetch/question_pattern', function (Request $request, response $response) use ($app) {
	include '../function/pwt/question_pattern/fetch.php';	
});


//student_base
$app->put('/update/archive_students', function (Request $request, Response $response) use ($app) {
	include '../function/student_base/archive_student.php';	
});

$app->post('/register/student', function (Request $request, Response $response) use ($app) {
	include '../function/student_base/register.php';	
});

//fetch_archived_students
$app->get('/fetch/archived_students/{course}/{department}/{level_id}', function (Request $request, Response $response) use ($app) {
	include '../function/student_base/fetch_archived_students.php';	
});
$app->get('/fetch/archived_students/{course}/{department}', function (Request $request, Response $response) use ($app) {
	include '../function/student_base/fetch_archived_students.php';	
});
$app->get('/fetch/archived_students/{course}', function (Request $request, Response $response) use ($app) {
	include '../function/student_base/fetch_archived_students.php';	
});
$app->get('/fetch/archived_students', function (Request $request, Response $response) use ($app) {
	include '../function/student_base/fetch_archived_students.php';	
});

//exam_day_ops
//pwi_deliverables
$app->get('/fetch/pwi_deliverables/{course_id}/{season_id}/{exams_id}/{date}/{time}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/pwi_deliverables.php';	
});
$app->get('/fetch/pwi_deliverables/{course_id}/{season_id}/{exams_id}/{date}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/pwi_deliverables.php';	
});
$app->get('/fetch/pwi_deliverables/{course_id}/{season_id}/{exams_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/pwi_deliverables.php';	
});
$app->get('/fetch/pwi_deliverables/{course_id}/{season_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/pwi_deliverables.php';	
});
$app->get('/fetch/pwi_deliverables/{course_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/pwi_deliverables.php';	
});

$app->get('/fetch/pwi_deliverables', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/pwi_deliverables.php';	
});

//count_students
$app->get('/count/students/{course_id}/{season_id}/{exams_id}/{date_time}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/count_students.php';	
});
$app->get('/count/students/{course_id}/{season_id}/{exams_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/count_students.php';	
});
$app->get('/count/students/{course_id}/{season_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/count_students.php';	
});
$app->get('/count/students/{course_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/count_students.php';	
});
$app->get('/count/students', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/count_students.php';	
});

//monitor_pwi_submission
$app->get('/fetch/monitor_pwi_submission/{course_id}/{season_id}/{exams_id}/{date}/{time}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/pwi_submission.php';	
});
$app->get('/fetch/monitor_pwi_submission/{course_id}/{season_id}/{exams_id}/{date}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/pwi_submission.php';	
});
$app->get('/fetch/monitor_pwi_submission/{course_id}/{season_id}/{exams_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/pwi_submission.php';	
});
$app->get('/fetch/monitor_pwi_submission/{course_id}/{season_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/pwi_submission.php';	
});
$app->get('/fetch/monitor_pwi_submission/{course_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/pwi_submission.php';	
});
$app->get('/fetch/monitor_pwi_submission', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/pwi_submission.php';	
});
///count_status
//absent
$app->get('/count_absent/monitor_pwi_submission/{course_id}/{season_id}/{exams_id}/{date_time}/{proctor_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/count_status.php';	
});
$app->get('/count_absent/monitor_pwi_submission/{course_id}/{season_id}/{exams_id}/{date_time}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/count_status.php';	
});
$app->get('/count_absent/monitor_pwi_submission/{course_id}/{season_id}/{exams_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/count_status.php';	
});
$app->get('/count_absent/monitor_pwi_submission/{course_id}/{season_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/count_status.php';	
});
$app->get('/count_absent/monitor_pwi_submission/{course_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/count_status.php';	
});
$app->get('/count_absent/monitor_pwi_submission', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/count_status.php';	
});
//present
$app->get('/count_present/monitor_pwi_submission/{course_id}/{season_id}/{exams_id}/{date_time}/{proctor_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/count_status.php';	
});
$app->get('/count_present/monitor_pwi_submission/{course_id}/{season_id}/{exams_id}/{date_time}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/count_status.php';	
});
$app->get('/count_present/monitor_pwi_submission/{course_id}/{season_id}/{exams_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/count_status.php';	
});
$app->get('/count_present/monitor_pwi_submission/{course_id}/{season_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/count_status.php';	
});
$app->get('/count_present/monitor_pwi_submission/{course_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/count_status.php';	
});
$app->get('/count_present/monitor_pwi_submission', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/count_status.php';	
});
//Malpractice
$app->get('/count_Malpractice/monitor_pwi_submission/{course_id}/{season_id}/{exams_id}/{date_time}/{proctor_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/count_status.php';	
});
$app->get('/count_Malpractice/monitor_pwi_submission/{course_id}/{season_id}/{exams_id}/{date_time}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/count_status.php';	
});
$app->get('/count_Malpractice/monitor_pwi_submission/{course_id}/{season_id}/{exams_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/count_status.php';	
});
$app->get('/count_Malpractice/monitor_pwi_submission/{course_id}/{season_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/count_status.php';	
});
$app->get('/count_Malpractice/monitor_pwi_submission/{course_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/count_status.php';	
});
$app->get('/count_Malpractice/monitor_pwi_submission', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/count_status.php';	
});

//export_pwi_submission
$app->get('/export/pwi_submission/{course_id}/{season_id}/{exams_id}/{date_time}/{proctor_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/export_pwi_submission.php';	
});
$app->get('/export/pwi_submission/{course_id}/{season_id}/{exams_id}/{date_time}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/export_pwi_submission.php';	
});
$app->get('/export/pwi_submission/{course_id}/{season_id}/{exams_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/export_pwi_submission.php';	
});
$app->get('/export/pwi_submission/{course_id}/{season_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/export_pwi_submission.php';	
});
$app->get('/export/pwi_submission/{course_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/export_pwi_submission.php';	
});
$app->get('/export/pwi_submission', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/export_pwi_submission.php';	
});

//exam_day_ops
//dashboard
$app->get('/dashboard/exam_day_ops/{course_id}/{season_id}/{exams_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/dashboard.php';	
});
$app->get('/dashboard/exam_day_ops/{course_id}/{season_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/dashboard.php';	
});
$app->get('/dashboard/exam_day_ops/{course_id}', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/dashboard.php';	
});
$app->get('/dashboard/exam_day_ops', function (Request $request, response $response) use ($app) {
	include '../function/exam_day_ops/dashboard.php';	
});





//PWE
///DASHBOARD
$app->get('/get/pwe_dashboard/{course_id}', function (Request $request, response $response) use ($app) {
	include '../function/pwe/dashboard/pwe_dashboard.php';	
});

//evaluate_answer_scripts
$app->get('/fetch/evaluate_answer_scripts/{paper}/{slot}', function (Request $request, response $response) use ($app) {
	include '../function/pwe/eva_ans_scripts/fetch.php';	
});
$app->get('/fetch/evaluate_answer_scripts/{paper}', function (Request $request, response $response) use ($app) {
	include '../function/pwe/eva_ans_scripts/fetch.php';	
});
$app->get('/fetch/evaluate_answer_scripts', function (Request $request, response $response) use ($app) {
	include '../function/pwe/eva_ans_scripts/fetch.php';	
});

///exam_result
$app->post('/add/evaluate_answer_scripts', function (Request $request, response $response) use ($app) {
	include '../function/pwe/evaluate/insert.php';	
});


///re-evaluate_answer_scripts
$app->get('/get/re-evaluate', function (Request $request, response $response) use ($app) {
	include '../function/pwe/re_evaluate_answer_scripts/fetch.php';	
});

///re-evaluate_answer_scripts
$app->put('/update/re-evaluate', function (Request $request, response $response) use ($app) {
	include '../function/pwe/re_evaluate/update.php';	
});


//export_grade
$app->get('/export/grading_students', function (Request $request, response $response) use ($app) {
	include '../function/pwe/export_grading_students/fetch.php';	
});


/*
//evaluate_answer_scripts
$app->post('/add/evaluate_answer_scripts', function (Request $request, response $response) use ($app) {
	include '../function/pwe/eva_ans_scripts/insert.php';	
});
*/
///count_evaluate_answer_scripts
///students
$app->get('/count/evaluate_answer_scripts/{paper}/{slot}', function (Request $request, response $response) use ($app) {
	include '../function/pwe/eva_ans_scripts/count.php';	
});

$app->get('/count/evaluate_answer_scripts/{paper}', function (Request $request, response $response) use ($app) {
	include '../function/pwe/eva_ans_scripts/count.php';	
});

$app->get('/count/evaluate_answer_scripts', function (Request $request, response $response) use ($app) {
	include '../function/pwe/eva_ans_scripts/count.php';	
});



//exam_base/////////////
$app->post('/add/exam_base', function (Request $request, response $response) use ($app) {
	include '../function/exam_base/insert.php';	
});
	
	//start_exams
	//fetch
$app->get('/fetch/start_exam/{course_id}/{season_id}', function (Request $request) use ($app) {
		include '../function/exam_base/fetch_start_exam.php';
	});
	$app->get('/fetch/start_exam/{course_id}', function (Request $request) use ($app) {
		include '../function/exam_base/fetch_start_exam.php';
	});
	$app->get('/fetch/start_exam', function (Request $request) use ($app) {
		include '../function/exam_base/fetch_start_exam.php';
	});
	//update_start_exam
	$app->get('/update/start_exam/{id}', function (Request $request) use ($app) {
		include '../function/exam_base/start_exam.php';
	});
//update_end_exam
	$app->put('/update/end_exam/{id}', function (Request $request) use ($app) {
		include '../function/exam_base/end_exam.php';
	});

//ajith
	$app->post('/file', function (Request $request) use ($app) {
		include '../function/pwe/pdf.php';
	});

////------------------------------------------monitor evaluation screen 1-----------------------------------------////
	///exam_post_ops
	///monitor_eva
	//SCREEN 1

	$app->get('/fetch/monitor_eva/{course_id}/{exams_id}/{date}/{time}', function (Request $request) use ($app) {
		include '../function/exam_post_ops/monitor_evaluation1/monitor_eva.php';
	});
	$app->get('/fetch/monitor_eva/{course_id}/{exams_id}/{date}', function (Request $request) use ($app) {
		include '../function/exam_post_ops/monitor_evaluation1/monitor_eva.php';
	});
	$app->get('/fetch/monitor_eva/{course_id}/{exams_id}', function (Request $request) use ($app) {
		include '../function/exam_post_ops/monitor_evaluation1/monitor_eva.php';
	});
	$app->get('/fetch/monitor_eva/{course_id}', function (Request $request) use ($app) {
		include '../function/exam_post_ops/monitor_evaluation1/monitor_eva.php';
	});
	

	//evaluated_count
	$app->get('/count/evaluated/{course_id}/{exams_id}/{date}/{time}', function (Request $request) use ($app) {
		include '../function/exam_post_ops/monitor_evaluation1/evaluated.php';
	});
	$app->get('/count/evaluated/{course_id}/{exams_id}/{date}', function (Request $request) use ($app) {
		include '../function/exam_post_ops/monitor_evaluation1/evaluated.php';
	});
	$app->get('/count/evaluated/{course_id}/{exams_id}', function (Request $request) use ($app) {
		include '../function/exam_post_ops/monitor_evaluation1/evaluated.php';
	});
	$app->get('/count/evaluated/{course_id}', function (Request $request) use ($app) {
		include '../function/exam_post_ops/monitor_evaluation1/evaluated.php';
	});
	
///------------------------------------------------monitor evaluation screen 2----------------------------------------------///
	 //SCREEN2
	///monitor_evalution_FETCH
	$app->get('/monitor_evalution/{course_id}/{exams_id}/{papers_shortcode}/{slots}', function (Request $request) use ($app) {
		include '../function/exam_post_ops/monitor_evaluation2/monitor_evaluation.php';
	});
	$app->get('/monitor_evalution/{course_id}/{exams_id}/{papers_shortcode}', function (Request $request) use ($app) {
		include '../function/exam_post_ops/monitor_evaluation2/monitor_evaluation.php';
	});
	
	$app->get('/monitor_evalution/{course_id}/{exams_id}', function (Request $request) use ($app) {
		include '../function/exam_post_ops/monitor_evaluation2/monitor_evaluation.php';
	});
	$app->get('/monitor_evalution/{course_id}', function (Request $request) use ($app) {
		include '../function/exam_post_ops/monitor_evaluation2/monitor_evaluation.php';
	});
	

	//monitor_evaluation_count
	$app->get('/evalution/count/{course_id}/{exams_id}/{papers_shortcode}/{slots}', function (Request $request) use ($app) {
		include '../function/exam_post_ops/monitor_evaluation2/count.php';
	});
	
	//total_files_COUNT
	$app->get('/total_files/{course_id}/{exams_id}/{papers_shortcode}/{slot}', function (Request $request) use ($app) {
		include '../function/exam_post_ops/monitor_evaluation2/total_files.php';
	});
	
	
//-------------------------------------------------------review results screen------------------------------------------//

//screen3
	//review_results_FETCH
	$app->get('/review_results/{course_id}/{exams_id}/{papers_shortcode}', function (Request $request) use ($app) {
		include '../function/exam_post_ops/review_results/fetch_results.php';
	});
	$app->get('/review_results/{course_id}/{exams_id}', function (Request $request) use ($app) {
		include '../function/exam_post_ops/review_results/fetch_results.php';
	});
	$app->get('/review_results/{course_id}', function (Request $request) use ($app) {
		include '../function/exam_post_ops/review_results/fetch_results.php';
	});

	
	//review_results_count
	//passed/absent/failed
	$app->get('/review_results_count/{course_id}/{exams_id}/{papers_id}', function (Request $request) use ($app) {
		include '../function/exam_post_ops/review_results/count_state.php';
	});


	//total_students_COUNT
	$app->get('/total_students_result/{course_id}/{exams_id}/{papers_shortcode}', function (Request $request) use ($app) {
		include '../function/exam_post_ops/review_results/total_student.php';
	});


//---------------------------------------------publish_results_screen-----------------------------------------//
	//publish_results_screen
	
	//dropdown
	$app->get('/dd_publish/{course_id}/{exams_id}', function (Request $request) use ($app) {
		include '../function/exam_post_ops/publish_results/dd.php';
	});
	$app->get('/dd_publish/{course_id}', function (Request $request) use ($app) {
		include '../function/exam_post_ops/publish_results/dd.php';
	});
	
	//count
	$app->get('/publish_result_count/{course_id}/{exams_id}/{papers_shortcode}', function (Request $request) use ($app) {
		include '../function/exam_post_ops/publish_results/count.php';
	});

	//publish_result
	$app->get('/publish_result/{papers_id}', function (Request $request) use ($app) {
		include '../function/exam_post_ops/publish_results/publish_results.php';
	});

	//publish_all
	$app->get('/publish_all/{papers_id}', function (Request $request) use ($app) {
		include '../function/exam_post_ops/publish_results/publish_all.php';
	});

//----------------------------------------------monitor_disputes_screen---------------------------------------//
	//monitor_disputes_screen
	// //count


		//publish_result
		$app->get('/re_publish_result/{papers_id}', function (Request $request) use ($app) {
			include '../function/exam_post_ops/monitor_disputes/re_publish.php';
		});

		//publish_all
		$app->get('/re_publish_all/{papers_id}', function (Request $request) use ($app) {
			include '../function/exam_post_ops/monitor_disputes/re_publish_all.php';
		});


		//monitor_disputes
		$app->get('/monitor_disputes/{course_id}/{exams_id}/{papers_shortcode}', function (Request $request) use ($app) {
			include '../function/exam_post_ops/monitor_disputes/monitor_disputes.php';
		});
		$app->get('/monitor_disputes/{course_id}/{exams_id}', function (Request $request) use ($app) {
			include '../function/exam_post_ops/monitor_disputes/monitor_disputes.php';
		});
		$app->get('/monitor_disputes/{course_id}', function (Request $request) use ($app) {
			include '../function/exam_post_ops/monitor_disputes/monitor_disputes.php';
		});

	///----------------------------------------------------------------------------------------------------------------///

	//exam_base
	$app->get('/exam_list/{course_id}/{exams_id}/{papers_shortcode}', function (Request $request) use ($app) {
		include '../function/exam_base/exam_list/fetch.php';
	});
	$app->get('/exam_list/{course_id}/{exams_id}', function (Request $request) use ($app) {
		include '../function/exam_base/exam_list/fetch.php';
	});
	$app->get('/exam_list/{course_id}', function (Request $request) use ($app) {
		include '../function/exam_base/exam_list/fetch.php';
	});

	///count
	$app->get('/exam_list_count/{course_id}/{exams_id}/{papers_shortcode}', function (Request $request) use ($app) {
		include '../function/exam_base/exam_list/count.php';
	});

	//update
	$app->put('/update_exam_list/{id}', function (Request $request) use ($app) {
		include '../function/exam_base/exam_list/update.php';
	});

	//delete
	$app->delete('/delete_exam_list/{id}', function (Request $request) use ($app) {
		include '../function/exam_base/exam_list/delete.php';
	});


	//-----------------------------------------------------------------------------------------------------------------//
	//Report
	//count
	$app->get('/get_report_count/{course_id}/{exams_id}/{papers_shortcode}', function (Request $request) use ($app){
		include '../function/exam_base/report/count.php';
	});
                              //-------------------------------------------------//
	//fetch_RS
	$app->get('/fetch_rs_report/{course_id}/{exams_id}/{papers_shortcode}', function (Request $request) use($app){
		include '../function/exam_base/report/fetch_RS.php';
	});
	$app->get('/fetch_rs_report/{course_id}/{exams_id}', function (Request $request) use($app){
		include '../function/exam_base/report/fetch_RS.php';
	});
	$app->get('/fetch_rs_report/{course_id}', function (Request $request) use($app){
		include '../function/exam_base/report/fetch_RS.php';
	});
							  //-------------------------------------------------//
	//chart
	$app->get('/chart_report', function(Request $request) use ($app){
		include '../function/exam_base/report/chart.php';
	});						  



			///sinnamuthu///

//student enable

$app->get('/disabled/student/{student_id}', function (Request $request) use ($app) {

 
/* Attempt to connect to MySQL database */
$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

 
    //Verifying the required parameters
    // verifyRequiredParams(array('firstname', 'email', 'password'));
$id=$request->getAttribute('student_id');

 $data=array();

 $query1="SELECT * FROM student WHERE student_id='$id' ";
 $res=mysqli_query($con,$query1);
 while($row=mysqli_fetch_assoc($res)){
$status=$row['status'];
 }

 if ($status=='1') {
   $query = "UPDATE  student SET status='0' WHERE student_id=$id";
 $stmt = $con->prepare($query);
  //$stmt->execute();
 $result = $stmt->execute();
        $stmt->close();
        if($result==true){

$response=array('status' => "true",'Message' => "student Disabled  Succesfully");
echo json_encode($response);
        }
        else{
          $response=array('status' => "false",'Message' => "student Disabled Failed");
         echo json_encode($response);
        }   
 }

 else{
   $query = "UPDATE  student SET status='1' WHERE student_id=$id";
 $stmt = $con->prepare($query);
  //$stmt->execute();
 $result = $stmt->execute();
        $stmt->close();
        if($result==true){

$response=array('status' => "true",'Message' => "student Enabled  Succesfully");
echo json_encode($response);
        }
        else{
          $response=array('status' => "false",'Message' => "student Disabled Failed");
         echo json_encode($response);
        }   
 }

 
});


//Exam post ops

//4 screen
$app->get('/fetch/publish_results/{course_id}/{semester_id}/{exams_id}', function(Request $request, response $response) use($app){
   include '../functions/post_ops/publish_results.php'; 
});


//3 screen
$app->get('/fetch/pap_monitor_evaluation/{course_id}/{semester_id}/{exams_id}/{paper}', function(Request $request, response $response) use($app){
   include '../functions/post_ops/pap_monitor_evaluation.php'; 
});

//2st screen
$app->get('/fetch/pap_monitor_evaluation/{course_id}/{semester_id}/{exams_id}/{paper}/{slot}', function(Request $request, response $response) use($app){
   include '../functions/post_ops/pap_monitor_evaluation.php'; 
});


//1st screen
$app->get('/fetch/monitor_evaluation/{course_id}/{semester_id}/{exams_id}/{date}/{time}', function(Request $request, response $response) use($app){
   include '../functions/post_ops/monitor_evaluation.php'; 
});
$app->get('/fetch/monitor_evaluation/{course_id}', function(Request $request, response $response) use($app){
   include '../functions/post_ops/monitor_evaluation.php'; 
});


//pwe 
//question pattern submit


$app->post('/insert/question_pattern_answer', function (Request $request, response $response) use ($app) {
 include '../functions/pwe/question_pattern_submit.php';
});

$app->get('/fetch/evaluvate/{id}', function(Request $request, response $response) use($app){
   include '../functions/pwe/evaluvate_answer.php'; 
});

//get question paper
$app->get('/fetch/pwe/get_Q_papers/{id}/{set_sections_id}', function (Request $request, response $response) use ($app) {
	include '../functions/pwe/get_question.php';	
});


// Syllabus fetch
$app->get('/fetch/syllabus_pwt/{id}', function(Request $request, response $response) use($app){
   include '../functions/pwt_syllabus/fetch.php'; 
});

//File Upload
$app->post('/upload/students_file', function (Request $request, response $response) use ($app) {
 include '../functions/file/pwi_file_upload.php';
});


//Syllabus insert unit
$app->post('/insert/units_final', function (Request $request, response $response) use ($app) {
 include '../functions/units/insert.php';
});

//PWT Syllabus insert unit
$app->post('/insert/pwt_units_final', function (Request $request, response $response) use ($app) {
 include '../functions/units/pwt_units_final.php';
});

// Curriculum fetch Syllabus
$app->get('/fetch/curriculum/syllabus_datas/{id}', function(Request $request, response $response) use($app){
   include '../functions/units/fetch_curriculum_syllabus.php'; 
});


// Syllabus fetch
$app->get('/fetch/syllabus_datas/{id}', function(Request $request, response $response) use($app){
   include '../functions/units/fetch.php'; 
});

// Syllabus start
$app->get('/fetch_api_data/syllabus/{id}', function(Request $request, response $response) use($app){
   include '../syllabus/syllabus_api_get.php'; 
});

/**************************Mobile app api*****************************/
/*1.upcoming exams api*/

//1.upcoming exams

$app->get('/fetch/mobile/get_upcoming_exams/{roll_number}', function(Request $request, response $response) use($app){
   include '../mobile/exams/upcoming_exams.php'; 
});


/*********************************************************************/
///getstudents array/////

$app->get('/fetch/get_students_array/{date}/{course_id}/{session_id}/{exams_id}', function(Request $request, response $response) use ($app) {
    include '../functions/exma_pre_ops/students_array.php';
});

 

///get rooms and seats/////

$app->get('/fetch/get_room', function(Request $request, response $response) use ($app) {
    include '../functions/exma_pre_ops/get_rooms.php';
});


///algorithm/////

$app->get('/fetch/assign_proctors/{course_id}/{season_id}/{exams_id}/{date}/{time}', function(Request $request, response $response) use ($app) {
    include '../functions/exma_pre_ops/seatingarrangments.php';
});


///PWI///


$app->get('/fetch/pwidashboard/{course_id}/{season_id}/{exams_id}', function(Request $request, response $response) use ($app) {
    include '../functions/pwi/dashboard.php';
});
$app->get('/fetch/pwidashboard/{course_id}/{season_id}', function(Request $request, response $response) use ($app) {
    include '../functions/pwi/dashboard.php';
});
$app->get('/fetch/pwidashboard/{course_id}', function(Request $request, response $response) use ($app) {
    include '../functions/pwi/dashboard.php';
});
$app->get('/fetch/pwidashboard', function(Request $request, response $response) use ($app) {
    include '../functions/pwi/dashboard.php';
});

$app->get('/fetch/pwi_submit/{id}', function(Request $request, response $response) use ($app) {
    include '../functions/pwi/pwi_submit.php';
});

$app->get('/fetch/punch_code/{id}', function(Request $request, response $response) use ($app) {
    include '../functions/pwi/punch_code.php';
});


//count
    $app->get('/fetch/pwi_count/{id}', function(Request $request, response $response) use ($app) {
    include '../functions/pwi/pwi_count.php';
});

$app->put('/update/pwi_submit_answer/{id}', function (Request $request, response $response) use ($app) {
include '../functions/pwi/pwi_submit_answer.php';
});

/***************************************************/



/*Exam Day ops*/

//get date
    $app->get('/fetch/day_ops/get_date/{course_id}/{season_id}/{exams_id}', function(Request $request, response $response) use ($app) {
    include '../functions/day_ops/get_date.php';
});
        $app->get('/fetch/day_ops/get_date/{course_id}/{season_id}', function(Request $request, response $response) use ($app) {
    include '../functions/day_ops/get_date.php';
});
    $app->get('/fetch/day_ops/get_date/{course_id}', function(Request $request, response $response) use ($app) {
    include '../functions/day_ops/get_date.php';
});

//get time
  $app->get('/fetch/day_ops/get_time/{date}', function(Request $request, response $response) use ($app) {
    include '../functions/day_ops/get_time.php';
});
     
//pwi submission
  $app->get('/fetch/day_ops/pwi_submission/{course_id}/{season_id}/{exams_id}/{date}/{time}', function(Request $request, response $response) use ($app) {
    include '../functions/day_ops/pwi_submission.php';
});
    $app->get('/fetch/day_ops/pwi_submission/{course_id}/{season_id}/{exams_id}/{date}', function(Request $request, response $response) use ($app) {
    include '../functions/day_ops/pwi_submission.php';
});
      $app->get('/fetch/day_ops/pwi_submission/{course_id}/{season_id}/{exams_id}', function(Request $request, response $response) use ($app) {
    include '../functions/day_ops/pwi_submission.php';
});
        $app->get('/fetch/day_ops/pwi_submission/{course_id}/{season_id}', function(Request $request, response $response) use ($app) {
    include '../functions/day_ops/pwi_submission.php';
});
          $app->get('/fetch/day_ops/pwi_submission/{course_id}', function(Request $request, response $response) use ($app) {
    include '../functions/day_ops/pwi_submission.php';
});




//pwi submission percentage

      $app->get('/fetch/day_ops/pwi_submission_percentage/{course_id}/{season_id}/{exams_id}/{date}/{time}', function(Request $request, response $response) use ($app) {
    include '../functions/day_ops/pwi_submission_percentage.php';
});
    $app->get('/fetch/day_ops/pwi_submission_percentage/{course_id}/{season_id}/{exams_id}/{date}', function(Request $request, response $response) use ($app) {
    include '../functions/day_ops/pwi_submission_percentage.php';
});
      $app->get('/fetch/day_ops/pwi_submission_percentage/{course_id}/{season_id}/{exams_id}', function(Request $request, response $response) use ($app) {
    include '../functions/day_ops/pwi_submission_percentage.php';
});
        $app->get('/fetch/day_ops/pwi_submission_percentage/{course_id}/{season_id}', function(Request $request, response $response) use ($app) {
    include '../functions/day_ops/pwi_submission_percentage.php';
});
          $app->get('/fetch/day_ops/pwi_submission_percentage/{course_id}', function(Request $request, response $response) use ($app) {
    include '../functions/day_ops/pwi_submission_percentage.php';
});     


//pwi_submission_list//
      $app->get('/fetch/day_ops/pwi_submission_list/{id}', function(Request $request, response $response) use ($app) {
    include '../functions/day_ops/pwi_submission_list.php';
});

//pwi deliverables
  $app->get('/fetch/day_ops/pwi_deliverables/{course_id}/{season_id}/{exams_id}/{date}/{time}', function(Request $request, response $response) use ($app) {
    include '../functions/day_ops/pwi_deliverables.php';
});
    $app->get('/fetch/day_ops/pwi_deliverables/{course_id}/{season_id}/{exams_id}/{date}', function(Request $request, response $response) use ($app) {
    include '../functions/day_ops/pwi_deliverables.php';
});
      $app->get('/fetch/day_ops/pwi_deliverables/{course_id}/{season_id}/{exams_id}', function(Request $request, response $response) use ($app) {
    include '../functions/day_ops/pwi_deliverables.php';
});
        $app->get('/fetch/day_ops/pwi_deliverables/{course_id}/{season_id}', function(Request $request, response $response) use ($app) {
    include '../functions/day_ops/pwi_deliverables.php';
});
          $app->get('/fetch/day_ops/pwi_deliverables/{course_id}', function(Request $request, response $response) use ($app) {
    include '../functions/day_ops/pwi_deliverables.php';
});
       
         
       //pwi deliverables percentage

      $app->get('/fetch/day_ops/pwi_deliverables_percentage/{course_id}/{season_id}/{exams_id}/{date}/{time}', function(Request $request, response $response) use ($app) {
    include '../functions/day_ops/pwi_deliverables_percentage.php';
});
    $app->get('/fetch/day_ops/pwi_deliverables_percentage/{course_id}/{season_id}/{exams_id}/{date}', function(Request $request, response $response) use ($app) {
    include '../functions/day_ops/pwi_deliverables_percentage.php';
});
      $app->get('/fetch/day_ops/pwi_deliverables_percentage/{course_id}/{season_id}/{exams_id}', function(Request $request, response $response) use ($app) {
    include '../functions/day_ops/pwi_deliverables_percentage.php';
});
        $app->get('/fetch/day_ops/pwi_deliverables_percentage/{course_id}/{season_id}', function(Request $request, response $response) use ($app) {
    include '../functions/day_ops/pwi_deliverables_percentage.php';
});
          $app->get('/fetch/day_ops/pwi_deliverables_percentage/{course_id}', function(Request $request, response $response) use ($app) {
    include '../functions/day_ops/pwi_deliverables_percentage.php';
});     


/**************************************/


/***********Exam pre ops***********************/

/*1.getpaper_drop_down in set student
  2.getslots_drop_down in set student
  3.getdate_drop_down in set student
  4.gettime_drop_down in set student
  5.getstudent_list
  6.post set_student list
  7.Get set_assign_proctors
  8.Update set_assign_proctors
  9.Get proctors sheet
  //vengat start//
 10.vassign_paper
 11.vset_syllabus_dropdown
 //vengat End//
  */
//set-syllabus_dd//


//getpaper_drop_down in set student//

$app->get('/fetch/get_paper_drop_down/{course_id}/{season_id}/{exams_id}', function(Request $request, response $response) use ($app) {
    include '../functions/exma_pre_ops/get_paper_drop_down.php';
});

$app->get('/fetch/get_paper_drop_down/{course_id}/{season_id}', function(Request $request, response $response) use ($app) {
    include '../functions/exma_pre_ops/get_paper_drop_down.php';
});
$app->get('/fetch/get_paper_drop_down/{course_id}', function(Request $request, response $response) use ($app) {
    include '../functions/exma_pre_ops/get_paper_drop_down.php';
});
 
//getslots_drop_down in set student//

$app->get('/fetch/get_slots_drop_down/{course_id}/{season_id}/{exams_id}/{paper}' ,function(Request $request, response $response) use ($app) {
	include '../functions/exma_pre_ops/get_slots_drop_down.php';
});

//set student slot drop down
$app->get('/fetch/get_slots_drop_down/set_students/{course_id}/{season_id}/{exams_id}/{paper}' ,function(Request $request, response $response) use ($app) {
	include '../functions/exma_pre_ops/get_students_slots_drop_down.php';
});

//getdate_drop_down in set student//

$app->get('/fetch/get_date_drop_down/{course_id}/{season_id}/{exams_id}/{paper}/{slots}' ,function(Request $request, response $response) use ($app) {
	include '../functions/exma_pre_ops/get_date_drop_down.php';
});

//gettime_drop_down in set student//

$app->get('/fetch/get_time_drop_down/{course_id}/{season_id}/{exams_id}/{paper}/{slots}/{date}' ,function(Request $request, response $response) use ($app) {
	include '../functions/exma_pre_ops/get_time_drop_down.php';
});

//getstudent_list//
$app->get('/fetch/get_set_students_list/{course_id}/{season_id}/{paper}' ,function(Request $request, response $response) use ($app) {
	include '../functions/exma_pre_ops/get_set_students_list.php';
});

//post set_student list
$app->post('/insert/set_student_insert', function (Request $request, Response $response) use ($app) {

   include '../functions/exma_pre_ops/set_student_insert.php';
});

//7.get set_assign_proctors
$app->get('/fetch/set_assign_proctors/{date}/{time}' ,function(Request $request, response $response) use ($app) {
	include '../functions/exma_pre_ops/set_assign_proctors.php';
});

//8.Update set_assign_proctors
$app->post('/insert_update/assign_proctors', function (Request $request, Response $response) use ($app) {

  include '../functions/exma_pre_ops/update_assign_proctors.php';
});

//9.Get proctors sheet
$app->get('/fetch/proctors_sheet/{date}/{time}' ,function(Request $request, response $response) use ($app) {
	include '../functions/exma_pre_ops/proctors_sheet.php';
});

//10.vassign
$app->get('/fetch/vassign_papers/{course_id}/{dept_id}/{level_id}/{year}/{term}/{type}', function(Request $request, response $response) use ($app) {
    include '../functions/exma_pre_ops/vassign_papers.php';
});
$app->get('/fetch/vassign_papers/{course_id}/{dept_id}/{level_id}/{year}/{term}', function(Request $request, response $response) use ($app) {
    include '../functions/exma_pre_ops/vassign_papers.php';
});
$app->get('/fetch/vassign_papers/{course_id}/{dept_id}/{level_id}/{year}', function(Request $request, response $response) use ($app) {
    include '../functions/exma_pre_ops/vassign_papers.php';
});
$app->get('/fetch/vassign_papers/{course_id}/{dept_id}/{level_id}', function(Request $request, response $response) use ($app) {
    include '../functions/exma_pre_ops/vassign_papers.php';
});
$app->get('/fetch/vassign_papers/{course_id}/{dept_id}', function(Request $request, response $response) use ($app) {
    include '../functions/exma_pre_ops/vassign_papers.php';
});
$app->get('/fetch/vassign_papers/{course_id}', function(Request $request, response $response) use ($app) {
    include '../functions/exma_pre_ops/vassign_papers.php';
});
 
//11.vset_syllabus_dropdown
$app->get('/fetch/set_syllabus_dd/{course_id}/{dept_id}/{level_id}/{year}/{term}/{type}', function(Request $request, response $response) use ($app) {
    include '../functions/curriculum/set_syllabus_dd.php';
});
$app->get('/fetch/set_syllabus_dd/{course_id}/{dept_id}/{level_id}/{year}/{term}', function(Request $request, response $response) use ($app) {
    include '../functions/curriculum/set_syllabus_dd.php';
});
$app->get('/fetch/set_syllabus_dd/{course_id}/{dept_id}/{level_id}/{year}', function(Request $request, response $response) use ($app) {
    include '../functions/curriculum/set_syllabus_dd.php';
});
$app->get('/fetch/set_syllabus_dd/{course_id}/{dept_id}/{level_id}', function(Request $request, response $response) use ($app) {
    include '../functions/curriculum/set_syllabus_dd.php';
});
$app->get('/fetch/set_syllabus_dd/{course_id}/{dept_id}', function(Request $request, response $response) use ($app) {
    include '../functions/curriculum/set_syllabus_dd.php';
});
$app->get('/fetch/set_syllabus_dd/{course_id}', function(Request $request, response $response) use ($app) {
    include '../functions/curriculum/set_syllabus_dd.php';
});

//create slots
$app->get('/fetch/exma_pre_ops/create_slots/{course_id}/{dept_id}/{level_id}', function(Request $request) use ($app) {
    include '../functions/exma_pre_ops/fetch_slots_paper.php';
});
$app->get('/fetch/exma_pre_ops/create_slots/{course_id}/{dept_id}', function(Request $request) use ($app) {
    include '../functions/exma_pre_ops/fetch_slots_paper.php';
});
$app->get('/fetch/exma_pre_ops/create_slots/{course_id}', function(Request $request) use ($app) {
    include '../functions/exma_pre_ops/fetch_slots_paper.php';
});
/****************************************/

/********************Seating Arrangment*****************/
/*1.Get block name
  2.Get floor name
  3.get seating_fetch drop_down
  4.Get seating arangment date drop down
  5.Get seating arangment time drop down
  6.Get seating arrangment room list
  7.Set insert Room*/
  
  //1.get block name drop_down
$app->get('/fetch/get_blockname' ,function(Request $request, response $response) use ($app) {
	include '../functions/seating_arrangment/get_blockname.php';
});

  //2.get floor name drop_down
$app->get('/fetch/get_floorname/{blockid}' ,function(Request $request, response $response) use ($app) {
	include '../functions/seating_arrangment/get_floorname.php';
});

 //3.get seating_fetch drop_down
$app->get('/fetch/seating_arrangment/{blockid}/{floorid}' ,function(Request $request, response $response) use ($app) {
	include '../functions/seating_arrangment/fetch_seating_arrangment.php';
});

//4.get_seating_arrangment_date.php

$app->get('/fetch/get_seating_arrangment_date/{course_id}/{season_id}/{exams_id}' ,function(Request $request, response $response) use ($app) {
	include '../functions/seating_arrangment/get_seating_arrangment_date.php';
});

//5.get_seating_arrangment_time.php

$app->get('/fetch/get_seating_arrangment_time/{course_id}/{season_id}/{exams_id}/{date}' ,function(Request $request, response $response) use ($app) {
	include '../functions/seating_arrangment/get_seating_arrangment_time.php';
});

//6.get_seating_arrangment_room_list.php

$app->get('/fetch/get_seating_arrangment_room_list/{block_id}/{floors}' ,function(Request $request, response $response) use ($app) {
	include '../functions/seating_arrangment/get_seating_arrangment_room_list.php';
});


//7.post set_student list
$app->post('/insert/set_room_insert', function (Request $request, Response $response) use ($app) {

   include '../functions/seating_arrangment/set_room_insert.php';
});
/*******************************************************/
/*Student API*/

$app->get('/fetch/student', function(Request $request, response $response) use ($app) {
    include '../functions/student/student_fetch.php';
});

$app->post('/fetch/archive_student', function(Request $request, response $response) use ($app) {
    include '../functions/student/archive_student.php';
});


$app->post('/insert/student', function (Request $request, response $response) use ($app) {
 include '../functions/student/student_insert.php';
});

$app->put('/update/student/{student_id}', function (Request $request, response $response) use ($app) {
include '../functions/student/student_edit.php';
});

$app->delete('/delete/student/{student_id}', function (Request $request, response $response) use ($app) {
include '../functions/student/student_delete.php';
});

$app->get('/fetch/active_student', function(Request $request, response $response) use ($app) {
    include '../functions/student/student_active.php';
});

$app->get('/fetch/non_active_student', function (Request $request, Response $response) use ($app) {
include '../functions/student/student_nonactive.php';
});

$app->get('/fetch/student_list', function(Request $request) use ($app) {
    include '../functions/student/student_list.php';
});
$app->get('/fetch/student_list/{course}', function(Request $request) use ($app) {
    include '../functions/student/student_list.php';
});
$app->get('/fetch/student_list/{course}/{department}', function(Request $request) use ($app) {
    include '../functions/student/student_list.php';
});
$app->get('/fetch/student_list/{course}/{department}/{level_id}', function(Request $request) use ($app) {
    include '../functions/student/student_list.php';
});
$app->get('/fetch/student_list/{course}/{department}/{level_id}/{batch}', function(Request $request) use ($app) {
    include '../functions/student/student_list.php';
});

//Archive Student
$app->get('/fetch/archive_student_list/{course}/{department}/{level_id}', function(Request $request) use ($app) {
    include '../functions/student/archive_student_list.php';
});
$app->get('/fetch/archive_student_list/{course}/{department}', function(Request $request) use ($app) {
    include '../functions/student/archive_student_list.php';
});
$app->get('/fetch/archive_student_list/{course}/{department}/{level_id}/{batch}', function(Request $request) use ($app) {
    include '../functions/student/archive_student_list.php';
});
$app->get('/fetch/archive_student_list/{course}', function(Request $request) use ($app) {
    include '../functions/student/archive_student_list.php';
});

$app->get('/fetch/archive_student_list', function(Request $request) use ($app) {
    include '../functions/student/archive_student_list.php';
});


$app->get('/fetch/student_batch', function(Request $request) use ($app) {
    include '../functions/student/studentbatch.php';
});
$app->get('/fetch/student_batch/{course}', function(Request $request) use ($app) {
    include '../functions/student/studentbatch.php';
});
$app->get('/fetch/student_batch/{course}/{department}', function(Request $request) use ($app) {
    include '../functions/student/studentbatch.php';
});
$app->get('/fetch/student_batch/{course}/{department}/{level_id}', function(Request $request) use ($app) {
    include '../functions/student/studentbatch.php';
});
$app->get('/fetch/student_batch/{course}/{department}/{level_id}/{batch}', function(Request $request) use ($app) {
    include '../functions/student/studentbatch.php';
});

$app->get('/fetch/students_pool', function(Request $request, response $response) use ($app) {
    include '../functions/student/students_pool.php';
});
$app->get('/fetch/students_pool/{course}', function(Request $request, response $response) use ($app) {
    include '../functions/student/students_pool.php';
});
$app->get('/fetch/students_pool/{course}/{department}', function(Request $request, response $response) use ($app) {
    include '../functions/student/students_pool.php';
});
$app->get('/fetch/students_pool/{course}/{department}/{level_id}', function(Request $request, response $response) use ($app) {
    include '../functions/student/students_pool.php';
});
$app->get('/fetch/students_pool/{course}/{department}/{level_id}/{batch}', function(Request $request, response $response) use ($app) {
    include '../functions/student/students_pool.php';
});


$app->get('/fetch/student_profile/{roll_number}', function(Request $request) use ($app) {
    include '../functions/student/student_profile.php';
});


/*Grade*/

// Grade course

$app->get('/fetch/grade_course', function(Request $request) use ($app) {
    include '../functions/grade/grade_course/course_fetch.php';
});
$app->get('/fetch/grade_course/{course_id}', function(Request $request) use ($app) {
    include '../functions/grade/grade_course/course_fetch.php';
});
$app->get('/fetch/grade_course/{course_id}/{dept_id}', function(Request $request) use ($app) {
    include '../functions/grade/grade_course/course_fetch.php';
});
$app->get('/fetch/grade_course/{course_id}/{dept_id}/{level_id}', function(Request $request) use ($app) {
    include '../functions/grade/grade_course/course_fetch.php';
});
$app->post('/insert/grade_course', function (Request $request, response $response) use ($app) {
 include '../functions/grade/grade_course/course_insert.php';	
});

$app->put('/update/grade/{grade_course_id}', function (Request $request, response $response) use ($app) {
include '../functions/grade/grade_course/course_edit.php';
});

$app->delete('/delete/grade/{grade_course_id}', function (Request $request, response $response) use ($app) {
include '../functions/grade/grade_course/course_delete.php';
});


// Set Grade

$app->get('/fetch/set_grade', function(Request $request, response $response) use ($app) {
    include '../functions/grade/set_grade/set_grade_fetch.php';
});
$app->get('/fetch/set_grade/{course_id}', function(Request $request, response $response) use ($app) {
    include '../functions/grade/set_grade/set_grade_fetch.php';
});
$app->get('/fetch/set_grade/{course_id}/{dept_id}', function(Request $request, response $response) use ($app) {
    include '../functions/grade/set_grade/set_grade_fetch.php';
});
$app->get('/fetch/set_grade/{course_id}/{dept_id}/{level_id}', function(Request $request, response $response) use ($app) {
    include '../functions/grade/set_grade/set_grade_fetch.php';
});
$app->get('/fetch/set_grade/{course_id}/{dept_id}/{level_id}/{type}', function(Request $request, response $response) use ($app) {
    include '../functions/grade/set_grade/set_grade_fetch.php';
});


$app->post('/insert/set_grade', function (Request $request, response $response) use ($app) {
 include '../functions/grade/set_grade/set_grade_insert.php';
});

$app->put('/update/set_grade/{set_grade_id}', function (Request $request, response $response) use ($app) {
include '../functions/grade/set_grade/set_grade_edit.php';
});

$app->delete('/delete/set_grade/{set_grade_id}', function (Request $request, response $response) use ($app) {
include '../functions/grade/set_grade/set_grade_delete.php';
});

//Export Grade
$app->get('/fetch/set_export_grade_get/{course_id}/{dept_id}/{level_id}/{type_name}',function (Request $request) use ($app) {
include '../functions/grade/export_grade/grade_export_get.php';
});
$app->get('/fetch/set_export_grade_get/{course_id}/{dept_id}/{level_id}',function (Request $request) use ($app) {
include '../functions/grade/export_grade/grade_export_get.php';
});
$app->get('/fetch/set_export_grade_get/{course_id}/{dept_id}',function (Request $request) use ($app) {
include '../functions/grade/export_grade/grade_export_get.php';
});
$app->get('/fetch/set_export_grade_get/{course_id}',function (Request $request) use ($app) {
include '../functions/grade/export_grade/grade_export_get.php';
});
$app->get('/fetch/set_export_grade_get',function (Request $request) use ($app) {
include '../functions/grade/export_grade/grade_export_get.php';
});




 // Assign Papers 

$app->post('/fetch/assign_papers', function (Request $request, response $response) use ($app) {
include '../functions/exma_pre_ops/assign_papers.php';
});








//Curriculum setup
$app->get('/fetch/curriculum/set_papers/{course_id}/{dept_id}/{level_id}/{year}/{term}/{type}/{papers_shortcode}', function(Request $request) use ($app) {
    include '../functions/curriculum/set_papers.php';
});
$app->get('/fetch/curriculum/set_papers/{course_id}/{dept_id}/{level_id}/{year}/{term}/{type}', function(Request $request) use ($app) {
    include '../functions/curriculum/set_papers.php';
});
$app->get('/fetch/curriculum/set_papers/{course_id}/{dept_id}/{level_id}/{year}/{term}', function(Request $request) use ($app) {
    include '../functions/curriculum/set_papers.php';
});
$app->get('/fetch/curriculum/set_papers/{course_id}/{dept_id}/{level_id}/{year}', function(Request $request) use ($app) {
    include '../functions/curriculum/set_papers.php';
});
$app->get('/fetch/curriculum/set_papers/{course_id}/{dept_id}/{level_id}', function(Request $request) use ($app) {
    include '../functions/curriculum/set_papers.php';
});
$app->get('/fetch/curriculum/set_papers/{course_id}/{dept_id}', function(Request $request) use ($app) {
    include '../functions/curriculum/set_papers.php';
});
$app->get('/fetch/curriculum/set_papers/{course_id}', function(Request $request) use ($app) {
    include '../functions/curriculum/set_papers.php';
});
$app->get('/fetch/curriculum/set_papers', function(Request $request) use ($app) {
    include '../functions/curriculum/set_papers.php';
});

	

//Set_units
$app->get('/fetch/curriculum/units/{set_papers_id}', function(Request $request) use ($app) {
    include '../functions/curriculum/units.php';
});
$app->get('/fetch/curriculum/units', function(Request $request) use ($app) {
    include '../functions/curriculum/units.php';
});
$app->post('/insert/units', function (Request $request, response $response) use ($app) {
   include '../functions/curriculum/insert_units.php';	
});
$app->put('/update/units/{unit_id}', function (Request $request, response $response) use ($app) {
include '../functions/curriculum/edit_units.php';
});
$app->delete('/delete/units/{unit_id}', function (Request $request, response $response) use ($app) {
include '../functions/curriculum/delete_units.php';
});


//Set_chapter
$app->get('/fetch/curriculum/chapter/{unit_id}', function(Request $request) use ($app) {
    include '../functions/curriculum/chapter.php';
});
$app->get('/fetch/curriculum/chapter', function(Request $request) use ($app) {
    include '../functions/curriculum/chapter.php';
});
$app->post('/insert/chapter', function (Request $request, response $response) use ($app) {
   include '../functions/curriculum/insert_chapter.php';	
});
$app->put('/update/chapter/{chapter_id}', function (Request $request, response $response) use ($app) {
include '../functions/curriculum/edit_chapter.php';
});
$app->delete('/delete/chapter/{chapter_id}', function (Request $request, response $response) use ($app) {
include '../functions/curriculum/delete_chapter.php';
});

	//Set_Main_topics
$app->get('/fetch/curriculum/main_topics/{chapter_id}', function(Request $request) use ($app) {
    include '../functions/curriculum/main_topics.php';
});
$app->get('/fetch/curriculum/main_topics', function(Request $request) use ($app) {
    include '../functions/curriculum/main_topics.php';
});
$app->post('/insert/main_topics', function (Request $request, response $response) use ($app) {
   include '../functions/curriculum/insert_main_topics.php';	
});
$app->put('/update/main_topics/{main_topics_id}', function (Request $request, response $response) use ($app) {
include '../functions/curriculum/edit_main_topics.php';
});
$app->delete('/delete/main_topics/{main_topics_id}', function (Request $request, response $response) use ($app) {
include '../functions/curriculum/delete_main_topics.php';
});
 
//Set_Sub_topics
$app->get('/fetch/curriculum/sub_topics/{main_topics_id}', function(Request $request) use ($app) {
    include '../functions/curriculum/sub_topics.php';
});
$app->get('/fetch/curriculum/sub_topics', function(Request $request) use ($app) {
    include '../functions/curriculum/sub_topics.php';
});
$app->post('/insert/sub_topics', function (Request $request, response $response) use ($app) {
   include '../functions/curriculum/insert_sub_topics.php';	
});
$app->put('/update/sub_topics/{sub_topics_id}', function (Request $request, response $response) use ($app) {
include '../functions/curriculum/edit_sub_topics.php';
});
$app->delete('/delete/sub_topics/{sub_topics_id}', function (Request $request, response $response) use ($app) {
include '../functions/curriculum/delete_sub_topics.php';
});


//Exam Base

$app->post('/insert/exam_base/new_exam', function(Request $request, response $response) use ($app) {
    include '../functions/exam_base/new_exam.php';
});


$app->put('/insert/exam_base/start_exam', function(Request $request, response $response) use ($app) {
    include '../functions/exam_base/start_exam.php';
});

$app->get('/fetch/exam_base/exam_list', function(Request $request) use ($app) {
    include '../functions/exam_base/exam_list.php';
});
$app->get('/fetch/exam_base/exam_list/{course_id}', function(Request $request) use ($app) {
    include '../functions/exam_base/exam_list.php';
});
$app->get('/fetch/exam_base/exam_list/{course_id}/{season_id}', function(Request $request) use ($app) {
    include '../functions/exam_base/exam_list.php';
});

                                                       ////fetch_set_papers

																																	   

$app->get('/fetch/setpapers', function (Request $request) use ($app) {

define('DB_SERVER', 'localhost');

define('DB_USERNAME', 'Restax_final');

define('DB_PASSWORD', 'Restax_final123');

define('DB_NAME', 'Restax_api_data');

 

/* Attempt to connect to MySQL database */

$con = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

$response=array();

$sql="SELECT * FROM set_papers";

$res= $con->query($sql);

	

if($res->num_rows>0)

{



	$i=0;

	while($row=$res->fetch_assoc())

		

	{	

$i++;

		$id=$row['id'];		

		$shortcode=$row['shortcode'];

		$paper_name=$row['paper_name'];

		$credits=$row['credits'];

				

	

		$data=array(

	"id" => $id,

	"shortcode"=>$shortcode,

	"paper_name"=>$paper_name,

	"credits"=>$credits,

	

	

	);

	    $message=$data;

	



	

	$response=array('status' => "true",'Message' => "feched data successfully",'set_papers' => $message);

echo json_encode($response);

        }

}

        else{

          $response=array('status' => "false",'Message' => " Failed to fetch");

         echo json_encode($response);

        }   

		

	



});


///sinnamuthu///



//pugazh//


//ExamBase APi //

$app->post('/insert/exam', function (Request $request, Response $response) use ($app) {

/* Attempt to connect to MySQL database */

$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

  $course = $request->getParsedBody()['course_id'];
  $season = $request->getParsedBody()['season_id'];
  $examname=$request->getParsedBody()['examname'];
 $examtype = $request->getParsedBody()['examtype'];
 $exam_start= $request->getParsedBody()['exam_start'];
 $exam_end= $request->getParsedBody()['exam_end'];
 $start_exam="0";
 $end_exam="0";
 $response=array();
 $data=array();

 $sql2="SELECT * FROM Exams WHERE examname = '$examname'";
$result2=mysqli_query($con,$sql2);

 if(mysqli_num_rows($result2) > 0){
	 $response=array('status' => "false",'Message' => "Examname Already Exist");
         echo json_encode($response);
}

else{

  $query = "INSERT INTO Exams (course_id,season_id,examname,examtype,exam_start,exam_end,exam_start_date_time,exam_end_date_time) VALUES (?,?,?,?,?,?,?,?)";
 $stmt = $con->prepare($query);
 $stmt->bind_param("ssssssss",$course,$season,$examname,$examtype,$start_exam,$end_exam,$exam_start,$exam_end);
  //$stmt->execute();
 $result = $stmt->execute();
        $stmt->close();
        if($result==true){
            $data=
        array(
            'course' => $course,
            'season' =>$season,
            'examname' => $examname,
            'examtype' => $examtype,
			'exam_start' => $exam_start,
            'exam_end' => $exam_end,
            'exam_start_status'=>$start_exam,
            'exam_end_status'=>$end_exam,
			
         );
    
    $message=$data;

$response=array('status' => "true",'Message' => "Exam Created Succesfully",'Exam' => $message);
echo json_encode($response);
        }
        else{
          $response=array('status' => "false",'Message' => "Failed Exam Creation");
         echo json_encode($response);
        }
    }
});
/////




$app->get('/fetch/exam/{season_id}', function (Request $request, Response $response) use ($app) {
// Attempt to connect to MySQL database //
$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
$response=array();
$season_id=$request->getAttribute('season_id');

$sql1="SELECT * FROM season WHERE id=$season_id";
$result1=mysqli_query($con,$sql1);

 if(mysqli_num_rows($result1) > 0){
	while ($row=mysqli_fetch_assoc($result1)) {

		$course_id=$row['course_id'];
		$course_id;
}
$sql2="SELECT * FROM Exams WHERE course_id=$course_id AND season_id=$season_id";
$result2=mysqli_query($con,$sql2);

 if(mysqli_num_rows($result2) > 0){
	while ($row[]=mysqli_fetch_assoc($result2)) {

		$exam=$row;
   
}
 echo json_encode($exam) ;
	}
	else{
	  $response=array('status' => "false",'Message' => "Exam Not Found");
         echo json_encode($response);
}

		

}
else{
	  $response=array('status' => "false",'Message' => "Exam Not Found");
         echo json_encode($response);
}
    

   exit();

});

$app->get('/fetch/allexam', function (Request $request, Response $response) use ($app) {


// Attempt to connect to MySQL database //
$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
$response=array();
$sql="SELECT * FROM Exams";
$result=mysqli_query($con,$sql);
    while ($row[]=mysqli_fetch_assoc($result)) {
     // $name=$row['Firstname'];
     // $lname=$row['Lastname'];
     // $email=$row['Email'];
     // $response=array('firstname' => $name,'lastname' => $lname,'email' =>$email );
      $user=$row;
    }
    echo json_encode($user);
   exit();
});


//Season APi //


$app->post('/insert/season', function (Request $request, Response $response) use ($app) {

/* Attempt to connect to MySQL database */

$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

  $course = $request->getParsedBody()['course_id'];
  $acyear = $request->getParsedBody()['acadamicyear'];
  $seasonname=$request->getParsedBody()['seasonname'];
  $status="0";
 $response=array();
 $data=array();

$sql2="SELECT * FROM season WHERE seasonname = '$seasonname'";
$result2=mysqli_query($con,$sql2);

 if(mysqli_num_rows($result2) > 0){
	 $response=array('status' => "false",'Message' => "Season Already Exist");
         echo json_encode($response);
}
	
	
 else{


  $query = "INSERT INTO  season (seasonname,course_id,academicyear,status) VALUES (?,?,?,?)";
 $stmt = $con->prepare($query);
 $stmt->bind_param("ssss",$seasonname,$course,$acyear,$status);
  //$stmt->execute();
 $result = $stmt->execute();
        $stmt->close();
        if($result==true){
            $data=
        array(
            'course_id' =>$course,
            'acadamicyear' => $acyear,
            'seasonname' => $seasonname,
            'status' =>$status,
         );
    
    $message=$data;

$response=array('status' => "true",'Message' => "Season Created Succesfully",'Exam' => $message);
echo json_encode($response);
        }
        else{
          $response=array('status' => "false",'Message' => "Failed Season Creation");
         echo json_encode($response);
        }

    }
        
});

$app->get('/fetch/allseason', function (Request $request, Response $response) use ($app) {


// Attempt to connect to MySQL database //
$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
$response=array();
$sql="SELECT * FROM season";
$result=mysqli_query($con,$sql);
    while ($row[]=mysqli_fetch_assoc($result)) {

      $user=$row;
    }
    echo json_encode($user);
   exit();

});

$app->get('/fetch/allseason/{course_id}', function (Request $request, Response $response) use ($app) {


// Attempt to connect to MySQL database //
$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
$response=array();
$sql="SELECT * FROM season";
$result=mysqli_query($con,$sql);
    while ($row[]=mysqli_fetch_assoc($result)) {

      $user=$row;
    }
    echo json_encode($user);
   exit();

});


$app->get('/fetch/examseason/{course_id}', function (Request $request, Response $response) use ($app) {


// Attempt to connect to MySQL database //
$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
$response=array();
$course_id=$request->getAttribute('course_id');

$sql1="SELECT * FROM season WHERE course_id=$course_id AND status='0'";
$result1=mysqli_query($con,$sql1);

 if(mysqli_num_rows($result1) > 0){
	while ($row[]=mysqli_fetch_assoc($result1)) {

		$Season=$row;
}
echo json_encode($Season);
}

});

$app->get('/fetch/examseason/{course_id}/{academic_year}', function (Request $request, Response $response) use ($app) {


// Attempt to connect to MySQL database //
$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
$response=array();
$course_id = $request->getAttribute('course_id');
$academic_year = $request->getAttribute('academic_year');

$sql1="SELECT * FROM season WHERE course_id='$course_id' AND academicyear='$academic_year' AND status='0'";
$result1=mysqli_query($con,$sql1);

 if(mysqli_num_rows($result1) > 0){
	while ($row[]=mysqli_fetch_assoc($result1)) {

		$Season=$row;
}
echo json_encode($Season);
}

});

$app->get('/fetch/startexamseason/{course_id}', function (Request $request, Response $response) use ($app) {


// Attempt to connect to MySQL database //
$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
$response=array();
$course_id=$request->getAttribute('course_id');

$sql1="SELECT * FROM season WHERE course_id=$course_id AND status='1'";
$result1=mysqli_query($con,$sql1);

 if(mysqli_num_rows($result1) > 0){
  while ($row[]=mysqli_fetch_assoc($result1)) {

    $Season=$row;
}
echo json_encode($Season);
}
 else{
          $response=array('status' => "false",'Message' => "Season not Found");
         echo json_encode($response);
        }
});


$app->post('/set_classes/season', function (Request $request, Response $response) use ($app) {

/* Attempt to connect to MySQL database */

$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

  $course = $request->getParsedBody()['course_id'];
  $season_id = $request->getParsedBody()['season_id'];
  $deptid=$request->getParsedBody()['department'];
  $level=$request->getParsedBody()['level'];
  $year=$request->getParsedBody()['year'];
  $term=$request->getParsedBody()['term'];
  $sections=$request->getParsedBody()['sections'];
 $response=array();
 $data=array();
 
 

$sql="select * from set_classes where course_id = '$course' AND season_id='$season_id' AND department='$deptid' AND level= '$level' AND year='$year' 
AND term='$term' AND  sections='$sections'";
$result = $con->query($sql);
if ($result->num_rows > 0) {
    
    echo "Data alredy exist";
}
else
{
  $query = "INSERT INTO  set_classes (course_id,season_id,department,level,year,term,sections) VALUES (?,?,?,?,?,?,?)";
 $stmt = $con->prepare($query);
 $stmt->bind_param("sssssss",$course,$season_id,$deptid,$level,$year,$term,$sections);
  //$stmt->execute();
 $result = $stmt->execute();
        $stmt->close();
        if($result==true){
            $data=
        array(
            'course_id' =>$course,
            'season_id' => $season_id,
            'dept_id' => $deptid,
            'level_id' =>$level,
            'year' =>$year,
            'term' =>$term,
            'sections' =>$sections,

         );
    
    $message=$data;

$response=array('status' => "true",'Message' => "Set Class Succesfully",'Exam' => $message);
echo json_encode($response);
        }
        else{
          $response=array('status' => "false",'Message' => "Failed to set class");
         echo json_encode($response);
        }
}       
});

$app->put('/update/season_class/{class_id}', function (Request $request) use ($app) {

 
/* Attempt to connect to MySQL database */
$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

 
    //Verifying the required parameters

$id=$request->getAttribute('class_id');
  $dept_id = $request->getParsedBody()['department'];
  $level=$request->getParsedBody()['level'];
  $year = $request->getParsedBody()['year'];
 $term = $request->getParsedBody()['term'];
 $sections=$request->getParsedBody()['sections'];

 $data=array();

  $query = "UPDATE set_classes SET sections=? WHERE id=$id";
 $stmt = $con->prepare($query);
 $stmt->bind_param("s",$sections);
  //$stmt->execute();
 $result = $stmt->execute();
        $stmt->close();
        if($result==true){
            $data=
        array(
            'sections'=>$sections,
         );
    
    $message=$data;

$response=array('status' => "true",'Message' => "Season Class Updated Succesfully",'class' => $message);
echo json_encode($response);
        }
        else{
          $response=array('status' => "false",'Message' => "Class Details Update Failed");
         echo json_encode($response);
        }   
});


$app->delete('/delete/season_class/{class_id}', function (Request $request) use ($app) {

 
/* Attempt to connect to MySQL database */
$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

 
    //Verifying the required parameters

$id=$request->getAttribute('class_id');
 
 $response=array();
 $data=array();

  $query = "DELETE FROM  set_classes WHERE id=?";
 $stmt = $con->prepare($query);
 $stmt->bind_param("s",$id);
  //$stmt->execute();
 $result = $stmt->execute();
        $stmt->close();
        if($result==true){

$response=array('status' => "false",'Message' => "Class Removed Succesfully");
echo json_encode($response);
        }
        else{
          $response=array('status' => "true",'Message' => "Class Removed Failed");
         echo json_encode($response);
        }   
});



$app->post('/set/sesion_student', function (Request $request, Response $response) use ($app) {

/* Attempt to connect to MySQL database */

$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);


$course_id=$request->getParsedBody()['course_id'];
 $season_id = $request->getParsedBody()['session_id'];
  $deptid = $request->getParsedBody()['dept_id'];
  $level_id = $request->getParsedBody()['level_id'];
  $year=$request->getParsedBody()['year'];
  $term = $request->getParsedBody()['term'];
  $section = $request->getParsedBody()['section'];
  $rollnumber=$request->getParsedBody()['rollnumber'];
  $student_name = $request->getParsedBody()['student_name'];
  $detained = $request->getParsedBody()['detained'];
  $buffered=$request->getParsedBody()['buffered'];
  $papers_undertaking=$request->getParsedBody()['papers_undertaking'];
  $suply_papers=$request->getParsedBody()['suply_papers'];
  $institutename=$request->getParsedBody()['Institute_name'];
  $institute_code=$request->getParsedBody()['institute_code'];
  $password=$request->getParsedBody()['password'];


  json_decode($papers_undertaking,true);
  json_decode($suply_papers,true);
$resultpaperundertaking = json_encode($papers_undertaking);
$resultsupllypapers = json_encode($suply_papers);
 $response=array();
 $data=array();


$query2="SELECT * FROM  student WHERE insitute_name='$institutename' AND institute_no='$institute_code' AND student_name='$student_name' AND roll_number='$rollnumber' AND password='$password' AND status='1'";
 $result2=mysqli_query($con,$query2);
  while($row = mysqli_fetch_assoc($result2)){

     $checkinstituename=$row['insitute_name'];
   $checkinstituteno=$row['institute_no'];
   $checkstudentname=$row['student_name'];
   $checkrollnumber=$row['roll_number'];
   $checkpassword=$row['password'];
 
 }




  if ($checkinstituteno!=$institute_code AND $checkpassword!=$password AND $checkrollnumber!=$rollnumber AND $checkinstituename!=$institutename AND $checkstudentname!=$student_name) {
   $response=array('status' => "false",'Message' => "Student Name/rollnumber/institutecode/institutename/password Not Matching");
     echo json_encode($response); 
 }

elseif($checkstudentname!=$student_name) {
   $response=array('status' => "false",'Message' => "StudentName Not Matching");

     echo json_encode($response); 
 }
 elseif ($checkrollnumber!=$rollnumber) {
   $response=array('status' => "false",'Message' => "StudentRollnumber Not Matching");
     echo json_encode($response); 
 }
  elseif ($checkinstituename!=$institutename) {
   $response=array('status' => "false",'Message' => "Institutename Not Matching");
     echo json_encode($response); 
 }
  elseif ($checkinstituteno!=$institute_code AND $checkpassword!=$password) {
   $response=array('status' => "false",'Message' => "Institutecode Not Matching");
     echo json_encode($response); 
 }
   elseif ($checkpassword!=$password) {
   $response=array('status' => "false",'Message' => "Password Not Matching");
     echo json_encode($response); 
 }
  
 else{
     
      $sql32="SELECT * FROM set_student_season WHERE Institute_name='$institutename' AND institute_code='$institute_code' AND student_name='$student_name' AND rollnumber='$rollnumber' AND password='$password'";
$result32=mysqli_query($con,$sql32);

 if(mysqli_num_rows($result32) > 0){
   $response=array('status' => "false",'Message' => "Faculty Number or Email or Phone Already Exist");

}
else{
  $query = "INSERT INTO  set_student_season (course_id,session_id,dept_id,level_id,year,term,section,rollnumber,student_name,detained,buffered,papers_undertaking,suply_papers,Institute_name,institute_code,password)
   VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
 
 $stmt = $con->prepare($query);
 $stmt->bind_param("ssssssssssssssss",$course_id,$season_id, $deptid,$level_id,$year,$term,$section,$rollnumber,$student_name,$detained,$buffered,$resultpaperundertaking,$resultsupllypapers,$institutename,$institute_code,$password);
  //$stmt->execute();
 $result = $stmt->execute();
        $stmt->close();
        if($result==true){
            $data=
        array(
           'institute_name'=>$institutename,
           'institutecode'=>$institute_code,
          'student_name'=>$student_name,
            'rollnumber' =>$rollnumber,
            'dept_id' => $deptid,
            'level_id' => $level_id,
            'year' =>$year,
            'term'=>$term,
            'section'=>$section,
            'papers_undertaking'=>$papers_undertaking,
            'suply_papers'=>$suply_papers,
            'detained'=>$detained,
            'buffered'=>$buffered,
            'password'=>$password,
         );
    
    $message=$data;

$response=array('status' => "true",'Message' => "Student Registered Succesfully",'Season' => $message);
echo json_encode($response);
        }
        else{
          $response=array('status' => "false",'Message' => "Registration Failed");
         echo json_encode($response);
        }
}
    
  } 
 
});

$app->put('/update/session_student/{id}', function (Request $request, Response $response) use ($app) {

/* Attempt to connect to MySQL database */

$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

$id=$request->getAttribute('id');
$course_id=$request->getParsedBody()['course_id'];
 $session_id = $request->getParsedBody()['session_id'];
  $dept_id = $request->getParsedBody()['dept_id'];
  $level_id = $request->getParsedBody()['level_id'];
  $year=$request->getParsedBody()['year'];
  $term = $request->getParsedBody()['term'];
  $section = $request->getParsedBody()['section'];
  $rollnumber=$request->getParsedBody()['rollnumber'];
  $student_name = $request->getParsedBody()['student_name'];
  $detained = $request->getParsedBody()['detained'];
  $buffered=$request->getParsedBody()['buffered'];
  $papers_undertaking=$request->getParsedBody()['papers_undertaking'];
  $suply_papers=$request->getParsedBody()['suply_papers'];
  $Institute_name=$request->getParsedBody()['Institute_name'];
  $institute_code=$request->getParsedBody()['institute_code'];
  $password=$request->getParsedBody()['password'];
 $response=array();
 $data=array();


  $query = "UPDATE set_student_season SET  course_id=?,session_id=?,dept_id=?,level_id=?,year=?,term=?,section=?,rollnumber=?,student_name=?,detained=?,buffered=?,papers_undertaking=?,suply_papers=?,Institute_name=?,institute_code=?,password=? WHERE id=$id";
 $stmt = $con->prepare($query);
 $stmt->bind_param("ssssssssssssssss",$course_id,$session_id, $dept_id,$level_id,$year,$term,$section,$rollnumber,$student_name,$detained,$buffered,$papers_undertaking,$suply_papers,$Institute_name,$institute_code,$password);
  //$stmt->execute();
 $result = $stmt->execute();
        $stmt->close();
        if($result==true){
            $data=
        array(
           'Institute_name'=>$Institute_name,
           'institute_code'=>$institute_code,
          'student_name'=>$student_name,
            'rollnumber' =>$rollnumber,
            'dept_id' => $dept_id,
            'level_id' => $level_id,
            'year' =>$year,
            'term'=>$term,
            'section'=>$section,
            'papers_undertaking'=>$papers_undertaking,
            'suply_papers'=>$suply_papers,
            'detained'=>$detained,
            'buffered'=>$buffered,
            'password'=>$password,
         );
    
    $message=$data;

$response=array('status' => "true",'Message' => "Student Data Updated Succesfully",'Season' => $message);
echo json_encode($response);
        }
        else{
          $response=array('status' => "false",'Message' => "Updation Failed");
         echo json_encode($response);
        }
        
});

$app->delete('/delete/season_student/{student_id}', function (Request $request) use ($app) {

 
/* Attempt to connect to MySQL database */
$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

 
    //Verifying the required parameters

$id=$request->getAttribute('student_id');
 
 $response=array();
 $data=array();

  $query = "DELETE FROM  set_student_season WHERE id=?";
 $stmt = $con->prepare($query);
 $stmt->bind_param("s",$id);
  //$stmt->execute();
 $result = $stmt->execute();
        $stmt->close();
        if($result==true){

$response=array('status' => "false",'Message' => "Student Removed Succesfully");
echo json_encode($response);
        }
        else{
          $response=array('status' => "true",'Message' => "Student Removed Failed");
         echo json_encode($response);
        }   
});

$app->get('/fetch/season/papers_undertaking/{course_id}/{dept_id}/{level_id}/{year}/{term}', function(Request $request) use ($app) {
    include '../functions/season/papersundertaking.php';
});
$app->get('/fetch/season/papers_undertaking/{course_id}', function(Request $request) use ($app) {
    include '../functions/season/papersundertaking.php';
});
$app->get('/fetch/season/papers_undertaking/{course_id}/{dept_id}', function(Request $request) use ($app) {
    include '../functions/season/papersundertaking.php';
});
$app->get('/fetch/season/papers_undertaking/{course_id}/{dept_id}/{level_id}', function(Request $request) use ($app) {
    include '../functions/season/papersundertaking.php';
});
$app->get('/fetch/season/papers_undertaking/{course_id}/{dept_id}/{level_id}/{year}', function(Request $request) use ($app) {
    include '../functions/season/papersundertaking.php';
});
$app->get('/fetch/season/papers_undertaking', function(Request $request) use ($app) {
   include '../functions/season/papersundertaking.php';
});

//fetchseasonstudents
$app->get('/fetch/season/set_students/{course_id}/{dept_id}/{level_id}/{year}/{term}', function(Request $request) use ($app) {
    include '../functions/season/fetchstudent.php';
});
$app->get('/fetch/season/set_students/{course_id}', function(Request $request) use ($app) {
    include '../functions/season/fetchstudent.php';
});
$app->get('/fetch/season/set_students/{course_id}/{dept_id}', function(Request $request) use ($app) {
    include '../functions/season/fetchstudent.php';
});
$app->get('/fetch/season/set_students/{course_id}/{dept_id}/{level_id}', function(Request $request) use ($app) {
    include '../functions/season/fetchstudent.php';
});
$app->get('/fetch/season/set_students/{course_id}/{dept_id}/{level_id}/{year}', function(Request $request) use ($app) {
    include '../functions/season/fetchstudent.php';
});
$app->get('/fetch/season/set_students', function(Request $request) use ($app) {
   include '../functions/season/fetchstudent.php';
});

$app->put('/update/season_start_End/{course_id}', function (Request $request) use ($app) {

 
/* Attempt to connect to MySQL database */
$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

 
    //Verifying the required parameters

$id=$request->getParsedBody()['season_id'];
$course_id=$request->getAttribute('course_id');
$academicyear=$request->getParsedBody()['academicyear'];
$query1="SELECT * FROM season WHERE course_id='$course_id' AND id='$id' AND academicyear='$academicyear'";
$res=mysqli_query($con,$query1);
while ($row=mysqli_fetch_assoc($res)) {
	$status=$row['status'];
  echo $status;
}


if ($status=="1") {
	 $data=array();

  $query = "UPDATE season SET status='0' WHERE id=$id";
 $stmt = $con->prepare($query);
  //$stmt->execute();
 $result = $stmt->execute();
        $stmt->close();
        if($result==true){

$response=array('status' => "true",'Message' => "Season Deactivated Succesfully");
echo json_encode($response);
        }
        else{
          $response=array('status' => "false",'Message' => "Season Deactivate Failed");
         echo json_encode($response);
        } 
}

if ($status=="0") {
	 $data=array();

  $query = "UPDATE season SET status='1' WHERE id=$id";
 $stmt = $con->prepare($query);
  //$stmt->execute();
 $result = $stmt->execute();
        $stmt->close();
        if($result==true){

$response=array('status' => "true",'Message' => "Season Activated Succesfully");

        }
        else{
          $response=array('status' => "false",'Message' => "Season Activate Failed");
         echo json_encode($response);
        } 
}

echo json_encode($response);
  
});

$app->get('/fetch/season_class/{course_id}', function (Request $request) use ($app) {

   include '../functions/season/getclasses.php';
});
$app->get('/fetch/season_class/{course_id}/{season_id}', function (Request $request) use ($app) {

   include '../functions/season/getclasses.php';
});
$app->get('/fetch/season_class/{course_id}/{season_id}/{dept_id}', function (Request $request) use ($app) {

   include '../functions/season/getclasses.php';
});
$app->get('/fetch/season_class/{course_id}/{season_id}/{dept_id}/{level_id}', function (Request $request) use ($app) {

   include '../functions/season/getclasses.php';
});
$app->get('/fetch/season_class/{course_id}/{season_id}/{dept_id}/{level_id}/{year}', function (Request $request) use ($app) {

   include '../functions/season/getclasses.php';
});
$app->get('/fetch/season_class/{course_id}/{season_id}/{dept_id}/{level_id}/{year}/{term}', function (Request $request) use ($app) {

   include '../functions/season/getclasses.php';
});
$app->get('/fetch/season_class/{course_id}/{season_id}/{dept_id}/{level_id}/{year}/{term}/{sections}', function (Request $request) use ($app) {

   include '../functions/season/getclasses.php';
});
$app->get('/fetch/season_class', function (Request $request) use ($app) {

   include '../functions/season/getclasses.php';
});






//Faculty Base APi //

$app->post('/add/faculty', function (Request $request, Response $response) use ($app) {

/* Attempt to connect to MySQL database */


$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
$institutecode=$request->getParsedBody()['Institute_code'];
 $institutename = $request->getParsedBody()['Institute_name'];
  $facultyname = $request->getParsedBody()['Faculty_name'];
  $staffnumber = $request->getParsedBody()['Staff_number'];
  $papersmanaging=$request->getParsedBody()['papers_managing'];
  $email = $request->getParsedBody()['Email'];
  $phone = $request->getParsedBody()['Phone'];
  $pwt=$request->getParsedBody()['PWT'];
  $pwi = $request->getParsedBody()['PWI'];
  $pwe = $request->getParsedBody()['PWE'];
  $password=$request->getParsedBody()['Password'];
  $course=$request->getParsedBody()['course_id'];
  $dept=$request->getParsedBody()['dept_id'];
  $date=date("m.d.y");
  $time=date("H:i:s"); 
  $status="1";

  json_decode($papersmanaging,true);


$resultEncoded = json_encode($papersmanaging);


 $response=array();
 $data=array();

 if ($pwt=="") {
  $pwt="0";
 }
 if ($pwi=="") {
  $pwi="0";
 }
 if ($pwe=="") {
  $pwe="0";
 }

 $sql2="SELECT * FROM faculty WHERE Staff_number = ' $staffnumber' OR Email='$email' OR Phone='$phone'";
$result2=mysqli_query($con,$sql2);

 if(mysqli_num_rows($result2) > 0){
   $response=array('status' => "false",'Message' => "Faculty Number or Email or Phone Already Exist");
         echo json_encode($response);
}
  
  
 else{


  $query = "INSERT INTO  faculty (Institute_name,institute_code,Faculty_name,Staff_number,papers_managing,Email,Phone,PWT,PWI,PWE,Password,course_id,dept_id,status,date,time) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
 $stmt = $con->prepare($query);
 $stmt->bind_param("ssssssssssssssss",$institutename,$institutecode, $facultyname,$staffnumber,$resultEncoded,$email,$phone,$pwt,$pwi,$pwe,$password,$course,$dept,$status,$date,$time);
  //$stmt->execute();
 $result = $stmt->execute();
        $stmt->close();
        if($result==true){
            $data=
        array(
           'Institute_name'=>$institutename,
          'institute_code'=>$institutecode,
            'Faculty_name' =>$facultyname,
            'Staff_number' => $staffnumber,
            'papers_managing' => $papersmanaging,
            'Email' =>$email,
            'Phone'=>$phone,
            'PWT'=>$pwt,
            'PWI'=>$pwi,
            'PWE'=>$pwe,
            'Password'=>$password,
            'course_id'=>$course,
            'dept_id'=>$dept,
            'status'=>$status,
         );
    
    $message=$data;

$response=array('status' => "true",'Message' => "Faculty Registered Succesfully",'Exam' => $message);
echo json_encode($response);
        }
        else{
          $response=array('status' => "false",'Message' => "Registration Failed");
         echo json_encode($response);
        }
      }
        
});

$app->get('/fetch/faculty', function (Request $request, Response $response) use ($app) {


// Attempt to connect to MySQL database //
$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
$response=array();
$sql="SELECT * FROM faculty";
$result=mysqli_query($con,$sql);
    while ($row[]=mysqli_fetch_assoc($result)) {

      $user=$row;
    }
    echo json_encode($user);
   exit();

});

$app->get('/fetch/faculty/{course_id}/{dept_id}', function (Request $request, Response $response) use ($app) {


// Attempt to connect to MySQL database //
$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
$response=array();
$deptid=$request->getAttribute('dept_id');
$course_id=$request->getAttribute('course_id');

	$sql1="SELECT * FROM faculty WHERE course_id=$course_id AND dept_id=$deptid AND status='1'";
$result1=mysqli_query($con,$sql1);

 if(mysqli_num_rows($result1) > 0){
  while ($row[]=mysqli_fetch_assoc($result1)) {

    $Season=$row;
}
echo json_encode($Season);
}

});

$app->get('/fetch/faculty/{course_id}', function (Request $request, Response $response) use ($app) {


// Attempt to connect to MySQL database //
$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
$response=array();
$deptid=$request->getAttribute('dept_id');
$course_id=$request->getAttribute('course_id');

	$sql1="SELECT * FROM faculty WHERE course_id=$course_id AND status='1'";
$result1=mysqli_query($con,$sql1);

 if(mysqli_num_rows($result1) > 0){
  while ($row[]=mysqli_fetch_assoc($result1)) {

    $Season=$row;
}
echo json_encode($Season);
}
else{
  
       echo "null";
       } 
});



$app->put('/update/faculty/{faculty_id}', function (Request $request) use ($app) {

 
/* Attempt to connect to MySQL database */
$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

 
    //Verifying the required parameters

$id=$request->getAttribute('faculty_id');
  $staffnumber = $request->getParsedBody()['Staff_number'];
  $facultyname = $request->getParsedBody()['Faculty_name'];
 $email = $request->getParsedBody()['Email'];

 $data=array();

  $query = "UPDATE  faculty SET Staff_number=?,Faculty_name=?,Email=? WHERE id=$id";
 $stmt = $con->prepare($query);
 $stmt->bind_param("sss",$staffnumber,$facultyname,$email);
  //$stmt->execute();
 $result = $stmt->execute();
        $stmt->close();
        if($result==true){
            $data=
        array(
            'Staff_number' => $staffnumber,
            'Faculty_name' =>$facultyname,
            'Email' => $email,
         );
    
    $message=$data;

$response=array('status' => "true",'Message' => "Faculty Details Updated Succesfully",'Faculty' => $message);
echo json_encode($response);
        }
        else{
          $response=array('status' => "false",'Message' => "Faculty Details Update Failed");
         echo json_encode($response);
        }   
});

$app->delete('/delete/faculty/{faculty_id}', function (Request $request) use ($app) {

 
/* Attempt to connect to MySQL database */
$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);


$id=$request->getAttribute('faculty_id');
 
 $response=array();
 $data=array();

  $query = "DELETE FROM faculty WHERE id=?";
 $stmt = $con->prepare($query);
 $stmt->bind_param("s",$id);
  //$stmt->execute();
 $result = $stmt->execute();
        $stmt->close();
        if($result==true){

$response=array('status' => "false",'Message' => "Faculty Removed Succesfully");
echo json_encode($response);
        }
        else{
          $response=array('status' => "true",'Message' => "Faculty Removed Failed");
         echo json_encode($response);
        }   
});

$app->get('/disabled/faculty/{faculty_id}', function (Request $request) use ($app) {

 
/* Attempt to connect to MySQL database */
$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

 

$id=$request->getAttribute('faculty_id');

 $data=array();

 $query1="SELECT * FROM faculty WHERE id='$id' ";
 $res=mysqli_query($con,$query1);
 while($row=mysqli_fetch_assoc($res)){
$status=$row['status'];
 }

 if ($status=='1') {
   $query = "UPDATE  faculty SET status='0' WHERE id=$id";
 $stmt = $con->prepare($query);
  //$stmt->execute();
 $result = $stmt->execute();
        $stmt->close();
        if($result==true){

$response=array('status' => "true",'Message' => "Faculty Disabled  Succesfully");
echo json_encode($response);
        }
        else{
          $response=array('status' => "false",'Message' => "Faculty Disabled Failed");
         echo json_encode($response);
        }   
 }

 else{
   $query = "UPDATE  faculty SET status='1' WHERE id=$id";
 $stmt = $con->prepare($query);
  //$stmt->execute();
 $result = $stmt->execute();
        $stmt->close();
        if($result==true){

$response=array('status' => "true",'Message' => "Faculty Enabled  Succesfully");
echo json_encode($response);
        }
        else{
          $response=array('status' => "false",'Message' => "Faculty Disabled Failed");
         echo json_encode($response);
        }   
 }

 
});


//facultypaperfetching
$app->get('/fetch/faculty2/papers_managing/{course_id}/{dept_id}/{level_id}/{year}/{term}/{type}', function(Request $request) use ($app) {
    include '../functions/faculty/fetching_fact_papers.php';
});
$app->get('/fetch/faculty2/papers_managing/{course_id}/{dept_id}/{level_id}/{year}/{term}', function(Request $request) use ($app) {
    include '../functions/faculty/fetching_fact_papers.php';
});
$app->get('/fetch/faculty2/papers_managing/{course_id}/{dept_id}/{level_id}/{year}', function(Request $request) use ($app) {
    include '../functions/faculty/fetching_fact_papers.php';
});
$app->get('/fetch/faculty2/papers_managing/{course_id}/{dept_id}/{level_id}', function(Request $request) use ($app) {
    include '../functions/faculty/fetching_fact_papers.php';
});
$app->get('/fetch/faculty2/papers_managing/{course_id}/{dept_id}', function(Request $request) use ($app) {
    include '../functions/faculty/fetching_fact_papers.php';
});
$app->get('/fetch/faculty2/papers_managing/{course_id}', function(Request $request) use ($app) {
    include '../functions/faculty/fetching_fact_papers.php';
});
$app->get('/fetch/faculty2/papers_managing', function (Request $request) use ($app) {
  include '../functions/faculty/fetching_fact_papers.php';
});



$app->get('/totalcounts/faculty/{course_id}/{dept_id}', function (Request $request) use ($app) {

 
/* Attempt to connect to MySQL database */
$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

$depid=$request->getAttribute('dept_id');
$course_id=$request->getAttribute('course_id');

$result = $con->query("select * from faculty WHERE course_id='$course_id' AND dept_id='$depid'");
$count=$result->num_rows;


$result1 = $con->query("select PWT from faculty WHERE PWT='1' AND course_id='$course_id' AND dept_id='$depid'");
$count1=$result1->num_rows;


$result2 = $con->query("select PWI from faculty WHERE PWI='1' AND course_id='$course_id' AND dept_id='$depid'");
$count2=$result2->num_rows;



$result3 = $con->query("select PWE from faculty WHERE PWE='1' AND course_id='$course_id' AND dept_id='$depid'");
$count3=$result3->num_rows;

$data=array([
'faculty'=>$count,
'PWT'=>$count1,
'PWI'=>$count2,
'PWE'=>$count3
]
);
echo json_encode($data);
});

$app->get('/totalcounts/faculty/{course_id}', function (Request $request) use ($app) {

 
/* Attempt to connect to MySQL database */
$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

$course_id=$request->getAttribute('course_id');

$result = $con->query("select * from faculty WHERE course_id='$course_id'");
$count=$result->num_rows;


$result1 = $con->query("select PWT from faculty WHERE PWT='1' AND course_id='$course_id'");
$count1=$result1->num_rows;


$result2 = $con->query("select PWI from faculty WHERE PWI='1' AND course_id='$course_id'");
$count2=$result2->num_rows;



$result3 = $con->query("select PWE from faculty WHERE PWE='1' AND course_id='$course_id'");
$count3=$result3->num_rows;

$data=array([
'faculty'=>$count,
'PWT'=>$count1,
'PWI'=>$count2,
'PWE'=>$count3
]
);
echo json_encode($data);
});

$app->get('/totalcounts/faculty', function (Request $request) use ($app) {

 
/* Attempt to connect to MySQL database */
$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);


$result = $con->query("select * from faculty");
$count=$result->num_rows;


$result1 = $con->query("select PWT from faculty WHERE PWT='1' ");
$count1=$result1->num_rows;


$result2 = $con->query("select PWI from faculty WHERE PWI='1' ");
$count2=$result2->num_rows;



$result3 = $con->query("select PWE from faculty WHERE PWE='1'");
$count3=$result3->num_rows;

$data=array([
'faculty'=>$count,
'PWT'=>$count1,
'PWI'=>$count2,
'PWE'=>$count3
]
);
echo json_encode($data);
});


$app->put('/assignrole/faculty/{faculty_id}', function (Request $request) use ($app) {

 
/* Attempt to connect to MySQL database */
$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);

 
    //Verifying the required parameters
    // verifyRequiredParams(array('firstname', 'email', 'password'));
$id=$request->getAttribute('faculty_id');
$pwt=$request->getParsedBody()['PWT'];
$pwe=$request->getParsedBody()['PWE'];
$pwi=$request->getParsedBody()['PWI'];

 $data=array();

  $query = "UPDATE  faculty SET PWT='$pwt',PWI='$pwi',PWE='$pwe' WHERE id=$id";
 $stmt = $con->prepare($query);
  //$stmt->execute();
 $result = $stmt->execute();
        $stmt->close();
        if($result==true){
            $data=
        array(
            'PWT' => $pwt,
            'PWI' =>$pwi,
            'PWE' => $pwe,
         );
    
    $message=$data;

$response=array('status' => "true",'Message' => "Faculty Role Assigned Succesfully",'Faculty' => $message);
echo json_encode($response);
        }
        else{
          $response=array('status' => "false",'Message' => "Faculty Role Assigned Failed");
         echo json_encode($response);
        }   
});


//ExamPreOps

//EaxmPreOpsExamSchedule
$app->post('/insert/exam_schedule', function (Request $request, Response $response) use ($app) {

   include '../functions/exampreops/examschedule.php';
});
$app->put('/update/exam_schedule/{schedule_id}', function (Request $request, Response $response) use ($app) {

   include '../functions/exampreops/updateexamschedule.php';
});
$app->delete('/delete/exam_schedule/{schedule_id}', function (Request $request, Response $response) use ($app) {

   include '../functions/exampreops/deleteexamschedule.php';
});

//ExamPreOpsfetchexamschedule

$app->get('/fetch/exam_schedule', function (Request $request) use ($app) {
   include '../functions/exampreops/getppaperplot.php';
});

$app->get('/fetch/exam_schedule/{course_id}', function (Request $request) use ($app) {
   include '../functions/exampreops/getppaperplot.php';
});
$app->get('/fetch/exam_schedule/{course_id}/{season_id}', function (Request $request) use ($app) {
   include '../functions/exampreops/getppaperplot.php';
});
$app->get('/fetch/exam_schedule/{course_id}/{season_id}/{exams_id}', function (Request $request) use ($app) {
   include '../functions/exampreops/getppaperplot.php';
});

$app->get('/fetch/exam_schedule/{course_id}/{season_id}/{exams_id}/{date}', function (Request $request) use ($app) {
   include '../functions/exampreops/getppaperplot.php';
});


//ExamPreOpsfetchpaperslots

 $app->get('/fetch/paper_slots', function (Request $request) use ($app) {

   include '../functions/exampreops/getpaperslots.php';
});

$app->get('/fetch/paper_slots/{course_id}', function (Request $request) use ($app) {

   include '../functions/exampreops/getpaperslots.php';
});
$app->get('/fetch/paper_slots/{course_id}/{season_id}', function (Request $request) use ($app) {
    include '../functions/exampreops/getpaperslots.php';
});
$app->get('/fetch/paper_slots/{course_id}/{season_id}/{exams_id}', function (Request $request) use ($app) {

   include '../functions/exampreops/getpaperslots.php';
});


//EaxmPreOpssetMarks
$app->post('/insert/setmarks', function (Request $request, Response $response) use ($app) {

   include '../functions/exampreops/setmarks.php';
});
$app->put('/update/setmarks/{mark_id}', function (Request $request, Response $response) use ($app) {

   include '../functions/exampreops/updatemarks.php';
});
$app->delete('/delete/setmarks/{mark_id}', function (Request $request, Response $response) use ($app) {

  include '../functions/exampreops/deletemarks.php';
});

 $app->get('/fetch/fset_marks', function (Request $request) use ($app) {

   include '../functions/exampreops/fetch_setmarks.php';
});

$app->get('/fetch/fset_marks/{course_id}', function (Request $request) use ($app) {

   include '../functions/exampreops/fetch_setmarks.php';
});
$app->get('/fetch/fset_marks/{course_id}/{season_id}', function (Request $request) use ($app) {
    include '../functions/exampreops/fetch_setmarks.php';
});
$app->get('/fetch/fset_marks/{course_id}/{season_id}/{exams_id}', function (Request $request) use ($app) {

   include '../functions/exampreops/fetch_setmarks.php';
});

//ExamPreOpsSetstudents


$app->get('/fetch/students_get_exampreops/{course_id}', function (Request $request) use ($app) {

  include '../functions/exampreops/set_students/fetch_student.php';
});

$app->post('/insert/setstudents/exampreops', function (Request $request, Response $response) use ($app) {

  include '../functions/exampreops/set_students/set_student.php';
});


//ExamPreOpsfetchexams

$app->get('/fetch/fetchallexams', function (Request $request) use ($app) {

   include '../functions/exampreops/getallexams.php';
});

$app->get('/fetch/fetchallexams/{course_id}', function (Request $request) use ($app) {

   include '../functions/exampreops/getallexams.php';
});
$app->get('/fetch/fetchallexams/{course_id}/{season_id}', function (Request $request) use ($app) {
    include '../functions/exampreops/getallexams.php';
});

//PWI
//pwiactionneeded
$app->get('/fetch/pwiactions/{course_id}', function (Request $request) use ($app) {

   include '../functions/pwi/getactionspwi.php';
});

//pwisubmitanswerscripts
$app->post('/insert/answerscripts', function (Request $request, Response $response) use ($app) {

  include '../functions/pwi/answerscripts.php';
});


//PWE
//pweactionneeded
$app->get('/fetch/pweactions/{course_id}', function (Request $request) use ($app) {
   include '../functions/pwe/getactionspwe.php';
});

//pwepreviousActivities
$app->get('/fetch/pwepreviousActivities/{course_id}', function (Request $request) use ($app) {
   include '../functions/pwe/getpreviouspwe.php';
});

//pwe Evaluate Answer Scripts
$app->get('/fetch/pweeveluateanwerScript/{course_id}/{exam_id}/{paper_shortcode}', function (Request $request) use ($app) {
   include '../functions/pwe/evaluateanswerscript.php';
});

//pwe Evaluate Answer Scripts file
$app->get('/fetch/pweeveluateanwerScriptFile/{course_id}/{exam_id}/{paper_shortcode}', function (Request $request) use ($app) {
   include '../functions/pwe/evaluateanswerscriptfile.php';
});

//pwe Evaluate Answer Scripts counts
$app->get('/fetch/pweeveluateanwerScriptpage1count/{course_id}/{exam_id}/{paper_shortcode}', function (Request $request) use ($app) {
   include '../functions/pwe/evaluatelist_count/evaluate_page1_counts.php';
});

//pweanswersheetsubmit
$app->post('/fetch/pweanswersheetsubmit', function (Request $request) use ($app) {
   include '../functions/pwe/submit_pwe_paper.php';
});

//pwe grading screen count
$app->get('/fetch/pwegradingscreencount/{course_id}/{exam_id}/{paper_shortcode}', function (Request $request) use ($app) {
   include '../functions/pwe/grading/gradingcounts.php';
});

//pwe grading student list
$app->get('/fetch/pwegradingstudentlist/{course_id}/{exam_id}/{paper_shortcode}', function (Request $request) use ($app) {
   include '../functions/pwe/grading/gradingstudentlist.php';
});
//pwe grading grade list
$app->get('/fetch/pwegradinggradelist/{course_id}/{exam_id}/{paper_shortcode}', function (Request $request) use ($app) {
   include '../functions/pwe/grading/gradinggradelist.php';
});

//pwe grading grade list
$app->get('/fetch/pwegreevaluatepapaer/{course_id}/{exam_id}/{paper_shortcode}', function (Request $request) use ($app) {
   include '../functions/pwe/reevaluatepaper.php';
});




//pugazh//

//last//

//PWT Module
    //Dashboard
    $app->get('/fetch/pwtdashboard/{course_id}', function (Request $request) use ($app) {
   include '../functions/pwt/pwtdashboard/pwtdashboard.php';
    });
    
    //set_sections
//insert_set_sections
$app->post('/add/set_sectioned', function (Request $request, response $response) use ($app) {
	include '../functions/pwt/set_questionpaper/set_sections/insert.php';	
});
//fetch_set_sections
$app->get('/fetch/set_sectioned/{paper_id}', function (Request $request, response $response) use ($app) {
	include '../functions/pwt/set_questionpaper/set_sections/fetch.php';	
});


//update_set_sections
$app->put('/update/set_sectioned/{id}', function (Request $request, response $response) use ($app) {
	include '../functions/pwt/set_questionpaper/set_sections/update.php';	
});
//delete_set_sections
$app->delete('/delete/set_sectioned/{id}', function (Request $request, response $response) use ($app) {
	include '../functions/pwt/set_questionpaper/set_sections/delete.php';	
});
    
//last//




/// Mobile Api ///

//Exam Screen
$app->get('/fetch/upcoming_exams/{roll_no}', function (Request $request, response $response) use($app){
   include '../mobile/exams/upcoming_exams.php'; 
}); 


//Get paper
$app->get('/fetch/get_paper_list/{paper_id}', function (Request $request, response $response) use($app){
    include '../mobile/paper/paper_list.php';
});


//Syllabus

$app->get('/fetch/get_syllabus/{paper}',function (Request $request, response $response) use($app){
    include '../mobile/syllabus/syllabus_list.php';
});


//profile

$app->get('/fetch/get_profile/{roll_no}', function (Request $request, response $response) use($app){

           include '../mobile/syllabus/profile.php';
});
/// Mobile Api ///
	
$app->run();