How would you design this?

teammatt3's picture

He has: 2,102 posts

Joined: Sep 2003

You're writing an application that manages online courses. A course is completed in many different ways. A user must do one, or more of the follow to complete the course:

  • spend x amount of hours in the course
  • take a test, and pass the test
  • take all the lessons in a course
  • etc

When a course is completed, some event needs to happen. The event depends on the course, of course Smiling. One or more of the following may need to happen:

  • A custom certificate is created for the user
  • An organization is alerted via email, HTTP callback, or something else
  • some other requirement that I don't know about yet

How would you design an application like this? Is there a design pattern I can use to eliminate redundant code? Any thoughts?

EDIT: I should add that many of the courses are almost identical with their requirements, but some are completely unique, and there are a lot of courses, upwards of 50.

decibel.places's picture

He has: 1,494 posts

Joined: Jun 2008

Is there any LMS/SCORM solution that does this? (there are some open-source GPL ones)

I imagine your db could have a table for each course with a row for each user that has activity for that course, when a user has activity for that course the appropriate data would be entered in the column (test results, cumulative hours, # of lessons completed)

when user completes a task, scan the corresponding table for "completeness"

I could also imagine building this with Drupal Rules (Workflow-ng in D5)

greg's picture

He has: 1,581 posts

Joined: Nov 2005

teammatt3 wrote:
You're writing an application that manages online courses
So is that an offline app (for windows) that accesses online data? As I'm sure you don't need advice on how to go about building a website for this...?

teammatt3's picture

He has: 2,102 posts

Joined: Sep 2003

I'm talking about the more abstract program design, not really specifics.

I asked this question on another forum, and someone suggested creating a course object, that accepts two other objects, a requirements object, and a completed actions object.

The requirements class is simply a list of objects that implement an interface that has one method, isMetBy(), which determines if that course has met that specific requirement. -- That's the kind of advice I'm after.

This application is already running, and has been for two years, but it's a nightmare for me to maintain, so I would like to rebuild it using a more intelligent technique.

We don't talk much about program design on the forum, but I still wanted to ask here.

They have: 121 posts

Joined: Dec 2008

Interesting...

Maintaining, and then executing a list of child objects that implement a 'pre-requisite' interface sounds like a logical approach.

My brain is mush at the moment... let me think about it, would love to chat this through.

Cheers,
Shaggy.

They have: 121 posts

Joined: Dec 2008

Good Morning!

The first issue was surrounding course pre-requisites.
I don't have any experience building online courses, but I think I can see that a course can be separated into many 'Tasks'.

In a course, 'Tasks' might be completed by a user either seqentially, or they may bounce around a little bit picking and choosing which they want to do first, second, etc.

So, I can see an 'Course' object being the traffic cop, per-se, of delivering 'Tasks'. Tasks would implement a standard interface so the 'Course' object can always determine
1) If a task is complete or in-complete
2) Is user input required: Is this going to be a machine run task, or something that requires input from the user?
2) What stage in a course the task should be completed
- prolog - before the user is able to do anything - setup
- body - The user's 'Course work'
- epilog The end, after the user has supplied everything
- result - The results, after all requirements and 'prolog' have been met
3) other things I haven't thought of that are 'tasky' Laughing out loud

Imagine now that your setup tasks, pre-requisite tasks, and results tasks are just 'Tasks', no different than a user driven question or activity in the course.

You can slide in setup tasks in the prolog if you require it before the user needs to lift a finger. You can check requirements in the epilog and instruct the 'Course' object to have the user move back into the 'body' of the course, and you can generate results after the course requirements are complete at the result stage.

A course is never really 'complete' until the result tasks have been delivered to the user.

The administrator would build 'Tasks', and then glue them together inside a 'Course' As your 'Task' library builds including post-course checks and results, building a course becomes little more than gluing the re-usable pieces together into a new 'Course'.

Pick it apart! Offspring is tugging on arm to go play...

Cheers,
Shaggy.

teammatt3's picture

He has: 2,102 posts

Joined: Sep 2003

Interesting ideas Shaggy. I've thought about it a little more, and I'm thinking, since I am a much better at designing databases than code, maybe I should create a database that stores the requirements for each course. Then my application code could just run a simple query and check if all the requirements were met. It seems easy, perhaps too easy...

They have: 121 posts

Joined: Dec 2008

The database is typically where I start out as well. 'Object Relational Modeling' (ORM) is a good way to implement a system from the database up in an object oriented environment. ORM is a system that allows you to refer to your tables, relationships, and rows in objects.

Often (though depending on the implementation) you may 'describe' the tables and their relationships by setting up new classes within your chosen ORM framework. The framework will then create new tables from new objects, and alter tables from existing objects as you build/change. It is a bit of work up front, but often pays huge dividends when changes come down the road.

I believe PHP has several good implementations, I've used 'PHP Doctrine' with success: http://www.doctrine-project.org/

Cheers,
Shaggy

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.