提交 a0a14685 authored 作者: yujiejie's avatar yujiejie

导师端验收台静态接入

上级 1805d707
......@@ -1522,6 +1522,193 @@ function buildMentorDeployCompletenessNotice(sub) {
'<div>该学生提交材料不完整:缺少<b class="mx-0.5">' + missing.join('、') + '</b>,暂不能提交「通过」验收结论。</div></div>';
}
// ===== 导师部署验收台:验收参数与测试状态(按学生索引,临时值不改学生原始提交) =====
var mentorDeployReviewState = {
params: {},
tests: {}
};
function getMentorDeployReviewParams(studentId) {
var sid = Number(studentId);
var sub = getMentorDeploySubmission(sid);
var a = (sub && sub.artifact) || {};
var saved = mentorDeployReviewState.params[sid] || {};
return {
apiUrl: saved.apiUrl != null ? saved.apiUrl : (a.apiUrl || ''),
apiKey: saved.apiKey != null ? saved.apiKey : (a.apiKey || ''),
modelName: saved.modelName != null ? saved.modelName : (a.modelName || ''),
apiPath: saved.apiPath != null ? saved.apiPath : (a.apiPath || '/v1/chat/completions'),
prompt: saved.prompt != null ? saved.prompt : '请用一句话介绍你自己。',
maxTokens: saved.maxTokens != null ? saved.maxTokens : '2048',
temperature: saved.temperature != null ? saved.temperature : '0.7',
imagePrompt: saved.imagePrompt != null ? saved.imagePrompt : '一只戴蓝色围巾的柴犬,半身像,自然光',
size: saved.size != null ? saved.size : '1024x1024',
seed: saved.seed != null ? saved.seed : ''
};
}
function setMentorDeployReviewParam(field, value) {
var sid = Number(mentorState.deployReviewStudentId);
if (!mentorDeployReviewState.params[sid]) mentorDeployReviewState.params[sid] = {};
mentorDeployReviewState.params[sid][field] = value;
}
function restoreMentorDeployReviewParams() {
var sid = Number(mentorState.deployReviewStudentId);
mentorDeployReviewState.params[sid] = {};
renderContent();
}
function mentorDeployTestNotReady(name) {
showStudentFlowModal('测试功能待接入', '「' + name + '」的 API 测试将在下一步接入,当前为验收台静态布局预览。');
}
function buildMentorDeployTestItemHeader(method, path, name, result) {
var badge = 'bg-[#F2F3F5] text-[#86909C]';
var badgeText = '未测试';
if (result) {
if (result.status === 'pass') { badge = 'bg-emerald-100 text-emerald-700'; badgeText = '已通过'; }
else if (result.status === 'fail') { badge = 'bg-rose-100 text-rose-700'; badgeText = '失败'; }
else { badge = 'bg-amber-100 text-amber-700'; badgeText = '测试中'; }
}
return '<div class="flex items-center justify-between mb-1"><div><span class="font-mono text-sm text-[#1D2129] font-medium">' + method + ' ' + path + '</span><span class="text-xs text-[#86909C] ml-2">' + name + '</span></div><span class="text-xs px-2 py-0.5 rounded ' + badge + '">' + badgeText + '</span></div>';
}
function buildMentorDeployTestMeta(result) {
if (!result) {
return '<div class="flex items-center gap-3 text-xs text-[#86909C] mt-2"><span>状态码:—</span><span>耗时:—</span></div>';
}
var codeCls = result.httpStatus >= 200 && result.httpStatus < 300 ? 'text-emerald-600' : (result.httpStatus ? 'text-rose-500' : 'text-[#86909C]');
return '<div class="flex items-center gap-3 text-xs mt-2"><span class="text-[#86909C]">状态码:<b class="' + codeCls + '">' + (result.httpStatus || '—') + '</b></span><span class="text-[#86909C]">耗时:<b class="text-[#1D2129]">' + (result.latency != null ? result.latency + ' ms' : '—') + '</b></span></div>';
}
function buildMentorDeployTestError(result) {
if (!result || !result.error) return '';
return '<div class="mt-2 text-xs text-rose-500 bg-rose-50 border border-rose-100 rounded p-2">' + mentorDeployReviewEsc(result.error) + '</div>';
}
function buildMentorDeployTestSummary(tests, keys) {
var done = 0, passed = 0;
keys.forEach(function(k) {
if (tests[k] && tests[k].status) done++;
if (tests[k] && tests[k].status === 'pass') passed++;
});
if (done === 0) return '未测试';
return passed + '/' + keys.length + ' 通过';
}
function buildMentorDeployParamsPanel(sid) {
var p = getMentorDeployReviewParams(sid);
return '<div class="bg-white rounded-lg border border-[#E5E6EB] p-4 mb-4">' +
'<div class="flex items-center justify-between mb-2"><h3 class="font-semibold text-[#1D2129]">验收参数</h3><span class="text-xs px-2 py-1 rounded bg-[#E8F3FF] text-[#165DFF]">临时调整</span></div>' +
'<p class="text-xs text-[#86909C] mb-3">已带入学生提交值,以下调整仅用于本次验收,不会修改学生原始提交内容。</p>' +
'<div class="space-y-2.5">' +
'<div><label class="text-xs font-medium text-[#4E5969] block mb-1">API 地址</label><input class="input-field text-sm font-mono" value="' + mentorDeployReviewEsc(p.apiUrl) + '" placeholder="http://IP:端口" oninput="setMentorDeployReviewParam(\'apiUrl\', this.value)"></div>' +
'<div><label class="text-xs font-medium text-[#4E5969] block mb-1">API Key</label><input class="input-field text-sm font-mono" type="password" value="' + mentorDeployReviewEsc(p.apiKey) + '" placeholder="sk-..." oninput="setMentorDeployReviewParam(\'apiKey\', this.value)"></div>' +
'<div class="grid grid-cols-2 gap-2">' +
'<div><label class="text-xs font-medium text-[#4E5969] block mb-1">模型名称</label><input class="input-field text-sm font-mono" value="' + mentorDeployReviewEsc(p.modelName) + '" oninput="setMentorDeployReviewParam(\'modelName\', this.value)"></div>' +
'<div><label class="text-xs font-medium text-[#4E5969] block mb-1">请求路径</label><input class="input-field text-sm font-mono" value="' + mentorDeployReviewEsc(p.apiPath) + '" oninput="setMentorDeployReviewParam(\'apiPath\', this.value)"></div>' +
'</div>' +
'</div>' +
'<button class="btn-outline w-full mt-3 py-2 text-sm" onclick="restoreMentorDeployReviewParams()">恢复学生提交值</button>' +
'</div>';
}
function buildMentorDeployTextModelItems(sid) {
var p = getMentorDeployReviewParams(sid);
var tests = mentorDeployReviewState.tests[sid] || {};
var modelsResult = tests.models || null;
var chatResult = tests.chat || null;
var modelName = p.modelName;
return '<div class="bg-white rounded-lg border border-[#E5E6EB] p-4 mb-4">' +
'<div class="flex items-center justify-between mb-3"><h3 class="font-semibold text-[#1D2129]">文本模型验收项</h3><span class="text-xs px-2 py-1 rounded bg-[#F2F3F5] text-[#86909C]">' + buildMentorDeployTestSummary(tests, ['models', 'chat']) + '</span></div>' +
'<div class="p-3 rounded-lg bg-[#F7F8FA] mb-3">' +
buildMentorDeployTestItemHeader('GET', '/v1/models', '模型列表', modelsResult) +
buildMentorDeployTestMeta(modelsResult) +
(modelsResult && modelsResult.modelFound != null
? '<div class="mt-1.5 text-xs ' + (modelsResult.modelFound ? 'text-emerald-600' : 'text-rose-500') + '">' + (modelsResult.modelFound ? '已包含声明的模型 ' + mentorDeployReviewEsc(modelName) : '未找到声明的模型 ' + mentorDeployReviewEsc(modelName)) + '</div>'
: '') +
buildMentorDeployTestError(modelsResult) +
(modelsResult && modelsResult.raw != null ? '<pre class="mt-2 bg-[#1D2129] text-emerald-300 rounded p-3 text-[10px] overflow-auto max-h-32 leading-relaxed">' + mentorDeployReviewEsc(modelsResult.raw) + '</pre>' : '') +
'<button class="btn-outline w-full mt-3 py-2 text-sm" onclick="mentorDeployTestNotReady(\'模型列表\')">测试</button>' +
'</div>' +
'<div class="p-3 rounded-lg bg-[#F7F8FA]">' +
buildMentorDeployTestItemHeader('POST', '/v1/chat/completions', '聊天补全', chatResult) +
'<div class="mt-2"><label class="text-xs font-medium text-[#4E5969] block mb-1">测试提示词</label><textarea class="input-field text-sm min-h-[64px] resize-none" oninput="setMentorDeployReviewParam(\'prompt\', this.value)">' + mentorDeployReviewEsc(p.prompt) + '</textarea></div>' +
'<div class="grid grid-cols-2 gap-2 mt-2">' +
'<div><label class="text-xs font-medium text-[#4E5969] block mb-1">Max Tokens</label><input class="input-field text-sm" value="' + mentorDeployReviewEsc(p.maxTokens) + '" oninput="setMentorDeployReviewParam(\'maxTokens\', this.value)"></div>' +
'<div><label class="text-xs font-medium text-[#4E5969] block mb-1">Temperature</label><input class="input-field text-sm" value="' + mentorDeployReviewEsc(p.temperature) + '" oninput="setMentorDeployReviewParam(\'temperature\', this.value)"></div>' +
'</div>' +
buildMentorDeployTestMeta(chatResult) +
(chatResult && chatResult.responseText ? '<div class="mt-2 p-2 rounded bg-white border border-[#E5E6EB] text-xs leading-relaxed whitespace-pre-wrap">' + mentorDeployReviewEsc(chatResult.responseText) + '</div>' : '') +
buildMentorDeployTestError(chatResult) +
(chatResult && chatResult.raw != null ? '<pre class="mt-2 bg-[#1D2129] text-emerald-300 rounded p-3 text-[10px] overflow-auto max-h-32 leading-relaxed">' + mentorDeployReviewEsc(chatResult.raw) + '</pre>' : '') +
'<button class="btn-primary w-full mt-3 py-2 text-sm" onclick="mentorDeployTestNotReady(\'聊天补全\')">测试</button>' +
'</div>' +
'</div>';
}
function getMentorDeploySizeOptions(current) {
var opts = ['1024x1024', '1664x928', '928x1664'];
return opts.map(function(sz) {
return '<option value="' + sz + '"' + (sz === current ? ' selected' : '') + '>' + sz.replace('x', ' × ') + '</option>';
}).join('');
}
function buildMentorDeployImageGenItems(sid) {
var p = getMentorDeployReviewParams(sid);
var tests = mentorDeployReviewState.tests[sid] || {};
var modelsResult = tests.models || null;
var genResult = tests.genSubmit || null;
var statusResult = tests.genStatus || null;
return '<div class="bg-white rounded-lg border border-[#E5E6EB] p-4 mb-4">' +
'<div class="flex items-center justify-between mb-3"><h3 class="font-semibold text-[#1D2129]">图像生成验收项</h3><span class="text-xs px-2 py-1 rounded bg-[#F2F3F5] text-[#86909C]">' + buildMentorDeployTestSummary(tests, ['models', 'genSubmit', 'genStatus']) + '</span></div>' +
'<div class="p-3 rounded-lg bg-[#F7F8FA] mb-3">' +
buildMentorDeployTestItemHeader('GET', '/v1/models', '图像模型列表', modelsResult) +
buildMentorDeployTestMeta(modelsResult) +
buildMentorDeployTestError(modelsResult) +
'<button class="btn-outline w-full mt-3 py-2 text-sm" onclick="mentorDeployTestNotReady(\'图像模型列表\')">测试</button>' +
'</div>' +
'<div class="p-3 rounded-lg bg-[#F7F8FA] mb-3">' +
buildMentorDeployTestItemHeader('POST', '/v1/generations', '提交生成任务', genResult) +
'<div class="mt-2"><label class="text-xs font-medium text-[#4E5969] block mb-1">生成描述</label><textarea class="input-field text-sm min-h-[64px] resize-none" oninput="setMentorDeployReviewParam(\'imagePrompt\', this.value)">' + mentorDeployReviewEsc(p.imagePrompt) + '</textarea></div>' +
'<div class="grid grid-cols-2 gap-2 mt-2">' +
'<div><label class="text-xs font-medium text-[#4E5969] block mb-1">图片尺寸</label><select class="input-field text-sm" onchange="setMentorDeployReviewParam(\'size\', this.value)">' + getMentorDeploySizeOptions(p.size) + '</select></div>' +
'<div><label class="text-xs font-medium text-[#4E5969] block mb-1">随机种子</label><input class="input-field text-sm" placeholder="可选" value="' + mentorDeployReviewEsc(p.seed) + '" oninput="setMentorDeployReviewParam(\'seed\', this.value)"></div>' +
'</div>' +
buildMentorDeployTestMeta(genResult) +
(genResult && genResult.taskId ? '<div class="mt-1.5 text-xs text-[#4E5969]">任务 ID:<b class="font-mono">' + mentorDeployReviewEsc(genResult.taskId) + '</b></div>' : '') +
buildMentorDeployTestError(genResult) +
'<button class="btn-primary w-full mt-3 py-2 text-sm" onclick="mentorDeployTestNotReady(\'提交生成任务\')">提交生成任务</button>' +
'</div>' +
'<div class="p-3 rounded-lg bg-[#F7F8FA]">' +
buildMentorDeployTestItemHeader('GET', '/v1/generations/{id}', '查询生成任务', statusResult) +
buildMentorDeployTestMeta(statusResult) +
(statusResult && statusResult.taskStatus
? '<div class="mt-1.5 text-xs text-[#4E5969]">任务状态:<b class="' + (statusResult.taskStatus === 'succeeded' ? 'text-emerald-600' : 'text-[#1D2129]') + '">' + mentorDeployReviewEsc(statusResult.taskStatus) + '</b> · 进度:' + (statusResult.progress || 0) + '%</div>'
: '') +
buildMentorDeployTestError(statusResult) +
'<button class="btn-outline w-full mt-3 py-2 text-sm" onclick="mentorDeployTestNotReady(\'查询生成任务\')">查询状态</button>' +
'</div>' +
'</div>';
}
function buildMentorDeployConclusionPanel() {
return '<div class="bg-white rounded-lg border border-[#E5E6EB] p-4">' +
'<div class="flex items-center justify-between mb-3"><h3 class="font-semibold text-[#1D2129]">验收结论</h3><span class="text-xs px-2 py-1 rounded bg-[#F2F3F5] text-[#86909C]">下一步接入</span></div>' +
'<div class="rounded-lg bg-[#F7F8FA] p-5 text-center text-sm text-[#86909C]">通过 / 驳回 / 要求补充材料、评分与导师评语将在验收台功能确认后接入。</div>' +
'</div>';
}
function buildMentorDeployReviewPanel(student) {
if (!student) return '';
var sid = Number(student.id);
var sub = getMentorDeploySubmission(sid);
var taskType = (sub && sub.taskType === 'image-gen') ? 'image-gen' : 'text-model';
var itemsHtml = taskType === 'image-gen' ? buildMentorDeployImageGenItems(sid) : buildMentorDeployTextModelItems(sid);
return buildMentorDeployParamsPanel(sid) + itemsHtml + buildMentorDeployConclusionPanel();
}
function reviewDeployArtifact(passed) {
var comment = document.getElementById('deployReviewComment');
var text = comment ? comment.value.trim() : '';
......@@ -1544,7 +1731,8 @@ function reviewDeployArtifact(passed) {
sub.reportSubmitted = false;
}
renderContent();
showStudentFlowModal(passed ? '部署验收已通过' : '已驳回并允许重提', passed ? '学生可直接进入旧实操报告页面;报告评审通过后再申请答辩。' : '学生可根据导师评语修改后重新提交。');
showStudentFlowModal('API 验收台功能待接入', '「通过」按钮将在下一步接入。');
return;
}
pageRenderers["mentor-deploy-review"] = function() {
......@@ -1560,21 +1748,22 @@ pageRenderers["mentor-deploy-review"] = function() {
}).length;
var listHtml = buildMentorDeployStudentList(students, selectedId);
var contentHtml = selected
? '<div class="mb-4 flex items-center justify-between"><div><h3 class="font-semibold text-[#1D2129]">' + mentorDeployReviewEsc(selected.name) + ' · 提交内容</h3><p class="text-xs text-[#86909C] mt-1">学生提交内容只读展示,API 验收台将在下一步接入</p></div><span class="px-2.5 py-1 rounded-lg text-xs font-medium ' + statusClass + '">' + status + '</span></div>' +
? '<div class="mb-4 flex items-center justify-between"><div><h3 class="font-semibold text-[#1D2129]">' + mentorDeployReviewEsc(selected.name) + ' · 提交内容</h3><p class="text-xs text-[#86909C] mt-1">学生提交内容只读展示,验收参数与 API 测试见右侧验收台</p></div><span class="px-2.5 py-1 rounded-lg text-xs font-medium ' + statusClass + '">' + status + '</span></div>' +
buildMentorDeployCompletenessNotice(sub) +
buildMentorDeploySubmissionPanel(sub)
: '<div class="bg-white rounded-lg border border-[#E5E6EB] p-8 text-center text-[#86909C]">请先从左侧选择学生</div>';
return '<div class="max-w-7xl mx-auto">' +
'<div class="flex items-center justify-between mb-6"><div><h1 class="text-2xl font-bold text-[#1D2129]">部署验收</h1><p class="text-sm text-[#86909C] mt-1">选择负责学生,查看部署产物、实操日志与实操报告</p></div>' +
return '<div class="max-w-[1400px] mx-auto">' +
'<div class="flex items-center justify-between mb-6"><div><h1 class="text-2xl font-bold text-[#1D2129]">部署验收</h1><p class="text-sm text-[#86909C] mt-1">选择负责学生,查看提交内容并完成 API 验收</p></div>' +
'<span class="px-3 py-1.5 rounded-lg text-sm font-medium ' + statusClass + '">' + status + '</span></div>' +
'<div class="grid grid-cols-3 gap-5 mb-6">' +
'<div class="feature-card p-5"><div class="text-xs text-[#86909C]">负责学生</div><div class="text-2xl font-bold mt-1">' + students.length + '</div></div>' +
'<div class="feature-card p-5"><div class="text-xs text-[#86909C]">待验收提交</div><div class="text-2xl font-bold mt-1">' + pendingCount + '</div></div>' +
'<div class="feature-card p-5"><div class="text-xs text-[#86909C]">当前学生</div><div class="text-lg font-bold mt-1">' + (selected ? mentorDeployReviewEsc(selected.name) : '—') + '</div></div>' +
'</div>' +
'<div class="grid grid-cols-3 gap-6">' +
'<div class="bg-white rounded-lg border border-[#E5E6EB] p-5"><h3 class="font-semibold mb-4">我的学生</h3>' + (listHtml || '<div class="py-10 text-center text-sm text-[#86909C]">暂无负责学生</div>') + '</div>' +
'<div class="col-span-2">' + contentHtml + '</div>' +
'<div class="grid grid-cols-12 gap-6">' +
'<div class="col-span-3 bg-white rounded-lg border border-[#E5E6EB] p-5"><h3 class="font-semibold mb-4">我的学生</h3>' + (listHtml || '<div class="py-10 text-center text-sm text-[#86909C]">暂无负责学生</div>') + '</div>' +
'<div class="col-span-5">' + contentHtml + '</div>' +
'<div class="col-span-4">' + buildMentorDeployReviewPanel(selected) + '</div>' +
'</div></div>';
};
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论