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

Subject Management #55

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Subject Management #55

wants to merge 1 commit into from

Conversation

rkjcb
Copy link
Collaborator

@rkjcb rkjcb commented Jul 1, 2021

No description provided.

@UKnowWhoIm UKnowWhoIm linked an issue Jul 1, 2021 that may be closed by this pull request
$department_code = $faculty->department_code;

if ($faculty && $faculty->isHOD()) {
$courses = Course::with(['Classroom','Subject','Faculty'])->get();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Classroom, Subject okke lower case alle vende

$classrooms = Classroom::all();
$faculties = Faculty::where('department_code',$department_code)->get();
$subjects = Subject::where('department_code',$department_code)->get();
$types = CourseTypes::getKeys();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use this enum directly in views, no need to pass from controller

$course->subject_code = $data["subject"];
// Here is room for improvement instead of again querying in database table,we can infer it from above
// message/ do we need this in the first place <<Semester>>
$course->semester = Classroom::where('id',$data["classroom"])->get('semester')->first()->semester;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use find to get by id. Classroom::find($data["classroom"])->semester

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do course need a semester as it is always linked to classroom?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, classroom was added after semester, so we do need to to think about it.
But an obvious reason for semester is Minor courses. They don't have a particular classroom.

Maybe we could make semester null for other courses, and add a getter getSemester() to Course model, which will either get from classroom or from the semester field.

Comment on lines +121 to +124
$editCourse->faculty_id=$data["faculty"];
$editCourse->classroom_id = $data["classroom"];
$editCourse->subject_code = $data["subject"];
$editCourse->type = CourseTypes::getValue($data["type"]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should all fields be updatable?
Faculty is ok, because they can be changed in between.
But subject, classroom and course_type?

* Move Course creation to model
* Javascipt function to check subject code is unique or not in client side
* Optimise Course creation
* Update method - PUT/PATCH ?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PATCH

*/
$auth_user = Auth::user();
$faculty = $auth_user->faculty;
$department_code = $faculty->department_code;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Admin can create subjects. They may no be a faculty.
Checkout faculty.store, where I encountered a similar situation

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it better that HOD's do subject creation , since subject belongs to a department

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Admin can literally do anything, admin is GOD, so don't restrict admin.

@UKnowWhoIm
Copy link
Member

@rkjcb camelCase is the convention, for almost all variable names, checkout that best practices repo.
Move your business logic to service class.
Do your authorization and validation in Requests.

@rkjcb rkjcb changed the title Subject,Course creation done. Need to complete validation and tests Subject Management Jul 2, 2021
@UKnowWhoIm
Copy link
Member

@rkjcb #61 would make some breaking changes to this PR, merge and integrate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HOD subject management
2 participants