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

Git development #368

Open
wants to merge 5 commits into
base: UAT
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions config/Migrations/20220119052635_InstitutionsExaminationsTable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
use Migrations\AbstractMigration;

class InstitutionsExaminationsTable extends AbstractMigration
{
/**
* Change Method.
*
* More information on this method is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-change-method
* @return void
*/
public function change()
{
$table = $this->table('institutions_examinations');

$table->addColumn('institution_id', 'integer', [
'default' => null,
'null' => true
]);

$table->addColumn('examination_id', 'integer', [
'default' => null,
'null' => true
]);


$table->addColumn('created', 'timestamp', [
'default' => 'CURRENT_TIMESTAMP',
'null' => false
]);

$table->addColumn('modified', 'datetime', [
'default' => null,
'null' => true
]);



$table->addForeignKey('institution_id', 'institutions', 'id', ['delete'=> 'RESTRICT', 'update'=> 'CASCADE']);
$table->addForeignKey('examination_id', 'examinations', 'id', ['delete'=> 'RESTRICT', 'update'=> 'CASCADE']);
$table->create();
}
}
Binary file added config/Migrations/schema-dump-default.lock
Binary file not shown.
15 changes: 14 additions & 1 deletion plugins/Examination/src/Model/Table/ExaminationsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ public function initialize(array $config)
$this->table('examinations');
parent::initialize($config);

$this->belongsTo('AcademicPeriods', ['className' => 'AcademicPeriod.AcademicPeriods']);
$this->belongsToMany('AcademicPeriods', ['className' => 'AcademicPeriod.AcademicPeriods']);
$this->belongsTo('EducationGrades', ['className' => 'Education.EducationGrades']);
$this->hasMany('ExaminationItems', ['className' => 'Examination.ExaminationItems', 'dependent' => true, 'cascadeCallbacks' => true]);
$this->hasMany('InstitutionExaminations', ['className' => 'Institution.InstitutionExaminations', 'dependent' => true, 'cascadeCallbacks' => true]);

$this->hasMany('ExaminationItemResults', ['className' => 'Examination.ExaminationItemResults', 'dependent' => true, 'cascadeCallbacks' => true]);
$this->belongsToMany('ExaminationCentres', [
'className' => 'Examination.ExaminationCentres',
Expand All @@ -39,6 +41,17 @@ public function initialize(array $config)
'cascadeCallbacks' => true
]);

// 19-01-2022
// $this->belongsToMany('Institutions', [
// 'className' => 'Institution.Institutions',
// 'joinTable' => 'institutions_examinations',
// 'foreignKey' => 'examination_id',
// 'targetForeignKey' => ['institution_id'],
// 'through' => 'Institution.InstitutionsExaminations',
// 'dependent' => true,
// 'cascadeCallbacks' => true
// ]);

