ed-api-client 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ed_api_client-0.1.0/PKG-INFO +118 -0
- ed_api_client-0.1.0/README.md +92 -0
- ed_api_client-0.1.0/ed_api_client/__init__.py +9 -0
- ed_api_client-0.1.0/ed_api_client/assignments.py +241 -0
- ed_api_client-0.1.0/ed_api_client/canvas.py +67 -0
- ed_api_client-0.1.0/ed_api_client/challenges.py +279 -0
- ed_api_client-0.1.0/ed_api_client/client.py +272 -0
- ed_api_client-0.1.0/ed_api_client/quizzes.py +282 -0
- ed_api_client-0.1.0/ed_api_client/slides.py +233 -0
- ed_api_client-0.1.0/ed_api_client/users.py +56 -0
- ed_api_client-0.1.0/ed_api_client/websockets.py +104 -0
- ed_api_client-0.1.0/ed_api_client/workspaces.py +530 -0
- ed_api_client-0.1.0/pyproject.toml +24 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: ed-api-client
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A client for interacting with the Ed LMS
|
|
5
|
+
License: MIT
|
|
6
|
+
Author: David Milne
|
|
7
|
+
Author-email: d.n.milne@gmail.com
|
|
8
|
+
Requires-Python: >=3.6,<4.0
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Requires-Dist: DateTime (>=5.1,<6.0)
|
|
20
|
+
Requires-Dist: dataclasses (==0.6)
|
|
21
|
+
Requires-Dist: pylcs (>=0.1.1,<0.2.0)
|
|
22
|
+
Requires-Dist: python-dateutil (>=2.9.0,<3.0.0)
|
|
23
|
+
Requires-Dist: requests (>=2.31.0,<3.0.0)
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# ed-api-client
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## Getting started
|
|
31
|
+
|
|
32
|
+
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
|
33
|
+
|
|
34
|
+
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
|
35
|
+
|
|
36
|
+
## Add your files
|
|
37
|
+
|
|
38
|
+
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
|
39
|
+
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
cd existing_repo
|
|
43
|
+
git remote add origin https://gitlab.com/dmilne/ed-api-client.git
|
|
44
|
+
git branch -M main
|
|
45
|
+
git push -uf origin main
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Integrate with your tools
|
|
49
|
+
|
|
50
|
+
- [ ] [Set up project integrations](https://gitlab.com/dmilne/ed-api-client/-/settings/integrations)
|
|
51
|
+
|
|
52
|
+
## Collaborate with your team
|
|
53
|
+
|
|
54
|
+
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
|
55
|
+
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
|
56
|
+
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
|
57
|
+
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
|
58
|
+
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
|
59
|
+
|
|
60
|
+
## Test and Deploy
|
|
61
|
+
|
|
62
|
+
Use the built-in continuous integration in GitLab.
|
|
63
|
+
|
|
64
|
+
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
|
|
65
|
+
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
|
66
|
+
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
|
67
|
+
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
|
68
|
+
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
|
69
|
+
|
|
70
|
+
***
|
|
71
|
+
|
|
72
|
+
# Editing this README
|
|
73
|
+
|
|
74
|
+
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
|
75
|
+
|
|
76
|
+
## Suggestions for a good README
|
|
77
|
+
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
|
78
|
+
|
|
79
|
+
## Name
|
|
80
|
+
Choose a self-explaining name for your project.
|
|
81
|
+
|
|
82
|
+
## Description
|
|
83
|
+
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
|
84
|
+
|
|
85
|
+
## Badges
|
|
86
|
+
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
|
87
|
+
|
|
88
|
+
## Visuals
|
|
89
|
+
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
|
90
|
+
|
|
91
|
+
## Installation
|
|
92
|
+
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
|
93
|
+
|
|
94
|
+
## Usage
|
|
95
|
+
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
|
96
|
+
|
|
97
|
+
## Support
|
|
98
|
+
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
|
99
|
+
|
|
100
|
+
## Roadmap
|
|
101
|
+
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
102
|
+
|
|
103
|
+
## Contributing
|
|
104
|
+
State if you are open to contributions and what your requirements are for accepting them.
|
|
105
|
+
|
|
106
|
+
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
|
107
|
+
|
|
108
|
+
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
|
109
|
+
|
|
110
|
+
## Authors and acknowledgment
|
|
111
|
+
Show your appreciation to those who have contributed to the project.
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
For open source projects, say how it is licensed.
|
|
115
|
+
|
|
116
|
+
## Project status
|
|
117
|
+
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
|
118
|
+
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# ed-api-client
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## Getting started
|
|
6
|
+
|
|
7
|
+
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
|
8
|
+
|
|
9
|
+
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
|
10
|
+
|
|
11
|
+
## Add your files
|
|
12
|
+
|
|
13
|
+
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
|
14
|
+
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
cd existing_repo
|
|
18
|
+
git remote add origin https://gitlab.com/dmilne/ed-api-client.git
|
|
19
|
+
git branch -M main
|
|
20
|
+
git push -uf origin main
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Integrate with your tools
|
|
24
|
+
|
|
25
|
+
- [ ] [Set up project integrations](https://gitlab.com/dmilne/ed-api-client/-/settings/integrations)
|
|
26
|
+
|
|
27
|
+
## Collaborate with your team
|
|
28
|
+
|
|
29
|
+
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
|
30
|
+
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
|
31
|
+
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
|
32
|
+
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
|
33
|
+
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
|
34
|
+
|
|
35
|
+
## Test and Deploy
|
|
36
|
+
|
|
37
|
+
Use the built-in continuous integration in GitLab.
|
|
38
|
+
|
|
39
|
+
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
|
|
40
|
+
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
|
41
|
+
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
|
42
|
+
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
|
43
|
+
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
|
44
|
+
|
|
45
|
+
***
|
|
46
|
+
|
|
47
|
+
# Editing this README
|
|
48
|
+
|
|
49
|
+
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
|
50
|
+
|
|
51
|
+
## Suggestions for a good README
|
|
52
|
+
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
|
53
|
+
|
|
54
|
+
## Name
|
|
55
|
+
Choose a self-explaining name for your project.
|
|
56
|
+
|
|
57
|
+
## Description
|
|
58
|
+
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
|
59
|
+
|
|
60
|
+
## Badges
|
|
61
|
+
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
|
62
|
+
|
|
63
|
+
## Visuals
|
|
64
|
+
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
|
65
|
+
|
|
66
|
+
## Installation
|
|
67
|
+
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
|
68
|
+
|
|
69
|
+
## Usage
|
|
70
|
+
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
|
71
|
+
|
|
72
|
+
## Support
|
|
73
|
+
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
|
74
|
+
|
|
75
|
+
## Roadmap
|
|
76
|
+
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
77
|
+
|
|
78
|
+
## Contributing
|
|
79
|
+
State if you are open to contributions and what your requirements are for accepting them.
|
|
80
|
+
|
|
81
|
+
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
|
82
|
+
|
|
83
|
+
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
|
84
|
+
|
|
85
|
+
## Authors and acknowledgment
|
|
86
|
+
Show your appreciation to those who have contributed to the project.
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
For open source projects, say how it is licensed.
|
|
90
|
+
|
|
91
|
+
## Project status
|
|
92
|
+
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
from ed_api_client.slides import *
|
|
2
|
+
from ed_api_client.users import *
|
|
3
|
+
from ed_api_client.challenges import *
|
|
4
|
+
from ed_api_client.quizzes import *
|
|
5
|
+
from ed_api_client.assignments import *
|
|
6
|
+
from ed_api_client.workspaces import *
|
|
7
|
+
from ed_api_client.websockets import *
|
|
8
|
+
from ed_api_client.client import *
|
|
9
|
+
from ed_api_client.canvas import *
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from typing import List, Dict, Set
|
|
3
|
+
import datetime
|
|
4
|
+
import math
|
|
5
|
+
|
|
6
|
+
from ed_api_client import Slide, ChallengeResult, User, QuizResult, Quiz
|
|
7
|
+
from ed_api_client.challenges import ChallengeMarker, MarkType, Challenge
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass
|
|
11
|
+
class Assignment:
|
|
12
|
+
"""
|
|
13
|
+
An assignment against which students are graded
|
|
14
|
+
|
|
15
|
+
Attributes
|
|
16
|
+
----------
|
|
17
|
+
name : int
|
|
18
|
+
The name of the assignment.
|
|
19
|
+
marks : int
|
|
20
|
+
The total available marks for this assignment
|
|
21
|
+
maxScore : int
|
|
22
|
+
The maximum score that users might achieve on this assignment. This depends on the gradeType:
|
|
23
|
+
For BY_CHALLENGE this should be the number of challenges.
|
|
24
|
+
For BY_TESTCASE this should be the number of test cases accross all challenges.
|
|
25
|
+
For BY_TESTCASE_SCORE this should be the sum of all scores for all test cases across all challenges
|
|
26
|
+
gradeType: GradeType
|
|
27
|
+
The approach used for calculating grades
|
|
28
|
+
deadline: datetime
|
|
29
|
+
The default deadline beyond which submissions will be penalised.
|
|
30
|
+
lessonIds: Set[int]
|
|
31
|
+
The ids of all lessons involved in this assignment (note this is populated automatically as slides are added)
|
|
32
|
+
slideIds: Set[int]
|
|
33
|
+
The ids of all slides involved in this assignment (note this is populated automatically as slides are added)
|
|
34
|
+
challengeIds: List[int]
|
|
35
|
+
The ids of all challenges involved in this assignment (note this is populated automatically as slides are added)
|
|
36
|
+
challengeNames: List[str]
|
|
37
|
+
The names of all challenges involved in this assignment (note this is populated automatically as slides are added)
|
|
38
|
+
extensionsByStudentId: Dict[int,datetime]
|
|
39
|
+
Associates ids of students with deadlines that have been given to them (i.e. as extensions)
|
|
40
|
+
|
|
41
|
+
Methods
|
|
42
|
+
----------
|
|
43
|
+
add_slide (slide:Slide)
|
|
44
|
+
Adds a slide (usually a code challenge) to this assignment
|
|
45
|
+
add_extension (student: User, deadline:datetime)
|
|
46
|
+
Provides the given student with an extension, until the given deadline
|
|
47
|
+
get_deadline (student: Student) -> datetime
|
|
48
|
+
Returns the deadline for the given student
|
|
49
|
+
get_canvas_col ( ) -> str
|
|
50
|
+
Returns the name of the column that would match this assignment in an gradebook exported from canvas.
|
|
51
|
+
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
name: str
|
|
55
|
+
maxMarks: int
|
|
56
|
+
marker: ChallengeMarker
|
|
57
|
+
deadline: datetime.datetime
|
|
58
|
+
challenges: List[Challenge] = field(default_factory=list)
|
|
59
|
+
quizzes: List[Quiz] = field(default_factory=list)
|
|
60
|
+
extensionsByStudentId: Dict[int, datetime.datetime] = field(default_factory=dict)
|
|
61
|
+
dailyPenalty: float = 0.05
|
|
62
|
+
|
|
63
|
+
def add_challenge_slide(self, slide: Slide):
|
|
64
|
+
|
|
65
|
+
if slide.challengeId is None:
|
|
66
|
+
raise ValueError("This slide is not a code challenge")
|
|
67
|
+
|
|
68
|
+
self.challenges.append(Challenge(slide.challengeId, slide.id, slide.title))
|
|
69
|
+
|
|
70
|
+
def add_quiz_slide(self, slide: Slide, questions: list):
|
|
71
|
+
|
|
72
|
+
self.quizzes.append(Quiz(slide.id, slide.title, questions))
|
|
73
|
+
|
|
74
|
+
def add_multichoice_solution(self, questionId: int, solution: Set[int]):
|
|
75
|
+
|
|
76
|
+
for quiz in self.quizzes:
|
|
77
|
+
|
|
78
|
+
if quiz.add_multichoice_solution(questionId, solution):
|
|
79
|
+
return
|
|
80
|
+
|
|
81
|
+
print(f"could not locate multichoice question {questionId}")
|
|
82
|
+
|
|
83
|
+
def add_parsons_solution(self, questionId: int, solution: str):
|
|
84
|
+
|
|
85
|
+
for quiz in self.quizzes:
|
|
86
|
+
|
|
87
|
+
if quiz.add_parsons_solution(questionId, solution):
|
|
88
|
+
return
|
|
89
|
+
|
|
90
|
+
print(f"could not locate parsons question {questionId}")
|
|
91
|
+
|
|
92
|
+
def add_extension(self, student, deadline):
|
|
93
|
+
self.extensionsByStudentId[student.id] = deadline
|
|
94
|
+
|
|
95
|
+
def add_extensions(self, students, deadline):
|
|
96
|
+
for student in students:
|
|
97
|
+
self.extensionsByStudentId[student.id] = deadline
|
|
98
|
+
|
|
99
|
+
def get_deadline(self, student):
|
|
100
|
+
if student.id in self.extensionsByStudentId:
|
|
101
|
+
return self.extensionsByStudentId[student.id]
|
|
102
|
+
|
|
103
|
+
return self.deadline
|
|
104
|
+
|
|
105
|
+
def get_max_score(self):
|
|
106
|
+
maxScore = 0
|
|
107
|
+
for quiz in self.quizzes:
|
|
108
|
+
maxScore = maxScore + quiz.getMaxScore()
|
|
109
|
+
|
|
110
|
+
if self.marker.markType == MarkType.BY_CHALLENGE:
|
|
111
|
+
maxScore = maxScore + (
|
|
112
|
+
len(self.challenges) * self.marker.pointsPerChallenge
|
|
113
|
+
)
|
|
114
|
+
else:
|
|
115
|
+
maxScore = maxScore + self.marker.maxTestCaseScore
|
|
116
|
+
|
|
117
|
+
return maxScore
|
|
118
|
+
|
|
119
|
+
def get_canvas_col(self):
|
|
120
|
+
return "{} ({})".format(self.name, self.id)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
@dataclass
|
|
124
|
+
class AssignmentResult:
|
|
125
|
+
"""
|
|
126
|
+
Records the results of a student for an assignment.
|
|
127
|
+
|
|
128
|
+
Marks for the assignment include a 10% penalty per day if work is received late.
|
|
129
|
+
Late submissions are only considered if they improve the student's marks after the late penalty is applied.
|
|
130
|
+
|
|
131
|
+
Attributes
|
|
132
|
+
----------
|
|
133
|
+
studentId : int
|
|
134
|
+
The id of the student
|
|
135
|
+
completed : bool
|
|
136
|
+
True if the student successfully completed this assignment, otherwise false.
|
|
137
|
+
score : int
|
|
138
|
+
The score recieved by this student
|
|
139
|
+
mark : float
|
|
140
|
+
The mark recieved by this student.
|
|
141
|
+
daysLate: int
|
|
142
|
+
The number of days past the deadline that work was received and considered.
|
|
143
|
+
challengeResults: Dict[int, ChallengeResult]
|
|
144
|
+
Associates ids of challenges with their individual results
|
|
145
|
+
|
|
146
|
+
Methods
|
|
147
|
+
----------
|
|
148
|
+
add (submission:Submission, student:Student, assignment:Assignment)
|
|
149
|
+
Updates this result based on a single submission
|
|
150
|
+
finalize (assignment:Assignment, crawler: EdCrawler)
|
|
151
|
+
To be called after all submissions have been added.
|
|
152
|
+
"""
|
|
153
|
+
|
|
154
|
+
studentId: int
|
|
155
|
+
score: int = None
|
|
156
|
+
mark: float = None
|
|
157
|
+
daysLate: int = None
|
|
158
|
+
penalty: float = None
|
|
159
|
+
challengeResults: Dict[int, ChallengeResult] = field(default_factory=dict)
|
|
160
|
+
quizResults: Dict[int, QuizResult] = field(default_factory=dict)
|
|
161
|
+
|
|
162
|
+
def add_challenge_submission(self, submission, student, assignment):
|
|
163
|
+
|
|
164
|
+
deadline = assignment.get_deadline(student)
|
|
165
|
+
|
|
166
|
+
daysLate = 0
|
|
167
|
+
if submission.markedAt > deadline:
|
|
168
|
+
diff = submission.markedAt - deadline
|
|
169
|
+
daysLate = math.ceil(diff.total_seconds() / (60 * 60 * 24))
|
|
170
|
+
|
|
171
|
+
if submission.challengeId not in self.challengeResults:
|
|
172
|
+
self.challengeResults[submission.challengeId] = ChallengeResult()
|
|
173
|
+
|
|
174
|
+
self.challengeResults[submission.challengeId].add(submission, daysLate)
|
|
175
|
+
|
|
176
|
+
def add_quiz_result(self, quizResult: QuizResult):
|
|
177
|
+
self.quizResults[quizResult.quizId] = quizResult
|
|
178
|
+
|
|
179
|
+
def finalize(self, assignment: Assignment, crawler):
|
|
180
|
+
|
|
181
|
+
self.score = 0
|
|
182
|
+
self.mark = 0
|
|
183
|
+
self.daysLate = 0
|
|
184
|
+
self.penalty = 0
|
|
185
|
+
|
|
186
|
+
quizScore = 0
|
|
187
|
+
for quizResult in self.quizResults.values():
|
|
188
|
+
quizScore = quizScore + quizResult.score
|
|
189
|
+
|
|
190
|
+
if self.challengeResults is not None:
|
|
191
|
+
for challengeId, challenge in self.challengeResults.items():
|
|
192
|
+
challenge.finalize(assignment.marker, crawler)
|
|
193
|
+
|
|
194
|
+
dailyMarkPenalty = assignment.dailyPenalty * assignment.maxMarks
|
|
195
|
+
|
|
196
|
+
for daysLate in range(0, 6):
|
|
197
|
+
score = quizScore
|
|
198
|
+
|
|
199
|
+
for challengeId, challenge in self.challengeResults.items():
|
|
200
|
+
score = score + challenge.scoresByCalendarDaysLate[daysLate]
|
|
201
|
+
|
|
202
|
+
mark = assignment.maxMarks * (score / assignment.get_max_score())
|
|
203
|
+
penalty = daysLate * dailyMarkPenalty
|
|
204
|
+
mark = mark - penalty
|
|
205
|
+
if mark < 0:
|
|
206
|
+
mark = 0
|
|
207
|
+
|
|
208
|
+
if mark > self.mark:
|
|
209
|
+
self.score = score
|
|
210
|
+
self.mark = mark
|
|
211
|
+
self.daysLate = daysLate
|
|
212
|
+
self.penalty = penalty
|
|
213
|
+
|
|
214
|
+
def printSummary(self, student: User, assignment: Assignment):
|
|
215
|
+
|
|
216
|
+
msg = f"{student.name} got {self.mark:.1f}/{assignment.maxMarks} marks from {self.score}/{assignment.get_max_score()} points"
|
|
217
|
+
|
|
218
|
+
if self.daysLate > 0:
|
|
219
|
+
msg = f"{msg} and a penalty of {self.penalty:.1f} marks for submitting {self.daysLate} days late"
|
|
220
|
+
|
|
221
|
+
print(msg)
|
|
222
|
+
|
|
223
|
+
for quiz in assignment.quizzes:
|
|
224
|
+
quizResult = self.quizResults.get(quiz.id)
|
|
225
|
+
|
|
226
|
+
if quiz.id is None:
|
|
227
|
+
print(
|
|
228
|
+
f" 0/{quiz.getMaxScore()} points for "
|
|
229
|
+
+ quiz.name
|
|
230
|
+
+ " due to no attempt"
|
|
231
|
+
)
|
|
232
|
+
else:
|
|
233
|
+
quizResult.print_summary(quiz)
|
|
234
|
+
|
|
235
|
+
for challenge in assignment.challenges:
|
|
236
|
+
|
|
237
|
+
challengeResult = self.challengeResults.get(challenge.id)
|
|
238
|
+
if challengeResult is None:
|
|
239
|
+
print(f" 0 points for " + challenge.name + " due to no attempt")
|
|
240
|
+
else:
|
|
241
|
+
challengeResult.print_summary(challenge, self.daysLate)
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import csv
|
|
2
|
+
from typing import Dict
|
|
3
|
+
|
|
4
|
+
from ed_api_client import Assignment, Users, AssignmentResult
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class CanvasExporter:
|
|
8
|
+
def __init__(self, students: Users):
|
|
9
|
+
self.__students = students
|
|
10
|
+
self.__assignmentsByCol = {}
|
|
11
|
+
self.__resultsByCol = {}
|
|
12
|
+
self.__fieldNames = ["Student", "ID", "SIS User ID", "SIS Login ID", "Section"]
|
|
13
|
+
|
|
14
|
+
def addAssignment(
|
|
15
|
+
self,
|
|
16
|
+
assignment: Assignment,
|
|
17
|
+
columnName: str,
|
|
18
|
+
results: Dict[int, AssignmentResult],
|
|
19
|
+
):
|
|
20
|
+
|
|
21
|
+
self.__assignmentsByCol[columnName] = assignment
|
|
22
|
+
self.__resultsByCol[columnName] = results
|
|
23
|
+
self.__fieldNames.append(columnName)
|
|
24
|
+
return self
|
|
25
|
+
|
|
26
|
+
def generateCsv(self, sourceCsv, targetCsv):
|
|
27
|
+
|
|
28
|
+
with open(sourceCsv) as input:
|
|
29
|
+
reader = csv.DictReader(input)
|
|
30
|
+
|
|
31
|
+
with open(targetCsv, "w") as output:
|
|
32
|
+
writer = csv.DictWriter(output, fieldnames=self.__fieldNames)
|
|
33
|
+
writer.writeheader()
|
|
34
|
+
|
|
35
|
+
for inputRow in reader:
|
|
36
|
+
|
|
37
|
+
outputRow = self.handleRow(inputRow)
|
|
38
|
+
|
|
39
|
+
if outputRow is None:
|
|
40
|
+
continue
|
|
41
|
+
|
|
42
|
+
writer.writerow(outputRow)
|
|
43
|
+
|
|
44
|
+
def handleRow(self, inputRow: dict):
|
|
45
|
+
|
|
46
|
+
studentEmail = inputRow.get("SIS Login ID")
|
|
47
|
+
if studentEmail is None:
|
|
48
|
+
return None
|
|
49
|
+
|
|
50
|
+
student = self.__students.getByEmail(studentEmail.lower())
|
|
51
|
+
if student is None:
|
|
52
|
+
print(f"Could not locate student {studentEmail}")
|
|
53
|
+
return None
|
|
54
|
+
|
|
55
|
+
outputRow = {}
|
|
56
|
+
for field in ["Student", "ID", "SIS User ID", "SIS Login ID", "Section"]:
|
|
57
|
+
outputRow[field] = inputRow[field]
|
|
58
|
+
|
|
59
|
+
for col, assignment in self.__assignmentsByCol.items():
|
|
60
|
+
|
|
61
|
+
results = self.__resultsByCol.get(col, {}).get(student.id)
|
|
62
|
+
if results is None:
|
|
63
|
+
outputRow[col] = 0
|
|
64
|
+
else:
|
|
65
|
+
outputRow[col] = round(results.mark, 3)
|
|
66
|
+
|
|
67
|
+
return outputRow
|