Liking cljdoc? Tell your friends :D

examples.class-scheduling


add-classclj

(add-class db classname available-seats)

Used to populate the database's class list. Adds a new class to the list of available classes and sets the number of available seats for the class.

Used to populate the database's class list. Adds a new class to the
list of available classes and sets the number of available seats for
the class.
sourceraw docstring

available-classesclj

(available-classes db)

Returns a list of available classes. An available class is one with 1 or more seats open for enrollment.

Returns a list of available classes. An available class is one with
1 or more seats open for enrollment.
sourceraw docstring

drop-studentclj

(drop-student db student-id class-id)

Drops a student from a class, if he is signed up for it.

Drops a student from a class, if he is signed up for it.
sourceraw docstring

init-dbclj

(init-db db classnames)

Helper function to initialize the db with a bunch of classnames. Sets the number of available seats for each class to 10. Clears out the DB, so all existing information about classes and attendees is dropped.

Helper function to initialize the db with a bunch of classnames.
Sets the number of available seats for each class to 10. Clears out
the DB, so all existing information about classes and attendees is
dropped.
sourceraw docstring

reset-classclj

(reset-class db class-id)
(reset-class db class-id available-seats)

Helper function to remove all attendees from a class and reset it. If available-seats is provided, we use that number as the new value of available-seats. If not, we set the value to the number of attendees in the class + the number of seats still available in the class.

NOTE: This is not part of the original example.

Helper function to remove all attendees from a class and reset it.
If `available-seats` is provided, we use that number as the new
value of `available-seats`. If not, we set the value to the number
of attendees in the class + the number of seats still available in
the class.

*NOTE*: This is not part of the original example.
sourceraw docstring

reset-studentclj

(reset-student db student-id)

Drop the given student from all classes he has signed up for.

Drop the given student from all classes he has signed up for.
sourceraw docstring

run-simclj

(run-sim num-of-students ops-per-student)

Runs the simulate-student function across multiple threads.

Runs the `simulate-student` function across multiple threads.
sourceraw docstring

signup-studentclj

(signup-student db student-id class-id)

Signs up a student for a class. Constraints are as follows:

  • The student isn't already enrolled for this class.
  • The class should have seats available for enrollment.
  • The student can sign up for a maximum of 5 classes.
Signs up a student for a class. Constraints are as follows:

- The student isn't already enrolled for this class.
- The class should have seats available for enrollment.
- The student can sign up for a maximum of 5 classes.
sourceraw docstring

simulate-studentclj

(simulate-student sid ops-per-student)

Simulates a student represented by sid. The student performs ops-per-student actions. Actions are any of:

  • signup: signup for a class (chosen at random)
  • drop: drop an existing class (chosen at random)
  • switch: switch from an existing class to a different class (chosen at random).
Simulates a student represented by `sid`. The student
performs `ops-per-student` actions. Actions are any of:

- `signup`: signup for a class (chosen at random)
- `drop`: drop an existing class (chosen at random)
- `switch`: switch from an existing class to a different
  class (chosen at random).
sourceraw docstring

switch-classesclj

(switch-classes db student-id old-class-id new-class-id)

Given a student-id and two class-ids, switch classes for the student! The contraints are as follows:

  • Don't drop the existing class unless the student has successfully signed up for the new class.
Given a student-id and two class-ids, switch classes for the
student! The contraints are as follows:

- Don't drop the existing class unless the student has successfully
  signed up for the new class.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close