Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TCDA-214] Feat/class plan validate #694

Merged
merged 25 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b28f600
first commit
AnotherOne07 Apr 2, 2024
92513f6
models adjustment and module configs
AnotherOne07 Apr 4, 2024
b1823cb
create view finished
AnotherOne07 Apr 5, 2024
fb6dd7e
create action finished/ update function already working
AnotherOne07 Apr 10, 2024
58d6d44
pendingPlans added
AnotherOne07 Apr 12, 2024
e18da25
ref/module adjusted
AnotherOne07 Apr 16, 2024
79199a6
table finished, just missing the action to validate
AnotherOne07 Apr 16, 2024
e1f61e3
new inputs added
AnotherOne07 Apr 17, 2024
0ce5d3c
function adjusted
AnotherOne07 Apr 17, 2024
43a1136
minor adjustment
AnotherOne07 Apr 17, 2024
12783a5
request added
AnotherOne07 Apr 18, 2024
ad9edaf
feat/forms finished, just missing to create a new type of access
AnotherOne07 Apr 19, 2024
c86ee86
feat/create button to enable edition
AnotherOne07 Apr 20, 2024
b3432aa
Merge branch 'dev' into feat/class_plan_validate
AnotherOne07 Apr 20, 2024
1daf3ed
feat/add readonly property to fields that shouldn't be change
AnotherOne07 Apr 21, 2024
f7271b0
feat/observation field added to form
AnotherOne07 Apr 22, 2024
5741804
fix/date fixed and hiding buttons depending on auth item
AnotherOne07 Apr 23, 2024
5bb4f0f
docs/CHANGELOG e config.php updated
AnotherOne07 Apr 23, 2024
f371a14
fix/update description in select itens
AnotherOne07 Apr 23, 2024
dfb520d
fix/sanitize html appends and sonarlint issues
AnotherOne07 Apr 23, 2024
e434b3a
fix/sonarlint and change description
AnotherOne07 Apr 23, 2024
e07a544
Merge branch 'dev' into feat/class_plan_validate
AnotherOne07 Apr 23, 2024
3a85db6
feat/icons inserted
AnotherOne07 Apr 24, 2024
246769f
fix/icon styles
AnotherOne07 Apr 24, 2024
6ddea8d
Merge branch 'dev' into feat/class_plan_validate
igorgoncalves Apr 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
## [Versão 3.78.135]
- Adicionando funcionalidade de validação de planos de aula
- Criando novo tipo de usuário e visibilidade "Coordenador"

## [Versão 3.77.135]
- Adicionado novas inconsistências para a falta de componentes curriculasres

## [Versão 3.77.134]
- Consertado tela de frequencia para os professores
-
-
## [Versão 3.77.133]
- Realizado correções nas validações das datas para Professor, Estudante e Escola

## [Versão 3.78.132]
- Adicionado campo para a assinatura do diretor
- Adicionado campo para a assinatura do diretor

## [Versão 3.77.132]
- Criando as telas relacionadas a agricultor no novo módulo de merenda escolar
Expand Down
3 changes: 2 additions & 1 deletion app/config/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@
'curricularcomponents',
'stages',
'foods',
'dashboard'
'dashboard',
'courseplan'
),
// application components
'components' => array(
Expand Down
9 changes: 9 additions & 0 deletions app/messages/pt_br/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -742,13 +742,20 @@
//Course Plan
'Course Plan' => 'Plano de aula',
'Create Plan' => 'Criar plano',
'Pendent Plan' => 'Planos pendentes',
'Pending Course Plan' => 'Planos de aula pendentes',
'Class' => 'Aula',
'Objective' => 'Objetivo',
'New' => 'Novo',
'Content' => 'Conteúdo',
'Type' => 'Tipo',
'Resource' => 'Recurso',
'Add Resource' => 'Novo Recurso',
'Start Date' => 'Data Inicial',
'Situation' => 'Situação',
'Save Approval' => 'Salvar Aprovação',
'Plan Approval' => 'Aprovação do plano',
'Observation' => 'Observação',

//Labels
'User' => 'Usuário',
Expand Down Expand Up @@ -857,6 +864,8 @@
'Users' => 'Usuários',
'manager' => 'Gestor Escolar',
'instructor' => 'Professor',
'coordinator' => 'Coordenador Pedagógico',
'nutritionist' => 'Nutricionista',
'admin' => 'Administrador',
'Edit Password' => 'Alterar Senha',

Expand Down
7 changes: 7 additions & 0 deletions app/migrations/2024-22-04_courseplan_validate/sql.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ALTER TABLE course_plan ADD COLUMN situation ENUM('APROVADO', 'PENDENTE', 'REJEITADO') NOT NULL;

ALTER TABLE course_plan ADD COLUMN start_date DATE NOT NULL;

ALTER TABLE course_plan ADD COLUMN observation VARCHAR(500);

INSERT INTO `demo.tag.ong.br`.auth_item (name,`type`,`data`) VALUES ('coordinator',2,'N;');
18 changes: 16 additions & 2 deletions app/models/CoursePlan.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,22 @@
* @property integer $users_fk
* @property string $creation_date
* @property string $fkid
* @property string $situation
* @property string $start_date
* @property string $observation
*
* The followings are the available model relations:
* @property ClassroomHasCoursePlan[] $classroomHasCoursePlans
* @property CourseClass[] $courseClasses
* @property CourseClassTypes[] $courseClassTypes
* @property Users $usersFk
* @property SchoolIdentification $schoolInepFk
* @property EdcensoStageVsModality $modalityFk
* @property EdcensoDiscipline $disciplineFk
*/
class CoursePlan extends CActiveRecord
{
public const STATUS_PENNDING = "PENDENTE";
/**
* @return string the associated database table name
*/
Expand All @@ -39,15 +44,17 @@ public function rules()
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('name, school_inep_fk, modality_fk, discipline_fk', 'required'),
array('name, school_inep_fk, modality_fk, discipline_fk, situation, start_date', 'required'),
array('modality_fk, discipline_fk, users_fk', 'numerical', 'integerOnly'=>true),
array('name', 'length', 'max'=>100),
array('school_inep_fk', 'length', 'max'=>8),
array('fkid', 'length', 'max'=>40),
array('situation', 'length', 'max'=>9),
array('observation', 'length', 'max'=>500),
array('creation_date', 'safe'),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('id, name, school_inep_fk, modality_fk, discipline_fk, users_fk, creation_date, fkid', 'safe', 'on'=>'search'),
array('id, name, school_inep_fk, modality_fk, discipline_fk, users_fk, creation_date, fkid, situation, start_date, observation', 'safe', 'on'=>'search'),
);
}

