|
@@ -82,98 +82,14 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
/**
|
|
|
@条件1 当examId有值,则paperId 和 owner必定有值,sheet代表一个评测下的某一个试卷的答题卡数据,且答题卡的scope对应为评测的scope,且school和creatorId 与评测保持一致,且sheet.id从前端传递来的无效,
|
|
|
因为id需要根据当前评测examId的试卷绑定的答题卡覆写或者新建
|
|
|
- 如果检测到examId下对应的试卷绑定答题卡sheet为空则新生成一个答题卡id,并自动绑定。如果检测评测对应的试卷已经绑定答题卡,则只需要更新实时的答题卡数据。
|
|
|
-
|
|
|
+ 如果检测到examId下对应的试卷绑定答题卡sheet为空则新生成一个答题卡id,并自动绑定。
|
|
|
@条件2 当examId没有值,且paperId有值,sheet代表一个试卷库的某一个试卷的答题卡数据,且答题卡的scope对应为试卷库paperId的scope,且school和creatorId 与评测保持一致,且sheet.id从前端传递来的无效,
|
|
|
因为id需要根据试卷绑定的答题卡覆写或者新建
|
|
|
如果检测到paperId的试卷绑定的答题卡sheett为空则新生成一个答题卡id,并自动绑定。如果检测aperId的试卷已经绑定答题卡,则只需要更新实时的答题卡数据。
|
|
|
-
|
|
|
@条件3 当examId和paperId都没有值,sheet代表与评测,试卷库无关的答题卡数据,且答题卡的scope ,school和creatorId 根据当前创建者需要保存数据的规则有关。
|
|
|
且sheet.id,如果有值则是更新答题卡内容数据。
|
|
|
如果sheet.id,没有值则是新建保存答题卡数据。
|
|
|
-
|
|
|
@条件4 其他情况的参数传递不予以考虑,直接返回400参数错误。
|
|
|
-{ "examId":"31d0c8e4-ab94-42a0-8b38-d22a0c02a083",
|
|
|
- "paperId":"6bf05899-8bc6-2d74-0f4c-e339da79fc33",
|
|
|
- "owner":"teacher/shcool"
|
|
|
- "sheet": {
|
|
|
- "id": "2553744",
|
|
|
- "code": "hbcn",
|
|
|
- "school": "hbcn",
|
|
|
- "creatorId": "1595321354",
|
|
|
- "scope": "teacher",
|
|
|
- "columns": 1,
|
|
|
- "pageWidth": 2150,
|
|
|
- "pageHeight": 3000,
|
|
|
- "pageNumBlockCount": 3,
|
|
|
- "pageNumStartValue": 1,
|
|
|
- "threshValue": [
|
|
|
- 190,
|
|
|
- 220,
|
|
|
- 10
|
|
|
- ],
|
|
|
- "threshValuePhone": [
|
|
|
- 190,
|
|
|
- 220,
|
|
|
- 10
|
|
|
- ],
|
|
|
- "huiSize": 70,
|
|
|
- "minHuiSize": 0.005,
|
|
|
- "maxHuiSize": 0.1,
|
|
|
- "notHuisRect": [
|
|
|
- 0.3,
|
|
|
- 0.3,
|
|
|
- 0.4,
|
|
|
- 0.4
|
|
|
- ],
|
|
|
- "contents": [
|
|
|
- {
|
|
|
- "type": 0,
|
|
|
- "x": 200,
|
|
|
- "y": 261,
|
|
|
- "width": 1760,
|
|
|
- "height": 610,
|
|
|
- "pageNum": 1,
|
|
|
- "vblockCount": 10,
|
|
|
- "hblockCount": 10,
|
|
|
- "id": "12dae-ea-daefgh-easa",
|
|
|
- "isFix": false
|
|
|
- },
|
|
|
- {
|
|
|
- "type": 1,
|
|
|
- "x": 200,
|
|
|
- "y": 1000,
|
|
|
- "width": 1760,
|
|
|
- "height": 520,
|
|
|
- "pageNum": 1,
|
|
|
- "vblockCount": 5,
|
|
|
- "hblockCount": 25,
|
|
|
- "id": "12dae-ea-daefgh-easa",
|
|
|
- "isFix": false
|
|
|
- },
|
|
|
- {
|
|
|
- "type": 2,
|
|
|
- "x": 200,
|
|
|
- "y": 1760,
|
|
|
- "width": 1760,
|
|
|
- "height": 430,
|
|
|
- "pageNum": 1,
|
|
|
- "id": "12dae-ea-daefgh-easa",
|
|
|
- "isFix": false
|
|
|
- },
|
|
|
- {
|
|
|
- "type": 2,
|
|
|
- "x": 200,
|
|
|
- "y": 2350,
|
|
|
- "width": 1760,
|
|
|
- "height": 430,
|
|
|
- "pageNum": 1,
|
|
|
- "id": "12dae-ea-daefgh-easa",
|
|
|
- "isFix": false
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
-}
|
|
|
**/
|
|
|
/// <summary>
|
|
|
/// 新增 或 修改答题卡
|
|
@@ -198,12 +114,14 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
if (!sheet.code.StartsWith("SheetConfig-")) {
|
|
|
sheet.code = $"SheetConfig-{sheet.code}";
|
|
|
}
|
|
|
+
|
|
|
sheet.pk = $"SheetConfig";
|
|
|
sheet.ttl = -1;
|
|
|
string tbname = sheet.scope.Equals("school", StringComparison.OrdinalIgnoreCase)? "School": "Teacher";
|
|
|
// @条件1 代表需要更新评测的某一个试卷的答题卡
|
|
|
if (!_paperId.ValueKind.Equals(JsonValueKind.Null) && !_examId.ValueKind.Equals(JsonValueKind.Null) && !string.IsNullOrEmpty($"{ _examId}") && !string.IsNullOrEmpty($"{ _paperId}"))
|
|
|
{
|
|
|
+ sheet.from = "exam";
|
|
|
string code = "";
|
|
|
if (!string.IsNullOrEmpty($"{_owner}") && $"{_owner}".Equals("school", StringComparison.OrdinalIgnoreCase)) {
|
|
|
code = $"Exam-{sheet.school}";
|
|
@@ -219,18 +137,18 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
var ps = exam.papers.Where(p => p.id == $"{_paperId}").FirstOrDefault();
|
|
|
if (ps != null)
|
|
|
{
|
|
|
- if (!string.IsNullOrEmpty(ps.sheet))
|
|
|
+ if (string.IsNullOrEmpty(ps.sheet))
|
|
|
{
|
|
|
- await client.GetContainer(Constant.TEAMModelOS, tbname).DeleteItemStreamAsync($"{ps.sheet}", new PartitionKey(sheet.code));
|
|
|
+ sheet.id = Guid.NewGuid().ToString();
|
|
|
+ ps.sheet = sheet.id;
|
|
|
}
|
|
|
- sheet.id = await SheetService.genSheetId(client, _dingDing, _option, sheet.code, tbname);
|
|
|
- exam.papers.ForEach(x =>
|
|
|
- {
|
|
|
- if (x.id.Equals($"{_paperId}"))
|
|
|
- {
|
|
|
- x.sheet = sheet.id;
|
|
|
- }
|
|
|
- });
|
|
|
+ else {
|
|
|
+ sheet.id = ps.sheet;
|
|
|
+ }
|
|
|
+ if (string.IsNullOrEmpty(sheet.no)) {
|
|
|
+ sheet.no = await SheetService.genSheetNo(client, _dingDing, _option, sheet.code, tbname, sheet.from);
|
|
|
+ }
|
|
|
+ ps.sheetNo = sheet.no;
|
|
|
exam = await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamInfo>(exam, $"{_examId}", new PartitionKey($"{code}"));
|
|
|
}
|
|
|
else
|
|
@@ -247,13 +165,14 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
else if ((string.IsNullOrEmpty($"{ _examId}") || !_examId.ValueKind.Equals(JsonValueKind.Null))
|
|
|
&& !_paperId.ValueKind.Equals(JsonValueKind.Null) && !string.IsNullOrEmpty($"{ _paperId}"))
|
|
|
{
|
|
|
+ sheet.from = "paper";
|
|
|
string code = sheet.scope.Equals("school", StringComparison.OrdinalIgnoreCase) ? $"Paper-{sheet.school}": $"Paper-{sheet.creatorId}";
|
|
|
try
|
|
|
{
|
|
|
Paper paper = await client.GetContainer(Constant.TEAMModelOS, tbname).ReadItemAsync<Paper>($"{_paperId}", new PartitionKey($"{code}"));
|
|
|
if (string.IsNullOrEmpty(paper.sheet))
|
|
|
{
|
|
|
- sheet.id =await SheetService.genSheetId(client, _dingDing, _option, sheet.code, tbname);
|
|
|
+ sheet.no = await SheetService.genSheetNo(client, _dingDing, _option, sheet.code, tbname, sheet.from);
|
|
|
paper.sheet = sheet.id;
|
|
|
paper = await client.GetContainer(Constant.TEAMModelOS, tbname).ReplaceItemAsync<Paper>(paper, $"{_paperId}", new PartitionKey($"{code}"));
|
|
|
}
|
|
@@ -261,6 +180,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
{
|
|
|
sheet.id = paper.sheet;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
@@ -270,17 +190,18 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
//@条件3 代表需要直接产生一个答题卡
|
|
|
else if (string.IsNullOrEmpty($"{ _examId}") && string.IsNullOrEmpty($"{ _paperId}"))
|
|
|
{
|
|
|
+ sheet.from = "sheet";
|
|
|
if (string.IsNullOrEmpty(sheet.id)) {
|
|
|
- sheet.id = await SheetService.genSheetId(client, _dingDing, _option, sheet.code, tbname);
|
|
|
+ sheet.no = await SheetService.genSheetNo(client, _dingDing, _option, sheet.code, tbname, sheet.from);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
//@条件4
|
|
|
return BadRequest("params is error!");
|
|
|
}
|
|
|
- if (string.IsNullOrEmpty(sheet.id))
|
|
|
+ if (string.IsNullOrEmpty(sheet.no))
|
|
|
{
|
|
|
- sheet.id = await SheetService.genSheetId(client, _dingDing, _option, sheet.code, tbname);
|
|
|
+ sheet.no = await SheetService.genSheetNo(client, _dingDing, _option, sheet.code, tbname,sheet.from);
|
|
|
|
|
|
}
|
|
|
sheet = await client.GetContainer(Constant.TEAMModelOS, tbname).UpsertItemAsync(sheet, new PartitionKey($"{sheet.code}"));
|