node -v
redis-cli -v
postgres --version
git clone https://github.com/cul-2016/quiz.git && cd quiz
npm install
npm run postgres
and a redis server running with: redis-server
config.env
as follows:/ config.env /
#!/bin/bash
unset PORT
export DATABASE_USER=<db_user>
export DATABASE_PASSWORD=<db_password>
export DATABASE_HOST=<aws_db_host>
export DATABASE_PORT=5432
export DATABASE_NAME=<db_name>
export TEMPLATE_DIRECTORY=./server/templates
export SENDER_EMAIL_ADDRESS=quiz.cityuni@gmail.com
export AWS_REGION=us-west-2
export AWS_ACCESS_KEY_ID=<aws_access_key>
export AWS_SECRET_ACCESS_KEY=<aws_secret_access_key>
export SERVER_ROUTE=http://localhost:9000
export JWT_SECRET=<secret>
export FORUM_URL=http://localhost:4567
export STUDY_PLANNER_URL=http://localhost:5000
and run source local.env
npm start
npm run webpack-watch
http://localhost:9000
to get startednpm test
npm run coverage
The app has a staging version and a production version.
Staging version:
Production version:
Redis free plan on Heroku
migrations
folder with the following format: yy-mm-dd_update_table_name
test-schema-local.txt
located in /test/utils/test-schema-local.txt
which will also need to be updated with the same information as that in the newly added migration filenpm run load-staging-schema
to get this new schema on the staging version of the appThe live database is a postgresql instance, hosted on aws (rds). The class of the instance is db.t2.small during the week, and, using an aws lambda, is downgraded to db.t2.micro at the weekend, when the app will see the least use.
The upgrade/downgrade class and schedule can be edited on aws:
modifyRDSInstanceClass
. The environment variables are as follows:
instance
- The name of the database instance.upgrade
- The class to upgrade the instance to.downgrade
- The class to downgrade the instance to.CloudWatch
. Rules should be set to trigger on a schedule
, using a cron expression. For help figuring out the cron expression for the period you want to use (daily, weekly etc.), you can use https://crontab.guru/. The target of the rules should be set to the modifyRDSInstanceClass
lambda, with a constant json input of {"grade": required_term}
, where required_term
is either "upgrade"
or "downgrade"
.Backups are automated to happen daily between 22:00 and 22:30. This window can be changed, but backups do not cause any significant downtime (a few seconds at most).
To manually modify the instance specifications, select the instance on the aws rds page, and choose modify
from the instance actions
. Any changes made here will occur during the maintenance window (Saturday 3:00am - 3:30am, but changeable) unless Apply Immediately
is selected.
├── server
├── lib # Helper functions for the server handlers logic
├── plugins # Server plugins
├── templates # Email templates see [dwyl/sendemail](https://github.com/dwyl/sendemail)
|
├── server.js # Main Server logic
└── start.js # Starts the server
├── src
├── js # [Typical redux file structure](https://jaysoo.ca/2016/02/28/organizing-redux-application/)
├── actions
├── reducers
├── routes
├── container
├── components
|
├── index.js # Entry point
├── root.js
├── socket.js # Implementation of socket.io
└── store.js
├── scss # To start the server
└── utils # Dev server configuration
├── test
├── front
└── back
├── public # Files served by server
├── bundle.js # Webpack bundle of the `src/js/index.js` entry point
├── index.html
└── ...
├── package.json
├── README.md
└── ...
Super Admin
Client
individual lecturer
or group admin
account type.No
for:
Lecturers
Students
src/root.js
contains the routes for the different views.
Each route makes use of React Router's onEnter
hooks. Functions that run onEnter
can be found in src/js/lib/onEnterHooks.js
All routes run an authenticate
function, with the exception of the IndexRoute
and the two routes that deal with user sign up.
Routes for the ModuleContainer
and StudentModuleContainer
views also run fetchModule
.
Redux allows you to listen for state changes and run functions.
These listeners are located in src/js/lib/subscriptions.js
.
fetchDashboard
is registered when the Dashboard
component is mounted. It executes when state.user.is_lecturer !== undefined
joinWebsocketRoom
is registered when the Module
and StudentModule
components are mounted. It executes when state.module.module_id !== undefined
.
room
.sendQuizInvite
is run, which runs emitSendQuizInvite
sendQuizInvite
dispatches three actions:
setIntervalID
setQuizDetails
getQuizQuestions
emitSendQuizInvite
emits the send_quiz_invite
socket event on an intervalreceive_quiz_invite
is received by studentsreceive_quiz_invite
dispatches:
OPEN_QUIZ
--> sets isQuizOpen
in student state to trueisQuizOpen
)startQuiz
is run, which runs sendNextQuestion
startQuiz
dispatches two actions:
START_QUIZ
- sets isQuizStarted
in lecturer state to trueGO_TO_NEXT_QUESTION
--> updates nextQuestionIndex
in lecturer stateemitSendNextQuestion
emits the send_next_question
socket eventreceive_next_question
is received by studentsSET_NEXT_QUESTION
!isQuizStarted
, two additional actions are dispatched (before SET_NEXT_QUESTION
):
SET_QUIZ_DETAILS
START_QUIZ
loadtest
.Here are the list of steps that you'll need to take for stress Testing
artillery
with npm i -g artillery
loadtest
file. You will need to replace the following text get cookie from headers in the live app for user student@city.ac.uk and paste it here
with your new cookieartillery run loadtest-{version}.yml > loadtest-{version}.txt
.txt
file.The staging version of the app is hosted on basic heroku with no paid options. (free postgres w/ option of 10 max concurrent connections). We reach saturation point in phase 6 of the load testing where it starts to throw errors when it reaches ~60 concurrent users
The live version of the app is hosted on 1 dyno @ $25. We reached a saturation point somewhere between 320 - 500 concurrent users where it started to throw errors. This is approximately a six fold increase.
Quodl is available to be used as an external tool in Moodle through LTI.
For details on how to set this up, see the LTI Integration guide
The in-app privacy statement for Quodl has been updated in line with GDPR as
per issue #716.
If further changes are required, these can be easily made by updating the following file:
src/js/components/privacy-message.js
.