* Check if the no. of students is forty or not */ if (!checkFourtyStud($cid)) { echo '<script language="javascript"> alert("You cannot enter more than 40 students !!"); window.location="' . SERVER . '/teacher/course/' . $cid . '"; </script>'; return; } /** @var int $tid Teacher ID */ $tid = $_SESSION['tid']; /** * Check the student has already added or not */ if (!checkUniqueId($tid, $stuId, $cid)) { echo '<script language="javascript"> alert("ID has already inserted !!"); window.location="' . SERVER . '/course/' . $cid . '/addstudent"; </script>'; return; } /** * Adding Student in the Course */ addStudent($tid, $stuId, $cid); attendence($stuId, $cid); addMarks($stuId, $cid); echo '<script language="javascript"> alert("Successfully Added"); window.location="' . SERVER . '/teacher/course/' . $cid . '"; </script>';
function clipboard_options() { if (!current_user_can('manage_options')) { wp_die(__('You do not have sufficient permissions to access this page.')); } function attendence() { global $wpdb; $period = $_POST['Period']; $order_choice = $_POST['order']; if ($period != 0) { $wpdb->update('wp_class_cur', array(period_choice => $period), array(id => 1), array('%s')); } if ($order_choice != 0) { $wpdb->update('wp_class_cur', array(order_choice => $order_choice), array(id => 1), array('%s')); if ($order_choice == 1) { $order = 'temp_comp'; } else { if ($order_choice == 2) { $order = 'login'; } else { if ($order_choice == 3) { $order = 'first_name'; } else { if ($order_choice == 4) { $order = 'last_name'; } else { if ($order_choice == 5) { $order = 'totalxp'; } } } } } } $stored_period = (int) $wpdb->get_var("SELECT period_choice FROM wp_class_cur where id=1"); $stored_order = (int) $wpdb->get_var("SELECT order_choice FROM wp_class_cur where id=1"); if ($stored_order == 1) { $order = 'temp_comp'; } else { if ($stored_order == 2) { $order = 'id'; } else { if ($stored_order == 3) { $order = 'first_name'; } else { if ($stored_order == 4) { $order = 'last_name'; } else { if ($stored_order == 5) { $order = 'xp'; } } } } } ?> <br /> <br /> <form method="post" action="" > Period: <select name="Period" onchange="form.submit()" > <option value="<?php echo $stored_period; ?> "><?php echo $stored_period; ?> </option> <option value="1">Period 1</option> <option value="2">Period 2</option> <option value="3">Period 3</option> <option value="4">Period 4</option> <option value="5">Period 5</option> <option value="6">Period 6</option> <option value="7">Period 7</option> </select> Order By: <select name="order" onchange="form.submit()" > <option value="<?php echo $stored_order; ?> "><?php echo $order; ?> </option> <option value="1">comp</option> <option value="2">id</option> <option value="3">first name</option> <option value="4">last name</option> <option value="5">xp</option> </select> <input type="submit" value="Collect Data" name="collect"/> </form> <br /> <?php global $wpdb; $upload_data = $_POST['collect']; if (isset($upload_data)) { global $wpdb; $students_login = $wpdb->get_results("SELECT DISTINCT user_id FROM wp_usermeta where meta_key like 'wp_capabilities' and meta_value like '%student%'"); foreach ($students_login as $login) { foreach ($login as $user_id) { $user_info = get_userdata($user_id); $user_login = $user_info->user_login; global $wpdb; $table_name_b = $wpdb->prefix . "total_cur"; $query = "select id from {$table_name_b} where id='{$user_id}'"; $query_run = mysql_query($query); if (mysql_num_rows($query_run) == 0) { $rows_affected = $wpdb->insert('wp_total_cur', array('login' => $user_login, 'id' => $user_id)); } $period_one = (int) $wpdb->get_var("SELECT meta_value FROM wp_usermeta where meta_key = 'period' and user_id = '{$user_id}'"); $period_two = (int) $wpdb->get_var("SELECT meta_value FROM wp_usermeta where meta_key = 'periodtwo' and user_id = '{$user_id}'"); $period_three = (int) $wpdb->get_var("SELECT meta_value FROM wp_usermeta where meta_key = 'periodthree' and user_id = '{$user_id}'"); $comp_one = (int) $wpdb->get_var("SELECT meta_value FROM wp_usermeta where meta_key like 'computer' and user_id = '{$user_id}'"); $comp_two = (int) $wpdb->get_var("SELECT meta_value FROM wp_usermeta where meta_key like 'computertwo' and user_id = '{$user_id}'"); $comp_three = (int) $wpdb->get_var("SELECT meta_value FROM wp_usermeta where meta_key like computerthree' and user_id = '{$user_id}'"); $queryminutes = "SELECT SUM(minutes) FROM wp_class_cur where login = '******'"; $resultminutes = mysql_query($queryminutes) or die(mysql_error()); $rowminutes = mysql_fetch_array($resultminutes); $totalminutes = $rowminutes['SUM(minutes)']; $querygold = "SELECT SUM(gold) FROM wp_class_cur where login = '******'"; $resultgold = mysql_query($querygold) or die(mysql_error()); $rowgold = mysql_fetch_array($resultgold); $gold_rnd = $rowgold['SUM(gold)']; $xp = cp_getPoints($user_id); $first_name = $user_info->user_firstname; $last_name = $user_info->user_lastname; $table_name_b = $wpdb->prefix . "total_cur"; $wpdb->update('wp_total_cur', array('totalgold' => $gold_rnd, 'minutes' => $totalminutes, 'totalxp' => $xp, 'period_one' => $period_one, 'period_two' => $period_two, 'period_three' => $period_three, 'computer_one' => $comp_one, 'computer_two' => $comp_two, 'computer_three' => $comp_three, 'first_name' => $first_name, 'last_name' => $last_name), array(id => $user_id), array('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%s'), array('%s')); } } } $period = $_POST['Period']; $order_choice = $_POST['order']; global $wpdb; ?> <table class="widefat" id="anyid" border="1px" bordercolor="#000000" cellpadding="3px"> <thead> <tr><th width="100px">ID</th> <th width="50px">Comp</th> <th>Name</th> <th width="100px">Gamertag</th> <th width="50px">Gold</th> <th width="50px">Minutes</th> <th width="50px">XP</th> <th width="80px">Encountered</th> <th width="80px">Accepted</th> <th width="80px">Completed</th> <th width="80px">Mastered</th> </tr></thead> <?php $studs_id = $wpdb->get_results("SELECT user_id FROM wp_usermeta where meta_key like '%period%' and meta_value = {$period}"); foreach ($studs_id as $id_two) { foreach ($id_two as $stud_id) { global $wpdb; $per = $wpdb->get_var("SELECT meta_key FROM wp_usermeta where meta_key like '%period%' and meta_value = {$period} and user_id = {$stud_id}"); if ($per == 'period') { $comp = 'computer'; } else { if ($per == 'periodtwo') { $comp = 'computertwo'; } else { if ($per == 'periodthree') { $comp = 'computerthree'; } } } $computer_num = (int) $wpdb->get_var("SELECT meta_value FROM wp_usermeta where meta_key = '{$comp}' and user_id = {$stud_id}"); $wpdb->update('wp_total_cur', array('temp_comp' => $computer_num), array('id' => $stud_id), array('%d'), array('%d')); } } if (isset($_POST['Period'])) { $period = $_POST['Period']; } else { $period = (int) $wpdb->get_var("SELECT period_choice FROM wp_class_cur where id=1"); } if (isset($_POST['order'])) { $order_choice = $_POST['order']; } else { $order_choice = (int) $wpdb->get_var("SELECT order_choice FROM wp_class_cur where id=1"); } if ($order_choice == 1) { $order = 'temp_comp'; } else { if ($order_choice == 2) { $order = 'login'; } else { if ($order_choice == 3) { $order = 'first_name'; } else { if ($order_choice == 4) { $order = 'last_name'; } else { if ($order_choice == 5) { $order = 'totalxp'; } } } } } $table_name_all_users = $wpdb->prefix . "usermeta"; $students_id = $wpdb->get_results("SELECT id\nFROM wp_total_cur\nWHERE (period_one ={$period}\nOR period_two ={$period}\nOR period_three = {$period})\norder by {$order}\n"); $x = 0; $pstat_id = (int) $wpdb->get_var("select post_id from wp_postmeta where meta_key = '_wp_page_template' and meta_value = 'page.stats.php'"); $pstat_link = get_permalink($pstat_id); foreach ($students_id as $id) { foreach ($id as $student_id) { $st_id_ca = (int) $wpdb->get_var("SELECT count(*) FROM wp_usermeta where meta_key = 'wp_capabilities' and meta_value like '%student%' and user_id = {$student_id} "); if ($st_id_ca != 0) { $user_info = get_userdata($student_id); $user_login_name = $user_info->user_login; $first_name = $user_info->user_firstname; $last_name = $user_info->user_lastname; $display_name = $user_info->display_name; $date = date('l jS F Y'); $gold = (int) $wpdb->get_var("SELECT totalgold FROM wp_total_cur where login = '******'"); $silver = (int) $wpdb->get_var("SELECT totalsilver FROM wp_total_cur where login = '******'"); $copper = (int) $wpdb->get_var("SELECT totalcopper FROM wp_total_cur where login = '******'"); $minutes = (int) $wpdb->get_var("SELECT minutes FROM wp_total_cur where login = '******'"); $xp = cp_getPoints($student_id); $per = $wpdb->get_var("SELECT meta_key FROM wp_usermeta where meta_key like '%period%' and meta_value = {$period} and user_id = {$student_id}"); if ($per == 'period') { $comp = 'computer'; } else { if ($per == 'periodtwo') { $comp = 'computertwo'; } else { if ($per == 'periodthree') { $comp = 'computerthree'; } } } $computer_nums = (int) $wpdb->get_var("SELECT meta_value FROM wp_usermeta where meta_key = '{$comp}' and user_id = {$student_id}"); ?> <tr> <td><a href="<?php echo $pstat_link; ?> ?id=<?php echo $student_id; ?> " target="_blank"> <?php echo $letter[$x] = $user_login_name; ?> </a> </td><td> <?php echo $computer_nums; ?> </td> <td style="width: 84px;"> <?php echo $first_name . " " . $last_name; ?> </td> <td> <?php echo $display_name; ?> </td><td> <?php echo $gold; ?> </td><td> <?php echo $minutes; ?> </td><td> <?php echo $xp; ?> </td><td> <?php $num_enc = (int) $wpdb->get_var("SELECT count(*) FROM wp_cp WHERE status = 1 and uid = {$student_id}"); $num_acc = (int) $wpdb->get_var("SELECT count(*) FROM wp_cp WHERE status = 2 and uid = {$student_id}"); $num_com = (int) $wpdb->get_var("SELECT count(*) FROM wp_cp WHERE status = 3 and uid = {$student_id}"); $num_mas = (int) $wpdb->get_var("SELECT count(*) FROM wp_cp WHERE status = 4 and uid = {$student_id}"); echo '(' . $num_enc . ')'; ?> </td> <td> <?php echo '(' . $num_acc . ')'; ?> </td><td> <?php echo '(' . $num_com . ')'; ?> </td><td> <?php echo '(' . $num_mas . ')'; ?> </td> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html><body> <td style="width: 77px;"> <form method="post" action=""> <input type= "submit" value= "Absent" name= <?php echo 'ab' . $letter[$x]; ?> /> <input type="submit" value="Fix" name=<?php echo 'del_ab_today' . $letter[$x]; ?> /> </form> </td> <td style="width: 77px;"> <form method="post"> <input type= "submit" value= "Tardy" name= <?php echo 'ty' . $letter[$x]; ?> /> <input type="submit" value="Fix" name=<?php echo 'del_tardy_today' . $letter[$x]; ?> /> </form></td> <td style="width: 84px;"> <form method="post"> <input type= "submit" value= "Truancy" name= <?php echo 'tr' . $letter[$x]; ?> /> <input type="submit" value="Fix" name=<?php echo 'del_tr_today' . $letter[$x]; ?> /> </form></td> <td style="width: 84px;"> <form method="post"> <input type= "submit" value= "Off Task" name= <?php echo 'ot' . $letter[$x]; ?> /> <input type="submit" value="Fix" name=<?php echo 'del_ot_today' . $letter[$x]; ?> /> </form></td> </tr> <?php $tardy = $_POST['ty' . $letter[$x]]; if (isset($tardy)) { global $wpdb; $table_name_cp = $wpdb->prefix . "class_cur"; $wpdb->insert($table_name, array('login' => $user_login_name, 'minutes' => -30, 'minutes_reason' => "Tardy"), array('%s', '%s', '%s')); } $absence = $_POST['ab' . $letter[$x]]; if (isset($absence)) { $table_name_user = $wpdb->prefix . "class_cur"; $wpdb->insert($table_name_user, array('login' => $user_login_name, 'minutes' => -60, 'minutes_reason' => "Absent"), array('%s', '%s', '%s')); } $delete_absence_today = $_POST['del_ab_today' . $letter[$x]]; if (isset($delete_absence_today)) { global $wpdb; $table_name_d = $wpdb->prefix . "class_cur"; $wpdb->query("delete from wp_cp where minutes_reason like 'Absent' and uid like {$student_id} limit 1"); } $delete_tardy_today = $_POST['del_tardy_today' . $letter[$x]]; if (isset($delete_tardy_today)) { global $wpdb; $table_name_d = $wpdb->prefix . "class_cur"; $wpdb->query("delete from wp_cp where minutes_reason like 'Tardy' and uid like {$student_id} limit 1"); } $truancy = $_POST['tr' . $letter[$x]]; if (isset($truancy)) { $table_name_user = $wpdb->prefix . "class_cur"; $wpdb->insert($table_name_user, array('login' => $user_login_name, 'minutes' => -180, 'minutes_reason' => "Truant"), array('%s', '%s', '%s')); } $delete_truancy_today = $_POST['del_tr_today' . $letter[$x]]; if (isset($delete_truancy_today)) { global $wpdb; $table_name_d = $wpdb->prefix . "class_cur"; $wpdb->query("delete from wp_cp where minutes_reason like 'Truancy' and uid like {$student_id} limit 1"); } $offtask = $_POST['ot' . $letter[$x]]; if (isset($offtask)) { $table_name_user = $wpdb->prefix . "class_cur"; $wpdb->insert($table_name_user, array('login' => $user_login_name, 'minutes' => -30, 'minutes_reason' => "Off Task"), array('%s', '%s', '%s')); } $delete_offtask_today = $_POST['del_ot_today' . $letter[$x]]; if (isset($delete_offtask_today)) { global $wpdb; $table_name_d = $wpdb->prefix . "class_cur"; $wpdb->query("delete from wp_cp where minutes_reason like 'Off Task' and uid like {$student_id} limit 1"); } $bonus = $_POST['bns' . $letter[$x]]; if (isset($bonus)) { $table_name_user = $wpdb->prefix . "class_cur"; $wpdb->insert($table_name_user, array('login' => $user_login_name, 'minutes' => -60, 'minutes_reason' => "Bonus"), array('%s', '%s', '%s')); } $delete_bonus_today = $_POST['del_bns_today' . $letter[$x]]; if (isset($delete_offtask_today)) { global $wpdb; $table_name_d = $wpdb->prefix . "class_cur"; $wpdb->query("delete from wp_cp where minutes_reason like 'Bonus' and uid like {$student_id} limit 1"); } $x = $x + 1; } } } ?> </table> <?php } do_action($get_attendence, attendence()); do_action('attendence'); }