-
Notifications
You must be signed in to change notification settings - Fork 0
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
verify-student endpoint in student controller #209
Conversation
lib/dbservice/groups.ex
Outdated
@doc """ | ||
Gets group by child_id and type. | ||
Raises `Ecto.NoResultsError` if the Group does not exist. | ||
## Examples | ||
iex> get_group_by_child_id_and_type(123,"batch") | ||
%Group{} | ||
iex> get_group_by_child_id_and_type(456,"batch") | ||
** (Ecto.NoResultsError) | ||
""" | ||
def get_group_by_child_id_and_type(child_id, type) do | ||
Repo.get_by(Group, child_id: child_id, type: type) | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is already defined above where type is hardcoded. Maybe we can reuse that and also pass "batch" as argument where it was used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I have done the same in the latest commit.
key == "date_of_birth" -> | ||
user_dob = Map.get(user, String.to_existing_atom(key)) | ||
parsed_value = Date.from_iso8601!(value) | ||
Date.compare(user_dob, parsed_value) == :eq |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if user_dob
and parsed_value
are not equal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It returns false if user_dob and parsed_value are equal, and if any condition is false then the function inside Enum.all() will return false.
lib/dbservice/groups.ex
Outdated
@@ -45,16 +45,16 @@ defmodule Dbservice.Groups do | |||
end | |||
|
|||
@doc """ | |||
Gets group by child_id. | |||
Gets group by child_id and type. | |||
Raises `Ecto.NoResultsError` if the Group does not exist. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update comment also to say that error will be returned if type is wrong or does not exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I will update the comment.
post("/api/student/verify-student") | ||
|
||
parameters do | ||
body(:body, Schema.ref(:VerifyStudentRequest), "The verify student request", required: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the message to read bette. Instead of "The verify student requrest", "parameters needed for student veritication" or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I will update the message.
example(%{ | ||
student_id: "20190240808", | ||
verification_params: %{ | ||
auth_group_id: 2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we can't verify with auth group name (PunjabStudents
, DelhiStudents
, etc?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are getting auth_group_id as query param in the portal-backend from portal-frontend.
end | ||
|
||
defp get_student_and_user(student_id) do | ||
case Users.get_student_by_student_id(student_id) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it Users.get_student...
and not Students.get_student
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the Ecto query functions for User, Student and Teacher are present in this Users module.
Overview
Created a new API endpoint for verifying student information. The endpoint allows for the validation of student and user data and group-user record against provided
student_id
andauth_group_id
and other parameters.Functionality