My teacher want to create some virtual lessons for his object and he created a version for the student and one for the teacher.
He now asked me how to redirect students using the teacher control panel, from one part of the lesson to another.
I can do the PHP part for the teacher panel and the server file to be called every 2-3 seconds to see if a redirect is mandatory. Maybe this is a JSON/AJAX thing?
Thanks
You can do in this way. (for student)
from student panel, make a periodic request to server (in interval of 5-10 s).
//data is returned by server as json object
//data.route = true or false as validated from database
//data.location is the location new url
$.post("server.php", { "id": "studentid" },
function(data){ //data is returned by server as json object
if(data.route)
{
window.location = data.location
}
},
"json");
On the server side you can do
if(student is to be routed){ //check from the database
$data['route'] = true;
$data['location'] = 'location';
}
else{
$data['route'] = false;
}
echo json_encode($data);
UPDATE::
put the above ajax code insde a function
function fun1()
{
//put your ajax code herer
}
and on document ready funcion
$(function(){ setInterval( 'fun1()', 1000) });
//use setInterval function
// to call function periodically
you might wanna see this