Skip to content

Commit

Permalink
Use new tutorial feedback API json
Browse files Browse the repository at this point in the history
  • Loading branch information
bebatut committed Jun 24, 2024
1 parent d7f811c commit 9ff0c0a
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions bin/extract_gtn_tutorials.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import shared_functions


def get_request_json(url: str, headers: dict = {}) -> dict:
def get_request_json(url: str, headers: dict = None) -> dict:
"""
Return JSON output using request
Expand Down Expand Up @@ -161,15 +161,16 @@ def get_feedback_per_tutorials() -> Dict:
"""
Get feedback from GTN API and group per tutorial
"""
feedback = get_request_json("https://training.galaxyproject.org/training-material/api/feedback.json")
feedback = get_request_json("https://training.galaxyproject.org/training-material/api/feedback2.json")
feedback_per_tuto = {}
for f in feedback:
tuto = f["tutorial"]
feedback_per_tuto.setdefault(tuto, {"number": 0, "mean note": 0})
feedback_per_tuto[tuto]["number"] += 1
feedback_per_tuto[tuto]["mean note"] += int(f["note"])
for tutorials in feedback.values():
for tuto, feedback in tutorials.items():
for f in feedback:
feedback_per_tuto.setdefault(tuto, {"number": 0, "mean rating": 0})
feedback_per_tuto[tuto]["number"] += 1
feedback_per_tuto[tuto]["mean rating"] += int(f["rating"])
for tuto in feedback_per_tuto:
feedback_per_tuto[tuto]["mean note"] /= feedback_per_tuto[tuto]["number"]
feedback_per_tuto[tuto]["mean rating"] /= feedback_per_tuto[tuto]["number"]
return feedback_per_tuto


Expand Down

0 comments on commit 9ff0c0a

Please sign in to comment.