diff --git a/backend/CMakeLists.txt b/backend/CMakeLists.txt index 1ab3e10..90b83b7 100644 --- a/backend/CMakeLists.txt +++ b/backend/CMakeLists.txt @@ -28,6 +28,7 @@ add_library(csp_core src/services/kb_import_runner.cc src/services/problem_gen_runner.cc src/services/submission_feedback_service.cc + src/services/submission_feedback_runner.cc src/services/import_service.cc src/services/import_runner.cc src/domain/enum_strings.cc diff --git a/backend/include/csp/services/submission_feedback_runner.h b/backend/include/csp/services/submission_feedback_runner.h new file mode 100644 index 0000000..a4c78a7 --- /dev/null +++ b/backend/include/csp/services/submission_feedback_runner.h @@ -0,0 +1,41 @@ +#pragma once + +#include "csp/db/sqlite_db.h" + +#include +#include +#include +#include +#include + +namespace csp::services { + +class SubmissionFeedbackRunner { + public: + static SubmissionFeedbackRunner& Instance(); + + void Configure(std::string db_path); + + /// Enqueue a submission for async feedback generation. + bool Enqueue(int64_t submission_id); + + /// Scan DB for submissions without feedback and enqueue them. + void AutoStartIfEnabled(db::SqliteDb& db); + + size_t PendingCount() const; + + private: + SubmissionFeedbackRunner() = default; + void StartWorkerIfNeededLocked(); + void WorkerLoop(); + void RecoverPendingLocked(); + + std::string db_path_; + mutable std::mutex mu_; + std::deque queue_; + size_t pending_jobs_ = 0; + bool worker_running_ = false; + bool recovered_ = false; +}; + +} // namespace csp::services diff --git a/backend/src/controllers/submission_controller.cc b/backend/src/controllers/submission_controller.cc index 1136f94..89b41b9 100644 --- a/backend/src/controllers/submission_controller.cc +++ b/backend/src/controllers/submission_controller.cc @@ -6,6 +6,7 @@ #include "csp/services/contest_service.h" #include "csp/services/problem_service.h" #include "csp/services/solution_access_service.h" +#include "csp/services/submission_feedback_runner.h" #include "csp/services/submission_feedback_service.h" #include "csp/services/submission_service.h" #include "http_auth.h" @@ -130,6 +131,10 @@ void SubmissionController::submitProblem( services::SubmissionService svc(csp::AppState::Instance().db()); auto s = svc.CreateAndJudge(create); + + // Auto-enqueue LLM feedback generation in background. + services::SubmissionFeedbackRunner::Instance().Enqueue(s.id); + cb(JsonOk(domain::ToJson(s))); } catch (const std::invalid_argument&) { cb(JsonError(drogon::k400BadRequest, "invalid numeric field")); @@ -187,6 +192,14 @@ void SubmissionController::getSubmission( Json::Value payload = domain::ToJson(*s); payload["code"] = s->code; + // Attach problem title for frontend linking. + { + services::ProblemService psvc(csp::AppState::Instance().db()); + if (const auto p = psvc.GetById(s->problem_id); p.has_value()) { + payload["problem_title"] = p->title; + } + } + services::SolutionAccessService access_svc(csp::AppState::Instance().db()); const auto stats = access_svc.QueryUserProblemViewStats(s->user_id, s->problem_id); diff --git a/backend/src/main.cc b/backend/src/main.cc index 6fa72a1..6bf5ee9 100644 --- a/backend/src/main.cc +++ b/backend/src/main.cc @@ -6,6 +6,7 @@ #include "csp/services/kb_import_runner.h" #include "csp/services/problem_gen_runner.h" #include "csp/services/problem_solution_runner.h" +#include "csp/services/submission_feedback_runner.h" #include #include @@ -20,6 +21,7 @@ int main(int argc, char** argv) { csp::services::KbImportRunner::Instance().Configure(db_path); csp::services::ProblemSolutionRunner::Instance().Configure(db_path); csp::services::ProblemGenRunner::Instance().Configure(db_path); + csp::services::SubmissionFeedbackRunner::Instance().Configure(db_path); // Optional seed admin user for dev/test. { @@ -48,6 +50,9 @@ int main(int argc, char** argv) { csp::AppState::Instance().db()); // Auto-generate one CSP-J new problem (RAG + dedupe) on startup by default. csp::services::ProblemGenRunner::Instance().AutoStartIfEnabled(); + // Auto-queue submission feedback generation for submissions without feedback. + csp::services::SubmissionFeedbackRunner::Instance().AutoStartIfEnabled( + csp::AppState::Instance().db()); // CORS (dev-friendly). In production, prefer reverse proxy same-origin. drogon::app().registerPreRoutingAdvice([](const drogon::HttpRequestPtr& req, diff --git a/backend/src/services/submission_feedback_runner.cc b/backend/src/services/submission_feedback_runner.cc new file mode 100644 index 0000000..55b4fb8 --- /dev/null +++ b/backend/src/services/submission_feedback_runner.cc @@ -0,0 +1,180 @@ +#include "csp/services/submission_feedback_runner.h" + +#include "csp/services/problem_service.h" +#include "csp/services/submission_feedback_service.h" +#include "csp/services/submission_service.h" + +#include +#include + +#include +#include +#include +#include +#include +#include + +namespace csp::services { + +namespace { + +bool EnvBool(const char* key, bool default_value) { + const char* raw = std::getenv(key); + if (!raw) return default_value; + std::string val(raw); + for (auto& c : val) + c = static_cast(::tolower(static_cast(c))); + if (val == "1" || val == "true" || val == "yes" || val == "on") return true; + if (val == "0" || val == "false" || val == "no" || val == "off") return false; + return default_value; +} + +int EnvInt(const char* key, int default_value) { + const char* raw = std::getenv(key); + if (!raw) return default_value; + try { + return std::stoi(raw); + } catch (...) { + return default_value; + } +} + +} // namespace + +SubmissionFeedbackRunner& SubmissionFeedbackRunner::Instance() { + static SubmissionFeedbackRunner inst; + return inst; +} + +void SubmissionFeedbackRunner::Configure(std::string db_path) { + std::lock_guard lock(mu_); + db_path_ = std::move(db_path); + RecoverPendingLocked(); + StartWorkerIfNeededLocked(); +} + +bool SubmissionFeedbackRunner::Enqueue(int64_t submission_id) { + std::lock_guard lock(mu_); + if (db_path_.empty()) return false; + queue_.push_back(submission_id); + ++pending_jobs_; + StartWorkerIfNeededLocked(); + return true; +} + +void SubmissionFeedbackRunner::AutoStartIfEnabled(db::SqliteDb& db) { + if (!EnvBool("CSP_FEEDBACK_AUTO_RUN", false)) { + LOG_INFO << "submission feedback auto-run disabled"; + return; + } + + const int limit = + std::max(1, std::min(10000, EnvInt("CSP_FEEDBACK_AUTO_LIMIT", 500))); + + // Find submissions without feedback. + sqlite3_stmt* stmt = nullptr; + const char* sql = + "SELECT s.id FROM submissions s " + "LEFT JOIN submission_feedback f ON f.submission_id=s.id " + "WHERE f.id IS NULL " + "ORDER BY s.id DESC LIMIT ?"; + if (sqlite3_prepare_v2(db.raw(), sql, -1, &stmt, nullptr) != SQLITE_OK) { + LOG_ERROR << "feedback runner: failed to query pending submissions"; + return; + } + sqlite3_bind_int(stmt, 1, limit); + + int queued = 0; + while (sqlite3_step(stmt) == SQLITE_ROW) { + const int64_t sid = sqlite3_column_int64(stmt, 0); + Enqueue(sid); + ++queued; + } + sqlite3_finalize(stmt); + + LOG_INFO << "submission feedback auto-run queued=" << queued + << ", pending=" << PendingCount(); +} + +size_t SubmissionFeedbackRunner::PendingCount() const { + std::lock_guard lock(mu_); + return pending_jobs_; +} + +void SubmissionFeedbackRunner::StartWorkerIfNeededLocked() { + if (worker_running_ || queue_.empty()) return; + worker_running_ = true; + std::thread([this]() { WorkerLoop(); }).detach(); +} + +void SubmissionFeedbackRunner::WorkerLoop() { + while (true) { + int64_t submission_id = 0; + std::string db_path; + { + std::lock_guard lock(mu_); + if (queue_.empty()) { + worker_running_ = false; + return; + } + submission_id = queue_.front(); + queue_.pop_front(); + db_path = db_path_; + } + + try { + db::SqliteDb db = db::SqliteDb::OpenFile(db_path); + SubmissionFeedbackService feedback_svc(db); + + // Skip if feedback already exists. + if (feedback_svc.GetBySubmissionId(submission_id).has_value()) { + std::lock_guard lock(mu_); + if (pending_jobs_ > 0) --pending_jobs_; + continue; + } + + SubmissionService sub_svc(db); + const auto submission = sub_svc.GetById(submission_id); + if (!submission.has_value()) { + LOG_WARN << "feedback runner: submission " << submission_id + << " not found, skipping"; + std::lock_guard lock(mu_); + if (pending_jobs_ > 0) --pending_jobs_; + continue; + } + + ProblemService prob_svc(db); + const auto problem = prob_svc.GetById(submission->problem_id); + if (!problem.has_value()) { + LOG_WARN << "feedback runner: problem " << submission->problem_id + << " not found for submission " << submission_id; + std::lock_guard lock(mu_); + if (pending_jobs_ > 0) --pending_jobs_; + continue; + } + + feedback_svc.GenerateAndSave(*submission, *problem, false); + LOG_INFO << "feedback runner: generated feedback for submission " + << submission_id; + } catch (const std::exception& e) { + LOG_ERROR << "feedback runner: submission " << submission_id + << " failed: " << e.what(); + } + + { + std::lock_guard lock(mu_); + if (pending_jobs_ > 0) --pending_jobs_; + } + + // Small delay between jobs to avoid overwhelming LLM API / SQLite. + std::this_thread::sleep_for(std::chrono::seconds(2)); + } +} + +void SubmissionFeedbackRunner::RecoverPendingLocked() { + if (recovered_ || db_path_.empty()) return; + recovered_ = true; + // Recovery is handled by AutoStartIfEnabled; no separate DB state to recover. +} + +} // namespace csp::services diff --git a/docker-compose.yml b/docker-compose.yml index 9f0ad4a..3521451 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,6 +22,9 @@ services: - CSP_SOLUTION_AUTO_RUN_MISSING=true - CSP_SOLUTION_AUTO_LIMIT=50000 - CSP_SOLUTION_AUTO_MAX_SOLUTIONS=3 + - CSP_FEEDBACK_AUTO_RUN=true + - CSP_FEEDBACK_AUTO_LIMIT=500 + - CSP_FEEDBACK_SCRIPT_PATH=/app/scripts/analyze_submission_feedback.py build: context: . dockerfile: Dockerfile.backend diff --git a/frontend/src/app/submissions/[id]/page.tsx b/frontend/src/app/submissions/[id]/page.tsx index 86d37c9..6301285 100644 --- a/frontend/src/app/submissions/[id]/page.tsx +++ b/frontend/src/app/submissions/[id]/page.tsx @@ -1,5 +1,6 @@ "use client"; +import Link from "next/link"; import { useParams } from "next/navigation"; import { useEffect, useMemo, useState } from "react"; @@ -21,6 +22,7 @@ type Submission = { id: number; user_id: number; problem_id: number; + problem_title?: string; contest_id: number | null; language: string; code: string; @@ -117,7 +119,17 @@ export default function SubmissionDetailPage() {

{tx("用户", "User")}: {data.user_id}

-

{tx("题目", "Problem")}: {data.problem_id}

+

+ {tx("题目", "Problem")}:{" "} + + {data.problem_title + ? `P${data.problem_id} - ${data.problem_title}` + : `P${data.problem_id}`} + +

{tx("比赛", "Contest")}: {data.contest_id ?? "-"}

{tx("语言", "Language")}: {data.language}

{tx("状态", "Status")}: {data.status}

diff --git a/ref/CSP-Minecraft-UI-Kit/dev-guide/09-CSS-Naming-Convention-and-Code-4K.png b/ref/CSP-Minecraft-UI-Kit/dev-guide/09-CSS-Naming-Convention-and-Code-4K.png index 72ab949..e69de29 100644 Binary files a/ref/CSP-Minecraft-UI-Kit/dev-guide/09-CSS-Naming-Convention-and-Code-4K.png and b/ref/CSP-Minecraft-UI-Kit/dev-guide/09-CSS-Naming-Convention-and-Code-4K.png differ diff --git a/ref/CSP-Minecraft-UI-Kit/docs/Design-Delivery-Document.html b/ref/CSP-Minecraft-UI-Kit/docs/Design-Delivery-Document.html index cf0d055..e69de29 100644 --- a/ref/CSP-Minecraft-UI-Kit/docs/Design-Delivery-Document.html +++ b/ref/CSP-Minecraft-UI-Kit/docs/Design-Delivery-Document.html @@ -1,804 +0,0 @@ - - - - - - CSP Learning Platform - Minecraft UI Kit Design Delivery - - - - - - - - - -
- - -
-
-

CSP Learning Platform

-

Minecraft Pixel Art Style UI Kit

-
- DESIGN DELIVERY DOCUMENT • V1.0 • OCTOBER 2023 -
-
-
- - -
-
-

Design Concept

- NEW -
-
-
-
-

The Voxel World Metaphor

-

The CSP Learning Platform's design is deeply rooted in the "Minecraft" aesthetic, utilizing a voxel/pixel art style to create an immersive and engaging learning environment for programming students. This choice is strategic:

-
    -
  • Gamification: Leveraging the familiarity of sandbox games to make coding challenges feel like quests.
  • -
  • Modularity: The block-based nature of Minecraft mirrors the modular nature of code and algorithms.
  • -
  • Creativity: Encouraging students to "build" their knowledge just as they build structures in-game.
  • -
-
-
-

Visual Language

-

Our visual language relies on distinct 8-bit textures, bold black borders, and high-contrast colors. The interface uses skeuomorphic elements (wooden signs, stone buttons) combined with flat pixel art to ensure usability while maintaining the theme.

-
-
-

> System Status: ONLINE

-

> Style Loaded: PIXEL_ART_V2

-

> Assets: READY

-
-
-
-
-
- - -
-
-

UI Kit Components

-
- -
-
- Basic Components System - -
- Basic UI Components -

Comprehensive system including color palette, typography hierarchy, input fields, and standard buttons with 4 states (Normal, Hover, Pressed, Disabled).

-
- -
-
-
- Button States & Feedback -
- Button States -
-
-
- Gamification & Progress -
- Gamification Components -
-
- -
-
- Level System & XP Visualization - ANIMATED -
- Level System -
-
- - -
-
-

Page Designs

-
- - -
-
- 01. Login & Authentication -
- Login Page -
- - -
-
-
- 02. Problem Library -
- Problem Library Page -
-
-
- 03. Code Editor IDE -
- Code Editor Page -
-
- - -
-
-
- 04. User Profile Center -
- Profile Page -
-
-
- 05. Contest Arena -
- Contest Page -
-
-
- - -
-
-

Responsive Behavior

-
-
- Responsive Design Showcase -
-

Desktop (>1200px)
-

Tablet Landscape (1024px)
-

Tablet Portrait (768px)
-

Mobile (< 480px)
-
-
-
- - -
-
-

Development Guidelines

-
-
- CSS Naming - -

Core CSS Implementation (SCSS)

-
-
// Variables & Mixins
-$mc-grass-top: #5cb85c;
-$mc-dirt: #795548;
-$pixel-scale: 4px;
-
-@mixin pixel-border($color: #000) {
-    box-shadow: 
-        -4px 0 0 0 $color,
-        4px 0 0 0 $color,
-        0 -4px 0 0 $color,
-        0 4px 0 0 $color;
-    margin: 4px;
-}
-
-.mc-btn {
-    background-color: $mc-stone;
-    border: none;
-    color: #fff;
-    padding: 12px 24px;
-    font-family: 'Minecraft', monospace;
-    @include pixel-border(#212121);
-    
-    &:hover {
-        background-color: lighten($mc-stone, 10%);
-        transform: translateY(-2px);
-    }
-}
-
-
-
- - -
-
-

Asset Library

-
- -
-
-
Navigation Icons (32px)
- Navigation Icons -
-
-
Difficulty & Prog. Icons
- Difficulty Icons -
-
- -
-
-
Tiled Textures (256px)
- Textures -
-
-
Achievement Badges
- Badges -
-
- -
-
Blocks, Particles & Effects
- Blocks and Particles -
-
- - -
-
-

Download Resources

-
- -
-
-
- -
-
Complete UI Kit - Figma Source
-
.fig | 145 MB | Updated Oct 24, 2023
-
-
- Download -
-
-
- -
-
Icon Set (SVG + PNG)
-
.zip | 24 MB | 120 Icons
-
-
- Download -
-
-
- -
-
Texture Pack High-Res
-
.zip | 312 MB | Seamless Patterns
-
-
- Download -
-
-
- -
-
Pixel Fonts Bundle
-
.ttf | 2 MB | 4 Font Families
-
-
- Download -
-
-
- - -
-
-

Appendix: Color Tokens

-
-
-
-
-
-
- Grass Top - #5CB85C -
-
-
-
-
- Dirt - #795548 -
-
-
-
-
- Stone - #9E9E9E -
-
-
-
-
- Wood - #8D6E63 -
-
-
-
-
- Gold - #FFD700 -
-
-
-
-
- Diamond - #40E0D0 -
-
-
-
-
- Redstone - #F44336 -
-
-
-
-
- Obsidian - #212121 -
-
-
-
-
- -
-

CSP Learning Platform Design System © 2023

-

Designed with ❤️ for future coders.

-
- -
- - \ No newline at end of file diff --git a/ref/CSP-Minecraft-UI-Kit/docs/Design-Document-Preview.jpeg b/ref/CSP-Minecraft-UI-Kit/docs/Design-Document-Preview.jpeg index f8e54f3..e69de29 100644 Binary files a/ref/CSP-Minecraft-UI-Kit/docs/Design-Document-Preview.jpeg and b/ref/CSP-Minecraft-UI-Kit/docs/Design-Document-Preview.jpeg differ diff --git a/ref/CSP-Minecraft-UI-Kit/html/assets/preview-code-editor.png b/ref/CSP-Minecraft-UI-Kit/html/assets/preview-code-editor.png index 1626ad4..e69de29 100644 Binary files a/ref/CSP-Minecraft-UI-Kit/html/assets/preview-code-editor.png and b/ref/CSP-Minecraft-UI-Kit/html/assets/preview-code-editor.png differ diff --git a/ref/CSP-Minecraft-UI-Kit/html/assets/preview-contest.png b/ref/CSP-Minecraft-UI-Kit/html/assets/preview-contest.png index b7e642e..e69de29 100644 Binary files a/ref/CSP-Minecraft-UI-Kit/html/assets/preview-contest.png and b/ref/CSP-Minecraft-UI-Kit/html/assets/preview-contest.png differ diff --git a/ref/CSP-Minecraft-UI-Kit/html/assets/preview-login.png b/ref/CSP-Minecraft-UI-Kit/html/assets/preview-login.png index 771bc1b..e69de29 100644 Binary files a/ref/CSP-Minecraft-UI-Kit/html/assets/preview-login.png and b/ref/CSP-Minecraft-UI-Kit/html/assets/preview-login.png differ diff --git a/ref/CSP-Minecraft-UI-Kit/html/assets/preview-problem-library.png b/ref/CSP-Minecraft-UI-Kit/html/assets/preview-problem-library.png index 98f2399..e69de29 100644 Binary files a/ref/CSP-Minecraft-UI-Kit/html/assets/preview-problem-library.png and b/ref/CSP-Minecraft-UI-Kit/html/assets/preview-problem-library.png differ diff --git a/ref/CSP-Minecraft-UI-Kit/html/assets/preview-profile-center.png b/ref/CSP-Minecraft-UI-Kit/html/assets/preview-profile-center.png index ceb5a9c..e69de29 100644 Binary files a/ref/CSP-Minecraft-UI-Kit/html/assets/preview-profile-center.png and b/ref/CSP-Minecraft-UI-Kit/html/assets/preview-profile-center.png differ diff --git a/ref/CSP-Minecraft-UI-Kit/html/index.html b/ref/CSP-Minecraft-UI-Kit/html/index.html index 4995d47..e69de29 100644 --- a/ref/CSP-Minecraft-UI-Kit/html/index.html +++ b/ref/CSP-Minecraft-UI-Kit/html/index.html @@ -1,651 +0,0 @@ - - - - - - CSP Learning Platform - Minecraft Edition - - - - - - - - - - -
- -
-
-
- -
-

- - CSP Learning Platform -

-
Minecraft Pixel Art Style Edition
-

Complete HTML package with 5 fully functional pages

- -
-
Pure HTML/CSS/JS
-
Offline Ready
-
Responsive Design
-
Pixel Perfect
-
- - Start Exploring -
-
- - -
-
- -
- -
-
-
- Login Page -
-
-

Login Page

-

Minecraft-themed authentication with form validation.

-
- Tab Switching - Password Strength - Mock Login -
-
- -
-
-
-
- - -
-
-
- Problem Library -
-
-

Problem Library

-

Browse 1,556 problems with advanced filtering and search.

-
- Sidebar Menu - Search & Filter - Pagination -
-
- -
-
-
-
- - -
-
-
- Code Editor -
-
-

Code Editor

-

Split-panel editor with syntax highlighting and output.

-
- Multi-language - Theme Toggle - Test Runner -
-
- -
-
-
-
- - -
-
-
- Profile Center -
-
-

Profile Center

-

User dashboard with achievements, stats, and history.

-
- XP System - Badges - Leaderboard -
-
- -
-
-
-
- - -
-
-
- Contest Page -
-
-

Contest Page

-

Live contests with real-time leaderboard and arena mode.

-
- Countdown Timer - Live Updates - Rankings -
-
- -
-
-
-
- -
- - -
-

Ready to Craft Your Code?

-
-
csp-platform-v1.0.zip (12.5 MB)
-
README.txt (2 KB)
-
/assets (images, css, js)
-
-
- -
-

Installation: Simply unzip and open index.html in any browser.

-
-
-
- - -
-

Crafted with by HTML Generator | Version 1.19.2

-

Mock GitHub Link: github.com/user/csp-minecraft

-
- - - - - - - \ No newline at end of file diff --git a/ref/CSP-Minecraft-UI-Kit/html/pages/code-editor.html b/ref/CSP-Minecraft-UI-Kit/html/pages/code-editor.html index ebe0b97..e69de29 100644 --- a/ref/CSP-Minecraft-UI-Kit/html/pages/code-editor.html +++ b/ref/CSP-Minecraft-UI-Kit/html/pages/code-editor.html @@ -1,619 +0,0 @@ - - - - - - Minecraft Code Editor - - - - - - - - -
- - - - - -
- -
-
- - -
Size: 14px
-
-
- - -
-
- - -
-
- 1
2
3
4
5
6
7
8
9
10
11 -
-
-class Solution { -public: - vector<int> twoSum(vector<int>& nums, int target) { - unordered_map<int, int> hash; - - for (int i = 0; i < nums.size(); i++) { - int complement = target - nums[i]; - - if (hash.find(complement) != hash.end()) { - return {hash[complement], i}; - } - hash[nums[i]] = i; - } - return {}; - } -};
-
- - -
- Ready - - 0ms - 0KB -
-
COMBO x5
-
- - -
-
- - Test Console - -
-
- - -
-
-
-
Case 1
-
Input
-
nums = [2,7,11,15], target = 9
-
Expected
-
[0,1]
-
-
-
Case 2
-
Input
-
nums = [3,2,4], target = 6
-
Expected
-
[1,2]
-
-
-
Case 3
-
Input
-
nums = [3,3], target = 6
-
Expected
-
[0,1]
-
-
-
-
-
- - -
+50 XP
- - - - \ No newline at end of file diff --git a/ref/CSP-Minecraft-UI-Kit/html/pages/contest.html b/ref/CSP-Minecraft-UI-Kit/html/pages/contest.html index ec6d3cb..e69de29 100644 --- a/ref/CSP-Minecraft-UI-Kit/html/pages/contest.html +++ b/ref/CSP-Minecraft-UI-Kit/html/pages/contest.html @@ -1,905 +0,0 @@ - - - - - - Minecraft Contest Page - - - - - - - - - -
- - -
-
-
ONGOING
-
UPCOMING
-
FINISHED
-
- -
- -
-
-
-
-

Weekly Challenge #42

-
- Ends in 2h - - 500 XP -
-
-
-
- -
-
- -
-
-
-
-

Bi-Weekly Rumble #15

-
- Sat, 14:00 - - 350 XP -
-
-
-
- -
-
- -
-
-
-
-

Diamond League Qualifiers

-
- Sun, 10:00 - - 1000 XP + BADGE -
-
-
-
- -
-
-
- - -
-
-

LEADERBOARD

-
- UPDATING LIVE -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#PLAYERSCORETIMESTATUS
1Notch_Real40000:45:12AC
2Alex_Pro38000:52:30AC
3CreeperAwMan35001:05:00AC
4Enderman_tp32001:10:22AC
5RedstoneEng30001:15:45AC
6Miner6428001:20:10AC
7STEVE_DEV (YOU)25001:30:00WA (1)
8ZombieBoi20001:35:12AC
-
- -
- - -
- - -
-
- MY STATS - -
-
- Participated: - 24 -
-
- Best Rank: - #3 🥉 -
-
- Total Points: - 1,250 -
-
- Rating: - 1650 (Diamond II) -
- -
-
- -
2
-
-
- -
5
-
-
- -
8
-
-
-
- - -
-
- RULES - -
-
-
    -
  • Duration: 3 Hours
  • -
  • Penalty: +5 mins per WA
  • -
  • Languages: Java, C++, Python
  • -
  • Plagiarism check is ACTIVE
  • -
  • Do not break obsidian blocks
  • -
-
-
- - -
-
- HISTORY - -
- -
-
-
-
-
-
2023-10-15
-
Weekly #41 - Rank #15
-
-
-
-
-
-
-
2023-10-08
-
Weekly #40 - Rank #2 🥈
-
-
-
-
-
-
-
2023-10-01
-
Weekly #39 - Rank #3 🥉
-
-
-
-
-
-
-
2023-09-24
-
Weekly #38 - Rank #45
-
-
-
-
- -
-
- - - - \ No newline at end of file diff --git a/ref/CSP-Minecraft-UI-Kit/html/pages/login.html b/ref/CSP-Minecraft-UI-Kit/html/pages/login.html index b2d70c9..e69de29 100644 --- a/ref/CSP-Minecraft-UI-Kit/html/pages/login.html +++ b/ref/CSP-Minecraft-UI-Kit/html/pages/login.html @@ -1,605 +0,0 @@ - - - - - - CSP Learning Platform - Minecraft Login - - - - - - - - - - - -
- -
- -
- -
-
- Online Players: 12,002 -
-
-
-
-
- - - - \ No newline at end of file diff --git a/ref/CSP-Minecraft-UI-Kit/html/pages/problem-library.html b/ref/CSP-Minecraft-UI-Kit/html/pages/problem-library.html index e0c0ac6..e69de29 100644 --- a/ref/CSP-Minecraft-UI-Kit/html/pages/problem-library.html +++ b/ref/CSP-Minecraft-UI-Kit/html/pages/problem-library.html @@ -1,849 +0,0 @@ - - - - - - Minecraft Problem Library - - - - - - - -
- - - - -
- - -
-
-
TOTAL PROBLEMS
-
1,556
-
-
-
COMPLETED
-
128
-
-
-
PASS RATE
-
85%
-
-
- -
-
- - - -
- -
- - - - -
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
STSIDTITLERATEDIFFTAGSACT
1001A+B Problem95% -
- - - -
-
MathSOLVE
1002Fibonacci Sequence45% -
- - - -
-
DPSOLVE
-
- - -
- - - -
- - - - \ No newline at end of file diff --git a/ref/CSP-Minecraft-UI-Kit/html/pages/profile-center.html b/ref/CSP-Minecraft-UI-Kit/html/pages/profile-center.html index 26d2d43..e69de29 100644 --- a/ref/CSP-Minecraft-UI-Kit/html/pages/profile-center.html +++ b/ref/CSP-Minecraft-UI-Kit/html/pages/profile-center.html @@ -1,896 +0,0 @@ - - - - - - Minecraft Profile Center - - - - - - - - - - -
- -
-
- - Avatar -
- -
-
-

CodeMaster2024

-
-
Passionate problem solver
-
-
Lv.25
-
Algorithm Expert
-
- -
-
-
8,450 / 10,000 XP
-
-
- -
-
-
128
-
Problems
-
-
-
456
-
Submits
-
-
-
85%
-
Acceptance
-
-
-
15🔥
-
Streak
-
-
-
- - -
- -
-
-
-
Difficulty Stats
-
-
- Easy - Med - Hard -
-
-
- -
-
-
Activity Log
-
Last 30 Days
-
- -
-
-
- -
-
-
Timeline
-
-
-
Solved "Two Sum"
-
2 hours ago
-
-
-
Failed "Dijkstra"
-
5 hours ago
-
-
-
Badge Unlocked
-
1 day ago
-
-
-
-
-
- - -
-
-
-
Achievement Wall
-
- - -
- -
-
Novice Slayer
-
Solve 10 Easy
-
+50 XP
-
-
-
- -
-
Iron Will
-
Solve 50 Medium
-
+200 XP
-
-
-
- -
LOCKED: Diamond Blade
-
-
- -
-
Champion
-
Win a Contest
-
+1000 XP
-
-
-
- -
-
Scholar
-
Read 100 Articles
-
+100 XP
-
-
- - -
- -
-
Alchemist
-
Optimize 10 times
-
+150 XP
-
-
-
- -
LOCKED: Inferno
-
-
- -
-
Speedster
-
Solve in 5 mins
-
+50 XP
-
-
-
- -
LOCKED: Star Player
-
-
- -
LOCKED: Explorer
-
- - -
- -
LOCKED: Guardian
-
-
- -
LOCKED: Builder
-
-
- -
LOCKED: Bug Hunter
-
-
- -
LOCKED: Navigator
-
-
- -
LOCKED: King
-
-
-
-
- -
-
-
Learning Path
-
-
- Basics - 100% -
-
-
-
-
- Algorithms - 75% -
-
-
-
-
- Data Structures - 60% -
-
-
-
-
- Advanced DP - 40% -
-
-
-
-
- Contest Prep - 20% -
-
-
-
-
-
- - -
-
-
-
Leaderboard
-
-
1
-
Notch
-
99k
-
-
-
2
-
Jeb_
-
85k
-
-
-
3
-
Alex
-
72k
-
-
-
4
-
Herobrine
-
66k
-
-
-
5
-
CodeMaster
-
50k
-
-
-
- -
-
-
Daily Quests
-
-
-
Login
-
10XP
-
-
-
-
Solve 1 Easy
-
20XP
-
-
-
-
Review Code
-
15XP
-
-
-
-
Solve 1 Hard
-
100XP
-
-
-
-
Forum Post
-
30XP
-
-
-
- -
-
-
-
- -
Daily Reward
-
-
-
-
-
-
- - - - - - - \ No newline at end of file diff --git a/ref/CSP-Minecraft-UI-Kit/images/badges/13-Badges-Achievement-System-Complete-4K.png b/ref/CSP-Minecraft-UI-Kit/images/badges/13-Badges-Achievement-System-Complete-4K.png index ca03e09..e69de29 100644 Binary files a/ref/CSP-Minecraft-UI-Kit/images/badges/13-Badges-Achievement-System-Complete-4K.png and b/ref/CSP-Minecraft-UI-Kit/images/badges/13-Badges-Achievement-System-Complete-4K.png differ diff --git a/ref/CSP-Minecraft-UI-Kit/images/icons/10-Icons-Navigation-and-Functional-32x32-4K.png b/ref/CSP-Minecraft-UI-Kit/images/icons/10-Icons-Navigation-and-Functional-32x32-4K.png index c89fd1a..e69de29 100644 Binary files a/ref/CSP-Minecraft-UI-Kit/images/icons/10-Icons-Navigation-and-Functional-32x32-4K.png and b/ref/CSP-Minecraft-UI-Kit/images/icons/10-Icons-Navigation-and-Functional-32x32-4K.png differ diff --git a/ref/CSP-Minecraft-UI-Kit/images/icons/11-Icons-Difficulty-and-Programming-32x32-4K.png b/ref/CSP-Minecraft-UI-Kit/images/icons/11-Icons-Difficulty-and-Programming-32x32-4K.png index f27e4da..e69de29 100644 Binary files a/ref/CSP-Minecraft-UI-Kit/images/icons/11-Icons-Difficulty-and-Programming-32x32-4K.png and b/ref/CSP-Minecraft-UI-Kit/images/icons/11-Icons-Difficulty-and-Programming-32x32-4K.png differ diff --git a/ref/CSP-Minecraft-UI-Kit/images/textures/12-Textures-Minecraft-Library-4K.png b/ref/CSP-Minecraft-UI-Kit/images/textures/12-Textures-Minecraft-Library-4K.png index 492df2c..e69de29 100644 Binary files a/ref/CSP-Minecraft-UI-Kit/images/textures/12-Textures-Minecraft-Library-4K.png and b/ref/CSP-Minecraft-UI-Kit/images/textures/12-Textures-Minecraft-Library-4K.png differ diff --git a/ref/CSP-Minecraft-UI-Kit/images/ui/14-UI-Elements-Blocks-and-Particles-4K.png b/ref/CSP-Minecraft-UI-Kit/images/ui/14-UI-Elements-Blocks-and-Particles-4K.png index 16950fe..e69de29 100644 Binary files a/ref/CSP-Minecraft-UI-Kit/images/ui/14-UI-Elements-Blocks-and-Particles-4K.png and b/ref/CSP-Minecraft-UI-Kit/images/ui/14-UI-Elements-Blocks-and-Particles-4K.png differ diff --git a/ref/CSP-Minecraft-UI-Kit/images/ui/15-UI-Elements-Button-States-and-Feedback-4K.png b/ref/CSP-Minecraft-UI-Kit/images/ui/15-UI-Elements-Button-States-and-Feedback-4K.png index 1eeb25e..e69de29 100644 Binary files a/ref/CSP-Minecraft-UI-Kit/images/ui/15-UI-Elements-Button-States-and-Feedback-4K.png and b/ref/CSP-Minecraft-UI-Kit/images/ui/15-UI-Elements-Button-States-and-Feedback-4K.png differ diff --git a/ref/CSP-Minecraft-UI-Kit/images/ui/16-UI-Elements-Level-System-and-XP-4K.png b/ref/CSP-Minecraft-UI-Kit/images/ui/16-UI-Elements-Level-System-and-XP-4K.png index fca4736..e69de29 100644 Binary files a/ref/CSP-Minecraft-UI-Kit/images/ui/16-UI-Elements-Level-System-and-XP-4K.png and b/ref/CSP-Minecraft-UI-Kit/images/ui/16-UI-Elements-Level-System-and-XP-4K.png differ diff --git a/ref/CSP-Minecraft-UI-Kit/pages/03-Page-Design-Login-2K.png b/ref/CSP-Minecraft-UI-Kit/pages/03-Page-Design-Login-2K.png index 616997c..e69de29 100644 Binary files a/ref/CSP-Minecraft-UI-Kit/pages/03-Page-Design-Login-2K.png and b/ref/CSP-Minecraft-UI-Kit/pages/03-Page-Design-Login-2K.png differ diff --git a/ref/CSP-Minecraft-UI-Kit/pages/04-Page-Design-Problem-Library-1K.png b/ref/CSP-Minecraft-UI-Kit/pages/04-Page-Design-Problem-Library-1K.png index f5c9710..e69de29 100644 Binary files a/ref/CSP-Minecraft-UI-Kit/pages/04-Page-Design-Problem-Library-1K.png and b/ref/CSP-Minecraft-UI-Kit/pages/04-Page-Design-Problem-Library-1K.png differ diff --git a/ref/CSP-Minecraft-UI-Kit/pages/05-Page-Design-Code-Editor-1K.png b/ref/CSP-Minecraft-UI-Kit/pages/05-Page-Design-Code-Editor-1K.png index 89ca909..e69de29 100644 Binary files a/ref/CSP-Minecraft-UI-Kit/pages/05-Page-Design-Code-Editor-1K.png and b/ref/CSP-Minecraft-UI-Kit/pages/05-Page-Design-Code-Editor-1K.png differ diff --git a/ref/CSP-Minecraft-UI-Kit/pages/06-Page-Design-Profile-Center-1K.png b/ref/CSP-Minecraft-UI-Kit/pages/06-Page-Design-Profile-Center-1K.png index fc2aeb4..e69de29 100644 Binary files a/ref/CSP-Minecraft-UI-Kit/pages/06-Page-Design-Profile-Center-1K.png and b/ref/CSP-Minecraft-UI-Kit/pages/06-Page-Design-Profile-Center-1K.png differ diff --git a/ref/CSP-Minecraft-UI-Kit/pages/07-Page-Design-Contest-2K.png b/ref/CSP-Minecraft-UI-Kit/pages/07-Page-Design-Contest-2K.png index bda810b..e69de29 100644 Binary files a/ref/CSP-Minecraft-UI-Kit/pages/07-Page-Design-Contest-2K.png and b/ref/CSP-Minecraft-UI-Kit/pages/07-Page-Design-Contest-2K.png differ diff --git a/ref/CSP-Minecraft-UI-Kit/responsive/08-Responsive-Design-Showcase-4K.png b/ref/CSP-Minecraft-UI-Kit/responsive/08-Responsive-Design-Showcase-4K.png index c8349f6..e69de29 100644 Binary files a/ref/CSP-Minecraft-UI-Kit/responsive/08-Responsive-Design-Showcase-4K.png and b/ref/CSP-Minecraft-UI-Kit/responsive/08-Responsive-Design-Showcase-4K.png differ diff --git a/ref/CSP-Minecraft-UI-Kit/ui-kit/01-UI-KIT-Basic-Components-4K.png b/ref/CSP-Minecraft-UI-Kit/ui-kit/01-UI-KIT-Basic-Components-4K.png index 7d7dc80..e69de29 100644 Binary files a/ref/CSP-Minecraft-UI-Kit/ui-kit/01-UI-KIT-Basic-Components-4K.png and b/ref/CSP-Minecraft-UI-Kit/ui-kit/01-UI-KIT-Basic-Components-4K.png differ diff --git a/ref/CSP-Minecraft-UI-Kit/ui-kit/02-UI-KIT-Gamification-Components-4K.png b/ref/CSP-Minecraft-UI-Kit/ui-kit/02-UI-KIT-Gamification-Components-4K.png index bb01b68..e69de29 100644 Binary files a/ref/CSP-Minecraft-UI-Kit/ui-kit/02-UI-KIT-Gamification-Components-4K.png and b/ref/CSP-Minecraft-UI-Kit/ui-kit/02-UI-KIT-Gamification-Components-4K.png differ diff --git a/scripts/analyze_submission_feedback.py b/scripts/analyze_submission_feedback.py index 6f9d088..4f848f8 100644 --- a/scripts/analyze_submission_feedback.py +++ b/scripts/analyze_submission_feedback.py @@ -8,6 +8,7 @@ import json import os import re import sys +import time from dataclasses import dataclass from typing import Any, Dict, List, Optional @@ -88,9 +89,17 @@ def build_fallback_feedback(payload: Dict[str, Any], llm_error: str = "") -> Llm ) lines: List[str] = [] - lines.append("### 评测结论") + lines.append("### 总体评语") lines.append(f"- 本次状态:**{status}**,分数:**{score}**。") - lines.append(f"- 思路评价:{thought}") + lines.append(f"- {thought}") + lines.append("") + lines.append("### 代码逐段讲解") + lines.append("- 由于 LLM 分析不可用,暂时无法提供代码逐段讲解。请仔细检查代码逻辑,确保输入输出格式正确。") + lines.append("") + lines.append("### 知识点提示") + lines.append("- 强项:基础实现与调试流程。") + lines.append("- 待加强:边界构造、类型一致性、赛场环境兼容性。") + lines.append("- 请对照 CSP-J/S 大纲,确认所涉及的算法知识点是否已掌握。") lines.append("") lines.append("### 福建 CSP-J/S 规范检查(C++14)") for tip in risk_tips: @@ -100,16 +109,12 @@ def build_fallback_feedback(payload: Dict[str, Any], llm_error: str = "") -> Llm if runtime_log.strip(): lines.append("- 运行日志有输出,建议重点检查边界输入与数组越界风险。") lines.append("") - lines.append("### 修改建议(可执行)") + lines.append("### 改进建议") lines.append("- 按“先编译通过→再保证正确→最后做优化”的顺序迭代。") lines.append("- `long long` 读写统一 `%lld`;不要使用 `%I64d`。") lines.append("- 清理 signed/unsigned 警告,降低不同编译器行为差异。") lines.append("- 确保 `int main()` 且 `return 0;`。") lines.append("") - lines.append("### 知识点评测") - lines.append("- 强项:基础实现与调试流程。") - lines.append("- 待加强:边界构造、类型一致性、赛场环境兼容性。") - lines.append("") lines.append("### 推荐外链资料") for item in DEFAULT_LINKS: lines.append(f"- [{item['title']}]({item['url']})") @@ -162,17 +167,25 @@ def call_llm(payload: Dict[str, Any]) -> LlmResult: raise RuntimeError("missing OI_LLM_API_URL") system_prompt = ( - "你是福建省 CSP-J/S 代码规范与评测老师。" + "你是福建省 CSP-J/S 代码规范与评测老师,也是一位经验丰富的算法竞赛教练。" "请严格按 C++14 旧 GCC 环境给建议,重点指出会导致 CE/RE/爆零的风险。" + "你的评测需要覆盖以下维度:\n" + "1. 总体评语:对代码质量和解题思路的综合评价(2-3句话)\n" + "2. 代码逐段讲解:解释代码的关键逻辑和实现思路\n" + "3. 知识点提示:涉及的算法和数据结构知识点,与 CSP-J/S 大纲的对应关系\n" + "4. 福建 CSP-J/S 规范检查(C++14):指出不符合规范的地方\n" + "5. 改进建议:具体可操作的优化方向\n" + "6. 推荐外链资料:相关学习资源\n" "输出 JSON,不要输出其他文字。" ) user_prompt = { - "task": "分析这份提交并给出改进建议", + "task": "分析这份提交并给出详细点评", "required_sections": [ - "评测结论", + "总体评语", + "代码逐段讲解", + "知识点提示", "福建 CSP-J/S 规范检查(C++14)", - "修改建议", - "知识点评测", + "改进建议", "推荐外链资料", ], "submission": payload, @@ -197,7 +210,37 @@ def call_llm(payload: Dict[str, Any]) -> LlmResult: ], } - resp = requests.post(api_url, headers=headers, json=body, timeout=50) + max_retries = 5 + last_exc: Optional[Exception] = None + resp = None + for attempt in range(1, max_retries + 1): + try: + resp = requests.post(api_url, headers=headers, json=body, timeout=50) + if resp.status_code < 500: + resp.raise_for_status() + break + # 5xx — retry + last_exc = requests.exceptions.HTTPError( + f"HTTP {resp.status_code}", response=resp + ) + print( + f"[feedback] LLM returned {resp.status_code}, " + f"retry {attempt}/{max_retries}", + file=sys.stderr, + ) + except (requests.exceptions.ConnectionError, + requests.exceptions.Timeout) as exc: + last_exc = exc + print( + f"[feedback] LLM request failed ({exc}), " + f"retry {attempt}/{max_retries}", + file=sys.stderr, + ) + if attempt < max_retries: + time.sleep(min(2 ** attempt, 16)) + else: + raise last_exc or RuntimeError("LLM request failed after retries") + resp.raise_for_status() data = resp.json()