Пример #1
0
 /**
 * Creates data provider instance with search query applied
 *
 * @param array $params
 *
 * @return ActiveDataProvider
 */
 public function search($params)
 {
     $query = Levels::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'score' => $this->score, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'level', $this->level])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'color', $this->color]);
     return $dataProvider;
 }
Пример #2
0
 /**
  * Displays the moreresults page
  *
  * @return mixed
  */
 public function actionMoreresults()
 {
     $tilesUsers = TilesUsers::find()->where(['created_by' => Yii::$app->getUser()->id])->all();
     $tilesCategories = TilesCategories::find()->all();
     $categoriesNames = [];
     $categoriesLevels = [];
     foreach ($tilesCategories as $tilesCategory) {
         $points[$tilesCategory->name] = 0;
         $outOf[$tilesCategory->name] = 0;
         $levels[$tilesCategory->name] = 0;
         $categoriesNames[] = $tilesCategory->name;
     }
     foreach ($tilesUsers as $tilesUser) {
         $category = Tiles::findOne($tilesUser->tile)->category0;
         $level = Levels::findOne($tilesUser->level);
         $points[$category->name] += $level->score;
         $outOf[$category->name] += 1;
         $levels[$category->name] += $level->level;
     }
     foreach ($tilesCategories as $tilesCategory) {
         $levels[$tilesCategory->name] = round($levels[$tilesCategory->name] / $outOf[$tilesCategory->name]);
         $categoriesLevels[] = $levels[$tilesCategory->name];
         $colors[$tilesCategory->name] = Levels::find()->where(['level' => $levels[$tilesCategory->name]])->one()->color;
     }
     return $this->render('moreresults', ['tilesCategories' => $tilesCategories, 'points' => $points, 'outOf' => $outOf, 'levels' => $levels, 'colors' => $colors, 'categoriesNames' => $categoriesNames, 'categoriesLevels' => $categoriesLevels]);
 }
Пример #3
0
 /**
  * Finds the Levels model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Levels the loaded model
  * @throws HttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Levels::findOne($id)) !== null) {
         return $model;
     } else {
         throw new HttpException(404, 'The requested page does not exist.');
     }
 }
Пример #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getLevel0()
 {
     return $this->hasOne(Levels::className(), ['id' => 'level']);
 }