virtualcommons / port-of-mars

Port of Mars is an online, game-based, social science experiment set on the first human community on the Red Planet. We are now in an open beta where anyone aged 18 and over can participate.
https://portofmars.asu.edu
GNU Affero General Public License v3.0
9 stars 15 forks source link

add educator service stubs and tests #943

Open alee opened 4 weeks ago

alee commented 4 weeks ago

Educators should be able to:

  1. create a classroom
  2. add students to a classroom
  3. generate a unique classroom auth code
  4. generate a unique password for themselves server side (still in flux)

Students should be able to:

  1. join a classroom
  2. generate a unique auth code which they can use to rejoin their classroom or running game (CURRENT TASK)

Jest test stubs currently in test/services/educator.test.ts

Jest documentation:

https://jestjs.io/docs/getting-started

sgfost commented 4 weeks ago

classroom.authToken (game code):

should be short (4/5 characters)

student.rejoinCode:

should be a bit longer due to needing more of them but still easily memorized or transcribed by a student

teacher.password:

considerably longer just for better security

something to note is that a helper function can be shared between generation functions if the strategy for creating the code is similar by taking in some parameter to determine the length, i.e. a word count or character count

all should be guaranteed to be unique by attempting to generate a code, checking for uniqueness in the db, then trying again in case of a collision. Alternatively, these all have a unique constraint in the db so inserting a non-unique value will raise an error, which can be taken advantage of with a try...catch if that error is unique (we wouldn't want to keep trying if the error was something else that went wrong)