IMMREX7
@extends('schools.school_layout')
@section('content')
<div class="row clearfix">
<div class="col-sm-12">
<div class="card">
<div class="header">
<h2><strong>@if(isset($template)) @if(!isset($show)) Edit @else Show @endif @else Add @endif Exam </strong>Master</h2>
</div>
<div class="body">
@if(isset($template))
{!! Form::model( $template, ['route' => ['master.update', $template->idMcq], 'method' => 'put','class'=>'form-horizontal','id'=>'form'] ) !!}
<h6> Exam Details</h6>
<hr>
<div class="table-responsive">
<table class="table table-bordered" style="margin-bottom: 30px;">
<thead>
<tr>
<th>Exam Name</th>
<th>Class</th>
<th>Section</th>
<th>Subject</th>
<th>Start Time</th>
<th>Duration</th>
<th>Total Marks</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{$template->examName}}</td>
<td>{{$template->classM->className}}</td>
<td>@if(isset($template->section->sectionName)){{$template->section->sectionName}}@else All Section @endif</td>
<td>{{$template->subjectName}}</td>
<td>{{$template->examDate}}</td>
<td>{{$template->examTime}}</td>
<td>{{$template->totalMarks}}</td>
</tr>
</tbody>
</table>
</div>
@else
{!! Form::open(['url' => 'school/exam/master','class'=>'form-horizontal','id'=>'form']) !!}
@endif
@if(!isset($show))
<h6> Enter Form Details</h6>
<hr>
<div class="row clearfix" style="margin-top: 30px;">
<label class="col-sm-2 col-form-label">Class </label>
<div class="col-sm-4">
<div class="form-group">
{!! Form::select('idClass',$classes,null,['class' => 'form-control select2 show-tick ms','required'=>'required']) !!}
</div>
</div>
</div>
<div class="row clearfix">
<label class="col-sm-2 col-form-label">Section </label>
<div class="col-sm-4">
<div class="form-group">
@if(isset($template))
{!! Form::select('idSection',$section,null,['class' => 'form-control select2 show-tick ms','id'=>'idSection']) !!}
@else
{!! Form::select('idSection',$section,null,['class' => 'form-control select2 show-tick ms','required'=>'required','id'=>'idSection']) !!}
@endif
</div>
</div>
</div>
<div class="row clearfix">
<label class="col-sm-2 col-form-label">Subject </label>
<div class="col-sm-4">
<div class="form-group">
@if(isset($template))
{!! Form::select('idSubject',$subject,null,['class' => 'form-control select2 show-tick ms','id'=>'idSubject']) !!}
@else
{!! Form::select('idSubject',$subject,null,['class' => 'form-control select2 show-tick ms','required'=>'required','id'=>'idSubject']) !!}
@endif
</div>
</div>
</div>
<div class="row clearfix">
<label class="col-sm-2 col-form-label">Exam Name </label>
<div class="col-sm-4">
<div class="form-group">
@if(isset($template))
{!! Form::text('examName',$template->examName,['class' => 'form-control','required'=>'required','placeholder'=>'Exam Name']) !!}
@else
{!! Form::text('examName',null,['class' => 'form-control','required'=>'required','placeholder'=>'Exam Name']) !!}
@endif
</div>
</div>
</div>
<div class="row clearfix">
<label class="col-sm-2 col-form-label">Exam Date </label>
<div class="col-sm-4">
<div class="form-group">
<div class="input-group date" id="datetimepicker1" data-target-input="nearest">
@if(isset($template))
{!! Form::text('examDate',null,['class' => 'form-control datetimepicker-input','placeholder'=>$template->examDate,'data-target'=> '#datetimepicker1']) !!}
@else
{!! Form::text('examDate',null,['class' => 'form-control datetimepicker-input','required'=>'required','placeholder'=>'Select Date and Time','data-target'=> '#datetimepicker1']) !!}
@endif
<div class="input-group-append" data-target="#datetimepicker1" data-toggle="datetimepicker">
<div class="input-group-text"><i class="zmdi zmdi-calendar-check"></i></div>
</div>
</div>
</div>
</div>
</div>
<div class="row clearfix">
<label class="col-sm-2 col-form-label">Duration </label>
<div class="col-sm-4">
<div class="form-group">
<div class="input-group date" id="datetimepicker3" data-target-input="nearest">
@if(isset($template))
{!! Form::text('totalTime',null,['class' => 'form-control datetimepicker-input','placeholder'=> $template->examTime,'data-target'=>"#datetimepicker3", 'value'=>'00:00']) !!}
@else
{!! Form::text('totalTime',null,['class' => 'form-control datetimepicker-input','required'=>'required','placeholder'=>'Total Time','data-target'=>"#datetimepicker3", 'value'=>'00:00']) !!}
@endif
<div class="input-group-append" data-target="#datetimepicker3" data-toggle="datetimepicker">
<div class="input-group-text"><i class="zmdi zmdi-time"></i></div>
</div>
</div>
</div>
</div>
</div>
<div class="row clearfix">
<label class="col-sm-2 col-form-label">Total Marks </label>
<div class="col-sm-4">
<div class="form-group">
{!! Form::text('totalMarks',null,['class' => 'form-control','required'=>'required','placeholder'=>'Total Marks']) !!}
</div>
</div>
</div>
@endif
@if(isset($show))
<div class="row clearfix">
<label class="col-sm-2 col-form-label">Question Template </label>
<div class="table-responsive col-sm-10">
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Question Type</th>
<th scope="col">Number of Questions</th>
<th scope="col">Marks</th>
</tr>
</thead>
<tbody id="total_question">
<?php $k= 1;?>
@foreach($paper as $value)
<tr>
<th scope="row">{{$k}}</th>
<td>{{$questions["$value->typeName"]}}</td>
<td>{{$value->questions}}</td>
<td>{{$value->marks}}</td>
</tr>
<?php $k++;?>
@endforeach
</tbody>
</table>
</div>
</div>
@else
@if(isset($template))
<div class="row clearfix">
<label class="col-sm-2 col-form-label">Question Template </label>
<div class="table-responsive col-sm-10">
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Question Type</th>
<th scope="col">Number of Questions</th>
<th scope="col">Marks</th>
</tr>
</thead>
<tbody id="total_question">
<?php $k= 1;?>
@foreach($paper as $value)
<tr>
<th scope="row"><span class="questionno">{{$k}}</span></th>
<td style="min-width: 250px;"> {!! Form::select('questions['.$k.'][type]',$questions,$value->typeName,['class' => 'form-control']) !!}
</td>
<td>{!! Form::text('questions['.$k.'][total]',$value->questions,['class' => 'form-control','placeholder'=>'No. of Question']) !!}</td>
<td style="min-width: 100px;">{!! Form::text('questions['.$k.'][marks]',$value->marks,['class' => 'form-control','placeholder'=>'Marks']) !!}</td>
<td style="text-align:right;vertical-align: middle;"><input type="button" class="btn btn-sm btn-danger" value="Delete" id="remove_row"></td>
</tr>
<?php $k++;?>
@endforeach
</tbody>
<tr>
<td colspan="13" style="text-align: right"><input type="button" class="add-row-question btn btn-sm btn-success" value="Add Row"></td>
</tr>
</table>
</div>
</div>
@else
<div class="row clearfix">
<label class="col-sm-2 col-form-label">Question Template </label>
<div class="table-responsive col-sm-10">
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Question Type</th>
<th scope="col">Number of Questions</th>
<th scope="col">Marks</th>
</tr>
</thead>
<tbody id="total_question">
<tr>
<th scope="row"><span class="questionno">1</span></th>
<td style="min-width: 250px;"> {!! Form::select('questions[1][type]',$questions,null,['class' => 'form-control']) !!}
</td>
<td>{!! Form::text('questions[1][total]',null,['class' => 'form-control','placeholder'=>'No. of Question']) !!}</td>
<td style="min-width: 100px;">{!! Form::text('questions[1][marks]',null,['class' => 'form-control','placeholder'=>'Marks']) !!}</td>
<td></td>
</tr>
</tbody>
<tr>
<td colspan="13" style="text-align: right"><input type="button" class="add-row-question btn btn-sm btn-success" value="Add Row"></td>
</tr>
</table>
</div>
</div>
@endif
@endif
<div class="row clearfix">
<div class="col-sm-6 offset-sm-2">
@if(isset($template))
@if(!isset($show))
{!! Form::submit('UPDATE',['class' => 'btn btn-raised btn-primary btn-round waves-effect','id'=>'update-btn']) !!}
@endif
@else
{!! Form::submit('SAVE NOW',['class' => 'btn btn-raised btn-primary btn-round waves-effect','id'=>'submit-btn']) !!}
@endif
{!! Form::close() !!}
</div>
<div class="col-sm-12">
<label id="markserror" class="error col-sm-12" for="minmaxlength">
</label>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-12">
<div class="card">
<div class="header">
<h2><strong>List Of Exam MCQs </strong></h2>
</div>
<div class="body table-responsive">
<table class="table table-bordered table-striped table-hover js-basic-example dataTable" id ="templates">
<thead>
<tr>
<th>Exam Name</th>
<th>Class</th>
<th>Section</th>
<th>Subject</th>
<th>Start Time</th>
<th>Total Marks</th>
<th>Action</th>
<th>Question Status</th>
</tr>
</thead>
<tbody>
<!--@foreach($exams as $value)
<tr>
<td>{{$value->examName}}</td>
<td>{{$value->classM->className}}</td>
<td>@if(isset($value->section->sectionName)){{$value->section->sectionName}}@else All Section @endif</td>
<td>{{$value->subjectName}}</td>
<td>{{$value->examDate}}</td>
<td>{{$value->totalMarks}}</td>
<td>
<a href="{{ url('school/exam/master/' . $value->idMcq) }}" class="btn btn-raised btn-primary waves-effect btn-round">View</a>
<a href="{{ url('school/exam/master/' . $value->idMcq.'/edit') }}" class="btn btn-raised btn-info waves-effect btn-round">Edit</a>
<button class="btn btn-raised btn-danger waves-effect btn-round js-sweetalert" data-id="{{$value->idMcq}}" data-type="confirm">DELETE</button>
</td>
<td>
<?php
$questions = DB::table('exam_ques_types')->where('idExam',$value->idMcq)->sum('questions');
$total = \App\ExamQuestions::where('idMcq', $value->idMcq)->count();
?>
@if($questions == $total)
<a href="#" class="btn btn-primary waves-effect btn-round">Done</a>
@else
<a href="{{ url('school/exam/addquestions/' . $value->idMcq) }}" class="btn btn-danger waves-effect btn-round">Pending</a>
@endif
</td>
</tr>
@endforeach-->
</tbody>
</table>
<!--{{ $exams->links() }}-->
</div>
</div>
</div>
</div>
@stop
@section('script')
<script>
$(document).ready(function() {
//$('.dataTables_paginate').css('display','none');
if ( $.fn.dataTable.isDataTable( '#templates' ) ) {
table = $('#templates').DataTable();
table.destroy();
table = $('#templates').DataTable( {
"processing": true,
"serverSide": true,
"ajax": "{{url('school/exam/master')}}"
});
}
var classID = 'All';
$('select[name="idClass"]').on('change', function() {
classID = $(this).val();
if(classID!='All') {
$.ajax({
url: "{{url('/school/class') }}"+'/' +classID + "/sections",
type: "GET",
dataType: "json",
success:function(data) {
$('#idSection').empty();
$('#idSection').append('<option value="" selected="selected">-- Select Section --</option>');
$('#idSection').append('<option value="all" selected="selected">-- All Section --</option>');
$.each(data, function(key, value) {
$('#idSection').append('<option value="'+key+'">'+value+'</option>');
});
}
});
$.ajax({
url: "{{url('/school/class') }}"+'/' +classID + "/subjects",
type: "GET",
dataType: "json",
success:function(data) {
$('#idSubject').empty();
$('#idSubject').append('<option value="" selected="selected">-- Select Section --</option>');
$.each(data, function(key, value) {
$('#idSubject').append('<option value="'+key+'">'+value+'</option>');
});
}
});
}else{
$('select[name="idSection"]').empty();
}
});
$.fn.datetimepicker.Constructor.Default = $.extend({}, $.fn.datetimepicker.Constructor.Default, {
icons: {
time: 'zmdi zmdi-time',
date: 'zmdi zmdi-calendar-alt',
up: 'zmdi zmdi-long-arrow-up',
down: 'zmdi zmdi-long-arrow-down',
previous: 'zmdi zmdi-chevron-left',
next: 'zmdi zmdi-chevron-right',
today: 'zmdi zmdi-calendar-check',
clear: 'zmdi zmdi-delete',
close: 'zmdi zmdi-close'
} });
$('#datetimepicker1').datetimepicker();
$('#datetimepicker3').datetimepicker({
defaultDate:moment(new Date()).hours(0).minutes(0).seconds(0).milliseconds(0) ,
format: 'HH:mm'
});
$( "#size_custom" ).change(function() {
var id = $(this).data('id');
if( $(this).val() == 'custom')
{
$("#custom_"+id).show();
$("#custom_"+id).css('display','inline-flex')
}
else $("#custom_"+id).hide();
});
//Add Input field if others is selecyted
var k = $('.questionno:last').text();
$(".add-row-question").click(function(){
k++;
var markup = '<tr><td><span class="questionno">'+k+'</span></td>\
<td><select class="form-control" required="required" name="questions['+k+'][type]" tabindex="-1" title=""><option value="">-- Select Questions --</option><option value="mcq">MCQ Questions</option><option value="images_questions">Image to Questions</option><option value="question_image">Questions to Images</option><option value="image_image">Image to Image</option><option value="math_type">Math Type</option><option value="short">Short Question</option><option value="long">Long Question</option><option value="image_long">Image for Long Question</option><option value="paragraph_mcq">Paragraph MCQ</option><option value="paragraph_short">Paragraph Short Question</option></select></td>\n\
<td><input class="form-control" type="text" name="questions['+k+'][total]" required="required" placeholder = "No. of Question"></td>\n\
<td><input class="form-control" type="text" name="questions['+k+'][marks]" required="required" placeholder = "Marks"></td>\n\
<td style="text-align:right;vertical-align: middle;"><input type="button" class="btn btn-sm btn-danger" value="Delete" id="remove_row"></td></tr>';
$("#total_question").append(markup);
});
$('#total_question').on('click', 'input[type="button"]', function () {
$(this).closest('tr').remove();
k = $('.longno:last').text();
});
});
$(document).on('click', '.js-sweetalert', function (e) {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
e.preventDefault();
var idPaper = $(this).data('id');
swal({
title: "Are you sure?",
text: "Are You sure you want to delete this exam as it will delete all the questions and result assosiated with it!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: true
},
function() {
// console.log('here');
$.ajax({
type: "DELETE",
url: "{{url('/school/exam/master/')}}"+"/"+idPaper
})
.done(function(data) {
swal({
title: "Deleted",
text: "Exam has been successfully deleted",
type: "success"
},function() {
location.reload();
});
})
.fail(function(data) {
swal("Oops", "We couldn't connect to the server!", "error");
});
return false;
});
});
@if(isset($template))
// Saving form data
$('#form').on('submit',function(e){
$.ajaxSetup({
header:$('meta[name="_token"]').attr('content')
});
var formData = new FormData($('#form')[0]);
$("#update-btn").prop('disabled', true);
$.ajax({
type:"POST",
url: "{{url('school/exam/master/'.$template->idMcq) }}",
processData: false,
contentType: false,
data:formData,
dataType: 'json',
success:function(data){
if( data[Object.keys(data)[0]] === 'SUCCESS' ){
$("#update-btn").prop('disabled', true);
window.location = "{{url('school/exam/master')}}";
}
else { //False Case: With error msg
$("#markserror").html(data); //$msg is the id of empty msg
$("#update-btn").prop('disabled', false);
}
},
error: function(data){
$("#update-btn").prop('disabled', false);
if( data.status === 422 ) {
var errors = data.responseJSON.errors;
$('#markserror').html('<div class="alert alert-danger">'+errors+'</div>');
}
}
});
return false;
});
@else
// Saving form data
$('#form').on('submit',function(e){
$.ajaxSetup({
header:$('meta[name="_token"]').attr('content')
});
var formData = new FormData($('#form')[0]);
$("#submit-btn").prop('disabled', true);
$.ajax({
type:"POST",
url: "{{url('school/exam/master') }}",
processData: false,
contentType: false,
data:formData,
dataType: 'json',
success:function(data){
if( data[Object.keys(data)[0]] === 'SUCCESS' ){
$("#submit-btn").prop('disabled', true);
window.location = "{{url('school/exam/master')}}";
}
else { //False Case: With error msg
$("#markserror").html(data); //$msg is the id of empty msg
$("#submit-btn").prop('disabled', false);
}
},
error: function(data){
$("#submit-btn").prop('disabled', false);
if( data.status === 422 ) {
var errors = data.responseJSON.errors;
$('#markserror').html('<div class="alert alert-danger">'+errors+'</div>');
}
}
});
return false;
});
@endif
</script>
@stop
Copyright © 2021 -