Skip to content

Commit

Permalink
fixed another canvas api change
Browse files Browse the repository at this point in the history
  • Loading branch information
jabelone committed Jan 6, 2024
1 parent 2783a98 commit f4f0d37
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions memberportal/api_billing/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ def post(self, request):
canvas_api = Canvas()
except OperationalError as error:
capture_exception(error)
logger.error(error)
return Response({"success": False, "score": 0})

score = (
Expand All @@ -419,6 +420,7 @@ def post(self, request):

except Exception as e:
capture_exception(e)
logger.error(e)
return Response({"success": False, "score": 0, "error": str(e)})


Expand Down
8 changes: 4 additions & 4 deletions memberportal/services/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ def __init__(self):
def _get(self, url):
r = requests.get(
self.base_url + url,
headers={"Authorization": "Bearer " + self.api_token},
headers={"Authorization": f"Bearer {self.api_token}"},
)

return r.json()

def _query_graph(self, query):
response = requests.post(
self.graphql_url,
headers={"Authorization": "Bearer " + self.api_token},
headers={"Authorization": f"Bearer {self.api_token}"},
data=query,
)

Expand All @@ -33,9 +33,9 @@ def get_course_details(self, course_id):
:return:
"""
query = {
"query": "query MyQuery {course(id: "
"query": 'query MyQuery {course(id: "'
+ str(course_id)
+ ") {enrollmentsConnection {nodes {user {email}grades {finalScore}}}}}",
+ '") {enrollmentsConnection {nodes {user {email}grades {finalScore}}}}}',
}
return self._query_graph(query)

Expand Down

0 comments on commit f4f0d37

Please sign in to comment.