DEV Community

Aashutosh Rathi
Aashutosh Rathi

Posted on

Labper: Lab Performance Evaluator

About Labper

It was around Sept 2018 (Start of 5th semester of my Engineering), we have a course named Software Engineering (CS-302), in which we learn about different Software Development Life Cycle (SDLCs) and best practices.

We also have to submit a project at the end of course with tons of documentation on how we created that project.
On top of that, the project you create should be of value.

A little backstory

When thinking about problem statements to pick with my team, I remembered one of my friends from IITK telling me about Prutor, a software to manage labs session and much more.
We thought about our current lab evaluation scenario, we found out a bunch of issues in the process.

Let me create a list of issues for a quick overview:

  • My institute had only 2 branches (as of 2020): CS & IT, hence most of the assignment involves some kind of code.
  • The current process was to write, compile and test code on Lab Computers and then submit the zip for Code with Documentation (which has test cases you ran) and then upload it to Google Classroom.
  • The Lab Computers limit the kind of compilers (languages) we can use, plus the checking of the assignment was with pretty random test cases, hence most of the codes missing corner cases might pass the evaluation.

We decided to move on with this problem statement for our institute and started working on planning the MVP.
We spent around 15-20 days on tons of documentation (~20 includes Database Design and stuff) created (as part of course work) and then we had 15 days to code out the MVP.

Implementation

We started executing our plans from the very beginning of the project, the landing page shouldn't be misleading and hence we simply added only the Sign In Button.

Whitelisting Domains and Validating Users

Now we needed to whitelist few domains for OAuth and we started on deciding on how we can set permissions (user categorization) on login itself.

Then we came up with a solution using the email address pattern that we have in our institute, which is:

  • For students, it will be all digits (Year [4 digits], Branch [2 digits], RollNumber[3 digits]). For example: If your batch started in 2016 and your branch is CS (51) and your roll number is 1, then your email will be 201651001@iiitvadodara.ac.in
  • For Professor/Staff, it will be all alphabets with some special characters. Ex: heet.sankesara@iiitvadodara.ac.in.

Hence we clearly drew a line on the login itself for all kind of things are to happen on the homepage.

We differentiated it using this code:

@login_required
def home(request):
    user = request.user
    month = datetime.date.today().month
    year = datetime.date.today().year

    # Session Type was an ENUM(w: Winter, a: Autumn)
    session_type = 'a' if month > 6 else 'a'

    session, create = Session.objects.get_or_create(year=year, type=session_type)
    target = Profile.objects.get(user=user)
    is_teacher = not target.user.username.isdigit()

    if is_teacher:
        teacher, create = Teacher.objects.get_or_create(profile=target)
        courses = teacher.course.all() # Courses opted for being taught
    else:
        # First 4 digits of username
        batch = int(target.roll_no[:4]) + 4

        # Get the 5th and 6th digit of username
        branch = target.roll_no[4:6]

        student, create = Student.objects.get_or_create(
            profile=target, batch=batch, branch=branch)

        # Courses for the batch of user
        user_courses = Course.objects.filter(target_batch=batch)
        for c in user_courses:
            student.course.add(c)
        courses = student.course.all()

    context = {
        'courses': courses,
        'upgd': is_teacher,
        'session': session,
    }
    if student:
        context['student'] = student

    return render(request, 'landing/home.html', context=context)

The above home is function is pretty much what our home function looks like, but we also have to cover the case where the user is TA (Teaching Assitant).
So, the problem one is over, now the user is inside the matrix and is identified by Labper.
We also created a small pipeline along with social-auth, to get the user's profile picture from Google.
The pipeline's code is something like this and it is executed as part of the login

def get_profile(backend, user, response, details, *args, **kwargs):
    url = None
    profile = Profile.objects.get_or_create(user=user)[0]
    if backend.name == "google-oauth2":
        if response['picture']:
            url = response['picture']
    profile.avatar = url
    profile.save()