Expand All @@ -61,6 +68,7 @@ public function relations()
return array(
'classroomHasCoursePlans' => array(self::HAS_MANY, 'ClassroomHasCoursePlan', 'course_plan_fk'),
'courseClasses' => array(self::HAS_MANY, 'CourseClass', 'course_plan_fk'),
'courseClassTypes' => array(self::HAS_MANY, 'CourseClassTypes', 'course_class_fk'),
'usersFk' => array(self::BELONGS_TO, 'Users', 'users_fk'),
'schoolInepFk' => array(self::BELONGS_TO, 'SchoolIdentification', 'school_inep_fk'),
'modalityFk' => array(self::BELONGS_TO, 'EdcensoStageVsModality', 'modality_fk'),
Expand All @@ -82,6 +90,9 @@ public function attributeLabels()
'users_fk' => 'Users Fk',
'creation_date' => 'Creation Date',
'fkid' => 'Fkid',
'situation' => 'Situation',
'start_date' => 'Start Date',
'observation' => 'Observation',
);
}

Expand Down Expand Up @@ -111,6 +122,9 @@ public function search()
$criteria->compare('users_fk',$this->users_fk);
$criteria->compare('creation_date',$this->creation_date,true);
$criteria->compare('fkid',$this->fkid,true);
$criteria->compare('situation',$this->situation,true);
$criteria->compare('start_date',$this->start_date,true);
$criteria->compare('observation',$this->observation,true);

return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
Expand Down
36 changes: 36 additions & 0 deletions app/modules/courseplan/CourseplanModule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

