public function get(Request $request)
 {
     $messages = Messages::select(['users.avatar', 'users.nickname', 'users.id as user_id', 'messages.message', 'messages.created_at'])->leftJoin('users', 'messages.user_id', '=', 'users.id')->orderBy('messages.id', 'DESC')->limit(30)->get()->toArray();
     foreach ($messages as $key => $msg) {
         $messages[$key]['created_at'] = Helper::getGoodDate($msg['created_at']);
     }
     $this->user->last_seen = Carbon::now()->toDateTimeString();
     $this->user->save();
     return response()->json(array_reverse($messages));
 }
Exemple #2
0
 public static function boot()
 {
     parent::boot();
     static::created(function ($course) {
         // 2016-09-01:应教务处要求添加公体选课统计,修改选课统计方式
         if ($isPubSport = Helper::isCourseType($course->kcxh, 'TB14')) {
             $count = Count::whereKcxh($course->kcxh)->first();
         } else {
             $count = Count::whereKcxh($course->kcxh)->whereZy($course->zy)->first();
         }
         if (count($count)) {
             $count->rs += 1;
         } else {
             $count = new Count();
             $count->kcxh = $course->kcxh;
             $count->zy = $isPubSport ? '' : $course->zy;
             $count->rs = 1;
         }
         $count->save();
         $log = new Slog();
         $log->kcxh = $course->kcxh;
         $log->ip = request()->ip();
         $log->czlx = 'insert';
         $log->save();
     });
     static::deleted(function ($course) {
         // 2016-09-01:应教务处要求添加公体选课统计,修改选课统计方式
         if ($isPubSport = Helper::isCourseType($course->kcxh, 'TB14')) {
             $count = Count::whereKcxh($course->kcxh)->first();
         } else {
             $count = Count::whereKcxh($course->kcxh)->whereZy($course->zy)->first();
         }
         if (count($count)) {
             $count->rs -= 1;
         } else {
             $count = new Count();
             $count->kcxh = $course->kcxh;
             $count->zy = $isPubSport ? '' : $course->zy;
             $count->rs = 0;
         }
         $count->save();
         $log = new Slog();
         $log->kcxh = $course->kcxh;
         $log->ip = request()->ip();
         $log->czlx = 'delete';
         $log->save();
     });
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     if ($request->isMethod('post')) {
         $this->validate($request, ['type' => 'required', 'kcxh' => 'required|size:12']);
         $inputs = $request->all();
         $course = Mjcourse::whereNd(session('year'))->whereXq(session('term'))->whereKcxh($inputs['kcxh'])->whereZsjj(session('season'))->firstOrFail();
         $application = new Application();
         $application->xh = Auth::user()->xh;
         $application->xm = Auth::user()->profile->xm;
         $application->nd = $course->nd;
         $application->xq = $course->xq;
         $application->kcxh = $course->kcxh;
         $application->kch = Helper::getCno($course->kcxh);
         $application->pt = $course->pt;
         $application->xz = $course->xz;
         $application->kkxy = $course->kkxy;
         $application->xf = $course->plan->zxf;
         $application->sf = '0';
         $application->sh = '0';
         $application->xksj = Carbon::now();
         switch ($inputs['type']) {
             case 'other':
                 $application->xklx = '0';
                 break;
             case 'retake':
                 $application->xklx = '1';
                 $application->ynd = $inputs['ynd'];
                 $application->yxq = $inputs['yxq'];
                 $application->ykcxh = $inputs['ykcxh'];
                 $application->yxf = $inputs['yxf'];
                 break;
             default:
                 $application->xklx = '0';
                 break;
         }
         if ($application->save()) {
             return redirect('application')->withStatus('课程申请成功');
         } else {
             return back()->withInput()->withStatus('选课申请提交失败');
         }
     }
 }
