Skip to content

Commit 2cdad7d

Browse files
jsb2092claude
andcommitted
Set target points from selected questions when template has no max_points
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 2b9dd2b commit 2cdad7d

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

‎questionbank/static/js/app.js‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,9 +1204,25 @@
12041204
document.getElementById('exam-max-long-points').value = template.max_long_points || '';
12051205

12061206
// Sync target points in sidebar with template max_points
1207+
// If template has max_points, use that; otherwise calculate from selected questions
12071208
const targetPointsInput = document.getElementById('target-points');
1208-
if (targetPointsInput && template.max_points) {
1209-
targetPointsInput.value = template.max_points;
1209+
if (targetPointsInput) {
1210+
if (template.max_points) {
1211+
targetPointsInput.value = template.max_points;
1212+
} else {
1213+
// Calculate total points from selected questions
1214+
const totalPoints = Array.from(selectedQuestions).reduce((sum, qId) => {
1215+
const row = document.querySelector(`tr[data-question-id="${qId}"]`);
1216+
if (row) {
1217+
const pointsCell = row.querySelector('td:nth-child(4)');
1218+
if (pointsCell) {
1219+
return sum + (parseFloat(pointsCell.textContent) || 0);
1220+
}
1221+
}
1222+
return sum;
1223+
}, 0);
1224+
targetPointsInput.value = totalPoints || '';
1225+
}
12101226
updateTargetIndicator();
12111227
}
12121228

0 commit comments

Comments
 (0)