Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Numbas Integration feature into 8.0.x #443

Merged
merged 130 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
3ae95f8
new:numbas feature backend intital commit
maddernd Dec 5, 2023
fa2de36
new:numbas feature backend intital commit
maddernd Dec 5, 2023
f035c44
fix test_attempts api paths
ublefo Mar 11, 2024
4165b10
Enforce authentication for the test_attempts api
ublefo Mar 13, 2024
55fcbc5
Modify the api to fetch test attempts with task id
ublefo Mar 13, 2024
061f49f
Numbas data management features
ublefo Mar 20, 2024
d53610a
feat: add Numbas config options to task def backend
satikaj Mar 22, 2024
dade800
Remove foreign key reference and add missing columns to csv file
ublefo Mar 22, 2024
aa8926e
refactor: simplify Numbas config storage
satikaj Mar 22, 2024
3f19ffa
fix: reset Numbas configs if no zip file has been uploaded
satikaj Mar 23, 2024
54c27ce
feat: change Numbas time delay config to enable incremental delays
satikaj Mar 24, 2024
20d5265
fix: expose enable Numbas test config to all users
satikaj Mar 27, 2024
5d80830
fix: use correct Numbas data path in Numbas api
satikaj Mar 28, 2024
0cc4915
fix: use custom endpoint for Numbas
satikaj Apr 9, 2024
27253bd
fix: consolidate numbas api endpoints
ublefo Apr 9, 2024
ff5ff62
fix: refactor numbas config reset logic
ublefo Apr 15, 2024
89a6615
fix: add missing numbas config fields to fix unit tests
ublefo Apr 15, 2024
ee992f4
fix: use correct endpoint url and include exam result for numbas test…
satikaj Apr 30, 2024
a7c4006
fix: use test attempt entity in file instead
satikaj Apr 30, 2024
b4d3f9d
fix: temporarily disable auth and fix test attempt lookup
ublefo May 4, 2024
e650ef1
refactor: modify test attempt files to match PoC
satikaj May 5, 2024
3f5aa2b
feat: add numbas task comment on test completion
satikaj May 6, 2024
26d75f5
feat: restrict test attempts by limit and comments to when test is co…
satikaj May 6, 2024
d9f640f
refactor: rewrite test_attempt api and generalize scorm variables
ublefo May 11, 2024
8047f4c
chore: address rubocop errors
ublefo May 14, 2024
3539d95
fix: add allow review property to task def related files
satikaj May 14, 2024
0812e20
fix: post scorm comment after test attempt termination
ublefo May 14, 2024
b498924
fix: rename entity file and add update fields in task spreadsheet
ublefo May 14, 2024
d71ea14
fix: enforce attempt limit
ublefo May 14, 2024
910eecd
fix: expose scorm configs to student
satikaj May 15, 2024
2a04a06
fix: use project and task def to fix issue where task is undefined on…
satikaj Jun 1, 2024
8c9a68b
feat: enable reviewing, passing, and deleting test attempts
satikaj Jun 1, 2024
c5055b8
feat: enable students to request extra scorm attempt
satikaj Jun 5, 2024
1e00d41
test: add sample numbas zip
satikaj Jun 5, 2024
28f3279
fix: calculate attempt number and limit instead of using stored int
satikaj Jun 5, 2024
7d31f7c
feat: add test attempt auth
satikaj Jun 6, 2024
273b62e
refactor: remove attempt number in task comment text
satikaj Jun 11, 2024
3d44ef2
fix: grant same number of extra attempts as scorm limit
satikaj Jun 11, 2024
1240b3f
fix: prevent new attempt if last is incomplete or passed
satikaj Jun 11, 2024
1ae0347
fix: prevent scorm extensions if no attempt limit
satikaj Jun 15, 2024
4255347
fix: check for attempts before accessing properties
satikaj Jun 15, 2024
fce7e75
feat: add attribute to allow file upload before scorm is passed
satikaj Jun 15, 2024
69053ee
fix: change scorm comment text
satikaj Jun 18, 2024
4139690
fix: add scorm bypass to excel file
satikaj Jun 18, 2024
fc8134a
feat: create unique token for scorm asset retrieval
satikaj Jun 26, 2024
c854fc1
test: add scorm unit tests
satikaj Jul 2, 2024
6108b52
fix: check if no old scorm tokens exist
satikaj Jul 2, 2024
3d86d04
refactor: remove stale todo comment
satikaj Jul 2, 2024
c5240d8
fix: validate attempt id
satikaj Jul 2, 2024
5db5f35
fix: reorder columns for csv export
satikaj Jul 2, 2024
08a0090
fix: use unique perms for scorm test retrieval
satikaj Jul 2, 2024
835d2b0
Merge branch 'new/numbas-integration' into 8.0.x
satikaj Jul 3, 2024
52450be
fix: ensure main convenor validation on change only
macite Jul 3, 2024
e740d82
fix: streamline archiving units in maintenance task
macite Jul 3, 2024
eacbac1
fix: remove rollover teaching period
macite Jul 3, 2024
7f3b752
feat: allow new unit code to be provided to rollover
macite Jul 3, 2024
9bdbe0e
chore(release): 8.0.9
macite Jul 3, 2024
6373eee
fix: ensure task definitions render when upload requirements are nil
macite Jul 4, 2024
4359cf2
refactor: correct syntax for rubocop
satikaj Jul 5, 2024
a49fc8c
fix: turn it in enabled property
macite Jul 10, 2024
bb29f84
fix: ensure sidekiq moves to Rails root before task pdf creation
macite Jul 10, 2024
5b8f5d3
fix: ensure turn it in actions only occur when tii enabled
macite Jul 10, 2024
9288fae
Merge branch '8.0.x' of https://github.com/macite/doubtfire-api into …
macite Jul 10, 2024
e3fab0d
fix: ensure logger only logs to stdout in development
macite Jul 10, 2024
58d8281
fix: guard access of pwd incase pwd is invalid
macite Jul 10, 2024
32b1d9f
fix: ensure failure to send email is handled
macite Jul 10, 2024
460681a
chore(release): 8.0.10
macite Jul 10, 2024
210c3f4
test: add tests for multi unit sync and connection errors in sync
macite Jul 12, 2024
d4808b0
feat: ensure deakin sync retries failed connections
macite Jul 12, 2024
6aea5c1
Merge branch '8.0.x' of https://github.com/macite/doubtfire-api into …
macite Jul 12, 2024
439669a
chore(release): 8.0.11
macite Jul 12, 2024
2fcb477
quality: ensure tii enabled always through class
macite Jul 15, 2024
e01ed19
feat: allow register webhooks to be controlled via config
macite Jul 15, 2024
61f2f49
chore(release): 8.0.12
macite Jul 15, 2024
ebbacb9
fix: check need to register webhooks in tii action
macite Jul 15, 2024
4dae884
fix: ensure tii module looks for appropriate user
macite Jul 15, 2024
0bf29eb
feat: add env var to configure log to stdout
macite Jul 15, 2024
6b08013
feat: check that old tii submissions upload when eula accepted
macite Jul 16, 2024
57acea2
Merge branch '8.0.x' of https://github.com/macite/doubtfire-api into …
macite Jul 16, 2024
03e9214
fix: limit tii action log to 25 entries
macite Jul 16, 2024
be21763
fix: ensure webhook test will register hooks
macite Jul 16, 2024
789fbad
fix: tii action retry resets retries
macite Jul 16, 2024
1eadf31
Merge branch '8.0.x' of https://github.com/macite/doubtfire-api into …
macite Jul 16, 2024
4f3979b
fix: merge student records for deakin students
macite Jul 17, 2024
6c74d7d
chore(release): 8.0.13
macite Jul 17, 2024
de3ec39
fix: add logging info to debug hmac issues
macite Jul 18, 2024
7d47eda
feat: allow logging to stdout using env var
macite Jul 18, 2024
cc2f674
chore: fix test to use assert_not and ensure actions are destroyed
macite Jul 18, 2024
72b4c69
chore: switch bundle exec to rails in shell scripts
macite Jul 18, 2024
15ca645
chore: update portfolio autogen shell script
macite Jul 18, 2024
68a7248
chore(release): 8.0.14
macite Jul 18, 2024
a249662
fix: correct turn it in hmac calculation
macite Jul 20, 2024
1b2a43c
fix: ensure pax header is not included in tex on 2nd pass
macite Jul 22, 2024
38a6922
chore(release): 8.0.15
macite Jul 22, 2024
232dcaa
fix: ensure comment added on task pdf convert fail
macite Jul 22, 2024
b70aeac
chore(release): 8.0.16
macite Jul 22, 2024
b868799
quality: address minor cop issue with automated error messages
macite Jul 22, 2024
4e38e6c
test: fix issues with file locn and tii features
macite Jul 22, 2024
908c803
chore(release): 8.0.17
macite Jul 22, 2024
752f26e
test: groups can be locked
macite Jul 24, 2024
7e9adaa
feat: add ability to manually remove webhooks from rails console
macite Jul 25, 2024
efa6692
fix: ensure tii signing secret is sent as a base64 string
macite Jul 25, 2024
547dbb9
chore(release): 8.0.18
macite Jul 25, 2024
d84856b
fix: remove newlines from signing key base64 encoding
macite Jul 26, 2024
b047e4c
chore: update log level for tii hook debug
macite Jul 26, 2024
166a0ad
quality: add tests for filename in task definitions
macite Jul 26, 2024
cea12e5
fix: ensure accept submission checks number of files
macite Jul 26, 2024
edcd36a
chore(release): 8.0.19
macite Jul 26, 2024
527b810
test: fix tests to conform to new validations
macite Jul 26, 2024
70f095c
fix: webhook registration key check
macite Jul 26, 2024
875b831
chore(release): 8.0.20
macite Jul 29, 2024
6753d80
fix: delay pdf generation to ensure sufficient time for async task to…
macite Jul 30, 2024
3a4eb51
chore(release): 8.0.21
macite Jul 30, 2024
7dfd547
test: task pdf download
macite Aug 1, 2024
33ee3ce
fix: ensure scoop files checks files are a hash
macite Aug 1, 2024
3e0a1ba
fix: add awaiting processing pdf
macite Aug 1, 2024
e3d36c2
fix: only try overseer assessment when overseer enabled
macite Aug 1, 2024
218afb9
fix: change zip of new upload to avoid loss
macite Aug 1, 2024
1e3acd4
feat: add email on accept submission error
macite Aug 1, 2024
8139f41
feat: report high usage on database timeout
macite Aug 1, 2024
758a51d
fix: avoid attempts to read negative size in file stream helper
macite Aug 1, 2024
eb8859b
chore(release): 8.0.22
macite Aug 1, 2024
842f233
fix: remove global error and report failures to admin user for tii
macite Aug 5, 2024
cbec03d
fix: ensure folders are removed when we move files with file helper
macite Aug 5, 2024
7023650
chore(release): 8.0.23
macite Aug 5, 2024
edbacb3
Merge branch '8.0.x' of https://github.com/satikaj/doubtfire-api into…
macite Aug 5, 2024
7de1a8f
quality: remove unused scorm entity
macite Aug 5, 2024
e7a6eed
fix: update auth token to work with scorm and general
macite Aug 8, 2024
02af2cf
test: fix scorm and auth tests with new tokens
macite Aug 9, 2024
8059213
fix: preload unit in test attempt and ensure limit flexibility in val…
macite Aug 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 147 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,153 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [8.0.23](https://github.com/macite/doubtfire-deploy/compare/v8.0.22...v8.0.23) (2024-08-05)


### Bug Fixes

* ensure folders are removed when we move files with file helper ([cbec03d](https://github.com/macite/doubtfire-deploy/commit/cbec03d9e148e5d3fbead9b88621f6c06d368371))
* remove global error and report failures to admin user for tii ([842f233](https://github.com/macite/doubtfire-deploy/commit/842f233d210345682d051e77cc3ddedb98baadc9))

### [8.0.22](https://github.com/macite/doubtfire-deploy/compare/v8.0.21...v8.0.22) (2024-08-01)


### Features

* add email on accept submission error ([1e3acd4](https://github.com/macite/doubtfire-deploy/commit/1e3acd4e64af2f41227c03b8fa53ab71811dac20))
* report high usage on database timeout ([8139f41](https://github.com/macite/doubtfire-deploy/commit/8139f41207a2a2b38f6560cc254d8e65bce40988))


### Bug Fixes

* add awaiting processing pdf ([3e0a1ba](https://github.com/macite/doubtfire-deploy/commit/3e0a1bac485322b6f7936fd3c244cdc5594ca9b1))
* avoid attempts to read negative size in file stream helper ([758a51d](https://github.com/macite/doubtfire-deploy/commit/758a51dfb9f8c5bc2cf2471caf5b8c0875467971))
* change zip of new upload to avoid loss ([218afb9](https://github.com/macite/doubtfire-deploy/commit/218afb9291b6864c3ede03b4f74bceaef81b339f))
* ensure scoop files checks files are a hash ([33ee3ce](https://github.com/macite/doubtfire-deploy/commit/33ee3cecd6e8317cd54f51c4e1e4314725b5085c))
* only try overseer assessment when overseer enabled ([e3d36c2](https://github.com/macite/doubtfire-deploy/commit/e3d36c27cffbeb8e56dc6c2b085665c5d91cd9ce))

### [8.0.21](https://github.com/macite/doubtfire-deploy/compare/v8.0.20...v8.0.21) (2024-07-30)


### Bug Fixes

* delay pdf generation to ensure sufficient time for async task to run ([6753d80](https://github.com/macite/doubtfire-deploy/commit/6753d803a573c3ced9fb58ef202486cc69d3329c))

### [8.0.20](https://github.com/macite/doubtfire-deploy/compare/v8.0.19...v8.0.20) (2024-07-29)


### Bug Fixes

* webhook registration key check ([70f095c](https://github.com/macite/doubtfire-deploy/commit/70f095c3bb762b73738344f6902cfd53e11daf0b))

### [8.0.19](https://github.com/macite/doubtfire-deploy/compare/v8.0.18...v8.0.19) (2024-07-26)


### Bug Fixes

* ensure accept submission checks number of files ([cea12e5](https://github.com/macite/doubtfire-deploy/commit/cea12e5bee7ba7b954bdeff1c5257d2c9c9a841a))
* remove newlines from signing key base64 encoding ([d84856b](https://github.com/macite/doubtfire-deploy/commit/d84856b8e90126e34cb34e4d405acc462af7e147))

### [8.0.18](https://github.com/macite/doubtfire-deploy/compare/v8.0.17...v8.0.18) (2024-07-25)


### Features

* add ability to manually remove webhooks from rails console ([7e9adaa](https://github.com/macite/doubtfire-deploy/commit/7e9adaa50b8db70fb488ae3a489ad521dac5e28a))


### Bug Fixes

* ensure tii signing secret is sent as a base64 string ([efa6692](https://github.com/macite/doubtfire-deploy/commit/efa669273bc8aa56ecfced4d63ab0f9af4649273))

### [8.0.17](https://github.com/macite/doubtfire-deploy/compare/v8.0.16...v8.0.17) (2024-07-22)

### [8.0.16](https://github.com/macite/doubtfire-deploy/compare/v8.0.15...v8.0.16) (2024-07-22)


### Bug Fixes

* ensure comment added on task pdf convert fail ([232dcaa](https://github.com/macite/doubtfire-deploy/commit/232dcaa7c5ea11109d35bc3bd7cd9d3c737259cd))

### [8.0.15](https://github.com/macite/doubtfire-deploy/compare/v8.0.14...v8.0.15) (2024-07-22)


### Bug Fixes

* correct turn it in hmac calculation ([a249662](https://github.com/macite/doubtfire-deploy/commit/a249662d6866a80cf03c5793bc4816a766ad2b97))
* ensure pax header is not included in tex on 2nd pass ([1b2a43c](https://github.com/macite/doubtfire-deploy/commit/1b2a43c0bfe45019b69bbf1952373709c09b67c5))

### [8.0.14](https://github.com/macite/doubtfire-deploy/compare/v8.0.13...v8.0.14) (2024-07-18)


### Features

* allow logging to stdout using env var ([7d47eda](https://github.com/macite/doubtfire-deploy/commit/7d47eda6affafb6056d391a101c39670e3a1b7f6))


### Bug Fixes

* add logging info to debug hmac issues ([de3ec39](https://github.com/macite/doubtfire-deploy/commit/de3ec392612470a1103f6a04c737775965e58ccf))

### [8.0.13](https://github.com/macite/doubtfire-deploy/compare/v8.0.12...v8.0.13) (2024-07-17)


### Features

* add env var to configure log to stdout ([0bf29eb](https://github.com/macite/doubtfire-deploy/commit/0bf29eb79824cfab89a6f4ce5ce15d89f1a77ca5))
* check that old tii submissions upload when eula accepted ([6b08013](https://github.com/macite/doubtfire-deploy/commit/6b08013b423ae990c34224fdd6c358b08026e9f0))


### Bug Fixes

* check need to register webhooks in tii action ([ebbacb9](https://github.com/macite/doubtfire-deploy/commit/ebbacb90cd1602b04489d2d41ee9723d13a75852))
* ensure tii module looks for appropriate user ([4dae884](https://github.com/macite/doubtfire-deploy/commit/4dae884dd29bf443d64654e36134e09e570ce31e))
* ensure webhook test will register hooks ([be21763](https://github.com/macite/doubtfire-deploy/commit/be21763e2b486df0181da1a87ffbddcfb7407388))
* limit tii action log to 25 entries ([03e9214](https://github.com/macite/doubtfire-deploy/commit/03e9214182e07561100b051cbed6e82191cc8750))
* merge student records for deakin students ([4f3979b](https://github.com/macite/doubtfire-deploy/commit/4f3979ba4c00a0040f4899e33e48cd950cb6e833))
* tii action retry resets retries ([789fbad](https://github.com/macite/doubtfire-deploy/commit/789fbada30f8d91cfaff732a4392ecb12d346e3f))

### [8.0.12](https://github.com/macite/doubtfire-deploy/compare/v8.0.11...v8.0.12) (2024-07-15)


### Features

* allow register webhooks to be controlled via config ([e01ed19](https://github.com/macite/doubtfire-deploy/commit/e01ed1940ecc7f91c66ea9d22ebbacae04ce7b70))

### [8.0.11](https://github.com/macite/doubtfire-deploy/compare/v8.0.10...v8.0.11) (2024-07-12)


### Features

* ensure deakin sync retries failed connections ([d4808b0](https://github.com/macite/doubtfire-deploy/commit/d4808b0f9d2653a02e56f868a9f0d9bec6e53826))

### [8.0.10](https://github.com/doubtfire-lms/doubtfire-deploy/compare/v8.0.9...v8.0.10) (2024-07-10)


### Bug Fixes

* ensure failure to send email is handled ([32b1d9f](https://github.com/doubtfire-lms/doubtfire-deploy/commit/32b1d9f94c225e326ed7fbc111565fa75de3ec00))
* ensure logger only logs to stdout in development ([e3fab0d](https://github.com/doubtfire-lms/doubtfire-deploy/commit/e3fab0d897bac82dcc14d3ff4b3948245a203b1c))
* ensure sidekiq moves to Rails root before task pdf creation ([bb29f84](https://github.com/doubtfire-lms/doubtfire-deploy/commit/bb29f84c8c4808886cf84b89069a622308d7b859))
* ensure task definitions render when upload requirements are nil ([6373eee](https://github.com/doubtfire-lms/doubtfire-deploy/commit/6373eee8ab38f5b1c79be5e88302c1880e36cc90))
* ensure turn it in actions only occur when tii enabled ([5b8f5d3](https://github.com/doubtfire-lms/doubtfire-deploy/commit/5b8f5d35f520f7e59ddfe53d795200f45882c517))
* guard access of pwd incase pwd is invalid ([58d8281](https://github.com/doubtfire-lms/doubtfire-deploy/commit/58d828193ee4448df15d4fcc391d2a1a22338efc))
* turn it in enabled property ([a49fc8c](https://github.com/doubtfire-lms/doubtfire-deploy/commit/a49fc8c042d608f109706278f933071e0f058ed2))

### [8.0.9](https://github.com/macite/doubtfire-deploy/compare/v8.0.8...v8.0.9) (2024-07-03)


### Features

* allow new unit code to be provided to rollover ([7f3b752](https://github.com/macite/doubtfire-deploy/commit/7f3b7529a9c8ee0a8800e28aa1504f221f80bc5d))


### Bug Fixes

* ensure main convenor validation on change only ([52450be](https://github.com/macite/doubtfire-deploy/commit/52450bec9039fda80f6f8a6d3a742adc8def8d77))
* remove rollover teaching period ([eacbac1](https://github.com/macite/doubtfire-deploy/commit/eacbac1f659e09252ab24a4fc9e0d5a02d811a00))
* streamline archiving units in maintenance task ([e740d82](https://github.com/macite/doubtfire-deploy/commit/e740d8218478b6ef27795fc15093082c07e0c69a))

### [8.0.8](https://github.com/doubtfire-lms/doubtfire-deploy/compare/v8.0.7...v8.0.8) (2024-07-01)


Expand Down
9 changes: 9 additions & 0 deletions app/api/api_root.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class ApiRoot < Grape::API
when ActionController::ParameterMissing
message = "Missing value for #{e.param}"
status = 400
when ActiveRecord::ConnectionTimeoutError
message = 'There is currently high load on the system. Please wait a moment and try again.'
status = 503
else
# rubocop:disable Rails/Output
puts e.inspect unless Rails.env.production?
Expand All @@ -57,6 +60,7 @@ class ApiRoot < Grape::API
mount BreaksApi
mount DiscussionCommentApi
mount ExtensionCommentsApi
mount ScormExtensionCommentsApi
mount GroupSetsApi
mount LearningOutcomesApi
mount LearningAlignmentApi
Expand All @@ -78,6 +82,8 @@ class ApiRoot < Grape::API
mount Tii::TiiGroupAttachmentApi
mount Tii::TiiActionApi

mount ScormApi
mount TestAttemptsApi
mount CampusesPublicApi
mount CampusesAuthenticatedApi
mount TutorialsApi
Expand All @@ -98,6 +104,7 @@ class ApiRoot < Grape::API
AuthenticationHelpers.add_auth_to BreaksApi
AuthenticationHelpers.add_auth_to DiscussionCommentApi
AuthenticationHelpers.add_auth_to ExtensionCommentsApi
AuthenticationHelpers.add_auth_to ScormExtensionCommentsApi
AuthenticationHelpers.add_auth_to GroupSetsApi
AuthenticationHelpers.add_auth_to LearningOutcomesApi
AuthenticationHelpers.add_auth_to LearningAlignmentApi
Expand All @@ -124,6 +131,8 @@ class ApiRoot < Grape::API
AuthenticationHelpers.add_auth_to UnitRolesApi
AuthenticationHelpers.add_auth_to UnitsApi
AuthenticationHelpers.add_auth_to WebcalApi
AuthenticationHelpers.add_auth_to ScormApi
AuthenticationHelpers.add_auth_to TestAttemptsApi

add_swagger_documentation \
base_path: nil,
Expand Down
36 changes: 27 additions & 9 deletions app/api/authentication_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
class AuthenticationApi < Grape::API
helpers LogHelper
helpers AuthenticationHelpers
helpers AuthorisationHelpers

#
# Sign in - only mounted if AAF auth is NOT used
Expand Down Expand Up @@ -71,7 +72,7 @@ class AuthenticationApi < Grape::API

# Return user details
present :user, user, with: Entities::UserEntity
present :auth_token, user.generate_authentication_token!(remember).authentication_token
present :auth_token, user.generate_authentication_token!(remember: remember).authentication_token
end
end

Expand Down Expand Up @@ -237,18 +238,18 @@ class AuthenticationApi < Grape::API
requires :auth_token, type: String, desc: 'The user\'s temporary auth token'
end
post '/auth' do
error!({ error: 'Invalid token.' }, 404) if params[:auth_token].nil?
logger.info "Get user via auth_token from #{request.ip}"
error!({ error: 'Invalid authentication details.' }, 404) if params[:auth_token].blank? || params[:username].blank?
logger.info "Get user via auth_token from #{request.ip} - #{params[:username]}"

# Authenticate that the token is okay
if authenticated?
if authenticated?(:login)
user = User.find_by(username: params[:username])
token = user.token_for_text?(params[:auth_token]) unless user.nil?
error!({ error: 'Invalid token.' }, 404) if token.nil?
token = user.token_for_text?(params[:auth_token], :login) unless user.nil?
error!({ error: 'Invalid authentication details.' }, 404) if token.nil?

# Invalidate the token and regenrate a new one
token.destroy!
token = user.generate_authentication_token! true
token = user.generate_authentication_token!

logger.info "Login #{params[:username]} from #{request.ip}"

Expand Down Expand Up @@ -324,7 +325,7 @@ class AuthenticationApi < Grape::API

# Find user
user = User.find_by(username: user_param)
token = user.token_for_text?(token_param) unless user.nil?
token = user.token_for_text?(token_param, :general) unless user.nil?
remember = params[:remember] || false

# Token does not match user
Expand Down Expand Up @@ -359,7 +360,7 @@ class AuthenticationApi < Grape::API
}
delete '/auth' do
user = User.find_by(username: headers['username'] || headers['Username'])
token = user.token_for_text?(headers['auth-token'] || headers['Auth-Token']) unless user.nil?
token = user.token_for_text?(headers['auth-token'] || headers['Auth-Token'], :general) unless user.nil?

if token.present?
logger.info "Sign out #{user.username} from #{request.ip}"
Expand All @@ -368,4 +369,21 @@ class AuthenticationApi < Grape::API

present nil
end

desc 'Get SCORM authentication token'
get '/auth/scorm' do
if authenticated?(:general)
unless authorise? current_user, User, :get_scorm_token
error!({ error: 'You cannot get SCORM tokens' }, 403)
end

token = current_user.auth_tokens.find_by(token_type: :scorm)
if token.nil? || token.auth_token_expiry <= Time.zone.now
token&.destroy
token = current_user.generate_scorm_authentication_token!
end

present :scorm_auth_token, token.authentication_token
end
end
end
8 changes: 7 additions & 1 deletion app/api/entities/task_definition_entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def staff?(my_role)
task_definition.upload_requirements
else
# Filter out turn it in details
task_definition.upload_requirements.map { |r| r.except('tii_check', 'tii_pct') }
task_definition.upload_requirements.map { |r| r.except('tii_check', 'tii_pct') } unless task_definition.upload_requirements.nil?
end
end

Expand All @@ -39,6 +39,12 @@ def staff?(my_role)
expose :has_task_sheet?, as: :has_task_sheet
expose :has_task_resources?, as: :has_task_resources
expose :has_task_assessment_resources?, as: :has_task_assessment_resources, if: ->(unit, options) { staff?(options[:my_role]) }
expose :has_scorm_data?, as: :has_scorm_data
expose :scorm_enabled
expose :scorm_allow_review
expose :scorm_bypass_test
expose :scorm_time_delay_enabled
expose :scorm_attempt_limit
expose :is_graded
expose :max_quality_pts
expose :overseer_image_id, if: ->(unit, options) { staff?(options[:my_role]) }, expose_nil: false
Expand Down
1 change: 1 addition & 0 deletions app/api/entities/task_entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class TaskEntity < Grape::Entity
end

expose :extensions
expose :scorm_extensions

expose :times_assessed
expose :grade, expose_nil: false
Expand Down
12 changes: 12 additions & 0 deletions app/api/entities/test_attempt_entity.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module Entities
class TestAttemptEntity < Grape::Entity
expose :id
expose :task_id
expose :attempted_time
expose :terminated
expose :success_status
expose :score_scaled
expose :completion_status
expose :cmi_datamodel
end
end
2 changes: 1 addition & 1 deletion app/api/entities/user_entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class UserEntity < Grape::Entity
expose :opt_in_to_research, unless: :minimal
expose :has_run_first_time_setup, unless: :minimal

expose :accepted_tii_eula, unless: :minimal, if: ->(user, options) { Doubtfire::Application.config.tii_enabled } do |user, options|
expose :accepted_tii_eula, unless: :minimal, if: ->(user, options) { TurnItIn.enabled? } do |user, options|
if TiiActionFetchFeaturesEnabled.eula_required?
TurnItIn.eula_version == user.tii_eula_version
else
Expand Down
Loading