chore: update to frontend-lib-content-components 2.6.8
This commit is contained in:
@@ -164,7 +164,7 @@ export const scoringCardHooks = (scoring, updateSettings, defaultValue) => {
|
||||
|
||||
const handleWeightChange = (event) => {
|
||||
let weight = parseFloat(event.target.value);
|
||||
if (_.isNaN(weight)) {
|
||||
if (_.isNaN(weight) || weight < 0) {
|
||||
weight = 0;
|
||||
}
|
||||
updateSettings({ scoring: { ...scoring, weight } });
|
||||
@@ -198,7 +198,7 @@ export const useAnswerSettings = (showAnswer, updateSettings) => {
|
||||
|
||||
const handleAttemptsChange = (event) => {
|
||||
let attempts = parseInt(event.target.value, 10);
|
||||
if (_.isNaN(attempts)) {
|
||||
if (_.isNaN(attempts) || attempts < 0) {
|
||||
attempts = 0;
|
||||
}
|
||||
updateSettings({ showAnswer: { ...showAnswer, afterAttempts: attempts } });
|
||||
@@ -214,7 +214,7 @@ export const useAnswerSettings = (showAnswer, updateSettings) => {
|
||||
export const timerCardHooks = (updateSettings) => ({
|
||||
handleChange: (event) => {
|
||||
let time = parseInt(event.target.value, 10);
|
||||
if (_.isNaN(time)) {
|
||||
if (_.isNaN(time) || time < 0) {
|
||||
time = 0;
|
||||
}
|
||||
updateSettings({ timeBetween: time });
|
||||
|
||||
@@ -49,6 +49,8 @@ const ScoringCard = ({
|
||||
<Form.Group>
|
||||
<Form.Control
|
||||
type="number"
|
||||
min={0}
|
||||
step={0.1}
|
||||
value={scoring.weight}
|
||||
onChange={handleWeightChange}
|
||||
floatingLabel={intl.formatMessage(messages.scoringWeightInputLabel)}
|
||||
@@ -59,6 +61,8 @@ const ScoringCard = ({
|
||||
</Form.Group>
|
||||
<Form.Group>
|
||||
<Form.Control
|
||||
type="number"
|
||||
min={0}
|
||||
value={attemptDisplayValue}
|
||||
onChange={handleOnChange}
|
||||
onBlur={handleMaxAttemptChange}
|
||||
|
||||
@@ -69,6 +69,7 @@ const ShowAnswerCard = ({
|
||||
<Form.Group className="pb-0 mb-0 mt-4">
|
||||
<Form.Control
|
||||
type="number"
|
||||
min={0}
|
||||
value={showAnswer.afterAttempts}
|
||||
onChange={handleAttemptsChange}
|
||||
floatingLabel={intl.formatMessage(messages.showAnswerAttemptsInputLabel)}
|
||||
|
||||
@@ -27,6 +27,7 @@ const TimerCard = ({
|
||||
<Form.Group>
|
||||
<Form.Control
|
||||
type="number"
|
||||
min={0}
|
||||
value={timeBetween}
|
||||
onChange={handleChange}
|
||||
floatingLabel={intl.formatMessage(messages.timerInputLabel)}
|
||||
|
||||
@@ -24,7 +24,11 @@ export const handleToleranceTypeChange = ({ updateSettings, tolerance, answers }
|
||||
|
||||
export const handleToleranceValueChange = ({ updateSettings, tolerance, answers }) => (event) => {
|
||||
if (!isAnswerRangeSet({ answers })) {
|
||||
const newTolerance = { value: event.target.value, type: tolerance.type };
|
||||
let value = parseFloat(event.target.value);
|
||||
if (value < 0) {
|
||||
value = 0;
|
||||
}
|
||||
const newTolerance = { value, type: tolerance.type };
|
||||
updateSettings({ tolerance: newTolerance });
|
||||
}
|
||||
};
|
||||
@@ -92,6 +96,8 @@ const ToleranceCard = ({
|
||||
<Form.Control
|
||||
className="mt-4"
|
||||
type="number"
|
||||
min={0}
|
||||
step={0.1}
|
||||
value={tolerance.value}
|
||||
onChange={handleToleranceValueChange({ updateSettings, tolerance, answers })}
|
||||
floatingLabel={intl.formatMessage(messages.toleranceValueInputLabel)}
|
||||
|
||||
@@ -138,7 +138,7 @@ describe('ToleranceCard', () => {
|
||||
const { queryByTestId } = render(<ToleranceCard tolerance={mockToleranceNull} {...props} />);
|
||||
expect(queryByTestId('input')).toBeFalsy();
|
||||
});
|
||||
it('Renders with intial value of tolerance', async () => {
|
||||
it('Renders with initial value of tolerance', async () => {
|
||||
const { queryByTestId } = render(<ToleranceCard tolerance={mockToleranceNumber} {...props} />);
|
||||
expect(queryByTestId('input')).toBeTruthy();
|
||||
expect(screen.getByDisplayValue('0')).toBeTruthy();
|
||||
@@ -146,7 +146,12 @@ describe('ToleranceCard', () => {
|
||||
it('Calls change function on change.', () => {
|
||||
const { queryByTestId } = render(<ToleranceCard tolerance={mockToleranceNumber} {...props} />);
|
||||
fireEvent.change(queryByTestId('input'), { target: { value: 52 } });
|
||||
expect(props.updateSettings).toHaveBeenCalledWith({ tolerance: { type: ToleranceTypes.number.type, value: '52' } });
|
||||
expect(props.updateSettings).toHaveBeenCalledWith({ tolerance: { type: ToleranceTypes.number.type, value: 52 } });
|
||||
});
|
||||
it('Resets negative value on change.', () => {
|
||||
const { queryByTestId } = render(<ToleranceCard tolerance={mockToleranceNumber} {...props} />);
|
||||
fireEvent.change(queryByTestId('input'), { target: { value: -52 } });
|
||||
expect(props.updateSettings).toHaveBeenCalledWith({ tolerance: { type: ToleranceTypes.number.type, value: 0 } });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -20,7 +20,9 @@ exports[`ScoringCard snapshot snapshot: scoring setting card 1`] = `
|
||||
<Form.Group>
|
||||
<Form.Control
|
||||
floatingLabel="Points"
|
||||
min={0}
|
||||
onChange={[MockFunction scoringCardHooks.handleWeightChange]}
|
||||
step={0.1}
|
||||
type="number"
|
||||
value={1.5}
|
||||
/>
|
||||
@@ -36,8 +38,10 @@ exports[`ScoringCard snapshot snapshot: scoring setting card 1`] = `
|
||||
<Form.Control
|
||||
disabled={false}
|
||||
floatingLabel="Attempts"
|
||||
min={0}
|
||||
onBlur={[MockFunction scoringCardHooks.handleMaxAttemptChange]}
|
||||
onChange={[MockFunction scoringCardHooks.handleOnChange]}
|
||||
type="number"
|
||||
/>
|
||||
<Form.Control.Feedback>
|
||||
<FormattedMessage
|
||||
@@ -95,7 +99,9 @@ exports[`ScoringCard snapshot snapshot: scoring setting card max attempts 1`] =
|
||||
<Form.Group>
|
||||
<Form.Control
|
||||
floatingLabel="Points"
|
||||
min={0}
|
||||
onChange={[MockFunction scoringCardHooks.handleWeightChange]}
|
||||
step={0.1}
|
||||
type="number"
|
||||
value={1.5}
|
||||
/>
|
||||
@@ -111,8 +117,10 @@ exports[`ScoringCard snapshot snapshot: scoring setting card max attempts 1`] =
|
||||
<Form.Control
|
||||
disabled={true}
|
||||
floatingLabel="Attempts"
|
||||
min={0}
|
||||
onBlur={[MockFunction scoringCardHooks.handleMaxAttemptChange]}
|
||||
onChange={[MockFunction scoringCardHooks.handleOnChange]}
|
||||
type="number"
|
||||
/>
|
||||
<Form.Control.Feedback>
|
||||
<FormattedMessage
|
||||
@@ -170,7 +178,9 @@ exports[`ScoringCard snapshot snapshot: scoring setting card zero zero weight 1`
|
||||
<Form.Group>
|
||||
<Form.Control
|
||||
floatingLabel="Points"
|
||||
min={0}
|
||||
onChange={[MockFunction scoringCardHooks.handleWeightChange]}
|
||||
step={0.1}
|
||||
type="number"
|
||||
value={0}
|
||||
/>
|
||||
@@ -186,8 +196,10 @@ exports[`ScoringCard snapshot snapshot: scoring setting card zero zero weight 1`
|
||||
<Form.Control
|
||||
disabled={false}
|
||||
floatingLabel="Attempts"
|
||||
min={0}
|
||||
onBlur={[MockFunction scoringCardHooks.handleMaxAttemptChange]}
|
||||
onChange={[MockFunction scoringCardHooks.handleOnChange]}
|
||||
type="number"
|
||||
/>
|
||||
<Form.Control.Feedback>
|
||||
<FormattedMessage
|
||||
|
||||
@@ -22,6 +22,7 @@ exports[`TimerCard snapshot snapshot: renders reset true setting card 1`] = `
|
||||
<Form.Group>
|
||||
<Form.Control
|
||||
floatingLabel="Seconds"
|
||||
min={0}
|
||||
onChange={[MockFunction timerCardHooks.handleChange]}
|
||||
type="number"
|
||||
value={5}
|
||||
|
||||
@@ -418,7 +418,7 @@ export class OLXParser {
|
||||
[type]: defaultValue,
|
||||
};
|
||||
}
|
||||
const isAnswerRange = /[([]\d*,\d*[)\]]/gm.test(numericalresponse['@_answer']);
|
||||
const isAnswerRange = /[([]\s*\d*,\s*\d*\s*[)\]]/gm.test(numericalresponse['@_answer']);
|
||||
answers.push({
|
||||
id: indexToLetterMap[answers.length],
|
||||
title: numericalresponse['@_answer'],
|
||||
|
||||
@@ -123,7 +123,7 @@ const LicenseDetails = ({
|
||||
</Form.Label>
|
||||
<ActionRow.Spacer />
|
||||
<CheckboxControl
|
||||
cchecked={details.shareAlike}
|
||||
checked={details.shareAlike}
|
||||
disabled={level === LicenseLevel.course}
|
||||
onChange={(e) => updateField({
|
||||
licenseDetails: {
|
||||
|
||||
@@ -28,13 +28,15 @@ const LicenseDisplay = ({
|
||||
<LicenseBlurb license={license} details={details} />
|
||||
<div className="x-small mt-3">{licenseDescription}</div>
|
||||
</div>
|
||||
<Hyperlink
|
||||
className="text-primary-500 x-small"
|
||||
destination="https://creativecommons.org/about"
|
||||
target="_blank"
|
||||
>
|
||||
<FormattedMessage {...messages.viewLicenseDetailsLabel} />
|
||||
</Hyperlink>
|
||||
{license === LicenseTypes.creativeCommons && (
|
||||
<Hyperlink
|
||||
className="text-primary-500 x-small"
|
||||
destination="https://creativecommons.org/about"
|
||||
target="_blank"
|
||||
>
|
||||
<FormattedMessage {...messages.viewLicenseDetailsLabel} />
|
||||
</Hyperlink>
|
||||
)}
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -26,17 +26,6 @@ exports[`LicenseDisplay snapshots snapshots: renders as expected with default pr
|
||||
FormattedMessage component with license description
|
||||
</div>
|
||||
</div>
|
||||
<Hyperlink
|
||||
className="text-primary-500 x-small"
|
||||
destination="https://creativecommons.org/about"
|
||||
target="_blank"
|
||||
>
|
||||
<FormattedMessage
|
||||
defaultMessage="View license details"
|
||||
description="Label for view license details button"
|
||||
id="authoring.videoeditor.license.viewLicenseDetailsLabel.label"
|
||||
/>
|
||||
</Hyperlink>
|
||||
</Stack>
|
||||
`;
|
||||
|
||||
@@ -66,17 +55,6 @@ exports[`LicenseDisplay snapshots snapshots: renders as expected with level set
|
||||
FormattedMessage component with license description
|
||||
</div>
|
||||
</div>
|
||||
<Hyperlink
|
||||
className="text-primary-500 x-small"
|
||||
destination="https://creativecommons.org/about"
|
||||
target="_blank"
|
||||
>
|
||||
<FormattedMessage
|
||||
defaultMessage="View license details"
|
||||
description="Label for view license details button"
|
||||
id="authoring.videoeditor.license.viewLicenseDetailsLabel.label"
|
||||
/>
|
||||
</Hyperlink>
|
||||
</Stack>
|
||||
`;
|
||||
|
||||
@@ -148,16 +126,5 @@ exports[`LicenseDisplay snapshots snapshots: renders as expected with level set
|
||||
FormattedMessage component with license description
|
||||
</div>
|
||||
</div>
|
||||
<Hyperlink
|
||||
className="text-primary-500 x-small"
|
||||
destination="https://creativecommons.org/about"
|
||||
target="_blank"
|
||||
>
|
||||
<FormattedMessage
|
||||
defaultMessage="View license details"
|
||||
description="Label for view license details button"
|
||||
id="authoring.videoeditor.license.viewLicenseDetailsLabel.label"
|
||||
/>
|
||||
</Hyperlink>
|
||||
</Stack>
|
||||
`;
|
||||
|
||||
Reference in New Issue
Block a user