@using System.Web.Mvc.Html
@using System.Web.UI.HtmlControls
@using DAL
@using Microsoft.AspNet.Identity
@using Model
@using Ninject.Infrastructure.Disposal
@model Model.Contest
@{
var diff = 0;
var contestId = Model.Id;
}
<link rel="stylesheet"
href="https://c...content-available-to-author-only...e.com/ajax/libs/highlight.js/9.12.0/styles/androidstudio.min.css">
<link href="~/Content/Watch.css" rel="stylesheet" />
<button id ="ref">ref</button>
<div>
<h1 align="center">Contest - @Model.Name</h1>
@if (Model.EndTime < DateTime.Now)
{
diff = -1;
<h2>contest has Ended</h2>
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="problem-tab" data-toggle="tab" href="#problems" role="tab" aria-controls="home" aria-selected="true">Problems</a>
</li>
<li class="nav-item">
<a class="nav-link" id="standings-tab" data-toggle="tab" href="#standings" role="tab" aria-controls="profile" aria-selected="false">Standings</a>
</li>
<li class="nav-item">
<a class="nav-link" id="submissions-tab" data-toggle="tab" href="#submissions" role="tab" aria-controls="contact" aria-selected="false">Submissions</a>
</li>
</ul>
<div class
="tab-content" id
="myTabContent"> <div class
="tab-pane fade show active" id
="problems" role
="tabpanel" aria
-labelledby
="problem-tab">
Contest has ended. Go to Problem Section to up solve the problems
</div>
<div class
="tab-pane fade" id
="standings" role
="tabpanel" aria
-labelledby
="standings-tab"> @Html.Partial("StandingPartial", Model)
</div>
<div class
="tab-pane fade" id
="submissions" role
="tabpanel" aria
-labelledby
="submissions-tab"> <h3>Submissions</h3>
<table id="Submissions" class="table table-bordered table-hover">
@if (Model.Participants != null)
{
<thead>
<tr>
<th>Submission Problem</th>
<th>Participant Name</th>
<th>Compiler Comment</th>
<th>Submission Time</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Submissions.OrderByDescending(t => t.SubmissionTime.Second))
{
if (item.IsContestTime == false)
{
continue;
}
var tim = (item.SubmissionTime - Model.StarTime).TotalSeconds;
TimeSpan
time = TimeSpan.
FromSeconds(tim
); string str
= time.
ToString(@
"hh\:mm\:ss"); var color = "btn";
<tr>
@if (item.Participant != null)
{
<td>
@item.Problem.ProblemName
</td>
<td>
@item.Participant.Id
</td>
<td>
@if (item.IsProcessed == true && item.IsCompiledSuccessfully == false)
{
color = "btn btn-danger";
item.CompilerComment = "Compilation Error";
}
else if (item.CompilerComment == "Accepted")
{
color = "btn btn-success";
}
else if (item.CompilerComment == "Wrong Answer" || item.CompilerComment == "Runtime Error" || item.CompilerComment == "Time Limit" || item.CompilerComment == "Runtime Error" || item.CompilerComment == "Memory Limit")
{
color = "btn btn-danger";
}
else if (item.CompilerComment == "Duplicate")
{
color = "btn btn-warning";
}
<button item-id-at="@item.Id" type="button" class="@color">
@Html.DisplayFor(modelItem => item.CompilerComment)
</button>
</td>
<td>@str</td>
}
@*<td>
@Html.DisplayFor(modelItem => item.TimeLimit)
</td>
<td></td>*@
</tr>
}
</tbody>
}
</table>
</div>
</div>
}
else if (Model.StarTime > DateTime.Now)
{
<h2>contest has not started yet</h2>
diff = (int) (Model.StarTime - DateTime.Now).TotalSeconds;
var participant = this.Model.Participants.Where(c => c.Id == this.User.Identity.GetUserName()).Count();
if (participant != 0)
{
<h3>You have registered for this contest</h3>
}
else
{
if (this.Model.Visible == true)
{
@Html.ActionLink("Registration", "RegistrationForContest",
"Participant", new {id = Model.Id,}, htmlAttributes: new {@class = "btn btn-primary"})
}
else
{
<h3>contest is invite only.</h3>
}
}
<div id
="timer" data
-time
-id
=@diff
> <span id="days"></span>days
<span id="hours"></span>hours
<span id="minutes"></span>minutes
<span id="seconds"></span>seconds
</div>
}
else
{
diff = (int) (Model.EndTime - DateTime.Now).TotalSeconds;
<div id
="timer" data
-time
-id
=@diff
> <span id="days"></span>days
<span id="hours"></span>hours
<span id="minutes"></span>minutes
<span id="seconds"></span>seconds
</div>
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="problem-tab" data-toggle="tab" href="#problems" role="tab" aria-controls="home" aria-selected="true">Problems</a>
</li>
<li class="nav-item">
<a class="nav-link" id="standings-tab" data-toggle="tab" href="#standings" role="tab" aria-controls="profile" aria-selected="false">Standings</a>
</li>
<li class="nav-item">
<a class="nav-link" id="submissions-tab" data-toggle="tab" href="#submissions" role="tab" aria-controls="contact" aria-selected="false">Submissions</a>
</li>
</ul>
<div class
="tab-content" id
="myTabContent"> <div class
="tab-pane fade show active" id
="problems" role
="tabpanel" aria
-labelledby
="problem-tab">
<h3>Problems</h3>
<table id="Problems" class="table table-bordered table-hover">
@if (Model.Problems != null)
{
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Problems[0].ProblemName)
</th>
<th>
@Html.DisplayNameFor(model => model.Problems[0].ProblemName)
</th>
<th>
@Html.DisplayNameFor(model => model.Problems[0].ProblemName)
</th>
<th>Utilitis</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Problems)
{
<tr>
<td>
@Html.ActionLink(item.ProblemName, "Details", "Problem", new {id = item.Id}, null)
</td>
<td>
@Html.DisplayFor(modelItem => item.Score)
</td>
<td>
@Html.DisplayFor(modelItem => item.TimeLimit)
</td>
<td></td>
</tr>
}
</tbody>
}
</table>
</div>
<div class
="tab-pane fade" id
="standings" role
="tabpanel" aria
-labelledby
="standings-tab"> @Html.Partial("StandingPartial", Model)
</div>
<div class
="tab-pane fade" id
="submissions" role
="tabpanel" aria
-labelledby
="submissions-tab"> <h3>Submissions</h3>
<table id="Submissions" class="table table-bordered table-hover">
@if (Model.Participants != null)
{
<thead>
<tr>
<th>Submission Problem</th>
<th>Participant Name</th>
<th>Compiler Comment</th>
<th>Submission Time</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Submissions.OrderByDescending(t => t.SubmissionTime.Millisecond))
{
if (item.IsContestTime == false)
{
continue;
}
var tim = (item.SubmissionTime - Model.StarTime).TotalSeconds;
TimeSpan
time = TimeSpan.
FromSeconds(tim
); string str
= time.
ToString(@
"hh\:mm\:ss"); var color = "btn";
<tr>
@if (item.Participant != null)
{
<td>
@item.Problem.ProblemName
</td>
<td>
@item.Participant.Id
</td>
<td>
@if (item.IsProcessed == true && item.IsCompiledSuccessfully == false)
{
color = "btn btn-danger";
item.CompilerComment = "Compilation Error";
}
else if (item.CompilerComment == "Accepted")
{
color = "btn btn-success";
}
else if (item.CompilerComment == "Wrong Answer" || item.CompilerComment == "Runtime Error" || item.CompilerComment == "Time Limit" || item.CompilerComment == "Runtime Error" || item.CompilerComment == "Memory Limit")
{
color = "btn btn-danger";
}
else if (item.CompilerComment == "Duplicate")
{
color = "btn btn-warning";
}
<button item-id-at="@item.Id" type="button" class="@color">
@Html.DisplayFor(modelItem => item.CompilerComment)
</button>
</td>
<td>
@str
</td>
}
@*<td>
@Html.DisplayFor(modelItem => item.TimeLimit)
</td>
<td></td>*@
</tr>
}
</tbody>
}
</table>
</div>
</div>
}
<hr/>
</div>
<p>
@Html.ActionLink("Edit", "Edit", new {id = Model.Id}) |
@Html.ActionLink("Back to List", "Index")
</p>
</div>
<div class
="modal fade" id
="myModal"> <div class
="modal-dialog"> <div class
="modal-content">
<!-- Modal Header -->
<div class
="modal-header"> <h4 class="modal-title">Code</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<pre><code id="codeset" class="cpp"> </code></pre>
</div>
<!-- Modal footer -->
<div class
="modal-footer"> <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
@section scripts
{
<script src="https://c...content-available-to-author-only...e.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://c...content-available-to-author-only...e.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script src="~/Scripts/Encoder.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="~/Scripts/watch.js"></script>
<script src="~/Scripts/jquery.signalR-2.2.3.min.js"></script>
<script src="~/signalr/hubs"></script>
<script>
var signalRHubInitialized = false;
$(function () {
InitializeSignalRHubStore();
});
$("#ref").click(function() {
ReloadIndexPartial();
});
function InitializeSignalRHubStore() {
if (signalRHubInitialized)
return;
try {
var clientHub = $.connection.StandingHub;
clientHub.client.broadcastMessage = function (message) {
if (message === "Refresh")
ReloadIndexPartial();
};
$.connection.hub.start().done(function () {
clientHub.server.initialize($("#NotifierEntity").val());
signalRHubInitialized = true;
});
} catch (err) {
signalRHubInitialized = false;
}
};
function ReloadIndexPartial() {
$.post('@Url.Action("StandingPartial", "Contest", null, Request.Url.Scheme)')
.done(function (response) {
$("#standings").html(response)
if (!signalRHubInitialized)
InitializeSignalRHubStore();
});
};
</script>
<script>
setdata(@diff);
</script>
<script>
var con = @contestId;
$(document).ready(function () {
$('#Submissions button').click(function() {
var obj = $(this);
$.ajax({
url: '@Url.RouteUrl("DefaultApi",
new {httproute = "", controller = "Submission"})/' +
obj.attr("item-id-at"),
// < -- -- -- -- -- -- -- -- -- -- -- -- - > It 's represent url of api
type: 'GET',
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - > we need to set whether we getting / posting the data
dataType: 'json',
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > type of data
success: function(data, textStatus, xhr) {
//-- -- -- -- -- -- -- > here we can the result from data object
var cn = Encoder.htmlEncode(data.code);
$("#myModal").modal("toggle");
$("#codeset").html(cn);
//document.getElementById("codeset").innerHTML("Hello");
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - > here you can proceed to get the data
},
error: function(xhr, textStatus, errorThrown) {
console.
log('Error in Database'); // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - >
//if any error caught
}
});
});
$("#Problems").DataTable();
$("#Standings").DataTable();
$("#Submissions").DataTable({
"order": [[ 3, "desc" ]]
} );
$("#Problems .js-delete").on("click",
function() {
var button = $(this);
var obj = $(this);
var Url = "@Url.RouteUrl("DefaultApi",
new {httproute = "", controller = "Problem"})/";
bootbox.confirm("Are you sure to delete this problem?",
function(result) {
if (result) {
$.ajax({
url: Url + obj.attr("data-problem-id"),
method: "DELETE",
success: function() {
button.
parents("tr").
remove(); }
});
}
});
});
});
</script>
<script src="@Url.Content("~/Scripts/val.js")"></script>
}