示例#1
0
 public function save_info(StudentRequest $request)
 {
     $mark = new Mark();
     $mark->student_id = $request->student_id;
     $mark->disp_id = $request->disp_id;
     $mark->value_1 = $request->value_1;
     $mark->value_2 = $request->value_2;
     $mark->value_3 = $request->value_3;
     $mark->save();
     return back();
 }
示例#2
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Mark();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Mark'])) {
         $model->attributes = $_POST['Mark'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function store()
 {
     $rules = array('code' => 'required|min:3|numeric', 'name' => 'required', 'range_initial' => 'required|min:8', 'range_final' => 'required|min:8');
     $validator = Validator::make(Input::all(), $rules);
     // process the login
     if ($validator->fails()) {
         return Redirect::to('admin/mark/create')->withErrors($validator)->withInput();
     } else {
         // store
         $mark = new Mark();
         $mark->code = Input::get('code');
         $mark->name = Input::get('name');
         $mark->product_range_initial = Input::get('range_initial');
         $mark->product_range_final = Input::get('range_final');
         $mark->save();
         // redirect
         Session::flash('message', 'Successfully created mark!');
         return Redirect::to('admin/mark');
     }
 }
示例#4
0
 public function actionMark()
 {
     if (Yii::app()->request->isAjaxRequest && !Yii::app()->user->isGuest) {
         if (!isset($_GET['id'])) {
             throw new CHttpException(404, 'Страница не найденa');
         } else {
             $site_id = $_GET['id'];
             $site = Site::model()->findByPk($site_id);
             if ($site == null) {
                 throw new CHttpException(404, 'Страница не найденa');
             } else {
                 $mark = Mark::model()->find('site_id = :site_id AND user_id = :user_id', array('site_id' => $site->site_id, 'user_id' => Yii::app()->user->id));
                 if ($mark != null) {
                     $mark->delete();
                 }
                 $mark = new Mark();
                 $mark->user_id = Yii::app()->user->id;
                 $mark->site_id = $site_id;
                 $mark->value = $_POST['value'];
                 $mark->save();
                 print 'Ваш голос учтен';
                 Yii::app()->end();
             }
         }
     } else {
         throw new CHttpException(404, 'Страница не найдена');
     }
 }
 /**
  * Update the specified resource in storage.
  * PUT /frontend/publiccontact/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function oceni($id)
 {
     try {
         if (!Session::get('id')) {
             return Redirect::to(Request::root() . '/login?ref=' . rawurlencode("ljudi/" . $id));
         } else {
             $contact = Contact::findOrFail($id);
             $update = false;
             try {
                 $mark = Mark::where('people_id', '=', $id)->where('user_id', '=', Session::get('id'))->firstOrFail();
                 $update = true;
             } catch (Exception $e) {
                 $mark = new Mark();
             }
             $mark->user_id = Session::get('id');
             $mark->people_id = $id;
             $mark->uskladjenost = Input::get('uskladjenost');
             $mark->jasnost = Input::get('jasnost');
             $mark->interakcija = Input::get('interakcija');
             $mark->komunikacija = Input::get('komunikacija');
             $mark->konflikt = Input::get('konflikt');
             $mark->inspiracija = Input::get('inspiracija');
             $mark->aktivnost = Input::get('aktivnost');
             $mark->kvalitet_literature = Input::get('literatura');
             $mark->student_relations = Input::get('odnos');
             $avg = ($mark->uskladjenost + $mark->jasnost + $mark->interakcija + $mark->komunikacija + (11 - $mark->konflikt) + $mark->inspiracija + $mark->aktivnost + $mark->kvalitet_literature + $mark->student_relations) / 9;
             $mark->total_impression = $avg;
             $mark->note = Input::get('komentar');
             $mark->save();
             $mark_count = Mark::where('people_id', '=', $id)->count();
             $contact->mark_count++;
             $contact->uskladjenost = ($contact->uskladjenost * ($mark_count - 1) + $mark->uskladjenost) / $mark_count;
             $contact->jasnost = ($contact->jasnost * ($mark_count - 1) + $mark->jasnost) / $mark_count;
             $contact->interakcija = ($contact->interakcija * ($mark_count - 1) + $mark->interakcija) / $mark_count;
             $contact->komunikacija = ($contact->komunikacija * ($mark_count - 1) + $mark->komunikacija) / $mark_count;
             $contact->konflikt = ($contact->konflikt * ($mark_count - 1) + $mark->konflikt) / $mark_count;
             $contact->inspiracija = ($contact->inspiracija * ($mark_count - 1) + $mark->inspiracija) / $mark_count;
             $contact->aktivnost = ($contact->aktivnost * ($mark_count - 1) + $mark->aktivnost) / $mark_count;
             $contact->kvalitet_literature = ($contact->kvalitet_literature * ($mark_count - 1) + $mark->kvalitet_literature) / $mark_count;
             $contact->student_relations = ($contact->student_relations * ($mark_count - 1) + $mark->student_relations) / $mark_count;
             $contact->total_impression = ($contact->total_impression * ($mark_count - 1) + $mark->total_impression) / $mark_count;
             $contact->save();
             if ($update) {
                 return Redirect::to(Request::root() . '/ljudi/' . $id)->with('notif', 'success')->with('message', __("Оцена предавача ажурирана"));
             }
             return Redirect::to(Request::root() . '/ljudi/' . $id)->with('notif', 'success')->with('message', __("Успешно сте оценили предавача"));
         }
     } catch (Exception $e) {
         return Redirect::to(Request::root() . '/ljudi/' . $id)->with('notif', 'danger')->with('message', __("Одабрани предавач не постоји"));
     }
 }