Forum .LRN Q&A: Re: Implementing class membership quota

Collapse
Posted by Radamanthus Batnag on
I've created a preliminary version of this.

What I've done

max_n_members is a property of dotlrn_community_types,
and is inherited by dotlrn_communities. i.e. you can
set a per-subject membership limit, and all class instances
of that subject will have by default the same membership limit.

For subjects, the value for max_n_members is set through the "edit subject properties".
For communities and class instances, the value is set through the edit community properties" pages.

max_n_members applies to all dotlrn communities.

if, for a particular community, max_n_members = 0 or is null, no membership limit will be enforced for that community.

How I did it

1. modify the data model:
  - add max_n_members column to dotlrn_community_types
  - add max_n_members column to dotlrn_communities_all
  - created additional *__new stored procedures for dotlrn_community_types and dotlrn_communities_all
  (I only did a PostgreSQL version)
  - created a new table: dotlrn_community_mem_rel_tracking, to track community memberships
  - created before insert and after delete triggers on dotlrn_member_rels, to keep dotlrn_community_mem_rel_tracking up-to-date

2. modify the tcl (and xql) procs:
  - community-procs.tcl: added get_* and set_* procs for max_n_members and mem_count

3. modify the UI - added a form field for max_n_members in the following add/edit pages:
  - community-edit.tcl
  - /dotlrn/admin/class-edit.tcl
  - /dotlrn/admin/class-instance-new.tcl
  - /dotlrn/admin/class-new.tcl

4. enforce the max. membership rule
  - /dotlrn/register.tcl: added a select...for update lock that checks to make sure that the max. membership
  rule will not be exceeded if the user joined the community

5. reinstall dotLRN (to recreate the views affected by step #1)

Please help me...

1. Suggest better ways of implementing this
2. Suggest ways on how to test this (I only tested this using simultaneous mouse clicks on two separate computers)

Thanks!