//选题系统是否关闭
public functiontest_android01(){//'CAN_SELECT'=>0, 1-能选题;0-禁止选题
if( 0 == C('CAN_SELECT')){echo '系统处于关闭状态';
}else{$this->test_android();
}
}//Android端查看全部没有被选的题目
public functiontest_android(){$myModel = new\Think\Model();$result=$myModel->query("select id,exp_name,tname,exp_tech
from g_experiment,g_teacher
where (g_experiment.sno = '' or sno is null)
&& g_experiment.exp_tno = g_teacher.tno;");echo json_encode($result);
}//Android端查看我的选题
public functiontest_check(){$sno = I('sno');$Experiment = M("Experiment");
$exp_tno = $Experiment -> where("sno = '".$sno."'") -> getField('exp_tno');
$RowCount = $Experiment -> where("sno = '".$sno."'") -> Count();if($RowCount == 1){$myModel = new\Think\Model();$result=$myModel->query("select *from g_experiment,g_teacher where sno = $sno && tno = $exp_tno ;");$this ->ajaxReturn($result);
}else{echo '你还没有选题';
}
}//修改信息
public functiontest_reset(){$sno = I('sno');$Student = M("Student");
$RowCount = $Student -> where("sno = '".$sno."'") -> Count();if($RowCount == 1){$myModel = new\Think\Model();$result=$myModel->query("select *from g_student where sno = $sno;");$this ->ajaxReturn($result);
}
}//退选功能
public functiontest_reselect(){if( 0 == C('CAN_SELECT')){echo '系统处于关闭状态';
}else{$id= I('id');$Experiment = M("Experiment");$data['sno'] = '';$Experiment -> where("id = '".$id."'") -> save($data);echo '退选成功';
}
}//修改密码
public functiontest_repassword(){$sno = I('sno');$old_passwd = md5(I('old_passwd'));$new_passed1 = md5(I('new_passed1'));$new_passed2 = md5(I('new_passed2'));$Student = M('Student');$data['passwd'] = $new_passed1;$condition['sno'] = $sno;$RowCount = $Student->where($condition)->Count();if($RowCount == 1){$Student->where("sno = '".$sno."'")->save($data);echo '您的密码已经成功修改。';
}else{echo '老师端密码修改失败';
}
}/*选题功能
思想:拿到题号查询学号是否为空,若为空则证明该题未选否则显示该题已经选过了
为空的情况下拿着学号查询题号是否为空,若为空则证明该学生尚未选题可进行选题
否则需要退选之后选题。*/
public functiontest_select(){$Experiment = M("Experiment");$id= I('id');$sno = I('sno');//通过id查找学号
$exp_sno = $Experiment -> where("id = '".$id."'") -> getField('sno');if($exp_sno != ''){echo '该题已经被选';
}else{//通过学号查找id
$exp_id = $Experiment -> where("sno = '".$sno."'") -> getField('id');if($exp_id != null){echo '需要退选之后才能选题';
}else if($sno != ''){$data['sno'] = $sno;$Experiment -> where("id = '".$id."'") -> save($data);echo '选题成功';
}
}
}//搜索功能
public functiontest_search(){$Experiment = M("Experiment");$Teacher = M("Teacher");$tname = I('tname');
$exp_tno = $Teacher -> where("tname = '".$tname."'") -> getField('tno');
$myModel = new\Think\Model();$result=$myModel->query("select id,exp_name,istate from g_experiment where exp_tno = $exp_tno;");echo json_encode($result);
}//完善信息
public functiontest_message(){$sno = I('sno');
$cellphone = I('cellphone');$email = I('email');$qq = I('qq');$Student = M("Student");$data['cellphone'] = $cellphone;$data['email'] = $email;$data['qq'] = $qq;$Student -> where("sno = '".$sno."'") -> save($data);echo '完善信息成功';
}//模糊搜索功能
public functiontest_search02(){if(0 == C('CAN_SELECT')){echo '系统处于关闭状态';
}else{$Experiment = M("Experiment");$Teacher = M("Teacher");$tname = I('exp_tname');$exp_tno = $Teacher -> where("tname = '".$tname."'") -> getField('tno');$myModel = new\Think\Model();$result=$myModel->query("select id,exp_name,tname
from g_experiment,g_teacher
where (exp_name LIKE '%$tname%' OR exp_tno = '$exp_tno') AND g_experiment.exp_tno = g_teacher.tno;");echo json_encode($result);
}
}