Wednesday, July 31, 2013

What is the best way to architect this part of the application?

I thank you again for answering a different question a couple of weeks ago. Today, however, I'm struggling with the best way to architect a part of my app.  I'm hoping that you can help me figure out the best way to provide the necessary functionality to the user.


I am building an application that allows home school families the ability to register their children for upcoming classes.  This is a co-operative and so parents can be teachers, admins, etc. and there can be multiple children in each family.

You may find the following information familiar. I copied/pasted it from my earlier post. 

In my models.py file I have the following class definitions:


class Family(models.Model):

...

name = models.CharField(verbose_name="Family Name")


------------------------------------------------------------------------------------------------


class FamilyMember(AbstractUser):

....

family = models.ForeignKey(Family, blank=True, null=True)

family_member_role = models.ForeignKey(FamilyMemberRole, blank=True, null=True)    #For our example, let's assume this is either a parent or a child

...

------------------------------------------------------------------------------------------------


class Student(models.Model):

...

family_member = models.OneToOneField(FamilyMember)

...

------------------------------------------------------------------------------------------------

class Schedule(models.Model):

...

semester = models.ForeignKey(Semester, verbose_name='Semester')

student = models.ManyToManyField(Student, verbose_name='Students',  blank=True, null=True)

...

------------------------------------------------------------------------------------------------

So, there is a table called Family that I belong to. It holds my family name and a couple of other fields.   

There is then a one-to-many relationship from that to the FamilyMember table. In this table I have a record for each member of my family.   

The FamilyMember table is also being used as the authentication table for my site. I have not replaced the default security model but only abstracted it and added additional fields.

My children are students so they are in the Student table. Of course, they are in the FamilyMember table with a foreign key in the Students table.

I am logged into the site as myself. Since my family_member_role is set to parent I should be able to enroll all of my children into their courses.


The Schedule table contains a bunch of relationships that "glue" together a course in a course catalog, a semester, a set of teachers, a set of assistants, a set of students, etc. I don't think that this this matters in my question but I wanted to mention it just in case.

*** There can be unlimited periods. For this semester, we might have 3 periods but next semester we might have 4 or 5. So, I have a table that stores the periods for each semester.


On to my design question.

From the user perspective, I'm thinking of the following workflow. However, I don't know if there is a better way to architect it.


A parent logs into the site.
She clicks on the "Schedule" link for a specific Semester.
She sees a list of classes that she can enroll her children in.   It is grouped by periods (first hour, second hour, etc) and it looks something like below. Note, the co-op only meets twice a month and does not replace any of the children's actual curriculum. These classes can be very educational but are really designed more for social interaction.

First Period
-------- Fun with math   (1st - 3rd grade)
-------- Spelling games (1st - 3rd grade)
-------- C++ programming (4th - 5th grade)
-------- Sing and dance (4th - 5th grade)

Second Period
-------- Science experiments (1st - 3rd grade)
-------- Computer games (1st - 3rd grade)
-------- Woodworking (4th - 5th grade)
-------- Public speaking (4th - 5th grade)

Now, as a parent, I need to enroll my two children into classes. I have a 3rd grader and a 4th grader.  I am NOT forced to enroll my children in classes that match their grades. I can enroll my 3rd grade child in the C++ programming class if I think that he can succeed in that class. 

So, how do I set up this enrollment?   I have a couple of options that are floating around in my mind. The first option is to use the bootstrap accordian class (See OPTION 1 below). When a parent clicks on the "Fun with math" the list of their children are displayed as radio buttons. The parent can select either/or child.   Both children /could/ be enrolled in the same first period if desired. Let's say that Mark is selected in the Math class.   When the parent clicks on the "Spelling games" class, the same children list is displayed. If the parent selects Mark for this Spelling class, then the math class selection is cleared for Mark.   So, Mark can only be enrolled in one class during First Period.     

As the parent moves on to Second Period, she can enroll her children just like she did during first period.

The problems that I see with this:
.  Once the form is submitted, the Student record will be stored in the Schedule table. If the user comes back to the enrollment screen, how will I be able to display what class each child has been enrolled in? 
.  If the parent makes any changes after posting the form, I will have to figure out how to delete the records from the Schedule table for that child, for that period, before adding a new Student record to the Schedule table.  How do I do that?

OPTION 1:

First Period
-------- Fun with math   (1st - 3rd grade)

+++++ O  Mark
+++++ O  Jessica

-------- Spelling games (1st - 3rd grade)

+++++ O  Mark
+++++ O  Jessica

-------- C++ programming (4th - 5th grade)
-------- Sing and dance (4th - 5th grade)

Second Period
-------- Science experiments (1st - 3rd grade)
-------- Computer games (1st - 3rd grade)
-------- Woodworking (4th - 5th grade)
-------- Public speaking (4th - 5th grade)


Another idea that I have floating around is to create a drop down of classes per child instead. It would look something like OPTION 2 below.   The parent would only be able to choose one course for each child, for each period. 

Similar problems apply to this option:
.  Once the form is submitted, the Student record will be stored in the Schedule table. If the user comes back to the enrollment screen, how will I be able to display what class each child has been enrolled in as the "selected" item in the drop down list?
.  If the parent makes any changes after posting the form, I will have to figure out how to delete the records from the Schedule table for that child, for that period, before adding a new Student record to the Schedule table.  How do I do that?

OPTION 2:

First Period
++++  Mark [ drop down of first period courses ]
++++  Jessica [ drop down of first period courses ]

-------- Fun with math   (1st - 3rd grade)
-------- Spelling games (1st - 3rd grade)
-------- C++ programming (4th - 5th grade)
-------- Sing and dance (4th - 5th grade)

Second Period
++++  Mark [ drop down of first period courses ]
++++  Jessica [ drop down of first period courses ]

-------- Science experiments (1st - 3rd grade)
-------- Computer games (1st - 3rd grade)
-------- Woodworking (4th - 5th grade)
-------- Public speaking (4th - 5th grade)



Sorry for the long email but I wanted to fully explain what I'm doing.      Should I create a new table that stores the child and each class that he is enrolled in?    Remember, each semester might have a different total of periods. This semester we might have 3 periods but next semester we might have 4 or 5.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment