Ejemplo n.º 1
0
 /**
  * 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('选课申请提交失败');
         }
     }
 }
Ejemplo n.º 2
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);
 }
Ejemplo n.º 3
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('评学成功');
 }
Ejemplo n.º 4
0
 /**
  * 保存所选课程
  * @author FuRongxin
  * @date 2016-06-29
  * @version 2.1.1
  * @param  \Illuminate\Http\Request  $request 保存请求
  * @return \Illuminate\Http\Response 选课列表
  */
 public function store(Request $request)
 {
     if ('pubsport' == $request->input('type')) {
         if (config('constants.status.disable') == Setting::find('XK_GT')->value) {
             abort(403, '现在未开放公体选课,不允许公体选课');
         }
     } elseif (config('constants.status.disable') == Setting::find('XK_KG')->value) {
         abort(403, '现在未开放选课,不允许选课');
     }
     if (Unpaid::whereXh(Auth::user()->xh)->exists()) {
         abort(403, '请交清费用再进行选课');
     }
     if ('pubsport' != $request->input('type')) {
         if (config('constants.status.enable') == Setting::find('XK_SJXZ')->value) {
             $profile = Profile::whereXh(Auth::user()->xh)->select('nj', 'xz')->firstOrFail();
             // 未在时间限制表中配置,默认不允许选课
             $now = Carbon::now();
             $exists = Lmttime::whereNj($profile->nj)->whereXz($profile->xz)->where('kssj', '<', $now)->where('jssj', '>', $now)->exists();
             if (!$exists) {
                 abort(403, '现在未到选课时间,不允许选课');
             }
         }
     }
     if ($request->isMethod('post')) {
         $this->validate($request, ['kcxh' => 'required|alpha_num|size:12']);
         $inputs = $request->all();
         if (in_array($inputs['type'], array_keys(config('constants.course.general')))) {
             if (config('constants.stauts.disable') == Setting::find('XK_TS')->value) {
                 abort(403, '现在未开放通识素质课选课,不允许选课');
             }
             if (config('constants.status.enable') == Setting::find('XK_TSXZ')->value) {
                 $profile = Profile::whereXh(Auth::user()->xh)->select('nj', 'xz')->firstOrFail();
                 // 未在时间限制表中配置,默认不允许选通识素质课
                 $now = Carbon::now();
                 $limit = Lmtgeneral::whereNj($profile->nj)->whereXz($profile->xz)->where('kssj', '<', $now)->where('jssj', '>', $now)->orderBy('kssj', 'desc')->first();
                 if (!$limit) {
                     abort(403, '现在未到通识素质课选课时间,不允许选课');
                 }
                 $limit_course = $limit->ms;
                 $limit_ratio = 0 < $limit->bl ? $limit->bl / 100 : $limit->bl;
             }
         } else {
             $limit_ratio = 1;
         }
         $course = Mjcourse::ofType($inputs['type'])->whereNd(session('year'))->whereXq(session('term'))->whereZsjj(session('season'))->whereKcxh($inputs['kcxh'])->firstOrFail();
         $ms = isset($limit_course) ? $limit_course : -1;
         $rs = isset($limit_ratio) ? $limit_ratio * $course->rs : -1;
         $limits = $this->checkcourse($inputs['type'], $course->kcxh, $course->zy, $ms, $rs);
         if ($limits['ms']) {
             $request->session()->flash('forbidden', '通识素质课选课门数已达上限' . $ms . '门,请选其他课程');
             return back()->withInput();
         }
         if ($limits['rs']) {
             $request->session()->flash('forbidden', '选课人数已满,请选其他课程');
             return back()->withInput();
         }
         if (Prior::failed(Helper::getCno($course->kcxh), Auth::user())->exists()) {
             $request->session()->flash('forbidden', '前修课未修读');
             return back()->withInput();
         }
         $selcourse = new Selcourse();
         $selcourse->xh = Auth::user()->xh;
         $selcourse->xm = Auth::user()->profile->xm;
         $selcourse->nd = $course->nd;
         $selcourse->xq = $course->xq;
         $selcourse->kcxh = $inputs['kcxh'];
         $selcourse->kch = Helper::getCno($inputs['kcxh']);
         $selcourse->pt = $course->pt;
         $selcourse->xz = $course->xz;
         $selcourse->xl = $course->xl;
         $selcourse->jsgh = $course->task->jsgh;
         $selcourse->xf = $course->plan->zxf;
         $selcourse->sf = config('constants.status.enable');
         $selcourse->zg = $course->bz;
         $selcourse->cx = config('constants.status.disable');
         $selcourse->bz = config('constants.status.disable');
         $selcourse->sj = Carbon::now();
         $selcourse->kkxy = $course->kkxy;
         $selcourse->qz = 0;
         $selcourse->tdkch = '';
         $selcourse->tdyy = '';
         $selcourse->zy = $course->zy;
         if ($selcourse->save()) {
             return redirect()->route('selcourse.show', $inputs['type'])->withStatus('选课成功');
         } else {
             return back()->withInput()->withStatus('选课失败');
         }
     }
 }
Ejemplo n.º 5
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'));
 }