include ("session-utils.php");
include ("google-ads.php");
if (!isset($_SESSION['idx']))
$_SESSION['idx'] = rand(1,32767);
$idx = $_SESSION['idx'];
$_SESSION['teaOrKid'] = "0";
include ("db_utils.php");
db_connect();
include ("menu_utils.php");
include ("reg-utils.php");
if($_SESSION['AcctName']) // If we are already logged in, there must be a session
{
$AcctName = $_SESSION['AcctName'];
$AcctApwd = $_SESSION['AcctApwd'];
$AcctID = $_SESSION['AcctID'];
}
else
{
$AcctName = 'guest'; // reset
$AcctApwd = ''; // reset
$AcctID = 10; // for 'guest'
}
if (isset($AcctNameT)) // This is set if this file was called as a post from "Login"
{
$AcctNameT2 = truncate($AcctNameT, 10);
$AcctApwdT2 = truncate($AcctApwdT, 8);
$AcctID = is_valid_user_login($AcctNameT, $AcctApwdT, $idx);
if ($AcctID > 0)
{
$_SESSION['AcctName'] = $AcctNameT2;
$_SESSION['AcctApwd'] = $AcctApwdT2;
$_SESSION['AcctID'] = $AcctID;
$AcctName = $AcctNameT2;
$AcctApwd = $AcctApwdT2;
}
}
include ("MathApp_utils.php");
$DTAG = "DIV";
$DTAG2 = "DIV";
include ("upd-browser-stats.php");
update_user_stat($MacSF, $MacIE, $MacN6, $MacCh, $WinFF, $WinIE, $WinN6, $WinCh);
$a_channel = A_PROB_PAGE; // Problem page
$s_channel = S_PROB_PAGE; // Problem page
if ($mode == 1) {
$a_channel = A_PROGRESS; // Check progress
$s_channel = S_PROGRESS; // Check progress
}
else if ($mode == 2) {
$a_channel = A_FIND_HWORK; // Find Homework
$s_channel = S_FIND_HWORK; // Find Homework
}
?>
MathDrill - an interactive site for Math Problems!
if ($mode == 0) {
?>
}
?>
include ("misc-jsutils.php");
inclEndSessScript($BrwCh, $BrwN6, $BrwIE, $BrwFF, $AcctID);
?>
if ($mode == 0 && $AcctID > 0) {
if (isset($hwork))
$appmode = 1;
else
$appmode = 0;
if (!isset($level))
$level = 0;
print("\n");
// print("initNumCols($level);");
// print("moreProblems('$platform', '$AcctName', '$AcctApwd', '$level', '$access');");
}
else {
print("\n");
}
?>
ShowGoogleAd($a_channel);
?>
if (isset($hwork))
showLogoAndAcct($s_channel, $AcctID, $AcctName, NULL, -1);
else
showLogoAndAcct($s_channel, $AcctID, $AcctName, $HLogin, $mode);
?>
if (!isset($hwork))
{ // don't display site nav labels for HWork
?>
if ($mode == 1) // Display activity summary
ShowMenuBar('progress');
elseif ($mode == 2) // Display homework summary
ShowMenuBar('homework');
else // Display applet for lessons
ShowMenuBar('problems');
?>
} // don't display site nav labels for HWork
?>
include ("MathControl.php");
if ($AcctID > 0) {
if ($mode == 0) { // Display applet for lessons
?>
if (!isset($numP))
$numP = 10;
ShowMathControl($level, $numP, $platform, $AcctName, $AcctApwd, $DTAG, $DTAG2, $BRW);
} // if ($mode == 0) {
elseif ($mode == 1) { // Display activity summary
?>
print("\n"); // Form is unused in this mode
} // elseif ($mode == 1) // Display activity summary
elseif ($mode == 2) { // Display homework summary
include ("db_info.php");
include ("submit-getpass.php");
/* make connection to database */
MYSQL_CONNECT($hostname, $username, $password) OR DIE("Unable to connect to MYSQL");
@mysql_select_db( "$dbName") or die( "Unable to select database");
if (isset($addW)) { // This is set if this file was called as a post from this file itself (add Teacher)
$TeacherID = db_getVal("Teacher", "TeacherId", "Name", $addW); // Check if $addW is a valid teacher
if ($TeacherID > 0) { // check if this teacher is already in watchlist
$TID = db_getVal2("MyTeachers", "TeacherId", "AcctId", $AcctID, "TeacherId", $TeacherID);
if ($TID <= 0)
db_addVal2("MyTeachers", $AcctID, $TeacherID);
}
}
if (isset($dnum)) { // This is set if this file was called as a post from this file itself (del Teacher)
for ($i = 0; $i < $dnum; $i++) {
$TeacherID = db_getVal("Teacher", "TeacherId", "Name", $delW[$i]);
if ($TeacherID > 0)
db_delVal2("MyTeachers", "AcctId", $AcctID, "TeacherId", $TeacherID);
}
}
?>
if (isset($addW)) {
print("\n");
if ($TeacherID == 0)
print("$addW is not a Teacher in our database!");
else if ($TID > 0)
print("$addW is already in your watchlist!");
print(" \n");
}
?>
Homeworks Due
if (isset($grade))
print(" for Grade $grade");
?>
(Click on a Hw # to bring up the Problems Page with that problem level.)
$Grade = db_getVal("MathAcct", "Grade", "AcctId", $AcctID);
$today = date("Y-m-d");
$lastMonth = date("Y-m-d", time() - 2592000);
$query = "SELECT Name, HworkGivenId, Label, HomeworkGiven.Level as Level, NumProbs, DueDate, Sname ";
if (!isset($grade))
$query .= ", Grade ";
$query .= "FROM HomeworkGiven, MyTeachers, MathLevels, Teacher, Submission ";
$query .= "WHERE MyTeachers.AcctId = $AcctID AND DueDate >= '$lastMonth' ";
$query .= "AND HomeworkGiven.TeacherId = MyTeachers.TeacherId ";
$query .= "AND MyTeachers.TeacherId = Teacher.TeacherId ";
$query .= "AND HomeworkGiven.Level = MathLevels.Level ";
$query .= "AND Submission.Stype = HomeworkGiven.Stype ";
if (isset($grade))
$query .= "AND HomeworkGiven.Grade = '$grade' ";
$query .= "ORDER BY Name, HworkGivenId";
$result = MYSQL_QUERY($query);
$number = MYSQL_NUMROWS($result);
// Print these results to the screen in a nice format
$i = 0;
if ($numW == 0)
print("You need to put some registered teachers in your watchlist in order to find the homeworks that they have assigned. \n");
elseif ($number == 0)
print("
No homeworks assigned by teachers in your watchlist . \n");
elseif ($number > 0) {
print("
");
print("\n");
print(" Teacher Hw # ");
if (!isset($grade))
print(" For Grade ");
print(" Problem Level # problems Due Date Acceptance\n");
print(" \n");
while ($i < $number) {
$Name = mysql_result($result,$i,"Name");
$HworkGivenId = mysql_result($result,$i,"HworkGivenId");
$Label = mysql_result($result,$i,"Label");
$Level = mysql_result($result,$i,"Level");
$NumProbs = mysql_result($result,$i,"NumProbs");
$DueDate = mysql_result($result,$i,"DueDate");
list($year, $month, $day) = explode('-', $DueDate);
if (!isset($grade))
$Grade = mysql_result($result,$i,"Grade");
$Sname = mysql_result($result,$i,"Sname");
$Upass = getSubmitPass($HworkGivenId);
if ($DueDate >= $today)
print("\n");
else
print(" \n");
print(" $Name ");
print(" $HworkGivenId ");
if (!isset($grade))
print(" $Grade ");
print(" $Label $NumProbs $month/$day/$year $Sname\n");
print(" \n");
$i++;
}
print("
\n");
}
} // elseif ($mode == 2) // Display homework summary
inclMathControlApplet($BRW);
if ($mode != 0)
{
include ("bottom-links.php");
ShowBottomLinks("0", $sidSfx, $MainApp, $Logout, $BRW, $lang);
}
} // if ($AcctID > 0)
else { // No or incorrect account info in cookies. Show login form
if (!isset($mode))
$mode = 0;
print(" \n");
include ("login_utils.php");
ShowLoginForm($mode, $AcctID, $lang);
}
?>