Yii::app()->session
Добавлено: 31 окт 2015, 09:12
Zdravstvuyte, lyudi dobrie i umnie. Pojaluysta pomogite
Controller:
index.php
Problema:
1.v etom sluche vivodet 10 shtuk odinakvy testi dlya vsex actionov ( prichenu kanewno ponimayu no rewat ne smogla
2.dlya kajdogo actiona doljna bit svoya sessiya Vverxu umenya ssilka dlya razlichnix actionov Xochu chtob oni rabotali kak prev I next
Controller:
- Код: Выделить всё
public function actionFizika($id)
{
$block = Category::model()->findByPk(array($id));
$models1 = Fizika::model()->findAll(
array(
"condition" => "",
"order" => "rand()",
"limit" => 10,
)
);
$this->render('index', array('models'=>$models1, 'block'=>$block));
}
public function actionMatem()
{
…
$this->render('index', array('models'=>$models1, 'block'=>$block));
}
index.php
- Код: Выделить всё
<?php echo CHtml::beginForm();
echo "<div class='right'>";
echo "<b id='s'>".CHtml::link(CHtml::encode("1"), array('test/'.$block->a_block.'/'.$block->id))."</b>";
echo "<b id='s'>".CHtml::link(CHtml::encode("2"), array('test/'.$block->b_block.'/'.$block->id))."</b>";
echo "<b id='s'>".CHtml::link(CHtml::encode("3"), array('test/'.$block->c_block.'/'.$block->id))."</b>";
echo "</div>";
$a=0;
foreach ($models as $one ) {
$a++;
if (isset(Yii::app()->session['questions'])) {
echo '<b>'.$a.'. </b>'.Yii::app()->session['questions']['question'].'</br>';
echo CHtml::radioButtonList('answer_'.$a, $model->answer,array(
Yii::app()->session['questions']['a'], Yii::app()->session['questions']['b'])).'</br>';
}
else Yii::app()->session['questions']=array(
'id'=>$one->id,
'question'=>$one->question,
'a'=>$one->a,
'b'=>$one->b,
);
}
echo "</br>".CHtml::SubmitButton('result',array('class'=>"btn btn-info"));
echo CHtml::endForm();
?>
Problema:
1.v etom sluche vivodet 10 shtuk odinakvy testi dlya vsex actionov ( prichenu kanewno ponimayu no rewat ne smogla
2.dlya kajdogo actiona doljna bit svoya sessiya Vverxu umenya ssilka dlya razlichnix actionov Xochu chtob oni rabotali kak prev I next