#266 showing table of recitations scores
This commit is contained in:
parent
cfc20ce3f5
commit
f26c687bf1
92
GanjooRazor/Pages/RecitationsOrder.cshtml
Normal file
92
GanjooRazor/Pages/RecitationsOrder.cshtml
Normal file
@ -0,0 +1,92 @@
|
||||
@page
|
||||
@model GanjooRazor.Pages.RecitationsOrderModel
|
||||
@using DNTPersianUtils.Core
|
||||
@{
|
||||
Layout = null;
|
||||
}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="fa-IR" dir="rtl">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="robots" content="noindex, nofollow" />
|
||||
<title>اطلاعات رتبهبندی خوانشهای شعر</title>
|
||||
<link href="/css/p8.css?version=25" rel="stylesheet" type="text/css" />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="fa">
|
||||
@if (!string.IsNullOrEmpty(Model.LastError))
|
||||
{
|
||||
<div class="width-100per">
|
||||
<div class="width-100per text-align-center">
|
||||
<p class="alert-text">
|
||||
@Model.LastError
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="poem">
|
||||
<h2>اطلاعات رتبهبندی خوانشهای شعر</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
خوانش
|
||||
</th>
|
||||
<th>
|
||||
امتیاز سابقه
|
||||
</th>
|
||||
<th>
|
||||
آرای کاربران *
|
||||
</th>
|
||||
<th>
|
||||
امتیاز منفی اشکالات
|
||||
</th>
|
||||
<th>
|
||||
امتیاز نهایی
|
||||
</th>
|
||||
<th>
|
||||
ترتیب
|
||||
</th>
|
||||
</tr>
|
||||
@foreach (var score in Model.Scores)
|
||||
{
|
||||
<tr id="@($"a{score.RecitationId}")">
|
||||
<td>
|
||||
@($"{score.Recitation.AudioTitle} به خوانش {score.Recitation.AudioArtist}")
|
||||
</td>
|
||||
<td>
|
||||
@score.EarlynessAdvantage.ToPersianNumbers()
|
||||
</td>
|
||||
<td>
|
||||
@score.UpVotes.ToPersianNumbers()
|
||||
</td>
|
||||
<td>
|
||||
-@score.Mistakes.ToPersianNumbers()
|
||||
</td>
|
||||
<td>
|
||||
@score.TotalScores.ToPersianNumbers()
|
||||
</td>
|
||||
<td>
|
||||
@score.ComputedOrder.ToPersianNumbers()
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
|
||||
<p>
|
||||
* رأی ثبت شده توسط کاربر مالک خوانش در محاسبه لحاظ نمیشود.
|
||||
</p>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
72
GanjooRazor/Pages/RecitationsOrder.cshtml.cs
Normal file
72
GanjooRazor/Pages/RecitationsOrder.cshtml.cs
Normal file
@ -0,0 +1,72 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Newtonsoft.Json;
|
||||
using RMuseum.Models.GanjoorAudio.ViewModels;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GanjooRazor.Pages
|
||||
{
|
||||
public class RecitationsOrderModel : PageModel
|
||||
{
|
||||
/// <summary>
|
||||
/// HttpClient instance
|
||||
/// </summary>
|
||||
private readonly HttpClient _httpClient;
|
||||
|
||||
/// <summary>
|
||||
/// constructor
|
||||
/// </summary>
|
||||
/// <param name="httpClient"></param>
|
||||
public RecitationsOrderModel(HttpClient httpClient)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Last Error
|
||||
/// </summary>
|
||||
public string LastError { get; set; }
|
||||
|
||||
public RecitationOrderingViewModel[] Scores { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync()
|
||||
{
|
||||
LastError = "";
|
||||
|
||||
if (!string.IsNullOrEmpty(Request.Query["p"]))
|
||||
{
|
||||
var poemId = int.Parse(Request.Query["p"]);
|
||||
var response = await _httpClient.GetAsync($"{APIRoot.Url}/api/audio/votes/{poemId}/scores");
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
LastError = JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync());
|
||||
}
|
||||
else
|
||||
{
|
||||
Scores = JsonConvert.DeserializeObject<RecitationOrderingViewModel[]>(await response.Content.ReadAsStringAsync());
|
||||
if(Scores.Length > 0)
|
||||
{
|
||||
response = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/poem/{poemId}/recitations");
|
||||
if(!response.IsSuccessStatusCode)
|
||||
{
|
||||
LastError = JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync());
|
||||
}
|
||||
var recitations = JsonConvert.DeserializeObject<PublicRecitationViewModel[]>(await response.Content.ReadAsStringAsync());
|
||||
foreach (var score in Scores)
|
||||
{
|
||||
score.Recitation = recitations.Where(r => r.Id == score.RecitationId).Single();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LastError = "شعری انتخاب نشده است.";
|
||||
}
|
||||
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -24,6 +24,7 @@
|
||||
{
|
||||
<a role="button" class="w3tooltip cursor-pointer recitation-button" onclick="switchRecitationVote(@recitaion.Id)"><i class="recitation-icons recitation-novote" id="@($"recitaion-{recitaion.Id}")"></i><span class="w3tooltiptext">رأی به خوانش</span></a>
|
||||
}
|
||||
<a role="button" class="w3tooltip cursor-pointer recitation-button" href="@($"/RecitationsOrder/?p={recitaion.PoemId}#a{recitaion.Id}")" onclick="wpopen(this.href); return false"><i class="recitation-icons recitation-score"></i><span class="w3tooltiptext">اطلاعات رتبهبندی</span></a>
|
||||
</div>
|
||||
@if (recitaion.Mistakes.Length > 0)
|
||||
{
|
||||
|
||||
@ -1274,6 +1274,10 @@ ol {
|
||||
content: 'thumb_up_alt';
|
||||
}
|
||||
|
||||
.recitation-score::after {
|
||||
content: 'calculate';
|
||||
}
|
||||
|
||||
audio{
|
||||
width:100%;
|
||||
}
|
||||
|
||||
@ -34,5 +34,10 @@
|
||||
/// computed order
|
||||
/// </summary>
|
||||
public int ComputedOrder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// recitation (it is null by default and you should fill it using a separate api call based on RecitationId)
|
||||
/// </summary>
|
||||
public PublicRecitationViewModel Recitation { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -4174,6 +4174,11 @@
|
||||
computed order
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.GanjoorAudio.ViewModels.RecitationOrderingViewModel.Recitation">
|
||||
<summary>
|
||||
recitation (it is null by default and you should fill it using a separate api call based on RecitationId)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:RMuseum.Models.GanjoorAudio.ViewModels.RecitationPublishingTrackerViewModel">
|
||||
<summary>
|
||||
RecitationPublishingTracker View Model
|
||||
|
||||
Loading…
Reference in New Issue
Block a user