Counting points
This commit is contained in:
parent
bf7de908d0
commit
680a87f4b7
@ -26,22 +26,26 @@ namespace WebApplication5.Templates
|
||||
foreach (string fileName in fileEntries.Where(f => f.EndsWith(".pdf")))
|
||||
{
|
||||
var answers = ProcessFile(fileName);
|
||||
var questions = _db.Questions.Include("Answers").Where(q => answers.Select(a => a.QuestionId).Contains(q.Id)).ToList();
|
||||
var questionsIds = answers.Select(a => a.QuestionId).ToList();
|
||||
var questions = _db.Questions.Include("Answers").Where(q => questionsIds.Contains(q.Id)).ToList();
|
||||
|
||||
var points = 0;
|
||||
var maxPoints = questions.Sum(q => q.DefaultScore);
|
||||
|
||||
foreach (var q in questions)
|
||||
{
|
||||
var ta = answers.First(a => a.QuestionId == q.Id).Answers.Where(a => a.Checked).Select(a => a.AnswerNumber);
|
||||
var minId = q.Answers.Min(a => a.Id);
|
||||
var correctRelativeAnswers = q.Answers.Where(a => a.IsCorrect).Select(a => a.Id - minId + 1);
|
||||
|
||||
points += q.DefaultScore;
|
||||
var ta = answers.First(a => a.QuestionId == q.Id).Answers.Where(a => a.Checked).Select(a => a.AnswerNumber).ToList();
|
||||
var correctRelativeAnswers = new List<int>();
|
||||
for (int i = 0; i < q.Answers.Count; i++)
|
||||
{
|
||||
if (q.Answers.ElementAt(i).IsCorrect)
|
||||
correctRelativeAnswers.Add(i);
|
||||
}
|
||||
if (ta.SequenceEqual(correctRelativeAnswers))
|
||||
points += q.DefaultScore;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<TemplateAnswer> ProcessFile(string fileName)
|
||||
{
|
||||
fileName = PDFtoIMG(fileName);
|
||||
@ -147,7 +151,7 @@ namespace WebApplication5.Templates
|
||||
if ((pixels - nonZero) / pixels > 0.5)
|
||||
a.Checked = true;
|
||||
|
||||
image.Save(@"C:\Users\Janek\Desktop\Tests\scans\" + rightcolumn + i + j + ".jpg");
|
||||
qA.Answers.Add(a);
|
||||
|
||||
}
|
||||
result.Add(qA);
|
||||
|
Loading…
Reference in New Issue
Block a user