194 lines
9.2 KiB
PHP
194 lines
9.2 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
@include('layouts.shared/title-meta', ['title' => 'Form'])
|
|
@include('layouts.shared/head-css', ['mode' => $mode ?? '', 'demo' => $demo ?? ''])
|
|
<link href="{{ asset('assets/libs/sweetalert2/sweetalert2.min.css') }}" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<div id="pageloader">
|
|
<img src="http://cdnjs.cloudflare.com/ajax/libs/semantic-ui/0.16.1/images/loader-large.gif" alt="processing..." />
|
|
</div>
|
|
|
|
<body class="loading">
|
|
<div class="account-pages">
|
|
<div class="container">
|
|
<div class="row justify-content-center">
|
|
<div class="col-md-8 col-lg-6 col-xl-5 p-0">
|
|
<div class="card bg-pattern">
|
|
<div class="card-body p-3 row form-body">
|
|
|
|
@if (Session::has('error'))
|
|
<div class="alert alert-danger">{{ Session::get('error') }}</div>
|
|
<br>
|
|
@endif
|
|
@if (session('success'))
|
|
<div class=" alert alert-success">{{ session('success') }}
|
|
</div>
|
|
<br>
|
|
@endif
|
|
<div class="col-12">
|
|
<h4 class="page-title">{{ $form->name }}</h4>
|
|
</div>
|
|
@if($form->limit_attempts == 'Yes' && $form->number_attempts <= $form->existing_attempts)
|
|
<h4 class="header-title mt-3"> You have already submitted the Quiz for the maximum number of times allowed. </h4>
|
|
<h5 class="header-title mt-3"> Allowed attempts: {{$form->number_attempts}} </h5>
|
|
<h5 class="header-title mt-3"> Attempts done: {{$form->existing_attempts}} </h5>
|
|
@elseif(strtotime($form->start_time) <= strtotime("now")+(19800) && strtotime($form->end_time) >= strtotime("now")+(19800) )
|
|
<form method="POST" action="/form/submit" id="quiz-form" enctype="multipart/form-data">
|
|
<input type="hidden" name="form_id" value="{{$form->id}}">
|
|
<input type="hidden" name="time_taken" id="time_taken" value="">
|
|
@csrf
|
|
|
|
@php
|
|
$qc = 1;
|
|
$ols = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'];
|
|
@endphp
|
|
@foreach ($questions as $question)
|
|
<h4 class="header-title mt-3">{{$qc}}) {{ $question->question }}</h4>
|
|
@php
|
|
$ac = 0;
|
|
@endphp
|
|
@foreach($question->options as $ans)
|
|
<div class="radio radio-success mb-2">
|
|
<input type="radio" name="answer[{{$question->id}}]" id="answer_{{$question->id}}_{{$ac}}" value="{{$ac}}" {{$ac==0?'required':''}}>
|
|
<label for="answer_{{$question->id}}_{{$ac}}">
|
|
{{$ans->option}}
|
|
</label>
|
|
</div>
|
|
@php
|
|
$ac++;
|
|
@endphp
|
|
@endforeach
|
|
@php
|
|
$qc++;
|
|
@endphp
|
|
@endforeach
|
|
|
|
@if (!isset($form->is_approval) || (isset($form->is_approval) && $form->is_approval != 'yes'))
|
|
<div class="text-center d-grid mt-3">
|
|
<button class="btn btn-primary" type="submit" id="submit-btn"> Submit
|
|
</button>
|
|
</div>
|
|
@endif
|
|
</form>
|
|
@else
|
|
<h4 class="header-title mt-3">Quiz will be active from {{date("d M, h:iA", strtotime($form->start_time)) }} to {{date("d M, h:iA", strtotime($form->end_time)) }} </h4>
|
|
|
|
|
|
|
|
@endif
|
|
|
|
</div> <!-- end card-body -->
|
|
<div class="card-body p-3 row message-body">
|
|
<div class="col-12">
|
|
<h4 class="page-title">{{ $form->name }}</h4>
|
|
</div>
|
|
<div class="col-12">
|
|
<h2>Your response are successfully submitted.</h2>
|
|
</div>
|
|
<div class="col-12">
|
|
@if($form->show_score)
|
|
<div class="alert alert-success bg-success text-white border-0 show_score_wrapper" role="alert">
|
|
|
|
</div>
|
|
@endif
|
|
</div>
|
|
<div class="col-12">
|
|
@if($form->show_answers)
|
|
@php
|
|
$qc = 1;
|
|
$ols = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'];
|
|
@endphp
|
|
@foreach ($questions as $question)
|
|
<h4 class="header-title mt-3">{{$qc}}) {{ $question->question }}</h4>
|
|
@php
|
|
$ac = 0;
|
|
@endphp
|
|
@foreach($question->options as $ans)
|
|
<p style="margin-bottom:5px" class="{{$ans->is_correct?'text-success fw-bold ':''}}">{{$ols[$ac]}}) {{$ans->option}}</p>
|
|
@php
|
|
$ac++;
|
|
@endphp
|
|
@endforeach
|
|
@php
|
|
$qc++;
|
|
@endphp
|
|
@endforeach
|
|
@endif
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- end card -->
|
|
|
|
<!-- end row -->
|
|
|
|
</div> <!-- end col -->
|
|
</div>
|
|
<!-- end row -->
|
|
</div>
|
|
<!-- end container -->
|
|
</div>
|
|
<!-- end page -->
|
|
<style type="text/css">
|
|
#pageloader {
|
|
background: rgba(255, 255, 255, 0.8);
|
|
display: none;
|
|
height: 100%;
|
|
position: fixed;
|
|
width: 100%;
|
|
z-index: 9999;
|
|
}
|
|
|
|
#pageloader img {
|
|
left: 50%;
|
|
margin-left: -32px;
|
|
margin-top: -32px;
|
|
position: absolute;
|
|
top: 50%;
|
|
}
|
|
</style>
|
|
@include('layouts.shared/footer-script')
|
|
<script src="{{ URL::asset('assets/js/jquery-sparkline/jquery-sparkline.min.js')}}"></script>
|
|
<script src="{{ URL::asset('assets/js/pages/timeme.js')}}"></script>
|
|
<script type="text/javascript">
|
|
jQuery(document).ready(function($){
|
|
$('.message-body').hide()
|
|
|
|
$('#quiz-form').on('submit', function(event){
|
|
event.preventDefault();
|
|
$("#pageloader").fadeIn();
|
|
$('#time_taken').val(TimeMe.getTimeOnCurrentPageInSeconds());
|
|
$.ajax({
|
|
type: "POST",
|
|
url: '/quizly/ajaxsubmit',
|
|
data: $('#quiz-form').serialize(),
|
|
success: function( data ) {
|
|
console.log(data)
|
|
$("#pageloader").fadeOut();
|
|
if(data.status == 'success') {
|
|
$('.message-body').show()
|
|
$('.form-body').hide()
|
|
console.log(data)
|
|
$('.show_score_wrapper').html('You answered <strong> '+data.submission.correct_answers+' correct out of '+data.submission.total_questions+' </strong>questions<br />You took <strong>'+data.submission.time_taken+' sec</strong> to submit the Quiz')
|
|
console.log('You answered <strong> '+data.submission.correct_answers+' correct out of '+data.submission.total_questions+' </strong>questions<br />You took <strong>'+data.submission.time_taken+' sec</strong> to submit the Quiz')
|
|
}
|
|
},
|
|
});
|
|
});
|
|
|
|
TimeMe.initialize({
|
|
currentPageName: "my-home-page", // current page
|
|
idleTimeoutInSeconds: 10, // seconds
|
|
|
|
});
|
|
|
|
// $('#post-media-btn').click(function(){
|
|
//
|
|
// });
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|