Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 25 |
| ViewAction | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
20.00 | |
0.00% |
0 / 25 |
| run | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 17 |
|||
| findModel | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 8 |
|||
| <?php | |
| namespace backend\controllers\survey; | |
| use Yii; | |
| use common\models\Survey; | |
| use common\models\SurveyAnswer; | |
| use common\models\SurveyOpinion; | |
| use common\models\SurveyQuestion; | |
| use yii\base\Action; | |
| use yii\web\UploadedFile; | |
| use yii\web\BadRequestHttpException; | |
| use yii\web\ForbiddenHttpException; | |
| use yii\web\NotFoundHttpException; | |
| /** | |
| * Creates a new Meeting model. | |
| * If creation is successful, the browser will be redirected to the 'view' page. | |
| * @param integer $participant | |
| * @return mixed | |
| */ | |
| class ViewAction extends Action | |
| { | |
| public $surveyClassName = 'common\models\Survey'; | |
| public function run($id) | |
| { | |
| $model = $this->findModel($id); | |
| $survey = $model; | |
| if (!($survey instanceof Survey)) { | |
| $survey = $model->survey; | |
| } | |
| $opinion_quantity = $survey->getSurveyOpinions()->count(); | |
| $questions = $survey->getSurveyQuestions() | |
| ->with(["surveyAnswers"]) | |
| ->all(); | |
| return $this->controller->render('..\survey\answer\index', [ | |
| 'model' => $model, | |
| 'survey' => $survey, | |
| 'opinionQuantity' => $opinion_quantity, | |
| 'questions' => $questions, | |
| ]); | |
| } | |
| /** | |
| * Finds the Survey model based on its primary key value. | |
| * If the model is not found, a 404 HTTP exception will be thrown. | |
| * @param string $id | |
| * @return Survey the loaded model | |
| * @throws NotFoundHttpException if the model cannot be found | |
| */ | |
| protected function findModel($id) | |
| { | |
| $className = $this->surveyClassName; | |
| if (($model = $className::findOne($id)) !== null) { | |
| return $model; | |
| } else { | |
| throw new NotFoundHttpException('The requested page does not exist.'); | |
| } | |
| } | |
| } |