Location: PHPKode > projects > EdLite-light-weight web classrooms > edlite/templates/student_template/assignments.php
This file is part of EdLite.
Copyright (C) 2005 Philip Spears and Philip Allen

Edlite is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

Edlite is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with EdLite; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

Version: 2005081900 


$student_name = str_replace(dirname(getcwd())."/", "", getcwd());
$course_name = str_replace(dirname(dirname(getcwd()))."/", "", dirname(getcwd()));
$current_date  = date("m.d.Y");
$title = basename($HTTP_SERVER_VARS[PHP_SELF], ".php");
if (file_exists("./header.html")) { include ("./header.html"); }
if ($HTTP_POST_VARS['post'] == "true") {
	$assignment	=stripslashes($HTTP_POST_VARS['assignment']);
	$date		=$HTTP_POST_VARS['date'];
	$course		=$HTTP_POST_VARS['course'];
	$file = "./assign.txt";
/* merge post data into string.. tab deliminated with cr (\n) and lf \r */
	$assignment_entry = $course."\t".$date."\n\r".$assignment."\n\r\n\r\n\r";
	if (!file_exists($file)) { touch($file); }
	if (is_writable($file)) {
		// making entry_read here!!
		if (!$entry_read = fopen($file, "r")) {
			echo "cannot read text file";
		// make $content here!
		if (filesize($file) == "0") {
			$content = "";
		} else {
			$content = fread($entry_read, filesize($file));
		//this $towrite = $jentry . $content; // is the same as one line below
		$towrite = $assignment_entry.$content;
		//make $entry1 here!
		if (!$entry = fopen($file, "w+")) {
			echo "cannot open test.txt";
		//or die("Could not create file.");
		//writes the input jentry to string entry1;
		if (fwrite ($entry, $towrite) === FALSE) {
			echo "cannot write to assign.txt";
		printf ("<div class=\"box_red\" style=\"text-align: center;\">Assignment Posted<br /></div>");
		//prints link to jentry web output
		//printf ("<a href=\"assignments.php\">Read Assignments</a>");
		//closes entry one
		} else { // else if file is writable.
			printf ("<div class=\"box_red\" style=\"text-align: center;\">unable to write to ($file)<br /></div>");
		} // end if writable.
}//end if post == true
<div class="box_noborder">
	<?php printf($student_name); ?>'s <?php printf($course_name); ?> Assignment Entries
	<br />
	<a href="#NewEntry">Create a new Entry</a>
<br />
<div class="box">
$file = "./assign.txt";
if (file_exists($file) && filesize($file) != "0") {
<pre style="padding-left:10px; padding-right:10px;" wrap="on"><?php include ($file); ?></pre>
} else {
	printf ("<br /><center>No assignments posted.</center><br />");
<br /><br /><br /><br /><br /><br />
<div class="box">
	&nbsp;&nbsp;<a name="NewEntry">Assignment Entry Form</a><br />
	<form action="assignments.php" method=post>
		&nbsp;&nbsp;Date : <input name="date" type="text" value="<?php printf($current_date); ?>"><br />
		&nbsp;&nbsp;Assignment<br />
		&nbsp;&nbsp;<textarea  name="assignment" rows="15" cols="60" wrap></textarea><br />
		<input name="course" type="hidden" value="<?php printf($course_name); ?>">
		<input name="post" type="hidden" value="true">
		&nbsp;&nbsp;<input type="submit" name="submit" value="Add Entry"><br />
if (file_exists("./footer.html")) { include ("./footer.html"); }
Return current item: EdLite-light-weight web classrooms