Now we have fully functional Auth and stuff.
Next comes the Course, Lab Creation Part

Course, Lab Creation, and Notifications

Now, since for testing we needed an email address which is all made of alphabets, as a student we didn't have one, but we had the email of codingclub@iiitvadodara.ac.in which acted as a professor for our whole testing time.

  • We created a bunch of more tables Lab, Assignment, Session, etc.
  • The create Course, create Lab, promote to TA, invite to Course features were given to Professor. Also, the ability to view all submissions for course and mark them.
  • As soon as a student logs in, they enroll for all the courses made for their batches and can start submitting lab assignments directly.

For notifications, we used Django's core send_mail functionality. So if you are enrolled on Labper and some new course is added for your batch, you will receive an email for the same.

Solving development environment issue

One of the MSP of Labper, as we mentioned in all the docs, was that it will remove dependencies from Lab Computers.

Now we needed to add an IDE to the platform, we started looking for what we can do in a day or two (certainly we can't make an online IDE of our own).

Hence we took a trial for SPOJ's IDE widget and added that to our platform so that students can Code, Compile and Test the code there itself, in most of the languages.

Also, we added a plugin with it named Test Case Generator, which is a small script that lets you generate random test cases for the correct code. So that Professors can test the code on multiple random test cases and the scale is not biased anymore.

Demo Link

You can tryout Labper here:
https://labper.herokuapp.com/ (Currently sign in only works for @iiitvadodara.ac.in Accounts), you can fork it and host your own with different domain whitelisting.

Link to Code

The repo was last updated around the submission of the project itself and requires maintenance. New maintainers will soon be assigned.

GitHub logo aashutoshrathi / labper

Smart Lab Management System (built using Django)

Labper

Lab performance evaluator

How to Use

To use this project, follow these steps:

  • Make a .env file having same structure as .env.sample
  • Get your G_KEY and G_SKEY by creating a project on Google Dev Console
  • Add you client key to G_KEY and client secret key to G_SKEY.
  • Fill up the following entries in .env.
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_HOST_USER=YourEmail
EMAIL_HOST_PASSWORD=YourPassword
  • You have to enable access by insecure apps in your respective email serivce provider.

  • Install requirements:

pip install -r requirements.txt
  • Makemigrations and migrate the Database to populate the table
python manage.py makemigrations && python manage.py migrate
  • Create superuser
python manage.py createsuperuser
  • Run server
python manage.py runserver

Deployment to Pythonanywhere

  • Take Python 3.7 app with Django 2.0.8.

  • Clone the repository using:

      git clone https://github.com/aashutoshrathi/labper.git brutus 
  • Go into project directory using:

    cd brutus
  • Install requirements:

      pip3 install --user -r requirements.txt
  • Makemigrations and collectstatic using:

      python3 manage.py makemigrations landing
      python3 manage.py migrate
      pytohn3

How we built it 🛠

At that point in time, the members of our team were pretty proficient in Django and had some experience with Javascript EcoSystem too.

We used:

  • Django (For almost everything)
  • UIKit as CSS Library
  • Javascript (Of course everything on the web is incomplete without it)
  • PostgreSQL as Primary Database
  • Google OAuth (for whitelisted domains)

We used Heroku for DB Instance as well as our own deployment and also got some credits using GitHub Student Pack

Future Work

There is plenty of improvements that can be made to Labper in its current state.

  • We need to renew SPOJ IDE Widget's subscription.
  • We can add Plagiarism Detection features on the platform
  • The auto-scoring of submission based on given test cases can be done using a new service.

Additional Thoughts

I normally struggle with writing blogs, but somehow the Labper story was handy for me to write, because of the memories created and lessons learned while implementing the project.

I hope the experience was helpful to you. If your institute faces a similar kind of issue, feel free to fork Labper and customize and host it as your own.

Top comments (0)