Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2952c71

Browse files
authoredSep 6, 2024
Merge pull request #1169 from concord-consortium/188024567-set-rubric-min-rating-score
fix: Set the minimum rubric rating score to 1
2 parents b8af44b + f7f9e86 commit 2952c71

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed
 

‎app/assets/javascripts/lara-typescript.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -139922,8 +139922,15 @@ var RubricRatingsItem = function (_a) {
139922139922
}));
139923139923
}, [rating]);
139924139924
var handleScoreUpdate = (0, react_1.useCallback)(function (e) {
139925+
// don't allow scores less than 1
139926+
var newScore = parseInt(e.target.value, 10);
139927+
139928+
if (isNaN(newScore) || newScore < 1) {
139929+
newScore = 1;
139930+
}
139931+
139925139932
onUpdate(index, __assign(__assign({}, rating), {
139926-
score: parseInt(e.target.value, 10)
139933+
score: newScore
139927139934
}));
139928139935
}, [rating]);
139929139936
return React.createElement("tr", null, React.createElement("td", null, React.createElement("input", {
@@ -139938,7 +139945,8 @@ var RubricRatingsItem = function (_a) {
139938139945
})), React.createElement("td", null, React.createElement("input", {
139939139946
value: score,
139940139947
type: "number",
139941-
onChange: handleScoreUpdate
139948+
onChange: handleScoreUpdate,
139949+
min: 1
139942139950
})), React.createElement("td", null, React.createElement(trash_1.Trash, {
139943139951
onClick: handleDelete
139944139952
})));
@@ -139980,7 +139988,7 @@ var RubricRatings = function () {
139980139988
draft.ratings.push({
139981139989
id: "R" + (draft.ratings.length + 1),
139982139990
label: "",
139983-
score: 0
139991+
score: 1
139984139992
});
139985139993
});
139986139994
};

‎lara-typescript/src/rubric-authoring/rubric-ratings.tsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,19 @@ export const RubricRatingsItem = ({index, rating, onDelete, onUpdate}: IRubricRa
2323
onUpdate(index, {...rating, label: e.target.value});
2424
}, [rating]);
2525
const handleScoreUpdate = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
26-
onUpdate(index, {...rating, score: parseInt(e.target.value, 10)});
26+
// don't allow scores less than 1
27+
let newScore = parseInt(e.target.value, 10);
28+
if (isNaN(newScore) || newScore < 1) {
29+
newScore = 1;
30+
}
31+
onUpdate(index, {...rating, score: newScore});
2732
}, [rating]);
2833

2934
return (
3035
<tr>
3136
<td><input value={id} type="text" disabled={true} /></td>
3237
<td><input value={label} type="text" autoFocus={true} onChange={handleLabelUpdate} /></td>
33-
<td><input value={score} type="number" onChange={handleScoreUpdate} /></td>
38+
<td><input value={score} type="number" onChange={handleScoreUpdate} min={1} /></td>
3439
<td><Trash onClick={handleDelete} /></td>
3540
</tr>
3641
);
@@ -63,7 +68,7 @@ export const RubricRatings = () => {
6368

6469
const handleAdd = () => {
6570
setRubric(draft => {
66-
draft.ratings.push({id: `R${draft.ratings.length + 1}`, label: "", score: 0});
71+
draft.ratings.push({id: `R${draft.ratings.length + 1}`, label: "", score: 1});
6772
});
6873
};
6974

0 commit comments

Comments
 (0)
Failed to load comments.