Готовые аттестации
This commit is contained in:
parent
0d7809310a
commit
96a5f2c708
@ -58,8 +58,6 @@ namespace UniversityBusinessLogic.BusinessLogics
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
model.Score = AttestationScore.Неявка;
|
||||
|
||||
if (_attestationStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
@ -89,51 +87,6 @@ namespace UniversityBusinessLogic.BusinessLogics
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool ScoreUpdate(AttestationBindingModel model, AttestationScore newScore)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (!Enum.IsDefined(typeof(AttestationScore), newScore))
|
||||
{
|
||||
_logger.LogWarning("Score update to " + newScore.ToString() + " operation failed. Attestation status incorrect.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_attestationStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
model.Score = newScore;
|
||||
return true;
|
||||
}
|
||||
public bool SetPass(AttestationBindingModel model)
|
||||
{
|
||||
return ScoreUpdate(model, AttestationScore.Зачёт);
|
||||
}
|
||||
|
||||
public bool SetNotPass(AttestationBindingModel model)
|
||||
{
|
||||
return ScoreUpdate(model, AttestationScore.Незачёт);
|
||||
}
|
||||
|
||||
public bool SetTwo(AttestationBindingModel model)
|
||||
{
|
||||
return ScoreUpdate(model, AttestationScore.Неудовлетворительно);
|
||||
}
|
||||
public bool SetThree(AttestationBindingModel model)
|
||||
{
|
||||
return ScoreUpdate(model, AttestationScore.Удовлетворительно);
|
||||
}
|
||||
public bool SetFour(AttestationBindingModel model)
|
||||
{
|
||||
return ScoreUpdate(model, AttestationScore.Хорошо);
|
||||
}
|
||||
public bool SetFive(AttestationBindingModel model)
|
||||
{
|
||||
return ScoreUpdate(model, AttestationScore.Отлично);
|
||||
}
|
||||
|
||||
private void CheckModel(AttestationBindingModel model, bool withParams = true)
|
||||
{
|
||||
|
@ -110,10 +110,31 @@ namespace UniversityClientAppWorker.Controllers
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.AttestationScore = Enum.GetValues(typeof(AttestationScore)).Cast<AttestationScore>();
|
||||
return View();
|
||||
ViewBag.Students = APIClient.GetRequest<List<StudentViewModel>>($"api/student/getstudents?userId={APIClient.User.Id}");
|
||||
ViewBag.AttestationScore = Enum.GetValues(typeof(AttestationScore)).Cast<AttestationScore>();
|
||||
return View(APIClient.GetRequest<List<AttestationViewModel>>($"api/attestation/getattestations?userId={APIClient.User.Id}"));
|
||||
}
|
||||
[HttpGet]
|
||||
[HttpPost]
|
||||
public void CreateAttestation(string formOfEvaluation, int student, AttestationScore score)
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Âõîä òîëüêî àâòîðèçîâàííûì");
|
||||
}
|
||||
if (string.IsNullOrEmpty(formOfEvaluation) || student == 0)
|
||||
{
|
||||
throw new Exception("Ââåäèòå ôîðìó îöåíèâàíèÿ è âûáåðèòå ñòóäåíòà");
|
||||
}
|
||||
APIClient.PostRequest("api/attestation/createattestation", new AttestationBindingModel
|
||||
{
|
||||
UserId = APIClient.User.Id,
|
||||
FormOfEvaluation = formOfEvaluation,
|
||||
StudentId = student,
|
||||
Score = score
|
||||
});
|
||||
Response.Redirect("Attestations");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Students()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
|
@ -1,34 +1,40 @@
|
||||
@{
|
||||
ViewData["Title"] = "Manage Attestations";
|
||||
@using UniversityContracts.ViewModels
|
||||
@model List<AttestationViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "Управление аттестациями";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">@ViewData["Title"]</h2>
|
||||
</div>
|
||||
|
||||
<form method="post">
|
||||
<form asp-action="CreateAttestation" method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Form Of Evaluation:</div>
|
||||
<div class="col-4">Форма оценивания:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="formOfEvaluation" id="formOfEvaluation" class="form-control" />
|
||||
<select name="formOfEvaluation" id="formOfEvaluation" class="form-control">
|
||||
<option value="Зачёт">Зачёт</option>
|
||||
<option value="Экзамен">Экзамен</option>
|
||||
<option value="Дифферинцируемый зачёт">Дифферинцируемый зачёт</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Student:</div>
|
||||
<div class="col-4">Студент:</div>
|
||||
<div class="col-8">
|
||||
<select name="student" id="student" class="form-control" multiple asp-items="ViewBag.Students"></select>
|
||||
<select name="student" id="student" class="form-control" asp-items="@(new SelectList(ViewBag.Students, "Id", "Name"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Score:</div>
|
||||
<div class="col-4">Оценка:</div>
|
||||
<div class="col-8">
|
||||
<select id="score" name="score" class="form-control" asp-items="@(new SelectList(ViewBag.AttestationScore, "Score"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Create Attestation" class="btn btn-primary" />
|
||||
<div class="col-4 mt-2">
|
||||
<input type="submit" value="Добавить аттестацию" class="btn btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@ -36,31 +42,40 @@
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Form Of Evaluation</th>
|
||||
<th>Student</th>
|
||||
<th>Score</th>
|
||||
<th>Actions</th>
|
||||
<th>Id</th>
|
||||
<th>Форма оценивания</th>
|
||||
<th>Студент</th>
|
||||
<th>Оценка</th>
|
||||
<th>Действия</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@* @foreach (var discipline in Model)
|
||||
@foreach (var attestation in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>@discipline.Name</td>
|
||||
<td>@discipline.Description</td>
|
||||
<td>
|
||||
@foreach (var student in discipline.Students)
|
||||
{
|
||||
<span>@student.Name</span>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => attestation.Id)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => attestation.FormOfEvaluation)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => attestation.StudentName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => attestation.Score)
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
<a asp-controller="Home" asp-action="" asp-route-id="@attestation.Id" class="btn btn-warning">Изменить</a>
|
||||
<form asp-controller="Home" asp-action="DeleteAttestation" method="post">
|
||||
<input type="hidden" name="id" value="@attestation.Id" />
|
||||
<button type="submit" class="btn btn-danger">Удалить</button>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="Edit" asp-route-id="@discipline.Id" class="btn btn-warning">Edit</a>
|
||||
<a asp-action="Details" asp-route-id="@discipline.Id" class="btn btn-info">Details</a>
|
||||
<a asp-action="Delete" asp-route-id="@discipline.Id" class="btn btn-danger">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
} *@
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
@ -15,5 +15,6 @@ namespace UniversityContracts.BindingModels
|
||||
public string FormOfEvaluation { get; set; } = string.Empty;
|
||||
public AttestationScore Score { get; set; } = AttestationScore.Неявка;
|
||||
public int StudentId { get; set; }
|
||||
public string StudentName { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -15,12 +15,6 @@ namespace UniversityContracts.BusinessLogicsContracts
|
||||
bool CreateAttestation(AttestationBindingModel model);
|
||||
bool DeleteAttestation(AttestationBindingModel model);
|
||||
bool UpdateAttestation(AttestationBindingModel model);
|
||||
bool SetPass(AttestationBindingModel model);
|
||||
bool SetNotPass(AttestationBindingModel model);
|
||||
bool SetTwo(AttestationBindingModel model);
|
||||
bool SetThree(AttestationBindingModel model);
|
||||
bool SetFour(AttestationBindingModel model);
|
||||
bool SetFive(AttestationBindingModel model);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ namespace UniversityContracts.ViewModels
|
||||
public int Id { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public int StudentId { get; set; }
|
||||
[DisplayName("ФИО студента")]
|
||||
public string StudentName { get; set; } = string.Empty;
|
||||
[DisplayName("Форма оценивания")]
|
||||
public string FormOfEvaluation { get; set; } = string.Empty;
|
||||
[DisplayName("Оценка")]
|
||||
|
@ -23,25 +23,18 @@ namespace UniversityDatabaseImplement.Implements
|
||||
|
||||
public List<AttestationViewModel> GetFilteredList(AttestationSearchModel model)
|
||||
{
|
||||
using var context = new UniversityDatabase();
|
||||
if (model.Id.HasValue)
|
||||
if (model == null)
|
||||
{
|
||||
return context.Attestations
|
||||
.Include(x => x.Student)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.StudentId.HasValue)
|
||||
{
|
||||
return context.Attestations
|
||||
.Include(x => x.Student)
|
||||
.Where(x => x.StudentId == model.StudentId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
return new();
|
||||
}
|
||||
|
||||
return new();
|
||||
using var context = new UniversityDatabase();
|
||||
|
||||
return context.Attestations
|
||||
.Include(x => x.Student)
|
||||
.Include(x => x.User)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public AttestationViewModel? GetElement(AttestationSearchModel model)
|
||||
|
@ -18,6 +18,7 @@ namespace UniversityDatabaseImplement.Models
|
||||
public int UserId { get; private set; }
|
||||
[Required]
|
||||
public int StudentId { get; private set; }
|
||||
public string StudentName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string FormOfEvaluation { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
@ -37,6 +38,7 @@ namespace UniversityDatabaseImplement.Models
|
||||
User = context.Users.First(x => x.Id == model.UserId),
|
||||
StudentId = model.StudentId,
|
||||
Student = context.Students.First(x => x.Id == model.StudentId),
|
||||
StudentName = model.StudentName,
|
||||
FormOfEvaluation = model.FormOfEvaluation,
|
||||
Score = model.Score
|
||||
};
|
||||
@ -48,6 +50,7 @@ namespace UniversityDatabaseImplement.Models
|
||||
return;
|
||||
}
|
||||
StudentId = model.StudentId;
|
||||
StudentName = model.StudentName;
|
||||
FormOfEvaluation = model.FormOfEvaluation;
|
||||
Score = model.Score;
|
||||
}
|
||||
@ -55,6 +58,7 @@ namespace UniversityDatabaseImplement.Models
|
||||
{
|
||||
Id = Id,
|
||||
StudentId = StudentId,
|
||||
StudentName = StudentName,
|
||||
FormOfEvaluation = FormOfEvaluation,
|
||||
Score = Score
|
||||
};
|
||||
|
@ -20,15 +20,15 @@ namespace UniversityRestApi.Controllers
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<AttestationViewModel>? GetAttestations(int studentId)
|
||||
public List<AttestationViewModel>? GetAttestations(int userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadList(new AttestationSearchModel { StudentId = studentId });
|
||||
return _logic.ReadList(new AttestationSearchModel { UserId = userId });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения аттестаций студента id={Id}", studentId);
|
||||
_logger.LogError(ex, "Ошибка получения аттестаций пользователя id={Id}", userId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user