fix: remove unused portions of effort estimate experiment (#560)
We are sticking with the sequence version, and abandoning the section version. This commit also marks the strings for translation, as it is a real feature now, not just an experiment. AA-659
This commit is contained in:
@@ -106,7 +106,12 @@ export function buildSimpleCourseBlocks(courseId, title, options = {}) {
|
||||
export function buildMinimalCourseBlocks(courseId, title, options = {}) {
|
||||
const sequenceBlocks = options.sequenceBlocks || [Factory.build(
|
||||
'block',
|
||||
{ display_name: 'Title of Sequence', type: 'sequential' },
|
||||
{
|
||||
display_name: 'Title of Sequence',
|
||||
effort_activities: 2,
|
||||
effort_time: 15,
|
||||
type: 'sequential',
|
||||
},
|
||||
{ courseId },
|
||||
)];
|
||||
const sectionBlocks = options.sectionBlocks || [Factory.build(
|
||||
@@ -115,8 +120,6 @@ export function buildMinimalCourseBlocks(courseId, title, options = {}) {
|
||||
type: 'chapter',
|
||||
display_name: 'Title of Section',
|
||||
complete: options.complete || false,
|
||||
effort_time: 15,
|
||||
effort_activities: 2,
|
||||
resume_block: options.resumeBlock || false,
|
||||
children: sequenceBlocks.map(block => block.id),
|
||||
},
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
import { FormattedMessage, injectIntl, intlShape } from '@edx/frontend-platform/i18n';
|
||||
|
||||
import messages from './messages';
|
||||
|
||||
// This component shows an effort estimate provided by the backend block data. Either time, activities, or both.
|
||||
// Right now it is an experiment, and AA-659 is its cleanup ticket.
|
||||
|
||||
function EffortEstimate(props) {
|
||||
const {
|
||||
@@ -12,27 +14,34 @@ function EffortEstimate(props) {
|
||||
effortTime,
|
||||
},
|
||||
className,
|
||||
intl,
|
||||
} = props;
|
||||
|
||||
// FIXME: This is not properly internationalized. This is just an experiment right now, so I chose to not mark
|
||||
// FIXME: the strings for translation. That should be fixed if/when this is made real code. AA-659
|
||||
const minuteCount = Math.ceil(effortTime / 60); // effortTime is in seconds
|
||||
const minutesAbbreviated = intl.formatMessage(messages.minutesAbbreviated, { minuteCount });
|
||||
const minutesFull = intl.formatMessage(messages.minutesFull, { minuteCount });
|
||||
const minutes = (
|
||||
<>
|
||||
{minuteCount}
|
||||
<span aria-hidden="true"> min</span>
|
||||
<span className="sr-only"> {minuteCount === 1 ? 'minute' : 'minutes'}</span>
|
||||
<span aria-hidden="true">{minutesAbbreviated}</span>
|
||||
<span className="sr-only">{minutesFull}</span>
|
||||
</>
|
||||
);
|
||||
const activities = <>{effortActivities} {effortActivities === 1 ? 'activity' : 'activities'}</>;
|
||||
const activities = intl.formatMessage(messages.activities, { activityCount: effortActivities });
|
||||
let content = null;
|
||||
|
||||
if (effortTime && effortActivities) {
|
||||
content = <>{minutes} + {activities}</>;
|
||||
content = (
|
||||
<FormattedMessage
|
||||
id="learning.effortEstimation.combinedEstimate"
|
||||
defaultMessage="{minutes} + {activities}"
|
||||
description="You can likely leave this alone, unless you want to use a full width plus or similar change"
|
||||
values={{ activities, minutes }}
|
||||
/>
|
||||
);
|
||||
} else if (effortTime) {
|
||||
content = <>{minutes}</>;
|
||||
content = minutes;
|
||||
} else if (effortActivities) {
|
||||
content = <>{activities}</>;
|
||||
content = activities;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@@ -57,6 +66,7 @@ EffortEstimate.propTypes = {
|
||||
effortTime: PropTypes.number,
|
||||
}).isRequired,
|
||||
className: PropTypes.string,
|
||||
intl: intlShape.isRequired,
|
||||
};
|
||||
|
||||
export default EffortEstimate;
|
||||
export default injectIntl(EffortEstimate);
|
||||
|
||||
20
src/shared/effort-estimate/messages.js
Normal file
20
src/shared/effort-estimate/messages.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import { defineMessages } from '@edx/frontend-platform/i18n';
|
||||
|
||||
const messages = defineMessages({
|
||||
activities: {
|
||||
id: 'learning.effortEstimation.activities',
|
||||
defaultMessage: '{activityCount, plural, one {# activity} other {# activities}}',
|
||||
},
|
||||
minutesAbbreviated: {
|
||||
id: 'learning.effortEstimation.minutesAbbreviated',
|
||||
defaultMessage: '{minuteCount, plural, other {# min}}',
|
||||
description: 'Number of minutes in a casual, shorthand manner: 5 min',
|
||||
},
|
||||
minutesFull: {
|
||||
id: 'learning.effortEstimation.minutesFull',
|
||||
defaultMessage: '{minuteCount, plural, one {# minute} other {# minutes}}',
|
||||
description: 'Number of minutes spelled out: 5 minutes',
|
||||
},
|
||||
});
|
||||
|
||||
export default messages;
|
||||
Reference in New Issue
Block a user