Exemple #4
0
 /**
  * 显示评教结果
  * @author FuRongxin
  * @date    2016-03-30
  * @version 2.0
  * @param   \Illuminate\Http\Request  $request 评教结果请求
  * @param   string $kcxh 12位课程序号
  * @return  \Illuminate\Http\Response 评教结果
  */
 public function show(Request $request, $kcxh)
 {
     $inputs = $request->all();
     $table = $inputs['year'] . $inputs['term'] . 't';
     $mark = $inputs['year'] . $inputs['term'] . 'Mark';
     // 获取评教分值
     $data = DB::connection('pgset')->selectOne('SELECT AVG(s_jxtd) AS jxtd, AVG(s_jxnr) AS jxnr, AVG(s_jxff) AS jxff, AVG(s_jxxg) AS jxxg, AVG(s_zhpf) As zhpf FROM "' . $table . '" WHERE c_kcxh = ? and c_jsgh = ? GROUP BY c_kcbh, c_jsgh', [$kcxh, Auth::user()->jsgh]);
     $scores = [];
     if (count($data)) {
         $scores = ['1' => sprintf('%.2f', $data->jxtd), '2' => sprintf('%.2f', $data->jxnr), '3' => sprintf('%.2f', $data->jxff), '4' => sprintf('%.2f', $data->jxxg), 'zhpf' => sprintf('%.2f', $data->zhpf)];
         $categories = DB::connection('pgset')->select('SELECT a.zb_id, a.zb_mc, COUNT(*) AS total FROM t_zb_yjzb a, t_zb_ejzb b WHERE a.zb_id = b.zb_id GROUP BY a.zb_id, a.zb_mc ORDER BY a.zb_id');
         foreach ($categories as $category) {
             $items = DB::connection('pgset')->select('SELECT ejzb_id, ejzb_mc, AVG(s_mark) AS mark FROM "' . $mark . '", t_zb_ejzb WHERE c_xm = CAST(ejzb_id AS TEXT) AND zb_id = ? AND c_kcxh = ? AND c_jsgh = ? GROUP BY ejzb_id, ejzb_mc, c_kcbh, c_jsgh, c_xm ORDER BY ejzb_id', [$category->zb_id, $kcxh, Auth::user()->jsgh]);
             $scores['zb'][$category->zb_id] = ['zb_mc' => $category->zb_mc, 'total' => $category->total];
             foreach ($items as $item) {
                 $scores['zb'][$category->zb_id]['ejzb'][] = ['ejzb_id' => $item->ejzb_id, 'ejzb_mc' => $item->ejzb_mc, 'score' => sprintf('%.2f', $item->mark)];
             }
         }
     }
     // 获取评教评语
     $comments = DB::connection('pgset')->select('SELECT c_yd, c_qd, c_one, c_xh FROM t_zl_xspy a INNER JOIN "' . $table . '" b ON a.c_kcxh = b.c_kcxh WHERE a.c_nd = ? AND a.c_xq = ? AND b.c_jsgh = ? AND b.c_kcxh = ?', [$inputs['year'], $inputs['term'], Auth::user()->jsgh, $kcxh]);
     $title = $inputs['year'] . '年度' . Term::find($inputs['term'])->mc . '学期' . $kcxh . Course::find(Helper::getCno($kcxh))->kcmc . '课程';
     return view('set.show')->withTitle($title . '评教结果')->withScores($scores)->withComments($comments);
 }
