|
@@ -306,7 +306,7 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- ExamClassResult classResult;
|
|
|
|
|
|
+ ExamClassResult classResult = new ExamClassResult() ;
|
|
List<PaperSimple> standerAnswers = new List<PaperSimple>();
|
|
List<PaperSimple> standerAnswers = new List<PaperSimple>();
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(
|
|
queryText: $"select A0.point,A0.answers from c join A0 in c.papers where c.id = '{id}'and A0.id = '{paperId}'",
|
|
queryText: $"select A0.point,A0.answers from c join A0 in c.papers where c.id = '{id}'and A0.id = '{paperId}'",
|
|
@@ -322,158 +322,165 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
}
|
|
}
|
|
List<List<string>> ans = answer.ToObject<List<List<string>>>();
|
|
List<List<string>> ans = answer.ToObject<List<List<string>>>();
|
|
- List<List<string>> standard = standerAnswers[0].answers;
|
|
|
|
- List<double> points = standerAnswers[0].point;
|
|
|
|
- int index = examClassResults[0].studentIds.IndexOf(studentId.ToString());
|
|
|
|
|
|
+ List<List<string>> standard = new List<List<string>>();
|
|
|
|
+ List<double> points = new List<double>();
|
|
int rule = int.Parse(multipleRule.ToString());
|
|
int rule = int.Parse(multipleRule.ToString());
|
|
- //classResult.studentAnswers[index] = ans;
|
|
|
|
- if (index == -1)
|
|
|
|
- {
|
|
|
|
- examClassResults[0].studentIds.Add(studentId.ToString());
|
|
|
|
- examClassResults[0].studentScores.Add(new List<double>());
|
|
|
|
- examClassResults[0].studentAnswers.Add(new List<List<string>>());
|
|
|
|
|
|
+ foreach (PaperSimple simple in standerAnswers) {
|
|
|
|
+ standard = simple.answers;
|
|
|
|
+ points = simple.point;
|
|
}
|
|
}
|
|
- for (int i = 0; i < ans.Count; i++)
|
|
|
|
- {
|
|
|
|
- examClassResults[0].studentAnswers[index][i] = ans[i];
|
|
|
|
- //算分处理
|
|
|
|
- if (standard[i].Count > 0)
|
|
|
|
|
|
+ foreach (ExamClassResult result in examClassResults) {
|
|
|
|
+ int index = result.studentIds.IndexOf(studentId.ToString());
|
|
|
|
+ //classResult.studentAnswers[index] = ans;
|
|
|
|
+ if (index == -1)
|
|
|
|
+ {
|
|
|
|
+ result.studentIds.Add(studentId.ToString());
|
|
|
|
+ result.studentScores.Add(new List<double>());
|
|
|
|
+ result.studentAnswers.Add(new List<List<string>>());
|
|
|
|
+ }
|
|
|
|
+ for (int i = 0; i < ans.Count; i++)
|
|
{
|
|
{
|
|
- if (ans[i].Count == standard[i].Count && standard[i].Count == 1)
|
|
|
|
|
|
+ result.studentAnswers[index][i] = ans[i];
|
|
|
|
+ //算分处理
|
|
|
|
+ if (standard[i].Count > 0)
|
|
{
|
|
{
|
|
- foreach (string right in ans[i])
|
|
|
|
|
|
+ if (ans[i].Count == standard[i].Count && standard[i].Count == 1)
|
|
{
|
|
{
|
|
- if (standard[i].Contains(right))
|
|
|
|
|
|
+ foreach (string right in ans[i])
|
|
{
|
|
{
|
|
- examClassResults[0].studentScores[index][i] = points[i];
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- examClassResults[0].studentScores[index][i] = 0;
|
|
|
|
|
|
+ if (standard[i].Contains(right))
|
|
|
|
+ {
|
|
|
|
+ result.studentScores[index][i] = points[i];
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ result.studentScores[index][i] = 0;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- if (rule > 0)
|
|
|
|
|
|
+ }
|
|
|
|
+ else
|
|
{
|
|
{
|
|
- int falseCount = 0;
|
|
|
|
- foreach (string obj in ans[i])
|
|
|
|
|
|
+ if (rule > 0)
|
|
{
|
|
{
|
|
- if (!standard[i].Contains(obj))
|
|
|
|
|
|
+ int falseCount = 0;
|
|
|
|
+ foreach (string obj in ans[i])
|
|
{
|
|
{
|
|
- falseCount++;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- switch (rule)
|
|
|
|
- {
|
|
|
|
- case 1:
|
|
|
|
- if (ans[i].Count == standard[i].Count)
|
|
|
|
|
|
+ if (!standard[i].Contains(obj))
|
|
{
|
|
{
|
|
- if (falseCount == 0)
|
|
|
|
|
|
+ falseCount++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ switch (rule)
|
|
|
|
+ {
|
|
|
|
+ case 1:
|
|
|
|
+ if (ans[i].Count == standard[i].Count)
|
|
{
|
|
{
|
|
- examClassResults[0].studentScores[index][i] = points[i];
|
|
|
|
|
|
+ if (falseCount == 0)
|
|
|
|
+ {
|
|
|
|
+ result.studentScores[index][i] = points[i];
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ result.studentScores[index][i] = 0;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- examClassResults[0].studentScores[index][i] = 0;
|
|
|
|
|
|
+ result.studentScores[index][i] = 0;
|
|
}
|
|
}
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- examClassResults[0].studentScores[index][i] = 0;
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 2:
|
|
|
|
- if (falseCount > 0)
|
|
|
|
- {
|
|
|
|
- examClassResults[0].studentScores[index][i] = 0;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- if (ans[i].Count == standard[i].Count)
|
|
|
|
|
|
+ break;
|
|
|
|
+ case 2:
|
|
|
|
+ if (falseCount > 0)
|
|
{
|
|
{
|
|
- examClassResults[0].studentScores[index][i] = points[i];
|
|
|
|
|
|
+ result.studentScores[index][i] = 0;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- examClassResults[0].studentScores[index][i] = points[i] / 2;
|
|
|
|
- }
|
|
|
|
|
|
+ if (ans[i].Count == standard[i].Count)
|
|
|
|
+ {
|
|
|
|
+ result.studentScores[index][i] = points[i];
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ result.studentScores[index][i] = points[i] / 2;
|
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 3:
|
|
|
|
- if (falseCount > 0)
|
|
|
|
- {
|
|
|
|
- examClassResults[0].studentScores[index][i] = 0;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- if (ans[i].Count == standard[i].Count)
|
|
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 3:
|
|
|
|
+ if (falseCount > 0)
|
|
{
|
|
{
|
|
- examClassResults[0].studentScores[index][i] = points[i];
|
|
|
|
|
|
+ result.studentScores[index][i] = 0;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- examClassResults[0].studentScores[index][i] = System.Math.Round((double)ans[i].Count / standard[i].Count * points[i], 1);
|
|
|
|
- }
|
|
|
|
|
|
+ if (ans[i].Count == standard[i].Count)
|
|
|
|
+ {
|
|
|
|
+ result.studentScores[index][i] = points[i];
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ result.studentScores[index][i] = System.Math.Round((double)ans[i].Count / standard[i].Count * points[i], 1);
|
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 4:
|
|
|
|
- if (ans[i].Count == standard[i].Count)
|
|
|
|
- {
|
|
|
|
- examClassResults[0].studentScores[index][i] = points[i];
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- double persent = (double)(standard[i].Count - 2 * falseCount) / standard[i].Count;
|
|
|
|
- if (persent <= 0)
|
|
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 4:
|
|
|
|
+ if (ans[i].Count == standard[i].Count)
|
|
{
|
|
{
|
|
- examClassResults[0].studentScores[index][i] = 0;
|
|
|
|
|
|
+ result.studentScores[index][i] = points[i];
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- examClassResults[0].studentScores[index][i] = System.Math.Round(persent * points[i], 1);
|
|
|
|
|
|
+ double persent = (double)(standard[i].Count - 2 * falseCount) / standard[i].Count;
|
|
|
|
+ if (persent <= 0)
|
|
|
|
+ {
|
|
|
|
+ result.studentScores[index][i] = 0;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ result.studentScores[index][i] = System.Math.Round(persent * points[i], 1);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- break;
|
|
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- /*if (examClassResults[0].studentScores.Contains(-1)) {
|
|
|
|
|
|
+ /*if (result.studentScores.Contains(-1)) {
|
|
|
|
|
|
- }*/
|
|
|
|
- bool flag = true;
|
|
|
|
- foreach (List<double> scores in examClassResults[0].studentScores)
|
|
|
|
- {
|
|
|
|
- foreach (double score in scores)
|
|
|
|
|
|
+ }*/
|
|
|
|
+ bool flag = true;
|
|
|
|
+ foreach (List<double> scores in result.studentScores)
|
|
{
|
|
{
|
|
- if (score == -1)
|
|
|
|
|
|
+ foreach (double score in scores)
|
|
{
|
|
{
|
|
- flag = false;
|
|
|
|
- break;
|
|
|
|
|
|
+ if (score == -1)
|
|
|
|
+ {
|
|
|
|
+ flag = false;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- if (flag)
|
|
|
|
- {
|
|
|
|
- ExamInfo exam = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{school}"));
|
|
|
|
- examClassResults[0].progress = true;
|
|
|
|
- exam.subjects.ForEach(s =>
|
|
|
|
|
|
+ if (flag)
|
|
{
|
|
{
|
|
- if (s.id.Equals(subjectId.ToString()))
|
|
|
|
|
|
+ ExamInfo exam = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{school}"));
|
|
|
|
+ result.progress = true;
|
|
|
|
+ exam.subjects.ForEach(s =>
|
|
{
|
|
{
|
|
- s.classCount += 1;
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"Exam-{school}"));
|
|
|
|
|
|
+ if (s.id.Equals(subjectId.ToString()))
|
|
|
|
+ {
|
|
|
|
+ s.classCount += 1;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"Exam-{school}"));
|
|
|
|
+ }
|
|
|
|
+ result.sum[index] = result.studentScores[index].Sum();
|
|
|
|
+ classResult = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(result, result.id, new PartitionKey($"{result.code}"));
|
|
}
|
|
}
|
|
- examClassResults[0].sum[index] = examClassResults[0].studentScores[index].Sum();
|
|
|
|
- classResult = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(examClassResults[0], examClassResults[0].id, new PartitionKey($"{examClassResults[0].code}"));
|
|
|
|
|
|
+
|
|
return Ok(new { classResult });
|
|
return Ok(new { classResult });
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
catch (Exception e)
|
|
@@ -517,53 +524,56 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- ExamClassResult classResult;
|
|
|
|
|
|
+ ExamClassResult classResult = new ExamClassResult();
|
|
//ExamInfo classResult = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"{code}"));
|
|
//ExamInfo classResult = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"{code}"));
|
|
//ExamClassResult classResult = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamClassResult>(id.ToString(), new PartitionKey($"{code}"));
|
|
//ExamClassResult classResult = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamClassResult>(id.ToString(), new PartitionKey($"{code}"));
|
|
/*foreach (double index in ans) {
|
|
/*foreach (double index in ans) {
|
|
classResult.studentScores.in
|
|
classResult.studentScores.in
|
|
}*/
|
|
}*/
|
|
- int index = examClassResults[0].studentIds.IndexOf(studentId.ToString());
|
|
|
|
- for (int i = 0; i < ans.Count; i++)
|
|
|
|
- {
|
|
|
|
- examClassResults[0].studentScores[index][i] = ans[i];
|
|
|
|
- }
|
|
|
|
- if (!examClassResults[0].progress)
|
|
|
|
- {
|
|
|
|
- bool flag = true;
|
|
|
|
- foreach (List<double> scores in examClassResults[0].studentScores)
|
|
|
|
|
|
+ foreach (ExamClassResult result in examClassResults) {
|
|
|
|
+ int index = result.studentIds.IndexOf(studentId.ToString());
|
|
|
|
+ for (int i = 0; i < ans.Count; i++)
|
|
{
|
|
{
|
|
- foreach (double score in scores)
|
|
|
|
|
|
+ result.studentScores[index][i] = ans[i];
|
|
|
|
+ }
|
|
|
|
+ if (!result.progress)
|
|
|
|
+ {
|
|
|
|
+ bool flag = true;
|
|
|
|
+ foreach (List<double> scores in result.studentScores)
|
|
{
|
|
{
|
|
- if (score == -1)
|
|
|
|
|
|
+ foreach (double score in scores)
|
|
{
|
|
{
|
|
- flag = false;
|
|
|
|
- break;
|
|
|
|
|
|
+ if (score == -1)
|
|
|
|
+ {
|
|
|
|
+ flag = false;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if (flag)
|
|
|
|
+ {
|
|
|
|
+ ExamInfo exam = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{school}"));
|
|
|
|
+ result.progress = true;
|
|
|
|
+ exam.subjects.ForEach(s =>
|
|
|
|
+ {
|
|
|
|
+ if (s.id.Equals(subjectId.ToString()))
|
|
|
|
+ {
|
|
|
|
+ s.classCount += 1;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"Exam-{school}"));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- if (flag)
|
|
|
|
|
|
+ else
|
|
{
|
|
{
|
|
ExamInfo exam = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{school}"));
|
|
ExamInfo exam = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{school}"));
|
|
- examClassResults[0].progress = true;
|
|
|
|
- exam.subjects.ForEach(s =>
|
|
|
|
- {
|
|
|
|
- if (s.id.Equals(subjectId.ToString()))
|
|
|
|
- {
|
|
|
|
- s.classCount += 1;
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ exam.updateTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"Exam-{school}"));
|
|
await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"Exam-{school}"));
|
|
}
|
|
}
|
|
|
|
+ result.sum[index] = result.studentScores[index].Sum();
|
|
|
|
+ classResult = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(result, result.id, new PartitionKey($"{result.code}"));
|
|
}
|
|
}
|
|
- else
|
|
|
|
- {
|
|
|
|
- ExamInfo exam = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{school}"));
|
|
|
|
- exam.updateTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
|
- await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"Exam-{school}"));
|
|
|
|
- }
|
|
|
|
- examClassResults[0].sum[index] = examClassResults[0].studentScores[index].Sum();
|
|
|
|
- classResult = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(examClassResults[0], examClassResults[0].id, new PartitionKey($"{examClassResults[0].code}"));
|
|
|
|
|
|
+
|
|
return Ok(new { classResult });
|
|
return Ok(new { classResult });
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|