<?php use kartik\tree\TreeView; use app\models\Course; use yii\helpers\html; $this->title = Yii::t('app', 'Course Manage'); echo TreeView::widget([ // single query fetch to render the tree // use the Product model you have in the previous step 'query' => Course::find()->addOrderBy('root, lft'), 'headingOptions' => ['label' => Yii::t('app', 'Contents')], 'fontAwesome' => false, // optional 'isAdmin' => true, // optional (toggle to enable admin mode) 'displayValue' => 1, // initial display value 'softDelete' => true, // defaults to true 'cacheSettings' => [ 'enableCache' => true // defaults to true ] ]);
/** * 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]); }
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; } }
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>"; } }
/** * 显示学生详细成绩单 * @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); }
/** * Displays a single Course model. * @param integer $id * @return mixed */ public function actionView() { $courseID = $_GET['id']; $id = \Yii::$app->user->identity->id; $model = Course::find()->innerJoin("person_course_role", 'course.id = person_course_role.course_id')->where(["person_course_role.person_id" => $id])->andWhere(["person_course_role.role_id" => CourseRoleHelper::EMPLOYEE])->andWhere(["course.id" => $courseID])->one(); if (!$model) { throw new ForbiddenHttpException("You have no access to this course"); } return $this->render('view', ['model' => $model]); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $course = Course::find($id); if ($course) { $message = 'Success.'; return Response()->json(ResponseManager::getResult($course, 10, $message)); } else { $message = 'Something went wrong. Please try again.'; return Response()->json(ResponseManager::getError('', 10, $message)); } }
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'); }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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']); }
/** * 显示评教结果 * @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); }
/** * get unassigned course */ public function actionGetUnassignedCourse() { $userId = Yii::$app->request->post('user_id'); $userCourseIds = \app\components\OvcCourse::getUserCourseIds($userId); $items = \app\models\Course::find()->select(['CONCAT(code," ( ", name," )") as name', 'id'])->where(['not in', 'id', $userCourseIds])->indexBy('id')->column(); $items = array_merge(['' => 'Select Course'], $items); echo \yii\helpers\Html::dropDownList('UserHasCourse[course_id]', null, $items, ['id' => 'userhascourse-course_id', 'class' => 'form-control']); }
/** * 查询听课列表 * @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')); }
/** * Join a member to couser * * @param $id * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function join($id) { $course = Course::find($id); $course->members()->attach(Auth::user()->id); return redirect(route('courses')); }
/** * Remove the specified Course from storage. * * @param int $id * @return Response */ public function destroy($id) { $course = Course::find($id); $course->delete(); Flash::success('Course deleted successfully.'); return redirect('/admin/course'); }
<?php echo $form->field($model, 'date')->widget(DatePicker::className(), ['clientOptions' => ['defaultDate' => 'getdate()'], 'dateFormat' => 'dd-MM-yyyy', 'options' => ['style' => 'width:250px;', 'class' => 'form-control']]); ?> <!-- "Given you have selected a course_id, you can retrieve a list of modules via the course_module table. Then given you select a module_id from this list then you can retrieve a list of students taking that module via the student_module table" --> <!-- http://www.dukaweb.net/2015/04/dependent-dropdown-list-from-scratch-in-yii2.html <!-- https://www.youtube.com/watch?v=ZepxKw8VA7w --> <!-- How to change field to Course Name? As id is pulling from attendance model --> <!-- DEPENDENT DROP DOWN WORKING BUT WHEN YOU SELECT FROM MODULE, ALL DROP DOWNS UPDATES TO THE MODULE NAME!! --> <?php echo $form->field($model, 'id')->dropDownList(ArrayHelper::map(Course::find()->all(), 'id', 'courseName'), ['prompt' => 'Select Course', 'name' => 'id', 'onchange' => ' $.post( "index.php?r=coursemodule/modules&id=' . '"+$(this).val(), function( data ) { $( "select#myCustomId" ).html( data ); });']); // This prints attendance/create - was hoping to print array // Tried $_POST but nothing prints /*$ids = $_GET; foreach($ids as $id){ echo $id; } */ ?> <!-- Creating custom id form input field in inputOptions Pass in class to make drop down same width. https://github.com/yiisoft/yii2/issues/7627 -->
/** * Search in Course the Subjects * * @param id * @return Response with subjects */ public function getSubjects($id) { $courses = Course::find($id)->subjects; $subjects = []; foreach ($courses as $id => $course) { $subjects[] = ["id" => $course->id, "name" => $course->name]; } return response()->json($subjects); }
<div class="block-time-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'institute')->dropdownList(institute::find()->select(['name', 'id'])->indexBy('id')->column(), ['prompt' => 'Select Institute', 'onchange' => '$.post( "index.php?r=institute/courses&id=" +$(this).val(), function( data ) { $( "select#blocktime-course_id" ).html( data ); });']); ?> <? if($model->institute != null){ echo $form->field($model,'course_id')->dropdownList( Course::find()->where(['institute_id'=>$model->institute->id])->select(['name','id'])->indexBy('id')->column(), [ 'prompt' => 'Select Courses', ]); } else{ echo $form->field($model,'course_id')->dropdownList( [], [ 'prompt' => 'Select Courses', ]); } ?> <label class="control-label" for="blocktime-starttime">Starttime</label>
/* @var $this yii\web\View */ /* @var $model app\models\UserHasCourse */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="user-has-course-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'user_id')->dropdownList(User::find()->select(['CONCAT(first_name," ",last_name, " ( ", username," )") as name', 'id'])->indexBy('id')->column(), ['prompt' => 'Select User']); ?> <?php echo $form->field($model, 'course_id')->dropdownList(Course::find()->select(['CONCAT(code," ( ", name," )") as name', 'id'])->indexBy('id')->column(), ['prompt' => 'Select Course']); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div> <script> var user_has_course_form_url = '<?php
/** * Returns all courses this person has a role to. * * @return \yii\db\ActiveQuery Person */ public function getCoursesForRole($role) { return Course::find()->innerJoin("person_course_role", 'course.id = person_course_role.course_id')->where(["person_course_role.person_id" => $this->getId()])->andWhere(["person_course_role.role_id" => $role])->all(); }
public static function getCoursesList() { $courses = Course::find()->all(); return ArrayHelper::map($courses, 'id', 'tud_id'); }
/** * * Shows the course picking page * @param $model * @return string */ private function _pickCourse($model) { // TODO: only show courses the student is following or has recently followed $models = Course::find()->all(); return $this->render('pickCourse', ['model' => $model, 'models' => $models]); }
use yii\widgets\ActiveForm; use yii\helpers\ArrayHelper; use app\models\Course; /* @var $this yii\web\View */ /* @var $model app\models\Classroom */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="classroom-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'course_id')->dropDownList(ArrayHelper::map(Course::find()->all(), 'course_id', 'course_name'), ['prompt' => 'เลือกคอร์ส']); ?> <?php echo $form->field($model, 'opendate')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'recive')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'place')->textInput(['maxlength' => true]); ?> <?php
?> <?php echo $form->field($model, 'num_pages')->textInput(); ?> <?php echo $form->field($model, 'paper_type')->textInput(); ?> <?php echo $form->field($model, 'num_plates')->textInput(); ?> <?php echo $form->field($model, 'course_id')->dropDownList(ArrayHelper::map(Course::find()->all(), 'id', 'title'), ['prompt' => 'เลือกหลักสูตร']); ?> <?php echo $form->field($model, 'num_series')->textInput(); ?> <?php echo $form->field($model, 'personnel_id')->dropDownList(ArrayHelper::map(Personnel::find()->all(), 'id', 'full_name'), ['prompt' => 'เลือกบุคลากร']); ?> <?php echo $form->field($model, 'total_pages')->textInput(); ?> <?php
/* @var $this yii\web\View */ /* @var $model app\models\Video */ /* @var $form yii\widgets\ActiveForm */ /** * user course id; */ $courseIds = \app\components\OvcCourse::getUserCourseIds(); ?> <div class="video-form"> <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?> <?php echo $form->field($model, 'course_id')->dropdownList(Course::find()->select(['name', 'id'])->where(['id' => $courseIds])->indexBy('id')->column(), ['prompt' => 'Select Course']); ?> <?php echo $form->field($model, 'title')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'description')->widget(TinyMce::className(), ['options' => ['rows' => 6], 'clientOptions' => ['menubar' => 'false']]); ?> <?php echo $form->field($model, 'path')->fileInput(); ?>
/** * 显示录入评学界面 * @author FuRongxin * @date 2016-03-30 * @version 2.0 * @param string $kcxh 12位课程序号 * @return \Illuminate\Http\Response 评学录入界面 */ public function edit($kcxh) { $items = Tesitem::with(['results' => function ($query) use($kcxh) { $query->whereNd(session('year'))->whereXq(session('term'))->whereKcxh($kcxh)->whereJsgh(Auth::user()->jsgh); }, 'category'])->whereZt(config('constants.status.enable'))->orderBy('px')->get(); if (count($items->first()->results)) { return redirect()->route('tes.show', ['kcxh' => $kcxh, 'year' => session('year'), 'term' => session('term')])->withStatus($kcxh . '课程评学数据已录入'); } else { $title = session('year') . '年度' . Term::find(session('term'))->mc . '学期' . $kcxh . Course::find(Helper::getCno($kcxh))->kcmc . '课程'; return view('tes.edit')->withTitle($title . '评学录入')->withItems($items)->withKcxh($kcxh); } }