Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Pull manual scores from feedbacks and not higher level scores attribute [PT-187021319] #460

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { TrackEventFunction, updateActivityFeedbackSettings } from "../../../actions";
import { connect } from "react-redux";
import { AUTOMATIC_SCORE, MANUAL_SCORE, NO_SCORE, RUBRIC_SCORE } from "../../../util/scoring-constants";
import { ScoreType, ScoringSettings, getScoredQuestions } from "../../../util/scoring";
import { ScoreType, ScoringSettings, getCurrentScores, getScoredQuestions } from "../../../util/scoring";
import { ScoreInput } from "./score-input";

import css from "../../../../css/portal-dashboard/feedback/feedback-settings-modal.less";
Expand Down Expand Up @@ -167,7 +167,8 @@
const updates: any = { scoreType };
if (maxScore !== undefined) {
// check if scores above max score and confirm if they are
const scoresAboveMax = feedbacks.scores.reduce((acc: boolean, cur: number) => {
const scores = getCurrentScores(feedbacks);
const scoresAboveMax = scores.reduce((acc: boolean, cur: number) => {

Check warning on line 171 in js/components/portal-dashboard/feedback/feedback-settings-modal.tsx

View check run for this annotation

Codecov / codecov/patch

js/components/portal-dashboard/feedback/feedback-settings-modal.tsx#L170-L171

Added lines #L170 - L171 were not covered by tests
return acc || cur > maxScore;
}, false);
if (scoresAboveMax && (scoreType === MANUAL_SCORE) && !confirmMaxScore) {
Expand Down
12 changes: 11 additions & 1 deletion js/util/scoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
break;

case MANUAL_SCORE:
const manualScores = feedbacks.scores;
const manualScores = getCurrentScores(feedbacks);

Check warning on line 74 in js/util/scoring.ts

View check run for this annotation

Codecov / codecov/patch

js/util/scoring.ts#L74

Added line #L74 was not covered by tests
if (manualScores.length > 0) {
const totalScore = manualScores.reduce((acc: number, cur: number) => acc + cur, 0);
avgScore = totalScore / manualScores.length;
Expand All @@ -83,6 +83,16 @@
return {avgScore, avgScoreMax};
};

export const getCurrentScores = (feedbacks: any) => {
return feedbacks.feedbacks.reduce((acc: any, cur: any) => {
const score = cur.get("score");

Check warning on line 88 in js/util/scoring.ts

View check run for this annotation

Codecov / codecov/patch

js/util/scoring.ts#L87-L88

Added lines #L87 - L88 were not covered by tests
if (score !== undefined) {
acc.push(score);

Check warning on line 90 in js/util/scoring.ts

View check run for this annotation

Codecov / codecov/patch

js/util/scoring.ts#L90

Added line #L90 was not covered by tests
}
return acc;

Check warning on line 92 in js/util/scoring.ts

View check run for this annotation

Codecov / codecov/patch

js/util/scoring.ts#L92

Added line #L92 was not covered by tests
}, []);
};

export const getCompletedRubricScores = (rubric: Rubric, feedbacks: any) => {
let scores: Map<any, any> = Map({});
const numCriteria = rubric.criteria.length;
Expand Down
Loading