/* Handle feedback submission */
function mkdir_r($dirName, $rights=0777){
$dirs = explode('/', $dirName);
$dir='';
foreach ($dirs as $part) {
$dir.=$part.'/';
if (!is_dir($dir) && strlen($dir)>0)
mkdir($dir, $rights);
}
}
if (isset($_POST["Submit"])) {
if ($_POST["course"]==$COURSEPREFIX) {
$comments=$_POST["comments"];
$comments=str_replace("\n\r", " ", $comments);
$comments=str_replace("\n", " ", $comments);
$comments=str_replace("\r", " ", $comments);
$values = $_POST["semester"]."\t".$_POST["year"]."\t". $_POST["stars"]. "\t" . $comments ."\n";
#. "\t" .$_POST["interest"] . "\t" . $_POST["effectiveness"] . "\t" . $_POST["email"] ."\n";
$feedbackFilename=getFeedbackPath($section)."feedback.txt";
$feedbackPath=getFeedbackPath($section);
if(!file_exists($feedbackFilename)) {
mkdir_r($feedbackPath,0775);
}
$open = fopen( $feedbackFilename, "a" );
fwrite( $open, $values);
fclose( $open );
$message=" Your feedback was received. THANK YOU! ";
}
else {
$message=" You submitted feedback but did not include the course name. You must include the course name in the feedback. ";
}
print $message;
}
?>
echo "$section";
?>
echo Outline2Str($outline,$section);
?>
|
#does not allow files to come from other servers
if(ereg('http',$filename)) {
die('bad filename');
}
else {
include($filename);
}
?>
echo navLinks($outline,$section);
?>
if(!$repressFeedback){
include("feedback.php");
$showFeedbackResults=TRUE;
if($showFeedbackResults) {
$feedbackFilename=getFeedbackPath($section)."feedback.txt";
if(file_exists($feedbackFilename)) {
$handle=fopen($feedbackFilename,"r");
$totalStars=0;
$responses=0;
$commentsTable="";
while (($data = fgetcsv($handle, 5000, "\t")) !== FALSE) {
$thisStar=$data[2];
if($thisStar!="") {
$thisComment=$data[3];
$totalStars=$totalStars+$thisStar;
$responses++;
$commentsTable=$commentsTable." | $thisComment | ";
}
else {
$commentsTable=$commentsTable." | $thisComment | ";
}
}
$aveStars=$totalStars/$responses;
$roundedAveStars=round(2*$aveStars)/2;
$starsImage="./images/ratingstars/stars-".$roundedAveStars.".gif";
print "Average Rating: ";
$commentsTable=$commentsTable." ";
print $commentsTable;
}
}
}
?>
|
|