Commit e7356076 authored by Pathirana I.P.H.S.Y's avatar Pathirana I.P.H.S.Y

Update user evaluation system/eve.py, user evaluation system/reg.py, user...

Update user evaluation system/eve.py, user evaluation system/reg.py, user evaluation system/results.php, user evaluation system/rues.php files
parent d96c00e9
import mysql.connector
import sys
from datetime import datetime
conn = mysql.connector.connect(host="localhost", port="3306", user="root", password="", database="umc")
cursor = conn.cursor()
ans1 = sys.argv[1]
ans2 = sys.argv[2]
ans3 = sys.argv[3]
ans4 = sys.argv[4]
ans5 = sys.argv[5]
ans6 = sys.argv[6]
ans7 = sys.argv[7]
ans8 = sys.argv[8]
ans9 = sys.argv[9]
ans10 = sys.argv[10]
counts = 0
if ans1 == 'A':
counts = counts+1
else:
counts = counts
if ans2 == 'B':
counts = counts+1
else:
counts = counts
if ans3 == 'A':
counts = counts+1
else:
counts = counts
if ans4 == 'C':
counts = counts+1
else:
counts = counts
if ans5 == 'D':
counts = counts+1
else:
counts = counts
if ans6 == 'B':
counts = counts+1
else:
counts = counts
if ans7 == 'D':
counts = counts+1
else:
counts = counts
if ans8 == 'C':
counts = counts+1
else:
counts = counts
if ans9 == 'B':
counts = counts+1
else:
counts = counts
if ans10 == 'A':
counts = counts+1
else:
counts = counts
global score , grade
score = int((counts / 10 * 100))
grade = ""
if score >= 75:
grade = "VVIP"
elif score >= 50 and score < 75:
grade = "VIP"
elif score >= 25 and score < 50:
grade = "Gold"
elif score < 25:
grade = "Silver"
print(grade)
score1 = str(score)
now = datetime.now()
username = now.strftime("%Y-%m-%d-%H-%M-%S")
sql = "INSERT INTO member (username,mtype,mvalue) VALUES ('"+username+"','"+grade+"','"+score1+"')"
cursor.execute(sql)
conn.commit()
\ No newline at end of file
import mysql.connector
conn = mysql.connector.connect(host="localhost", port="3306", user="root", password="", database="umc")
cursor = conn.cursor()
def userInfo():
global username
username = input("Enter Username: ")
select1 = "select count(username) from member where username = '"+username+"'"
cursor.execute(select1)
records1 = cursor.fetchall()
for row in records1:
name = row[0]
if name == 1:
print("User already exists!")
userInfo()
else:
sql = "INSERT INTO member (username) VALUES ('"+username+"')"
cursor.execute(sql)
conn.commit()
print("\n" + "------------------------------")
print("user created successfully")
def new_game():
guesses = []
correct_guesses = 0
question_number = 1
for key in questions:
print("------------------------------")
print(key)
for i in options[question_number-1]:
print(i)
guess = input("Enter (A, B, C or D): ")
guess = guess.upper()
guesses.append(guess)
correct_guesses += check_answer(questions.get(key), guess)
question_number += 1
display_score(correct_guesses, guesses)
def check_answer(answer, guess):
if answer == guess:
print("CORRECT!")
return 1
else:
print("Wrong!")
return 0
def display_score(correct_guesses, guesses):
print("--------------------------")
print ("RESULTS")
print("--------------------------")
print("Answers: ", end="")
for i in questions:
print(questions.get(i), end=" ")
print()
print("Guesses: ", end="")
for i in guesses:
print(i, end=" ")
print()
global score , grade
score = int((correct_guesses / len(questions)) * 100)
grade = ""
if score >= 75:
grade = "VVIP"
elif score >= 50 and score < 75:
grade = "VIP"
elif score >= 25 and score < 50:
grade = "Gold"
elif score < 25:
grade = "Silver"
print("Congratulations! Based on your response, we identified you as a "+grade+" member!")
#dictionary
questions = {
"Who created python?: ": "A",
"What year was python created?: ": "B",
"Python is tributed to which comedy group?: ": "C",
"Is the Earth round?: ": "A"
}
#2D list
options = [["A. Guido Van Rossum", "B. Elon Musk", "C. Bill Gates", "D. Mark Zuckerburg"],
["A. 1989", "B. 1991", "C. 2000", "D. 2016"],
["A. Lonely Island", "B. Smosh", "C. Monty Python", "D. SNL"],
["A. True", "B. False", "C. Sometimes", "D. What's Earth"]]
userInfo()
new_game()
print("Thank you for your response!")
def insertData():
score1 = str(score)
sql = "UPDATE member SET mtype = '"+grade+"',mvalue = '"+score1+"' WHERE username = '"+username+"' "
cursor.execute(sql)
conn.commit()
insertData()
\ No newline at end of file
<style>
.bg {
background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url("/umc/img/prediction.jpg");
height: 50%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
}
.hero-text {
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
}
.testbox{
position: relative;
background: #fff;
border-radius: 10px;
height: 45vh;
width: 25vw;
padding-right: 70px;
padding-left: 70px;
}
.main{
margin: 0;
padding: 0;
box-sizing: border-box;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background: linear-gradient(45deg, greenyellow, dodgerblue);
font-family: "Sansita Swashed", cursive;
}
.item{
margin-top: 50px;
}
.form-control{
float: right;
width: 200px;
margin-left: 30px;
border: 2px solid #000;
padding:8px;
color:black;
background:white;
border-radius: 10px;
}
.button{
padding:15px;
background: dodgerblue;
color: #fff;
border: #fff;
border-radius: 10px;
margin-top: 40px;
}
.button:hover{
background: linear-gradient(45deg, greenyellow, dodgerblue);
}
</style>
<?php
$results=array("");
if (isset($_POST['ans1'], $_POST['ans2'], $_POST['ans3'], $_POST['ans4'], $_POST['ans5'], $_POST['ans6'], $_POST['ans7'], $_POST['ans8'], $_POST['ans9'], $_POST['ans10'])) {
$ans1=$_POST['ans1'];
$ans2 = $_POST['ans2'];
$ans3 = $_POST['ans3'];
$ans4 = $_POST['ans4'];
$ans5 = $_POST['ans5'];
$ans6 = $_POST['ans6'];
$ans7 = $_POST['ans7'];
$ans8 = $_POST['ans8'];
$ans9 = $_POST['ans9'];
$ans10 = $_POST['ans10'];
$output = shell_exec("python eve.py $ans1 $ans2 $ans3 $ans4 $ans5 $ans6 $ans7 $ans8 $ans9 $ans10");
$results= (explode(",",$output));
}
?>
<div class="main">
<div class="testbox">
<p align="center" style="margin-top: 130px">Congratulations! Based on your response, we identified you as a <?php echo $results[0]; ?> member!
Thank you for your response!</p>
</div>
</div>
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment