Skip to content
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

Homework structure is different for normal users and admins #284

Open
laporchen opened this issue Apr 9, 2024 · 0 comments
Open

Homework structure is different for normal users and admins #284

laporchen opened this issue Apr 9, 2024 · 0 comments

Comments

@laporchen
Copy link

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: [[email protected]](mailto:[email protected])",
  "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: [[email protected]](mailto:[email protected])",
  "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: [[email protected]](mailto:[email protected])",
  "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

Back-End/model/homework.py

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)
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant