Vous êtes sur la page 1sur 29

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms

NFC Project Report - OMIS 107, Fall 2014 - Page 1/29

Present!
NFC Attendance Tracker

Present by Brian Grossman, Jacob Matta, Sean Meagher,


Josh Mitchell, Josh Taylor, and Lilly Wilhelms
OMIS 107 - Fall 2014
Professor Brian Moon
December 4, 2014

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 2/29

Table of Contents
Executive Summary
Business Problem and Background
Problem
Opportunity
Solution
How it Works
Our Competition
Business Case
Technical Discussion
Software Integrated
Windows NFC app
PHP
HTML/CSS
SQL
Web-based server
How It Works
Database Schema Description
Future Developments
Reference Citations
Appendices
GoToTags - Windows NFC App
Attendance, Instructor, and Student tables (mySQL)
Source Code: index.php
mySQL Database Dump
Attend107.com - Access Information

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 3/29

I.

Executive Summary

Present! is a fresh take on the world of attendance tracking. Our company is dedicated to making
attendance tracking better, much better, because as experienced college students, we understand
the value of attendance for students and teachers alike. Currently, we are comprised of six
upperclassmen attending Santa Clara University. During our years at school, we have taken
many classes with many different types of attendance tracking, giving us tremendous experience
of what works and what doesnt. The question now is why, and why now? We answer that
question with another one: Why hasnt our school adopted a professional, efficient, and easy-touse attendance system? We pride ourselves on being leading edge on all new technologies here in
the Silicon Valley, yet we are still leaving it up to the professors at this school to figure out their
own way to track attendance. There needs to be a better option for these professors, one that
aligns itself with the high-tech identity of the Silicon Valley. That is the need we strive to address
here at Present!, and we are ecstatic to present our solution to the world.

II.

Business Problem and Background


A. Problem

Anyone hoping to track audience attendance has faced the same headache for years. From
teachers to business professionals, this essential metric has been marred by crafty students and
employees alike who relish in circumventing the system. Professors in particular lack a standard,
reliable way of verifying student attendance. In the past, they have relied on roll call, sign-ins or
daily quizzes. Each of these solutions, however, are accompanied by huge inefficiencies. Roll
call takes valuable time away from class (and do not take tardiness into account), sign-ins can be
more than easily forged by friends of missing students, and quizzes require time and preparation
from the professor. Additionally, tallying up attendance takes time and is an imperfect process
that may inappropriately deduct points from a student. A perfect attendance system should
circumvent these problems; it should require little preparation from the professor, account for all
students who arrive to class during the time frame of the professors choosing, and uniquely
identify a student to decrease the chance of fraud. Additionally, once the attendance is collected,
it should take very little effort from the professor to aggregate. Further more, this attendance
system should be scalable so any professor in a university may adopt a standard system if he or
she chooses too. While there are many options for professors, no one solutions satiates all of
these points, until now. We would like to introduce Present!, the smartest attendance tracker on
the market.

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 4/29

