I Was Here – PHP Student Attendance Management System

I Was Here is a simple, free, and open-source PHP Student Attendance Management System. Not the best in the world, but it will help small schools to get started quickly without all the hassle.

 

TABLE OF CONTENTS

Download & Notes How To Use Quick Reference
How To Develop Common Problems

 

 

DOWNLOAD & NOTES

First, here are the download links and a quick “setup guide” for the impatient folks who don’t have the patience to read through everything.

 

REQUIREMENTS

  • Apache Mod Rewrite
  • PHP PDO Extension
  • Best to have at least PHP 7.4
  • “Grade A” browser

I-Was-Here has not been extensively tested, but it is developed and works on a WAMP8 (Windows Apache MySQL PHP 8) server.

 

INSTALLATION

Just access your website and walk through the installer.

 

LICENSE & DOWNLOAD

I-Was-Here is released under the MIT License. You are free to use it for your own personal and commercial projects, modify it as you see fit. On the condition that there the software is provided “as-is”. There are no warranties provided and “no strings attached”. Code Boxx and the authors are not liable for any claims, damages, or liabilities.

Download I-Was-Here | GitHub | SourceForge

 

 

HOW TO USE

So far so good? Let us now go through a quick crash course on how to use I Was Here.

 

STEP 1) REGISTER TEACHERS & STUDENTS

1A) ONE-BY-ONE

Access the “Users” tab. Simply click on the “Add” button to create a new user.

 

1B) IMPORT CSV

Of course, it will be a pain to do that for hundreds of teachers and students, so use the import feature to quickly add/update users. Just create a CSV file with 4 columns – Name, email, role, password. The role must be Admin, Teacher, Student, or Inactive.

 

STEP 2) REGISTER COURSES

Next, register your available courses under the “Courses” tab.

 

 

STEP 3) ASSIGN STUDENTS TO COURSES

3A) ONE-BY-ONE

With that, we can now assign teachers and students to their respective courses. The painful way is to assign the users one by one with their email.

 

3B) IMPORT CSV

The smarter way is to create a single-column CSV file with the email and import it.

 

STEP 4) REGISTER CLASSES

Now that all the necessary data is in, register the classes.

 

STEP 5) TAKE ATTENDANCE

Lastly, teachers only need to log in and select the appropriate class in the portal – Take the attendance.

 

 

QUICK REFERENCE

This section is for the developers, a quick walkthrough of the general system structures.

 

FOLDER STRUCTURE

  • api/ The API endpoint.
  • assets/ Public images, Javascript, CSS, etc…
  • lib/ Core engine and library files.
  • pages/ HTML pages.

Yes, there are only 4 folders in the entire system.

 

DATABASE TABLES

users – The teachers and students.
Field Description
user_id The user ID, primary key, auto-increment.
user_name Name of the user.
user_email Email of the user, unique and does not allow duplicates.
user_role Admin, Teacher, Student, Inactive.
user_password Account password.
courses – The available course.
Field Description
course_id Cours ID, primary key and auto-increment.
course_code The course code, unique.
course_name Name of the course.
course_desc A short description of the course.
course_start Course start date.
course_end Course end date.
courses_users – Which users are enrolled in which courses.
Field Description
course_id The course id, primary key.
user_id The user ID, primary key.
classes – Classes conducted.
Field Description
class_id The class ID, primary key, auto-increment.
user_id User ID, teacher-in-charge.
couse_id Course ID.
class_date Date and time of the class.
class_desc Short description of the class.
attendance – Attendance records.
Field Description
class_id The class ID, primary key.
user_id The user ID, primary key.
couse_id Course ID.
sign_date Timestamp, when the attendance is taken.

 

 

THE FRAMEWORKS

I Was Here is built with Bootstrap and Core Boxx. Believe it or not, the initial version is built within 48 man-hours using:

Go ahead and check those out if you want… The other “pre-developed” modules of Core Boxx should also snap right in.

 

DEVELOPING “I WAS HERE”

As simple as it may be, going through the entire system is still going to take some time. So instead of “explaining line-by-line”, here is a condensed version of “how to quickly customize and upgrade”.

 

STEP 1) CREATE/MODIFY DATABASE TABLES

Add your new tables or views, modify the existing ones.

 

STEP 2) ADD/UPDATE SYSTEM MODULE