$this->toggle('add', true);
$this->toggle('edit', true);
$this->toggle('remove', true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function initialize(array $config)
$this->belongsTo('Staff', ['className' => 'User.Users', 'foreignKey' => 'staff_id']);
$this->belongsTo('SecondaryStaff', ['className' => 'User.Users', 'foreignKey' => 'secondary_staff_id']);
$this->belongsTo('InstitutionShifts', ['className' => 'Institution.InstitutionShifts', 'foreignKey' => 'institution_shift_id']);
$this->belongsTo('Institutions', ['className' => 'Institution.Institutions', 'foreignKey' => 'institution_id']);
$this->belongsTo('Institutions', ['className' => 'Institution.Institutions', 'foreignKey' => 'institution_id']);

$this->hasMany('ClassGrades', ['className' => 'Institution.InstitutionClassGrades']);
$this->hasMany('ClassStudents', ['className' => 'Institution.InstitutionClassStudents', 'saveStrategy' => 'replace', 'cascadeCallbacks' => true]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function initialize(array $config)
parent::initialize($config);
$this->belongsTo('Users', ['className' => 'User.Users', 'foreignKey' => 'student_id']);
$this->belongsTo('Institutions', ['className' => 'Institution.Institutions']);
$this->belongsTo('AcademicPeriods', ['className' => 'AcademicPeriod.AcademicPeriods']);
$this->belongsTo('AcademicPeriods', ['className' => 'AcademicPeriod.AcademicPeriods', "foreignKey" => "Examination.academic_period_id"]);
$this->belongsTo('Examinations', ['className' => 'Examination.Examinations']);
$this->belongsTo('ExaminationCentres', ['className' => 'Examination.ExaminationCentres']);
$this->belongsTo('ExaminationCentresExaminations', [
Expand Down Expand Up @@ -208,7 +208,8 @@ public function implementedEvents()

public function beforeAction(Event $event, ArrayObject $extra)
{
$this->institutionId = $this->Session->read('Institution.Institutions.id');
// dd($this);
$this->institutionId = $this->Session->read('Institution.Institutions.id');

//work around for export button showing in pages not specified
if ($this->action != 'index') {
Expand All @@ -220,6 +221,7 @@ public function beforeAction(Event $event, ArrayObject $extra)

public function indexBeforeAction(Event $event, ArrayObject $extra)
{
dd($this);
$toolbarButtonsArray = $extra['toolbarButtons']->getArrayCopy();

if (array_key_exists('add', $toolbarButtonsArray)) {
Expand Down
104 changes: 73 additions & 31 deletions plugins/Institution/src/Model/Table/InstitutionExaminationsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,58 @@ class InstitutionExaminationsTable extends ControllerActionTable
{
public function initialize(array $config)
{
$this->table('examinations');
$this->table('examination_items');
parent::initialize($config);

$this->belongsTo('AcademicPeriods', ['className' => 'AcademicPeriod.AcademicPeriods']);
$this->belongsTo('EducationGrades', ['className' => 'Education.EducationGrades']);
$this->hasMany('ExaminationItems', ['className' => 'Examination.ExaminationItems', 'dependent' => true, 'cascadeCallbacks' => true]);
$this->hasMany('ExaminationItemResults', ['className' => 'Examination.ExaminationItemResults', 'dependent' => true, 'cascadeCallbacks' => true]);
$this->belongsTo('AcademicPeriods', [
'className' => 'AcademicPeriod.AcademicPeriods',
// 'joinTable' => 'examinations',
'targetForeignKey' => 'academic_period_id',
'through' => 'Examination.Examinations'
]);

// $this->belongsTo('EducationGrades', ['className' => 'Education.EducationGrades']);
// $this->hasMany('ExaminationItems', ['className' => 'Examination.ExaminationItems', 'foreignKey' => 'examination_id', 'dependent' => true, 'cascadeCallbacks' => true]);
// $this->hasMany('ExaminationItemResults', ['className' => 'Examination.ExaminationItemResults', 'dependent' => true, 'cascadeCallbacks' => true]);
// $this->belongsTo('ExaminationCentres', ['className' => 'Examnation.Centers', 'foreignKey' => 'examination_centre_id']);
// $this->belongsTo('Examination', ['className' => 'Examnation.Centers', 'foreignKey' => 'examination_centre_id']);
$this->belongsToMany('ExaminationCentres', [
'className' => 'Examination.ExaminationCentres',
'joinTable' => 'examination_centres_examinations',
'foreignKey' => 'examination_id',
'targetForeignKey' => 'examination_centre_id',
'through' => 'Examination.ExaminationCentresExaminations',
'dependent' => true,
'cascadeCallbacks' => true
]);
$this->belongsToMany('ExaminationCentreRooms', [
'className' => 'Examination.ExaminationCentreRooms',
'joinTable' => 'examination_centre_rooms_examinations',
'foreignKey' => 'examination_id',
'targetForeignKey' => 'examination_centre_room_id',
'through' => 'Examination.ExaminationCentreRoomsExaminations',
'dependent' => true,
'cascadeCallbacks' => true
]);

// $this->belongsTo('Examinations', ['className' => 'Examination.Examinations', "conditions" => [
// "Examinations.academic_period_id" => "AcademicPeriods.id"
// ]]);

// $this->belongsToMany('ExaminationCentres', [
// 'className' => 'Examination.ExaminationCentres',
// 'joinTable' => 'examination_centres_examinations',
// 'foreignKey' => 'examination_id',
// 'targetForeignKey' => 'examination_centre_id',
// 'through' => 'Examination.ExaminationCentresExaminations',
// 'dependent' => true,
// 'cascadeCallbacks' => true
// ]);

// $this->hasMany('ExaminationStudents', ['className' => 'Institution.InstitutionExaminationStudents', 'saveStrategy' => 'replace', 'cascadeCallbacks' => true]);

// $this->belongsToMany('Students', [
// 'className' => 'User.Users',
// 'through' => 'Institution.InstitutionExaminationStudents',
// 'foreignKey' => 'examination_id',
// 'targetForeignKey' => 'student_id',
// ]);


// $this->belongsToMany('ExaminationCentreRooms', [
// 'className' => 'Examination.ExaminationCentreRooms',
// 'joinTable' => 'examination_centre_rooms_examinations',
// 'foreignKey' => 'examination_id',
// 'targetForeignKey' => 'examination_centre_room_id',
// 'through' => 'Examination.ExaminationCentreRoomsExaminations',
// 'dependent' => true,
// 'cascadeCallbacks' => true
// ]);

$this->addBehavior('Restful.RestfulAccessControl', ['OpenEMIS_Classroom' => ['index', 'view', 'add', 'edit', 'delete'] ]);


$this->toggle('add', false);
$this->toggle('edit', false);
Expand All @@ -48,10 +73,12 @@ public function initialize(array $config)

public function indexBeforeAction(Event $event, ArrayObject $extra)
{
$extra['elements']['controls'] = ['name' => 'Institution.Examinations/controls', 'data' => [], 'options' => [], 'order' => 1];
// dd($this);
$extra['elements']['controls'] = ['name' => 'Institution.Examinations/controls', 'data' => [''], 'options' => [], 'order' => 1];

$this->field('description', ['visible' => 'hidden']);
$this->setFieldOrder(['academic_period_id', 'code', 'name', 'education_grade_id']);
$this->setFieldOrder(['code', 'name', 'education_grade_id']);
// $this->setFieldOrder(['academic_period_id', 'code', 'name', 'education_grade_id']);
}

public function indexBeforeQuery(Event $event, Query $query, ArrayObject $extra)
Expand Down Expand Up @@ -87,18 +114,33 @@ public function indexBeforeQuery(Event $event, Query $query, ArrayObject $extra)
}
}

public function viewBeforeQuery(Event $event, Query $query, ArrayObject $extra)
{
$query->contain(['ExaminationItems.EducationSubjects', 'ExaminationItems.ExaminationGradingTypes']);
}
// public function viewBeforeQuery(Event $event, Query $query, ArrayObject $extra)
// {
// $query->contain(['ExaminationItems.EducationSubjects', 'ExaminationItems.ExaminationGradingTypes']);
// }

public function viewBeforeAction(Event $event, ArrayObject $extra)
{
$this->field('examination_items', [
// $this->field('examination_items', [
// // 'type' => 'element',
// // 'element' => 'Examination.examination_items'
// ]);

$this->field('examination_students', [
// 'type' => 'element',
// 'element' => 'Examination.examination_items'

'label' => '',
'override' => true,
'type' => 'element',
'element' => 'Institution.Examinations/students',
'data' => [
'students' => [],
'studentOptions' => []
],
'visible' => ['view' => true, 'edit' => true]
]);

$this->setFieldOrder(['academic_period_id', 'code', 'name', 'description', 'education_grade_id', 'registration_start_date', 'registration_end_date', 'examination_items']);
$this->setFieldOrder(['code', 'name', 'description', 'education_grade_id', 'registration_start_date', 'registration_end_date','modified_user_id', 'modified', 'created_user_id', 'created', 'examination_students']);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
namespace Institution\Model\Table;

use ArrayObject;
use Cake\ORM\Query;
use Cake\ORM\Entity;
use Cake\ORM\Table;
use Cake\ORM\TableRegistry;
use Cake\Event\Event;
use App\Model\Table\ControllerActionTable;
use App\Model\Table\AppTable;

class InstitutionsExaminationsTable extends AppTable
{
public function initialize(array $config)
{
$this->table('institutions_examinations');
parent::initialize($config);
$this->belongsTo('Institutions', ['className' => 'Institution.Institutions', 'foreignKey' => 'institution_id' ]);
$this->belongsTo('Examinations', ['className' => 'Examination.Examinations', 'foreignKey' => 'examination_id' ]);
}
}
12 changes: 12 additions & 0 deletions plugins/Institution/src/Model/Table/InstitutionsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,18 @@ public function initialize(array $config)
'through' => 'Security.SecurityGroupInstitutions',
'dependent' => true
]);

// 19-01-2022
// $this->belongsToMany('Examinations', [
// 'className' => 'Examination.Examinations',
// 'joinTable' => 'institutions_examinations',
// 'foreignKey' => 'institution_id',
// 'targetForeignKey' => ['examination_id'],
// 'through' => 'Institution.InstitutionsExaminations',
// 'dependent' => true,
// 'cascadeCallbacks' => true
// ]);

if (Configure::read('schoolMode')) {
$this->toggle('remove', false);
} else {
Expand Down
Loading