Skip to content

Fix negative average shown for already-achieved grades - #3

Open
pcuj123-glitch wants to merge 1 commit into
theaayushstha1:mainfrom
pcuj123-glitch:fix/grade-target-already-achieved
Open

Fix negative average shown for already-achieved grades#3
pcuj123-glitch wants to merge 1 commit into
theaayushstha1:mainfrom
pcuj123-glitch:fix/grade-target-already-achieved

Conversation

@pcuj123-glitch

Copy link
Copy Markdown

Summary

  • When a student's current grade already exceeds a target (e.g., 81.2% current vs 80% B target), Grade Surgeon showed a confusing -1.2% average needed instead of "Already secured"
  • Fixed _calc_weighted_targets and _calc_total_points_targets in backend/services/canvas_analytics.py to return required_avg: None when the needed average is ≤ 0
  • The frontend already handles required_avg == null correctly by displaying "Already secured"

Test plan

  • Open Grade Surgeon for a class where current grade exceeds a target threshold (e.g., 81.2% with B selected)
  • Verify it shows "Already secured" instead of a negative percentage
  • Verify grades not yet achieved still show the correct positive average needed
  • Verify behavior when no remaining work exists (unchanged)

When the required average on remaining work is negative (meaning the
student already meets the target grade), return required_avg as None
so the frontend displays 'Already secured' instead of a confusing
negative percentage like -1.2%.

Fixes both _calc_weighted_targets and _calc_total_points_targets.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
theaayushstha1 added a commit that referenced this pull request Apr 10, 2026
Issue #1 - Gemini skips KB search:
  - New: adk_agent/kb_prefetch.py - in-memory TF-IDF prefetch (<10ms)
  - agent.py: before_model_callback injects top 3 KB docs into system instruction
  - Belt-and-suspenders: even if Gemini skips VertexAiSearchTool, docs are in prompt

Issue #2 - Instruction bloat (11,908 -> 3,903 chars, 67% reduction):
  - agent.py: Consolidated 9 grounding rules into 4, 9 security rules into 4
  - Removed verbose course rec steps, UI features conditionally injected
  - YOUR CAPABILITIES compressed from 4282 to ~1500 chars

Issue #3 - No automated regression tests:
  - New: backend_provider.py for promptfoo (tests full pipeline via /chat/guest)
  - 12 new tests: Drive links, security refusals, factual accuracy, edge cases
  - New: run_tests.sh CI gate script (fails below 90% pass rate)

Issue #4 - main.py monolith (4200 lines):
  - New: deps.py (shared dependencies, Pydantic models, auth helpers)
  - New: routers/auth.py (register, login, verify, resend - 4 endpoints)
  - Pattern proven, ready for incremental extraction of chat/admin/integrations

Pipeline simplification:
  - Removed gates from hot path (retrieval_gate, verification_gate, fast_retrieval)
  - Disabled semantic cache (0.95 threshold = expensive exact match)
  - Gated LLM rewriter (5+ word queries skip to agent session context)

Benchmark: 30/30 pass, 0 hallucinations, 4.4s median, 3.9K instruction

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant