Created
October 10, 2024 07:24
-
-
Save alanboy/62e8645ef8efbcb4c4bdc38ec270e670 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const BEARER_TOKEN = `` | |
| const PROJECT_ID = 288; | |
| const getData = async (api) => { | |
| return new Promise((resolve, reject) => { | |
| const headers = new Headers(); | |
| headers.append("Authorization", `Bearer ${BEARER_TOKEN}`); | |
| const requestOptions = { | |
| method: "GET", | |
| headers: headers, | |
| redirect: "follow" | |
| }; | |
| const url = `https://94s1zv81nb.execute-api.us-west-2.amazonaws.com/${api}` | |
| fetch(url, requestOptions) | |
| .then((response) => response.text()) | |
| .then((result) => resolve(JSON.parse(result))) | |
| .catch(reject); | |
| }); | |
| } | |
| // Requested CSV schema: | |
| // * Username | |
| // * User Email | |
| // * Student’s Real Name | |
| // * Assignment Name | |
| // * Submission DateTime | |
| // * Score | |
| // * name of test cases and pass&fail results | |
| const main = async () => { | |
| const submissions = await getData(`/api/projects/${PROJECT_ID}/submissions`); | |
| const ranking = await getData(`/api/projects/${PROJECT_ID}/ranking/icpc`); | |
| const project = await getData(`/api/projects/${PROJECT_ID}`); | |
| for (let student of ranking) { | |
| // get all the submissions of the student | |
| const studentSubmissions = submissions.filter(submission => submission.user_id === student.user_id); | |
| console.log(`Student: ${student.username} ${student.name} ${student.email}`); | |
| for (problem of student.problems) { | |
| // Find the problem in the list of problems | |
| const problemInfo = project.problems.find(p => p.id === problem.id); | |
| // Find submisions for this problem | |
| const problemSubmissions = studentSubmissions.filter(submission => submission.problem_id === problem.id); | |
| console.log(` > ${problemInfo.id} ${problemInfo.title} ${problem.solved}`); | |
| } | |
| console.log(); | |
| } | |
| } | |
| main(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment