Skip to content

Commit

Permalink
chore(reportquiz): minor update
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonbrad committed Oct 3, 2024
1 parent 7430c4a commit 41ec5da
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/report_quiz/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,16 @@ get_current_round(){
fi
}

# whether there is a ongoing competition
has_ongoing_competition() {
test $(ls ${DATABASE_DIR}/*.json | wc -l) -ne 0
}

# inform about a new round of quiz
start_quiz_competition(){
# can't start a competition if there is a ongoing one
has_ongoing_competition && return 0

message="🏆 OSSCameroon Quiz Competition, Round $(get_current_round): Submissions\n\n
QuizBot is now ready to accept submissions for the OSSCameroon Quiz Competition, Round.\n\n
Expand Down Expand Up @@ -72,7 +80,9 @@ send_quiz(){

# update quiz data based on user answers submission
fetch_quiz_user_answers(){
test $(ls ${DATABASE_DIR}/*.json | wc -l) -eq 0 && return 0
# require a ongoing competition
has_ongoing_competition || return 0

# get previous quiz user answers
user_answers=$(get_user_answers)

Expand All @@ -88,7 +98,10 @@ fetch_quiz_user_answers(){

# stop the current round of quiz
stop_quiz_competition(){
test $(ls ${DATABASE_DIR}/*.json | wc -l) -eq 0 && return 0
# require a ongoing competition
has_ongoing_competition || return 0

# enumerate quiz data
quiz_data_files=$(ls ${DATABASE_DIR}/*.json)

# stop all the active quizzes
Expand Down

0 comments on commit 41ec5da

Please sign in to comment.