480 lines
17 KiB
JavaScript
480 lines
17 KiB
JavaScript
|
|
var webroot = $("#hdWebroot").val();
|
|||
|
|
var rootUrl = webroot + '/exam/examresult/';
|
|||
|
|
var deleteUrl = rootUrl + 'delete';//删除地址
|
|||
|
|
var editexamPage =rootUrl + 'editexampaperPage';//编辑页面地址
|
|||
|
|
$(function () {
|
|||
|
|
//------------------------属性-------------------------------------
|
|||
|
|
var listUrl = rootUrl + 'list';//分页数据地址
|
|||
|
|
var saveUrl = rootUrl + 'save';//保存添加数据地址
|
|||
|
|
var comboxUrl=rootUrl+ 'examResultCombox';//下拉框
|
|||
|
|
var examResultUrl=rootUrl+ 'examResultList';//考试判卷——判卷——List
|
|||
|
|
var examResultImportUrl = rootUrl + 'examResultImport';//导入成绩
|
|||
|
|
var updateAnswerUrl = rootUrl + 'updateAnswer';//系统自动判卷-更新答案
|
|||
|
|
var updateUserScoreUrl = rootUrl + 'updateUserScore';//系统自动判卷-更新用户得分和判卷人
|
|||
|
|
|
|||
|
|
var dialogSize = {width: 800, height: '80%'};//弹出窗口大小
|
|||
|
|
var dialog = $('#dialog');
|
|||
|
|
var grid_form = $('#grid_form');
|
|||
|
|
|
|||
|
|
var grid = $('#grid');
|
|||
|
|
|
|||
|
|
var examId="";//试卷id
|
|||
|
|
var userId="";//工资号
|
|||
|
|
|
|||
|
|
//-----------------------初始化--------------------------------------
|
|||
|
|
initexamsGrid();
|
|||
|
|
// addFilter();
|
|||
|
|
addEvents();
|
|||
|
|
|
|||
|
|
//-------------------------------------方法--------------------------------------------------------
|
|||
|
|
function initexamsGrid() {
|
|||
|
|
//初始化搜索框
|
|||
|
|
$('#searchbox').uiSearchbox({
|
|||
|
|
width: 240,
|
|||
|
|
prompt: '答题人|部门|试卷名称',
|
|||
|
|
searcher: function (v) {
|
|||
|
|
grid.uiGrid('loadData', {queryParams: {key: $.trim(v)}, pageIndex: 1});
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
//初始化grid
|
|||
|
|
grid.uiGrid({
|
|||
|
|
url: listUrl,
|
|||
|
|
defaultSortField: 'user_time'
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
//下拉框
|
|||
|
|
$('#name').uiCombobox({
|
|||
|
|
mode: 'remote',
|
|||
|
|
searchable: true,
|
|||
|
|
delay :500,
|
|||
|
|
hasDownArrow:false,
|
|||
|
|
loader: comboxLoad,
|
|||
|
|
url: comboxUrl,
|
|||
|
|
onSelect: function(record) {
|
|||
|
|
examId = record.id;
|
|||
|
|
grid.uiGrid('loadData', {queryParams:{examId: examId}});
|
|||
|
|
},
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//初始化考试判卷编辑表单
|
|||
|
|
var formeditexamInit = function () {
|
|||
|
|
|
|||
|
|
var eqlist2 = $('#eqlist2');
|
|||
|
|
|
|||
|
|
eqlist2.uiGrid({
|
|||
|
|
autoFit: true,
|
|||
|
|
border: false,
|
|||
|
|
colFit: true,
|
|||
|
|
gridTitleFix: false,
|
|||
|
|
width: "100%",
|
|||
|
|
height: "80%",
|
|||
|
|
showHeader: false,
|
|||
|
|
icon: 'list',
|
|||
|
|
url: examResultUrl,
|
|||
|
|
queryParams: {'userId':userId,
|
|||
|
|
'examId':examId},//从前端获取,向后台传递参数
|
|||
|
|
defaultSortField: 'num'
|
|||
|
|
});
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
//初始化考试判卷弹出窗口
|
|||
|
|
var editexam_dialog = $('#editexam_dialog').uiDialog({
|
|||
|
|
title: '新建',
|
|||
|
|
icon: 'list',
|
|||
|
|
width:"95%",
|
|||
|
|
height:"95%",
|
|||
|
|
mask: true,
|
|||
|
|
showBtnBar: true,
|
|||
|
|
updateOnOpen: true,
|
|||
|
|
lazyLoad: true,
|
|||
|
|
url: editexamPage,
|
|||
|
|
onLoadComplete: formeditexamInit,
|
|||
|
|
onOpen: function () {
|
|||
|
|
var dialogP = $('#editexam_dialog').uiDialog('getUserParam');
|
|||
|
|
var id = dialogP.id;
|
|||
|
|
|
|||
|
|
setTimeout( function(){
|
|||
|
|
setStatistic();
|
|||
|
|
userScore();
|
|||
|
|
},100);
|
|||
|
|
},
|
|||
|
|
onPanelResize: function () {
|
|||
|
|
// setStatistic();//将计算题数和总分的方法放在了组件改变大小时触发,不合理,考虑用SQL语句初始化出来
|
|||
|
|
// userScore();
|
|||
|
|
},
|
|||
|
|
buttons: [
|
|||
|
|
// {
|
|||
|
|
// id: 'btnOK',
|
|||
|
|
// label: '保存',
|
|||
|
|
// style: 'button_submit',
|
|||
|
|
// icons: {left: 'icon_submit'},
|
|||
|
|
// disabled: false,
|
|||
|
|
// onClick: function () {
|
|||
|
|
// editexam_dialog.uiDialog('close');
|
|||
|
|
// }
|
|||
|
|
// },
|
|||
|
|
{
|
|||
|
|
id: 'btnOK',
|
|||
|
|
label: '提交',
|
|||
|
|
style: 'button_submit',
|
|||
|
|
icons: {left: 'icon_submit'},
|
|||
|
|
disabled: false,
|
|||
|
|
onClick: function () {
|
|||
|
|
$.uiMessagebox.confirm({
|
|||
|
|
title: '确认操作',
|
|||
|
|
content: "确定提交批阅的试卷吗?",
|
|||
|
|
onClose: function (value) {
|
|||
|
|
if (value){
|
|||
|
|
// var totalScore = 0;//总分
|
|||
|
|
for (var i=1; i<$('#eqlist2').find('tr').length; i++){
|
|||
|
|
var parent = "";
|
|||
|
|
var user_score="";
|
|||
|
|
var id = "";
|
|||
|
|
var score = "";
|
|||
|
|
parent=$('#eqlist2').find('tr:eq('+i+')');
|
|||
|
|
user_score = parent.find(".user_score").val();
|
|||
|
|
id = parent.find(".qid").html();
|
|||
|
|
// totalScore += Number(user_score);
|
|||
|
|
// score = parent.find("#score").html();
|
|||
|
|
// if(Number(user_score) > Number(score))
|
|||
|
|
// {
|
|||
|
|
// alert("考生得分不应大于该题总分!");
|
|||
|
|
// return;
|
|||
|
|
// }
|
|||
|
|
|
|||
|
|
$.ajax({
|
|||
|
|
type: 'post',
|
|||
|
|
url: saveUrl,
|
|||
|
|
data: {'id':id,
|
|||
|
|
'user_score':user_score},
|
|||
|
|
dataType: "json",
|
|||
|
|
success: function (result) {
|
|||
|
|
if (result.success) {
|
|||
|
|
grid.uiGrid('loadData', {queryParams:{examId: examId}});
|
|||
|
|
}
|
|||
|
|
showResult(result.success, result.message);
|
|||
|
|
$('#editexam_dialog').uiDialog('close');
|
|||
|
|
},
|
|||
|
|
error:function() {
|
|||
|
|
alert("提交批阅试卷失败");
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
id: 'btnCancel',
|
|||
|
|
label: '关闭',
|
|||
|
|
icons: {left: 'icon_cancel'},
|
|||
|
|
disabled: false,
|
|||
|
|
style: 'button_cancel',
|
|||
|
|
onClick: function () {
|
|||
|
|
editexam_dialog.uiDialog('close');
|
|||
|
|
}
|
|||
|
|
}]
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
//初始化导入成绩编辑表单
|
|||
|
|
var formimportInit2 = function () {
|
|||
|
|
$('#fileform').uiForm({
|
|||
|
|
template: 'grid_form_temp2',
|
|||
|
|
onLoadSuccess: function (data) {
|
|||
|
|
$('#btnUpload').bind('click', function () {
|
|||
|
|
$('#fileform').uiForm('submit', {
|
|||
|
|
url: examResultImportUrl,
|
|||
|
|
dataType: "application/json",
|
|||
|
|
onSubmit: function (params) {
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
success: function (result) {
|
|||
|
|
if (result.success) {
|
|||
|
|
$('#examresult_dialog').uiDialog('close');//保存成功后关闭对话框
|
|||
|
|
grid.uiGrid('loadData', {queryParams:{'examId': result.data.exam_id}});
|
|||
|
|
}
|
|||
|
|
showResult(result.success, result.message);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
//初始化弹出窗口——导入成绩
|
|||
|
|
var examresult_dialog = $('#examresult_dialog').uiDialog({
|
|||
|
|
title: '导入',
|
|||
|
|
icon: 'list',
|
|||
|
|
width:"80%",
|
|||
|
|
height:"60%",
|
|||
|
|
mask: true,
|
|||
|
|
showBtnBar: true,
|
|||
|
|
updateOnOpen: true,
|
|||
|
|
lazyLoad: true,
|
|||
|
|
onLoadComplete: formimportInit2,
|
|||
|
|
onOpen: function () {
|
|||
|
|
var dialogP = $('#examresult_dialog').uiDialog('getUserParam');
|
|||
|
|
op = dialogP.action;
|
|||
|
|
var id = dialogP.id;
|
|||
|
|
switch (op) {
|
|||
|
|
case 'view':
|
|||
|
|
case 'edit':
|
|||
|
|
$('#fileform').uiForm('load', grid.uiGrid('selectedData')[0]);
|
|||
|
|
break;
|
|||
|
|
case 'add':
|
|||
|
|
$('#fileform').uiForm('load', {});
|
|||
|
|
break;
|
|||
|
|
default :
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// $('#fileform').uiForm('load');//为组件加载数据
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
function addEvents() {
|
|||
|
|
|
|||
|
|
//考试判卷
|
|||
|
|
$('#btn1').bind('click', function () {
|
|||
|
|
var ids = grid.uiGrid('selectedData', 'id');
|
|||
|
|
userId = ids[0];//此处将工资号作为id
|
|||
|
|
// console.log(AndEdit_id);
|
|||
|
|
if(ids.length == 0){
|
|||
|
|
showResult(false,'请选择要批阅的试卷!','alert');
|
|||
|
|
}
|
|||
|
|
else if(ids.length > 1){
|
|||
|
|
showResult(false,'请选择要批阅的一张试卷,不支持同时选择多张试卷!','alert');
|
|||
|
|
}
|
|||
|
|
else{
|
|||
|
|
editexam_dialog.uiDialog('setUserParam', {action: 'add', id: 0});
|
|||
|
|
editexam_dialog.uiDialog('button', 'btnOK').show();
|
|||
|
|
editexam_dialog.uiDialog('open');
|
|||
|
|
editexam_dialog.uiDialog('title').html('判卷');
|
|||
|
|
// $('#eqlist2').uiGrid('loadData',{queryParams: {AndEdit_id: AndEdit_id}});
|
|||
|
|
|
|||
|
|
$.ajax({
|
|||
|
|
type: 'post',
|
|||
|
|
url: examResultUrl,
|
|||
|
|
data:{'userId':userId,
|
|||
|
|
'examId':examId},
|
|||
|
|
dataType: "json",
|
|||
|
|
success: function (result) { //result是接收后台return的结果
|
|||
|
|
//showResult(result.success, result.message);
|
|||
|
|
|
|||
|
|
if(result.data.rows.length > 0){
|
|||
|
|
var data=result.data.rows[0];
|
|||
|
|
if(data.state === "线下考试"){
|
|||
|
|
alert("线下考试不允许再次判卷!");
|
|||
|
|
editexam_dialog.uiDialog('close');
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
setTimeout(function () {
|
|||
|
|
if(result.data.rows.length > 0){
|
|||
|
|
var data=result.data.rows[0];
|
|||
|
|
$('#title_name').html(data.name);//将后台return的结果显示在前端
|
|||
|
|
$('#title_description').html(data.description);
|
|||
|
|
}
|
|||
|
|
},100);
|
|||
|
|
|
|||
|
|
// $('#eqlist2').uiGrid('loadData',{queryParams: {'userId':userId, 'examId':examId}});
|
|||
|
|
},
|
|||
|
|
error:function() {
|
|||
|
|
alert("考试判卷提交失败");
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
//导入成绩
|
|||
|
|
$('#btn2').bind('click', function () {
|
|||
|
|
examresult_dialog.uiDialog('setUserParam', {action: 'add', id: 0});
|
|||
|
|
examresult_dialog.uiDialog('button', 'btnOK').show();
|
|||
|
|
examresult_dialog.uiDialog('open');
|
|||
|
|
examresult_dialog.uiDialog('title').html('导入');
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
//导出成绩
|
|||
|
|
$('#btn3').bind('click', function () {
|
|||
|
|
var ids = $('#name').uiCombo('getValue');
|
|||
|
|
|
|||
|
|
if (typeof(ids) == "undefined") {
|
|||
|
|
showResult(false, '请选择试卷!', 'alert');
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
var j = ids;
|
|||
|
|
var openurl =webroot+"/ReportServer?reportlet=examResult.cpt"+'&id='+j+"&format=excel";
|
|||
|
|
// var openurl="http://localhost:8075/WebReport/ReportServer?reportlet=exam.cpt&format=excel";
|
|||
|
|
window.open(openurl);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
//自动判卷
|
|||
|
|
$('#btn4').bind('click', function () {
|
|||
|
|
var exam_id = $('#name').uiCombo('getValue');
|
|||
|
|
|
|||
|
|
if (typeof(exam_id) == "undefined") {
|
|||
|
|
showResult(false, '请选择试卷!', 'alert');
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
$.uiMessagebox.confirm({
|
|||
|
|
title: '确认操作',
|
|||
|
|
content: "确定使用客观题系统自动判卷吗?",
|
|||
|
|
onClose: function (value) {
|
|||
|
|
if (value) {
|
|||
|
|
$.ajax({
|
|||
|
|
type: 'post',
|
|||
|
|
url: updateAnswerUrl,
|
|||
|
|
data: {'exam_id':exam_id},
|
|||
|
|
dataType: "json",
|
|||
|
|
success: function (result) {
|
|||
|
|
if(result.success){
|
|||
|
|
$.ajax({
|
|||
|
|
type: 'post',
|
|||
|
|
url: updateUserScoreUrl,
|
|||
|
|
data: {'exam_id':exam_id},
|
|||
|
|
dataType: "json",
|
|||
|
|
success: function () {
|
|||
|
|
$('#grid').uiGrid('loadData');
|
|||
|
|
},
|
|||
|
|
error:function() {
|
|||
|
|
alert("系统自动判卷更新用户得分和判卷人失败");
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
error:function() {
|
|||
|
|
alert("系统自动判卷更新答案失败");
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//选择要批阅的试卷 下拉框
|
|||
|
|
function comboxLoad(param, success, error) {
|
|||
|
|
var opts = $(this).uiCombobox('options');
|
|||
|
|
if (!opts.url) return false;
|
|||
|
|
$.ajax({
|
|||
|
|
type: opts.method,
|
|||
|
|
url: opts.url,
|
|||
|
|
showLoading: false,
|
|||
|
|
data: param,
|
|||
|
|
showAlert:false,
|
|||
|
|
dataType: 'json',
|
|||
|
|
success: function (result) {
|
|||
|
|
if (result.success) {
|
|||
|
|
success(result.data);
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
error: function () {
|
|||
|
|
error.apply(this, arguments);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//arttemplate语法
|
|||
|
|
template.helper('judge', function (data, format) {
|
|||
|
|
if (data!=undefined && data.indexOf(format)!=-1){
|
|||
|
|
return true;
|
|||
|
|
}else {
|
|||
|
|
return false;}
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
//查看
|
|||
|
|
function viewRow(id, title) {
|
|||
|
|
var dialog = $('#dialog');
|
|||
|
|
dialog.uiDialog('setUserParam', {action: 'view', id: id});
|
|||
|
|
dialog.uiDialog('open');
|
|||
|
|
title = '-' + title || '';
|
|||
|
|
dialog.uiDialog('title').html('查看' + title);
|
|||
|
|
dialog.uiDialog('button', 'btnOK').hide();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//编辑
|
|||
|
|
function editRow(id) {
|
|||
|
|
var dialog = $('#dialog');
|
|||
|
|
dialog.uiDialog('setUserParam', {action: 'edit', id: id});
|
|||
|
|
dialog.uiDialog('open');
|
|||
|
|
dialog.uiDialog('title').html('编辑');
|
|||
|
|
dialog.uiDialog('button', 'btnOK').show();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 删除
|
|||
|
|
function deleteRow(id) {
|
|||
|
|
deleteData("此操作将删除试卷,可能会导致以往考试找不到试卷,确定删除吗?", deleteUrl, {ids: id}, function (result) {
|
|||
|
|
if (result.success) {
|
|||
|
|
$('#grid').uiGrid('loadData');
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//删除
|
|||
|
|
function deleteData(confirmText, url, data, callback) {
|
|||
|
|
$.uiMessagebox.confirm({
|
|||
|
|
title: '确认操作',
|
|||
|
|
content: confirmText,
|
|||
|
|
onClose: function (value) {
|
|||
|
|
if (value) {
|
|||
|
|
$.ajax({
|
|||
|
|
type: 'post',
|
|||
|
|
url: url,
|
|||
|
|
data: data,
|
|||
|
|
dataType: "json",
|
|||
|
|
success: function (result) {
|
|||
|
|
callback && callback.call(this, result);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//计算题数和总分
|
|||
|
|
function setStatistic() {
|
|||
|
|
var totalQuestion="";
|
|||
|
|
var totalScore=0;
|
|||
|
|
var score="";
|
|||
|
|
for (var i=1; i<$('#eqlist2').find('tr').length; i++){
|
|||
|
|
var parent="";
|
|||
|
|
parent=$('#eqlist2').find('tr:eq('+i+')');
|
|||
|
|
score=parent.find(".score").html();
|
|||
|
|
totalScore +=Number(score);
|
|||
|
|
}
|
|||
|
|
totalQuestion = $('#eqlist2').find('tr').length - 1;
|
|||
|
|
$('#sum').val(totalQuestion);
|
|||
|
|
$('#sum_score').val(totalScore);
|
|||
|
|
}
|
|||
|
|
//计算考生得分
|
|||
|
|
function userScore() {
|
|||
|
|
var totalScore=0;
|
|||
|
|
var score="";
|
|||
|
|
for (var i=1; i<$('#eqlist2').find('tr').length; i++){
|
|||
|
|
var parent="";
|
|||
|
|
parent=$('#eqlist2').find('tr:eq('+i+')');
|
|||
|
|
parent.find(".user_score").val(parent.find(".user_score").val().replace(/[^0-9]/g,''));
|
|||
|
|
score=parent.find(".user_score").val();
|
|||
|
|
totalScore +=Number(score);
|
|||
|
|
}
|
|||
|
|
$('#user_result').val(totalScore);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function checkSize(ele){
|
|||
|
|
var size_m = (ele.files[0].size / 1024);
|
|||
|
|
if(size_m >= 1024*1024*5){
|
|||
|
|
$('#hidFile').val(1);
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
$('#hidFile').val(0);
|
|||
|
|
return true;
|
|||
|
|
}
|