-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* User Submission History and User Stats User Submission History and User Stats * Updated to include new db changes and user specific data Updated to include new db changes and user specific data * Updated Code Updated Code * Updated as per comments Updated to check user session cookie, get count from already read database and directly convert to list * Updated to handle Session changes Updated to handle statsitics even if the session changes * Updated as per @rishabhKalakoti and @ theSage21 comments Updated as per @rishabhKalakoti and @ theSage21 comments * Formatted code Formatted code * Included enchancement to submit questions through the web interface Included enchancement to submit questions through the web interface * Updated to remove the existing table and replace it with the new table Updated to remove the existing table and replace it with the new table * Updated as per changes Updated to move the dummy code to another file Updated to add proper exceptions Upudated to adddeafult date/time Updated to refer session variable directly * Updated to add support for adding Contests Updated to add support for adding Contests * Updated insert_dummy.py file Updated file to populate test data without database call and directly through POST method
- Loading branch information
Showing
8 changed files
with
313 additions
and
60 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import requests | ||
import datetime | ||
import os | ||
|
||
|
||
path = os.path.abspath(__file__) | ||
dir_path = os.path.dirname(path) | ||
question_dir = "files/questions" | ||
|
||
with requests.Session() as session: | ||
register = session.post( | ||
"http://localhost:8080/register", data={"username": "test", "password": "test"} | ||
) | ||
|
||
login = session.post( | ||
"http://localhost:8080/login", data={"username": "test", "password": "test"} | ||
) | ||
|
||
for i in range(1, 7, 1): | ||
Question1 = session.post( | ||
"http://localhost:8080/questionInput", | ||
files={ | ||
"question": open( | ||
os.path.join(question_dir, str(i), "inputs.txt"), "rb" | ||
), | ||
"answer": open(os.path.join(question_dir, str(i), "output.txt"), "rb"), | ||
}, | ||
data={"statement": str(i)}, | ||
) | ||
|
||
Contest1 = session.post( | ||
"http://localhost:8080/contestInput", | ||
data={ | ||
"code": "PRACTICE", | ||
"description": "practice questions", | ||
"start_time": datetime.datetime(day=1, month=1, year=1), | ||
"end_time": datetime.datetime(day=1, month=1, year=9999), | ||
"selection": [1, 2], | ||
}, | ||
) | ||
Contest2 = session.post( | ||
"http://localhost:8080/contestInput", | ||
data={ | ||
"code": "PASTCONTEST", | ||
"description": "somewhere in the past", | ||
"start_time": datetime.datetime(day=1, month=11, year=2018), | ||
"end_time": datetime.datetime(day=1, month=12, year=2018), | ||
"selection": [1, 2], | ||
}, | ||
) | ||
Contest3 = session.post( | ||
"http://localhost:8080/contestInput", | ||
data={ | ||
"code": "ONGOINGCONTEST", | ||
"description": "somewhere in the present", | ||
"start_time": datetime.datetime(day=1, month=4, year=2019), | ||
"end_time": datetime.datetime(day=1, month=6, year=2019), | ||
"selection": [3, 4], | ||
}, | ||
) | ||
Contest4 = session.post( | ||
"http://localhost:8080/contestInput", | ||
data={ | ||
"code": "FUTURECONTEST", | ||
"description": "somewhere in the future", | ||
"start_time": datetime.datetime(day=1, month=1, year=2020), | ||
"end_time": datetime.datetime(day=1, month=10, year=2020), | ||
"selection": [5, 6], | ||
}, | ||
) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
% include('base.html', title="Add Contest") | ||
<body> | ||
<header class="text-center"> | ||
<h1>Contest Creation Page</h1> | ||
</header> | ||
<div class="container"> | ||
</br> | ||
</br> | ||
<form action="/contestInput" method = "post" enctype = "multipart/form-data"> | ||
Contest Code : <br/> | ||
<input type="text" name="code" required /><br/><br/> | ||
Contest Description : <br/> | ||
<textarea name="description" rows = "3" cols = "80" required>Enter Description</textarea> | ||
<br/><br/> | ||
Start Time : <br/> | ||
<input name="start_time" type='date'/><br/><br/> | ||
End Time : <br/> | ||
<input name="end_time" type='date'/> | ||
<br/> | ||
<br/> | ||
</div> | ||
<div class="container text-center"> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th class="d-flex justify-content-center justify-content-center">List Of Questions</th> | ||
</tr> | ||
</thead> | ||
</table> | ||
<table class="table"> | ||
<tbody style="height:20rem;display:inline-block;overflow-y:scroll"> | ||
<tr style="font-weight:bold;"> | ||
<td style="padding-right:10rem">Question</td> | ||
<td style="padding-right:6rem">Question Statement</td> | ||
<td style="padding-right:10rem">Author</td> | ||
<td style="padding-right:8rem">Time submitted</td> | ||
<td style="padding-right:8rem">Selection</td> | ||
</tr> | ||
% for question in question_bank : | ||
<tr> | ||
<td style="padding-right:10rem"> | ||
<a href="/question/{{question['id']}}" role="button" class="btn btn-primary"> | ||
Download Question | ||
</a> | ||
</td> | ||
<td name="statement" style="padding-right:10rem">{{question["question_statement"]}}</td> | ||
<td style="padding-right:10rem">{{question["username"]}}</td> | ||
<td style="padding-right:8rem">{{question["created_date_time"].strftime("%d-%m-%Y %H:%M")}}</td> | ||
<td style="padding-right:8rem"><input type="checkbox" name="selection" value="{{question['id']}}"></td> | ||
</tr> | ||
% end | ||
</tbody> | ||
</table> | ||
<button class="btn btn-primary" type="submit">Upload</button> | ||
</form> | ||
</div> | ||
</body> | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
% include('base.html', title="Add Question") | ||
<body> | ||
<header class="text-center"> | ||
<h1>Question Upload Page</h1> | ||
</header> | ||
<div class="container"> | ||
</br> | ||
</br> | ||
<form action="/questionInput" method = "post" enctype = "multipart/form-data">Question Upload : <br/> | ||
<input type="file" name="question" required /><br/><br/> | ||
Answer Upload : <br/> | ||
<input type="file" name="answer" required /><br/><br/> | ||
Statement : <br/> | ||
<textarea name="statement" rows = "3" cols = "80" required>Enter Statement</textarea> | ||
<br/> | ||
<br/> | ||
<button class="btn btn-primary" type="submit">Upload</button> | ||
</form> | ||
</div> | ||
</body> |
Oops, something went wrong.