Hi all,

I'm designing a system that allows students to sign up for 1:1 tutoring 
sessions with other student tutors. All students should be able to see the 
tutoring sessions that exist during a given week (including names of the 
tutor for each session, but once a spot is taken it should appear as 
taken--but enrolled students don't know by whom. Tutors on the other hand 
have full view of the sessions and who's signed up for what. They're also 
students themselves, so a student may have a "tutor" relationship to one 
course and an "enrolee" relationship to another. Additionally, there is an 
instructor who can also view everything, but cannot offer times that they 
would tutor.

The crux of the challenge at the moment is just how to *model* this stuff. 
The relevant bits of modeling I have so far are the following

type User
    = Student StudentInfo
    | Faculty FacultyInfo
    | Admin


type alias Model =
    { me : Maybe UserId
    , users : Dict UserId User
    , courses : Dict CourseId Course
    }


type alias BasicInfo =
    { name : String
    , id : UserId
    }



type CourseRelation
    = Enrolled (Maybe SessionId)
    | Tutoring (Set SessionId)


type alias StudentSpecific =
    { a

        | courses : Dict CourseId CourseRelation
    }


type alias StudentInfo =
    StudentSpecific BasicInfo


type alias FacultySpecific a =
    { a
        | courses : Set CourseId
    }


type alias FacultyInfo =
    FacultySpecific BasicInfo


type alias Course =
    { id : CourseId
    , name : String
    , instructor : UserId
    , sessions : Dict SessionId Session
    }


type alias Session =
    { id : SessionId
    , time : Date
    , tutor : UserId
    , location : String
    , registration : Registration
    }


Of course, the goal is not to have any information in the Model that the 
current user is not privileged to have. Cases that are tricky with the 
above model include

   - An enrolled student should see the sessions and who's tutoring them. 
   They get the tutor's UserId (which is okay to disclose) but they should not 
   have the whole StudentInfo model for the tutor in their store--it includes 
   things like what other courses the tutor is in and their relation to them.
   - Course staff (tutors and instructors) should be able to see the names 
   [and, not yet in the above model but forthcoming, contact info] for signed 
   up students--but if possible, not the other courses that the student is 
   related to.
   - In the model above, the Session doesn't store whatever enrolled 
   student may be associated with it because then anyone with the a session 
   record would see the student signed up, and signups must be anonymous (a 
   prior version had Registration tagging the registered student's UserId).
   - Probably other things I'm missing that make this thorny


Kind people of elm-discuss, am I just going about this in a way 
over-engineered way? Is there any way to reduce this complexity? You'll 
note that I've made heavy use of Sets and Dicts, as well use union types 
and carefully choose who owns what data, all in an attempt to make 
impossible states impossible. But I feel that it's become too much. The 
data is highly relational, and it'd be so simple to have just a few sets on 
the root of my Model for UserId/User, CourseId/Course, SessionId/Session, 
and many-to-many tables for CourseRelation (User <-> Course) and 
SessionSignups (Session <-> User). That would also permit a boatload of 
invalid states to be representable. In such a setup, the server would then 
just send only the rows that the user is privileged to see. Even then 
achieving the "session anonymity for enrolled students" seems tricky to 
implement.

I am new to building from scratch a system with these kinds of 
requirements--I would call them sophisticated, but that's probably my 
inexperience talking--and am completely open to the fact that there's 
something simple that I'm missing that'd make this all much more 
manageable. I'd even be happy to scrap all of this if what I've got so far 
is deeply problematic.

I would be extremely appreciative if anyone with some experience has any 
advice for me. Thank you very much and have a great weekend!

Cheers,
Spencer

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to