<?php

namespace common\modules\school\controllers;

use Yii;

use common\components\BaseController;

use common\modules\school\models\Lessons;
use common\modules\testings\models\Passing;

class LessonController extends BaseController
{    
    public static function actionsTitles()
    {
        return [
            'View'	 => 'Урок',
        ];
    }
    
    public function actionView($id)
    {
        $model = Lessons::findOne($id);

        \Yii::$app->view->registerMetaTag([
            'property' => 'og:title',
            'content' => $model->title
        ]);

        // Ищим прохождение теста
        $passing = null;
        if($model->test)
        {
            $passing = Passing::find()->where(['test_id' => $model->test_id, 'user_id' => Yii::$app->user->id])->one();
        }

        return $this->render('view', compact('model', 'passing'));
    }
}
