DiscJudge posting a "shorting answer" question
DiscJudge posting a "multiple choice"
DataStax Bulk Loader files
Uploading a .csv directly on the command line using DSBulk's execuatble
Viewing data on Astra's web dashboard
Data in Microsoft Excel
Communication with Astra database via Stargate REST API v.2.0 (Table creation, row creation, data searching in table, etc.)
Sample payload for 'question' retrieved from DataStax-Astra to local
Saving and checking logs for each instance of data uploading to Astra (Git ignored)
Interactive querying on the built-in Cassandra Query Language console.
bar.js: Deploying DCP Jobs to obtain 'Blob' data for media files
A segment of file_proc.js (renamed from 'bar.js')
DCP Worker script embedded in a Web file
Credits earned by running DCP Worker Web API
These days, people are mostly working and learning from home and Discord has recently enjoyed widespread popularity. We wanted to build a tool that caters to Discord users who are learners and who enjoy applying learnt knowledge through real examination and competition.
What it does
The Discord bot hosts rounds of quizzes/competitions, each consisting of a series of questions. Each individual user would answer multiple-choice questions by clicking on Discord message "reactions" and reply a message directly for "short answer" questions. The bot will then calculate scores based on the correctness of the reaction time, and maintain a leaderboard for all participants. Each MC question can have more than one correct answers, and all questions may be accompanied by a media file (e.g. image, gif, video, or even code excerpt).
Please take a look at the screenshots and especially the subtitles underneath each of them. They will give you a great sense of not only DiscJudge's overall structure and technologies used, but also how the components are connected to one another.
How we built it
We built the bot with the Discord.js library and a multitude of asynchronous event listeners and callbacks in Node.js.
We used DataStax-Astra, a cloud database-service based on Apache Cassandra, to store all of our data. We provisioned a keyspace, under which we set up tables (1 for each individual problem set). On each row of a table there are a question's identifier, problem statement, type (multiple choice or short answer), up to 4 choices, correct answer, type of media file, and data of media file. We interact with the database mostly using the Stargate-REST-API-v2, and occasionally with the Cassandra Driver, DataStax-Bulk-Loader (DSBulk) or directly on the webpage. Meanwhile, DiscJudge allows for the affiliation of media files to questions. Those files could not be directly stored in the Database, and so we would need to first convert any file into Binary-large-object (Blob) by generating a string containing the hexadecimal representation of the entire binary content of the file and then upload the "blob" to Astra. Whenever DiscJudge posts a question, it retrieves the "blob" of its corresponding media file from the database, decodes the hexadecimal string, and sends the file immediately after.
This is where distributed data computation and operations come in very handy. Assume that we have dozens of questions in a quiz, and that we have a 10+ second video attached to each question, the DCP API will potentially save us a significant amount of time by running "getHexRepresentation" "jobs" for all files in parallel. Similarly, we'd use DCP "jobs" on the array of contestants to calculate post-round scores and maintain the leaderboard, thereby supporting a large number of people participating simultaneously and smoothly. We would also instantiate objects of the Worker class on our local machines' Web browsers to contribute as much computing power as we can to the organization while using their resources.
What we learned
We explored a new database (DataStax-Astra) inside out and fully from blank. We studied the several ways of doing CRUD operations to Astra and querying information directly in the online interactive console using the Cassandra Query Language (CQL). To be able to store and retrieve media files, we had to discover how to express any file in base64/text or blob format and the means to convert it back to its original state. Additionally, we picked up the DCP API along the way, learning about how to deploy tasks in Node.js that can, via parallelism, help achieve huge improvement to performance--in terms of completion time.
Challenges we ran into
The major problems we encountered were all with with the Astra database. Specifically, we suspect that some parts of their "search" endpoints were not behaving as they were documented, as they don't seem to parse the headers within the requests correctly and continually sent 4XX failure status back. Further, we observed miscellaneous issues uploading Blobs as those strings must be changed into a specific format to be accepted by Cassandra storage and that sometimes their "key length" might exceed the designated upper limit:
No customer support agent for Astra work on weekends, and so we had no choice but to dig our way through the immense documentation or to search on Stack Overflow to find resolutions to all issues.
Accomplishments that we're proud of
What's next for DiscJudge
We will strive to enable more commands and interactive features on the Discord bot, and to conduct highly comprehensive and thorough testing to ensure all users will have a seamless experience using it.