public function testSetRoomScheduleCourse()
 {
     $roomsched = new RoomSchedule();
     $course = new Course();
     $course->setCourseCode("IT 197");
     $roomsched->setCourseCode($course->getCourseCode());
     $this->assertEquals("IT 197", $course->getCourseCode());
     $this->assertEquals("IT 197", $roomsched->getCourseCode());
 }
Exemplo n.º 2
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CourseRequest $request)
 {
     $data = $request->all();
     unset($data['Id']);
     $course = new Course();
     $course->fromArray($data);
     $course->save();
     flash()->success("ADDED");
     session(['attribute' => \Lang::get('general.COURSE')]);
     return redirect($this->main_page);
 }
Exemplo n.º 3
0
 public function testSetCourse()
 {
     $course = new Course();
     $course->setCourseCode("IT 197");
     $course->setDescription("Supervised On-the-Job Training");
     $course->setUnits(12);
     $course->setSemester("2nd");
     $this->assertEquals("IT 197", $course->getCourseCode());
     if ($course->getCourseCode() == "IT 197") {
         $this->assertEquals("Supervised On-the-Job Training", $course->getDescription());
         $this->assertEquals(12, $course->getUnits());
         $this->assertEquals("2nd", $course->getSemester());
     }
 }
Exemplo n.º 4
0
 /**
  * Show the form for creating a new resource.
  *
  * @param $courseId
  * @return \Illuminate\Http\Response
  */
 public function create($courseId)
 {
     $userId = Auth::user()->id;
     $tests = Test::where('user_id', '=', $userId)->get();
     $course = Course::find($courseId);
     return view('course.lesson.create', ['course' => $course, 'tests' => $tests]);
 }
Exemplo n.º 5
0
 /**
  * @param $courseId
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function show($courseId)
 {
     $course = Course::findOrFail($courseId);
     $lessons = $course->lessons;
     $members = $course->users;
     return view('mark.show', ['members' => $members, 'lessons' => $lessons, 'course' => $course]);
 }
Exemplo n.º 6
0
 /**
  * Creates a new Task model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $course_id = Yii::$app->request->get('course_id');
     $model = new Task();
     if ($model->load(Yii::$app->request->post())) {
         $model = $model->validateAttr($model);
         if (empty($model->errors)) {
             $resourceModel = new Resource();
             $model = $resourceModel->uploadImg($model, 'image');
             if ($model->save()) {
                 return $this->redirect(['view', 'id' => $model->id]);
             }
         }
     }
     $model->course_id = $course_id;
     if (!json_decode($model->answer_json)) {
         $model->answer_json = '';
     }
     $chapterName = $courseName = null;
     if (!empty($course_id)) {
         $chapterName = Course::findModel($course_id)->name;
         $courseName = Course::findRoot($course_id)->name;
     }
     return $this->render('create', ['model' => $model, 'courseId' => $course_id, 'chapterName' => $chapterName, 'courseName' => $courseName]);
 }
 public function getInstitute()
 {
     if ($this->course_id != NULL) {
         $institute_id = Course::find()->select(['institute_id'])->where(['id' => $this->course_id])->one()->institute_id;
         $institute = Institute::findOne(['id' => $institute_id]);
         return $institute;
     }
 }
Exemplo n.º 8
0
 protected function findModel($id)
 {
     if (($model = Course::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 9
0
 public function postCreate(Request $request)
 {
     $input = $request->only(['year', 'name']);
     $input['user_id'] = Auth::id();
     Course::create($input);
     flash()->success('Kurz bol vytvorený');
     return redirect()->back();
 }
Exemplo n.º 10
0
 public function detachFrom(Request $request)
 {
     $this->validate($request, ['classroom_id' => 'required', 'course_id' => 'required'], ['required' => 'Kolom :attribute diperlukan']);
     $course = Course::findOrFail($request->course_id);
     $course->classrooms()->detach($request->classroom_id);
     \Flash::success('Materi berhasil batalkan.');
     return redirect()->back();
 }
Exemplo n.º 11
0
 /**
  * get User Courses
  * @param type $userId
  * @return type
  */
 public static function getUserCourses($userId = null)
 {
     if (empty($userId)) {
         $userId = \app\components\OvcUser::getCurrentUser()->id;
     }
     $userCourseIds = self::getCourseIdsByUserId($userId);
     return Course::findAll(['id' => $userCourseIds]);
 }