Exemple #5
0
 /**
  * 学生考试报名
  * @author FuRongxin
  * @date    2016-02-22
  * @version 2.0
  * @param   \Illuminate\Http\Request $request 报名请求
  * @param   string $kslx 考试类型代码
  * @return  \Illuminate\Http\Response 报名列表
  */
 public function update(Request $request, $kslx)
 {
     $exam = Extype::find($kslx);
     $registered = Exregister::whereNd($exam->nd)->whereXh(Auth::user()->xh)->whereKslx($kslx)->exists();
     // 检测是否已经报过名
     if (!$registered) {
         // 检测是否CET4
         if (in_array($exam->kslx, Helper::getCet4())) {
             // 检测是否允许新生报考CET4
             if (config('constants.status.enable') == Setting::find('KS_CET4_XS')) {
                 // 不允许新生报考CET4
                 if (Profile::isFresh(Auth::user())->exists()) {
                     abort(403, '不允许新生报考CET4');
                 }
             }
         }
         // 检测是否CET6
         if (config('constants.exam.type.cet6') == $exam->kslx) {
             // 检测是否允许新生报考CET6
             if (config('constants.status.enable') == Setting::find('KS_CET6_XS')) {
                 // 不允许新生报考CET6
                 if (Profile::isFresh(Auth::user())->exists()) {
                     abort(403, '不允许新生报考CET6');
                 }
             }
             // 检测CET6是否具有过往成绩或者CET4是否及格
             if (!Exscore::whereC_xh(Auth::user()->xh)->whereC_kslx(config('constants.exam.type.cet6'))->exists() && !Exscore::isPassed(Auth::user(), Helper::getCet4())->exists()) {
                 abort(403, '四级成绩不达标,不能参加CET6考试');
             }
         }
         // 检测是否已经报过CET考试
         if (config('constants.exam.type.cet') == $exam->ksdl) {
             $registered = Exregister::with('type')->whereNd($exam->nd)->whereXh(Auth::user()->xh);
             foreach ($registered as $cet) {
                 if (config('constants.exam.type.cet') == $cet->type->ksdl) {
                     abort(403, '已经报名本次' . $cet . '考试,' . $cet . '和' . $exam->ksmc . '不能同时报名');
                 }
             }
         }
     }
     $register = new Exregister();
     $register->xh = Auth::user()->xh;
     $register->xq = Auth::user()->profile->college->pivot->xq;
     $register->kslx = $kslx;
     $register->bklb = '00';
     $register->kssj = $exam->sj;
     $register->clbz = config('constants.exam.status.register');
     $register->bmsj = date('Y-m-d H:i:s');
     $register->nd = $exam->nd;
     $register->save();
     return redirect('exam')->withStatus('考试报名成功,请交费!');
 }
Exemple #6
0
 /**
  * 录入评学结果
  * @author FuRongxin
  * @date    2016-03-30
  * @version 2.0
  * @param   \Illuminate\Http\Request  $request 评学结果请求
  * @param   string $kcxh 12位课程序号
  * @return  \Illuminate\Http\Response 评学结果
  */
 public function update(Request $request, $kcxh)
 {
     $inputs = $request->all();
     $this->validate($request, ['score.*.fz' => 'required|numeric|min:0|max:10']);
     $course = Mjcourse::whereNd(session('year'))->whereXq(session('term'))->whereKcxh($kcxh)->firstOrFail();
     foreach ($inputs['score'] as $id => $score) {
         $result = new Tesresult();
         $result->jsgh = Auth::user()->jsgh;
         $result->kcxh = $kcxh;
         $result->kch = Helper::getCno($kcxh);
         $result->pjbz_id = $id;
         $result->kkxy = $course->kkxy;
         $result->zy = $course->zy;
         $result->nj = $course->nj;
         $result->nd = $course->nd;
         $result->xq = $course->xq;
         $result->fz = $score['fz'];
         $result->save();
     }
     return redirect()->route('tes.show', ['kcxh' => $kcxh, 'year' => $course->nd, 'term' => $course->xq])->withStatus('评学成功');
 }
