Skip to content

Commit

Permalink
update grading package
Browse files Browse the repository at this point in the history
  • Loading branch information
scott-yj-yang committed May 25, 2023
1 parent 0231fb6 commit 0dabbc3
Show file tree
Hide file tree
Showing 8 changed files with 213 additions and 111 deletions.
109 changes: 61 additions & 48 deletions CanvasGroupy/_modidx.py

Large diffs are not rendered by default.

19 changes: 15 additions & 4 deletions CanvasGroupy/grading.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
__all__ = ['bcolors', 'Grading']

# %% ../nbs/api/04_project_grading.ipynb 3
from .github import GitHubGroup
from .canvas import CanvasGroup
from . import *
import github
import canvasapi
from ast import literal_eval
Expand Down Expand Up @@ -91,6 +90,18 @@ def update_canvas_score(self,
print(f"For student: {member}, the score is {score}")
print(f"Comments: {text_comment}")

def check_graded(self,
repo:github.Repository.Repository, # target repository to grade
component:str, # The component of the project grading, let it be proposal/checkpoint/final. Need to match the issue's title
) -> bool: # Whether the repo is graded.
"Check whether a component for a group project is graded"
score = self.parse_score_from_issue(repo, component)
if score is ...:
print(f"{bcolors.WARNING}{repo.name}'s {component} Not Graded. {bcolors.ENDC}")
return False
print(f"{bcolors.OKGREEN}{repo.name}'s {component} Graded. {bcolors.ENDC}")
return True

def grade_project(self,
repo:github.Repository.Repository, # target repository to grade
component:str, # The component of the project grading, let it be proposal/checkpoint/final. Need to match the issue's title
Expand All @@ -109,8 +120,8 @@ def grade_project(self,
group_name = canvas_group_name[repo.name]
else:
group_name = repo.name
if score is ...:
print(f"{bcolors.WARNING}{group_name}'s {component} Not Graded. {bcolors.ENDC}")
graded = self.check_graded(repo, component)
if graded:
return
issue = self.fetch_issue(repo, component)
self.update_canvas_score(group_name, assignment_id, score, issue, post)
Expand Down
60 changes: 30 additions & 30 deletions nbs/api/01_GroupEng_assign.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,12 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Successfully Authenticated. GitHub account: \u001B[92m scott-yj-yang \u001B[0m\n",
"Target Organization Set: \u001B[92m COGS118A \u001B[0m\n",
"\u001B[92mAuthorization Successful!\u001B[0m\n",
"Course Set: \u001B[92m COGS 195 - Instructional Apprenticeship - Fleischer [SP23] \u001B[0m\n",
"Successfully Authenticated. GitHub account: \u001b[92m scott-yj-yang \u001b[0m\n",
"Target Organization Set: \u001b[92m COGS118A \u001b[0m\n",
"\u001b[92mAuthorization Successful!\u001b[0m\n",
"Course Set: \u001b[92m COGS 195 - Instructional Apprenticeship - Fleischer [SP23] \u001b[0m\n",
"Getting List of Users... This might take a while...\n",
"Users Fetch Complete! The course has \u001B[94m5\u001B[0m students.\n"
"Users Fetch Complete! The course has \u001b[94m5\u001b[0m students.\n"
]
}
],
Expand Down Expand Up @@ -265,41 +265,41 @@
"[3.9, None, 3.1]\n",
"[3.4, 2.1, 2.5]\n",
"[3.4, 2.1, 2.5]\n",
"In Group Set: \u001B[94mProject 1\u001B[0m,\n",
"Group \u001B[92mGroup1-SP23-Testing\u001B[0m Created!\n",
"Member \u001B[92mdol005\u001B[0m Joined group \u001B[92mGroup1-SP23-Testing\u001B[0m\n",
"Member \u001B[92mxiw013\u001B[0m Joined group \u001B[92mGroup1-SP23-Testing\u001B[0m\n",
"In Group Set: \u001B[94mProject 1\u001B[0m,\n",
"Group \u001B[92mGroup2-SP23-Testing\u001B[0m Created!\n",
"Member \u001B[92mjiz088\u001B[0m Joined group \u001B[92mGroup2-SP23-Testing\u001B[0m\n",
"Member \u001B[92mjiz100\u001B[0m Joined group \u001B[92mGroup2-SP23-Testing\u001B[0m\n",
"Member \u001B[92mnmackler\u001B[0m Joined group \u001B[92mGroup2-SP23-Testing\u001B[0m\n",
"Quiz: \u001B[92mGitHub Username\u001B[0m fetch! \n",
"In Group Set: \u001b[94mProject 1\u001b[0m,\n",
"Group \u001b[92mGroup1-SP23-Testing\u001b[0m Created!\n",
"Member \u001b[92mdol005\u001b[0m Joined group \u001b[92mGroup1-SP23-Testing\u001b[0m\n",
"Member \u001b[92mxiw013\u001b[0m Joined group \u001b[92mGroup1-SP23-Testing\u001b[0m\n",
"In Group Set: \u001b[94mProject 1\u001b[0m,\n",
"Group \u001b[92mGroup2-SP23-Testing\u001b[0m Created!\n",
"Member \u001b[92mjiz088\u001b[0m Joined group \u001b[92mGroup2-SP23-Testing\u001b[0m\n",
"Member \u001b[92mjiz100\u001b[0m Joined group \u001b[92mGroup2-SP23-Testing\u001b[0m\n",
"Member \u001b[92mnmackler\u001b[0m Joined group \u001b[92mGroup2-SP23-Testing\u001b[0m\n",
"Quiz: \u001b[92mGitHub Username\u001b[0m fetch! \n",
"Generating Student Analaysis...\n",
"[====================] 100%\n",
"\u001B[92mReport Generated!\u001B[0m\n",
"The Question asked is \u001B[94m1399692: In plain text, what is your GitHub Username? Absolutely no typo, no extra space, no hyperlink please.\u001B[0m. \n",
"\u001b[92mReport Generated!\u001b[0m\n",
"The Question asked is \u001b[94m1399692: In plain text, what is your GitHub Username? Absolutely no typo, no extra space, no hyperlink please.\u001b[0m. \n",
"Make sure this is the correct question where you asked student for their GitHub id.\n",
"If you need to change the index of columns, change the col_index argument of this call.\n",
"dol005's GitHub Username not found\n",
"xiw013's GitHub Username not found\n",
"Repo \u001B[92m Group1-SP23-Testing \u001B[0m Created... Wait for 3 sec to updates\n",
"File Successfully Renamed from \u001B[96m Checkpoint_groupXXX.ipynb \u001B[0m to \u001B[92m Checkpoint_Group1-SP23-Testing.ipynb \u001B[0m\n",
"File Successfully Renamed from \u001B[96m FinalProject_groupXXX.ipynb \u001B[0m to \u001B[92m FinalProject_Group1-SP23-Testing.ipynb \u001B[0m\n",
"File Successfully Renamed from \u001B[96m Proposal_groupXXX.ipynb \u001B[0m to \u001B[92m Proposal_Group1-SP23-Testing.ipynb \u001B[0m\n",
"Team \u001B[92m Instructors_Sp23 \u001B[0m added to \u001B[92m Group1-SP23-Testing \u001B[0m with permission \u001B[92m admin \u001B[0m\n",
"Group Repo: \u001B[92m Group1-SP23-Testing \u001B[0m successfuly created!\n",
"Repo \u001b[92m Group1-SP23-Testing \u001b[0m Created... Wait for 3 sec to updates\n",
"File Successfully Renamed from \u001b[96m Checkpoint_groupXXX.ipynb \u001b[0m to \u001b[92m Checkpoint_Group1-SP23-Testing.ipynb \u001b[0m\n",
"File Successfully Renamed from \u001b[96m FinalProject_groupXXX.ipynb \u001b[0m to \u001b[92m FinalProject_Group1-SP23-Testing.ipynb \u001b[0m\n",
"File Successfully Renamed from \u001b[96m Proposal_groupXXX.ipynb \u001b[0m to \u001b[92m Proposal_Group1-SP23-Testing.ipynb \u001b[0m\n",
"Team \u001b[92m Instructors_Sp23 \u001b[0m added to \u001b[92m Group1-SP23-Testing \u001b[0m with permission \u001b[92m admin \u001b[0m\n",
"Group Repo: \u001b[92m Group1-SP23-Testing \u001b[0m successfuly created!\n",
"Repo URL: https://github.com/COGS118A/Group1-SP23-Testing\n",
"\n",
"jiz100's GitHub Username not found\n",
"jiz088's GitHub Username not found\n",
"Repo \u001B[92m Group2-SP23-Testing \u001B[0m Created... Wait for 3 sec to updates\n",
"File Successfully Renamed from \u001B[96m Checkpoint_groupXXX.ipynb \u001B[0m to \u001B[92m Checkpoint_Group2-SP23-Testing.ipynb \u001B[0m\n",
"File Successfully Renamed from \u001B[96m FinalProject_groupXXX.ipynb \u001B[0m to \u001B[92m FinalProject_Group2-SP23-Testing.ipynb \u001B[0m\n",
"File Successfully Renamed from \u001B[96m Proposal_groupXXX.ipynb \u001B[0m to \u001B[92m Proposal_Group2-SP23-Testing.ipynb \u001B[0m\n",
"Added Collaborator: \u001B[92m nmackler \u001B[0m to: \u001B[92m Group2-SP23-Testing \u001B[0m with permission: \u001B[92m write \u001B[0m\n",
"Team \u001B[92m Instructors_Sp23 \u001B[0m added to \u001B[92m Group2-SP23-Testing \u001B[0m with permission \u001B[92m admin \u001B[0m\n",
"Group Repo: \u001B[92m Group2-SP23-Testing \u001B[0m successfuly created!\n",
"Repo \u001b[92m Group2-SP23-Testing \u001b[0m Created... Wait for 3 sec to updates\n",
"File Successfully Renamed from \u001b[96m Checkpoint_groupXXX.ipynb \u001b[0m to \u001b[92m Checkpoint_Group2-SP23-Testing.ipynb \u001b[0m\n",
"File Successfully Renamed from \u001b[96m FinalProject_groupXXX.ipynb \u001b[0m to \u001b[92m FinalProject_Group2-SP23-Testing.ipynb \u001b[0m\n",
"File Successfully Renamed from \u001b[96m Proposal_groupXXX.ipynb \u001b[0m to \u001b[92m Proposal_Group2-SP23-Testing.ipynb \u001b[0m\n",
"Added Collaborator: \u001b[92m nmackler \u001b[0m to: \u001b[92m Group2-SP23-Testing \u001b[0m with permission: \u001b[92m write \u001b[0m\n",
"Team \u001b[92m Instructors_Sp23 \u001b[0m added to \u001b[92m Group2-SP23-Testing \u001b[0m with permission \u001b[92m admin \u001b[0m\n",
"Group Repo: \u001b[92m Group2-SP23-Testing \u001b[0m successfuly created!\n",
"Repo URL: https://github.com/COGS118A/Group2-SP23-Testing\n",
"\n"
]
Expand Down
4 changes: 2 additions & 2 deletions nbs/api/03_canvas.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -829,8 +829,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"In Group Set: \u001b[94mTEST-GroupProject\u001b[0m,\n",
"Group \u001b[92mTEST-GROUP1\u001b[0m Created!\n",
"In Group Set: \u001B[94mTEST-GroupProject\u001B[0m,\n",
"Group \u001B[92mTEST-GROUP1\u001B[0m Created!\n",
"TEST-GROUP1 (122854)\n"
]
}
Expand Down
19 changes: 15 additions & 4 deletions nbs/api/04_project_grading.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
"outputs": [],
"source": [
"#| export\n",
"from CanvasGroupy.github import GitHubGroup\n",
"from CanvasGroupy.canvas import CanvasGroup\n",
"from CanvasGroupy import *\n",
"import github\n",
"import canvasapi\n",
"from ast import literal_eval"
Expand Down Expand Up @@ -140,6 +139,18 @@
" print(f\"For student: {member}, the score is {score}\")\n",
" print(f\"Comments: {text_comment}\")\n",
"\n",
" def check_graded(self,\n",
" repo:github.Repository.Repository, # target repository to grade\n",
" component:str, # The component of the project grading, let it be proposal/checkpoint/final. Need to match the issue's title\n",
" ) -> bool: # Whether the repo is graded.\n",
" \"Check whether a component for a group project is graded\"\n",
" score = self.parse_score_from_issue(repo, component)\n",
" if score is ...:\n",
" print(f\"{bcolors.WARNING}{repo.name}'s {component} Not Graded. {bcolors.ENDC}\")\n",
" return False\n",
" print(f\"{bcolors.OKGREEN}{repo.name}'s {component} Graded. {bcolors.ENDC}\")\n",
" return True\n",
"\n",
" def grade_project(self,\n",
" repo:github.Repository.Repository, # target repository to grade\n",
" component:str, # The component of the project grading, let it be proposal/checkpoint/final. Need to match the issue's title\n",
Expand All @@ -158,8 +169,8 @@
" group_name = canvas_group_name[repo.name]\n",
" else:\n",
" group_name = repo.name\n",
" if score is ...:\n",
" print(f\"{bcolors.WARNING}{group_name}'s {component} Not Graded. {bcolors.ENDC}\")\n",
" graded = self.check_graded(repo, component)\n",
" if graded:\n",
" return\n",
" issue = self.fetch_issue(repo, component)\n",
" self.update_canvas_score(group_name, assignment_id, score, issue, post)\n",
Expand Down
Loading

0 comments on commit 0dabbc3

Please sign in to comment.