student

package
v0.0.0-...-181bd5f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2023 License: MIT Imports: 12 Imported by: 0

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/TURMA 2019/2/A
    160140000 Thiago Veras Machado
    160140000 Giovanni Guidini
    160140000 Vitor 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,
        }...,
    ]
    

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateStudents

func CreateStudents(db *mongo.Client, api *goforces.Client, students []StudentCreate, databaseName, collectionName string) ([]user.UserCredentials, 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)

func CreateStudentsFile

func CreateStudentsFile(db *mongo.Client, request string, databaseName, collectionName string) ([]user.UserCredentials, error)

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)

func DeleteStudents

func DeleteStudents(db *mongo.Client, students []Student, databaseName, collectionName string) error

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)

func GetIndividualUserProgress

func GetIndividualUserProgress(contestsIds []int, handle, groupID string, api *goforces.Client) (interface{}, error)

func GetUserProgress

func GetUserProgress(contestsIds []int, handle string, api *goforces.Client) (interface{}, error)

func UpdateStudents

func UpdateStudents(db *mongo.Client, api *goforces.Client, student StudentUpdate, databaseName, collectionName string) error

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)

Types

type Student

type Student struct {
	ID        primitive.ObjectID `bson:"_id,omitempty"`
	ClassID   primitive.ObjectID `bson:"classid,omitempty"`
	FirstName string             `json:"firstname"`
	LastName  string             `json:"lastname"`
	Matricula string             `json:"matricula"`
	Handles   StudentHandles     `json:"handles"`
	PhotoURL  string             `json:"photourl"`
	Email     string             `json:"email"`
	Grades    StudentGrades      `json:"grades"`
}

func GetStudent

func GetStudent(db *mongo.Client, studentID primitive.ObjectID, databaseName, collectionName string) (Student, error)

func GetStudentsClass

func GetStudentsClass(db *mongo.Client, classID primitive.ObjectID, databaseName, collectionName string) ([]Student, 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

type StudentCreate

type StudentCreate struct {
	ClassID   primitive.ObjectID `bson:"classid,omitempty"`
	FirstName string             `json:"firstname"`
	LastName  string             `json:"lastname"`
	Matricula string             `json:"matricula"`
	Handles   StudentHandles     `json:"handles"`
	PhotoURL  string             `json:"photourl"`
	Email     string             `json:"email"`
	Grades    StudentGrades      `json:"grades"`
}

type StudentCreatePage

type StudentCreatePage struct {
	Result   string                 `json:"result"`
	Students []user.UserCredentials `json:"students"`
}

type StudentGrades

type StudentGrades struct {
	Exams []float64 `json:"exams"`
	Lists []float64 `json:"lists"`
}

type StudentHandles

type StudentHandles struct {
	Codeforces string `json:"codeforces"`
	Uri        string `json:"uri"`
}

type StudentInfo

type StudentInfo struct {
	ID        primitive.ObjectID `bson:"_id,omitempty"`
	ClassID   primitive.ObjectID `bson:"classid,omitempty"`
	FirstName string             `json:"firstname"`
	LastName  string             `json:"lastname"`
	Matricula string             `json:"matricula"`
	Handles   StudentHandles     `json:"handles"`
	PhotoURL  string             `json:"photourl"`
	Email     string             `json:"email"`
	Grades    StudentGrades      `json:"grades"`
}

func AuthStudent

func AuthStudent(db *mongo.Client, student user.UserCredentials, databaseName, collectionName string) (StudentInfo, error)

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

func GetStudents

func GetStudents(db *mongo.Client, databaseName, collectionName string) ([]StudentInfo, error)

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

type StudentUpdate

type StudentUpdate struct {
	ID          primitive.ObjectID `bson:"_id,omitempty"`
	Email       string             `json:"email"`
	Password    string             `json:"password"`
	NewPassword string             `json:"newpassword"`
	Handles     StudentHandles     `json:"handles"`
	PhotoURL    string             `json:"photourl"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL