This is a single page React and Typescript application intended to provide a platform for presenting "Lightweight" activities.
- Clone this repo and
cdinto it - Run
npm installto pull dependencies - Run
npm startto runwebpack-dev-serverin development mode with hot module replacement
If you want to build a local version run npm build, it will create the files in the dist folder.
You do not need to build to deploy the code, that is automatic. See more info in the Deployment section below.
- Make sure if you are using Visual Studio Code that you use the workspace version of TypeScript.
To ensure that you are open a TypeScript file in VSC and then click on the version number next to
TypeScript Reactin the status bar and select 'Use Workspace Version' in the popup menu. - When coding, use 2 spaces for indentation.
- SVG icons are imported directly into the project in src/assets/. SVGR is used to convert SVGs to React components which can be directly imported into other React components (attributes such as fill can be styled using CSS classes).
The activity player uses the portal-report code base to display a report of the students work. Testing this is complicated. Here is one approach:
- create an activity player activity in authoring.staging.concord.org
- publish it to learn.staging.concord.org
- this is necessary to send the activity structure to the report-service
- it will create a new resource in learn staging, but you aren't going to use or modify that one
- this new resource can't be modified because then changes to the activity in LARA authoring won't be published correctly because LARA will be looking for a matching resource in learn.staging.concord.org
- find the new created resourced in learn staging using advanced search and copy the URL it should be something like:
https://activity-player.concord.org/branch/master/index.html?activity=https://authoring.staging.concord.org/api/v1/123.json - create a new resource in learn staging using: https://learn.staging.concord.org/eresource/new
- set the URL of this resource:
- replace the
activity-player.concord.orgwithlocalhost:8080(or whatever your local server for the activity player is) - add a new parameter
portal-report=https://localhost:8081(or whatever your local server for the portal-report is) - the new url will be something like:
https://localhost:8080?activity=https://authoring.staging.concord.org/api/v1/123.json&portal-report=https://localhost:8081
- replace the
- assign this resource to a class
- run the resource as a student in this class
Deployments are based on the contents of the /dist folder and are built automatically by GitHub Actions for each branch and tag pushed to GitHub.
Branches are deployed to https://activity-player.concord.org/branch/<name>/.
Tags are deployed to https://activity-player.concord.org/version/<name>/
You can view the status of all the branch and tag deploys here.
The production release is available at https://activity-player.concord.org.
Production releases are done using a manual GitHub Actions workflow. You specify which tag you want to release to production and the workflow copies that tag's index-top.html to https://activity-player.concord.org/index.html.
See the CLUE docs/deploy.md for more details (it uses the same process).
To deploy a production release:
- Update the version number in
package.jsonandpackage-lock.jsonnpm version --no-git-tag-version [patch|minor|major]
- Update the
CHANGELOG.mdwith a description of the new version - Verify that everything builds correctly
npm run lint && npm run build && npm run test
- Copy asset size markdown table from previous release and change sizes to match new sizes in
distcd distls -lhS *.js | awk '{print "|", $9, "|", $5, "|"}'ls -lhS *.css | awk '{print "|", $9, "|", $5, "|"}'
- Create
release-<version>branch and commit changes, push to GitHub, create PR and merge - Test the master build at: https://activity-player.concord.org/index-master.html
- Push a version tag to GitHub and/or use https://github.com/concord-consortium/activity-player/releases to create a new GitHub release
- Stage the release by running the Release Staging Workflow and entering the version tag you just pushed.
- Test the staged release at https://activity-player.concord.org/index-staging.html
- Update production by running the Release Workflow and entering the release version tag.
Run npm test to run jest tests. Run npm run test:full to run jest and Cypress tests.
Inside of your package.json file:
--browser browser-name: define browser for running tests--group group-name: assign a group name for tests running--spec: define the spec files to run--headed: show cypress test runner GUI while running test (will exit by default when done)--no-exit: keep cypress test runner GUI open when done running--record: decide whether or not tests will have video recordings--key: specify your secret record key--reporter: specify a mocha reporter
cypress run --browser chromewill run cypress in a chrome browsercypress run --headed --no-exitwill open cypress test runner when tests begin to run, and it will remain open when tests are finished running.cypress run --spec 'cypress/integration/examples/smoke-test.js'will point to a smoke-test file rather than running all of the test files for a project.
- activity={id|url}: load sample-activity {id} or load json from specified url
- sequence={id|url}: load sample-sequence {id} or load json from specified url
- sequenceActivity={n|activity_[id]}: load activity n where n corresponds to the activity's placement in the order of sequenced activities (1 = first activity, 2 = second activity, etc.), or by the activity's unique ID
- page={n|"page_[id]"}: load page n, where 0 is the activity introduction, 1 is the first page and [id] in "page_[id]" refers to an internal integer id of the page model exported from LARA.
- themeButtons: whether to show theme buttons
- mode={mode}: sets mode. Values: "teacher-edition"
- portalReport: override default base URL for the student report.
https://activity-player.concord.org/,https://activity-player-offline.concord.org/,https://activity-player.concord.org/version/*, andhttps://activity-player-offline.concord.org/version/*, default to a versioned URL defined as a constant in the codekProductionPortalReportUrl. Every other url defaults to the master branch of the portal-report. - override:locked When set to "true" the offering is locked, independent of the portal data value. Useful for development/testing.
- firebaseApp={id}: override default firebase app. https://activity-player.concord.org/ and https://activity-player-offline.concord.org/ without a path, defaults to
report-service-proevery other url defaults toreport-service-dev. For example https://activity-player.concord.org/branch/foo will usereport-service-devby default. - token={n}: set by the portal when launching external activity, to authenticate with portal API
- auth-domain={url}: root URL for the portal which can authenticate the current user. This parameter can be
used instead of the
tokenparam. Activity Player will do an OAuth2 request to the auth-domain in order to get an access-token. It doesn't follow camelCase naming convetion to be consistent with other applications that also useauth-domainparam (eg Portal Report) - domain={n}: set by the portal when launching external activity
- answersSourceKey={id}: which source collection to save data to in firestore (defaults to own hostname)
- runkey={uuid}: set by the app if we are running in anonymous datasaving mode
- preview: prevent running in anonymous datasaving mode
- enableFirestorePersistence: uses local offline firestore cache only
- clearFirestorePersistence: clears local offline firestore cache
- __cypressLoggedIn: triggers logged in code path for Cypress tests
- __skipGetApRun: skip the ap run load when loading a page
Activity Player is Copyright 2020 (c) by the Concord Consortium and is distributed under the MIT license.
See license.md for the complete license text.