관리-도구
편집 파일: CFCourse_assignment.php
<?php if (!class_exists('CFCourse_assignment')) { class CFCourse_assignment { var $loader; function __construct($arr) { $this->loader = $arr['loader']; } /* @param working: this function add section for course */ public function handleAssignmentData($assign_data = null) { global $mysqli; global $dbpref; $table = $dbpref . "content_options"; $course_id = (int)$mysqli->real_escape_string(trim($assign_data['cfcourse_course_id'])); $section_id = (int)$mysqli->real_escape_string(trim($assign_data['cfcourse_section_id'])); $title = $mysqli->real_escape_string(trim($assign_data['cfcourse_a_t'])); $type = $mysqli->real_escape_string(trim($assign_data['test_type'])); $position = $mysqli->real_escape_string(trim($assign_data['position'])); $positions = explode(",", $position); $time = date("Y-m-d H:i:s"); if (empty($title)) { json_encode(array("status" => 0, "type" => "a_title", "message" => "Please fill this field")); die(); } $etitle = $title; $option_type = $type; $content_type = $type; $total_count = getTotalCount($table); $site_token_for_dashboard = get_option('site_token'); if ($_SESSION['user_plan_type' . $site_token_for_dashboard] == 2 && $total_count >= 1) { $return_insert = -1; } else { $a_stmt = "INSERT INTO `" . $table . "` (`course_id`, `section_id`, `title`,`option_type`,`content_type`,`updates`, `created_at`, `updated_at` ) VALUES ($course_id, $section_id, '" . $etitle . "', '" . $option_type . "','" . $content_type . "','1','" . $time . "', '" . $time . "' )"; $return_insert = $mysqli->query($a_stmt) ? 1 : 1; } if ($return_insert == 1) { $last_id = $mysqli->insert_id; $result = $mysqli->query("SELECT * FROM `" . $table . "` Where `id`=" . $last_id); if ($result->num_rows > 0) { foreach ($positions as $posit) { if ($posit == "new") { $pos[] = $last_id; } else { $pos[] = $posit; } } $section_ob = $this->loader->load("section"); $section_ob->addPosition($pos, "l", $course_id); $a_data = $result->fetch_assoc(); self::addAssignmentData($a_data, "add", $type); $html = self::getAssignHtml($a_data, 1); echo json_encode(array("status" => 1, "cls" => ".cfcourse_s_t_i_des", "type" => "assign_add", "assign_id" => $last_id, "data" => $html, "message" => "course assign added succesfull")); die(); } } else { echo json_encode(array("status" => 0, "type" => "assign_add", "message" => "assignment not added succesfull")); die(); } } public function addAssignmentData($a_data = null, $action = null, $type = '') { global $mysqli; global $dbpref; $table = $dbpref . "assignment"; $assign_id = $a_data['id']; $section_id = $a_data['section_id']; $course_id = $a_data['course_id']; $a_title = $a_data['title']; $time = date("Y-m-d H:i:s"); if ($action == "add") { $u_stmt = "INSERT INTO `" . $table . "` (`type`,`course_id`, `section_id`, `assign_id`, `bi_title`, `updates`, `added_on` ) VALUES ('" . $type . "',$course_id, $section_id , $assign_id, '" . $a_title . "', '1','" . $time . "')"; } else if ($action == "update") { $u_stmt = "UPDATE `" . $table . "` SET `bi_title`='" . $a_title . "', `added_on`='" . $time . "' WHERE `assign_id`=" . $assign_id; } $total_count = getTotalCount($table); $site_token_for_dashboard = get_option('site_token'); if ($_SESSION['user_plan_type' . $site_token_for_dashboard] == 2 && $total_count >= 1) { $return_update = 0; } else { $return_update = $mysqli->query($u_stmt) ? 1 : 1; } if ($return_update) { return true; } else { return false; } } public function getAssignHtml($a_data = null, $next_count = 1) { $install_url = get_option("install_url"); $last_id = $a_data['id']; $section_id = $a_data['section_id']; $course_id = $a_data['course_id']; $type = $a_data['option_type']; $html = ""; $a_title = htmlspecialchars(stripslashes($a_data['title'])); $a_tle = ((strlen($a_title) > 80) ? substr($a_title, 0, 80) . '...' : $a_title); if ($type == "test") { $href = $install_url . '?page=cfcourse_manage_test&course_id=' . $course_id . '&section_id=' . $section_id . '&test_id=' . $last_id; ob_start(); echo ' <div id="cfcourse-o-t-cont-' . $last_id . '" class="cfcourse-o-t-c cfcourse-q bg-white cf--open-lectab p-2" data-posid="' . $last_id . '" data-position="not" > <div class="cfcourse-o-content "> <div class="d-flex cf--c--opsrtab cf--open-lectuer justify-content-between justify-content-md-between align-items-center flex-column flex-sm-row"> <div class="cf--course-stitle"> <i class="fas fa-check"></i> <span style="font-weight:bold" > ' . t('Test') . ' <span class="cfcourse-a-count"></span>: </span> <span class="cfcourse-quiz-title" > ' . $a_tle . ' <span> </div> <div class="cfcourse-action p-sm-0 pt-1 "> <div class="d-flex"> <div class="px-1 "> <a href="' . $href . '" class=" d-inline-block btn btn-success" target="_blank" title="' . t('Edit Test Content') . '"> <i class="fas fa-edit d-inline-block"></i> </a></div> <div class="px-1 cfcourse-del-content-btn cfcourse-del-content" data-cont-id="' . $last_id . '"><button class="cfcourse-del-content-btn btn btn-danger" title="' . t('Delete Test') . '"> <i class="fas fa-trash cfcourse-del-content-btn"></i> </button></div> </div> </div> </div> </div> </div> <div class="cfcourse-o-a-o cfcourse-a-o text-center mt-4" data-c-id="' . $course_id . '" data-s-id="' . $section_id . '"> <div class="cfcourse-a-o cfcourse-a-o-c " title="' . t('Add Content') . '"><button class="btn btn-primary cfcourse-a-o cfcourse-a-o-btn"><span class="cfcourse-a-o cfcourse-a-o-text">+</span></button></div> </div> '; $html .= ob_get_clean(); } else if ($type == "assign") { $href = $install_url . '?page=cfcourse_manage_assignment&course_id=' . $course_id . '&section_id=' . $section_id . '&assignment_id=' . $last_id; ob_start(); echo ' <div id="cfcourse-o-t-cont-' . $last_id . '" class="cfcourse-o-t-c cf--c--opsrtab cfcourse-q bg-white cf--open-lectab p-2" data-posid="' . $last_id . '" data-position="not" style="cursor: all-scroll;"> <div class="cfcourse-o-content cf--c--opsrtab"> <div class="d-flex cf--c--opsrtab cf--open-lectuer justify-content-between justify-content-md-between align-items-center flex-column flex-sm-row"> <div style="cursor: initial;" class="cf--course-stitle"> <i class="fas fa-tasks"></i> <span style="font-weight:bold" > ' . t('Assignment') . ' <span class="cfcourse-a-count"></span>: </span> <span class="cfcourse-quiz-title" > ' . $a_tle . ' <span> </div> <div class="cfcourse-action p-sm-0 pt-1 " style="cursor: initial;"> <div class="d-flex"> <div class="px-1 "> <a href="' . $href . '" class=" d-inline-block btn btn-success" target="_blank" title="' . t('Edit Assignment Content') . '"> <i class="fas fa-edit d-inline-block"></i> </a></div> <div class="px-1 cfcourse-del-content-btn cfcourse-del-content" data-cont-id="' . $last_id . '"><button class="cfcourse-del-content-btn btn btn-danger" title="' . t('Delete Assignment') . '"> <i class="fas fa-trash cfcourse-del-content-btn"></i> </button></div> </div> </div> </div> </div> </div> <div class="cfcourse-o-a-o cfcourse-a-o text-center mt-4" data-c-id="' . $course_id . '" data-s-id="' . $section_id . '"> <div class="cfcourse-a-o cfcourse-a-o-c " title="' . t('Add Content') . '"><button class="btn btn-primary cfcourse-a-o cfcourse-a-o-btn"><span class="cfcourse-a-o cfcourse-a-o-text">+</span></button></div> </div> '; $html .= ob_get_clean(); } return $html; } // this function play next lecture, assignemnt, quiz and also this fuction added duration of any kind of video function addDuration($ddata) { global $mysqli; global $dbpref; $table = $dbpref . "video_start"; $duration = $mysqli->real_escape_string(trim($ddata['duration'])); $action = $mysqli->real_escape_string(trim($ddata['param'])); $oid = (int)$mysqli->real_escape_string(trim($ddata['oid'])); $mem_id = (int)$mysqli->real_escape_string(trim($ddata['mid'])); $sid = (int)$mysqli->real_escape_string(trim($ddata['sid'])); $cid = (int)$mysqli->real_escape_string(trim($ddata['cid'])); $type = $mysqli->real_escape_string(trim($ddata['type'])); $p = $mysqli->real_escape_string(trim($ddata['person'])); $quiz_ob = $this->loader->load("quiz_stud_control"); $mem_data = $quiz_ob->checkIfIsAdmin($mem_id); $mid = $mem_data['mid']; $course_ob = $this->loader->load("course_control"); $cdata = $course_ob->get_course_by_id($cid, 'drip_on_off'); $drip_on_off = $cdata['drip_on_off']; $table_drip = $dbpref . "member_drip"; $add_times = date("Y-m-d", time()); $table2 = $dbpref . "all_products"; $watched = 10; $mysqli->query("UPDATE `$table2` SET `total_watched`=`total_watched`+$watched WHERE `id`=$cid"); if ($p == "s") { if ($action == "save") { $stmt1 = "SELECT * FROM `" . $table . "` WHERE `option_id`=$oid AND `member_id`=$mid"; $url = base64_encode(json_encode(["course_id" => $cid, "section_id" => $sid, "type" => $type, "option_id" => $oid])); $r_u = $mysqli->query($stmt1); if ($r_u->num_rows > 0) { $stmt = $mysqli->query("UPDATE `" . $table . "` SET `duration`=$duration WHERE `option_id`=$oid AND `member_id`=" . $mid); $stmt2 = $mysqli->query("SELECT * FROM `" . $table_drip . "` WHERE `course_id`=$cid AND `section_id`=$sid AND `member_id`=$mid LIMIT 1 "); if ($stmt2->num_rows > 0 && $drip_on_off == 1) { $dddata = $stmt2->fetch_assoc(); $days = $dddata['drip_days']; if ($dddata['created_at'] <= $add_times) { echo json_encode(array("status" => 1, 'type' => "add", "mes" => "already", "action" => "yes", "data" => $url)); die(); } else { echo json_encode(array("status" => 1, 'type' => "add", 'drip_days' => $days, "mes" => "already", "action" => "no", "data" => $url)); die(); } } else { echo json_encode(array("status" => 1, 'type' => "add", "mes" => "already", "action" => "yes", "data" => $url)); die(); } } else { $total_count = getTotalCount($table); $site_token_for_dashboard = get_option('site_token'); if ($_SESSION['user_plan_type' . $site_token_for_dashboard] == 2 && $total_count >= 1) { $affect_row = 0; } else { $stmt = "INSERT INTO `" . $table . "`(`course_id`, `section_id`, `option_id`, `member_id`, `duration`,`person`) VALUES ( $cid, $sid, $oid, $mid, $duration,'" . $p . "')"; $r_a = $mysqli->query($stmt) ? 1 : 1; $affect_row = $mysqli->affected_rows; } if ($affect_row == 1) { $dresult = $mysqli->query("SELECT * FROM `" . $table_drip . "` WHERE `course_id`=$cid AND `section_id`=$sid AND `member_id`=" . $mid); $url = base64_encode(json_encode(["course_id" => $cid, "section_id" => $sid, "type" => $type, "option_id" => $oid])); if ($dresult->num_rows > 0) { $dddata = $dresult->fetch_assoc(); $days = $dddata['drip_days']; if ($dddata['created_at'] <= $add_times && $drip_on_off == 1) { echo json_encode(array("status" => 1, 'type' => "add", "mes" => "already", "action" => "yes", "data" => $url)); die(); } else { echo json_encode(array("status" => 1, 'type' => "add", 'drip_days' => $days, "mes" => "already", "action" => "no", "data" => $url)); die(); } } else { echo json_encode(array("status" => 1, 'type' => "add", "mes" => "already", "action" => "yes", "data" => $url)); die(); } } else { echo json_encode(array("status" => 0, "data" => "data not fetched")); die(); } } die(); } else if ($action = "update") { $stmt1 = "SELECT * FROM `" . $table . "` WHERE `option_id`=$oid AND `member_id`=$mid"; $r_u = $mysqli->query($stmt1); if ($r_u->num_rows > 0) { $stmt = $mysqli->query("UPDATE `" . $table . "` SET `duration`=$duration WHERE `option_id`=$oid AND `member_id`=" . $mid); $stmt2 = $mysqli->query("SELECT * FROM `" . $table_drip . "` WHERE `course_id`=$cid AND `section_id`=$sid AND `member_id`=$mid LIMIT 1 "); $r = $r_u->fetch_assoc(); if ($stmt2->num_rows > 0 && $drip_on_off == 1) { $dddata = $stmt2->fetch_assoc(); $days = $dddata['drip_days']; if ($dddata['created_at'] <= $add_times) { echo json_encode(array("status" => 1, "type" => "update", "action" => "yes", "data" => "data updated ")); die(); } else { echo json_encode(array("status" => 1, 'type' => "update", 'drip_days' => $days, "mes" => "already", "action" => "no", "data" => "data_updated")); die(); } } else { echo json_encode(array("status" => 1, "type" => "update", "action" => "yes", "data" => "data updated ")); die(); } } else { $total_count = getTotalCount($table); $site_token_for_dashboard = get_option('site_token'); if ($_SESSION['user_plan_type' . $site_token_for_dashboard] == 2 && $total_count >= 1) { $affect_row = 0; } else { $stmt = "INSERT INTO `" . $table . "`(`course_id`, `section_id`, `option_id`, `member_id`, `duration`,`person`) VALUES ( $cid, $sid, $oid, $mid, $duration,'" . $p . "')"; $r_a = $mysqli->query($stmt) ? 1 : 1; $affect_row = $$mysqli->affected_rows; } if ($affect_row == 1) { $dresult = $mysqli->query("SELECT * FROM `" . $table_drip . "` WHERE `course_id`=$cid AND `section_id`=$sid AND `member_id`=" . $mid); $url = base64_encode(json_encode(["course_id" => $cid, "section_id" => $sid, "type" => $type, "option_id" => $oid])); if ($dresult->num_rows > 0 && $drip_on_off == 1) { $dddata = $dresult->fetch_assoc(); $days = $dddata['drip_days']; if ($dddata['created_at'] <= $add_times) { echo json_encode(array("status" => 1, "type" => "update", "action" => "yes", "data" => "data updated ")); die(); } else { echo json_encode(array("status" => 1, 'type' => "update", 'drip_days' => $days, "mes" => "already", "action" => "no", "data" => "data_updated")); die(); } } else { echo json_encode(array("status" => 1, "type" => "update", "action" => "yes", "data" => "data updated ")); die(); } } else { echo json_encode(array("status" => 0, "data" => "data not fetched")); die(); } } die(); } } elseif ($p == "a") { $url1 = base64_encode(json_encode(["admin" => "is_admin", "course_id" => $cid])); $url2 = base64_encode(json_encode(["course_id" => $cid, "section_id" => $sid, "type" => $type, "option_id" => $oid])); $url = "?page=cfcourse_preview&cfapreview=" . $url1 . "&cf_vid=" . $url2; echo json_encode(array("status" => 2, 'type' => "a", "data" => $url, "url_type" => $type)); die(); } } function exportToCSVASSIGN() { if (isset($_POST['assignto_csv'])) { global $mysqli; global $dbpref; $student_assign = $dbpref . "stud_assignment"; $assign_response = $dbpref . "submit_assignment"; $assign_table = $dbpref . "assignment"; $course_table = $dbpref . "all_products"; $sql = "SELECT cfsa.*, cfc.`title` FROM `" . $student_assign . "` as cfsa LEFT JOIN `" . $course_table . "` as cfc ON cfc.`id`=cfsa.`course_id` where cfsa.`type`= 'assign'"; $row = $mysqli->query($sql); $csv_fields = array(); $csv_fields[] = '#'; $csv_fields[] = 'STUDENTS NAME'; $csv_fields[] = 'STUDENT EMAIL'; $csv_fields[] = 'COURSE NAME'; $csv_fields[] = 'ASSIGNMEMT'; $csv_fields[] = 'Total Questions'; $csv_fields[] = 'Correct Answer'; $csv_fields[] = 'Percentage Received'; $csv_fields[] = 'Comments Received'; $csv_fields[] = 'Time Spent'; $csv_fields[] = 'Submitted On'; $output_handle = ''; $output_filename = 'assign.csv'; $output_handle = @fopen('php://output', 'w'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Content-Description: File Transfer'); header('Content-type: text/csv'); header('Content-Disposition: attachment; filename=' . $output_filename); header('Expires: 0'); header('Pragma: public'); fputcsv($output_handle, $csv_fields); if ($row !== false && $row->num_rows > 0) { $count = 0; while ($data = $row->fetch_assoc()) { ++$count; $make_sql = "SELECT cfsr.* FROM `" . $student_assign . "` cfsa LEFT JOIN `" . $assign_response . "` cfsr ON cfsa.`id`=cfsr.`response_id` "; $qry2 = $mysqli->query($make_sql); $outputrray = array($count); array_push($outputrray, $data['name']); array_push($outputrray, $data['email']); array_push($outputrray, $data['title']); array_push($outputrray, $data['assign_title']); array_push($outputrray, $data['no_of_questions']); array_push($outputrray, $data['no_correct_answers']); array_push($outputrray, $data['percentage'] . "%"); array_push($outputrray, $data['comment']); array_push($outputrray, $data['time_spent']); array_push($outputrray, $data['submitted_on']); fputcsv($output_handle, $outputrray); } } fclose($output_handle); die(); } } function exportToCSVASSIGN_AN() { if (isset($_POST['assignto_csv_an'])) { global $mysqli; global $dbpref; $student_assign = $dbpref . "stud_assignment"; $assign_response = $dbpref . "submit_assignment"; $assign_table = $dbpref . "assignment"; $course_table = $dbpref . "all_products"; $sql = "SELECT cfsa.*, cfc.`title` FROM `" . $student_assign . "` as cfsa LEFT JOIN `" . $course_table . "` as cfc ON cfc.`id`=cfsa.`course_id` where cfsa.`type`= 'assign'"; $row = $mysqli->query($sql); $csv_fields = array(); $csv_fields[] = '#'; $csv_fields[] = 'STUDENTS NAME'; $csv_fields[] = 'STUDENT EMAIL'; $csv_fields[] = 'COURSE NAME'; $csv_fields[] = 'ASSIGNMEMT'; $csv_fields[] = 'Total Questions'; $csv_fields[] = 'Correct Answer'; $csv_fields[] = 'Percentage Received'; $csv_fields[] = 'Comments Received'; $csv_fields[] = 'Time Spent'; $csv_fields[] = 'Submitted On'; $output_handle = ''; $output_filename = 'assign_an.csv'; $output_handle = @fopen('php://output', 'w'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Content-Description: File Transfer'); header('Content-type: text/csv'); header('Content-Disposition: attachment; filename=' . $output_filename); header('Expires: 0'); header('Pragma: public'); fputcsv($output_handle, $csv_fields); if ($row !== false && $row->num_rows > 0) { $count = 0; while ($data = $row->fetch_assoc()) { ++$count; $make_sql = "SELECT cfsr.* FROM `" . $student_assign . "` cfsa LEFT JOIN `" . $assign_response . "` cfsr ON cfsa.`id`=cfsr.`response_id` where cfsa.`member_id`=" . $data['member_id'] . " and cfsr.`type`= 'assign' "; $qry2 = $mysqli->query($make_sql); $outputrray = array($count); array_push($outputrray, $data['name']); array_push($outputrray, $data['email']); array_push($outputrray, $data['title']); array_push($outputrray, $data['assign_title']); array_push($outputrray, $data['no_of_questions']); array_push($outputrray, $data['no_correct_answers']); array_push($outputrray, $data['percentage'] . "%"); array_push($outputrray, $data['comment']); array_push($outputrray, $data['time_spent']); array_push($outputrray, $data['submitted_on']); fputcsv($output_handle, $outputrray); $new = []; $cnt = 0; array_push($new, ''); array_push($new, 'QUESTIONS NUMBER'); array_push($new, 'QUESTIONS'); array_push($new, 'STUDENT ANSWERS'); array_push($new, 'TEACHER ANSWERS'); fputcsv($output_handle, $new); while ($rows = $qry2->fetch_assoc()) { $ne = []; array_push($ne, ''); array_push($ne, ++$cnt); array_push($ne, strip_tags($rows['questions'])); array_push($ne, $rows['answers_student']); array_push($ne, strip_tags($rows['answers_admin'])); fputcsv($output_handle, $ne); } } } fclose($output_handle); die(); } } function exportToCSVTEST() { if (isset($_POST['testto_csv'])) { global $mysqli; global $dbpref; $student_assign = $dbpref . "stud_assignment"; $assign_response = $dbpref . "submit_assignment"; $assign_table = $dbpref . "assignment"; $course_table = $dbpref . "all_products"; $sql = "SELECT cfsa.*, cfc.`title` FROM `" . $student_assign . "` as cfsa LEFT JOIN `" . $course_table . "` as cfc ON cfc.`id`=cfsa.`course_id` where cfsa.`type`= 'test'"; $row = $mysqli->query($sql); $csv_fields = array(); $csv_fields[] = '#'; $csv_fields[] = 'STUDENTS NAME'; $csv_fields[] = 'STUDENT EMAIL'; $csv_fields[] = 'COURSE NAME'; $csv_fields[] = 'TEST'; $csv_fields[] = 'Total Questions'; $csv_fields[] = 'Correct Answer'; $csv_fields[] = 'Percentage Received'; $csv_fields[] = 'Comments Received'; $csv_fields[] = 'Time Spent'; $csv_fields[] = 'Submitted On'; $output_handle = ''; $output_filename = 'test.csv'; $output_handle = @fopen('php://output', 'w'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Content-Description: File Transfer'); header('Content-type: text/csv'); header('Content-Disposition: attachment; filename=' . $output_filename); header('Expires: 0'); header('Pragma: public'); fputcsv($output_handle, $csv_fields); if ($row !== false && $row->num_rows > 0) { $count = 0; while ($data = $row->fetch_assoc()) { ++$count; $make_sql = "SELECT cfsr.* FROM `" . $student_assign . "` cfsa LEFT JOIN `" . $assign_response . "` cfsr ON cfsa.`id`=cfsr.`response_id` where cfsa.`member_id`=" . $data['member_id'] . " and cfsr.`type`= 'test' "; $qry2 = $mysqli->query($make_sql); $outputrray = array($count); array_push($outputrray, $data['name']); array_push($outputrray, $data['email']); array_push($outputrray, $data['title']); array_push($outputrray, $data['assign_title']); array_push($outputrray, $data['no_of_questions']); array_push($outputrray, $data['no_correct_answers']); array_push($outputrray, $data['percentage'] . "%"); array_push($outputrray, $data['comment']); array_push($outputrray, $data['time_spent']); array_push($outputrray, $data['submitted_on']); fputcsv($output_handle, $outputrray); } } fclose($output_handle); die(); } } function exportToCSVTEST_AN() { if (isset($_POST['testto_an'])) { global $mysqli; global $dbpref; $student_assign = $dbpref . "stud_assignment"; $assign_response = $dbpref . "submit_assignment"; $assign_table = $dbpref . "assignment"; $course_table = $dbpref . "all_products"; $sql = "SELECT cfsa.*, cfc.`title` FROM `" . $student_assign . "` as cfsa LEFT JOIN `" . $course_table . "` as cfc ON cfc.`id`=cfsa.`course_id` where cfsa.`type`= 'test'"; $row = $mysqli->query($sql); $csv_fields = array(); $csv_fields[] = '#'; $csv_fields[] = 'STUDENTS NAME'; $csv_fields[] = 'STUDENT EMAIL'; $csv_fields[] = 'COURSE NAME'; $csv_fields[] = 'TEST'; $csv_fields[] = 'Total Questions'; $csv_fields[] = 'Correct Answer'; $csv_fields[] = 'Percentage Received'; $csv_fields[] = 'Comments Received'; $csv_fields[] = 'Time Spent'; $csv_fields[] = 'Submitted On'; $output_handle = ''; $output_filename = 'test_an.csv'; $output_handle = @fopen('php://output', 'w'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Content-Description: File Transfer'); header('Content-type: text/csv'); header('Content-Disposition: attachment; filename=' . $output_filename); header('Expires: 0'); header('Pragma: public'); fputcsv($output_handle, $csv_fields); if ($row !== false && $row->num_rows > 0) { $count = 0; while ($data = $row->fetch_assoc()) { ++$count; $make_sql = "SELECT cfsr.* FROM `" . $student_assign . "` cfsa LEFT JOIN `" . $assign_response . "` cfsr ON cfsa.`id`=cfsr.`response_id` where cfsa.`member_id`=" . $data['member_id'] . " and cfsr.`type`= 'test' "; $qry2 = $mysqli->query($make_sql); $outputrray = array($count); array_push($outputrray, $data['name']); array_push($outputrray, $data['email']); array_push($outputrray, $data['title']); array_push($outputrray, $data['assign_title']); array_push($outputrray, $data['no_of_questions']); array_push($outputrray, $data['no_correct_answers']); array_push($outputrray, $data['percentage'] . "%"); array_push($outputrray, $data['comment']); array_push($outputrray, $data['time_spent']); array_push($outputrray, $data['submitted_on']); fputcsv($output_handle, $outputrray); $new = []; $cnt = 0; array_push($new, ''); array_push($new, 'QUESTIONS NUMBER'); array_push($new, 'QUESTIONS'); array_push($new, 'STUDENT ANSWERS'); array_push($new, 'TEACHER ANSWERS'); fputcsv($output_handle, $new); while ($rows = $qry2->fetch_assoc()) { $ne = []; array_push($ne, ''); array_push($ne, ++$cnt); array_push($ne, strip_tags($rows['questions'])); array_push($ne, $rows['answers_student']); array_push($ne, strip_tags($rows['answers_admin'])); fputcsv($output_handle, $ne); } } } fclose($output_handle); die(); } } } //class ends }//if exist class ends