Exemplo n.º 12
0
 public function actionDelete($id)
 {
     $item = Course::findByPK($id);
     if (empty($item)) {
         $this->redirect('/admin/courses');
     }
     $item->delete();
     $this->redirect('/admin/courses');
 }
Exemplo n.º 13
0
 public static function courseDropDown()
 {
     $courses = Course::find()->all();
     //$courses = Course::courseDropDown();
     //$courseList = ArrayHelper::map($courses, 'id', 'courseName');
     foreach ((array) $courses as $course) {
         echo "<option value='" . $course->id . "'>" . $course->courseName . "</option>";
     }
 }
Exemplo n.º 14
0
 public static function getQuestionList($courseId)
 {
     $courseModel = Course::findOneById($courseId);
     if (Course::isRoot($courseModel)) {
         return static::find()->where(['root_id' => $courseId])->orderBy('create_time DESC')->all();
     }
     if (Course::isFile($courseModel)) {
         return static::find()->where(['course_id' => $courseId])->orderBy('create_time DESC')->all();
     }
 }
Exemplo n.º 15
0
 /**
  * 显示学生详细成绩单
  * @author FuRongxin
  * @date    2016-01-25
  * @version 2.0
  * @param   string $kch 8位课程号
  * @return  \Illuminate\Http\Response 学生成绩单
  */
 public function show($kch)
 {
     // 过程成绩
     $detail = Dtscore::detailScore(Auth::user(), $kch)->select('xh', 'xm', 'kcxh', 'kcpt', 'kcxz', 'nd', 'xq', 'kh', 'cj1', 'cj2', 'cj3', 'cj4', 'cj5', 'cj6', 'zpcj', 'kszt', 'tjzt');
     // 补考成绩
     $makeup = Muscore::makeupScore(Auth::user(), $kch)->select('xh', 'xm', 'kcxh', 'kcpt', 'kcxz', 'nd', 'xq', 'kh', 'cj1', 'cj2', 'cj3', 'cj4', 'cj5', 'cj6', 'zpcj', 'kszt', 'tjzt');
     $scores = $detail->union($makeup)->orderBy('nd', 'desc')->orderBy('xq', 'desc')->get();
     $ratios = $this->_arrangeScores($scores);
     return view('score.show')->withTitle(Course::find($kch)->kcmc . '课程详细成绩单')->withRatios($ratios);
 }
Exemplo n.º 16
0
 public static function commentList($courseId)
 {
     $courseModel = Course::findModel($courseId);
     if (Course::isFile($courseModel)) {
         return static::find()->where(['course_id' => $courseId, 'comment_type' => self::COMMENT_TYPE_COMMENT])->orderBy('comment_time DESC')->all();
     }
     if (Course::isRoot($courseModel)) {
         return static::find()->where(['root_id' => $courseId, 'comment_type' => self::COMMENT_TYPE_COMMENT])->orderBy('comment_time DESC')->all();
     }
 }
