/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Tracks::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * * Показывает для редактирования и сохраняет трек * * @param id * @return true * **/ public function actionEdit_track($id) { if (!Yii::app()->my->access("edit")) { return false; } $track = Tracks::model()->findByPk($id); if (isset($_REQUEST['Tracks'])) { foreach ($_REQUEST['Tracks'] as $key => $value) { $track->{$key} = $value; } if ($track->save()) { Yii::app()->notify->add("Трек сохранен. <a href='/track/" . $track->code . "' target='blank'><u>Перейти к треку</u></a>"); if (isset($_REQUEST['Tracks']["Docs"])) { $track->setRelationRecords("Docs", $_REQUEST['Tracks']["Docs"]); } if (isset($_REQUEST['Tracks']["Algorithms"])) { $track->setRelationRecords("Algorithms", $_REQUEST['Tracks']["Algorithms"]); } } else { Yii::app()->notify->add("Не удалось сохранить", "danger"); //print_r($task->getErrors()); } } $this->render("track", array("track" => $track)); }
<label for="">Порядок</label> <?php echo $form->textField($faq, 'order', array('class' => 'form-control')); ?> </div><!-- /.col-md-4 --> <div class="col-md-4"> <label for="">Трек, которому принадлежит видео</label> <?php echo $form->dropDownList($faq, 'track', CHtml::listData(Tracks::model()->findAll(), 'id', 'title'), array('class' => 'form-control')); ?> </div><!-- /.col-md-4 --> <div class="col-md-4"> <label for=""> </label> <button type="submit" class="btn btn-success form-control">Сохранить</button> </div><!-- /.col-md-4 -->
public function actionByid($id, $student = null) { $course = Courses::model()->findByPk($id); $tracks = Tracks::model()->with(array('Tasks.Solutions' => array('on' => 'Solutions.student=' . $_SESSION['user'])))->findAllByAttributes(array("course" => $course->id), array('order' => 't.order')); $this->render('single', array("course" => $course, "tracks" => $tracks)); }
?> <!-- --> <label for="">Код для встраивания</label> <?php echo $form->textArea($video, 'embed', array('class' => 'form-control')); ?> <!-- --> <label for="">Трек, которому принадлежит видео</label> <?php echo $form->dropDownList($video, 'track', CHtml::listData(Tracks::model()->findAll(), 'id', 'title')); ?> <button type="submit" class="btn btn-success">Сохранить</button> </div> </div> <?php $this->endWidget(); ?>
public function actionIndex() { $tracks = Tracks::model()->with("Videos")->findAll(); $this->render('index', array("tracks" => $tracks)); }
?> <br> <!-- Название --> <label for="">Описание</label> <?php echo $form->textArea($task, 'description', array('class' => 'form-control')); ?> </div> <div class="col-md-3"> <!-- Трек --> <label for="">Тема</label> <?php $list = CHtml::listData(Tracks::model()->findAll(), 'id', 'title'); ?> <?php echo $form->dropDownList($task, 'track', $list, array('class' => 'form-control')); ?> <br> <!-- Курс --> <label for="">Курс</label> <?php $list = CHtml::listData(Courses::model()->findAll(), 'id', 'title'); ?> <?php echo $form->dropDownList($task, 'course', $list, array('class' => 'form-control'));
<!-- Быстрый переход к прогрессу --> </td><td> <div class="btn-group pull-right "> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> Выберите тему<span class="caret"></span> </button> <ul class="dropdown-menu " role="menu"> <?php foreach (Tracks::model()->findAllByAttributes(array("course" => $data->course)) as $item) { ?> <li> <a href="/groups/<?php echo $data->id; ?> /progress/<?php echo $item->id; ?> "> <?php echo $item->title; ?> </a>
public function actionTheory($id) { $track = Tracks::model()->with("Tasks")->findByPk($id); $tasks = Tasks::model()->findAllByAttributes(array("track" => $id), array("order" => "t.order")); $this->render('theory', array('track' => $track, 'tasks' => $tasks)); }
</div> <div class="col-md-6"> <label for="">Подзаголовок</label> <?php echo $form->textField($algorithm, 'description', array("class" => "form-control")); ?> </div> <div class="col-md-3"> <label for="">Трек</label> <?php echo $form->dropDownList($algorithm, 'Tracks', CHtml::listData(Tracks::model()->findAll(), 'id', 'title'), array('class' => 'form-control', "multiple" => true)); ?> </div> </div> <hr> <?php $steps = json_decode($algorithm->steps, true); ?>