package
0.0.0-20230509074126-181bd5fcb334
Repository: https://github.com/apc-unb/apc-api.git
Documentation: pkg.go.dev

# README

Student

Create Students

  • HTTP Request : POST http://api.com/student

  • Send student's data in the request body in the following format

    [
        {
            "classid"   :	ObjectId,
            "firstname" :	String,
            "lastname"  :	String,
            "matricula" :	String
        },...
    ]
    
  • http StatusCreated (201) will be sent if the student has been created correctly

Create Students by CSV file

  • HTTP Request : POST http://api.com/student/file

  • Send data in the request body in the following format

    ANO/SEMESTE/TURMA2019/2/A
    160140000Thiago Veras Machado
    160140000Giovanni Guidini
    160140000Vitor Dullens
    	{  
    		"file"	: file.csv,
    	},...
    
  • http StatusCreated (201) will be sent if the student has been created correctly

Get all Students

  • HTTP Request : GET http://api.com/student

  • Return a list of object in json format as follow

    [
        {
            "id"       :	ObjectId,
            "classid"   :	ObjectId,
            "firstname" :	String,
            "lastname"  :	String,
            "matricula" :	String,
            "password"  :	String,
            "handles"   :	{
                "codeforces" :	String,
                "uri" 	 :	String
            },
            "photourl"  :	String,
            "email"     :	String,
            "grades"    :	{
                "exams"     :	[]float64,
                "projects"  :	[]float64,
                "lists"     :	[]float64
            }
        },...
    ]
    

Get all Students from a class

  • HTTP Request : GET http://api.com/student/{classid}

  • Return a list of object in json format as follow

    [
        {
            "id"       :	ObjectId,
            "classid"   :	ObjectId,
            "firstname" :	String,
            "lastname"  :	String,
            "matricula" :	String,
            "password"  :	String,
            "handles"   :	{
                "codeforces" :	String,
                "uri" 	 :	String
            },
            "photourl"  :	String,
            "email"     :	String,
            "grades"    :	{
                "exams"    :	[]float64,
                "projects" :	[]float64,
                "lists"    :	[]float64
            }
        }...
    ]
    

Update Students

  • HTTP Request : PUT http://api.com/student

  • Send data in the request body in the following format

  • PS : Student can only uptade empty handles

    [
        {  
            "id".      	:   ObjectId,
            "email" 	:   String,
            "password"	:   String,
            "newpassword":   String,
            "handles"   	: 	{
                    "codeforces" :	String,
                    "uri" 	:	String
            }
        },...
    ]
    
  • http StatusCreated (201) will be sent if the student has been updated correctly

Delete Students

  • HTTP Request : DELETE http://api.com/student

  • Send data in the request body in the following format

  • PS : Only admin with Professor : True can make this request

    [
        {  
            "id" : ObjectId
        },...
    ]
    
  • http StatusOK (200) will be sent if the students have been deleted correctly

Log in Student

  • HTTP Request : POST http://api.com/student/login

        {
            "matricula" :	String,
            "password"  :	String,
        }
    
  • Return a json format as follow

    {
        "userexist"     :	Boolean,
        "student"       :	StudentInfo,
        "class"	       :	SchoolClass,
        "news"	       :	[]News,
        "Progress": {
            "done"  : String,
            "total" : String
        },
    }
    

Get Student Codeforces Progress

  • HTTP Request : GET /student/contest/{studentid}

  • Return a json format as follow

    [
        {
            "name": String,
            "url": String
            "done": String,
            "total": String,
        }...,
    ]
    

# Functions

AuthStudent recieve a student (to be authenticated) Checks if that date exist in databse Return true if exist @param db pointer to database (to be deleted) @param student student matricula and password @param databaseName name of database @param collectionName name of collection @return []bool user exist veredict @return error function error.
CreateStudents recieve a list of students Checks if that list is not null (can't insert null list) Insert each student individually in database @param db pointer to database @param students list of students @param databaseName name of database @param collectionName name of collection @return error function error TODO : Insert all students at the same time (if possible).
CreateStudentsFile recieve csv file of students Call function that parse that file and return list o students Checks if that list is not null (can't insert null list) Insert each student individually in database @param db pointer to database @param request byte array file @param databaseName name of database @param collectionName name of collection @return error function error TODO : Insert all students at the same time (if possible).
DeleteStudents recieve a list of students (to be deleted) Checks if that list is not null (can't delete null list) Delete each student individually @param db pointer to database (to be deleted) @param students list of students @param databaseName name of database @param collectionName name of collection @return []Student list of all students @return error function error TODO : Delete all students at the same time (if possible).
No description provided by the author
No description provided by the author
GetStudents return list of all students from Database Get all students at the same time and store inside cursor Decode each student inside student class and append into students array @param db pointer to database @param databaseName name of database @param collectionName name of collection @return []Student list of all students @return error function error.
GetStudentsClass return list of all students from Database thata matchs with a certain class Get all students at the same time and store inside cursor Decode each student inside student class and append into students array @param db pointer to database @param classID ID of the current class @param databaseName name of database @param collectionName name of collection @return []Student list of all students @return error function error.
No description provided by the author
UpdateStudents recieve student (updated) Checks if student old password matches with db to update that student password or email @param db pointer to database (updated) @param students list of students @param databaseName name of database @param collectionName name of collection @return StudentUpdate student new data @return error function error TODO : Update all students at the same time (if possible).

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author