Enable writeable gradebook
These instructions will allow you to enable writeable gradebook.
Here is the link for github repo of Frontend Gradebook app, https://github.com/edx/frontend-app-gradebook
Following are the steps to enable writable gradebook.
Log into server.
Switch the user to edxapp.
sudo su edxapp -s /bin/bash
Activate the virtual env.
source /edx/app/edxapp/edxapp_env
Clone the github repo.
git clone https://github.com/edx/frontend-app-gradebook.git
Execute the npm command to install gradebook into your project
npm i --save @edx/frontend-app-gradebook
Go to Frontend repo directory and install node modules.
cd frontend-app-gradebook
npm install
Setup Oauth between LMS and the Writable Grades app
Log into LMS-URL/admin. This is the Django Admin panel.
From DJANGO OAUTH TOOLKIT, click Applications.
Add a Application by clicking button.
Fill form using appropriate values. It would auto generate Client id and Client secret, save these for later use.
To execute the gradebook on port 1994, but this teminates as terminal is closed.
npm run start
Update urls in .env.development file
nano .env.development
Update the following according to your urls.
BASE_URL='SERVER_IP:1994' LMS_BASE_URL='SERVER_IP' LOGIN_URL='SERVER_IP/login' LOGOUT_URL='SERVER_IP/login' REFRESH_ACCESS_TOKEN_ENDPOINT='SERVER_IP/login_refresh' DATA_API_BASE_URL='SERVER_IP' LMS_CLIENT_ID=CLIENT ID GENERATED IN ABOVE STEP IN ADMIN PANEL
If getting CORS error. In order to resolve we updated the lms.yml and studio.yml
nano /edx/etc/lms.yml nano /edx/etc/studio.yml
update the following flags
CORS_ORIGIN_ALLOW_ALL: true ENABLE_CORS_HEADERS: true CORS_ORIGIN_WHITELIST: (Add your ip and port) WRITABLE_GRADEBOOK_URL: 'https://SERVER_IP:1994'
Restart the edx service by issuing the following command:
sudo /edx/bin/supervisorctl restart all
When running on domain with SSL configured
Perform the following to get gradebook running on domain with SSL configured.
Configure sub domain and perform DNS configuration for grades.domain_name.
Create a file in site-enabled in nginx to to get the port 1994 working on the subdomain created.
vim /etc/nginx/sites-enabled/grades
Paste the following code in the file.
server { listen 80; server_name ~^((stage|prod)-)?grades.*; loacation / { proxy_pass http://localhost:1994; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; }
Create ssl certificate for the new created domain.
sudo certbot -d LMS-URL,studio.LMS-URL,notes.LMS-URL,grades.LMS-URL --expand
Update lms.yml and studio.yml
nano /edx/etc/lms.yml nano /edx/etc/studio.yml 1. Add subdomian in CORS_ORIGIN_WHITELIST CORS_ORIGIN_WHITELIST: - 'https://grades.LMS-URL' - 'grades.LMS-URL' 1. Add subdomain in CSRF_TRUSTED_ORIGINS CSRF_TRUSTED_ORIGINS: - 'https://grades.LMS-URL' - 'grades.LMS-URL' 1. Add subdomain in LOGIN_REDIRECT_WHITELIST LOGIN_REDIRECT_WHITELIST: - "grades.LMS-URL" - "https://grades.LMS-URL" 1. Update WRITABLE_GRADEBOOK_URL WRITABLE_GRADEBOOK_URL: 'https://grades.LMS-URL'
Update .env.dev
nano frontend-app-gradebook/.env.development 1. Update the following flags, DANGEROUSLY_DISABLE_HOST_CHECK=true DISABLE_HOST_CHECK=true HOST=LMS_URL BASE_URL='grades.LMS_URL' LMS_BASE_URL='https://LMS_URL' LOGIN_URL='https://LMS_URL/login' LOGOUT_URL='https://LMS_URL/login' REFRESH_ACCESS_TOKEN_ENDPOINT='https://LMS_URL/login_refresh' DATA_API_BASE_URL='https://LMS_URL'
Update Redirect uris, in OAuth Application(LMS_URL/admin/oauth2_provider/application) from admin panel.
Restart nginx service by issuing the following command:
sudo service nginx restart
Restart the edx service by issuing the following command:
sudo /edx/bin/supervisorctl restart all
Start the Writable gradebook service.
cd frontend-app-gradebook npm run start -- --host 0.0.0.0 --disable-host-check
The above command runs the frontend-app-gradebook, but stops as the terminal session gets end. Now run the frontend-app-gradebook as a service.
Install pm2.
sudo npm install -g pm2
Start the application from pm2
pm2 start npm --name "gradebook" -- start -- --host 0.0.0.0 --disable-host-check
Now you can check the application in pm2
pm2 list
Applications that are running under PM2 will be restarted automatically if the application crashes or is killed, but an additional step needs to be taken to get the application to launch on system startup (boot or reboot). Run the following command using root user.
pm2 startup systemd