Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e9ef204a7 | ||
|
|
f779e7fd35 | ||
|
|
a5a62922b5 | ||
|
|
2c6aa96f8e | ||
|
|
30e866128f | ||
|
|
ec81eb47d9 | ||
|
|
cd2a5ae903 | ||
|
|
7a02330e9e | ||
|
|
a929194a29 | ||
|
|
febf4d99c6 | ||
|
|
83ed8ab875 | ||
|
|
6563f54590 | ||
|
|
e1fe31dc94 | ||
|
|
8754263584 | ||
|
|
c660bd8d15 | ||
|
|
df32123f34 | ||
|
|
e81db01be2 | ||
|
|
05c3468d93 | ||
|
|
1687a6ca1a | ||
|
|
1a88343be9 |
22
package-lock.json
generated
22
package-lock.json
generated
@@ -3075,9 +3075,9 @@
|
||||
}
|
||||
},
|
||||
"@edx/paragon": {
|
||||
"version": "3.7.0",
|
||||
"resolved": "https://registry.npmjs.org/@edx/paragon/-/paragon-3.7.0.tgz",
|
||||
"integrity": "sha512-BFzPA03CjzSMEwz4utSu5Nzh9tz5kShrWHuBNZvTtwD529ObYK52C7occ9Eid2jVHtAkbwkBNQdLzz6KscCniw==",
|
||||
"version": "3.7.2",
|
||||
"resolved": "https://registry.npmjs.org/@edx/paragon/-/paragon-3.7.2.tgz",
|
||||
"integrity": "sha512-M1l/0yVc2291jqyVpOHZkaq3Hz3A2ua87P7WrxM4vk6I8HAqNJyWRasa8rPYEGJ6hz0wAhA2Eemuq7YlMHaBVA==",
|
||||
"requires": {
|
||||
"@edx/edx-bootstrap": "^1.0.0",
|
||||
"@sambego/storybook-styles": "^1.0.0",
|
||||
@@ -3112,14 +3112,14 @@
|
||||
"integrity": "sha512-gulJE5dGFo6Q61V/whS6VM4WIyrlydXfCgkE+Gxe5hjrJ8rXLLZlALq7zq2RPhOc45PSwQpJkrTnc2KgD6cvmA=="
|
||||
},
|
||||
"react": {
|
||||
"version": "16.6.1",
|
||||
"resolved": "https://registry.npmjs.org/react/-/react-16.6.1.tgz",
|
||||
"integrity": "sha512-OtawJThYlvRgm9BXK+xTL7BIlDx8vv21j+fbQDjRRUyok6y7NyjlweGorielTahLZHYIdKUoK2Dp9ByVWuMqxw==",
|
||||
"version": "16.6.3",
|
||||
"resolved": "https://registry.npmjs.org/react/-/react-16.6.3.tgz",
|
||||
"integrity": "sha512-zCvmH2vbEolgKxtqXL2wmGCUxUyNheYn/C+PD1YAjfxHC54+MhdruyhO7QieQrYsYeTxrn93PM2y0jRH1zEExw==",
|
||||
"requires": {
|
||||
"loose-envify": "^1.1.0",
|
||||
"object-assign": "^4.1.1",
|
||||
"prop-types": "^15.6.2",
|
||||
"scheduler": "^0.11.0"
|
||||
"scheduler": "^0.11.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"prop-types": {
|
||||
@@ -3545,7 +3545,7 @@
|
||||
},
|
||||
"@types/object-assign": {
|
||||
"version": "4.0.30",
|
||||
"resolved": "http://registry.npmjs.org/@types/object-assign/-/object-assign-4.0.30.tgz",
|
||||
"resolved": "https://registry.npmjs.org/@types/object-assign/-/object-assign-4.0.30.tgz",
|
||||
"integrity": "sha1-iUk3HVqZ9Dge4PHfCpt6GH4H5lI="
|
||||
},
|
||||
"@types/tapable": {
|
||||
@@ -20506,9 +20506,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"scheduler": {
|
||||
"version": "0.11.0",
|
||||
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.11.0.tgz",
|
||||
"integrity": "sha512-MAYbBfmiEHxF0W+c4CxMpEqMYK+rYF584VP/qMKSiHM6lTkBKKYOJaDiSILpJHla6hBOsVd6GucPL46o2Uq3sg==",
|
||||
"version": "0.11.2",
|
||||
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.11.2.tgz",
|
||||
"integrity": "sha512-+WCP3s3wOaW4S7C1tl3TEXp4l9lJn0ZK8G3W3WKRWmw77Z2cIFUW2MiNTMHn5sCjxN+t7N43HAOOgMjyAg5hlg==",
|
||||
"requires": {
|
||||
"loose-envify": "^1.1.0",
|
||||
"object-assign": "^4.1.1"
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
"dependencies": {
|
||||
"@edx/edx-bootstrap": "^0.4.3",
|
||||
"@edx/frontend-auth": "1.1.0",
|
||||
"@edx/paragon": "^3.7.0",
|
||||
"@edx/paragon": "^3.7.2",
|
||||
"babel-polyfill": "^6.26.0",
|
||||
"classnames": "^2.2.5",
|
||||
"email-prop-type": "^1.1.5",
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
.back-link{
|
||||
float:right;
|
||||
}
|
||||
.student-filters{
|
||||
display: flex;
|
||||
.label{
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import emailPropType from 'email-prop-type';
|
||||
import { Button, Modal, SearchField, Table, InputSelect } from '@edx/paragon';
|
||||
import { Button, InputSelect, Modal, SearchField, StatusAlert, Table } from '@edx/paragon';
|
||||
import queryString from 'query-string';
|
||||
|
||||
import { configuration } from '../../config';
|
||||
|
||||
export default class Gradebook extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
grades: [], // this.mapUserEntriesPercent(this.props.grades).sort(this.sortAlphaDesc),
|
||||
headings: [], // this.mapHeadings(this.props.grades[0]),
|
||||
filterValue: '',
|
||||
modalContent: (<h1>Hello, World!</h1>),
|
||||
modalOpen: false,
|
||||
modalModel: [{}],
|
||||
updateVal: 0,
|
||||
@@ -32,134 +27,6 @@ export default class Gradebook extends React.Component {
|
||||
this.props.getCohorts(this.props.match.params.courseId);
|
||||
}
|
||||
|
||||
sortAlphaDesc = (gradeRowA, gradeRowB) => {
|
||||
const a = gradeRowA.username.toUpperCase();
|
||||
const b = gradeRowB.username.toUpperCase();
|
||||
if (a < b) {
|
||||
return -1;
|
||||
}
|
||||
if (a > b) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
sortAlphaAsc = (gradeRowA, gradeRowB) => {
|
||||
const a = gradeRowA.username.toUpperCase();
|
||||
const b = gradeRowB.username.toUpperCase();
|
||||
if (a < b) {
|
||||
return 1;
|
||||
}
|
||||
if (a > b) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
sortNumerically = (colKey, direction) => {
|
||||
function sortNumAsc(gradeRowA, gradeRowB) {
|
||||
if (gradeRowA[colKey] < gradeRowB[colKey]) {
|
||||
return -1;
|
||||
}
|
||||
if (gradeRowA[colKey] > gradeRowB[colKey]) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function sortNumDesc(gradeRowA, gradeRowB) {
|
||||
if (gradeRowA[colKey] < gradeRowB[colKey]) {
|
||||
return 1;
|
||||
}
|
||||
if (gradeRowA[colKey] > gradeRowB[colKey]) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
this.setState({ grades: [...this.state.grades].sort(direction === 'desc' ? sortNumDesc : sortNumAsc) });
|
||||
}
|
||||
|
||||
mapHeadings = (entry) => {
|
||||
if (entry) {
|
||||
const results = [{
|
||||
label: 'Username',
|
||||
key: 'username',
|
||||
columnSortable: true,
|
||||
onSort: (direction) => {
|
||||
this.setState({
|
||||
grades: [...this.state.grades].sort(direction === 'desc' ? this.sortAlphaDesc : this.sortAlphaAsc),
|
||||
});
|
||||
},
|
||||
}];
|
||||
|
||||
const assignmentHeadings = entry.section_breakdown
|
||||
.filter(section => section.is_graded && section.label)
|
||||
.map(s => ({
|
||||
label: s.label,
|
||||
key: s.label,
|
||||
columnSortable: true,
|
||||
onSort: (direction) => { this.sortNumerically(s.label, direction); },
|
||||
}));
|
||||
|
||||
const totals = [{
|
||||
label: 'Total',
|
||||
key: 'total',
|
||||
columnSortable: true,
|
||||
onSort: (direction) => { this.sortNumerically('total', direction); },
|
||||
}];
|
||||
|
||||
return results.concat(assignmentHeadings).concat(totals);
|
||||
}
|
||||
return [];
|
||||
};
|
||||
|
||||
mapHeadingsHw = (entry) => {
|
||||
const results = [{
|
||||
label: 'Username',
|
||||
key: 'username',
|
||||
columnSortable: true,
|
||||
onSort: (direction) => {
|
||||
this.setState({
|
||||
grades: [...this.state.grades].sort(direction === 'desc' ? this.sortAlphaDesc : this.sortAlphaAsc),
|
||||
});
|
||||
},
|
||||
}];
|
||||
const assignmentHeadings = entry.section_breakdown
|
||||
.filter(section => section.is_graded && section.label && section.category == 'Homework')
|
||||
.map(s => ({
|
||||
label: s.label,
|
||||
key: s.label,
|
||||
columnSortable: true,
|
||||
onSort: (direction) => { this.sortNumerically(s.label, direction); },
|
||||
}));
|
||||
|
||||
return results.concat(assignmentHeadings);
|
||||
};
|
||||
|
||||
mapHeadingsExam = (entry) => {
|
||||
const results = [{
|
||||
label: 'Username',
|
||||
key: 'username',
|
||||
columnSortable: true,
|
||||
onSort: (direction) => {
|
||||
this.setState({
|
||||
grades: [...this.state.grades].sort(direction === 'desc' ? this.sortAlphaDesc : this.sortAlphaAsc),
|
||||
});
|
||||
},
|
||||
}];
|
||||
const assignmentHeadings = entry.section_breakdown
|
||||
.filter(section => section.is_graded && section.label && section.category == 'Exam')
|
||||
.map(s => ({
|
||||
label: s.label,
|
||||
key: s.label,
|
||||
columnSortable: true,
|
||||
onSort: (direction) => { this.sortNumerically(s.label, direction); },
|
||||
}));
|
||||
|
||||
return results.concat(assignmentHeadings);
|
||||
};
|
||||
|
||||
setNewModalState = (userEntry, subsection) => {
|
||||
this.setState({
|
||||
modalModel: [{
|
||||
@@ -170,7 +37,7 @@ export default class Gradebook extends React.Component {
|
||||
<input
|
||||
style={{ width: '25px' }}
|
||||
type="text"
|
||||
onChange={(event) => this.setState({updateVal: event.target.value})}
|
||||
onChange={event => this.setState({ updateVal: event.target.value })}
|
||||
/> / {subsection.score_possible}
|
||||
</span>
|
||||
),
|
||||
@@ -179,58 +46,28 @@ export default class Gradebook extends React.Component {
|
||||
modalOpen: true,
|
||||
updateModuleId: subsection.module_id,
|
||||
updateUserId: userEntry.user_id,
|
||||
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
mapUserEntriesPercent = entries => entries.map((entry) => {
|
||||
const results = { username: entry.username };
|
||||
const assignments = entry.section_breakdown
|
||||
.filter(section => section.is_graded)
|
||||
.reduce((acc, subsection) => {
|
||||
acc[subsection.label] = (
|
||||
<button
|
||||
className="btn btn-header link-style"
|
||||
onClick={() => this.setNewModalState(entry, subsection)}
|
||||
>
|
||||
{subsection.percent}
|
||||
</button>);
|
||||
return acc;
|
||||
}, {});
|
||||
const totals = { total: entry.percent * 100 };
|
||||
return Object.assign(results, assignments, totals);
|
||||
});
|
||||
|
||||
mapUserEntriesAbsolute = entries => entries.map((entry) => {
|
||||
const results = { username: entry.username };
|
||||
const assignments = entry.section_breakdown
|
||||
.filter(section => section.is_graded)
|
||||
.reduce((acc, subsection) => {
|
||||
acc[subsection.label] = (
|
||||
<button
|
||||
className="btn btn-header link-style"
|
||||
onClick={() => this.setNewModalState(entry, subsection)}
|
||||
>
|
||||
{subsection.score_earned}/{subsection.score_possible}
|
||||
</button>);
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
const totals = { total: entry.percent * 100 };
|
||||
return Object.assign(results, assignments, totals);
|
||||
});
|
||||
|
||||
handleAdjustedGradeClick = () => {
|
||||
this.props.updateGrades(this.props.match.params.courseId, [
|
||||
{
|
||||
'user_id': this.state.updateUserId,
|
||||
'usage_id': this.state.updateModuleId,
|
||||
'grade': {
|
||||
'earned_graded_override': this.state.updateVal,
|
||||
user_id: this.state.updateUserId,
|
||||
usage_id: this.state.updateModuleId,
|
||||
grade: {
|
||||
earned_graded_override: this.state.updateVal,
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
this.setState({
|
||||
modalModel: [{}],
|
||||
modalOpen: false,
|
||||
updateModuleId: null,
|
||||
updateUserId: null,
|
||||
});
|
||||
}
|
||||
|
||||
updateQueryParams = (queryKey, queryValue) => {
|
||||
const parsed = queryString.parse(this.props.location.search);
|
||||
parsed[queryKey] = queryValue;
|
||||
@@ -238,27 +75,27 @@ export default class Gradebook extends React.Component {
|
||||
};
|
||||
|
||||
mapCohortsEntries = (entries) => {
|
||||
let mapped = entries.map(entry => ({
|
||||
const mapped = entries.map(entry => ({
|
||||
id: entry.id,
|
||||
label: entry.name,
|
||||
}));
|
||||
mapped.unshift({id:0, label:'Cohorts'});
|
||||
mapped.unshift({ id: 0, label: 'Cohort-All' });
|
||||
return mapped;
|
||||
};
|
||||
|
||||
mapTracksEntries = (entries) => {
|
||||
let mapped = entries.map(entry => ({
|
||||
const mapped = entries.map(entry => ({
|
||||
id: entry.slug,
|
||||
label: entry.name,
|
||||
}));
|
||||
mapped.unshift({ label:'Tracks' });
|
||||
mapped.unshift({ label: 'Track-All' });
|
||||
return mapped;
|
||||
};
|
||||
|
||||
updateTracks = (event) => {
|
||||
const selectedTrackItem = this.props.tracks.find(x=>x.name===event);
|
||||
const selectedTrackItem = this.props.tracks.find(x => x.name === event);
|
||||
let selectedTrackSlug = null;
|
||||
if(selectedTrackItem) {
|
||||
if (selectedTrackItem) {
|
||||
selectedTrackSlug = selectedTrackItem.slug;
|
||||
}
|
||||
this.props.getUserGrades(
|
||||
@@ -266,14 +103,14 @@ export default class Gradebook extends React.Component {
|
||||
this.props.selectedCohort,
|
||||
selectedTrackSlug,
|
||||
);
|
||||
const updatedQueryStrings = this.updateQueryParams('track', selectedTrackSlug)
|
||||
const updatedQueryStrings = this.updateQueryParams('track', selectedTrackSlug);
|
||||
this.props.history.push(updatedQueryStrings);
|
||||
};
|
||||
|
||||
updateCohorts = (event) => {
|
||||
const selectedCohortItem = this.props.cohorts.find(x=>x.name===event);
|
||||
const selectedCohortItem = this.props.cohorts.find(x => x.name === event);
|
||||
let selectedCohortId = null;
|
||||
if(selectedCohortItem) {
|
||||
if (selectedCohortItem) {
|
||||
selectedCohortId = selectedCohortItem.id;
|
||||
}
|
||||
this.props.getUserGrades(
|
||||
@@ -281,7 +118,7 @@ export default class Gradebook extends React.Component {
|
||||
selectedCohortId,
|
||||
this.props.selectedTrack,
|
||||
);
|
||||
const updatedQueryStrings = this.updateQueryParams('cohort', selectedCohortId)
|
||||
const updatedQueryStrings = this.updateQueryParams('cohort', selectedCohortId);
|
||||
this.props.history.push(updatedQueryStrings);
|
||||
};
|
||||
|
||||
@@ -301,12 +138,60 @@ export default class Gradebook extends React.Component {
|
||||
return 'Tracks';
|
||||
};
|
||||
|
||||
formatter = {
|
||||
percent: entries => entries.map((entry) => {
|
||||
const results = { username: entry.username };
|
||||
const assignments = entry.section_breakdown
|
||||
.filter(section => section.is_graded)
|
||||
.reduce((acc, subsection) => {
|
||||
acc[subsection.label] = (
|
||||
<button
|
||||
className="btn btn-header link-style"
|
||||
onClick={() => this.setNewModalState(entry, subsection)}
|
||||
>
|
||||
{subsection.percent}
|
||||
</button>);
|
||||
return acc;
|
||||
}, {});
|
||||
const totals = { total: entry.percent * 100 };
|
||||
return Object.assign(results, assignments, totals);
|
||||
}),
|
||||
|
||||
absolute: entries => entries.map((entry) => {
|
||||
const results = { username: entry.username };
|
||||
const assignments = entry.section_breakdown
|
||||
.filter(section => section.is_graded)
|
||||
.reduce((acc, subsection) => {
|
||||
acc[subsection.label] = (
|
||||
<button
|
||||
className="btn btn-header link-style"
|
||||
onClick={() => this.setNewModalState(entry, subsection)}
|
||||
>
|
||||
{subsection.score_earned}/{subsection.score_possible}
|
||||
</button>);
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
const totals = { total: entry.percent * 100 };
|
||||
return Object.assign(results, assignments, totals);
|
||||
}),
|
||||
};
|
||||
|
||||
lmsInstructorDashboardUrl = courseId => `${configuration.LMS_BASE_URL}/courses/${courseId}/instructor`;
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="d-flex justify-content-center">
|
||||
<div className="card" style={{ width: '50rem' }}>
|
||||
<div className="card-body">
|
||||
<a
|
||||
href={this.lmsInstructorDashboardUrl(this.props.match.params.courseId)}
|
||||
className="back-link"
|
||||
>
|
||||
Back to Dashboard
|
||||
</a>
|
||||
<h1>Gradebook</h1>
|
||||
<h3> {this.props.match.params.courseId}</h3>
|
||||
<hr />
|
||||
<div className="d-flex justify-content-between" >
|
||||
<div>
|
||||
@@ -315,13 +200,13 @@ export default class Gradebook extends React.Component {
|
||||
<span>
|
||||
<input
|
||||
id="score-view-percent"
|
||||
className="ml-2"
|
||||
className="ml-2 mr-1"
|
||||
type="radio"
|
||||
name="score-view"
|
||||
value="percent"
|
||||
onClick={() => this.setState({ grades: this.mapUserEntriesPercent(this.props.results).sort(this.sortAlphaDesc) })}
|
||||
onClick={() => this.props.toggleFormat('percent')}
|
||||
/>
|
||||
<label className="ml-2 mr-2" htmlFor="score-view-percent">Percent</label>
|
||||
<label className="mr-2" htmlFor="score-view-percent">Percent</label>
|
||||
</span>
|
||||
<span>
|
||||
<input
|
||||
@@ -329,50 +214,48 @@ export default class Gradebook extends React.Component {
|
||||
type="radio"
|
||||
name="score-view"
|
||||
value="absolute"
|
||||
onClick={() => this.setState({ grades: this.mapUserEntriesAbsolute(this.props.results).sort(this.sortAlphaDesc) })}
|
||||
className="mr-1"
|
||||
onClick={() => this.props.toggleFormat('absolute')}
|
||||
/>
|
||||
<label className="ml-2 mr-2" htmlFor="score-view-absolute">Absolute</label>
|
||||
<label htmlFor="score-view-absolute">Absolute</label>
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
Category:
|
||||
<span>
|
||||
<label className="ml-2 mr-2" htmlFor="category-all">
|
||||
<input
|
||||
id="category-all"
|
||||
className="ml-2"
|
||||
type="radio"
|
||||
name="category"
|
||||
value="all"
|
||||
onClick={() =>
|
||||
this.setState({ headings: this.mapHeadings(this.props.results[0]) })}
|
||||
/>
|
||||
<input
|
||||
id="category-all"
|
||||
className="ml-2 mr-1"
|
||||
type="radio"
|
||||
name="category"
|
||||
value="all"
|
||||
onClick={() => this.props.filterColumns('all', this.props.grades[0])}
|
||||
/>
|
||||
<label className="mr-2" htmlFor="category-all">
|
||||
All
|
||||
</label>
|
||||
</span>
|
||||
<span>
|
||||
<input
|
||||
id="category-homework"
|
||||
className="ml-2"
|
||||
className="mr-1"
|
||||
type="radio"
|
||||
name="category"
|
||||
value="homework"
|
||||
onClick={() =>
|
||||
this.setState({
|
||||
headings: this.mapHeadingsHw(this.props.results[0]),
|
||||
})}
|
||||
onClick={() => this.props.filterColumns('hw', this.props.grades[0])}
|
||||
/>
|
||||
<label className="ml-2 mr-2" htmlFor="category-homework">Homework</label>
|
||||
<label className="mr-2" htmlFor="category-homework">Homework</label>
|
||||
</span>
|
||||
<span>
|
||||
<label className="ml-2 mr-2" htmlFor="Exam">
|
||||
<input
|
||||
id="category-exam"
|
||||
type="radio"
|
||||
name="category"
|
||||
value="exam"
|
||||
onClick={() => this.setState({ headings: this.mapHeadingsExam(this.props.results[0]) })}
|
||||
/>
|
||||
<input
|
||||
id="category-exam"
|
||||
type="radio"
|
||||
name="category"
|
||||
value="exam"
|
||||
className="ml-2 mr-1"
|
||||
onClick={() => this.props.filterColumns('exam', this.props.grades[0])}
|
||||
/>
|
||||
<label htmlFor="category-exam">
|
||||
Exam
|
||||
</label>
|
||||
</span>
|
||||
@@ -384,7 +267,7 @@ export default class Gradebook extends React.Component {
|
||||
</span>
|
||||
{this.props.tracks.length > 0 &&
|
||||
<InputSelect
|
||||
name='Tracks'
|
||||
name="Tracks"
|
||||
value={this.mapSelectedTrackEntry(this.props.selectedTrack)}
|
||||
options={this.mapTracksEntries(this.props.tracks)}
|
||||
onChange={this.updateTracks}
|
||||
@@ -392,7 +275,7 @@ export default class Gradebook extends React.Component {
|
||||
}
|
||||
{this.props.cohorts.length > 0 &&
|
||||
<InputSelect
|
||||
name='Cohorts'
|
||||
name="Cohorts"
|
||||
value={this.mapSelectedCohortEntry(this.props.selectedCohort)}
|
||||
options={this.mapCohortsEntries(this.props.cohorts)}
|
||||
onChange={this.updateCohorts}
|
||||
@@ -403,7 +286,7 @@ export default class Gradebook extends React.Component {
|
||||
</div>
|
||||
<div>
|
||||
<div style={{ marginLeft: '10px', marginBottom: '10px' }}>
|
||||
<a href="https://www.google./com">Download Grade Report</a>
|
||||
<a href={`${this.lmsInstructorDashboardUrl(this.props.match.params.courseId)}#view-data_download`}>Download Grade Report</a>
|
||||
</div>
|
||||
<SearchField
|
||||
onSubmit={value => this.props.searchForUser(this.props.match.params.courseId, value, this.props.selectedCohort, this.props.selectedTrack)}
|
||||
@@ -414,12 +297,18 @@ export default class Gradebook extends React.Component {
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
<StatusAlert
|
||||
alertType="success"
|
||||
dialog="The grade has been successfully edited."
|
||||
onClose={() => this.props.updateBanner(false)}
|
||||
open={this.props.showSuccess}
|
||||
/>
|
||||
<div className="gbook">
|
||||
<Table
|
||||
columns={this.mapHeadings(this.props.grades[0])}
|
||||
data={this.mapUserEntriesPercent(this.props.grades)}
|
||||
columns={this.props.headings}
|
||||
data={this.formatter[this.props.format](this.props.grades)}
|
||||
tableSortable
|
||||
defaultSortDirection="desc"
|
||||
defaultSortDirection="asc"
|
||||
defaultSortedColumn="username"
|
||||
/>
|
||||
</div>
|
||||
@@ -430,12 +319,9 @@ export default class Gradebook extends React.Component {
|
||||
<div>
|
||||
<h3>{this.state.modalModel[0].assignmentName}</h3>
|
||||
<Table
|
||||
columns={[{ label: 'Username', key: 'username' }, { label: 'Current grade', key: 'currentGrade' }, { label: 'Adjusted grade', key: 'adjustedGrade' }]}
|
||||
data={this.state.modalModel}
|
||||
tableSortable
|
||||
defaultSortDirection="desc"
|
||||
defaultSortedColumn="username"
|
||||
/>
|
||||
columns={[{ label: 'Username', key: 'username' }, { label: 'Current grade', key: 'currentGrade' }, { label: 'Adjusted grade', key: 'adjustedGrade' }]}
|
||||
data={this.state.modalModel}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
buttons={[
|
||||
@@ -443,7 +329,7 @@ export default class Gradebook extends React.Component {
|
||||
label="Edit Grade"
|
||||
buttonType="primary"
|
||||
onClick={this.handleAdjustedGradeClick}
|
||||
/>
|
||||
/>,
|
||||
]}
|
||||
onClose={() => this.setState({
|
||||
modalOpen: false,
|
||||
|
||||
@@ -1,17 +1,27 @@
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import Gradebook from '../../components/Gradebook';
|
||||
import { fetchGrades, fetchMatchingUserGrades, updateGrades } from '../../data/actions/grades';
|
||||
import {
|
||||
fetchGrades,
|
||||
fetchMatchingUserGrades,
|
||||
updateGrades,
|
||||
toggleGradeFormat,
|
||||
filterColumns,
|
||||
updateBanner,
|
||||
} from '../../data/actions/grades';
|
||||
import { fetchCohorts } from '../../data/actions/cohorts';
|
||||
import { fetchTracks } from '../../data/actions/tracks';
|
||||
|
||||
const mapStateToProps = state => (
|
||||
{
|
||||
grades: state.grades.results,
|
||||
headings: state.grades.headings,
|
||||
tracks: state.tracks.results,
|
||||
cohorts: state.cohorts.results,
|
||||
selectedTrack: state.grades.selectedTrack,
|
||||
selectedCohort: state.grades.selectedCohort,
|
||||
format: state.grades.gradeFormat,
|
||||
showSuccess: state.grades.showSuccess,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -32,6 +42,15 @@ const mapDispatchToProps = dispatch => (
|
||||
updateGrades: (courseId, updateData) => {
|
||||
dispatch(updateGrades(courseId, updateData));
|
||||
},
|
||||
toggleFormat: (formatType) => {
|
||||
dispatch(toggleGradeFormat(formatType));
|
||||
},
|
||||
filterColumns: (filterType, exampleUser) => {
|
||||
dispatch(filterColumns(filterType, exampleUser));
|
||||
},
|
||||
updateBanner: (showSuccess) => {
|
||||
dispatch(updateBanner(showSuccess));
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
import 'whatwg-fetch';
|
||||
import {
|
||||
STARTED_FETCHING_COMMENT,
|
||||
FINISHED_FETCHING_COMMENT,
|
||||
ERROR_FETCHING_COMMENT,
|
||||
GET_COMMENT,
|
||||
} from '../constants/actionTypes/comment';
|
||||
|
||||
const startedFetchingComment = () => ({ type: STARTED_FETCHING_COMMENT });
|
||||
const finishedFetchingComment = () => ({ type: FINISHED_FETCHING_COMMENT });
|
||||
const errorFetchingComment = () => ({ type: ERROR_FETCHING_COMMENT });
|
||||
const getComment = comment => ({ type: GET_COMMENT, comment });
|
||||
const fetchComment = commentId => (
|
||||
(dispatch) => {
|
||||
dispatch(startedFetchingComment());
|
||||
return fetch(`https://jsonplaceholder.typicode.com/comments/${commentId}`)
|
||||
.then((response) => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
}
|
||||
|
||||
throw new Error();
|
||||
})
|
||||
.then((data) => {
|
||||
dispatch(getComment(data));
|
||||
dispatch(finishedFetchingComment());
|
||||
})
|
||||
.catch(() => dispatch(errorFetchingComment()));
|
||||
}
|
||||
);
|
||||
|
||||
export {
|
||||
startedFetchingComment,
|
||||
finishedFetchingComment,
|
||||
errorFetchingComment,
|
||||
getComment,
|
||||
fetchComment,
|
||||
};
|
||||
@@ -6,39 +6,75 @@ import {
|
||||
GRADE_UPDATE_REQUEST,
|
||||
GRADE_UPDATE_SUCCESS,
|
||||
GRADE_UPDATE_FAILURE,
|
||||
TOGGLE_GRADE_FORMAT,
|
||||
SORT_GRADES,
|
||||
FILTER_COLUMNS,
|
||||
UPDATE_BANNER,
|
||||
} from '../constants/actionTypes/grades';
|
||||
import LmsApiService from '../services/LmsApiService';
|
||||
import store from '../store';
|
||||
import { headingMapper, gradeSortMap, sortAlphaAsc } from './utils';
|
||||
|
||||
|
||||
const sortGrades = (columnName, direction) => {
|
||||
const sortFn = gradeSortMap(columnName, direction);
|
||||
const { results } = store.getState().grades;
|
||||
results.sort(sortFn);
|
||||
|
||||
/* have to make a copy of results or React wont know there was
|
||||
* a change and wont trigger a re-render
|
||||
*/
|
||||
return ({ type: SORT_GRADES, results: [...results] });
|
||||
};
|
||||
|
||||
const startedFetchingGrades = () => ({ type: STARTED_FETCHING_GRADES });
|
||||
const finishedFetchingGrades = () => ({ type: FINISHED_FETCHING_GRADES });
|
||||
const errorFetchingGrades = () => ({ type: ERROR_FETCHING_GRADES });
|
||||
const gotGrades = (grades, cohort, track) => ({
|
||||
const gotGrades = (grades, cohort, track, headings) => ({
|
||||
type: GOT_GRADES,
|
||||
grades,
|
||||
cohort,
|
||||
track,
|
||||
headings,
|
||||
});
|
||||
|
||||
const gradeUpdateRequest = () => ({ type: GRADE_UPDATE_REQUEST });
|
||||
const gradeUpdateSuccess = responseData => ({
|
||||
type: GRADE_UPDATE_SUCCESS,
|
||||
payload: { responseData },
|
||||
})
|
||||
});
|
||||
const gradeUpdateFailure = error => ({
|
||||
type: GRADE_UPDATE_FAILURE,
|
||||
payload: { error },
|
||||
});
|
||||
|
||||
const fetchGrades = (courseId, cohort, track) => (
|
||||
|
||||
const toggleGradeFormat = formatType => ({ type: TOGGLE_GRADE_FORMAT, formatType });
|
||||
|
||||
const filterColumns = (filterType, exampleUser) => (
|
||||
dispatch => ({
|
||||
type: FILTER_COLUMNS,
|
||||
headings: headingMapper[filterType](dispatch, exampleUser),
|
||||
}));
|
||||
|
||||
const updateBanner = showSuccess => ({ type: UPDATE_BANNER, showSuccess });
|
||||
|
||||
const fetchGrades = (courseId, cohort, track, showSuccess) => (
|
||||
(dispatch) => {
|
||||
dispatch(startedFetchingGrades());
|
||||
return LmsApiService.fetchGradebookData(courseId, null, cohort, track)
|
||||
.then(response => response.data)
|
||||
.then((data) => {
|
||||
dispatch(gotGrades(data.results, cohort, track));
|
||||
dispatch(gotGrades(
|
||||
data.results.sort(sortAlphaAsc),
|
||||
cohort,
|
||||
track,
|
||||
headingMapper.all(dispatch, data.results[0]),
|
||||
));
|
||||
dispatch(finishedFetchingGrades());
|
||||
dispatch(updateBanner(!!showSuccess));
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch(() => {
|
||||
dispatch(errorFetchingGrades());
|
||||
});
|
||||
}
|
||||
@@ -50,10 +86,15 @@ const fetchMatchingUserGrades = (courseId, searchText, cohort, track) => (
|
||||
return LmsApiService.fetchGradebookData(courseId, searchText, cohort, track)
|
||||
.then(response => response.data)
|
||||
.then((data) => {
|
||||
dispatch(gotGrades(data.results, cohort, track));
|
||||
dispatch(gotGrades(
|
||||
data.results.sort(sortAlphaAsc),
|
||||
cohort,
|
||||
track,
|
||||
headingMapper.all(dispatch, data.results[0]),
|
||||
));
|
||||
dispatch(finishedFetchingGrades());
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch(() => {
|
||||
dispatch(errorFetchingGrades());
|
||||
});
|
||||
}
|
||||
@@ -65,7 +106,8 @@ const updateGrades = (courseId, updateData) => (
|
||||
return LmsApiService.updateGradebookData(courseId, updateData)
|
||||
.then(response => response.data)
|
||||
.then((data) => {
|
||||
dispatch(gradeUpdateSuccess(data))
|
||||
dispatch(gradeUpdateSuccess(data));
|
||||
dispatch(fetchGrades(courseId, null, null, true));
|
||||
})
|
||||
.catch((error) => {
|
||||
dispatch(gradeUpdateFailure(error));
|
||||
@@ -84,4 +126,8 @@ export {
|
||||
gradeUpdateSuccess,
|
||||
gradeUpdateFailure,
|
||||
updateGrades,
|
||||
toggleGradeFormat,
|
||||
sortGrades,
|
||||
filterColumns,
|
||||
updateBanner,
|
||||
};
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
import 'whatwg-fetch';
|
||||
|
||||
import {
|
||||
STARTED_FETCHING_POSTS,
|
||||
FINISHED_FETCHING_POSTS,
|
||||
GET_POSTS,
|
||||
} from '../constants/actionTypes/posts';
|
||||
|
||||
const startedFetchingPosts = () => (
|
||||
{
|
||||
type: STARTED_FETCHING_POSTS,
|
||||
}
|
||||
);
|
||||
|
||||
const finishedFetchingPosts = () => (
|
||||
{
|
||||
type: FINISHED_FETCHING_POSTS,
|
||||
}
|
||||
);
|
||||
|
||||
const getPosts = posts => (
|
||||
{
|
||||
type: GET_POSTS,
|
||||
posts,
|
||||
}
|
||||
);
|
||||
|
||||
const fetchPosts = () => (
|
||||
(dispatch) => {
|
||||
dispatch(startedFetchingPosts());
|
||||
return fetch('https://jsonplaceholder.typicode.com/posts')
|
||||
// TODO: handle response error
|
||||
.then(response => response.json())
|
||||
.then((data) => {
|
||||
dispatch(getPosts(data));
|
||||
dispatch(finishedFetchingPosts());
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
export {
|
||||
startedFetchingPosts,
|
||||
finishedFetchingPosts,
|
||||
getPosts,
|
||||
fetchPosts,
|
||||
};
|
||||
@@ -1,65 +0,0 @@
|
||||
import configureMockStore from 'redux-mock-store';
|
||||
import thunk from 'redux-thunk';
|
||||
import fetchMock from 'fetch-mock';
|
||||
|
||||
import {
|
||||
startedFetchingPosts,
|
||||
finishedFetchingPosts,
|
||||
getPosts,
|
||||
fetchPosts,
|
||||
} from './posts';
|
||||
import {
|
||||
STARTED_FETCHING_POSTS,
|
||||
GET_POSTS,
|
||||
FINISHED_FETCHING_POSTS,
|
||||
} from '../constants/actionTypes/posts';
|
||||
|
||||
const mockStore = configureMockStore([thunk]);
|
||||
|
||||
describe('actions', () => {
|
||||
afterEach(() => {
|
||||
fetchMock.reset();
|
||||
fetchMock.restore();
|
||||
});
|
||||
|
||||
it('sends started fetching post action', () => {
|
||||
const expected = { type: STARTED_FETCHING_POSTS };
|
||||
expect(startedFetchingPosts()).toEqual(expected);
|
||||
});
|
||||
|
||||
it('sends finished fetching posts', () => {
|
||||
const expected = { type: FINISHED_FETCHING_POSTS };
|
||||
expect(finishedFetchingPosts()).toEqual(expected);
|
||||
});
|
||||
|
||||
it('sends posts', () => {
|
||||
const data = 'data';
|
||||
const expected = { type: GET_POSTS, posts: data };
|
||||
expect(getPosts(data)).toEqual(expected);
|
||||
});
|
||||
|
||||
it('fetches posts', () => {
|
||||
const posts = [
|
||||
{
|
||||
id: 1,
|
||||
title: 'title',
|
||||
body: 'body',
|
||||
},
|
||||
];
|
||||
fetchMock.getOnce('https://jsonplaceholder.typicode.com/posts', {
|
||||
body: JSON.stringify({ posts }),
|
||||
headers: { 'content-type': 'application/json' },
|
||||
});
|
||||
const store = mockStore({ posts: [] });
|
||||
|
||||
const expectedActions = [
|
||||
{ type: STARTED_FETCHING_POSTS },
|
||||
{ type: GET_POSTS, posts: { posts } },
|
||||
{ type: FINISHED_FETCHING_POSTS },
|
||||
];
|
||||
|
||||
return store.dispatch(fetchPosts()).then(() => {
|
||||
expect(store.getActions()).toEqual(expectedActions);
|
||||
});
|
||||
});
|
||||
});
|
||||
142
src/data/actions/utils.js
Normal file
142
src/data/actions/utils.js
Normal file
@@ -0,0 +1,142 @@
|
||||
import { sortGrades } from './grades';
|
||||
|
||||
const sortAlphaAsc = (gradeRowA, gradeRowB) => {
|
||||
const a = gradeRowA.username.toUpperCase();
|
||||
const b = gradeRowB.username.toUpperCase();
|
||||
if (a < b) {
|
||||
return -1;
|
||||
}
|
||||
if (a > b) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
const sortAlphaDesc = (gradeRowA, gradeRowB) => {
|
||||
const a = gradeRowA.username.toUpperCase();
|
||||
const b = gradeRowB.username.toUpperCase();
|
||||
if (a < b) {
|
||||
return 1;
|
||||
}
|
||||
if (a > b) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
const sortNumerically = (colKey, direction) => {
|
||||
function getPercents(gradeRowA, gradeRowB) {
|
||||
if (colKey !== 'total') {
|
||||
return {
|
||||
a: gradeRowA.section_breakdown.find(x => x.label === colKey).percent,
|
||||
b: gradeRowB.section_breakdown.find(x => x.label === colKey).percent,
|
||||
};
|
||||
}
|
||||
return {
|
||||
a: gradeRowA.percent,
|
||||
b: gradeRowB.percent,
|
||||
};
|
||||
}
|
||||
|
||||
function sortNumAsc(gradeRowA, gradeRowB) {
|
||||
const { a, b } = getPercents(gradeRowA, gradeRowB);
|
||||
return a - b;
|
||||
}
|
||||
|
||||
function sortNumDesc(gradeRowA, gradeRowB) {
|
||||
const { a, b } = getPercents(gradeRowA, gradeRowB);
|
||||
return b - a;
|
||||
}
|
||||
|
||||
return direction === 'desc' ? sortNumDesc : sortNumAsc;
|
||||
};
|
||||
|
||||
function gradeSortMap(columnName, direction) {
|
||||
if (columnName === 'username' && direction === 'desc') {
|
||||
return sortAlphaDesc;
|
||||
} else if (columnName === 'username') {
|
||||
return sortAlphaAsc;
|
||||
}
|
||||
return sortNumerically(columnName, direction);
|
||||
}
|
||||
|
||||
const headingMapper = {
|
||||
all: (dispatch, entry) => {
|
||||
if (entry) {
|
||||
const results = [{
|
||||
label: 'Username',
|
||||
key: 'username',
|
||||
columnSortable: true,
|
||||
onSort: (direction) => { dispatch(sortGrades('username', direction)); },
|
||||
}];
|
||||
|
||||
const assignmentHeadings = entry.section_breakdown
|
||||
.filter(section => section.is_graded && section.label)
|
||||
.map(s => ({
|
||||
label: s.label,
|
||||
key: s.label,
|
||||
columnSortable: true,
|
||||
onSort: direction => dispatch(sortGrades(s.label, direction)),
|
||||
}));
|
||||
|
||||
const totals = [{
|
||||
label: 'Total',
|
||||
key: 'total',
|
||||
columnSortable: true,
|
||||
onSort: direction => dispatch(sortGrades('total', direction)),
|
||||
}];
|
||||
|
||||
return results.concat(assignmentHeadings).concat(totals);
|
||||
}
|
||||
return [];
|
||||
},
|
||||
hw: (dispatch, entry) => {
|
||||
const results = [{
|
||||
label: 'Username',
|
||||
key: 'username',
|
||||
columnSortable: true,
|
||||
onSort: (direction) => {
|
||||
this.setState({
|
||||
grades: [...this.state.grades].sort(direction === 'desc' ? this.sortAlphaDesc : this.sortAlphaAsc),
|
||||
});
|
||||
},
|
||||
}];
|
||||
|
||||
const assignmentHeadings = entry.section_breakdown
|
||||
.filter(section => section.is_graded && section.label && section.category == 'Homework')
|
||||
.map(s => ({
|
||||
label: s.label,
|
||||
key: s.label,
|
||||
columnSortable: false,
|
||||
onSort: (direction) => { this.sortNumerically(s.label, direction); },
|
||||
}));
|
||||
|
||||
return results.concat(assignmentHeadings);
|
||||
},
|
||||
exam: (dispatch, entry) => {
|
||||
const results = [{
|
||||
label: 'Username',
|
||||
key: 'username',
|
||||
columnSortable: false,
|
||||
onSort: (direction) => {
|
||||
this.setState({
|
||||
grades: [...this.state.grades].sort(direction === 'desc' ? this.sortAlphaDesc : this.sortAlphaAsc),
|
||||
});
|
||||
},
|
||||
}];
|
||||
|
||||
const assignmentHeadings = entry.section_breakdown
|
||||
.filter(section => section.is_graded && section.label && section.category == 'Exam')
|
||||
.map(s => ({
|
||||
label: s.label,
|
||||
key: s.label,
|
||||
columnSortable: false,
|
||||
onSort: (direction) => { this.sortNumerically(s.label, direction); },
|
||||
}));
|
||||
|
||||
return results.concat(assignmentHeadings);
|
||||
},
|
||||
};
|
||||
|
||||
export { headingMapper, gradeSortMap, sortAlphaAsc };
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { configuration } from '../config';
|
||||
import { getAuthenticatedAPIClient } from '@edx/frontend-auth';
|
||||
|
||||
import { configuration } from '../config';
|
||||
|
||||
const apiClient = getAuthenticatedAPIClient({
|
||||
appBaseUrl: configuration.BASE_URL,
|
||||
loginUrl: configuration.LOGIN_URL,
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
const STARTED_FETCHING_COMMENT = 'STARTED_FETCHING_COMMENT';
|
||||
const FINISHED_FETCHING_COMMENT = 'FINISHED_FETCHING_COMMENT';
|
||||
const ERROR_FETCHING_COMMENT = 'ERROR_FETCHING_COMMENT';
|
||||
const GET_COMMENT = 'GET_COMMENT';
|
||||
|
||||
export {
|
||||
STARTED_FETCHING_COMMENT,
|
||||
FINISHED_FETCHING_COMMENT,
|
||||
ERROR_FETCHING_COMMENT,
|
||||
GET_COMMENT,
|
||||
};
|
||||
@@ -7,6 +7,11 @@ const GRADE_UPDATE_REQUEST = 'GRADE_UPDATE_REQUEST';
|
||||
const GRADE_UPDATE_SUCCESS = 'GRADE_UPDATE_SUCCESS';
|
||||
const GRADE_UPDATE_FAILURE = 'GRADE_UPDATE_FAILURE';
|
||||
|
||||
const TOGGLE_GRADE_FORMAT = 'TOGGLE_GRADE_FORMAT';
|
||||
const SORT_GRADES = 'SORT_GRADES';
|
||||
const FILTER_COLUMNS = 'FILTER_COLUMNS';
|
||||
const UPDATE_BANNER = 'UPDATE_BANNER';
|
||||
|
||||
export {
|
||||
STARTED_FETCHING_GRADES,
|
||||
FINISHED_FETCHING_GRADES,
|
||||
@@ -15,4 +20,8 @@ export {
|
||||
GRADE_UPDATE_REQUEST,
|
||||
GRADE_UPDATE_SUCCESS,
|
||||
GRADE_UPDATE_FAILURE,
|
||||
TOGGLE_GRADE_FORMAT,
|
||||
SORT_GRADES,
|
||||
FILTER_COLUMNS,
|
||||
UPDATE_BANNER,
|
||||
};
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
const STARTED_FETCHING_POSTS = 'STARTED_FETCHING_POSTS';
|
||||
const GET_POSTS = 'GET_POSTS';
|
||||
const FINISHED_FETCHING_POSTS = 'FINISHED_FETCHING_POSTS';
|
||||
|
||||
export {
|
||||
STARTED_FETCHING_POSTS,
|
||||
GET_POSTS,
|
||||
FINISHED_FETCHING_POSTS,
|
||||
};
|
||||
@@ -1,46 +0,0 @@
|
||||
import {
|
||||
STARTED_FETCHING_COMMENT,
|
||||
ERROR_FETCHING_COMMENT,
|
||||
GET_COMMENT,
|
||||
} from '../constants/actionTypes/comment';
|
||||
|
||||
const initialState = {
|
||||
details: {
|
||||
id: null,
|
||||
postId: null,
|
||||
name: '',
|
||||
email: 'example@example.com',
|
||||
body: '',
|
||||
},
|
||||
startedFetching: false,
|
||||
finishedFetching: false,
|
||||
errorFetching: false,
|
||||
};
|
||||
|
||||
const comment = (state = initialState, action) => {
|
||||
switch (action.type) {
|
||||
case GET_COMMENT:
|
||||
return {
|
||||
...state,
|
||||
details: { ...action.comment },
|
||||
finishedFetching: true,
|
||||
errorFetching: false,
|
||||
};
|
||||
case STARTED_FETCHING_COMMENT:
|
||||
return {
|
||||
...state,
|
||||
startedFetching: true,
|
||||
finishedFetching: false,
|
||||
};
|
||||
case ERROR_FETCHING_COMMENT:
|
||||
return {
|
||||
...state,
|
||||
finishedFetching: true,
|
||||
errorFetching: true,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
export default comment;
|
||||
@@ -2,13 +2,21 @@ import {
|
||||
STARTED_FETCHING_GRADES,
|
||||
ERROR_FETCHING_GRADES,
|
||||
GOT_GRADES,
|
||||
TOGGLE_GRADE_FORMAT,
|
||||
FILTER_COLUMNS,
|
||||
GRADE_UPDATE_SUCCESS,
|
||||
UPDATE_BANNER,
|
||||
SORT_GRADES,
|
||||
} from '../constants/actionTypes/grades';
|
||||
|
||||
const initialState = {
|
||||
results: [],
|
||||
headings: [],
|
||||
startedFetching: false,
|
||||
finishedFetching: false,
|
||||
errorFetching: false,
|
||||
gradeFormat: 'percent',
|
||||
showSuccess: false,
|
||||
};
|
||||
|
||||
const grades = (state = initialState, action) => {
|
||||
@@ -17,6 +25,7 @@ const grades = (state = initialState, action) => {
|
||||
return {
|
||||
...state,
|
||||
results: action.grades,
|
||||
headings: action.headings,
|
||||
finishedFetching: true,
|
||||
errorFetching: false,
|
||||
selectedTrack: action.track,
|
||||
@@ -34,1009 +43,29 @@ const grades = (state = initialState, action) => {
|
||||
finishedFetching: true,
|
||||
errorFetching: true,
|
||||
};
|
||||
case TOGGLE_GRADE_FORMAT:
|
||||
return {
|
||||
...state,
|
||||
gradeFormat: action.formatType,
|
||||
};
|
||||
case FILTER_COLUMNS:
|
||||
return {
|
||||
...state,
|
||||
headings: action.headings,
|
||||
};
|
||||
case UPDATE_BANNER:
|
||||
return {
|
||||
...state,
|
||||
showSuccess: action.showSuccess,
|
||||
};
|
||||
case SORT_GRADES:
|
||||
return {
|
||||
...state,
|
||||
results: action.results,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
export default grades;
|
||||
|
||||
|
||||
// Gradebook.defaultProps = {
|
||||
// "results": [
|
||||
// {
|
||||
// "course_id": "course-v1:edX+DemoX+Demo_Course",
|
||||
// "email": "honor@example.com",
|
||||
// "user_id": 6,
|
||||
// "username": "honor",
|
||||
// "full_name": "",
|
||||
// "passed": false,
|
||||
// "percent": 0,
|
||||
// "letter_grade": null,
|
||||
// "progress_page_url": "/courses/course-v1:edX+DemoX+Demo_Course/progress/6/",
|
||||
// "section_breakdown": [
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Introduction",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/0.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@edx_introduction",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 0,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@d8a6192ade314473a78242dfeedfbf5b",
|
||||
// "subsection_name": "Demo Course Overview"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Example Week 1: Getting Started",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/3.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@19a30717eff543078a5d94ae9d6c18a5",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 3,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@interactive_demonstrations",
|
||||
// "subsection_name": "Lesson 1 - Getting Started"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": "Homework",
|
||||
// "chapter_name": "Example Week 1: Getting Started",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": true,
|
||||
// "grade_description": "(0.00/11.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": "Ex 01",
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@basic_questions",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 11,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@interactive_demonstrations",
|
||||
// "subsection_name": "Homework - Question Styles"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Example Week 2: Get Interactive",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/0.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@simulations",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 0,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@graded_interactions",
|
||||
// "subsection_name": "Lesson 2 - Let's Get Interactive!"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": "Homework",
|
||||
// "chapter_name": "Example Week 2: Get Interactive",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": true,
|
||||
// "grade_description": "(0.00/5.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": "Ex 02",
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@graded_simulations",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 5,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@graded_interactions",
|
||||
// "subsection_name": "Homework - Labs and Demos"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Example Week 2: Get Interactive",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/19.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@175e76c4951144a29d46211361266e0e",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 19,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@graded_interactions",
|
||||
// "subsection_name": "Homework - Essays"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Example Week 3: Be Social",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/0.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@48ecb924d7fe4b66a230137626bfa93e",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 0,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@social_integration",
|
||||
// "subsection_name": "Lesson 3 - Be Social"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Example Week 3: Be Social",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/0.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@dbe8fc027bcb4fe9afb744d2e8415855",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 0,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@social_integration",
|
||||
// "subsection_name": "Homework - Find Your Study Buddy"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Example Week 3: Be Social",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/0.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@6ab9c442501d472c8ed200e367b4edfa",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 0,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@social_integration",
|
||||
// "subsection_name": "More Ways to Connect"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": "Exam",
|
||||
// "chapter_name": "About Exams and Certificates",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": true,
|
||||
// "grade_description": "(0.00/6.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@workflow",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 6,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@1414ffd5143b4b508f739b563ab468b7",
|
||||
// "subsection_name": "edX Exams"
|
||||
// }
|
||||
// ],
|
||||
// "aggregates": {
|
||||
// "Exam": {
|
||||
// "score_possible": 6,
|
||||
// "score_earned": 0
|
||||
// },
|
||||
// "Homework": {
|
||||
// "score_possible": 16,
|
||||
// "score_earned": 0
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// "course_id": "course-v1:edX+DemoX+Demo_Course",
|
||||
// "email": "audit@example.com",
|
||||
// "user_id": 7,
|
||||
// "username": "audit",
|
||||
// "full_name": "",
|
||||
// "passed": false,
|
||||
// "percent": 0.17,
|
||||
// "letter_grade": null,
|
||||
// "progress_page_url": "/courses/course-v1:edX+DemoX+Demo_Course/progress/7/",
|
||||
// "section_breakdown": [
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Introduction",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/0.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@edx_introduction",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 0,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@d8a6192ade314473a78242dfeedfbf5b",
|
||||
// "subsection_name": "Demo Course Overview"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Example Week 1: Getting Started",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/3.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@19a30717eff543078a5d94ae9d6c18a5",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 3,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@interactive_demonstrations",
|
||||
// "subsection_name": "Lesson 1 - Getting Started"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": "Homework",
|
||||
// "chapter_name": "Example Week 1: Getting Started",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.45",
|
||||
// "is_graded": true,
|
||||
// "grade_description": "(5.00/11.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": "Ex 01",
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@basic_questions",
|
||||
// "percent": 0.45,
|
||||
// "score_earned": 5,
|
||||
// "score_possible": 11,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@interactive_demonstrations",
|
||||
// "subsection_name": "Homework - Question Styles"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Example Week 2: Get Interactive",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/0.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@simulations",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 0,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@graded_interactions",
|
||||
// "subsection_name": "Lesson 2 - Let's Get Interactive!"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": "Homework",
|
||||
// "chapter_name": "Example Week 2: Get Interactive",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": true,
|
||||
// "grade_description": "(0.00/5.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": "Ex 02",
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@graded_simulations",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 5,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@graded_interactions",
|
||||
// "subsection_name": "Homework - Labs and Demos"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Example Week 2: Get Interactive",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/19.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@175e76c4951144a29d46211361266e0e",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 19,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@graded_interactions",
|
||||
// "subsection_name": "Homework - Essays"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Example Week 3: Be Social",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/0.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@48ecb924d7fe4b66a230137626bfa93e",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 0,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@social_integration",
|
||||
// "subsection_name": "Lesson 3 - Be Social"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Example Week 3: Be Social",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/0.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@dbe8fc027bcb4fe9afb744d2e8415855",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 0,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@social_integration",
|
||||
// "subsection_name": "Homework - Find Your Study Buddy"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Example Week 3: Be Social",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/0.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@6ab9c442501d472c8ed200e367b4edfa",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 0,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@social_integration",
|
||||
// "subsection_name": "More Ways to Connect"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": "Exam",
|
||||
// "chapter_name": "About Exams and Certificates",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": true,
|
||||
// "grade_description": "(0.00/6.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@workflow",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 6,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@1414ffd5143b4b508f739b563ab468b7",
|
||||
// "subsection_name": "edX Exams"
|
||||
// }
|
||||
// ],
|
||||
// "aggregates": {
|
||||
// "Exam": {
|
||||
// "score_possible": 6,
|
||||
// "score_earned": 0
|
||||
// },
|
||||
// "Homework": {
|
||||
// "score_possible": 16,
|
||||
// "score_earned": 5
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// "course_id": "course-v1:edX+DemoX+Demo_Course",
|
||||
// "email": "verified@example.com",
|
||||
// "user_id": 8,
|
||||
// "username": "verified",
|
||||
// "full_name": "",
|
||||
// "passed": false,
|
||||
// "percent": 0,
|
||||
// "letter_grade": null,
|
||||
// "progress_page_url": "/courses/course-v1:edX+DemoX+Demo_Course/progress/8/",
|
||||
// "section_breakdown": [
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Introduction",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/0.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@edx_introduction",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 0,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@d8a6192ade314473a78242dfeedfbf5b",
|
||||
// "subsection_name": "Demo Course Overview"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Example Week 1: Getting Started",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/3.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@19a30717eff543078a5d94ae9d6c18a5",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 3,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@interactive_demonstrations",
|
||||
// "subsection_name": "Lesson 1 - Getting Started"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": "Homework",
|
||||
// "chapter_name": "Example Week 1: Getting Started",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": true,
|
||||
// "grade_description": "(0.00/11.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": "Ex 01",
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@basic_questions",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 11,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@interactive_demonstrations",
|
||||
// "subsection_name": "Homework - Question Styles"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Example Week 2: Get Interactive",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/0.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@simulations",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 0,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@graded_interactions",
|
||||
// "subsection_name": "Lesson 2 - Let's Get Interactive!"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": "Homework",
|
||||
// "chapter_name": "Example Week 2: Get Interactive",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": true,
|
||||
// "grade_description": "(0.00/5.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": "Ex 02",
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@graded_simulations",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 5,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@graded_interactions",
|
||||
// "subsection_name": "Homework - Labs and Demos"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Example Week 2: Get Interactive",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/19.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@175e76c4951144a29d46211361266e0e",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 19,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@graded_interactions",
|
||||
// "subsection_name": "Homework - Essays"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Example Week 3: Be Social",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/0.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@48ecb924d7fe4b66a230137626bfa93e",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 0,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@social_integration",
|
||||
// "subsection_name": "Lesson 3 - Be Social"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Example Week 3: Be Social",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/0.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@dbe8fc027bcb4fe9afb744d2e8415855",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 0,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@social_integration",
|
||||
// "subsection_name": "Homework - Find Your Study Buddy"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Example Week 3: Be Social",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/0.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@6ab9c442501d472c8ed200e367b4edfa",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 0,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@social_integration",
|
||||
// "subsection_name": "More Ways to Connect"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": "Exam",
|
||||
// "chapter_name": "About Exams and Certificates",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": true,
|
||||
// "grade_description": "(0.00/6.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@workflow",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 6,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@1414ffd5143b4b508f739b563ab468b7",
|
||||
// "subsection_name": "edX Exams"
|
||||
// }
|
||||
// ],
|
||||
// "aggregates": {
|
||||
// "Exam": {
|
||||
// "score_possible": 6,
|
||||
// "score_earned": 0
|
||||
// },
|
||||
// "Homework": {
|
||||
// "score_possible": 16,
|
||||
// "score_earned": 0
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// "course_id": "course-v1:edX+DemoX+Demo_Course",
|
||||
// "email": "staff@example.com",
|
||||
// "user_id": 9,
|
||||
// "username": "staff",
|
||||
// "full_name": "",
|
||||
// "passed": false,
|
||||
// "percent": 0,
|
||||
// "letter_grade": null,
|
||||
// "progress_page_url": "/courses/course-v1:edX+DemoX+Demo_Course/progress/9/",
|
||||
// "section_breakdown": [
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Introduction",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/0.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@edx_introduction",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 0,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@d8a6192ade314473a78242dfeedfbf5b",
|
||||
// "subsection_name": "Demo Course Overview"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Example Week 1: Getting Started",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/3.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@19a30717eff543078a5d94ae9d6c18a5",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 3,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@interactive_demonstrations",
|
||||
// "subsection_name": "Lesson 1 - Getting Started"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": "Homework",
|
||||
// "chapter_name": "Example Week 1: Getting Started",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": true,
|
||||
// "grade_description": "(0.00/11.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": "Ex 01",
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@basic_questions",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 11,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@interactive_demonstrations",
|
||||
// "subsection_name": "Homework - Question Styles"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Example Week 2: Get Interactive",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/0.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@simulations",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 0,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@graded_interactions",
|
||||
// "subsection_name": "Lesson 2 - Let's Get Interactive!"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": "Homework",
|
||||
// "chapter_name": "Example Week 2: Get Interactive",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": true,
|
||||
// "grade_description": "(0.00/5.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": "Ex 02",
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@graded_simulations",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 5,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@graded_interactions",
|
||||
// "subsection_name": "Homework - Labs and Demos"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Example Week 2: Get Interactive",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/19.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@175e76c4951144a29d46211361266e0e",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 19,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@graded_interactions",
|
||||
// "subsection_name": "Homework - Essays"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Example Week 3: Be Social",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/0.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@48ecb924d7fe4b66a230137626bfa93e",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 0,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@social_integration",
|
||||
// "subsection_name": "Lesson 3 - Be Social"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Example Week 3: Be Social",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/0.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@dbe8fc027bcb4fe9afb744d2e8415855",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 0,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@social_integration",
|
||||
// "subsection_name": "Homework - Find Your Study Buddy"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "Example Week 3: Be Social",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/0.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@6ab9c442501d472c8ed200e367b4edfa",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 0,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@social_integration",
|
||||
// "subsection_name": "More Ways to Connect"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": "Exam",
|
||||
// "chapter_name": "About Exams and Certificates",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": true,
|
||||
// "grade_description": "(0.00/6.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@workflow",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 6,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@1414ffd5143b4b508f739b563ab468b7",
|
||||
// "subsection_name": "edX Exams"
|
||||
// },
|
||||
// {
|
||||
// "are_grades_published": true,
|
||||
// "auto_grade": false,
|
||||
// "category": null,
|
||||
// "chapter_name": "holding section",
|
||||
// "comment": "",
|
||||
// "detail": "",
|
||||
// "displayed_value": "0.00",
|
||||
// "is_graded": false,
|
||||
// "grade_description": "(0.00/0.00)",
|
||||
// "is_ag": false,
|
||||
// "is_average": false,
|
||||
// "is_manually_graded": false,
|
||||
// "label": null,
|
||||
// "letter_grade": null,
|
||||
// "module_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@07bc32474380492cb34f76e5f9d9a135",
|
||||
// "percent": 0,
|
||||
// "score_earned": 0,
|
||||
// "score_possible": 0,
|
||||
// "section_block_id": "block-v1:edX+DemoX+Demo_Course+type@chapter+block@9fca584977d04885bc911ea76a9ef29e",
|
||||
// "subsection_name": "New Subsection"
|
||||
// }
|
||||
// ],
|
||||
// "aggregates": {
|
||||
// "Exam": {
|
||||
// "score_possible": 6,
|
||||
// "score_earned": 0
|
||||
// },
|
||||
// "Homework": {
|
||||
// "score_possible": 16,
|
||||
// "score_earned": 0
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ]
|
||||
// };
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
import {
|
||||
GET_POSTS,
|
||||
STARTED_FETCHING_POSTS,
|
||||
FINISHED_FETCHING_POSTS,
|
||||
} from '../constants/actionTypes/posts';
|
||||
|
||||
const posts = (state = { posts: [], startedFetching: false, finishedFetching: false }, action) => {
|
||||
switch (action.type) {
|
||||
case GET_POSTS:
|
||||
return {
|
||||
...state,
|
||||
posts: action.posts,
|
||||
};
|
||||
case STARTED_FETCHING_POSTS:
|
||||
return {
|
||||
...state,
|
||||
startedFetching: true,
|
||||
finishedFetching: false,
|
||||
};
|
||||
case FINISHED_FETCHING_POSTS:
|
||||
return {
|
||||
...state,
|
||||
startedFetching: false,
|
||||
finishedFetching: true,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
export default posts;
|
||||
@@ -1,45 +0,0 @@
|
||||
import posts from './posts';
|
||||
import {
|
||||
GET_POSTS,
|
||||
STARTED_FETCHING_POSTS,
|
||||
FINISHED_FETCHING_POSTS,
|
||||
} from '../constants/actionTypes/posts';
|
||||
|
||||
const initialState = {
|
||||
posts: [],
|
||||
startedFetching: false,
|
||||
finishedFetching: false,
|
||||
};
|
||||
|
||||
describe('posts reducer', () => {
|
||||
it('has initial state', () => {
|
||||
expect(posts(undefined, {})).toEqual(initialState);
|
||||
});
|
||||
|
||||
it('adds posts', () => {
|
||||
const fetchedPosts = [1, 2, 3];
|
||||
const expected = {
|
||||
...initialState,
|
||||
posts: fetchedPosts,
|
||||
};
|
||||
expect(posts(undefined, { type: GET_POSTS, posts: fetchedPosts })).toEqual(expected);
|
||||
});
|
||||
|
||||
it('updates started fetching posts state', () => {
|
||||
const expected = {
|
||||
...initialState,
|
||||
startedFetching: true,
|
||||
finishedFetching: false,
|
||||
};
|
||||
expect(posts(undefined, { type: STARTED_FETCHING_POSTS })).toEqual(expected);
|
||||
});
|
||||
|
||||
it('updates finished fetching posts state', () => {
|
||||
const expected = {
|
||||
...initialState,
|
||||
startedFetching: false,
|
||||
finishedFetching: true,
|
||||
};
|
||||
expect(posts(undefined, { type: FINISHED_FETCHING_POSTS })).toEqual(expected);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user