B. Opportunity
Students need to understand that a college classroom is not like a film screening, a
sunset, or a meteor shower, all of which will proceed in exactly the same way, whether
they are present or not. In my class they are an integral part of the action, valued
participants who ask questions, contribute to discussions, and critically affect the
learning of others as well as their own. Even a lecturer is affected by her audience,
responding if she is skillful to smiles and looks of confusion, level of attention, and pace
(or absence) of note-taking. Questions often stimulate further questioning.
(excerpted from http://www.nea.org/home/41269.htm)
According to Nance Hahn, a professor from Syracuse, attendance is integral to the professor and
student alike and it would seem professors that track attendance most definitely agree. The actual
process of tracking who shows up, is not quite as simple as it seems, however. Every professor
has a different system to collect this information, and every university has a different attendance
policy. At both of these levels, attendance systems (roll call, sign-ins, ect), can be largely
inaccurate, an issue that defeat the purpose of gathering attendance in the first place. Some
universities, like Emerson University, have an institutional policy of dropping an entire letter
grade if a student misses more than two sessions, per class, per semester. It is very clear how
these non-standard and inaccurate attendance systems could have massive ramifications for
students.
C. Solution
To rectify this issue, at an individual and institutional level, an attendance system must be
scalable, simple and inexpensive. Present! an elegant solution that meets all these qualifications.
The sticker holds a students unique identifier are extremely inexpensive and can easily be
programmed and distributed by the professor or the university on the first day of class. Replacing
lost tags is just as easy and inexpensive. Additionally, Present! Is very user friendly for the
student and professor. Setup is easy and quick, professors will no longer need to prepare and
print attendance slips, create sign-ins or spend class time calling roll. Students need only to
remember their sticker, which, when attached to a student ID, will not interfere with the
functionality of the ID. Further more, eco-friendliness has been an initiative across the board for
many organizations. This paperless system not only saves trees, it eviscerates printing costs.
Together, these factors build a solution that is extremely scalable, extremely simple and
incredibly inexpensive.

C.1. How it Works

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 5/29

Present! is a fully integrated tracking system that relies on NFC technology to accurately
collect and aggregate attendance. Heres how it works: students will be given an NFC
sticker (or tag), each containing a unique identifier. Before class, the professor will be
required to plug in an NFC reader into any computers USB. Upon entering class,
students will tap their NFC tags on the reader. Once the cursor is active students can tap
in and their presence is documented. After the attendance session is complete, the
professor clicks submit and the web server transfers the data into an online database. The
reader will send the students unique information to a web-based server, which will
aggregate and produce the appropriate metrics in any time frame of the professors
choosing. Present! is simple, time-efficient and cost-effective.
D. Our Competition
Aside from wasting valuable class time, the
following traditional roll call systems elicit by
nature a multitude of problems:
Sign-in sheets and questionnaires have a high
tendency for fraud as two or more forms can
easily be submitted by one student. Attendance
questionnaires like the ones used by Professor
Brian Moon in Systems Programming, though
useful, require class time to be aside for a process
that has the potential to be automated.
Daily quizzes can easily catalyze a students shift
from being intrinsically motivated to extrinsically
motivated. If a student genuinely enjoys learning
the content, having frequent evaluations on the material may do more harm than good.
Additionally, quiz preparation takes lots of time and effort on behalf of the professor.
iClickers are perhaps the most interactive way to track attendance, as they allow students to
respond electronically to questions throughout the lecture. While it is engaging, the remotes are
relatively expensive ($41.00 in the SCU bookstore), require batteries, and have a time consuming
setup.

E. Business Case
We at Present! think that we have a very marketable and viable business plan which is practically
ready to go to market today. We believe that we have a very marketable business model because

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 6/29

Present! is an extremely inexpensive, eco-friendly, extremely scalable, and easy to use alternative
to properly keeping track of attendance. Present! is definitely a cost efficient alternative to
keeping track of attendance because the implementation only cost a total of $56.99. The only two
inherent costs are buying the NFC chips/reader and hosting a web server. Present! is definitely an
eco-friendly option to keeping track of attendance because it is paperless; everything is done on
the computer, which means no paper is beings used at all or being wasted. This paperless system
not only saves trees, it eviscerates printing costs. Present! is an extremely scalable attendance
solution because any industry or business today requires some sort of system to properly keep
track of attendance or who was there on a certain day. Present! is setup in a way where someone
who does not come from a technical background can easily pick up the NFC chips/reader and
naviagate to www.attend107.com and start using the system. The sticker that holds a students
unique identifier are extremely inexpensive and can easily programmed and distributed by the
professor or the university on the first day of class or on the first day of school. Replacing lost
tags is just as easy and inexpensive. Additionally, Present! Is very user friendly for the student
and professor. Setup is easy and quick, professors will no longer need to prepare and print
attendance slips, create sign-ins or spend class time calling roll. Students need only to remember
their sticker, which, when attached to a student ID, will not interfere with the functionality of the
ID.
We plan to implement our Present! NFC attendance tracking system into schools, business, or
clubs; really anywhere where attendance is an integral part to the experience at hand. Our plan to
monetize Present! is fairly simple and we think if this solution is marketed, it could potentially
get a decent amount of funding. The Present! Attendance System takes into account the strengths
and weaknesses of its competitors and provides the most seamless solution. The cost to produce
was relatively low, with the two significant expenses being the reader / RF chips ($44.99) and
web server ($12). A suggested retail cost of $99.99 would result in a $43 marginal profit.

III.

Technical Discussion
A. Hardware: NFC Reader

Early on in the design phase, our group determined an NFC attendance system would be very
useful, but questions remained on the finer details. We discussed exploiting the NFC capability
built in to modern smartphones (since the availability of the technology is sure to expand). The
idea was to have a single NFC card in the classroom which could be read by a smartphone. The
smartphone would transmit a student number, date, and class ID to a server. However, we axed
that idea as too potentially error prone (dead phones being the most basic of examples). Without
further thought, one hotkey later we were skimming Amazon for what might be available on the
market already. Thats when we discovered our <$50 solution to monitoring absenteeism. A
small group, GoToTags, was advertising an NFC reader with five included NFC tags for $44.99.
We quickly pulled the trigger after looking into the software included with purchase. The NFC

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 7/29

reader ended up being consistently reliable. Plus, its small, durable, convenient, and
inexpensive. The GoToTags reader was the perfect hardware component for us, and the tags
worked flawlessly.
A. Software Integrated
a. Windows NFC app
Hardware is useless when it doesnt have the ability to communicate. One of the boons with our
system was that we were able to devote resources to more crucial components because the
GoToTags group provides free software to use with their NFC readers. The software worked
really well, and we only needed to make a few modifications. We disabled "auto perform first
record action" under the Tags menu. Under Integration, we modified the settings to autopaste the
records text. We also had it automatically append a press of the enter key afterwards. Once
modified, the software will automatically paste a student name, student number, and hit enter
every time a new tag is touched to the reader. This app runs in the system tray silently and
without using many system resources. Its perfect for our application.
b. PHP
The bulk of the inner workings of the project is PHP. Its the language that we used to connect to
our mySQL database. PHP supports the integration of user account systems.* It provides the
ability for data input on Attend107.com, which is saved into arrays from which mySQL can
extract data. Its able to properly insert student names and their numbers into their respective
tables along with the days date. Finally, it calculates and displays attendance and absenteeism.
For the date picker on the site, we were able to source some simple code that was perfect for the
job.
*When passwords are stored, they are hashed using the MD5 algorithm before they are stored.
Storing passwords in plain text is a major security flaw, so we avoided it from the beginning.

c. HTML/CSS
It would be hard to make a website without using a bit of HTML/CSS. HTML/CSS were simply
used to display titles and headers and format the website. They didnt play an integral part in the
inner workings, just the faade. Particularly, the user account creation system and login page
relied on the language and style sheets.
d. SQL

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 8/29

mySQL is the end destination for the data input using PHP. It takes the student and attendance
data stored in arrays and associates various tables with each other to eliminate the infeasibility of
needing to keep redundant data for each new association. We used a few different tables to match
instructors, their students, and their students attendance. It stores accounts and hashed
passwords. mySQL is smart and is able to match one student record with multiple days of
attendance or with multiple instructors. This ensures we are HIGHLY scalable.
e. Web-based server
i.
1and1
Though we started using Apache/mySQL (facilitated by XAMPP), we decided it would be a bit
more of a realistic demo if we were to purchase access to a premium server. 1and1.com, while
not the best rated servers on the planet, was very affordable and perfect for our proof of concept.
We gave up some perks like root access compared to our abilities with XAMPP, but the cloudbased nature was a big enough perk to make up for it. Login information is included for your
testing--see final page.
B. How It Works

This is how we connected to the database. Before this code we set variables for username,
password, database, and hostname. Using those parameters we were able to connect our code to
our database on the web-based server.

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 9/29

This is our main section for the login feature. Upon a login request, the system will pull the
username and password from the mySQL database. The password that is requested is requested
using MD5 hashing. If the username and password are correct, the session is authorized and is
set.

This section of the code scans the input


from the inputbox at Attend107.com and
saves them into arrays so that they can
be inputted into the mySQL database.

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 10/29

Once the user hits submit, the data is inputted into the database using an insert statement only if
the first query comes back without a record of the input.

This is the PHP behind the datepicker. The user is able to select a start and end date to run a
query against. The script modifies the queries based upon the user input.

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 11/29

This is the main function behind our script. This code determines which students were present
and which ones were absent. Upon find the absent students, it will print the students name under
the date in which they were absent. If no students were absent on any given day, the script
shows that no students were missing

Since we already figured out how to show absent students, we decided to implement a
percentage system. This section of the code takes the number of attendances and divides it
against the total number of days. It then displays the percentages to the user.

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 12/29

This is signup code for Attend107.com. This is setting up the fields for the user to input. Once
the user fills in the fields, a request for signup is processed by php request statements. The PHP
on the backend of this form then inserts the information into the database.

The code above is the HTML for the date picker. It provides the user with calendar fields to
select the start date and end date of their choice.

This is the HTML for the input field. It allows the user to input the data from the NFC tags into
the input field. Then the user hits submit and the PHP inserts the data into the mySQL database.
C. Database Schema Description
As noted, the current iteration of the system uses three tables: student, attendance, and instructor.
A single student can be associated with many attendance records. An instructor is able to

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 13/29

associate with many different attendance records. Thus, many students can have different or the
same classes with different or the same professors.

See the more complex schema to see our vision for adding tables to facilitate multiple classes.

IV.

Future Developments

The future holds many opportunities for Present! There is a potential market in all industries that
require a tracking system for attendance. Right now, were poised to expand across higher
education with few additional modifications (namely, the class table). It would be trivial to add
CAPTCHA and email verification, and an export feature for systems like Camino. Before we are
capable of expanding into a business environment, our current system will have to undergo some
modifications. We will have to develop both a check in and check out feature that tracks not only
date but also time. Instead of absenteeism, we would have to adapt our code to show hours per
day or week depending on the managers choice. Looking further into the future, we are
planning to introduce our own application that we will be able to market to consumers. We
believe that a fully packaged system will have more appeal to businesses.
With our packaged system, we intend to roll out new features. We are developing a simple, clean
graphical user interface that will allow any user to learn how to use our software quickly. We
believe that an intuitive GUI is essential to adding value to our product. In addition, we plan to
allow the admin user, whether instructor or manager, to export the data into an excel file so that
they can manage the data. We also have to increase our current admin functionality. Taking our
current system, teachers will need to be able to monitor multiple classes.

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 14/29

To correct this, we have to add a class table. The instructor table will then be linked to the class
table and an associative table will be used to form a connection between student and their
classes. Once we have the structure, we can give the option to the instructor to switch between
classes and view the attendance data separately. The last feature we are working to develop is
additional tracking features. This is our long term goal. We want to allow our NFC technology
to allow the user to set what they want to track and what information they want tracked. We
intend to give this functionality through our app. The user will be able to program our tags
giving them the freedom to choose their functionality.

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 15/29

The goal is to make our application compatible with local servers. Security is also a concern.
Our code implements the MD5 hashing command. This command is easily susceptible to brute
force. Almost any targeted attack can reverse the algorithm. In order to keep our information
secure, we will have to upgrade our security to at least a SHA-2 hashing algorithm. This hashing
method doubles our output size and and security bits. Unfortunately, the increase of security will
decrease the systems speed. With the added functionality, compatibility, and security we hope
that our packaged software can lead the tracking market.

V. Reference Citations
Collaborative Partner and Teacher: Dane Iracleous (Cited in Appendices. Contact
information is available upon request.)
Date Picker:
http://jqueryui.com/datepicker/
General PHP references:
http://php.net/manual/en/function.explode.php
http://php.net/manual/en/function.implode.php
http://php.net/manual/en/function.md5.php
http://php.net/manual/en/function.die.php
http://php.net/manual/en/function.unset.php
http://php.net/manual/en/function.isset.php
http://php.net/manual/en/language.types.array.php

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 16/29

VI.

Appendices
GoToTags - Windows NFC App

https://gototags.com/products/windows-app/

Attendance, Instructor, and Student tables (mySQL)

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 17/29

Source Code: index.php


<?PHP
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Attend107</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet"
href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jqueryui.min.js"></script>
<style type="text/css">
a{
color:#3D7A99;
}
fieldset {
border-style:solid;
border-color:#999;
border-width:1px;
}
.maintitle {
padding-top:0px;
margin-top:0px;
margin-bottom:30px;
font-size:40px;
color:#66CCFF;
text-shadow:2px 2px 1px rgba(0, 0, 0, 0.7);
}
.container {
background-color:#fff;
width:960px;

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 18/29

margin-left:auto;
margin-right:auto;
padding:20px;
border-radius:10px;
border-style:solid;
border-color:#ccc;
border-width:1px;
}
label {
display:inline-block;
width:200px;
}
.row {
margin:10px;
}
body {
font-family:Arial;
color:#333;
background-color:#eee;
}
.input-data {
width:500px;
height:200px;
}
</style>
<script>
//date picker
//sourced from: http://jqueryui.com/datepicker/
$(function() {
$(".datepicker").datepicker();
});
</script>
</head>
<body>
<div class="container">
<h1 class="maintitle">Attend 107 Project</h1>
<?php
// First, we set variables associated with a specific database on a remote server.
$host_name = "db553345207.db.1and1.com";
$database = "db553345207";
$user_name = "dbo553345207";
$password = "m00nsover107";

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 19/29

// Using our variables, we connect to that database.


$connect = mysqli_connect($host_name, $user_name, $password, $database);
// Should there be a failure (like should the server be down), we'll see an error message.
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$db = new mysqli('db553345207.db.1and1.com', 'dbo553345207', 'm00nsover107',
'db553345207');
if($db->connect_errno > 0) {
die('unable to connect');
}
//logout request
if(isset($_REQUEST['logout'])) {
unset($_SESSION['username']);
unset($_SESSION['authed']);
session_unset();
session_destroy();
} else if(isset($_REQUEST['signup_submit'])) { //signup request
$username = $_REQUEST['username'];
if($_REQUEST['password']!=$_REQUEST['password_confirm']) { //error
check for pass input
$signup_error = "passwords not the same";
} else {
$password = $_REQUEST['password'];
$q = "SELECT * FROM instructor WHERE username='".
$username."';";
$res = $db->query($q);
//case user already exists
if($res->num_rows>0) {
$signup_error = "User already exists";
} else {
//if user does not exist, insert user and pass into database using MD5
password hashing
$q = "INSERT INTO instructor (username, password) VALUES
('".$username."', '".md5($password)."');";
$res = $db->query($q);
//check if user and pass were created successfully

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 20/29

if($res) {
$q = "SELECT * FROM instructor WHERE
username='".$username."' AND password='".md5($password)."';";
$res = $db->query($q);
if($res) {
$row = mysqli_fetch_assoc($res);
$_SESSION['username'] = $row['username'];
$_SESSION['authed'] = $row['instructor_id'];
}
} else {
$signup_error = "Error";
}
}
}
} else if(isset($_REQUEST['login_submit'])) { //login request
$username = $_REQUEST['username'];
$password = $_REQUEST['password'];
//get password from database using MD5 password hashing
$q = "SELECT * FROM instructor WHERE username='".$username."' AND
password='".md5($password)."';";
$res = $db->query($q);
//check to see if inputted password is correct
if($res->num_rows > 0) {
$row = mysqli_fetch_assoc($res);
$_SESSION['username'] = $row['username'];
$_SESSION['authed'] = $row['instructor_id'];
} else {
$signup_error = "Username/password combo incorrect";
}
}
if(isset($_SESSION['authed']) && $_SESSION['authed'] == true) {
if(isset($_SESSION['username'])) {
echo "Welcome back, ".$_SESSION['username']."!<br/><br/>";
}
// Collaborative Partner: Dane Iracleous
if(isset($_REQUEST['data'])) {
echo "<h1>Importing data...</h1>";
$content = $_REQUEST['data'];
$temp_a = explode("\r\n", $content);
$a = $temp_a;

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 21/29

$d = date("Y-m-d");
$i = 0;
$fa = array();
while($i+1 < sizeof($a)) {
$name = $a[$i];
$code = $a[$i+1];
$t = array(
'name' => $name,
'code' => $code
);
$fa[] = $t;
$i+=2;
}
// Attendance data is inserted into the mySQL database from the input form
//screenshot
foreach($fa as $f) {
echo "<div style='background-color:#eee; padding:10px;
margin:10px;'>";
echo "Importing student of name '".$f['name']."' and code '".
$f['code']."'<br/>...";
$q = "SELECT * FROM student WHERE code='".$f['code']."';";
$res = $db->query($q);
if($res->num_rows==0) {
echo "does not exist - creating new student record.<br/>";
$q = "INSERT INTO student (code, name) VALUES ('".
$f['code']."', '".$f['name']."');";
$res = $db->query($q);
$q = "SELECT * FROM student WHERE code='".$f['code']."';";
$res = $db->query($q);
echo "...success!";
}
$row = $res->fetch_assoc();
echo "<br/>Inserting new record for the day...";
$q = "SELECT * FROM attendance WHERE instructor_id='".
$_SESSION['authed']."' AND student_id='".$row['student_id']."' AND date='".$d."';";
$fres = $db->query($q);
if($fres->num_rows==0) {
$q = "INSERT INTO attendance (instructor_id, student_id, date)
VALUES ('".$_SESSION['authed']."', '".$row['student_id']."', '".$d."');";

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 22/29

$fres = $db->query($q);
}
if(!$fres) {
$error = true;
echo "...failed!";
} else {
echo "...success!";
}
echo "</div>";
}
echo "<br/><br/>...done!<br/><br/>";
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<h2>Paste cursor in input field before scanning</h2>
<textarea name="data" class="input-data"></textarea>
<br/>
<input type="submit" name="submit" />
</form>
<?php
//date picker
//sourced from: http://jqueryui.com/datepicker/
//allows instructor to modify date range they want to check for attendance
if(isset($_REQUEST['start'])) {
$_REQUEST['start'] = date("Y-m-d", strtotime($_REQUEST['start']));
}
if(isset($_REQUEST['end'])) {
$_REQUEST['end'] = date("Y-m-d", strtotime($_REQUEST['end']));
}
$modify_a = array();
$modify_a[] = "WHERE instructor_id='".$_SESSION['authed']."'";
if(isset($_REQUEST['start'])) {
$modify_a[] = "a.date >= '".$_REQUEST['start']."'";
$modify_start = $_REQUEST['start'];
} else {
$modify_start = "";
}
if(isset($_REQUEST['end'])) {
$modify_a[] = "a.date <= '".$_REQUEST['end']."'";
$modify_end = $_REQUEST['end'];
} else {
$modify_end = "";
}

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 23/29

if(sizeof($modify_a) > 0) {
$modify = implode(" AND ", $modify_a);
}
//author: us
//queries based on date range
$q = "SELECT * FROM attendance a LEFT JOIN student s ON a.student_id =
s.student_id ".$modify." ORDER BY a.date;";
$res = $db->query($q);
$q = "SELECT * FROM student WHERE student_id IN (SELECT student_id
FROM attendance WHERE instructor_id='".$_SESSION['authed']."');";
$res1 = $db->query($q);
$students = array();
while($row = $res1->fetch_assoc()) {
$students[] = $row['name'];
}
//print_r($students);
?>
<h1>View Existing Data</h1>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET">
<fieldset><legend>Select Date Range</legend>
<input type="text" class="datepicker" value="<?php echo
$modify_start; ?>" name="start" /> to
<input type="text" class="datepicker" value="<?php echo $modify_end;
?>" name="end" />
<input type="submit" value="Go" />
</fieldset>
</form>
<h2>Absent Students by Day</h2>
<?php
// Collaborative Partner: Dane Iracleous, lines 291 -340
$days = array();
$student_t = array();
while($row = $res->fetch_assoc()) {
if(!isset($days[$row['date']])) {
$days[$row['date']] = array();
}
if(!isset($student_t[$row['name']])) {
$student_t[$row['name']] = 0;
}
$temp = array();
$temp['student_id'] = $row['student_id'];
$temp['attendance_id'] = $row['attendance_id'];
$temp['code'] = $row['code'];

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 24/29

$temp['name'] = $row['name'];
$days[$row['date']][] = $temp;
$student_t[$row['name']]++;
}
//screenshot (display of absent students on website)
if(sizeof($days)==0) {
//error check for days
echo "No data yet!";
} else {
//provide section break by day.
foreach($days as $k => $v) {
echo "<h3>Absent students on ".$k."</h3>";
//find absent students and print their name
$attendees = array();
foreach($v as $k1 => $v1) {
$attendees[] = $v1['name'];
}
$i = 0;
foreach($students as $k1 => $v1) {
if(!in_array($v1, $attendees)) {
if($v1!="") {
echo $v1."<br/>";
$i++;
}
} else {
}
}
//if everyone is in attendance print no missing students
if($i==0) {
echo "No missing students on this day!";
}
}
}
?>
<h2>Students by Absenteeism</h2>
<?php
//calculates student's attendance percentage
$highest = max($student_t);
//if the student has no data, echo error
if(sizeof($student_t)==0) {
echo "No data yet!";
} else {
//for each student with data, find # of present / highest days

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 25/29

foreach($student_t as $k => $v) {


echo "<b>".$k."</b>: ".($v / $highest * 100)."% attendance (".($highest
- $v)." times absent)<br/>";
}
}
?>
<br/><br/><br/>
<a href="<?php echo $_SERVER['PHP_SELF']; ?>?logout=1">Log Out</a>
<?php
} else if(isset($_REQUEST['signup'])) {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?signup=1" method="post">
<?php
if(isset($signup_error)) {
echo $signup_error."<br/><br/>";
}
?>
<fieldset><legend>Instructor Signup</legend>
<div class="row">
<label>Username</label> <input type="text" name="username" />
</div>
<div class="row">
<label>Password</label> <input type="password" name="password" />
</div>
<div class="row">
<label>Re-enter password</label> <input type="password" name="password_confirm"
/>
</div>
<div class="row">
<label></label><input type="submit" name="signup_submit" value="Sign Up" />
</div>
</fieldset>
</form>
<br/><br/>
<a href="<?php echo $_SERVER['PHP_SELF']; ?>">Back to login</a>
<?php
} else {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<?php
if(isset($login_error)) {
echo $login_error."<br/><br/>";
}
?>
<fieldset><legend>Instructor Login</legend>

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 26/29

<div class="row">
<label>Username</label> <input type="text" name="username" />
</div>
<div class="row">
<label>Password</label> <input type="password" name="password" />
</div>
<div class="row">
<label></label><input type="submit" name="login_submit" value="Log In" />
</div>
</fieldset>
</form>
<br/><br/>
Don't have an account? <a href="<?php echo $_SERVER['PHP_SELF']; ?>?signup=1">Click
here to signup</a>
<?php
}
?>
</div>
</body>
</html>

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 27/29

mySQL Database Dump


-- phpMyAdmin SQL Dump
-- version 4.1.14.6
-- http://www.phpmyadmin.net
--- Host: db553345207.db.1and1.com
-- Generation Time: Dec 03, 2014 at 11:02 PM
-- Server version: 5.1.73-log
-- PHP Version: 5.4.35-0+deb7u2
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS
*/;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION
*/;
/*!40101 SET NAMES utf8 */;
--- Database: `db553345207`
--- ---------------------------------------------------------- Table structure for table `attendance`
-CREATE TABLE IF NOT EXISTS `attendance` (
`attendence_id` int(11) NOT NULL AUTO_INCREMENT,
`instructor_id` int(11) NOT NULL,
`student_id` int(11) NOT NULL,
`date` date NOT NULL,
PRIMARY KEY (`attendence_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=16 ;
--- Dumping data for table `attendance`
-INSERT INTO `attendance` (`attendence_id`, `instructor_id`, `student_id`, `date`) VALUES
(1, 4, 1, '2014-11-27'),

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 28/29

(2, 4, 2, '2014-11-27'),
(3, 4, 3, '2014-11-27'),
(4, 4, 1, '2014-12-02'),
(5, 4, 4, '2014-12-02'),
(6, 4, 2, '2014-12-02'),
(7, 4, 5, '2014-12-02'),
(8, 4, 3, '2014-12-02'),
(9, 6, 1, '2014-12-02'),
(10, 6, 2, '2014-12-02'),
(11, 6, 3, '2014-12-02'),
(12, 6, 4, '2014-12-02'),
(13, 6, 5, '2014-12-02'),
(14, 6, 1, '2014-12-03'),
(15, 6, 2, '2014-12-03');
-- ---------------------------------------------------------- Table structure for table `instructor`
-CREATE TABLE IF NOT EXISTS `instructor` (
`instructor_id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) COLLATE latin1_general_ci NOT NULL,
`password` varchar(1000) COLLATE latin1_general_ci NOT NULL,
PRIMARY KEY (`instructor_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci
AUTO_INCREMENT=8 ;
--- Dumping data for table `instructor`
-INSERT INTO `instructor` (`instructor_id`, `username`, `password`) VALUES
(1, '!', '9033e0e305f247c0c3c80d0c7848c8b3'),
(2, 'yes', 'a6105c0a611b41b08f1209506350279e'),
(3, 'epic', '020be165a3e587d7c83cb489c3ec9923'),
(4, 'admn', '854f36c709b662f53c00ea2c11a40f7a'),
(5, 'testuser', '5d9c68c6c50ed3d02a2fcf54f63993b6'),
(6, 'sean', '9b938710211168f2902f9ed4357cd05c'),
(7, 'josh', '800d4d1009b8b505eee34576b20b8a7c');
-- ---------------------------------------------------------- Table structure for table `student`

Brian Grossman, Jacob Matta, Sean Meagher, Josh Mitchell, Josh Taylor, Lilly Wilhelms
NFC Project Report - OMIS 107, Fall 2014 - Page 29/29

-CREATE TABLE IF NOT EXISTS `student` (


`student_id` int(11) NOT NULL AUTO_INCREMENT,
`code` varchar(255) NOT NULL,
`name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`student_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;
--- Dumping data for table `student`
-INSERT INTO `student` (`student_id`, `code`, `name`) VALUES
(1, '1', 'Josh'),
(2, '2', 'Lilly'),
(3, '3', 'JoshT'),
(4, '4', 'Brian'),
(5, '5', 'Sean');
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

Attend107.com - Access Information


Control Panel: https://www.1and1.com/login
U/N: attend107.com
P/W: m00nsover107
SSH Login (PuTTY/Terminal):
Host: s551878474.onlinehome.us
U/N: u79039009
P/W: m00nsover107

Vous aimerez peut-être aussi