class CourseplanModule extends CWebModule
{
public $defaultController = 'courseplan';
public $baseScriptUrl;
public $baseUrl;
public function init()
{
// this method is called when the module is being created
// you may place code here to customize the module or the application
$this->baseUrl = Yii::app()->createUrl("courseplan");

$this->baseScriptUrl = Yii::app()->getAssetManager()
->publish(Yii::getPathOfAlias('application.modules.courseplan.resources'));
// import the module-level models and components
$this->setImport(array(
'courseplan.models.*',
'courseplan.components.*',
'courseplan.controllers.*',
));
}

public function beforeControllerAction($controller, $action)
{
$controller->layout = 'webroot.themes.default.views.layouts.fullmenu';
if(parent::beforeControllerAction($controller, $action))
{
// this method is called before any module controller action is performed
// you may place customized code here
return true;
}
else
return false;
}
}
101 changes: 90 additions & 11 deletions app/controllers/CourseplanController.php → ...plan/controllers/CourseplanController.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public function accessRules()
array('allow', // allow authenticated user to perform 'create' and 'update' actions
'actions' => array('create', 'update', 'index', 'delete',
'getDisciplines', 'save', 'getCourseClasses', 'getAbilitiesInitialStructure',
'getAbilitiesNextStructure', 'addResources', 'getResources'),
'getAbilitiesNextStructure', 'addResources', 'getResources', 'pendingPlans',
'validatePlan', 'enableCoursePlanEdition'),
'users' => array('*'),
),
array('deny', // deny all users
Expand All @@ -46,15 +47,17 @@ public function accessRules()
*/
public function actionCreate()
{
$coursePlan = new CoursePlan();
if (isset($_POST['CoursePlan'])) {
$this->actionSave();
} else {
$resources = CourseClassResources::model()->findAll(array('order'=>'name'));
$this->render('form', array(
'coursePlan' => new CoursePlan(),
$this->render('create', array(
'coursePlan' => $coursePlan,
'stages' => $this->getStages(),
'resources' => $resources,
));
Yii::app()->end();
}
}

Expand All @@ -65,13 +68,16 @@ public function actionCreate()
*/
public function actionUpdate($id)
{
if (isset($_POST['CoursePlan'])) {
if (isset($_POST['CoursePlan']))
{
$this->actionSave($id);
} else {
}
if (!isset($_POST['CoursePlan']))
{
$coursePlan = $this->loadModel($id);
$resources = CourseClassResources::model()->findAll(array('order'=>'name'));

$this->render('form', array(
$this->render('update', array(
'coursePlan' => $coursePlan,
'stages' => $this->getStages(),
'resources' => $resources,
Expand Down Expand Up @@ -199,12 +205,13 @@ public function actionGetAbilitiesNextStructure()
echo CJSON::encode($result);
}


/**
* Sabe the Course Plan, and yours course classes.
*/
public function actionSave($id = null)
{
$request = Yii::app()->request->getPost("CoursePlan");

if ($id !== null) {
$coursePlan = CoursePlan::model()->findByPk($id);
$logSituation = "U";
Expand All @@ -214,7 +221,10 @@ public function actionSave($id = null)
$coursePlan->users_fk = Yii::app()->user->loginInfos->id;
$logSituation = "C";
}
$coursePlan->attributes = $_POST["CoursePlan"];
$startTimestamp = $this->dataConverter($request["start_date"], 0);
$request["start_date"] = $startTimestamp;
$coursePlan->attributes = $request;
$coursePlan->situation = 'PENDENTE';
$coursePlan->save();
$courseClassIds = [];
$i = 1;
Expand Down Expand Up @@ -290,6 +300,25 @@ public function actionAddResources(){
}
}

public static function dataConverter($data, $case)
{
// Caso 0: converte dd/mm/yyyy para yyyy-mm-dd
if($case == 0){
$dataObj = date_create_from_format('d/m/Y', $data);
if(!$dataObj == false)
return date_format($dataObj, 'Y-m-d');
}

// Caso 1: converte yyyy-mm-dd para dd/mm/yyyy
if($case == 1){
$dataObj = date_create_from_format('Y-m-d', $data);
if(!$dataObj == false)
return date_format($dataObj, 'd/m/Y');
}

return false;
}

public function actionGetResources()
{
$resources = CourseClassResources::model()->findAll();
Expand Down Expand Up @@ -323,7 +352,8 @@ public function actionDelete($id)
Log::model()->saveAction("courseplan", $id, "D", $coursePlan->name);
echo json_encode(["valid" => true, "message" => "Plano de aula excluído com sucesso!"]);
} else {
echo json_encode(["valid" => false, "message" => "Não se pode remover plano de aula utilizado em alguma turma."]);
echo json_encode(["valid" => false,
"message" => "Não se pode remover plano de aula utilizado em alguma turma."]);
}
}

Expand All @@ -333,14 +363,18 @@ public function actionDelete($id)

public function actionIndex()
{
if (Yii::app()->getAuthManager()->checkAccess('instructor', Yii::app()->user->loginInfos->id)) {
if (Yii::app()->getAuthManager()->checkAccess('instructor', Yii::app()->user->loginInfos->id))
{
$dataProvider = new CActiveDataProvider('CoursePlan', array(
'criteria' => array(
'condition' => 'users_fk=' . Yii::app()->user->loginInfos->id,
),
'pagination' => false
));
} else {
}

if(!Yii::app()->getAuthManager()->checkAccess('instructor', Yii::app()->user->loginInfos->id))
{
$dataProvider = new CActiveDataProvider('CoursePlan', array(
'pagination' => false
));
Expand All @@ -351,6 +385,51 @@ public function actionIndex()
));
}

public function actionPendingPlans()
{
$criteria = new CDbCriteria;
$criteria->condition = "situation = 'PENDENTE'";
$dataProvider = new CActiveDataProvider('CoursePlan', array(
'criteria' => $criteria,
'pagination' => false
));

$this->render('pendingPlans', array(
'dataProvider' => $dataProvider,
));
}

public function actionValidatePlan($id)
{
$requestApproval = Yii::app()->request->getPost("approval_field");
$requestObservation = Yii::app()->request->getPost("observation");
$coursePlan = $this->loadModel($id);
if(!isset($requestApproval))
{
$this->render('formValidate', array(
'coursePlan' => $coursePlan,
'stages' => $this->getStages(),
));
}
if(isset($requestApproval))
{
if ($requestApproval == "true") {
$coursePlan->situation = 'APROVADO';
}
$coursePlan->observation = $requestObservation;
$coursePlan->save();
}
}

public function actionEnableCoursePlanEdition($id)
{
$coursePlan = $this->loadModel($id);
$coursePlan->situation = 'PENDENTE';
$coursePlan->save();
Yii::app()->user->setFlash('success', Yii::t('default', 'Plano de Curso Liberado para Edição!'));
$this->redirect(array('index'));
}

/**
* 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.
Expand Down