Пример #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('选课申请提交失败');
         }
     }
 }
Пример #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 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('评学成功');
 }
Пример #3
0
 /**
  * 显示可录入成绩学生名单
  * @author FuRongxin
  * @date    2016-03-19
  * @version 2.0
  * @param  	string $kcxh 12位课程序号
  * @return  \Illuminate\Http\Response 学生名单
  */
 public function edit($kcxh)
 {
     $course = Mjcourse::whereNd(session('year'))->whereXq(session('term'))->whereKcxh($kcxh)->firstOrFail();
     $task = Task::whereKcxh($kcxh)->whereNd(session('year'))->whereXq(session('term'))->whereJsgh(Auth::user()->jsgh)->firstOrFail();
     $ratios = [];
     $items = Ratio::whereFs($task->cjfs)->orderBy('id')->get();
     foreach ($items as $ratio) {
         $ratios[] = ['id' => $ratio->id, 'name' => $ratio->idm, 'value' => $ratio->bl];
     }
     $exists = Score::whereNd(session('year'))->whereXq(session('term'))->whereKcxh($course->kcxh)->whereTjzt(config('constants.score.uncommitted'))->exists();
     $statuses = Status::orderBy('dm')->get()->filter(function ($status) {
         return config('constants.score.deferral') != $status->dm && config('constants.score.retake') != $status->dm;
     });
     $noScoreStudents = Selcourse::whereNd(session('year'))->whereXq(session('term'))->whereKcxh($kcxh)->whereNotExists(function ($query) {
         $query->from('cj_web')->whereRaw('t_cj_web.nd = t_xk_xkxx.nd AND t_cj_web.xq = t_xk_xkxx.xq AND t_cj_web.kcxh = t_xk_xkxx.kcxh AND t_cj_web.xh = t_xk_xkxx.xh');
     })->get();
     if (count($noScoreStudents)) {
         foreach ($noScoreStudents as $student) {
             $score = new Score();
             $score->xh = $student->xh;
             $score->xm = $student->xm;
             $score->kcxh = $student->kcxh;
             $score->kcpt = $student->pt;
             $score->kcxz = $student->xz;
             $score->xl = $student->xl;
             $score->nd = $student->nd;
             $score->xq = $student->xq;
             $score->kh = $course->plan->kh;
             $score->zpcj = 0;
             $score->kszt = 0;
             // 考试状态:正常
             $score->zy = $student->zy;
             $score->tjzt = 0;
             // 提交状态:未提交
             $score->kkxy = $student->kkxy;
             for ($i = 1; $i <= 6; ++$i) {
                 $score->{'cj' . $i} = 0;
             }
             $score->save();
         }
     }
     $scoreNoStudents = Score::whereNd(session('year'))->whereXq(session('term'))->whereKcxh($kcxh)->whereNotExists(function ($query) {
         $query->from('xk_xkxx')->whereRaw('t_xk_xkxx.nd = t_cj_web.nd AND t_xk_xkxx.xq = t_cj_web.xq AND t_xk_xkxx.kcxh = t_cj_web.kcxh AND t_xk_xkxx.xh = t_cj_web.xh');
     })->select('nd', 'xq', 'xh', 'kcxh')->get();
     if (count($scoreNoStudents)) {
         foreach ($scoreNoStudents as $student) {
             $student->delete();
         }
     }
     $students = Score::with('status')->wherend(session('year'))->whereXq(session('term'))->whereKcxh($kcxh)->orderBy('xh')->get();
     $title = $course->college->mc . $course->nd . '年度' . $course->term->mc . '学期' . $course->kcxh . $course->plan->course->kcmc . '课程';
     return view('score.edit')->withTitle($title . '成绩录入')->withRatios($ratios)->withStudents($students)->withCourse($course)->withExists($exists)->withStatuses($statuses);
 }
Пример #4
0
 /**
  * 显示专业课程信息列表
  * @author FuRongxin
  * @date    2016-01-29
  * @version 2.0
  * @return  \Illuminate\Http\Response 专业课程信息
  */
 public function major()
 {
     $courses = Mjcourse::whereNd(session('year'))->whereXq(session('term'))->whereNj(Auth::user()->profile->nj)->whereZy(Auth::user()->profile->zy)->get();
     return view('course.major')->withTitle('本学期专业课程表')->withCourses($courses);
 }
