<%- include("./partials/stheader.ejs") %>
</head>

<body>
  <%- include("./partials/stnav.ejs") %>
  <div class="container" style="">
    <%if(questions[0]){%>
    <div class="">
      <h2 class="text-center mt-4"><%=exam.title%></h2>
      <hr style="border-top: 1px dashed grey">
      <p><b>Name:</b> <%=req.name%></p>
      <p><b>Roll:</b> <%=req.username%></p>
      <p style=""><b>Date Conducted:</b> <%=moment(exam.date).format( 'DD MMM YYYY')%></p>
      <p style=""><b>Score:</b> <%=response[0].marks%>/<%=exam.marks%></p>
      <hr style="border-top: 1px dashed grey">
    </div>
<div class="col-md-12">
    <% for(var i=0;i<=questions.length-1;i++){%>
      <div class="card m-4" >
        <div class="card-header">
        <b><%=(i+1)%>. <%=questions[i].q%></b>
          <%if(questions[i].ans == response[0].answers[i].marked){%>
          <p style="float:right;color:green" id="marks">(<%=questions[i].marks%>/<%=questions[i].marks%> Marks)</p>
          <%  }else{ %>
          <p style="float:right;color:red" id="marks">(0/<%=questions[i].marks%> Marks)</p>
          <%  } %>
        </div>
        <ul class="list-group list-group-flush">
          <%  for(var j=0;j<=questions[i].options.length-1;j++){ %>
          <li class="list-group-item">
            <%  if(questions[i].ans == j+1){%>
            <p><%=j+1%>) <%=questions[i].options[j]%> <i class="fas fa-check" style="color:green"></i></p>
            <%  }else if(response[0].answers[i].marked == j+1 && questions[i].ans != j+1){%>
            <p><%=j+1%>) <%=questions[i].options[j]%> <i class="fas fa-times" style="color:red"></i></p>
            <%  }else{%>
            <p><%=j+1%>) <%=questions[i].options[j]%></p>
            <%  }%>
          </li>
          <% }%>
        </ul>
      </div>
      <%}%>
    </div>
    <%}%>
    <div class="form-group submit text-center m-4">
      <a href="/st/completed" style="text-decoration:none"><button type="button" class="btn btn-outline-success">Back</button></a>
    </div>
</div>

<%- include("./partials/footer.ejs") %>
