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

New: Added configurable button text (fixes #11) #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,28 @@ The extension will hide the 'buttons' `<div>` for all the questions within the a

The following attributes are set within *articles.json*.

### **_submitAll** (object)
### **\_submitAll** (object)

The Submit All object. It contains the following settings:

#### **_isEnabled** (boolean)
#### **\_isEnabled** (boolean)

Turns on and off the extension.

#### **_insertAfterBlock** (string)
#### **\_insertAfterBlock** (string)

If you want the submit button to be appended to a specific block within this article, insert the block ID here. Leave blank to default to the last block in the article.

#### **\_button** (object)

##### **buttonText** (string)

Sets the text that appears for the visual submit all button. The default value is `Submit all`.

##### **ariaLabel** (string)

Defines the text for the submit all button that is read out by screen readers. The default value is `Submit all`.

### Notes

- You should ensure that all questions within the article are set to 'do not show feedback' (either by setting `_canShowFeedback` to `false` on the individual question components or - if an assessment article - by setting `_questions._canShowFeedback` to `false` in the article's `_assessment` configuration). If you don't, all the feedback will be shown at once which is unlikely to be desirable...
Expand Down
6 changes: 5 additions & 1 deletion example.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// To go in articles.json
"_submitAll": {
"_isEnabled": true,
"_insertAfterBlock": ""
"_insertAfterBlock": "",
"_button": {
"buttonText": "Submit all",
"ariaLabel": "Submit all"
}
}
2 changes: 1 addition & 1 deletion js/SubmitAllView.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class SubmitAllView extends Backbone.View {
const {
buttonText,
ariaLabel
} = Adapt.course.get('_buttons')._submit;
} = this.model.get('_button');
const data = {
...this,
model: this.model.toJSON(),
Expand Down
25 changes: 25 additions & 0 deletions properties.schema
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,31 @@
"inputType": "Text",
"validators": [],
"help": "If you want the submit button to be appended to a specific block within this article, insert its ID here. Leave blank to default to the last block in the article."
},
"_button": {
"type": "object",
"required": false,
"legend": "Button",
"properties": {
"buttonText": {
"type": "string",
"title": "Button text",
"default": "Submit all",
"inputType": "Text",
"required": false,
"validators": [],
"translatable": true
},
"ariaLabel": {
"type": "string",
"title": "ARIA label",
"default": "Submit all",
"inputType": "Text",
"required": false,
"validators": [],
"translatable": true
}
}
}
}
}
Expand Down
15 changes: 8 additions & 7 deletions templates/submitAll.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { classes } from 'core/js/reactHelpers';
import { classes, compile } from 'core/js/reactHelpers';

export default function SubmitAll (props) {
const {
Expand All @@ -9,8 +9,9 @@ export default function SubmitAll (props) {
} = props;

return (
<div className={'btn__container'}>
<div className={'btn__response-container'}>
<div className='btn__container'>
<div className='btn__response-container'>

<button
className={classes([
'btn-text',
Expand All @@ -19,11 +20,11 @@ export default function SubmitAll (props) {
'is-disabled'
])}
aria-label={ariaLabel}
aria-disabled="true"
aria-disabled='true'
onClick={onSubmitAllButtonClicked}
>
{buttonText}
</button>
dangerouslySetInnerHTML={{ __html: compile(buttonText) }}
/>

</div>
</div>
);
Expand Down
Loading