-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
This is the object normal users got from homework query
{
"end": 1710604800,
"id": "65e2e099e55a6f38e62ee9e4",
"markdown": "Homework #0.5 供同學測試使用,沒有計分,亦不佔用金牌。\n\nIf there is any question, please let us know.\n\nEmail: [algota@noj.tw](mailto:algota@noj.tw)",
"name": "HW #0.5",
"problemIds": [
562
],
"start": 1709395200,
"studentStatus": {
"562": {
"problemStatus": null,
"score": 0,
"submissionIds": []
}
}
}And this is what admins got
{
"end": 1710604800,
"id": "65e2e099e55a6f38e62ee9e4",
"markdown": "Homework #0.5 供同學測試使用,沒有計分,亦不佔用金牌。\n\nIf there is any question, please let us know.\n\nEmail: [algota@noj.tw](mailto:algota@noj.tw)",
"name": "HW #0.5",
"problemIds": [
562
],
"start": 1709395200,
"studentStatus": {
"40711016e": {
"562": {
"problemStatus": null,
"score": 0,
"submissionIds": []
}
},
"40747008s": {
"562": {
"problemStatus": null,
"score": 0,
"submissionIds": []
}
},
// and so on......
}
}Currently frontend for homework is using the admin structure for data displaying, which breaks score displaying for normal users.
Proposed solution
I prefer user using the same structure for both roles.
We should change the structure for normal user into
{
"end": 1710604800,
"id": "65e2e099e55a6f38e62ee9e4",
"markdown": "Homework #0.5 供同學測試使用,沒有計分,亦不佔用金牌。\n\nIf there is any question, please let us know.\n\nEmail: [algota@noj.tw](mailto:algota@noj.tw)",
"name": "HW #0.5",
"problemIds": [
562
],
"start": 1709395200,
"studentStatus": {
"STUDENT_ACCOUNT": {
"562": {
"problemStatus": null,
"score": 0,
"submissionIds": []
}
}
}
}By nesting the problems status into their relative username, we could have normal users and admins sharing the same structure for homework object.
Related code
Lines 123 to 129 in b82175a
| if user.role < 2: | |
| new.update({'studentStatus': homework.student_status}) | |
| else: | |
| new.update({ | |
| 'studentStatus': | |
| homework.student_status.get(user.username) | |
| }) |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels