2.6.0 • Published 1 year ago

@brightspace-ui-labs/grade-result v2.6.0

Weekly downloads
165
License
Apache-2.0
Repository
github
Last release
1 year ago

d2l-grade-result

NPM version

Note: this is a "labs" component. While functional, these tasks are prerequisites to promotion to BrightspaceUI "official" status:

A web component used for rendering grades in Brightspace

demo screenshot of numeric grade demo screenshot of letter grade

Properties

d2l-labs-d2l-grade-result

PropertyTypeDefaultDescription
hrefstring''The Hypermedia route to power the component. This component runs off of the /grade route or an activity.
tokenstring''For authentication
disableAutoSavebooleanfalsePrevent the component from automatically saving the grade to the API when the grade is changed.
_hideTitlebooleanfalseThis property will hide the "Overall Grade" title above the component.
customManualOverrideTextstringundefinedThis properly will substitute the stock text on the "Manual Override" button.
customManualOverrideClearTextstringundefinedThis properly will substitute the stock text on the "Clear Manual Override" button.
Public Methods
MethodDescription
saveGrade(): voidThis is the method used to manually save the grade to the server when disableAutoSave = true. This method will emit @d2l-grade-result-grade-saved-success or @d2l-grade-result-grade-saved-error.
hasUnsavedChanges(): booleanDetermines whether the grade has been changed by the user and has not been saved to the server yet.

If you are only interested in rendering the presentational layer of the component, you can simply use the d2l-grade-result-presentational component.

d2l-labs-d2l-grade-result-presentational

PropertyGradeTypeTypeDefaultDescription
gradeTypeAllstring ('Numeric' or 'LetterGrade')'Numeric'Specifies the type of grade that the component is meant to render.
labelTextAllstring''The text that appears above the component.
scoreNumeratorNumericnumber0The numerator of the numeric score that is given.
scoreDenominatorNumericnumber0The denominator of the numeric score that is given.
selectedLetterGradeLetterGradestring''The current selected letter grade of the options given.
letterGradeOptionsLetterGradeObjectnullA dictionary where the key is a unique id and the value is an object containing the LetterGrade text and the PercentStart.
includeGradeButtonAllbooleanfalseDetermines whether the grades icon button is rendered.
includeReportsButtonAllbooleanfalseDetermines whether the reports icon button is rendered.
gradeButtonTooltipAllstring''The text that is inside of the tooltip when hovering over the grades button.
reportsButtonTooltipAllstring''The text that is inside of the tooltip when hovering over the reports button.
readOnlyAllbooleanfalseSet to true if the user does not have permissions to edit the grade.
isManualOverrideActiveAllbooleanfalseSet to true if the user is currently manually overriding the grade. This will display the button to 'Clear Manual Override'.
hideTitleAllbooleanfalseThis property will hide the "Overall Grade" title above the component.
customManualOverrideClearTextAllstringundefinedThis property will substitute the stock text on the "Clear Manual Override" button.
subtitleTextAllstringundefinedThis property will show the given text under the title.
requiredNumericBooleanfalseSet to true if an undefined/blank grade is not considered valid
inputLabelTextNumericstring''This property sets the label that will be used inside the aria-label and validation error tool-tips

Events

d2l-labs-d2l-grade-result

EventDescription
@d2l-grade-result-initialized-successThis event is fired when the component is successfully initialized and a grade is loaded from the API.
@d2l-grade-result-initialized-errorThis event is fired when there is an error initializing the component. This is usually caused by an invalid href or token.
@d2l-grade-result-grade-updated-successThis event is fired when the grade is successfully updated on the frontend.
@d2l-grade-result-grade-updated-errorThis event is fired when there is an error updating the grade on the frontend.
@d2l-grade-result-grade-saved-successThis event is fired when the grade is successfully saved to the server.
@d2l-grade-result-grade-saved-errorThis event is fired when there is an error while saving the grade to the server.
@d2l-grade-result-grade-button-clickThis event is fired when the grades button is clicked.
@d2l-grade-result-reports-button-clickThis event is fired when the reports button is clicked.
@d2l-grade-result-manual-override-clear-clickThis event is fired when the manual override clear is clicked.

