| 1 |
<?php |
| 2 |
|
| 3 |
/** =====================( Functions Details )====================== |
| 4 |
|
| 5 |
# function for default settings |
| 6 |
|
| 7 |
* @since 1.0.0 |
| 8 |
* @last-update 1.2.0 |
| 9 |
|
| 10 |
* @param mixed $list For Settings, Class, Exam, Year, Extra field |
| 11 |
* @return void |
| 12 |
|
| 13 |
===================( function for default settings )=================== **/ |
| 14 |
|
| 15 |
function educare_add_default_settings($list, $show_data = null, $new_data = null) { |
| 16 |
global $wpdb; |
| 17 |
$table = $wpdb->prefix."educare_settings"; |
| 18 |
|
| 19 |
if ($list == 'Settings') { |
| 20 |
$target = array( |
| 21 |
'confirmation' => 'checked', |
| 22 |
'guide' => 'checked', |
| 23 |
'photos' => 'checked', |
| 24 |
'auto_results' => 'checked', |
| 25 |
'advance' => 'unchecked', |
| 26 |
'problem_detection' => 'checked', |
| 27 |
'clear_data' => 'unchecked', |
| 28 |
'custom_results' => 'unchecked', |
| 29 |
'results_page' => 'results', |
| 30 |
'students_page' => 'students', |
| 31 |
'institute' => 'Name Of The Institutions (Title) Or Slogan', |
| 32 |
'optional_sybmbol' => '✓', |
| 33 |
'display' => [ |
| 34 |
'Name' => ['Name', 'checked'], |
| 35 |
'Roll_No' => ['Roll No', 'checked'], |
| 36 |
'Regi_No' => ['Regi No', 'checked'], |
| 37 |
'Class' => ['Class', 'checked'], |
| 38 |
'Exam' => ['Exam', 'checked'], |
| 39 |
'Year' => ['Year', 'checked'] |
| 40 |
], |
| 41 |
'grade_system' => [ |
| 42 |
'current' => 'Default', |
| 43 |
'rules' => [ |
| 44 |
'Default' => [ |
| 45 |
'80-100' => [5, 'A+'], |
| 46 |
'70-79' => [4, 'A'], |
| 47 |
'60-69' => [3.5, 'A-'], |
| 48 |
'50-59' => [3, 'B'], |
| 49 |
'40-49' => [2, 'C'], |
| 50 |
'33-39' => [1, 'D'], |
| 51 |
'0-32' => [0, 'F'] |
| 52 |
] |
| 53 |
] |
| 54 |
], |
| 55 |
'educare_info' => [ |
| 56 |
'version' => '1.2.0', |
| 57 |
'educare_settings' => '1.0', |
| 58 |
'educare_results' => '1.0', |
| 59 |
'package' => 'free' |
| 60 |
] |
| 61 |
); |
| 62 |
} |
| 63 |
|
| 64 |
if ($list == 'Class') { |
| 65 |
$subject = array('English', 'Mathematics', 'ICT'); |
| 66 |
$target = array( |
| 67 |
'Class 6' => $subject, |
| 68 |
'Class 7' => [], |
| 69 |
'Class 8' => [] |
| 70 |
); |
| 71 |
} |
| 72 |
|
| 73 |
if ($list == 'Exam') { |
| 74 |
$target = array( |
| 75 |
'Exam no 1', |
| 76 |
'Exam no 2', |
| 77 |
'Exam no 3' |
| 78 |
); |
| 79 |
} |
| 80 |
|
| 81 |
if ($list == 'Year') { |
| 82 |
$target = array( |
| 83 |
'2022', |
| 84 |
'2023', |
| 85 |
'2024' |
| 86 |
); |
| 87 |
} |
| 88 |
|
| 89 |
if ($list == 'Extra_field') { |
| 90 |
$target = array( |
| 91 |
// type => Name |
| 92 |
'date Date of Birth', |
| 93 |
'text Fathers Name', |
| 94 |
'text Mothers Name', |
| 95 |
'text Institute', |
| 96 |
'text Type', |
| 97 |
'email Email', |
| 98 |
'number Mobile No' |
| 99 |
); |
| 100 |
} |
| 101 |
|
| 102 |
if ($show_data) { |
| 103 |
return $target; |
| 104 |
} else { |
| 105 |
$search = $wpdb->get_results("SELECT * FROM $table WHERE list='$list'"); |
| 106 |
if ($new_data) { |
| 107 |
$target = $new_data; |
| 108 |
} |
| 109 |
} |
| 110 |
|
| 111 |
if ($search) { |
| 112 |
foreach ($search as $print) { |
| 113 |
$id = $print->id; |
| 114 |
unset($print->id); |
| 115 |
$print->data = json_encode($target); |
| 116 |
} |
| 117 |
|
| 118 |
$print = json_decode(json_encode($print), TRUE); |
| 119 |
$wpdb->update($table, $print, array('ID' => $id)); |
| 120 |
|
| 121 |
} else { |
| 122 |
$wpdb->insert($table, array( |
| 123 |
"list" => $list, |
| 124 |
"data" => json_encode($target) |
| 125 |
)); |
| 126 |
} |
| 127 |
} |
| 128 |
|
| 129 |
// create function for store default settings/all in one |
| 130 |
function educare_default_settings() { |
| 131 |
educare_add_default_settings('Settings'); |
| 132 |
educare_add_default_settings('Class'); |
| 133 |
educare_add_default_settings('Exam'); |
| 134 |
educare_add_default_settings('Year'); |
| 135 |
educare_add_default_settings('Extra_field'); |
| 136 |
} |
| 137 |
|
| 138 |
|
| 139 |
?> |