Example #1
0
 public function init()
 {
     parent::init();
     if ($this->user_id != null) {
         for ($i = 0; $i < 15; $i++) {
             $this->marks[$this->getPastDates($i)] = ($mrk = MarkIt::getAverageForDateAndUser($this->getPastDates($i), $this->user_id)) ? $mrk : 0;
         }
     }
 }
Example #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMarkIts()
 {
     return $this->hasMany(MarkIt::className(), ['action_id' => 'id']);
 }
Example #3
0
 public function init()
 {
     parent::init();
     $this->user_avg = MarkIt::getThisGroupUsersAverageMark($this->group_id);
 }
Example #4
0
 /**
  * Добавление случайно оцененных действий пользователю
  * @param array $response_for_core_user
  * @param int $user_id
  * @return bool|string
  */
 private function addRandActionToSomeUser($response_for_core_user, $user_id)
 {
     for ($i = 0; $i < 15; $i++) {
         if (isset($response_for_core_user[$i])) {
             $model = new MarkIt();
             $model->ball = rand(3, 5);
             $model->action_id = $response_for_core_user[$i]['act'];
             $model->user_id = $user_id;
             $model->date = date('Y-m-d', time() - 60 * 60 * 24);
             if ($model->validate()) {
                 try {
                     if (!$model->save()) {
                         return "ОШИБКА СОХРАНЕНИЯ ДАННЫХ!";
                     }
                 } catch (\ErrorException $e) {
                     return "Не получилось(((... ";
                 }
             } else {
                 return "Ошибка при заполнении формы - оценки должны быть 1,2,3,4 или 5";
             }
         }
     }
     return true;
 }
Example #5
0
    var bounce = new Bounce();
    bounce.rotate({
        from: 0,
        to: 90
    });

    bounce.applyTo(document.querySelectorAll(".balll"));
</script>
<div class="col-sm-4 col-md-3 sidebar" xmlns="http://www.w3.org/1999/html">
    <p>Оценки последней недели</p>
    <?php 
echo \app\components\LastMarksWidget::widget(['user_id' => isset($user->id) ? $user->id : 1]);
?>
    <p>Твой общий средний балл</p>
    <?php 
$averball = \app\models\MarkIt::getAverageForUser(['user_id' => isset($user->id) ? $user->id : 1]);
?>
    <?php 
if ($averball >= 3.5) {
    ?>
        <p style="color: #40ff36"> <?php 
    echo $averball;
    ?>
 </p>
    <?php 
} else {
    ?>
        <p style="color: red"> <?php 
    echo $averball;
    ?>
 </p>