d2l-labs-d2l-grade-result-presentational

EventDescription
@d2l-grade-result-grade-button-clickThis event is fired when the grades button is clicked.
@d2l-grade-result-reports-button-clickThis event is fired when the reports button is clicked.
@d2l-grade-result-grade-changeThis event is fired on the change of the grade for a gradeType="Numeric" grade.
@d2l-grade-result-letter-score-selectedThis event is fired on the change of the grade for a gradeType="LetterGrade" grade.
@d2l-grade-result-manual-override-clear-clickThis event is fired when the manual override clear is clicked.

Installation

To install from NPM:

npm install @brightspace-ui-labs/d2l-grade-result

Usage

<script type="module">
    import '@brightspace-ui-labs/d2l-grade-result/d2l-grade-result.js';
</script>
<d2l-labs-d2l-grade-result href="href" token="token" disableAutoSave _hideTitle>My element</d2l-labs-d2l-grade-result>

Developing, Testing and Contributing

After cloning the repo, run npm install to install dependencies.

Linting

# eslint and lit-analyzer
npm run lint

# eslint only
npm run lint:eslint

Testing

# lint & run headless unit tests
npm test

# unit tests only
npm run test:headless

# debug or run a subset of local unit tests
npm run test:headless:watch

Visual Diff Testing

This repo uses the @brightspace-ui/visual-diff utility to compare current snapshots against a set of golden snapshots stored in source control.

The golden snapshots in source control must be updated by the visual-diff GitHub Action. If a pull request results in visual differences, a draft pull request with the new goldens will automatically be opened against its branch.

To run the tests locally to help troubleshoot or develop new tests, first install these dependencies:

npm install @brightspace-ui/visual-diff@X  --no-save

Replace X with the current version the action is using.

Then run the tests:

# run visual-diff tests
npx mocha './test/**/*.visual-diff.js' -t 10000
# subset of visual-diff tests:
npx mocha './test/**/*.visual-diff.js' -t 10000 -g some-pattern
# update visual-diff goldens
npx mocha './test/**/*.visual-diff.js' -t 10000 --golden

Running the demos

To start a @web/dev-server that hosts the demo page and tests:

npm start

Versioning & Releasing

TL;DR: Commits prefixed with fix: and feat: will trigger patch and minor releases when merged to main. Read on for more details...

The semantic-release GitHub Action is called from the release.yml GitHub Action workflow to handle version changes and releasing.

Version Changes

All version changes should obey semantic versioning rules: 1. MAJOR version when you make incompatible API changes, 2. MINOR version when you add functionality in a backwards compatible manner, and 3. PATCH version when you make backwards compatible bug fixes.

The next version number will be determined from the commit messages since the previous release. Our semantic-release configuration uses the Angular convention when analyzing commits:

  • Commits which are prefixed with fix: or perf: will trigger a patch release. Example: fix: validate input before using
  • Commits which are prefixed with feat: will trigger a minor release. Example: feat: add toggle() method
  • To trigger a MAJOR release, include BREAKING CHANGE: with a space or two newlines in the footer of the commit message.
  • Other suggested prefixes which will NOT trigger a release: build:, ci:, docs:, style:, refactor: and test:. Example: docs: adding README for new component

To revert a change, add the revert: prefix to the original commit message. This will cause the reverted change to be omitted from the release notes. Example: revert: fix: validate input before using.

Releases

When a release is triggered, it will:

  • Update the version in package.json
  • Tag the commit
  • Create a GitHub release (including release notes)
  • Deploy a new package to NPM

Releasing from Maintenance Branches

Occasionally you'll want to backport a feature or bug fix to an older release. semantic-release refers to these as maintenance branches.

Maintenance branch names should be of the form: +([0-9])?(.{+([0-9]),x}).x.

Regular expressions are complicated, but this essentially means branch names should look like:

  • 1.15.x for patch releases on top of the 1.15 release (after version 1.16 exists)
  • 2.x for feature releases on top of the 2 release (after version 3 exists)
2.6.0

1 year ago

2.5.0

2 years ago

2.4.0

2 years ago

2.3.1

2 years ago

2.3.0

2 years ago

2.2.0

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago