I think I may have answered this myself, if anyone would be so kind as to check my logic I would be extremely grateful.
The key is in the classroom embed code here...
// The object to load and instance name. To create a different "session",
// just copy the html page and change the instance name.
var object = 'new_conference:jethro';
So I need to change the 'var object' in the Javascript from 'jethro' (which is what I named the classroom) to a random string each time a teacher creates a classroom. That random string should be held in a PHP variable which I'll call '$instance'...
So I have created an index.php login page with a temporary database. Here is the link on the live site: http://toucan-talk.com/classes
The temporary database has the following credentials
username: jethro
password: password
Here is the index.php code with comments by me...
<?php
session_start();
if ($_POST['username']) {
// Temporary database
$dbUsname = "jethro";
$dbPaswd = "password";
$uid = "1";
$usname = strip_tags($_POST['username']);
$paswd = strip_tags($_POST['password']);
if ($usname == $dbUsname && $paswd == $dbPaswd) {
// Set session variables
$_SESSION['username'] = $usname;
$_SESSION['id'] = $uid;
// To generate the random string from a word
$str = "Hello"; // word to hash
$instance = md5($str); // hash stored in variable
header('Location: classroom.php?instance='.$instance);// Hash is concatenated onto the login redirect page
} else {
echo "<p>Oops! That username or password combination is incorrect. Please try again.</p>";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="style.css">
<title>Toucan-Talk Tutor Login</title>
</head>
<body>
<div id="wrapper">
<center>
<img style="width: 250px;" alt="" src="http://www.toucan-talk.com/images/logos/footer-logo.png">
</center>
<h1>Enter Classroom</h1>
<form id="form" action="index.php" method="post" enctype="multipart/form-data">
Username: <input type="text" name="username"/><br>
Password: <input type="password" name="password" /><br>
<br>
<center>
<input class="button" type="submit" value="Enter" name="Submit" />
</center>
</form>
</body>
</html>
So I have concatenated that md5 hash onto the header page redirect so that I now get a url that looks like this: http://toucan-talk.com/classes/classroom.php?instance=8b1a9953c4611296a827abf8c47804d7
I have made another file called classroom.php which the header redirects to. Inside there I have the classroom embed code. Here is just the PHP inside that file:
<?php
session_start();
// Variable with the md5() hash code
$instance = $_GET['instance'];
if (isset($_SESSION['id'])) {
$uid = $_SESSION['id'];
$usname = "Test variables: <br> Username: ".$usname. "<br> Id: ".$uid;
} else {
echo 'Please login';
die();
}
?>
As you can see I have defined the variable '$instance' again as $instance = $_GET['instance']; (I am not quite sure what this does still but it doesn't work without it!)
So I know $_GET['instance'] = $instance = 8b1a9953c4611296a827abf8c47804d7
Now I simply replace the Javascript 'var object' with the variable $instance in PHP tags to generate the classroom on the fly on the Groupworlds servers!
// The object to load and instance name. To create a different "session",
// just copy the html page and change the instance name.
var object = 'new_conference:<?php echo $instance ?>';
Now when I look at the classroom sourcecode the instance is the md5() hash!
sourcecode
This seems to do the trick... so does this seem like a reasonable way to solve this coding problem? I am excited to improve upon this to get something workable.
Many thanks for you guys help this far.
Jethro.