Compare commits
1 Commits
kdmccormic
...
aed/websoc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0aada7794 |
@@ -25,12 +25,41 @@ export default class Gradebook extends React.Component {
|
|||||||
updateVal: 0,
|
updateVal: 0,
|
||||||
updateModuleId: null,
|
updateModuleId: null,
|
||||||
updateUserId: null,
|
updateUserId: null,
|
||||||
|
socket: null,
|
||||||
|
websocketMsg: {
|
||||||
|
visible: false,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const urlQuery = queryString.parse(this.props.location.search);
|
const urlQuery = queryString.parse(this.props.location.search);
|
||||||
this.props.getRoles(this.props.match.params.courseId, urlQuery);
|
this.props.getRoles(this.props.match.params.courseId, urlQuery);
|
||||||
|
const socket = new WebSocket('ws://localhost:8765/ws/gradebook/course-v1:edX+DemoX+Demo_Course/');
|
||||||
|
socket.onmessage = this.socketMessageFunction;
|
||||||
|
}
|
||||||
|
|
||||||
|
socketMessageFunction = (event) => {
|
||||||
|
var data = JSON.parse(event.data);
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
|
const userIndex = this.props.grades.findIndex((entry) => entry.user_id == data.user_id);
|
||||||
|
const username = this.props.grades[userIndex].username;
|
||||||
|
const subsectionIndex = this.props.grades[userIndex].section_breakdown.findIndex((entry) => entry.module_id = data.subsection_id);
|
||||||
|
const subsectionName = this.props.grades[userIndex].section_breakdown[subsectionIndex].label;
|
||||||
|
|
||||||
|
let subsectionGrade = this.props.grades[userIndex].section_breakdown[subsectionIndex];
|
||||||
|
subsectionGrade.score_earned = data.override.earned_graded_override;
|
||||||
|
subsectionGrade.score_possible = data.override.possible_graded_override;
|
||||||
|
|
||||||
|
const updatedMsg = {
|
||||||
|
visible: true,
|
||||||
|
username: username,
|
||||||
|
subsectionName: subsectionName,
|
||||||
|
};
|
||||||
|
|
||||||
|
this.setState({ websocketMsg: updatedMsg });
|
||||||
|
this.props.gradeUpdateSuccess(this.props.match.params.courseId, this.props.grades);
|
||||||
}
|
}
|
||||||
|
|
||||||
setNewModalState = (userEntry, subsection) => {
|
setNewModalState = (userEntry, subsection) => {
|
||||||
@@ -355,6 +384,12 @@ export default class Gradebook extends React.Component {
|
|||||||
onClose={() => this.props.updateBanner(false)}
|
onClose={() => this.props.updateBanner(false)}
|
||||||
open={this.props.showSuccess}
|
open={this.props.showSuccess}
|
||||||
/>
|
/>
|
||||||
|
<StatusAlert
|
||||||
|
alertType="success"
|
||||||
|
dialog={`Grade for user ${this.state.websocketMsg.username} in ${this.state.websocketMsg.subsectionName} was updated.`}
|
||||||
|
onClose={() => this.setState({ websocketMsg : false })}
|
||||||
|
open={this.state.websocketMsg.visible}
|
||||||
|
/>
|
||||||
{PageButtons(this.props)}
|
{PageButtons(this.props)}
|
||||||
<div className="gbook">
|
<div className="gbook">
|
||||||
<Table
|
<Table
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
fetchGrades,
|
fetchGrades,
|
||||||
fetchMatchingUserGrades,
|
fetchMatchingUserGrades,
|
||||||
fetchPrevNextGrades,
|
fetchPrevNextGrades,
|
||||||
|
gradeUpdateSuccess,
|
||||||
updateGrades,
|
updateGrades,
|
||||||
toggleGradeFormat,
|
toggleGradeFormat,
|
||||||
filterColumns,
|
filterColumns,
|
||||||
@@ -79,6 +80,9 @@ const mapDispatchToProps = dispatch => (
|
|||||||
getRoles: (matchParams, urlQuery) => {
|
getRoles: (matchParams, urlQuery) => {
|
||||||
dispatch(getRoles(matchParams, urlQuery));
|
dispatch(getRoles(matchParams, urlQuery));
|
||||||
},
|
},
|
||||||
|
gradeUpdateSuccess: (courseId, data) => {
|
||||||
|
dispatch(gradeUpdateSuccess(courseId, data));
|
||||||
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -143,14 +143,14 @@ const updateGrades = (courseId, updateData, searchText, cohort, track) => (
|
|||||||
.then(response => response.data)
|
.then(response => response.data)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
dispatch(gradeUpdateSuccess(courseId, data));
|
dispatch(gradeUpdateSuccess(courseId, data));
|
||||||
dispatch(fetchMatchingUserGrades(
|
// dispatch(fetchMatchingUserGrades(
|
||||||
courseId,
|
// courseId,
|
||||||
searchText,
|
// searchText,
|
||||||
cohort,
|
// cohort,
|
||||||
track,
|
// track,
|
||||||
defaultAssignmentFilter,
|
// defaultAssignmentFilter,
|
||||||
true,
|
// true,
|
||||||
));
|
// ));
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
dispatch(gradeUpdateFailure(courseId, error));
|
dispatch(gradeUpdateFailure(courseId, error));
|
||||||
|
|||||||
Reference in New Issue
Block a user