<?php
require_once "evaluation.config.php"; //mod_evaluation config for database configuration, already connects to db through admin/common.php
class student {
var $databasefields;
function getToken($activeflag = 1)
{
global $dbprefix;
$querystring = "
SELECT p.idteacher, p.sid, p.token, p.validuntil, p.active,
t.firstname, su.short_title, t.lastname
FROM pretoken p, student s, teacher t, ".$dbprefix."surveys su
WHERE p.idstudent=s.idstudent AND p.idteacher=t.idteacher
AND p.sid=su.sid and p.idstudent=" . $this->databasefields['idstudent'] . " and p.active=" . $activeflag;
$result = mysql_query($querystring);
while ($row = mysql_fetch_assoc($result)) {
$outer_array[] = $row;
}
if (mysql_affected_rows()<1) {
//no result, create artificial answer as warning message
$row['sid']=0;
$outer_array[]=$row;
}
return $outer_array;
}
function printTokenList($activeflag = 1)
{
global $publicurl;
$activeToken = $this->getToken($activeflag);
foreach($activeToken as $myToken) {
if (!$myToken['sid']==0){
$getparameter[0]=$myToken['sid'];
$getparameter[1]='&token=' . $myToken['token'] ;
$getparameter[1]="";
echo "<a href='$publicurl/index.php?sid=" . $getparameter[0] . $getparameter[1]. "'>" . $myToken['firstname'] . " " . $myToken['lastname'] . "</a> " . $myToken['short_title'] . "<br>";
}else{
echo _NO_ENTRIES;
}
}
return null;
}
}
function me_error($message){
echo "<br>ERROR: <b style='background-color:red; color:black'>$message </b><br>";
}
function activateSurvey($flag, $_sid,$confirm){
$_GET['action']=$flag;
$_GET['sid']=$_sid;
$_GET['ok']=$confirm;
global $htmlheader;
global $databasename;
global $connect ;
global $setfont ;
global $btstyle ;
global $dbprefix;
global $scriptname;
$sid=$_sid;
require "../admin/activate.php"; //?action=activate&sid=2&ok=Y
}
class Teacher{
var $databasefields;
var $surveytablename;
function Teacher($idteacher)
{
global $dbprefix;
unset($databasefields);
$querystring="Select * from teacher where teacher.idteacher=$idteacher LIMIT 1";
$result=mysql_query($querystring);
$this->databasefields = mysql_fetch_assoc($result);
$this->surveytablename=$dbprefix ."survey_". $this->databasefields['currentsid'];
}
}
?>