Example #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;
 }
Example #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]);
 }