10月20日,北京【人工智能】源创会火热报名中,点击报名收获 AI 训练指南
Watch Star Fork

XiaoSK / DB2PHPGPL-2.0

加入码云
与超过 300 万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
DB2 是 2013-2014 学年春季学期数据库实验。
一键复制 编辑 Web IDE 原始数据 按行查看 历史
teacher.php 9.04 KB
XiaoSK 提交于 2014-05-28 14:53 . Release
<?
require 'ctrl/conn.php';
if($_SESSION['class'] != '2') {
require 'logout.php';
exit();
}
?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>教师平台 - 上海大学选课系统</title>
<script type="text/javascript" src="static/jquery.min.js"></script>
<script type="text/javascript">
function msg(w, m){
var notify = window.webkitNotifications.createNotification('static/' + w + '.png', '提示信息', m);
//设置定时撤销机制,防止通知长时间显示不被关闭
notify.ondisplay = function(event) {
setTimeout(function() {
event.currentTarget.cancel();
}, 4444);
};
//下面是定义点击事件,类似地还可定义其它事件
notify.onclick = function() {
window.focus();
this.cancel();
};
//弹出
notify.show();
}
</script>
<link rel="stylesheet" href="static/pure-min.css" />
<link rel="stylesheet" href="static/mainframe.css" />
</head>
<body>
<div class="container">
<div class="header">
<?
$st = $dbc->prepare("SELECT xm FROM teacher WHERE gh=?");
$st->bindValue(1, $_SESSION['id']);
$st->execute();
$xm = $st->fetchAll();
echo $_SESSION['id'].' '.$xm[0][0];
?> | <a href="logout.php">安全退出</a>
</div>
<div class="func">
<a href="?func=schedule">教学安排</a>
<a href="?func=stulist">学生名单</a>
<a href="?func=inputmarks">成绩录入</a>
<a href="?func=lookgrade">成绩查看</a>
</div>
<div class="main">
<?
if(isset($_GET['func'])) {
if($_GET['func'] == 'schedule') { // 上课时间表
?>
<table class="pure-table pure-table-bordered">
<thead>
<tr>
<th>#</th>
<th>课程号</th>
<th>课程名</th>
<th>上课地点</th>
<th>上课时间</th>
</tr>
</thead>
<tbody>
<?//课程号 课程名 上课地点 上课时间
$st = $dbc->prepare("SELECT kh,km,room,time FROM courseteach where gh=?");
$st->bindValue(1, $_SESSION['id']);
$st->execute();
$data = $st->fetchAll();
$num = 1;
foreach($data as &$peo)
{
echo "<tr>";
echo "<td>".$num."</td>";
for($i=0;$i<4;$i++)
echo "<td>".$peo[$i]."</td>";
echo "</tr>";
$num ++;
}
?>
</tbody>
</table>
<?
} else if($_GET['func'] == 'stulist') { // 学生名单
$st = $dbc->prepare("SELECT km,id FROM courseteach WHERE gh=?");
$st->bindValue(1, $_SESSION['id']);
$st->execute();
$all_kc = $st->fetchAll();
?>
<form class="pure-form pure-form-aligned">
<fieldset>
<div class="pure-g">
<div class="pure-u-1-2 pure-u-med-1-3">
<label for="kc0">选择课程:</label>
<select id="kc0" class="pure-input-1-2">
<? foreach($all_kc as &$km){echo "<option>".$km[0]."</option>";}?>
</select>
<button type="button" class="pure-button pure-button-primary" onclick="viewstudent();">查看名单</button>
</div>
</div>
</fieldset>
</form>
<script type="text/javascript">
function viewstudent() {
$.ajax({
type : "post",
url : "ctrl/class_student.php",
data : {
"kc": $("#kc0").val()
},
async : false,
success : function(data){
$("#class_student tr").remove();
$("#class_student").append(data);
}
});
}
</script>
<table class="pure-table pure-table-bordered">
<thead>
<tr>
<th>#</th>
<th>学号</th>
<th>姓名</th>
</tr>
</thead>
<tbody id="class_student">
</tbody>
</table>
<?
} else if($_GET['func'] == 'inputmarks') { // 成绩录入(核心功能)
$st = $dbc->prepare("SELECT km,id FROM courseteach WHERE gh=?");
$st->bindValue(1, $_SESSION['id']);
$st->execute();
$all_kc = $st->fetchAll();
?>
<script type="text/javascript">
function view(v) {
$.ajax({
type : "post",
url : "ctrl/markin.php",
data : {
"cid": v
},
async : false,
success : function(data){
if (data == 'fail') {
msg("e","设置失败!");
} else {
$("#hid").val(v);
$("#pe").val(data);
$("#p0").show();
}
}
});
}
function set(perc, cid) {
$.ajax({
type : "post",
url : "ctrl/markin.php",
data : {
"p": perc,
"i": cid
},
async : false,
success : function(data){
if (data == 'ok') {
msg("i","设置成功!");
} else {
msg("e", "设置失败!");
}
}
});
}
function ins(a) {
$.ajax({
type : "post",
url : "ctrl/markin.php",
data : {
"ii": a
},
async : false,
success : function(data){
if (data == 'fail') {
msg("i","操作失败!");
} else {
var lst = JSON.parse(data);
//console.log(lst);
$("#cj tr").remove();
for (var i = 0; i<lst.length;i++){
var ls = "<tr><td>",sp="</td><td>";
ls+= ( (i+1) + sp);
for (var j = 0;j<2;j++){
ls += (lst[i][j]+sp);
}
ls+= "<input type='text' name='cj[]'>";
ls+= "<input type='hidden' name='xh[]' value='"+lst[i][0]+"'></td></tr>";
$("#cj").append(ls);
}
$("#hidn").val(a);
$("#p1").show();
}
}
});
}
function go() {
$.ajax({
type : "post",
url : "ctrl/gradeinput.php",
data : $("form#p1").serialize(),
async : false,
success : function(data){
console.log(data);
if (data == 'ok') {
msg("i","设置成功!");
} else {
msg("e", "设置失败!");
}
}
});
}
</script>
<form class="pure-form pure-form-aligned">
<fieldset>
<label for="kc">选择课程:</label>
<select id="kc">
<? foreach($all_kc as &$km){echo "<option value='".$km[1]."'>".$km[0]."</option>";}?>
</select>
<button type="button" class="pure-button pure-button-primary" onclick="view($('#kc').val());">设置成绩比例</button>
<button type="button" class="pure-button pure-button-primary" onclick="ins($('#kc').val());">录入成绩</button>
</fieldset>
</form>
<form class="pure-form" id="p0" style="display:none;">
<fieldset>
<legend>设置平时成绩比例(默认为0.3)</legend>
<input type="text" name="pe" placeholder="如0.3" id="pe" value>
<input type="hidden" id="hid" value>
<button type="button" class="pure-button pure-button-primary" onclick="set($('#pe').val(),$('#hid').val());">设置</button>
</fieldset>
</form>
<form class="pure-form" id="p1" style="display:none;text-align:center;">
<fieldset>
<legend>录入成绩</legend><input type="hidden" id="hidn" name="hidn" value>
<input type="radio" name="cat" value="0" checked> 平时成绩 
<input type="radio" name="cat" value="1" > 考试成绩
<table class="pure-table pure-table-bordered" style="margin:20px auto;">
<thead>
<tr>
<th>#</th>
<th>学号</th>
<th>姓名</th>
<th>成绩</th>
</tr>
</thead>
<tbody id="cj">
</tbody>
</table>
<button type="button" class="pure-button pure-button-primary" onclick="go();">提交</button>
</fieldset>
</form>
<?
} else if($_GET['func'] == 'lookgrade') { // 成绩查看
$st = $dbc->prepare("SELECT km,id FROM courseteach WHERE gh=?");
$st->bindValue(1, $_SESSION['id']);
$st->execute();
$all_kc = $st->fetchAll();
?>
<form class="pure-form pure-form-aligned">
<fieldset>
<div class="pure-g">
<div class="pure-u-1-2 pure-u-med-1-3">
<label for="kc">选择课程:</label>
<select id="kc" class="pure-input-1-2">
<? foreach($all_kc as &$km){echo "<option>".$km[0]."</option>";}?>
</select>
<button type="button" class="pure-button pure-button-primary" onclick="view();">查看</button>
</div>
</div>
</fieldset>
</form>
<script type="text/javascript" src="static/highcharts.js"></script>
<script type="text/javascript" src="static/exporting.js"></script>
<script type="text/javascript">
function view() {
$.ajax({
type : "post",
url : "ctrl/gradeAnalyse.php",
data : {
"kc": $("#kc").val()
},
async : false,
success : function(piedata){
$('#chart_pie').highcharts({
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: true
},
title: {
text: '成绩分布图'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
format: '<b>{point.name}</b>: {point.percentage:.1f} %'
}
}
},
series: [{
type: 'pie',
name: '成绩分布图',
data: eval( '(' + piedata + ')' )
}]
});
$("text:last").hide();
}
});
}
</script>
<div id="chart_pie"></div>
<?
}
} else { // 未进行功能选择,暂时显示本学期选课时间等信息
$st = $dbc->prepare("select v from admin where k=? limit 1");
$st->bindValue(1, 'xk2');
if($st->execute()) {
$rs = $st->fetchAll();
$rs = $rs[0][0];
$t1 = substr($rs, 13, 4).'-'.substr($rs, 17,2).'-'.substr($rs, 19,2).' '.substr($rs, 21,2).':'.substr($rs, 23);
}
$st->bindValue(1, 'markin');
if($st->execute()) {
$rs = $st->fetchAll();
$rs = $rs[0][0];
$t2 = substr($rs, 0, 4).'-'.substr($rs, 4,2).'-'.substr($rs, 6,2).' '.substr($rs, 8,2).':'.substr($rs, 10);
}
?>
<div class="terminfo">
<h1>尊敬的 <?=$xm[0][0]?> 老师,您辛苦了!</h1>
<h3>选课结束时间:<?=$t1?></h3>
<h3>成绩录入截止:<?=$t2?></h3>
<h3>请务必在成绩录入截止时间前完成录入。</h3>
<h3>如遇使用问题请联系:66133370</h3>
</div>
<?
}
?>
</div>
</div>
</body>
</html>

评论 ( 0 )

你可以在登录后,发表评论

搜索帮助