public function actionGetViewData()
 {
     $result = array();
     $plan = CWorkPlanManager::getWorkplan(CRequest::getInt("plan_id"));
     $query = new CQuery();
     $query->select("parent.id as id, subject.name as name")->from(TABLE_CORRICULUM_DISCIPLINES . " as discipline")->innerJoin(TABLE_CORRICULUM_DISCIPLINES . " as parent", "parent.id = discipline.parent_id")->innerJoin(TABLE_DISCIPLINES . " as subject", "parent.discipline_id = subject.id")->condition("discipline.id = " . $plan->corriculum_discipline_id);
     foreach ($query->execute()->getItems() as $item) {
         $result[$item["id"]] = $item["name"];
     }
     return $result;
 }
 public function actionGetViewData()
 {
     $result = array();
     $plan = CWorkPlanManager::getWorkplan(CRequest::getInt("plan_id"));
     $discipline = CCorriculumsManager::getDiscipline($plan->corriculum_discipline_id);
     $query = new CQuery();
     $query->select("term.id as id, term.title as name")->from(TABLE_CORRICULUM_DISCIPLINE_SECTIONS . " as term")->condition("discipline_id=" . $discipline->getId());
     foreach ($query->execute()->getItems() as $item) {
         $result[$item["id"]] = $item["name"];
     }
     return $result;
 }
 public function actionAdd()
 {
     $object = new CWorkPlanSoftware();
     $object->plan_id = CRequest::getInt("id");
     $plan = CWorkPlanManager::getWorkplan(CRequest::getInt("id"));
     $object->ordering = $plan->software->getCount() + 1;
     $this->setData("object", $object);
     /**
      * Генерация меню
      */
     $this->addActionsMenuItem(array("title" => "Назад", "link" => "workplansoftware.php?action=index&plan_id=" . $object->plan_id, "icon" => "actions/edit-undo.png"));
     /**
      * Отображение представления
      */
     $this->renderView("_corriculum/_workplan/software/add.tpl");
 }
 public function actionAdd()
 {
     $plan = CWorkPlanManager::getWorkplan(CRequest::getInt("id"));
     $group = new CWorkPlanProjectThemeGroupAdd();
     $group->plan_id = CRequest::getInt("id");
     $group->type = CRequest::getInt("type");
     $this->setData("group", $group);
     /**
      * Генерация меню
      */
     $this->addActionsMenuItem(array("title" => "Назад", "link" => "workplanprojectthemes.php?action=index&plan_id=" . $group->plan_id . "&type=" . $group->type, "icon" => "actions/edit-undo.png"));
     /**
      * Отображение представления
      */
     $this->renderView("_corriculum/_workplan/projectThemes/add.tpl");
 }
 /**
  * Структура дисциплины.
  * Здесь идут жестокие sql-запросы, но так оно
  * работает намного быстрее
  */
 public function actionStructure()
 {
     $plan = CWorkPlanManager::getWorkplan(CRequest::getInt("plan_id"));
     $this->addActionsMenuItem(array("title" => "Обновить", "link" => "workplancontent.php?action=structure&plan_id=" . CRequest::getInt("plan_id"), "icon" => "actions/view-refresh.png"));
     $terms = array();
     $terms[] = "term.name";
     $termIds = array();
     foreach ($plan->terms->getItems() as $term) {
         $termIds[] = $term->getId();
         $terms[] = "sum(if(l.term_id = " . $term->getId() . ", l.value, 0)) as t_" . $term->getId();
     }
     if (count($termIds) > 0) {
         $terms[] = "sum(if(l.term_id in (" . join(", ", $termIds) . "), l.value, 0)) as t_sum";
     }
     /**
      * Определим нагрузку по каждому виду в каждом семестре
      */
     $query = new CQuery();
     $query->select(join(", ", $terms))->from(TABLE_WORK_PLAN_CONTENT_LOADS . " as l")->innerJoin(TABLE_TAXONOMY_TERMS . " as term", "term.id = l.load_type_id")->innerJoin(TABLE_WORK_PLAN_CONTENT_SECTIONS . " as section", "l.section_id = section.id")->innerJoin(TABLE_WORK_PLAN_CONTENT_MODULES . " as module", "section.module_id = module.id")->condition("module.plan_id = " . $plan->getId())->group("l.load_type_id")->order("term.name");
     $objects = $query->execute();
     $this->setData("objects", $objects);
     $this->setData("terms", $plan->terms);
     /**
      * Теперь определим разделы дисциплины и нагрузку по
      * ним в каждом семестре.
      */
     $termSectionsData = new CArrayList();
     foreach ($plan->terms->getItems() as $term) {
         $query = new CQuery();
         $select = array();
         $select[] = "section.sectionIndex";
         $select[] = "section.name";
         $select[] = "sum(if(term.alias in ('lecture', 'practice', 'labwork'), l.value, 0)) + sum(selfedu.question_hours) as total";
         $select[] = "sum(if(term.alias = 'lecture', l.value, 0)) as lecture";
         $select[] = "sum(if(term.alias = 'practice', l.value, 0)) as practice";
         $select[] = "sum(if(term.alias = 'labwork', l.value, 0)) as labwork";
         $select[] = "sum(selfedu.question_hours) as selfedu";
         $query->select(join(", ", $select))->from(TABLE_WORK_PLAN_CONTENT_SECTIONS . " as section")->innerJoin(TABLE_WORK_PLAN_CONTENT_LOADS . " as l", "l.section_id = section.id")->innerJoin(TABLE_TAXONOMY_TERMS . " as term", "term.id = l.load_type_id")->leftJoin(TABLE_WORK_PLAN_SELFEDUCATION . " as selfedu", "selfedu.load_id = l.id")->group("l.section_id")->condition("l.term_id = " . $term->getId());
         $items = $query->execute();
         if ($items->getCount() > 0) {
             $termSectionsData->add($term->getId(), $items);
         }
     }
     $this->setData("termSectionsData", $termSectionsData);
     $this->renderView("_corriculum/_workplan/content/structure.tpl");
 }
 public function actionSaveGroup()
 {
     $plan = CWorkPlanManager::getWorkplan(CRequest::getInt("id"));
     $group = new CExamGroupAdd();
     $group->setAttributes(CRequest::getArray($group::getClassName()));
     $texts = explode(chr(13), $group->text);
     foreach ($texts as $text) {
         $q = new CExamQuestion();
         $q->speciality_id = $group->speciality_id;
         $q->course = $group->course;
         $q->year_id = $group->year_id;
         $q->category_id = $group->category_id;
         $q->discipline_id = $group->discipline_id;
         $q->plan_id = $group->plan_id;
         $q->type = $group->type;
         $q->text = trim($text);
         $q->save();
     }
     $this->redirect("workplanexamquestions.php?action=index&plan_id=" . $q->plan_id . "&type=" . $q->type);
 }
 public function actionAdd()
 {
     $object = new CWorkPlanCriteriaOfEvaluation();
     $object->plan_id = CRequest::getInt("id");
     $object->type = CRequest::getInt("type");
     $plan = CWorkPlanManager::getWorkplan(CRequest::getInt("id"));
     if ($object->type == 1) {
         $object->ordering = $plan->criteriaExamOfEvaluation->getCount() + 1;
     } elseif ($object->type == 2) {
         $object->ordering = $plan->criteriaCreditOfEvaluation->getCount() + 1;
     } elseif ($object->type == 3) {
         $object->ordering = $plan->criteriaMaterialsOfEvaluation->getCount() + 1;
     }
     $this->setData("object", $object);
     /**
      * Генерация меню
      */
     $this->addActionsMenuItem(array("title" => "Назад", "link" => "workplancriteriaofevaluation.php?action=index&plan_id=" . $object->plan_id . "&type=" . $object->type, "icon" => "actions/edit-undo.png"));
     /**
      * Отображение представления
      */
     $this->renderView("_corriculum/_workplan/criteriaEvaluation/add.tpl");
 }
 public function actionAdd()
 {
     $object = new CWorkPlanLiterature();
     $object->plan_id = CRequest::getInt("plan_id");
     $object->type = CRequest::getInt("type");
     $plan = CWorkPlanManager::getWorkplan(CRequest::getInt("plan_id"));
     if ($object->type == 1) {
         $object->ordering = $plan->baseLiterature->getCount() + 1;
     } elseif ($object->type == 2) {
         $object->ordering = $plan->additionalLiterature->getCount() + 1;
     } elseif ($object->type == 3) {
         $object->ordering = $plan->internetResources->getCount() + 1;
     }
     $this->setData("object", $object);
     /**
      * Генерация меню
      */
     $this->addActionsMenuItem(array("title" => "Назад", "link" => "workplanliterature.php?action=index&plan_id=" . $object->plan_id . "&type=" . $object->type, "icon" => "actions/edit-undo.png"));
     /**
      * Отображение представления
      */
     $this->renderView("_corriculum/_workplan/literature/add.tpl");
 }
 public function actionUpdate()
 {
     $plan = CWorkPlanManager::getWorkplan(CRequest::getInt("plan_id"));
     if (!is_null($plan->corriculumDiscipline)) {
         foreach (CActiveRecordProvider::getWithCondition(TABLE_CORRICULUM_DISCIPLINE_SECTIONS, "discipline_id=" . $plan->corriculumDiscipline->getId())->getItems() as $ar) {
             $term = new CActiveModel($ar);
             $object = new CWorkPlanTerm();
             $object->plan_id = $plan->getId();
             $object->number = $term->getId();
             $object->save();
         }
     }
     $this->redirect("workplanterms.php?action=index&plan_id=" . $plan->getId());
 }
 /**
  * Структура дисциплины.
  * Здесь идут жестокие sql-запросы, но так оно
  * работает намного быстрее
  */
 public function actionStructure()
 {
     $plan = CWorkPlanManager::getWorkplan(CRequest::getInt("plan_id"));
     $this->addActionsMenuItem(array("title" => "Обновить", "link" => "workplancontent.php?action=structure&plan_id=" . CRequest::getInt("plan_id"), "icon" => "actions/view-refresh.png"));
     $terms = array();
     $terms[] = "term.name";
     $termIds = array();
     foreach ($plan->terms->getItems() as $term) {
         $termIds[] = $term->getId();
         $terms[] = "sum(if(l.term_id = " . $term->getId() . ", l.value, 0)) as t_" . $term->getId();
     }
     if (count($termIds) > 0) {
         $terms[] = "sum(if(l.term_id in (" . join(", ", $termIds) . "), l.value, 0)) as t_sum";
     }
     /**
      * Определим нагрузку по каждому виду в каждом семестре
      */
     $query = new CQuery();
     $query->select(join(", ", $terms))->from(TABLE_WORK_PLAN_CONTENT_LOADS . " as l")->innerJoin(TABLE_TAXONOMY_TERMS . " as term", "term.id = l.load_type_id")->innerJoin(TABLE_WORK_PLAN_CONTENT_SECTIONS . " as section", "l.section_id = section.id")->innerJoin(TABLE_WORK_PLAN_CONTENT_CATEGORIES . " as category", "section.category_id = category.id")->condition("category.plan_id = " . $plan->getId())->group("l.load_type_id")->order("l.ordering asc");
     $objects = $query->execute();
     $this->setData("objects", $objects);
     $this->setData("terms", $plan->terms);
     /**
      * Теперь определим разделы дисциплины и нагрузку по
      * ним в каждом семестре.
      */
     $termSectionsData = new CArrayList();
     foreach ($plan->terms->getItems() as $term) {
         $query = new CQuery();
         $select = array();
         $select[] = "section.sectionIndex";
         $select[] = "section.name";
         $select[] = "sum(if(term.alias in ('lecture', 'practice', 'labwork', 'ksr'), l.value, 0)) + sum(ifnull(selfedu.question_hours, 0)) as total";
         $select[] = "sum(if(term.alias = 'lecture', l.value, 0)) as lecture";
         $select[] = "sum(if(term.alias = 'practice', l.value, 0)) as practice";
         $select[] = "sum(if(term.alias = 'labwork', l.value, 0)) as labwork";
         $select[] = "sum(if(term.alias = 'ksr', l.value, 0)) as ksr";
         $select[] = "sum(ifnull(selfedu.question_hours, 0)) as selfedu";
         $query->select(join(", ", $select))->from(TABLE_WORK_PLAN_CONTENT_SECTIONS . " as section")->innerJoin(TABLE_WORK_PLAN_CONTENT_LOADS . " as l", "l.section_id = section.id")->innerJoin(TABLE_TAXONOMY_TERMS . " as term", "term.id = l.load_type_id")->leftJoin(TABLE_WORK_PLAN_SELFEDUCATION . " as selfedu", "selfedu.load_id = l.id")->group("l.section_id")->condition("l.term_id = " . $term->getId())->order("section.sectionIndex");
         $items = $query->execute();
         if ($items->getCount() > 0) {
             $termSectionsData->add($term->getId(), $items);
         }
     }
     $this->setData("termSectionsData", $termSectionsData);
     /**
      * Виды контроля
      */
     $set = new CRecordSet();
     $queryControlTypes = new CQuery();
     $set->setQuery($queryControlTypes);
     $queryControlTypes->select("l.*")->from(TABLE_WORK_PLAN_TYPES_CONTROL . " as l")->innerJoin(TABLE_TAXONOMY_TERMS . " as term", "term.id = l.control_id")->innerJoin(TABLE_WORK_PLAN_CONTENT_SECTIONS . " as section", "l.section_id = section.id")->innerJoin(TABLE_WORK_PLAN_CONTENT_CATEGORIES . " as category", "section.category_id = category.id")->condition("category.plan_id = " . $plan->getId())->order("section.sectionIndex asc");
     $controlTypes = new CArrayList();
     foreach ($set->getItems() as $ar) {
         $controlType = new CWorkPlanControlTypes($ar);
         $controlTypes->add($controlType->getId(), $controlType);
     }
     $this->setData("controlTypes", $controlTypes);
     /**
      * Описание и количество баллов по видам учебной деятельности
      */
     $setMarks = new CRecordSet();
     $queryMarks = new CQuery();
     $setMarks->setQuery($queryMarks);
     $queryMarks->select("control.*")->from(TABLE_WORK_PLAN_TYPES_CONTROL . " as control")->innerJoin(TABLE_WORK_PLAN_MARKS_STUDY_ACTIVITY . " as activity", "activity.activity_id = control.id")->innerJoin(TABLE_TAXONOMY_TERMS . " as term", "term.id = control.type_study_activity_id")->innerJoin(TABLE_WORK_PLAN_CONTENT_SECTIONS . " as section", "control.section_id = section.id")->innerJoin(TABLE_WORK_PLAN_CONTENT_CATEGORIES . " as category", "section.category_id = category.id")->condition("category.plan_id = " . $plan->getId())->order("activity.ordering asc");
     $marks = new CArrayList();
     foreach ($setMarks->getItems() as $ar) {
         $mark = new CWorkPlanControlTypes($ar);
         $marks->add($mark->getId(), $mark);
     }
     $this->setData("marks", $marks);
     $this->renderView("_corriculum/_workplan/content/structure.tpl");
 }
 public function actionEdit()
 {
     $plan = CWorkPlanManager::getWorkplan(CRequest::getInt("id"));
     $this->addActionsMenuItem(array(array("title" => "Назад", "link" => "workplans.php?action=index", "icon" => "actions/edit-undo.png"), array("title" => "Добавить модуль", "link" => "workplancontentmodules.php?action=add&id=" . $plan->getId(), "icon" => "actions/list-add.png"), array("title" => "Добавить цель", "link" => "workplangoals.php?action=add&id=" . $plan->getId(), "icon" => "actions/list-add.png")));
     $this->setData("plan", $plan);
     $this->addJSInclude(JQUERY_UI_JS_PATH);
     $this->addCSSInclude(JQUERY_UI_CSS_PATH);
     $this->addCSSInclude("_modules/_redactor/redactor.css");
     $this->addJSInclude("_modules/_redactor/redactor.min.js");
     $this->renderView("_corriculum/_workplan/workplan/edit.tpl");
 }
 public function actionCopyCompetentions()
 {
     $plan = CWorkPlanManager::getWorkplan(CRequest::getInt("id"));
     $corriculumDiscipline = $plan->corriculumDiscipline;
     $type = CRequest::getInt("type");
     foreach ($plan->competentionsFormed->getItems() as $competentionFormed) {
         $newItem = new CCorriculumDisciplineCompetention();
         $newItem->discipline_id = $corriculumDiscipline->getId();
         $newItem->competention_id = $competentionFormed->competention_id;
         $newItem->level_id = $competentionFormed->level_id;
         foreach ($competentionFormed->knowledges->getItems() as $knowledge) {
             $newItem->knowledges->add($knowledge->getId(), $knowledge->getId());
         }
         foreach ($competentionFormed->skills->getItems() as $skill) {
             $newItem->skills->add($skill->getId(), $skill->getId());
         }
         foreach ($competentionFormed->experiences->getItems() as $experience) {
             $newItem->experiences->add($experience->getId(), $experience->getId());
         }
         $newItem->save();
     }
     $this->redirect("workplancompetentions.php?action=index&plan_id=" . $plan->getId() . "&type=" . $type);
 }
 /**
  * Копирование списка рабочих программ в другой учебный план
  */
 public function actionCopyInCorriculum()
 {
     $bean = self::getStatefullBean();
     $corriculum = CRequest::getArray("selected");
     $plans = explode(":", $bean->getItem("selected"));
     $corriculum = CCorriculumsManager::getCorriculum($corriculum[0]);
     foreach ($plans as $id) {
         $plan = CWorkPlanManager::getWorkplan($id);
         foreach ($corriculum->getDisciplines() as $discipline) {
             if ($plan->corriculumDiscipline->discipline->getValue() == $discipline->discipline->getValue()) {
                 $newPlan = $plan->copy();
                 $newPlan->corriculum_discipline_id = $discipline->getId();
                 $newPlan->save();
             }
         }
     }
     $this->redirect("workplans.php");
 }