Дипломная работа: Автоматизация процесса контроля знаний учащихся в МБОУ «Алнашская СОШ»

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
- 122 -
]);
}
/**
* Creates a new Result model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Result();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
return $this->render('create', [
'model' => $model,
]);
}
/**
- 123 -
* Updates an existing Result model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
return $this->render('update', [
'model' => $model,
]);
}
/**
* Deletes an existing Result model.
* If deletion is successful, the browser will be redirected to the 'index' page.
- 124 -
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
/**
* Finds the Result model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Result the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
public static function findModel($id)
{
if (($model = Result::findOne($id)) !== null) {
return $model;
- 125 -
}
throw new NotFoundHttpException(Yii::t('app', 'The requested page does
not exist.'));
}
}
TestController.php
<?php
namespace app\controllers;
use Yii;
use app\models\Test;
use app\models\TestSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
/**
* TestController implements the CRUD actions for Test model.
*/
class TestController extends Controller
{
- 126 -
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' =>
[
[
'actions' => ['index', 'view', 'create', 'update',
'delete'],
'allow' => true,
'roles' => ['@'],
'matchCallback' => function ($rule, $action)
{
return Yii::$app->user->identity-
>IsAdmin || Yii::$app->user->identity->IsUser;
}
],
],
],
'verbs' => [
Источник: https://baza.diplomsite.ru/previewfile/2089