190 lines
9.4 KiB
PHP
190 lines
9.4 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
|
|
@foreach ($questions as $question)
|
|
<div class="col-12">
|
|
<h4 class="page-title mb-3">{{ $question->question }}</h4>
|
|
</div>
|
|
<div class="button-list pe-xl-4 d-grid">
|
|
<input type="hidden" name="answer[{{$question->id}}]" id="poll_answer" value="">
|
|
@php
|
|
$ac = 0;
|
|
@endphp
|
|
@foreach($question->options as $ans)
|
|
<button type="button" class="btn btn-outline-secondary waves-effect btn-lg poll_option" ac="{{$ac}}">{{$ans->option}}</button>
|
|
@php
|
|
$ac++;
|
|
@endphp
|
|
@endforeach
|
|
</div>
|
|
@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">Poll 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">
|
|
<h3>Your response are successfully submitted.</h3>
|
|
</div>
|
|
<div class="col-12 barsdiv">
|
|
@if($form->show_answers)
|
|
@foreach ($questions as $question)
|
|
@foreach($question->options as $ans)
|
|
<div class="progress mb-0">
|
|
<div class="progress-bar progress-bar-striped bg-warning" role="progressbar" style="width: 70%" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100">70%</div>
|
|
</div>
|
|
<p class="mb-3">{{$ans->option}}</p>
|
|
@endforeach
|
|
@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%;
|
|
}
|
|
.progress, .progress-bar {
|
|
height:20px;
|
|
}
|
|
</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()
|
|
$('.poll_option').click(function(){
|
|
$('#poll_answer').val( $(this).attr('ac') )
|
|
$('.poll_option').removeClass('btn-secondary')
|
|
$('.poll_option').addClass('btn-outline-secondary')
|
|
$(this).removeClass('btn-outline-secondary')
|
|
$(this).addClass('btn-secondary')
|
|
})
|
|
|
|
let questions = {!! json_encode($questions) !!}
|
|
|
|
$('#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') {
|
|
let html = ''
|
|
let total = 0
|
|
for(let ans of Object.values(data.answers) ) {
|
|
total = total + ans
|
|
}
|
|
for(let ans of Object.keys(data.answers)) {
|
|
let percent = Math.ceil((data.answers[ans]/total)*100)
|
|
html += `<div class="progress mb-0">
|
|
<div class="progress-bar progress-bar-striped bg-warning" role="progressbar" style="width: ${percent}%" aria-valuenow="${percent}" aria-valuemin="0" aria-valuemax="100">${percent}%</div>
|
|
</div>
|
|
<p class="mb-3">${questions[0].options[parseInt(ans)].option}</p>`
|
|
}
|
|
$('.message-body .barsdiv').html(html)
|
|
$('.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>
|