Exemplo n.º 17
0
 public function actionCertification()
 {
     //$searchModel = new CourseSearch();
     //$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     //$dataProvider->pagination->pageSize = 0;
     $query = Course::find()->where(['category_id' => '5']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $cat = new Category();
     return $this->render('mos', ['dataProvider' => $dataProvider, 'cat' => $cat]);
     //return $this->render('mos');
 }
Exemplo n.º 18
0
 public function actionDefault($course = null)
 {
     if (null === $course) {
         $this->data->course = 'all';
         $this->data->courses = Course::findAll();
     } else {
         $this->data->course = Course::findByPK($course);
         $this->data->item = new Lesson();
         $this->data->item->course = $this->data->course;
     }
 }
Exemplo n.º 19
0
 public static function getLearnPercent($userId, $courseId)
 {
     $fileCount = Course::fileCount($courseId);
     $userPlayModels = static::findAll(['user_id' => $userId, 'learn_status' => self::LEARN_STATUS_FINISH]);
     $count = 0;
     foreach ($userPlayModels as $userPlayModel) {
         if (Course::findOneById($userPlayModel->chapter_id)->root == $courseId) {
             $count++;
         }
     }
     return round($count / $fileCount, 2);
 }
Exemplo n.º 20
0
 public function addOperation()
 {
     if ($this->currency_id != '1') {
         $course = new Course();
         if (!$course->checkCourse($this->currency_id)) {
             $course->currency_id = $this->currency_id;
             $currency = Currency::findOne($this->currency_id);
             $course->course = $course->getCourse($currency->iso);
             if (!$course->save()) {
                 throw new ErrorException('Курс не обновлен' . var_dump($course));
             }
         }
     }
     $operation = new Operation();
     $operation->user_id = Yii::$app->getUser()->id;
     $operation->category_id = $this->category_id === '' ? 1 : $this->category_id;
     $operation->currency_id = $this->currency_id === '' ? 1 : $this->currency_id;
     $operation->summ = $this->operation_type == 'income' ? $this->summ * 100 : $this->summ * -100;
     $operation->description = $this->description;
     return $operation->save() ? $operation : null;
 }
Exemplo n.º 21
0
 /**
  * @GET("/profile", as="profile.index")
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function index()
 {
     $profile = $this->profile->profileWithUser();
     $courses_raw = Course::with('currency')->get();
     $courses = $courses_raw->filter(function ($value) {
         return $value->id != 11;
     });
     if (!$profile->wallet) {
         \Session::flash('message', 'Пожалуйста, укажите Elcoin кошелек и полностью заполните профиль, если у Вас нет кошелька,
         зарегистрируйтесь в системе Elephant: https://elcoin.space');
     }
     return view('profile.profile', compact('profile', 'courses'));
 }
Exemplo n.º 22
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Course::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Yii::$app->params['pageSize']]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'modified_at' => $this->modified_at]);
     $query->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
Exemplo n.º 23
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Course::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'name' => $this->name, 'leerlijn_id' => $this->leerlijn_id]);
     $query->andFilterWhere(['like', 'tud_id', $this->tud_id]);
     return $dataProvider;
 }
Exemplo n.º 24
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Course::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['category_id' => $this->category_id, 'price' => $this->price, 'created_dt' => $this->created_dt]);
     $query->andFilterWhere(['like', 'course_id', $this->course_id])->andFilterWhere(['like', 'course_name', $this->course_name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'course_detail', $this->course_detail])->andFilterWhere(['like', 'duration', $this->duration])->andFilterWhere(['like', 'f_jan', $this->f_jan])->andFilterWhere(['like', 'f_feb', $this->f_feb])->andFilterWhere(['like', 'f_mar', $this->f_mar])->andFilterWhere(['like', 'f_apr', $this->f_apr])->andFilterWhere(['like', 'f_may', $this->f_may])->andFilterWhere(['like', 'f_jun', $this->f_jun])->andFilterWhere(['like', 'f_july', $this->f_july])->andFilterWhere(['like', 'f_aug', $this->f_aug])->andFilterWhere(['like', 'f_sep', $this->f_sep])->andFilterWhere(['like', 'f_oct', $this->f_oct])->andFilterWhere(['like', 'f_nov', $this->f_nov])->andFilterWhere(['like', 'f_dec', $this->f_dec])->andFilterWhere(['like', 'level', $this->level])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'photo', $this->photo]);
     return $dataProvider;
 }
Exemplo n.º 25
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Course::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->joinWith('crsCt');
     $query->andFilterWhere(['crs_id' => $this->crs_id, 'crs_duration' => $this->crs_duration, 'crs_days' => $this->crs_days, 'crs_wkly_hrs' => $this->crs_wkly_hrs, 'crs_active' => $this->crs_active]);
     $query->andFilterWhere(['like', 'crs_desc', $this->crs_desc])->andFilterWhere(['like', 'crs_drtn_type', $this->crs_drtn_type])->andFilterWhere(['like', 'crs_disp_id', $this->crs_disp_id])->andFilterWhere(['like', 'course_type.ct_desc', $this->crs_ct_id]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Course::find();
     $query->joinWith(['institute']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->attributes['institute'] = ['asc' => ['institute.name' => SORT_ASC], 'desc' => ['institute.name' => SORT_DESC]];
     if (!($this->load($params) && $this->validate())) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'institute_id' => $this->institute_id]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     $query->andFilterWhere(['like', 'institute.name', $this->institute]);
     return $dataProvider;
 }
Exemplo n.º 27
0
 public function actionRegister($co = null, $cl = null)
 {
     $model = new Student();
     if ($model->load(Yii::$app->request->post())) {
         $model->course_id = $co;
         $model->classid = $cl;
         $model->created_dt = date('Y-m-d H:i:s');
         $model->save();
         return $this->redirect(['success']);
         //return $this->redirect(['view', 'id' => $model->id]);
     } else {
         if (!empty($co)) {
             $courselist = Course::findOne($co);
         }
         return $this->render('register', ['model' => $model, 'courselist' => $courselist]);
     }
 }
Exemplo n.º 28
0
 /**
  * Deletes an existing CourseType model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     try {
         //	$this->findModel($id)->delete();
         $ct = $this->findModel($id);
         //$crs = $ct->courses;
         //$cls = $ct->clsses;
         $crs_count = Course::find()->where(['crs_ct_id' => $id])->count();
         $cls_count = Clss::find()->where(['clss_ct_id' => $id])->count();
         Yii::$app->session->setFlash('message', "You cannot delete this record!");
         if ($crs_count == 0 && $cls_count == 0) {
             $ct->delete();
             //	Yii::$app->session->setFlash('success','The car was successfully deleted');
             //		foreach (Yii::$app->session->getAllFlashes() as $key => $message) {
             echo '<div class="alert alert-success">' . 'The car was successfully deleted' . '</div>';
             //	}
         } else {
             //header("HTTP/1.0 400 Relation Restriction");
             Yii::$app->session->setFlash('message', "You cannot delete this record!");
         }
     } catch (CDbException $e) {
         if ($e->errorInfo[1] == 1451) {
             header("HTTP/1.0 400 Relation Restriction");
             echo "Your error message.\n";
         } else {
             throw $e;
         }
         // 		} catch (IntegrityException $e) {
         //   	if($e->getCode()===23000){
         //You can have nother error handling
         //        		header("HTTP/1.0 400 Relation Restriction");
         // 	}else{
         //		throw $e;
         //}
     }
     return $this->redirect(['index']);
 }
Exemplo n.º 29
0
 /**
  * @POST("/purchase", as="purchase.store")
  * @param Purchase $purchase
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(Purchase $purchase, Request $request)
 {
     $data = $request->all();
     if ((int) $data['amount'] <= 0) {
         return redirect()->route('profile.index')->with('message', 'Некорректная сумма вклада!');
     }
     $type1 = TypePurchase::where('id', 1)->first();
     $type2 = TypePurchase::where('id', 2)->first();
     $type3 = TypePurchase::where('id', 3)->first();
     $user = User::where('id', $request->input('user_id'))->first();
     $course = Course::where('currency_id', $request->input('currency_id'))->first();
     $data['course'] = $course->course_purchase;
     if ($request->input('status_trust') === 'true') {
         $data['status_trust'] = 1;
         $purchase->fill($data);
         $purchase->type()->associate($type2);
         $purchase->user()->associate($user);
         $purchase->course()->associate($course);
         $purchase->save();
     } elseif (!$request->input('total')) {
         $data['total'] = $request->input('amount');
         $purchase->fill($data);
         $purchase->type()->associate($type3);
         $purchase->user()->associate($user);
         $purchase->course()->associate($course);
         $purchase->save();
     } else {
         $purchase->fill($data);
         $purchase->type()->associate($type1);
         $purchase->user()->associate($user);
         $purchase->course()->associate($course);
         $purchase->save();
     }
     return redirect()->route('profile.index')->with('message', 'Заявка сделана! Свои оперции Вы можете
     посмотреть в разделе "Мои операции"');
 }
Exemplo n.º 30
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);
 }