Compare commits
2 Commits
c5440eb931
...
16d7fe4beb
Author | SHA1 | Date | |
---|---|---|---|
16d7fe4beb | |||
632f476092 |
@ -66,7 +66,7 @@ func declareAPIAuthGradesRoutes(router *gin.RouterGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetAllGrades() (scores map[int64]map[int64]*float64, err error) {
|
func GetAllGrades() (scores map[int64]map[int64]*float64, err error) {
|
||||||
if rows, errr := DBQuery("SELECT id_user, id_survey, SUM(score)/COUNT(*) FROM student_scores GROUP BY id_user, id_survey"); err != nil {
|
if rows, errr := DBQuery("SELECT id_user, id_survey, SUM(score)/COUNT(*) FROM student_scores GROUP BY id_user, id_survey"); errr != nil {
|
||||||
return nil, errr
|
return nil, errr
|
||||||
} else {
|
} else {
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
@ -97,7 +97,7 @@ func GetAllGrades() (scores map[int64]map[int64]*float64, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s Survey) GetGrades() (scores map[int64]*float64, err error) {
|
func (s Survey) GetGrades() (scores map[int64]*float64, err error) {
|
||||||
if rows, errr := DBQuery("SELECT id_question, SUM(score)/COUNT(*) FROM student_scores WHERE id_survey=? GROUP BY id_question", s.Id); err != nil {
|
if rows, errr := DBQuery("SELECT id_question, SUM(score)/COUNT(*) FROM student_scores WHERE id_survey=? GROUP BY id_question", s.Id); errr != nil {
|
||||||
return nil, errr
|
return nil, errr
|
||||||
} else {
|
} else {
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
@ -122,7 +122,7 @@ func (s Survey) GetGrades() (scores map[int64]*float64, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s Survey) GetUserGrades(u *User) (scores map[int64]*float64, err error) {
|
func (s Survey) GetUserGrades(u *User) (scores map[int64]*float64, err error) {
|
||||||
if rows, errr := DBQuery("SELECT id_question, MAX(score) FROM student_scores WHERE id_survey=? AND id_user = ? GROUP BY id_question", s.Id, u.Id); err != nil {
|
if rows, errr := DBQuery("SELECT id_question, MAX(score) FROM student_scores WHERE id_survey=? AND id_user = ? GROUP BY id_question", s.Id, u.Id); errr != nil {
|
||||||
return nil, errr
|
return nil, errr
|
||||||
} else {
|
} else {
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
|
6
keys.go
6
keys.go
@ -95,6 +95,12 @@ func declareAPIAuthKeysRoutes(router *gin.RouterGroup) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
k2 := key
|
||||||
|
if err := k2.ReadInfos(u); err != nil {
|
||||||
|
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
k, err := u.NewKey(key.Type, key.Content)
|
k, err := u.NewKey(key.Type, key.Content)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Unable to NewKey:", err)
|
log.Println("Unable to NewKey:", err)
|
||||||
|
@ -302,7 +302,7 @@ func (s Survey) GetScore(u *User) (score *float64, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s Survey) GetScores() (scores map[int64]*float64, err error) {
|
func (s Survey) GetScores() (scores map[int64]*float64, err error) {
|
||||||
if rows, errr := DBQuery("SELECT id_user, SUM(score)/COUNT(*) FROM student_scores WHERE id_survey=? GROUP BY id_user", s.Id); err != nil {
|
if rows, errr := DBQuery("SELECT id_user, SUM(score)/COUNT(*) FROM student_scores WHERE id_survey=? GROUP BY id_user", s.Id); errr != nil {
|
||||||
return nil, errr
|
return nil, errr
|
||||||
} else {
|
} else {
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
{:then keys}
|
{:then keys}
|
||||||
{#if keys && keys.length > 0}
|
{#if keys && keys.length > 0}
|
||||||
{#each keys as keyid}
|
{#each keys as keyid}
|
||||||
{#await getKey(keyid)}
|
{#await getKey(keyid, student.id)}
|
||||||
Veuillez patienter
|
Veuillez patienter
|
||||||
{:then key}
|
{:then key}
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -51,8 +51,8 @@ export async function getKeys(userid) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getKey(kid) {
|
export async function getKey(kid, userid) {
|
||||||
const res = await fetch(`api/keys/${kid}`, {headers: {'Accept': 'application/json'}})
|
const res = await fetch(userid?`api/users/${userid}/keys/${kid}`:`api/keys/${kid}`, {headers: {'Accept': 'application/json'}})
|
||||||
if (res.status == 200) {
|
if (res.status == 200) {
|
||||||
return new Key(await res.json());
|
return new Key(await res.json());
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user