Test checking frontend.
This commit is contained in:
parent
442144c6e6
commit
070c0826a3
@ -5,6 +5,8 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Web.Mvc;
|
||||
using WebApplication5.Models;
|
||||
using WebApplication5.Templates;
|
||||
using System.IO;
|
||||
using System.Configuration;
|
||||
|
||||
namespace WebApplication5.Controllers
|
||||
{
|
||||
@ -87,7 +89,7 @@ namespace WebApplication5.Controllers
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Delets
|
||||
#region Deletes
|
||||
public ActionResult DeleteAnswer(int answerId)
|
||||
{
|
||||
var a = _db.Answers.FirstOrDefault(qu => qu.Id == answerId);
|
||||
@ -158,34 +160,22 @@ namespace WebApplication5.Controllers
|
||||
return RedirectToAction("AllForTemplate");
|
||||
}
|
||||
#endregion
|
||||
public ActionResult GeneratePDF(TemplatesOrder templatesToGenerate)
|
||||
{
|
||||
var catq1 = new TemplateViewModel()
|
||||
{
|
||||
CategoryId = 1,
|
||||
NumberOfQuestions = 3,
|
||||
QuestionsIds = new List<int>(){ 1, 2, 3 }
|
||||
};
|
||||
var catq2 = new TemplateViewModel()
|
||||
{
|
||||
CategoryId = 2,
|
||||
QuestionsIds = new List<int>(),
|
||||
NumberOfQuestions = 2
|
||||
};
|
||||
templatesToGenerate = new TemplatesOrder()
|
||||
{
|
||||
TestName = "Wielki Test1",
|
||||
NumberOfExamples = 5,
|
||||
Categories = new List<TemplateViewModel>() { catq1, catq2 }
|
||||
};
|
||||
|
||||
var x = new CheckCards(_db);
|
||||
x.CheckFolder(@"C:\Users\Janek\Desktop\Tests\scans");
|
||||
|
||||
|
||||
var generator = new TemplateGenerator(_db, templatesToGenerate);
|
||||
generator.ProcessOrder();
|
||||
return View();
|
||||
#region Check Templates
|
||||
public ActionResult Tests()
|
||||
{
|
||||
var path = string.Format("{0}{1}", ConfigurationManager.AppSettings["TestsFolder"], "toCheck");
|
||||
var listOfFoldersWithTests = Directory.GetDirectories(path);
|
||||
return View(listOfFoldersWithTests.ToList());
|
||||
}
|
||||
|
||||
public ActionResult CheckTest(string path)
|
||||
{
|
||||
var x = new CheckCards(_db);
|
||||
var results = x.CheckFolder(path);
|
||||
|
||||
return View(results);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
15
WebApplication5/Models/Business/Result.cs
Normal file
15
WebApplication5/Models/Business/Result.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace WebApplication5.Models
|
||||
{
|
||||
public class Result
|
||||
{
|
||||
public int Points { get; set; }
|
||||
public int PointsMax { get; set; }
|
||||
public string AnswerFileName { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ using Emgu.CV.Structure;
|
||||
using System.IO;
|
||||
using ImageMagick;
|
||||
using System.Drawing;
|
||||
using WebApplication5.Models;
|
||||
|
||||
namespace WebApplication5.Templates
|
||||
{
|
||||
@ -19,8 +20,9 @@ namespace WebApplication5.Templates
|
||||
{
|
||||
_db = db;
|
||||
}
|
||||
public void CheckFolder(string folder)
|
||||
public List<Result> CheckFolder(string folder)
|
||||
{
|
||||
var results = new List<Result>();
|
||||
string[] fileEntries = Directory.GetFiles(folder);
|
||||
|
||||
foreach (string fileName in fileEntries.Where(f => f.EndsWith(".pdf")))
|
||||
@ -44,7 +46,14 @@ namespace WebApplication5.Templates
|
||||
if (ta.SequenceEqual(correctRelativeAnswers))
|
||||
points += q.DefaultScore;
|
||||
}
|
||||
results.Add(new Result()
|
||||
{
|
||||
AnswerFileName = fileName,
|
||||
Points = points,
|
||||
PointsMax = maxPoints
|
||||
});
|
||||
}
|
||||
return results;
|
||||
}
|
||||
private List<TemplateAnswer> ProcessFile(string fileName)
|
||||
{
|
||||
|
@ -11,7 +11,6 @@ namespace WebApplication5.Templates
|
||||
{
|
||||
private TestsDbContext _db;
|
||||
private TemplatesOrder _templatesOrder;
|
||||
private string fileName = Guid.NewGuid().ToString();
|
||||
private WriterPDF writer= new WriterPDF();
|
||||
|
||||
public TemplateGenerator(TestsDbContext db, TemplatesOrder templatesOrder)
|
||||
@ -21,7 +20,7 @@ namespace WebApplication5.Templates
|
||||
}
|
||||
public void ProcessOrder()
|
||||
{
|
||||
writer.CreateFile(fileName);
|
||||
writer.CreateFile(_templatesOrder.TestName);
|
||||
for (int i = 0; i < _templatesOrder.NumberOfExamples; i++)
|
||||
{
|
||||
var questionNumber = 1;
|
||||
@ -40,10 +39,6 @@ namespace WebApplication5.Templates
|
||||
}
|
||||
writer.EndPage();
|
||||
writer.WriteAnswerTemplate(questions, string.Join("_", questions.Select(q => q.Id)));
|
||||
|
||||
//TODO
|
||||
//wrtie to DB
|
||||
//QRcode + questions
|
||||
}
|
||||
writer.CloseFile();
|
||||
}
|
||||
|
@ -115,8 +115,6 @@ namespace WebApplication5.Writer
|
||||
writer.Close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void WriteAnswerTemplate(List<Question> questions, string qrCode)
|
||||
{
|
||||
AddUserId();
|
||||
|
31
WebApplication5/Views/CRUD/CheckTest.cshtml
Normal file
31
WebApplication5/Views/CRUD/CheckTest.cshtml
Normal file
@ -0,0 +1,31 @@
|
||||
@using WebApplication5.Models
|
||||
@model List<Result>
|
||||
@{
|
||||
ViewBag.Title = "Rezultaty";
|
||||
}
|
||||
|
||||
<h2>@ViewBag.Title</h2>
|
||||
<div class="row">
|
||||
<div class="row">
|
||||
<div class="col-md-4">Nazwa</div>
|
||||
<div class="col-md-2">Liczba punktów</div>
|
||||
<div class="col-md-2">Max punktów</div>
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
|
||||
@foreach (var result in Model)
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col-md-4">@result.AnswerFileName</div>
|
||||
<div class="col-md-2">@result.Points</div>
|
||||
<div class="col-md-2">@result.PointsMax</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
|
||||
|
||||
@Scripts.Render("~/bundles/jqueryval")
|
||||
}
|
28
WebApplication5/Views/CRUD/Tests.cshtml
Normal file
28
WebApplication5/Views/CRUD/Tests.cshtml
Normal file
@ -0,0 +1,28 @@
|
||||
@model List<string>
|
||||
@{
|
||||
ViewBag.Title = "Foldery z wynikami";
|
||||
}
|
||||
|
||||
<h2>@ViewBag.Title</h2>
|
||||
<div class="row">
|
||||
<div class="row">
|
||||
<div class="col-md-4">Nazwa</div>
|
||||
<div class="col-md-2">Sprawdź folder</div>
|
||||
</div>
|
||||
<hr />
|
||||
|
||||
@foreach (var result in Model)
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col-md-4">@result</div>
|
||||
<div class="col-md-2">
|
||||
<a href="@Url.Action("CheckTest", "Crud", new { path = result })">Sprawdź</a>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@section Scripts {
|
||||
|
||||
|
||||
@Scripts.Render("~/bundles/jqueryval")
|
||||
}
|
@ -23,7 +23,7 @@
|
||||
<ul class="nav navbar-nav">
|
||||
<li>@Html.ActionLink("Kategorie", "Categories", "CRUD")</li>
|
||||
<li>@Html.ActionLink("Generacja", "AllForTemplate", "CRUD")</li>
|
||||
<li>@Html.ActionLink("Sprawdzanie", "Check", "CRUD")</li>
|
||||
<li>@Html.ActionLink("Sprawdzanie", "Tests", "CRUD")</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -384,6 +384,7 @@
|
||||
<Compile Include="Controllers\CRUDController.cs" />
|
||||
<Compile Include="Controllers\HomeController.cs" />
|
||||
<Compile Include="Controllers\ManageController.cs" />
|
||||
<Compile Include="Models\Business\Result.cs" />
|
||||
<Compile Include="Models\EF\DbEntities\Answer.cs" />
|
||||
<Compile Include="Models\EF\DbEntities\Category.cs" />
|
||||
<Compile Include="Models\EF\DbEntities\Configurations\AnswerConfig.cs" />
|
||||
@ -482,6 +483,8 @@
|
||||
<Content Include="Views\CRUD\Questions.cshtml" />
|
||||
<Content Include="Views\CRUD\Answers.cshtml" />
|
||||
<Content Include="Views\CRUD\AllForTemplate.cshtml" />
|
||||
<Content Include="Views\CRUD\CheckTest.cshtml" />
|
||||
<Content Include="Views\CRUD\Tests.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="App_Data\" />
|
||||
|
Loading…
Reference in New Issue
Block a user