Review recorded explanations of a solution on the site
The admin can upload a recording of themselves explaining a problem's solution out loud (mp3, m4a, wav, webm, ogg or flac, up to 25 MB) and get interview-style feedback, committed as reviews/<id>.md so every attempt is kept. Claude can't take audio, so the recording is transcribed first by an OpenAI-compatible endpoint (whisper-1 by default; TRANSCRIBE_API_KEY, with TRANSCRIBE_URL for a self-hosted server). Pace, pauses, filler words and when complexity first comes up are measured from the word timestamps and given to Claude with the timestamped transcript, the statement and optionally the code. The reply covers the verdict, scores in five areas, the approach and its complexity, missed edge cases, delivery and what to work on. Recordings are kept for playback in an S3 bucket (Garage) when the S3_* settings are given, and are thrown away otherwise. Reviews are admin-only. The job runs in the background like Explain, and the statement fetch and save-error handling are now shared between the two. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -2,17 +2,29 @@
|
||||
/**
|
||||
* One problem: its solution files, sample input, saved tests, notes,
|
||||
* explanation and git history. The admin also gets the status buttons, the
|
||||
* link/statement/notes editor and the Explain panel; each edit is a commit
|
||||
* the server pushes, and the response is the problem as it is afterwards, so
|
||||
* the page just takes it. An explanation takes minutes, so starting one only
|
||||
* queues it and the page polls until it is committed.
|
||||
* link/statement/notes editor, the Explain panel and recording reviews; each
|
||||
* edit is a commit the server pushes, and the response is the problem as it
|
||||
* is afterwards, so the page just takes it. An explanation or a review takes
|
||||
* minutes, so starting one only queues it and the page polls until it is
|
||||
* committed.
|
||||
*/
|
||||
import { computed, onUnmounted, ref, watch } from "vue";
|
||||
import { RouterLink } from "vue-router";
|
||||
import MarkdownIt from "markdown-it";
|
||||
import CodeBlock from "@/components/CodeBlock.vue";
|
||||
import Explanation from "@/components/Explanation.vue";
|
||||
import { explainStatus, fetchStatement, getMe, getProblem, setStatus, startExplain, updateMeta } from "@/api";
|
||||
import ReviewList from "@/components/ReviewList.vue";
|
||||
import {
|
||||
explainStatus,
|
||||
fetchStatement,
|
||||
getMe,
|
||||
getProblem,
|
||||
reviewStatus,
|
||||
setStatus,
|
||||
startExplain,
|
||||
startReview,
|
||||
updateMeta,
|
||||
} from "@/api";
|
||||
import { LANG_LABELS, STATUS_LABELS, formatDate, title } from "@/format";
|
||||
|
||||
const props = defineProps({ name: { type: String, required: true } });
|
||||
@@ -34,7 +46,10 @@ async function load() {
|
||||
const [p, me] = await Promise.all([getProblem(props.name), getMe().catch(() => ({ admin: false }))]);
|
||||
problem.value = p;
|
||||
admin.value = me.admin;
|
||||
if (me.admin) checkExplain();
|
||||
if (me.admin) {
|
||||
checkExplain();
|
||||
checkReview();
|
||||
}
|
||||
} catch (e) {
|
||||
problem.value = null;
|
||||
error.value = e.status === 404 ? "No such problem." : e.message;
|
||||
@@ -141,6 +156,77 @@ async function explain() {
|
||||
|
||||
const canExplain = computed(() => !!(problem.value?.statement || problem.value?.url));
|
||||
|
||||
// ---- recording reviews ----
|
||||
// The same shape as explanations, with its own job and timer: both can run
|
||||
// at once.
|
||||
const recording = ref(null);
|
||||
const recordingInput = ref(null);
|
||||
const reviewNote = ref("");
|
||||
const reviewCode = ref(true);
|
||||
const reviewJob = ref({ state: "idle" });
|
||||
let reviewPoll = null;
|
||||
|
||||
function stopReviewPolling() {
|
||||
clearTimeout(reviewPoll);
|
||||
reviewPoll = null;
|
||||
}
|
||||
onUnmounted(stopReviewPolling);
|
||||
watch(() => props.name, stopReviewPolling);
|
||||
|
||||
// 25 MB is the transcriber's limit; checking here saves uploading it first.
|
||||
const MAX_RECORDING = 25 << 20;
|
||||
|
||||
function pickRecording(e) {
|
||||
recording.value = e.target.files[0] || null;
|
||||
if (recording.value && recording.value.size > MAX_RECORDING) {
|
||||
reviewJob.value = { state: "error", error: "That recording is over 25 MB; export it at a lower bitrate." };
|
||||
} else if (reviewJob.value.state === "error") {
|
||||
reviewJob.value = { state: "idle" };
|
||||
}
|
||||
}
|
||||
|
||||
async function checkReview() {
|
||||
stopReviewPolling();
|
||||
const name = props.name;
|
||||
try {
|
||||
const s = await reviewStatus(name);
|
||||
if (name !== props.name) return;
|
||||
const finished = reviewJob.value.state === "running" && s.state === "done";
|
||||
reviewJob.value = s;
|
||||
if (s.state === "running") {
|
||||
reviewPoll = setTimeout(checkReview, 3000);
|
||||
} else if (finished) {
|
||||
problem.value = await getProblem(name);
|
||||
}
|
||||
} catch (e) {
|
||||
reviewJob.value = { state: "error", error: e.message };
|
||||
}
|
||||
}
|
||||
|
||||
async function submitReview() {
|
||||
const form = new FormData();
|
||||
form.append("audio", recording.value);
|
||||
form.append("note", reviewNote.value);
|
||||
form.append("includeCode", String(reviewCode.value));
|
||||
reviewJob.value = { state: "uploading" };
|
||||
try {
|
||||
reviewJob.value = await startReview(props.name, form);
|
||||
recording.value = null;
|
||||
if (recordingInput.value) recordingInput.value.value = "";
|
||||
reviewPoll = setTimeout(checkReview, 3000);
|
||||
} catch (e) {
|
||||
reviewJob.value = { state: "error", error: e.message };
|
||||
}
|
||||
}
|
||||
|
||||
const canReview = computed(
|
||||
() =>
|
||||
canExplain.value &&
|
||||
!!recording.value &&
|
||||
recording.value.size <= MAX_RECORDING &&
|
||||
!["uploading", "running"].includes(reviewJob.value.state),
|
||||
);
|
||||
|
||||
const moves = computed(() => {
|
||||
const s = problem.value?.status;
|
||||
return [
|
||||
@@ -226,6 +312,25 @@ const moves = computed(() => {
|
||||
<p v-if="job.state === 'error'" class="error">{{ job.error }}</p>
|
||||
</section>
|
||||
|
||||
<section v-if="admin" class="stuck card">
|
||||
<h2>Review my explanation</h2>
|
||||
<p class="muted">
|
||||
Record yourself explaining your solution as you would to an interviewer, then upload it (mp3, m4a, wav,
|
||||
webm, ogg or flac, up to 25 MB). It is transcribed, and Claude gives feedback on the approach and on your
|
||||
delivery. Each review is committed under <code>reviews/</code>.
|
||||
</p>
|
||||
<input ref="recordingInput" type="file" accept="audio/*,.mp3,.m4a,.wav,.webm,.ogg,.flac" @change="pickRecording" />
|
||||
<textarea v-model="reviewNote" rows="2" placeholder="Optional context: a mock interview, a time limit, what to focus on"></textarea>
|
||||
<div class="admin-row">
|
||||
<label class="check"><input v-model="reviewCode" type="checkbox" /> Include my code</label>
|
||||
<button class="btn primary" :disabled="!canReview" @click="submitReview">Review</button>
|
||||
<span v-if="reviewJob.state === 'uploading'" class="muted">Uploading…</span>
|
||||
<span v-else-if="reviewJob.state === 'running'" class="muted">Transcribing and reviewing… this takes a minute or two.</span>
|
||||
<span v-else-if="!canExplain" class="muted">Add a link or the statement first.</span>
|
||||
</div>
|
||||
<p v-if="reviewJob.state === 'error'" class="error">{{ reviewJob.error }}</p>
|
||||
</section>
|
||||
|
||||
<section v-if="notesHtml" class="notes card prose" v-html="notesHtml"></section>
|
||||
|
||||
<section v-if="problem.explanation">
|
||||
@@ -233,6 +338,11 @@ const moves = computed(() => {
|
||||
<Explanation :source="problem.explanation" />
|
||||
</section>
|
||||
|
||||
<section v-if="admin && problem.reviews.length">
|
||||
<h2>Reviews</h2>
|
||||
<ReviewList :name="problem.name" :reviews="problem.reviews" @changed="(p) => (problem = p)" />
|
||||
</section>
|
||||
|
||||
<details v-if="admin && statementHtml" class="statement card">
|
||||
<summary>Problem statement</summary>
|
||||
<div class="prose" v-html="statementHtml"></div>
|
||||
@@ -403,6 +513,10 @@ h2 {
|
||||
color: var(--color-ink);
|
||||
background: var(--color-paper);
|
||||
}
|
||||
.stuck input[type="file"] {
|
||||
font-size: 0.9rem;
|
||||
max-width: 100%;
|
||||
}
|
||||
.check {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
Reference in New Issue
Block a user