Assignment Manager -- Relation of Users to Courses

Oct 2, 2012   #assignment manager 

Having modified the happstack-authenticate hsp-demo to display my theming (meaning the navbar and menu I took from a Bootstrap demo) – on all the pages, even the login/logout ones, it is now time to make logged-in page display a bit more dynamic content. Meaning, something besides your user id. Actually, I also need to make that display the user’s “nickname”, which appears to be part of the default profile type, from what I read of the documentation. However, the current goal is to display links to the user’s courses.

At the moment my goal is a side menu with two sets of links: “Summary” (Calendar of Deadlines, Grades) and “Courses” (all of the users’ courses). I suppose that the courses list could be complicated by separating by the user’s role in the course (Professor, Staff, Student), but that should be a future minor UI tweak.

I’ve figured out enough about inserting dynamic content into HSP templates that actually putting the course names into the document will be easy (generating the web-routes links is something I’ll figure out later). The current challenge is associating a logged-in user with their courses. This requires a database.

I was planning to HDBC. It seems fairly straight-forward and works with sqlite3 (which is really, really easy). It’s also just doing SQL, which means that anything I learn about SQL now is a transferable skill to future dealings with standard SQL databases. However, happstack-authenticate uses acid-state to store everything. While I could definitely use two DB solutions, I’ll at least consider using theirs.

acid-state is special to Haskell. You make a Haskell type as usual, and also use Template Haskell to derive it instances for “Safecopy” and “IsAcidic”. Those are what let you store it in an acid-state database-thing. I need to read the rest of the tutorial to figure out the details.

Currently, I’m trying to figure out how to represent the relationship between Users and Courses, as modulated by Roles. I’m ignoring Assignments and Submissions and Grades at the moment. Each User has some set of Courses in which they have a role.

    :::Haskell
    Role = Professor | Staff | Student

Each Course has a set of Users who have Roles in it. There is a global [(User,Course,Role)].

When a User is logged-in, you want to get their courses to populate the side menu, and the calendar/grades. When you display course information for the Prof/Staff, you want to know who is the course. Email alerts will need to pick the appropriate people to contact for an event (Profs, Staff, Students).

I guess the relationship between Users and Courses should be a separate structure.

    :::Haskell
    Relation =
      { user::UserId
      , course::CourseId
      , role::Role
      , courseOptions::CourseOptions
      }

Should I be using Users and Courses instead of Ids? I don’t know; I don’t want to assume acid-state is that magical. This is something that I want to retrieve by user, by course, and by both-at-once.

I’ll go read more about acid-state now.