IMMREX7
<?php $__env->startSection('content'); ?>
<div class="row clearfix">
<div class="col-sm-12">
<div class="card">
<div class="header">
<h2><strong>Add </strong>Exam Quiz</h2>
</div>
<div class="body">
<?php echo Form::open(['url' => 'school/mcq','class'=>'form-horizontal','id'=>'form']); ?>
<div class="row clearfix">
<div class="col-sm-5">
<div class="row clearfix">
<div class="col-sm-6">
<div class="form-group">
<?php echo Form::select('idClass',$classes,null,['class' => 'form-control select2 show-tick ms','required'=>'required']); ?>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-6">
<div class="form-group">
<?php echo Form::select('idSection',$section,null,['class' => 'form-control select2 show-tick ms','required'=>'required','id'=>'idSection']); ?>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-6">
<div class="form-group">
<?php echo Form::select('idSubject',$subject,null,['class' => 'form-control select2 show-tick ms','required'=>'required','id'=>'idSubject']); ?>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-6">
<div class="form-group">
<?php echo Form::text('examName',null,['class' => 'form-control','required'=>'required','placeholder'=>'Exam Name']); ?>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-6">
<div class="form-group">
<div class="input-group date" id="datetimepicker1" data-target-input="nearest">
<?php echo Form::text('examDate',null,['class' => 'form-control datetimepicker-input','required'=>'required','placeholder'=>'Select Date and Time','data-target'=> '#datetimepicker1']); ?>
<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">
<div class="col-sm-4">
<div class="form-group">
<div class="input-group date" id="datetimepicker3" data-target-input="nearest">
<?php echo Form::text('totalTime',null,['class' => 'form-control datetimepicker-input','required'=>'required','placeholder'=>'Total Time','data-target'=>"#datetimepicker3", 'value'=>'00:00']); ?>
<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">
<div class="col-sm-4">
<div class="form-group">
<?php echo Form::text('totalMarks',null,['class' => 'form-control','required'=>'required','placeholder'=>'Total Marks']); ?>
</div>
</div>
</div>
</div>
<div class="table-responsive">
<div class="header">
<h2><strong>MCQ Questions </strong></h2>
</div>
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col"></th>
<th scope="col">Questions</th>
<th scope="col"></th>
<th scope="col">A</th>
<th scope="col"></th>
<th scope="col">B</th>
<th scope="col"></th>
<th scope="col">C</th>
<th scope="col"></th>
<th scope="col">D</th>
<th scope="col"></th>
</tr>
</thead>
<tbody id="optional_list">
<tr>
<th scope="row"><span class="sno">1</span></th>
<td><?php echo Form::text('mcq[1][marks]',null,['class' => 'form-control','required'=>'required','placeholder'=>'Marks','style'=>'width: 100px;']); ?></td>
<td><?php echo Form::textarea('mcq[1][questions]',null,['class' => 'form-control','required'=>'required','rows' => 2,'placeholder'=>'Question','style'=>'width: 300px;']); ?></td>
<td> <input type="checkbox" name="mcq[1][apa]" value="1" style="margin-top: 20px;"/></td>
<td><?php echo Form::textarea('mcq[1][opa]',null,['class' => 'form-control','rows' => 2,'required'=>'required','placeholder'=>'Answer A','style'=>'width: 300px;']); ?></td>
<td><input type="checkbox" name="mcq[1][apb]" value="1" style="margin-top: 20px;"></td>
<td><?php echo Form::textarea('mcq[1][opb]',null,['class' => 'form-control','required'=>'required','rows' => 2,'placeholder'=>'Answer B','style'=>'width: 300px;']); ?></td>
<td><input type="checkbox" name="mcq[1][apc]" value="1" style="margin-top: 20px;"></td>
<td> <?php echo Form::textarea('mcq[1][opc]',null,['class' => 'form-control','required'=>'required','rows' => 2,'placeholder'=>'Answer C','style'=>'width: 300px;']); ?></td>
<td><input type="checkbox" name="mcq[1][apd]" value="1" style="margin-top: 20px;"></td>
<td> <?php echo Form::textarea('mcq[1][opd]',null,['class' => 'form-control','required'=>'required','rows' => 2,'placeholder'=>'Answer D','style'=>'width: 300px;']); ?></td>
<td></td>
</tr>
</tbody>
<tr>
<td colspan="13" style="text-align: right"><input type="button" class="add-row btn btn-sm btn-success" value="Add Row"></td>
</tr>
</table>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-6 offset-sm-4">
<?php echo Form::submit('SAVE NOW',['class' => 'btn btn-raised btn-primary btn-round waves-effect']); ?>
<?php echo Form::close(); ?>
</div>
<div class="col-sm-9 offset-sm-3">
<p style="color:red;">You can't edit this questions, please recheck it before saving</p>
</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">
<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>
</tr>
</thead>
<tbody>
<?php $__currentLoopData = $exams; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<tr>
<td><?php echo e($value->examName); ?></td>
<td><?php echo e($value->classM->className); ?></td>
<td><?php if(isset($value->section->sectionName)): ?><?php echo e($value->section->sectionName); ?><?php else: ?> All Section <?php endif; ?></td>
<td><?php echo e($value->subjectName); ?></td>
<td><?php echo e($value->examDate); ?></td>
<td><?php echo e($value->totalMarks); ?></td>
<td>
<a href="<?php echo e(url('school/mcq/' . $value->idMcq)); ?>" class="btn btn-raised btn-info waves-effect btn-round">View </a>
<button class="btn btn-raised btn-danger waves-effect btn-round js-sweetalert" data-id="<?php echo e($value->idMcq); ?>" data-type="confirm">DELETE</button>
</td>
</tr>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>
<script>
$(document).ready(function() {
var classID = 'All';
$('select[name="idClass"]').on('change', function() {
classID = $(this).val();
if(classID!='All') {
$.ajax({
url: "<?php echo e(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: "<?php echo e(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();
});
var i = $('.sno:last').text();
$(".add-row").click(function(){
i++;
var markup = '<tr><td><span class="sno">'+i+'</span></td>\
<td><input class="form-control" type="text" name="mcq['+i+'][marks]" required="required" placeholder = "Marks" style="width: 100px;"></td>\n\
<td><textarea class="form-control" required="required" rows="2" placeholder="Question" name="mcq['+i+'][questions]" cols="50" style="width: 300px;"></textarea></td>\n\
<td><input type="checkbox" name="mcq['+i+'][apa]" value="1" style="margin-top: 20px;"></td>\n\
<td><textarea class="form-control" required="required" rows="2" placeholder="Answer A" name="mcq['+i+'][opa]" cols="50" style="width: 200px;"></textarea></td>\n\
<td><input type="checkbox" name="mcq['+i+'][apb]" value="1" style="margin-top: 20px;"></td>\n\
<td><textarea class="form-control" required="required" rows="2" placeholder="Answer B" name="mcq['+i+'][opb]" cols="50" style="width: 200px;"></textarea></td>\n\
<td><input type="checkbox" name="mcq['+i+'][apc]" value="1" style="margin-top: 20px;"></td>\n\
<td><textarea class="form-control" required="required" rows="2" placeholder="Answer C" name="mcq['+i+'][opc]" style="width: 200px;" cols="50"></textarea></td>\n\
<td><input type="checkbox" name="mcq['+i+'][apd]" value="1" style="margin-top: 20px;"></td>\n\
<td><textarea class="form-control" required="required" rows="2" placeholder="Answer D" style="width: 200px;" name="mcq['+i+'][opd]" cols="50"></textarea></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>';
/*setTimeout(function(){
$('.datepicker').datepicker({
autoclose: true,
format: 'dd-mm-yyyy',
todayBtn:true,
todayHighlight:true,
orientation: 'auto'
});
}, 100);*/
$("#optional_list").append(markup);
});
var m = $('.imgno:last').text();
$(".add-row-img").click(function(){
m++;
var markup = '<tr><td><span class="imgno">'+m+'</span></td>\
<td><input class="form-control" type="text" name="img['+m+'][marks]" required="required" placeholder = "Marks" style="width: 100px;"></td>\n\
<td><textarea class="form-control" required="required" rows="2" placeholder="Question" name="img['+m+'][questions]" cols="50" style="width: 300px;"></textarea></td>\n\
<td><input type="checkbox" name="img['+m+'][apa]" value="1" style="margin-top: 20px;"></td>\n\
<td><input type="file" name="img['+m+'][opa]" cols="50" style="width: 200px;"></td>\n\
<td><input type="checkbox" name="img['+m+'][apb]" value="1" style="margin-top: 20px;"></td>\n\
<td><input type="file" name="img['+m+'][opa]" cols="50" style="width: 200px;"></td>\n\
<td><input type="checkbox" name="img['+m+'][apc]" value="1" style="margin-top: 20px;"></td>\n\
<td><input type="file" name="img['+m+'][opa]" cols="50" style="width: 200px;"></td>\n\
<td><input type="checkbox" name="img['+m+'][apd]" value="1" style="margin-top: 20px;"></td>\n\
<td><input type="file" name="img['+m+'][opa]" cols="50" style="width: 200px;"></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>';
$("#image_list").append(markup);
});
$('#image_list').on('click', 'input[type="button"]', function () {
$(this).closest('tr').remove();
i = $('.imgno:last').text();
});
//Add Input field if others is selecyted
var k = $('.longno:last').text();
$(".add-row-long").click(function(){
k++;
var markup = '<tr><td><span class="longno">'+k+'</span></td>\
<td><input class="form-control" type="text" name="long['+k+'][marks]" required="required" placeholder = "Marks" style="width: 100px;"></td>\n\
<td><select class="form-control select2 show-tick ms" required="required" name="long['+k+'][type]" tabindex="-1" title=""><option value="short">Short Question</option><option value="long">Long Question</option><option value="image">Image Upload</option></select></td>\n\
<td><textarea class="form-control" required="required" rows="2" placeholder="Question" name="long['+k+'][questions]" cols="50"></textarea></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>';
$("#long_questions").append(markup);
});
$('#long_questions').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 id = $(this).data('id');
swal({
title: "Are you sure?",
text: "Are You sure you want to delete this Exam!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: true
},
function() {
// console.log('here');
$.ajax({
type: "DELETE",
url: "<?php echo e(url('/school/mcq/')); ?>" +"/"+id,
data: {id:id}
})
.done(function(data) {
swal({
title: "Deleted",
text: "Exam has been successfully deleted",
type: "success"
},function() {
location.reload();
});
})
.error(function(data) {
swal("Oops", "We couldn't connect to the server!", "error");
});
return false;
});
});
// 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: "<?php echo e(url('school/mcq')); ?>",
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 = "<?php echo e(url('school/mcq')); ?>";
}
else { //False Case: With error msg
$("#markserror").html(data); //$msg is the id of empty msg
}
},
error: function(data){
if( data.status === 422 ) {
var errors = data.responseJSON.errors;
$('#markserror').html('<div class="alert alert-danger">'+errors+'</div>');
}
}
});
return false;
});
</script>
<script type="module">
import MathLive from 'https://unpkg.com/mathlive/dist/mathlive.mjs';
const mf = MathLive.makeMathField('mf', {
smartMode: true,
virtualKeyboardMode: 'manual'
});
$(document).ready(function() {
var l = $('.mathno:last').text();
$(".add-row-maths").click(function(){
l++;
var markup = '<tr><td><span class="mathno">'+l+'</span></td>\
<td><input class="form-control" type="text" name="maths['+l+'][marks]" required="required" placeholder = "Marks" style="width: 100px;"></td>\n\
<td><div class="mathfield" id="mf_'+l+'"></div></td>\n\
<td style="text-align:right;vertical-align: middle;width: 100px;"><input type="button" class="btn btn-sm btn-danger" value="Delete" id="remove_row"></td></tr>';
$("#maths_questions").append(markup);
MathLive.makeMathField('mf_'+l, {
smartMode: true,
virtualKeyboardMode: 'manual'
});
});
$('#maths_questions').on('click', 'input[type="button"]', function () {
$(this).closest('tr').remove();
l = $('.mathno:last').text();
});
});
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('schools.school_layout', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
Copyright © 2021 -