I Was Here – PHP Student Attendance System (Free Open Source)

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 MYSQL PDO Extension
  • Best to have at least PHP 8.0
  • “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 index.php in your browser 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) ADDING USERS

Access the “Users” tab. Simply click on the “Add” or “Import” button to create new users.

 

1B) IMPORTING USERS

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) ADDING STUDENTS

Once again, you can either add students into a course one-by-one or import them.

 

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.
password_reset – Password Reset Requests
Field Description
user_id The user ID, primary and foreign key.
reset_hash Random security hash.
reset_time The time when the request is made.

 

 

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) ADMIN ONLY
if (!isset($_SESS["user"]) || $_SESS["user"]["user_role"]!="A") {
  $_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->autoGETAPI("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/ADMIN-name.php.
    • For teacher pages, add pages/TEACHER-name.php.
    • For student pages, add pages/STUDENT-name.php.
    • For example, pages/ADMIN-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/CORE-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 HOST_BASE in lib/CORE-config.php.
  • Run $_CORE->Route->init() to regenerate the .htaccess and api/.htaccess files.
  • Clear the browser cache to prevent irritating cache redirects.

 

UPGRADING

  • If your existing copy has an options table – Just override all the files and access index.php. The installer will take care of database updates (if any).
  • If not – Manually import the options table from SQL-iwashere.sql, create a IWN_VER entry with a value of 0 and group 0. Thereafter, just copy the new files and let the installer do the magic.

 

MANUAL INSTALLATION

  • Create a database and import lib/SQL-iwashere.sql.
  • Open lib/CORE-config.php, update the settings to your own.
    • The host settings.
    • Database settings.
    • If you want to develop mobile apps, consider enabling CORS.
    • Generate your own JWT secret key, set the issuer to your domain or company name.
    • Set the email “sent from”.
  • Run $_CORE->Route->init() to create .htaccess and api/.htaccess.
  • Create your own admin user. See “forgot password” above.
  • Rename lib/INSTALL-index.foo to index.php.

 

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

10 thoughts on “I Was Here – PHP Student Attendance System (Free Open Source)”

  1. can you help me to send sms or emails to the absents?
    If we have the phone #, email, and status of the attendance, this shouldn’t be a problem, right?

  2. its really great work and a very good job
    thanks a lot

    but I face a problem
    it show a massige
    ” Unable to create database – SQLSTATE[HY000]: General error: 1007 Can’t create database ‘iwashere’; database exists”
    please guide me
    thanks again

    1. If it is a new installation, just delete the database and reinstall. Also, redownload the latest build. It should be easier for updates in the future.

  3. 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.

  4. 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.