Exemple #7
0
 /**
  * 选课门数和人数限制检测
  * 2016-06-16:添加专业号检测
  * 2016-09-01:应教务处要求添加公体选课统计,修改选课统计方式
  * @author FuRongxin
  * @date    2016-09-01
  * @version 2.1.2
  * @param   string $type 课程类型
  * @param   string $kcxh 12位课程序号
  * @param   string $zy 专业号
  * @param   integer $ms 课程门数限制,-1为无限制
  * @param   integer $rs 选课人数限制,-1为无限制
  * @return  array 课程门数和人数限制标志数组,true为超限,false为未超限
  */
 public function checkcourse($type, $kcxh, $zy, $ms = -1, $rs = -1)
 {
     $limits = ['ms' => false, 'rs' => false];
     if (in_array($type, array_keys(config('constants.course.general')))) {
         if (-1 < $ms) {
             $count = Selcourse::ofType($type)->whereNd(session('year'))->whereXq(session('term'))->whereXh(Auth::user()->xh)->count();
             if ($count >= $ms) {
                 $limits['ms'] = true;
             }
         }
         if (-1 < $rs) {
             $course = Count::whereKcxh($kcxh)->whereZy($zy)->first();
             $count = isset($course) ? $course->rs : 0;
             if ($count >= $rs) {
                 $limits['rs'] = true;
             }
         }
     } else {
         // 2016-09-01:应教务处要求添加公体选课统计,修改选课统计方式
         if (Helper::isCourseType($kcxh, config('constants.course.pubsport.type'))) {
             $course = Count::whereKcxh($kcxh)->first();
         } else {
             $course = Count::whereKcxh($kcxh)->whereZy($zy)->first();
         }
         $count = isset($course) ? $course->rs : 0;
         if ($count >= $rs) {
             $limits['rs'] = true;
         }
     }
     return request()->ajax() ? response()->json($limits) : $limits;
 }
Exemple #8
0
 /**
  * 查询听课列表
  * @author FuRongxin
  * @date    2016-05-17
  * @version 2.1
  * @param   \Illuminate\Http\Request $request 听课查询请求
  * @return  \Illuminate\Http\Response 听课列表
  */
 public function search(Request $request)
 {
     $departments = Department::where('dw', '<>', '')->whereLx('1')->whereZt(config('constants.status.enable'))->orderBy('dw')->get();
     $title = session('year') . '年度' . Term::find(session('term'))->mc . '学期' . '听课查询';
     $courses = [];
     if ($request->isMethod('post')) {
         $this->validate($request, ['department' => 'required', 'week' => 'required', 'class' => 'required']);
         $input = $request->all();
         $query = Timetable::with(['classroom' => function ($query) {
             $query->select('jsh', 'mc');
         }, 'user' => function ($query) {
             $query->select('jsgh', 'xm', 'zc');
         }, 'user.position', 'campus'])->whereNd(session('year'))->whereXq(session('term'))->whereZc($input['week'])->where('ksj', '<=', $input['class'])->where('jsj', '>=', $input['class']);
         $kcxhs = Mjcourse::whereNd(session('year'))->whereXq(session('term'))->whereKkxy($input['department'])->select('kcxh')->distinct()->get()->pluck('kcxh');
         $query = $query->whereIn('kcxh', $kcxhs);
         $results = $query->get();
         foreach ($results as $result) {
             $courses[] = ['kcmc' => Course::find(Helper::getCno($result->kcxh))->kcmc, 'xqh' => $result->campus->mc, 'jsmc' => count($result->classroom) ? $result->classroom->mc : '', 'kkxy' => count($result->mjcourse) ? $result->mjcourse->college->mc : '', 'xy' => count($result->mjcourse) ? $result->mjcourse->major->college->mc : '', 'zy' => count($result->mjcourse) ? $result->mjcourse->major->mc : '', 'nj' => count($result->mjcourse) ? $result->mjcourse->nj : '', 'rs' => Selcourse::whereNd(session('year'))->whereXq(session('term'))->whereKcxh($result->kcxh)->count(), 'jsxm' => $result->user->xm, 'jszc' => $result->user->position->mc];
         }
         $department_name = 'all' == $input['department'] ? '所有学院' : Department::find($input['department'])->mc;
         $week_name = 'all' == $input['week'] ? '所有周次' : '星期' . config('constants.week.' . $input['week']);
         $class_name = '第 ' . $input['class'] . ' 节课';
         $subtitle = '查询条件:' . $department_name . $week_name . $class_name;
     }
     return view('timetable.search', compact('title', 'departments', 'courses', 'subtitle'));
 }