} $content .= $v['total'] . ','; $content .= $v['grade_rank'] . ','; $content .= $v['up_down'] . "\r\n"; } } $charset = empty($_REQUEST['charset']) ? 'UTF8' : trim($_REQUEST['charset']); $file = ecs_iconv(EC_CHARSET, $charset, $content); header("Content-Disposition: attachment; filename=《" . $prj_name . "》考试成绩汇总.csv"); header("Content-Type: application/unknown"); die($file); } elseif ($_REQUEST['act'] == 'template') { //考试名称 $prj_id = empty($_REQUEST['prj_id']) ? '' : trim($_REQUEST['prj_id']); //考试名称 $prj_name = get_exam_prj_name($prj_id); $subjects = get_subjects($class_code, $prj_id); $content = '您选择的《' . $prj_name . '》还没有进行考试安排!'; if (count($subjects) > 0) { $content = "考试名称,考试名称ID,学号,姓名,"; //学生学号,科目。。。,年级排名,年级进退 foreach ($subjects as $v) { $content .= $v["subject"] . ','; } $content .= "年级排名,年级进退\r\n"; $students = get_students($class_code, 'code'); foreach ($students as $s) { $content .= $prj_name . ',' . $prj_id . ','; //考试名称,考试名称 $content .= $s['code'] . ',' . $s['name'] . ','; //学号,姓名
$arr['class_code'] = $class_code; $grade_ranks_list[] = $arr; } insert_datas($grade_ranks_list); set_params(); $smarty->display('grade_rank_list.htm'); exit; } elseif ($_REQUEST['act'] == 'ajax_save') { $id = !empty($_REQUEST['grank_id']) ? intval($_REQUEST['grank_id']) : 0; $exam_prj = !empty($_REQUEST['exam_prj']) ? intval($_REQUEST['exam_prj']) : 0; $student = !empty($_REQUEST['student_code']) ? trim($_REQUEST['student_code']) : ""; //检查是否重复录入成绩 $sql = "select * from " . $ecs->table("grade_rank") . " where prj_id={$exam_prj} and student_code='{$student}' and class_code='{$class_code}' and grank_id!=" . $id; $oldScore = $db->getRow($sql); if ($oldScore) { make_json_error("学号:“" . $student . "”,在《" . get_exam_prj_name($exam_prj) . "》中的年级排名和年级进退于" . $oldScore["created"] . "已经录入到了系统,录入的年级排名为“" . $oldScore["grade_rank"] . "”,年级进退为“" . $oldScore["up_down"] . "”,请勿重复录入!"); exit; } if ($id == 0) { //insert $sql = "insert into " . $ecs->table("grade_rank") . " (prj_id, class_code, student_code, grade_rank, up_down, created )\r\n\t\tvalues \r\n\t\t\t({$exam_prj},'" . $_SESSION["class_code"] . "',\r\n\t\t\t'" . $student . "','" . $_REQUEST["grade_rank"] . "', '" . $_REQUEST["up_down"] . "',now())"; $db->query($sql); admin_log(addslashes($student), 'add', $sql); make_json_result("添加成功!"); } else { $sql = "update " . $ecs->table("grade_rank") . " set student_code='" . $_REQUEST["student_code"] . "',\r\n\t\t\tprj_id='" . $exam_prj . "',\r\n\t\t\tgrade_rank='" . $_REQUEST["grade_rank"] . "',\r\n\t\t\tup_down='" . $_REQUEST["up_down"] . "'\r\n\t\t\twhere grank_id=" . $id; $db->query($sql); admin_log(addslashes($_REQUEST["student_code"]), 'update', $sql); make_json_result("修改成功!"); } } elseif ($_REQUEST['act'] == 'ajax_delete') {
} // print_r($students);echo '<br>'; foreach ($students as $k => $v) { $content .= $v["student_code"] . "," . $v["student_name"] . ","; $total = 0; foreach ($subjects as $sk => $sv) { $score = intval($v[$sv["subject"]]); $total += $score; $content .= $score . ","; } $content .= $total; $content .= "\r\n"; } $charset = empty($_REQUEST['charset']) ? 'UTF8' : trim($_REQUEST['charset']); $file = ecs_iconv(EC_CHARSET, $charset, $content); header("Content-Disposition: attachment; filename=" . get_exam_prj_name($prj_id) . ".csv"); header("Content-Type: application/unknown"); die($file); } elseif ($_REQUEST['act'] == 'exportbyquery') { $prj_id = empty($_REQUEST['search_prj_id']) ? '' : trim($_REQUEST['search_prj_id']); //学生学号 $exam_subject = empty($_REQUEST['search_exam_subject']) ? '' : trim($_REQUEST['search_exam_subject']); //学生学号 $list = get_scores_by_exam($class_code, $prj_id, $_SESSION["student_code"], $exam_subject, " s.student_code"); $content = "考试名称,考试科目,学号,姓名,考试分数\r\n"; foreach ($list as $k => $v) { $content .= $v["prj_name"] . "," . $v["subject"] . "," . $v["student_code"] . "," . $v["student_name"] . "," . $v["score"] . "\r\n"; } $charset = empty($_REQUEST['charset']) ? 'UTF8' : trim($_REQUEST['charset']); $file = ecs_iconv(EC_CHARSET, $charset, $content); header("Content-Disposition: attachment; filename=score.csv");
$sql = "update " . $ecs->table("exam_prj") . " set name='" . $_REQUEST["name"] . "'\r\n\t\t\twhere prj_id=" . $id; $db->query($sql); admin_log(addslashes($_REQUEST["name"]), 'update', 'exam_prj'); make_json_result("修改“" . $id . "," . $_REQUEST["name"] . "”成功!"); } } elseif ($_REQUEST['act'] == 'ajax_delete') { $id = !empty($_REQUEST['prj_id']) ? intval($_REQUEST['prj_id']) : 0; //如果做了考试安排,则不能删除 $subjects = get_subjects($class_code, $id); if (count($subjects) > 0) { make_json_error("《" . get_exam_prj_name($id) . "》已经做了考试安排,不能直接删除!"); exit; } $sql = "select count(1) from " . $ecs->table("score") . " where prj_id=" . $id; if ($db->getOne($sql)) { make_json_error("《" . get_exam_prj_name($id) . "》已经在成绩录入中已使用,不能直接删除!"); exit; } $sql = "delete from " . $ecs->table("exam_prj") . " where prj_id=" . $id; $db->query($sql); admin_log($_REQUEST["prj_id"], 'delete', 'exam_prj'); make_json_result("删除成功!"); } /** * 返回班级管理员列表数据 * * @access public * @param * * @return void */
/** * 返回班级管理员列表数据 * * @access public * @param * * @return void */ function exam_list() { $result = get_filter(); if ($result === false) { /* 过滤条件 */ $filter['prj_id'] = empty($_REQUEST['search_prj']) ? '' : trim($_REQUEST['search_prj']); //名称 $filter['subject'] = empty($_REQUEST['search_subject']) ? '' : trim($_REQUEST['search_subject']); //科目 if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1) { $filter['name'] = json_str_iconv($filter['name']); } $filter['sort'] = empty($_REQUEST['sort']) ? 'exam_id' : trim($_REQUEST['sort']); $filter['order'] = empty($_REQUEST['order']) ? 'DESC' : trim($_REQUEST['order']); $filter['page'] = empty($_REQUEST['page']) ? '1' : trim($_REQUEST['page']); $filter['page_size'] = empty($_REQUEST['rows']) ? '25' : trim($_REQUEST['rows']); $ex_where = " WHERE class_code='" . $_SESSION["class_code"] . "' "; if ($filter['prj_id']) { $ex_where .= " AND prj_id = '" . mysql_like_quote($filter['prj_id']) . "'"; } if ($filter['subject']) { $ex_where .= " AND subject like '" . mysql_like_quote($filter['subject']) . "%'"; } $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table("exam") . $ex_where; $filter['record_count'] = $GLOBALS['db']->getOne($sql); /* 分页大小 */ $filter = page_and_size($filter); $sql = "SELECT * " . " FROM " . $GLOBALS['ecs']->table("exam") . $ex_where . " ORDER by " . $filter['sort'] . ' ' . $filter['order'] . " LIMIT " . $filter['start'] . ',' . $filter['page_size']; // echo $sql; echo '<br>'; $filter['semster'] = stripslashes($filter['semster']); set_filter($filter, $sql); } else { $sql = $result['sql']; $filter = $result['filter']; } $list = $GLOBALS['db']->getAll($sql); foreach ($list as $key => $val) { $list[$key]['setime'] = $val['stime'] . "-" . $val['etime']; $list[$key]['prj_name'] = get_exam_prj_name($val["prj_id"]); } $arr = array('rows' => $list, 'filter' => $filter, 'page' => $filter['page_count'], 'total' => $filter['record_count']); return $arr; }