Fix questions manage

parent feb69412
...@@ -6,6 +6,7 @@ use Yii; ...@@ -6,6 +6,7 @@ use Yii;
use common\components\AdminController; use common\components\AdminController;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use yii\helpers\ArrayHelper;
use common\modules\testings\models\TestingQuestion; use common\modules\testings\models\TestingQuestion;
use common\modules\testings\models\SearchTestingQuestion; use common\modules\testings\models\SearchTestingQuestion;
...@@ -92,47 +93,29 @@ class TestingQuestionAdminController extends AdminController ...@@ -92,47 +93,29 @@ class TestingQuestionAdminController extends AdminController
return $this->redirect(['manage']); return $this->redirect(['manage']);
} }
// public function actionManage() public function actionManage()
// { {
// $questions = array();//Вопросы с предупреждением о картинках $questions = [];
// //$param = 'карт, изобр, изображение, скриншот, картинка, схема, рисунок, рис'; $param = 'карт, изобр, изображение, скриншот, картинка, схема, рисунок, рис';
// $param = trim(Setting::getValue('testings_questions_with_picture')); // $param = trim(Setting::getValue('testings_questions_with_picture'));
// $words = empty($param) ? array() : explode(',', trim($param));
// $db = Yii::app()->db;
// if( isset($_GET['test']) && !empty($words)) {
// $where = array();
// for ($i = 0; $i < count($words); $i++) {
// $where[] = sprintf('%s LIKE trim(%s)',
// $db->quoteColumnName('text'),
// $db->quoteValue('%'.trim($words[$i]).'%'));
// }
// $where = implode(' OR ', $where);
// $sql = "SELECT id, `text` FROM testings_questions WHERE test_id = :test_id AND ($where)";
// $rows = $db->createCommand($sql)->queryAll(true, array('test_id' => $_GET['test']));
// foreach($rows as $row) {
// $questions[$row['id']] = $row['text'];
// }
// }
// $model=new TestingQuestion('search');
// $model->unsetAttributes();
// if(isset($_GET['TestingQuestion']))
// {
// $model->attributes = $_GET['TestingQuestion'];
// }
// $this->render('manage', array(
// 'model' => $model,
// 'questions' => $questions,
// 'questions_param' => $param,
// ));
// }
public function actionManage() $words = empty($param) ? array() : explode(',', trim($param));
if(Yii::$app->request->get('test') && !empty($words))
{
$query = TestingQuestion::find();
for ($i = 0; $i < count($words); $i++)
{ {
$query->orWhere(['like', 'text', trim($words[$i])]);
}
$query->andWhere(['test_id' => Yii::$app->request->get('test')]);
$questions = ArrayHelper::map($query->all(), 'id', 'text');
}
$searchModel = new SearchTestingQuestion(); $searchModel = new SearchTestingQuestion();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams); $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
...@@ -144,6 +127,8 @@ class TestingQuestionAdminController extends AdminController ...@@ -144,6 +127,8 @@ class TestingQuestionAdminController extends AdminController
return $this->render('manage', [ return $this->render('manage', [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
'questions' => $questions,
'questions_param' => $param,
]); ]);
} }
......
...@@ -28,8 +28,7 @@ $("#message_expand").one("click", function (e) { ...@@ -28,8 +28,7 @@ $("#message_expand").one("click", function (e) {
e.preventDefault(); e.preventDefault();
var el = $(this).hide(); var el = $(this).hide();
el.parent(".message") $('#list_expand').show();
.css({height: "auto", overflow: "auto"});
}); });
EOD; EOD;
...@@ -41,7 +40,7 @@ $this->registerJs($js, yii\web\View::POS_READY, 'expnd.info'); ...@@ -41,7 +40,7 @@ $this->registerJs($js, yii\web\View::POS_READY, 'expnd.info');
<a href="#" id="message_expand">Показать</a> <a href="#" id="message_expand">Показать</a>
<p>Имеются вопросы со словами: <b>&laquo<?php echo Html::encode($questions_param);?>&raquo</b></p> <p>Имеются вопросы со словами: <b>&laquo<?php echo Html::encode($questions_param);?>&raquo</b></p>
<br/><br/> <br/><br/>
<ul> <ul style="display:none;" id="list_expand">
<?php foreach($questions as $id => $text): ?> <?php foreach($questions as $id => $text): ?>
<li><?php echo Html::a(Html::encode($text), ['update', 'id' => $id]); ?></li> <li><?php echo Html::a(Html::encode($text), ['update', 'id' => $id]); ?></li>
<?php endforeach; ?> <?php endforeach; ?>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment