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>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
<style>
* {
box-sizing: border-box;
}
body {
background-color: #f1f1f1;
}
#regForm {
background-color: #ffffff;
margin: 100px auto;
font-family: Raleway;
padding: 40px;
width: 70%;
min-width: 300px;
}
h1 {
text-align: center;
}
/* Mark input boxes that gets an error on validation: */
/* Hide all steps by default: */
.tab {
display: none;
}
button {
background-color: #04AA6D;
color: #ffffff;
border: none;
padding: 10px 20px;
font-size: 17px;
font-family: Raleway;
cursor: pointer;
}
button:hover {
opacity: 0.8;
}
#prevBtn {
background-color: #bbbbbb;
}
/* Make circles that indicate the steps of the form: */
.step {
height: 15px;
width: 15px;
margin: 0 2px;
background-color: #bbbbbb;
border: none;
border-radius: 50%;
display: inline-block;
opacity: 0.5;
}
input[type="radio"]{
vertical-align: baseline;
margin-left: 20px;
margin-bottom: 10px;
}
.step.active {
opacity: 1;
}
/* Mark the steps that are finished and valid: */
.step.finish {
background-color: #04AA6D;
}
</style>
<?php
session_start();
?>
<body>
<form id="regForm" method="POST" action="/sashi/results.php">
<!-- One "tab" for each step in the form: -->
<div class="tab">
<h4>Question 01</h4>
<p>A. Answer 01 <br>B. Answer 02 <br> C. Answer 03 <br> D. Answer 04 </p>
<label>Select Answer<span></span></label><br>
<select name="ans1" class="form-control" id="anss1">
<option value="">Select</option>
<option value="A">Answer 01</option>
<option value="B">Answer 02</option>
<option value="C">Answer 03</option>
<option value="D">Answer 04</option>
</select>
</div>
<div class="tab">
<h4>Question 02</h4>
<p>A. Answer 01 <br>B. Answer 02 <br> C. Answer 03 <br> D. Answer 04 </p>
<label>Select Answer<span></span></label><br>
<select name="ans2" class="form-control" id="anss2">
<option value="">Select</option>
<option value="A">Answer 01</option>
<option value="B">Answer 02</option>
<option value="C">Answer 03</option>
<option value="D">Answer 04</option>
</select>
</div>
<div class="tab">
<h4>Question 03</h4>
<p>A. Answer 01 <br>B. Answer 02 <br> C. Answer 03 <br> D. Answer 04 </p>
<label>Select Answer<span></span></label><br>
<select name="ans3" class="form-control" id="anss3">
<option value="">Select</option>
<option value="A">Answer 01</option>
<option value="B">Answer 02</option>
<option value="C">Answer 03</option>
<option value="D">Answer 04</option>
</select>
</div>
<div class="tab">
<h4>Question 04</h4>
<p>A. Answer 01 <br>B. Answer 02 <br> C. Answer 03 <br> D. Answer 04 </p>
<label>Select Answer<span></span></label><br>
<select name="ans4" class="form-control" id="anss4">
<option value="">Select</option>
<option value="A">Answer 01</option>
<option value="B">Answer 02</option>
<option value="C">Answer 03</option>
<option value="D">Answer 04</option>
</select>
</div>
<div class="tab">
<h4>Question 05</h4>
<p>A. Answer 01 <br>B. Answer 02 <br> C. Answer 03 <br> D. Answer 04 </p>
<label>Select Answer<span></span></label><br>
<select name="ans5" class="form-control" id="anss5">
<option value="">Select</option>
<option value="A">Answer 01</option>
<option value="B">Answer 02</option>
<option value="C">Answer 03</option>
<option value="D">Answer 04</option>
</select>
</div>
<div class="tab">
<h4>Question 06</h4>
<lab <p>A. Answer 01 <br>B. Answer 02 <br> C. Answer 03 <br> D. Answer 04 </p>
<label>Select Answer<span></span></label><br>
<select name="ans6" class="form-control" id="anss6">
<option value="">Select</option>
<option value="A">Answer 01</option>
<option value="B">Answer 02</option>
<option value="C">Answer 03</option>
<option value="D">Answer 04</option>
</select>
</div>
<div class="tab">
<h4>Question 07</h4>
<p>A. Answer 01 <br>B. Answer 02 <br> C. Answer 03 <br> D. Answer 04 </p>
<label>Select Answer<span></span></label><br>
<select name="ans7" class="form-control" id="anss7">
<option value="">Select</option>
<option value="A">Answer 01</option>
<option value="B">Answer 02</option>
<option value="C">Answer 03</option>
<option value="D">Answer 04</option>
</select>
</div>
<div class="tab">
<h4>Question 08</h4>
<p>A. Answer 01 <br>B. Answer 02 <br> C. Answer 03 <br> D. Answer 04 </p>
<label>Select Answer<span></span></label><br>
<select name="ans8" class="form-control" id="anss8">
<option value="">Select</option>
<option value="A">Answer 01</option>
<option value="B">Answer 02</option>
<option value="C">Answer 03</option>
<option value="D">Answer 04</option>
</select>
</div>
<div class="tab">
<h4>Question 09</h4>
<p>A. Answer 01 <br>B. Answer 02 <br> C. Answer 03 <br> D. Answer 04 </p>
<label>Select Answer<span></span></label><br>
<select name="ans9" class="form-control" id="anss9">
<option value="">Select</option>
<option value="A">Answer 01</option>
<option value="B">Answer 02</option>
<option value="C">Answer 03</option>
<option value="D">Answer 04</option>
</select>
</div>
<div class="tab">
<h4>Question 10</h4>
<p>A. Answer 01 <br>B. Answer 02 <br> C. Answer 03 <br> D. Answer 04 </p>
<label>Select Answer<span></span></label><br>
<select name="ans10" class="form-control" id="anss10">
<option value="">Select</option>
<option value="A">Answer 01</option>
<option value="B">Answer 02</option>
<option value="C">Answer 03</option>
<option value="D">Answer 04</option>
</select>
</div>
<div style="overflow:auto;">
<div style="float:right;">
<button type="button" id="prevBtn" onclick="nextPrev(-1)">Previous</button>
<button type="button" id="nextBtn" onclick="nextPrev(1)">Next</button>
</div>
</div>
<!-- Circles which indicates the steps of the form: -->
<div style="text-align:center;margin-top:40px;">
<span class="step"></span>
<span class="step"></span>
<span class="step"></span>
<span class="step"></span>
<span class="step"></span>
<span class="step"></span>
<span class="step"></span>
<span class="step"></span>
<span class="step"></span>
<span class="step"></span>
</div>
</form>
<script>
var currentTab = 0; // Current tab is set to be the first tab (0)
showTab(currentTab); // Display the current tab
function showTab(n) {
// This function will display the specified tab of the form...
var x = document.getElementsByClassName("tab");
x[n].style.display = "block";
//... and fix the Previous/Next buttons:
if (n == 0) {
document.getElementById("prevBtn").style.display = "none";
} else {
document.getElementById("prevBtn").style.display = "inline";
}
if (n == (x.length - 1)) {
document.getElementById("nextBtn").innerHTML = "Submit";
} else {
document.getElementById("nextBtn").innerHTML = "Next";
}
//... and run a function that will display the correct step indicator:
fixStepIndicator(n)
}
function nextPrev(n) {
// This function will figure out which tab to display
var x = document.getElementsByClassName("tab");
// Exit the function if any field in the current tab is invalid:
if (n == 1 && !validateForm()) return false;
// Hide the current tab:
x[currentTab].style.display = "none";
// Increase or decrease the current tab by 1:
currentTab = currentTab + n;
// if you have reached the end of the form...
if (currentTab >= x.length) {
// ... the form gets submitted:
document.getElementById("regForm").submit();
return false;
}
// Otherwise, display the correct tab:
showTab(currentTab);
}
function validateForm() {
// This function deals with validation of the form fields
var x, y, i, valid = true;
x = document.getElementsByClassName("tab");
y = x[currentTab].getElementsByTagName("input");
// A loop that checks every input field in the current tab:
for (i = 0; i < y.length; i++) {
// If a field is empty...
if (y[i].value == "") {
// add an "invalid" class to the field:
y[i].className += " invalid";
// and set the current valid status to false
valid = false;
}
}
// If the valid status is true, mark the step as finished and valid:
if (valid) {
document.getElementsByClassName("step")[currentTab].className += " finish";
}
return valid; // return the valid status
}
function fixStepIndicator(n) {
// This function removes the "active" class of all steps...
var i, x = document.getElementsByClassName("step");
for (i = 0; i < x.length; i++) {
x[i].className = x[i].className.replace(" active", "");
}
//... and adds the "active" class on the current step:
x[n].className += " active";
}
</script><script>
var currentTab = 0; // Current tab is set to be the first tab (0)
showTab(currentTab); // Display the current tab
function showTab(n) {
// This function will display the specified tab of the form...
var x = document.getElementsByClassName("tab");
x[n].style.display = "block";
//... and fix the Previous/Next buttons:
if (n == 0) {
document.getElementById("prevBtn").style.display = "none";
} else {
document.getElementById("prevBtn").style.display = "inline";
}
if (n == (x.length - 1)) {
document.getElementById("nextBtn").innerHTML = "Submit";
} else {
document.getElementById("nextBtn").innerHTML = "Next";
}
//... and run a function that will display the correct step indicator:
fixStepIndicator(n)
}
function nextPrev(n) {
// This function will figure out which tab to display
var x = document.getElementsByClassName("tab");
// Exit the function if any field in the current tab is invalid:
if (n == 1 && !validateForm()) return false;
// Hide the current tab:
x[currentTab].style.display = "none";
// Increase or decrease the current tab by 1:
currentTab = currentTab + n;
// if you have reached the end of the form...
if (currentTab >= x.length) {
// ... the form gets submitted:
document.getElementById("regForm").submit();
return false;
}
// Otherwise, display the correct tab:
showTab(currentTab);
}
function validateForm() {
// This function deals with validation of the form fields
var x, y, i, valid = true;
x = document.getElementsByClassName("tab");
y = x[currentTab].getElementsByTagName("input");
// A loop that checks every input field in the current tab:
for (i = 0; i < y.length; i++) {
// If a field is empty...
if (y[i].value == "") {
// add an "invalid" class to the field:
y[i].className += " invalid";
// and set the current valid status to false
valid = false;
}
}
// If the valid status is true, mark the step as finished and valid:
if (valid) {
document.getElementsByClassName("step")[currentTab].className += " finish";
}
return valid; // return the valid status
}
function fixStepIndicator(n) {
// This function removes the "active" class of all steps...
var i, x = document.getElementsByClassName("step");
for (i = 0; i < x.length; i++) {
x[i].className = x[i].className.replace(" active", "");
}
//... and adds the "active" class on the current step:
x[n].className += " active";
}
</script>
</body>
</html>
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