lib/LIB-Report.php
class Report extends Core {
  function getStudentAttend ($id) {
    return $this->DB->fetchAll(
      "SELECT * FROM `attendence` WHERE `user_id`=? ORDER BY `sign_date` DESC",
      [$id]
    );
  }
}

To add a new module, create lib/LIB-Module.php. Define class Module extends Core, and add functions inside. In this example, we add a new report module – lib/LIB-Report.php and class Report extends Core.

That’s all. This new module can now be loaded via $_CORE->load("Report") and the function can be accessed via $_CORE->Report->getStudentAttend().

 

STEP 3) ADD/UPDATE API ENDPOINT (OPTIONAL)

api/API-Report.php
// (A) MUST BE SIGNED IN
if ($_USER===false || ($_USER["user_role"]!="A" && $_USER["user_role"]!="T")) {
  $_CORE->respond("E", "No permission or session expired", null, null, 403);
}

switch ($_REQ) {
  // (B) INVALID REQUEST
  default:
    $_CORE->respond(0, "Invalid request", null, null, 400);
    break;
 
  // (B) GET STUDENT ATTENDANCE
  case "getStudentAttend":
    $_CORE->autoAPI("Reports", "getStudentAttend");
    break;
}}

Create api/API-Module.php. For this example, send $_POST["id"]=123 to http://site.com/Report/getStudentAttend/ to get the student report – The API will reply with a JSON encoded string.

 

STEP 4) ADD/UPDATE HTML CSS JAVASCRIPT

  • Add your new pages in pages/.
    • For admin pages, add pages/APAGE-name.php.
    • For teacher pages, add pages/TPAGE-name.php.
    • For student pages, add pages/SPAGE-name.php.
    • For example, pages/APAGE-report.php can only be accessed by administrators from http://site.com/report.

That’s about it. Just reverse engineer and copy from the existing libraries, API, and pages… You will see the development pattern here.

 

COMMON PROBLEMS & FIXING THEM

I-Was-Here is “not working”? Here are a few of the common problems and how to “fix” them.

 

I FORGOT THE PASSWORD OR DELETED ALL ADMIN ACCOUNTS

recover.php
require "lib/GO.php";
$_CORE->load("Users");
$_CORE->Users->save("NAME", "EMAIL", "A", "PASSWORD", OPTIONAL-USER-ID);

Just create an “account recovery” script to create a new account (or update an existing one). Run and delete this afterward.

 

MIGRATED TO A NEW DOMAIN

  • Simply update URL_BASE in lib/GO.php.
  • Update the path in /.htaccess and /api/.htaccess if necessary.
  • Clear the browser cache to prevent irritating cache redirects.

 

MANUAL INSTALLATION

  • Create a database and import lib/i-was-here.sql.
  • Rename lib/GO.foo to lib/GO.php.
  • Open lib/GO.php, update the settings to your own.
    • (A2) The host settings.
    • (A3) Database settings.
    • (A4) If you want to develop mobile apps, consider enabling CORS.
    • (A6) Generate your own secret key, set the issuer to your domain or company name.
  • You will need to manually create /.htaccess and /api/.htaccess. Open index.php – Check out (D7) and (D8).
  • Delete the installer script index.php… Or just move it somewhere else.
  • Rename index.foo to index.php.
  • Create your own admin user, see “forgot password” above.

 

NOT WORKING. DON’T KNOW WHY.

Open the developer’s console, reload the page and see the error message.

How To Debug Javascript – A Very Simple Guide

How to Debug PHP Code – A Very Simple Guide

6 thoughts on “I Was Here – PHP Student Attendance Management System”

  1. Michele Fioretti

    Helllo , I have error 404 only on export attendance as csv. The remain function already works. Can yo have suggestions ? Thanks in advances.
    Can provide me example api call for register attendance of a student ? Thanks in advances.

    1. 1) Not getting 404 on my test server. The export CSV points to http://YOUR-SITE.COM/admin/export-attend and resolves to pages/ADMIN-export-attend.php as intended.
      2) Page updated, see reference above.

  2. Hi, when I run Iwashere with php -S 127.0.0.1:8000 it works fine but as soon as I upload it redirects to localhost/login and I get a 404 message. I am using 18.04 php ver 7.2.24 Apache2 ver 2.4.29. I cleared the.htaccess file and it didn’t work.

Leave a Comment

Your email address will not be published. Required fields are marked *