PluginProbe
School Management System – WPSchoolPress / 2.2.43
School Management System – WPSchoolPress v2.2.43
2.2.48 2.2.47 2.2.46 2.2.45 2.2.44 2.2.43 2.2.42 2.2.41 2.2.40 2.2.39 2.2.38 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 All 103 releases
wpschoolpress / includes / wpsp-examForm.php

wpsp-examForm.php in School Management System – WPSchoolPress 2.2.43, at includes/wpsp-examForm.php

178 lines 9.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if(!defined('ABSPATH')) exit;
2 $extable = $wpdb->prefix."wpsp_exam";
3 $examname = $examsdate = $examedate = $classid = $examid = '';
4 $subjectid = array();
5 if(isset($_GET['id'])){
6 $examid = intval($_GET['id']);
7 // $wpsp_exams = $wpdb->get_results( "select * from $extable where eid='".esc_sql($examid)."'");
8 $wpsp_exams = $wpdb->get_results($wpdb->prepare("SELECT * FROM $extable WHERE eid = %d",$examid));
9 foreach($wpsp_exams as $examdata){
10 $classid = $examdata->classid;
11 $examname = $examdata->e_name;
12 $examsdate = $examdata->e_s_date;
13 $examedate = $examdata->e_e_date;
14 $subjectid = explode( ",",$examdata->subject_id);
15 }
16 }
17 $label = isset($_GET['id']) ? esc_html__( 'Update Exam Information' , 'wpschoolpress' ): esc_html__('Add Exam Information' , 'wpschoolpress' );
18 $formname = isset($_GET['id']) ? 'ExamEditForm' : 'ExamEntryForm';
19 $buttonname = isset($_GET['id']) ? apply_filters( 'wpsp_exam_update_button_text', esc_html__( 'Update' , 'wpschoolpress' )) : apply_filters( 'wpsp_exam_submit_button_text', esc_html__('Submit' , 'wpschoolpress' ));
20 ?>
21 <!-- This form is used for Add/Update New Exam Information -->
22 <div id="formresponse"></div>
23 <form name="<?php echo esc_attr($formname);?>" action="#" id="<?php echo esc_attr($formname);?>" method="post">
24 <?php wp_nonce_field( 'ExamAction', 'wps_exam_nonce', '', true ) ?>
25 <div class="wpsp-row">
26 <div class="wpsp-col-xs-12">
27 <div class="wpsp-card">
28 <div class="wpsp-card-head">
29 <h3 class="wpsp-card-title">
30 <?php echo esc_html($label,'wpschoolpress'); ?>
31 </h3>
32 </div>
33 <div class="wpsp-card-body">
34 <div class="wpsp-row">
35 <?php do_action('wpsp_before_exam_fields');
36 $is_required_item = apply_filters('wpsp_exam_fields_is_required',array());
37 ?>
38 <div class="wpsp-col-lg-4 wpsp-col-md-6 wpsp-col-sm-6 wpsp-col-xs-12">
39 <div class="wpsp-form-group">
40 <input type="hidden" id="wpsp_locationginal" value="<?php echo esc_url(admin_url());?>" />
41 <?php
42 /*Check Required Field*/
43 if(isset($is_required_item['class_name'])){
44 $is_required = esc_html($is_required_item['class_name'],"wpschoolpress");
45 }else{
46 $is_required = true;
47 }
48 ?>
49 <label class="wpsp-label" for="Name"><?php esc_html_e("Class Name","wpschoolpress"); ?>
50 <span class="wpsp-required"><?php echo esc_html(($is_required))?"*":""; ?></span>
51 <?php if($current_user_role=='teacher') {} else {?>
52 </label>
53 <?php }?>
54 <?php
55 $classQuery = "select cid,c_name from $ctable";
56 if($current_user_role=='teacher') {
57 $cuserId = intval($current_user->ID);
58 // $classQuery = "select cid,c_name from $ctable where teacher_id='".esc_sql($cuserId)."'";
59 $classQuery = $wpdb->prepare("SELECT cid,c_name FROM $stable WHERE teacher_id = %d",$cuserId);
60 }
61 $wpsp_classes = $wpdb->get_results( $classQuery );
62 if($current_user_role=='teacher') {
63 echo ' : '.esc_html($wpsp_classes[0]->c_name);
64 echo '<input type="hidden" name="class_name" id="class_name" value="'.esc_attr($wpsp_classes[0]->cid).'">';
65 echo '</label>';
66 } else { ?>
67 <select name="class_name" data-is_required="<?php echo esc_attr($is_required); ?>" id="class_name" class="wpsp-form-control">
68 <option value=""><?php echo esc_html("Select Class","wpschoolpress");?></option>
69 <?php foreach($wpsp_classes as $value) {
70 $classlistid = intval($value->cid);?>
71 <option value="<?php echo esc_attr(intval($value->cid));?>" <?php if($classlistid == $classid) echo esc_html("selected","wpschoolpress"); ?>>
72 <?php echo esc_html($value->c_name);?>
73 </option>
74 <?php } ?>
75 </select>
76 <?php } ?>
77 </div>
78 </div>
79 <div class="wpsp-col-lg-4 wpsp-col-md-6 wpsp-col-sm-6 wpsp-col-xs-12">
80 <div class="wpsp-form-group">
81 <?php
82 /*Check Required Field*/
83 if(isset($is_required_item['ExName'])){
84 $is_required = esc_html($is_required_item['ExName'],"wpschoolpress");
85 }else{
86 $is_required = true;
87 }
88 ?>
89 <label class="wpsp-label" for="Name"><?php esc_html_e("Exam Name","wpschoolpress"); ?>
90 <span class="wpsp-required"><?php echo esc_html(($is_required))?"*":""; ?>
91 </label>
92 <input type="text" class="wpsp-form-control" data-is_required="<?php echo esc_attr($is_required); ?>" ID="ExName" name="ExName" value="<?php echo esc_attr($examname); ?>">
93 </div>
94 </div>
95 <div class="wpsp-col-lg-4 wpsp-col-md-6 wpsp-col-sm-6 wpsp-col-xs-12">
96 <div class="wpsp-form-group">
97 <?php
98 /*Check Required Field*/
99 if(isset($is_required_item['ExStart'])){
100 $is_required = esc_html($is_required_item['ExStart'],"wpschoolpress");
101 }else{
102 $is_required = true;
103 }
104 ?>
105 <label class="wpsp-label" for="Name"><?php esc_html_e("Exam Start Date","wpschoolpress"); ?>
106 <span class="wpsp-required"><?php echo esc_html(($is_required))?"*":""; ?>
107 </label>
108 <input type="text" data-is_required="<?php echo esc_attr($is_required); ?>" class="wpsp-form-control hasDatepicker" ID="ExStart" name="ExStart" value="<?php echo esc_attr($examsdate); ?>">
109 </div>
110 </div>
111 <div class="wpsp-col-lg-4 wpsp-col-md-6 wpsp-col-sm-6 wpsp-col-xs-12">
112 <div class="wpsp-form-group">
113 <?php
114 /*Check Required Field*/
115 if(isset($is_required_item['ExEnd'])){
116 $is_required = esc_html($is_required_item['ExEnd'],"wpschoolpress");
117 }else{
118 $is_required = true;
119 }
120 ?>
121 <label class="wpsp-label" for="Name"><?php esc_html_e("Exam End date","wpschoolpress"); ?>
122 <span class="wpsp-required"><?php echo esc_html(($is_required))?"*":""; ?>
123 </label>
124 <input type="text" data-is_required="<?php echo esc_attr($is_required); ?>" class="wpsp-form-control ExEnd hasDatepicker" ID="ExEnd" name="ExEnd" value="<?php echo esc_attr($examedate); ?>">
125 </div>
126 </div>
127 <div class="wpsp-col-lg-8 wpsp-col-md-12 wpsp-col-sm-12 wpsp-col-xs-12">
128 <div class="wpsp-form-group exam-subject-list">
129 <?php
130 /*Check Required Field*/
131 if(isset($is_required_item['subjectall'])){
132 $is_required = esc_html($is_required_item['subjectall'],"wpschoolpress");
133 }else{
134 $is_required = false;
135 }
136 ?>
137 <label class="wpsp-label" for="Name"><?php esc_html_e("Subject Name","wpschoolpress"); ?>
138 <span class="wpsp-required"><?php echo esc_html(($is_required))?"*":""; ?></label>
139 <input type="checkbox" data-is_required="<?php echo esc_attr($is_required); ?>" name="subjectall" value="All" class="exam-all-subjects wpsp-checkbox" id="all">
140 <label for="all" class="wpsp-checkbox-label">All</label>
141 <div class="exam-class-list">
142 <?php $sub_table = $wpdb->prefix."wpsp_subject";
143 if($current_user_role=='teacher') {
144 $classid = esc_sql($wpsp_classes[0]->cid);
145 }
146 if(!empty($classid)){
147 // $subjectlist = $wpdb->get_results("select sub_name,id from $sub_table where class_id='$classid'");
148 $subjectlist = $wpdb->get_results($wpdb->prepare("SELECT sub_name,id FROM $sub_table WHERE class_id = %d",$classid));
149 foreach($subjectlist as $svalue){ ?>
150 <input type="checkbox" name="subjectid[]" value="<?php echo esc_attr($svalue->id); ?>" class="exam-subjects wpsp-checkbox" id="subject-<?php echo esc_attr($svalue->id);?>" <?php if(in_array($svalue->id, $subjectid)){ ?> checked <?php } ?>>
151 <label for="subject-<?php echo esc_attr($svalue->id);?>" class="wpsp-checkbox-label">
152 <?php echo esc_html($svalue->sub_name);?>
153 </label>
154 <?php }
155 } ?>
156 </div>
157 </div>
158 </div>
159 <?php do_action('wpsp_after_exam_fields'); ?>
160 </div>
161 <?php if(!empty($examid)){ ?>
162 <input type="hidden" ID="ExamID" name="ExamID" value="<?php echo esc_attr($examid); ?>">
163 <?php } ?>
164 <div class="wpsp-row">
165 <div class="wpsp-col-xs-12">
166 <button type="submit" class="wpsp-btn wpsp-btn-success" id="e_submit">
167 <?php echo esc_html($buttonname); ?>
168 </button>
169 <a href="<?php echo esc_url(wpsp_admin_url().'sch-exams')?>" class="wpsp-btn wpsp-dark-btn"><?php echo esc_html__( 'Back' , 'wpschoolpress' ); ?>
170 </a>
171 </div>
172 </div>
173 </div>
174 </div>
175 </div>
176 </div>
177 </form>
178 <!-- End of Add/Update Exam Form -->