начало графиков
This commit is contained in:
parent
e298c31f0b
commit
b241c59c1c
@ -3,6 +3,8 @@ using SchoolAgainStudyContracts.BusinessLogicContracts;
|
||||
using SchoolAgainStudyContracts.SearchModel;
|
||||
using SchoolAgainStudyContracts.StorageContracts;
|
||||
using SchoolAgainStudyContracts.ViewModel;
|
||||
using SchoolAgainStudyDataBaseImplements.Models;
|
||||
using SchoolAgainStudyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -16,14 +18,19 @@ namespace SchoolAgainStudyBusinessLogic.BusinessLogic
|
||||
private readonly IInterestLogic _interest;
|
||||
private readonly IProductLogic _product;
|
||||
private readonly IDiyLogic _diy;
|
||||
|
||||
public ChartLogic(IInterestLogic interest, IProductLogic product, IDiyLogic diy)
|
||||
private readonly ILessonLogic _lesson;
|
||||
private readonly IMaterialLogic _material;
|
||||
private readonly ITaskLogic _task;
|
||||
|
||||
public ChartLogic(IInterestLogic interest, IProductLogic product, IDiyLogic diy, ILessonLogic lesson, ITaskLogic task, IMaterialLogic mateial)
|
||||
{
|
||||
|
||||
_interest = interest;
|
||||
_product = product;
|
||||
_diy = diy;
|
||||
|
||||
_lesson = lesson;
|
||||
_task = task;
|
||||
_material = mateial;
|
||||
}
|
||||
public (int Products, int Diyes) GetDifferenceInCount(int StudentId)
|
||||
{
|
||||
@ -73,5 +80,47 @@ namespace SchoolAgainStudyBusinessLogic.BusinessLogic
|
||||
var actList = list.Select(g => new ActivityChartViewModel { dateOf = g.Key.ToString("dd/MM"), count = g.Value }).ToList();
|
||||
return actList;
|
||||
}
|
||||
}
|
||||
|
||||
public List<TopersViewModel> GetTopMaterials(int TeacherId)
|
||||
{
|
||||
var materials = _material.ReadList(new MaterialSearchModel
|
||||
{
|
||||
TeacherId = TeacherId,
|
||||
});
|
||||
var lessons = _lesson.ReadList(new LessonSearchModel
|
||||
{
|
||||
TeacherId = TeacherId,
|
||||
DateFrom = DateTime.SpecifyKind(DateTime.Now.AddMonths(-1), DateTimeKind.Utc),
|
||||
DateTo = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc),
|
||||
});
|
||||
var tasks = _task.ReadList(new TaskSearchModel
|
||||
{
|
||||
TeacherId = TeacherId,
|
||||
DateFrom = DateTime.SpecifyKind(DateTime.Now.AddMonths(-1), DateTimeKind.Utc),
|
||||
DateTo = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc),
|
||||
});
|
||||
Dictionary<IMaterial, int> list = new Dictionary<IMaterial, int>();
|
||||
foreach (var material in materials)
|
||||
{
|
||||
list.Add(material, 0);
|
||||
foreach (var lesson in lessons)
|
||||
{
|
||||
if (lesson.LessonMaterials.ContainsKey(material.Id))
|
||||
list[material] += 1;
|
||||
}
|
||||
foreach (var task in tasks)
|
||||
{
|
||||
if (task.TaskMaterials.ContainsKey(material.Id))
|
||||
list[material] += 1;
|
||||
}
|
||||
}
|
||||
var actList = list.Select(g => new TopersViewModel { Name = g.Key.Title, Count = g.Value }).ToList();
|
||||
return actList;
|
||||
}
|
||||
|
||||
public List<TopersViewModel> GetTopStudents(int TeacherId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,5 +11,7 @@ namespace SchoolAgainStudyContracts.BusinessLogicContracts
|
||||
{
|
||||
public (int Products, int Diyes) GetDifferenceInCount(int StudentId);
|
||||
public List<ActivityChartViewModel> GetActivitys(int StudentId);
|
||||
}
|
||||
public List<TopersViewModel> GetTopMaterials(int TeacherId);
|
||||
public List<TopersViewModel> GetTopStudents(int TeacherId);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
namespace SchoolAgainStudyContracts.ViewModel
|
||||
{
|
||||
public class TopersViewModel
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public int Count { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Newtonsoft.Json;
|
||||
using SchoolAgainStudyBusinessLogic.MailWorker;
|
||||
using SchoolAgainStudyContracts.BindingModel;
|
||||
using SchoolAgainStudyContracts.BusinessLogicContracts;
|
||||
@ -21,7 +22,8 @@ namespace TeacherWebClient.Controllers
|
||||
private readonly ITeacherLogic _teacher;
|
||||
private readonly IReportLogic _report;
|
||||
private readonly AbstractMailWorker mailSender;
|
||||
public HomeController(ILogger<HomeController> logger, IProductLogic product, ILessonLogic lesson, ITaskLogic task, IMaterialLogic material, ITeacherLogic teacher, IReportLogic report, AbstractMailWorker abstractMailWorker)
|
||||
private readonly IChartLogic _chart;
|
||||
public HomeController(ILogger<HomeController> logger, IProductLogic product, ILessonLogic lesson, ITaskLogic task, IMaterialLogic material, ITeacherLogic teacher, IReportLogic report, AbstractMailWorker abstractMailWorker, IChartLogic chart)
|
||||
{
|
||||
_logger = logger;
|
||||
_product = product;
|
||||
@ -30,6 +32,7 @@ namespace TeacherWebClient.Controllers
|
||||
_material = material;
|
||||
_teacher = teacher;
|
||||
_report = report;
|
||||
_chart = chart;
|
||||
|
||||
try
|
||||
{
|
||||
@ -492,5 +495,20 @@ namespace TeacherWebClient.Controllers
|
||||
});
|
||||
return PartialView("_LessonTaskListPartial", items);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult TopMaterials()
|
||||
{
|
||||
if (APIClient.Teacher == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.DataPoints = JsonConvert.SerializeObject(_chart.GetActivitys(APIClient.Teacher.Id),
|
||||
new JsonSerializerSettings()
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
});
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
@ -29,6 +29,7 @@ builder.Services.AddTransient<IReportLogic, ReportLogic>();
|
||||
builder.Services.AddTransient<ITeacherLogic, TeacherLogic>();
|
||||
builder.Services.AddTransient<IMaterialLogic, MaterialLogic>();
|
||||
builder.Services.AddTransient<ILessonLogic, LessonLogic>();
|
||||
builder.Services.AddTransient<IChartLogic, ChartLogic>();
|
||||
|
||||
builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||
|
||||
|
@ -0,0 +1,33 @@
|
||||
@using SchoolAgainStudyContracts.ViewModel;
|
||||
@model List<TopersViewModel>
|
||||
<script type="text/javascript">
|
||||
var result = @Html.Raw(ViewBag.DataPoints);
|
||||
var dataPoints = [];
|
||||
for (var i = 0; i < result.length; i++) {
|
||||
dataPoints.push({ label: result[i].Name, y: result[i].Count });
|
||||
}
|
||||
window.onload = function () {
|
||||
var chart = new CanvasJS.Chart("chartContainer", {
|
||||
theme: "theme1",
|
||||
animationEnabled: true,
|
||||
title: {
|
||||
text: "Топ материалов за последний месяц"
|
||||
},
|
||||
data: [
|
||||
{
|
||||
// change type to bar, line, area, pie, etc.
|
||||
type: "column",
|
||||
|
||||
dataPoints: dataPoints
|
||||
}
|
||||
]
|
||||
});
|
||||
chart.render();
|
||||
|
||||
};
|
||||
</script>
|
||||
<body>
|
||||
<div id="chartContainer">
|
||||
</div>
|
||||
|
||||
</body>
|
@ -41,7 +41,10 @@
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Reports">Отчеты</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="SendingEmail">НаПочту</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="SendingEmail">На почту</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="TopMaterials">Топ материалов</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@ -62,6 +65,7 @@
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
|
||||
@await RenderSectionAsync("Scripts", required: false)
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user