Пример #5
0
 /**
  * 按校区列出可选课程
  * 2016-05-12:应教务处要求,添加公体选课类别名称
  * 2016-09-01:应教务处要求,添加公体选课人数
  * @author FuRongxin
  * @date    2016-09-01
  * @version 2.1.2
  * @param   string $type 课程类型
  * @param   string $campus 校区号
  * @return  JSON 可选课程列表
  */
 public function listing($type, $campus)
 {
     $courses = Mjcourse::ofType($type)->selectable($campus)->get();
     $datatable = Datatables::of($courses)->addColumn('action', function ($course) use($type) {
         $same = Selcourse::whereXh(Auth::user()->xh)->whereNd(session('year'))->whereXq(session('term'))->whereKch($course->kch)->where('kcxh', '<>', $course->kcxh)->exists();
         $exists = Selcourse::whereXh(Auth::user()->xh)->whereNd(session('year'))->whereXq(session('term'))->whereKcxh($course->kcxh)->exists();
         if ($exists) {
             return '<form name="deleteForm" action="' . route('selcourse.destroy', $course->kcxh) . '" method="post" role="form" data-id="' . $course->kcxh . '" data-name="' . $course->kcmc . '">' . method_field('delete') . csrf_field() . '<button type="submit" class="btn btn-danger">退课</button></form>';
         } elseif ($same) {
             return '<div class="text-danger">已选同号课程</div>';
         } elseif (Prior::failed($course->kch, Auth::user())->exists()) {
             return '<div class="text-danger">前修课未修读</div>';
         } elseif ($course->rs >= $course->zrs) {
             return '<div class="text-danger">人数已满</div>';
         } else {
             return '<form name="createForm" action="' . route('selcourse.store') . '" method="post" role="form" data-id="' . $course->kcxh . '" data-name="' . $course->kcmc . '">' . csrf_field() . '<button type="submit" class="btn btn-primary">选课</button><input type="hidden" name="kcxh" value="' . $course->kcxh . '"><input type="hidden" name="type" value="' . $type . '"></form>';
         }
     })->editColumn('kcmc', function ($course) use($type) {
         // 列出公体项目名称
         if ('pubsport' == $type) {
             $sport = Pubsport::whereNd(session('year'))->whereXq(session('term'))->whereKcxh($course->kcxh)->first();
             if (is_object($sport)) {
                 return $course->kcmc . '-' . $sport->xm;
             }
         }
         return $course->kcmc;
     })->editColumn('rs', function ($course) use($type) {
         // 显示公体已选人数
         if ('pubsport' == $type) {
             $count = Count::whereKcxh($course->kcxh)->first();
             if (is_object($count)) {
                 return $count->rs;
             }
         }
         return $course->rs;
     });
     for ($i = 1; $i <= 7; ++$i) {
         $datatable = $datatable->addColumn($this->_weeks[$i], function ($course) use($i) {
             $info = '';
             foreach (array_keys(explode(',', $course->zcs), $i) as $pos) {
                 $ksz = array_get(explode(',', $course->kszs), $pos);
                 $jsz = array_get(explode(',', $course->jszs), $pos);
                 $ksj = array_get(explode(',', $course->ksjs), $pos);
                 $jsj = array_get(explode(',', $course->jsjs), $pos);
                 $jsxm = array_get(explode(',', $course->jsxms), $pos);
                 $info .= '<p><div>第 ';
                 $info .= $ksz === $jsz ? $ksz : $ksz . ' ~ ' . $jsz;
                 $info .= ' 周</div><div class="text-danger">第 ';
                 $info .= $ksj === $jsj ? $ksj : $ksj . ' ~ ' . $jsj;
                 $info .= ' 节</div><div class="text-info">';
                 $info .= empty($jsxm) ? '未知老师' : $jsxm;
                 $info .= '</div></p>';
             }
             return $info;
         });
     }
     return $datatable->make(true);
 }
Пример #6
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'));
 }