"ID-"){ $counter++; $line=$_POST["$idlist[$i]"]; switch ($counter){ case 1: $quiz =$quiz."#$question\n"; $quiz =$quiz."$line\n"; $solutions=$solutions."$question/$line/"; break; case 2: $solutions=$solutions."$line\n"; break; case 3: $quiz =$quiz."Type: Choice\n"; $quiz =$quiz."&$line\n"; break; default: $quiz =$quiz."&$line\n"; break; } } else { if ($counter<3){ $quiz =$quiz."Type: Text\n"; } $counter=0; $question++; } } $filename=$_POST['filename']; if (file_exists ("../sitedata/Quiz/Questions/".$filename.".txt")){ echo '

File already exists!

'; } else{ $file=fopen("../sitedata/Quiz/Questions/".$filename.".txt", 'w+'); $quiz=rtrim($quiz, "\n"); fwrite($file, $quiz); fclose($file); echo '

Quiz file'. "$filename.txt".'
written successfully...

'; if ($file=fopen("../sitedata/Quiz/Solutions/~".$filename."~.txt", 'w+')){ $solutions=rtrim($solutions, "\n"); fwrite($file, $solutions); fclose($file); echo '

Solutions file'. "$filename.txt".'
written successfully.

'; } else { echo '

Solutions text file could not be written!

'; } } } ?>

Add Normal Question
Add MC Question

 

Quiz Title: File name

Back