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

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
- 112 -
$searchModel = new AnswerVariantSearch();
$dataProvider = $searchModel->search(Yii::$app->request-
>queryParams);
$dataProvider->query->andWhere(['id_question' => $question-
>id]);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'question' => $question,
'test' => $test,
]);
}
/**
* Displays a single AnswerVariant model.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionView($id)
{
$model = $this->findModel($id);
- 113 -
$question = QuestionController::findModel($model-
>id_question);
$test = TestController::findModel($question->id_test);
return $this->render('view', [
'model' => $model,
'question' => $question,
'test' => $test,
]);
}
/**
* Creates a new AnswerVariant model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate($id_question)
{
$question = QuestionController::findModel($id_question);
$test = TestController::findModel($question->id_test);
$model = new AnswerVariant();
- 114 -
if ($model->load(Yii::$app->request->post()) && $model->save()) {
$model->id_question = $question->id;
if ($model->save())
{
return $this->redirect(['view', 'id' => $model->id]);
}
}
else
{
$model->id_question = $question->id;
$model->position = $question->lastPosition + 1;
}
return $this->render('create', [
'model' => $model,
'question' => $question,
'test' => $test,
]);
}
/**
* Updates an existing AnswerVariant model.
- 115 -
* 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);
$question = QuestionController::findModel($model-
>id_question);
$test = TestController::findModel($question->id_test);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
return $this->render('update', [
'model' => $model,
'question' => $question,
'test' => $test,
]);
- 116 -
}
/**
* Deletes an existing AnswerVariant model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionDelete($id)
{
$model = $this->findModel($id);
$question = QuestionController::findModel($model-
>id_question);
$model->delete();
return $this->redirect(['index', 'id_question' => $question->id]);
}
/**
* Finds the AnswerVariant model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return AnswerVariant the loaded model
Источник: https://baza.diplomsite.ru/previewfile/2089