This commit is contained in:
Micik2 2019-01-09 12:48:07 +01:00
parent e6bd0311ee
commit b5a26a5891
8 changed files with 987 additions and 50 deletions

354
app.py
View File

@ -1,4 +1,4 @@
from flask import Flask, render_template, request, json, session, redirect, Blueprint, url_for, flash, Response, send_from_directory
from flask import Flask, render_template, request, json, session, redirect, Blueprint, url_for, flash, Response, send_from_directory, stream_with_context, g
from flask_wtf import Form
from wtforms.fields import StringField, SubmitField
from wtforms.validators import Required
@ -18,8 +18,13 @@ from httplib2 import Http
from oauth2client.service_account import ServiceAccountCredentials
import os
from werkzeug.utils import secure_filename
# from camera import VideoCamera
from camera import VideoCamera
import pyaudio
import sqlite3
from flask_mail import Mail, Message
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.header import Header
main = Blueprint('main', __name__)
@ -31,6 +36,18 @@ socketio = SocketIO()
app.register_blueprint(main)
socketio.init_app(app)
me = "wirtualna.uczelnia.2018@gmail.com"
my_password = "korniszon"
app.config.update(MAIL_SERVER = "smtp.gmail.com",
MAIL_PORT = 465,
MAIL_USE_SSL = True,
MAIL_USERNAME = "wirtualna.uczelnia.2018@gmail.com",
MAIL_PASSWORD = "korniszon")
mail = Mail(app)
# MySQL configurations
#app.config['MYSQL_DATABASE_USER'] = 'root'
#app.config['MYSQL_DATABASE_PASSWORD'] = 'localhost'
@ -43,6 +60,10 @@ UPLOAD_FOLDER = './uploads'
ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'])
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
DATABASE = 'database.db'
# connection = sqlite3.connect(DATABASE, isolation_level = None)
def allowed_file(filename):
return '.' in filename and \
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
@ -167,8 +188,8 @@ def signUp():
cursor = conn.cursor()
#_hashed_password = generate_password_hash(_password)
args = (_login, _password)
cursor.execute("INSERT into Users(login, password) values(%s, %s)", args)
args = (_login, _password,)
cursor.execute("INSERT into Users(login, password) values(?, ?)", args)
data = cursor.fetchall()
if len(data) is 0:
@ -198,8 +219,8 @@ def signUpENG():
cursor = conn.cursor()
#_hashed_password = generate_password_hash(_password)
args = (_login, _password)
cursor.execute("INSERT into Users(login, password) values(%s, %s)", args)
args = (_login, _password,)
cursor.execute("INSERT into Users(login, password) values(?, ?)", args)
data = cursor.fetchall()
if len(data) is 0:
@ -236,40 +257,31 @@ def validateLogin():
session['user'] = gmail_username + "@gmail.com" #.split('@')[0]
else:
session["user"] = gmail_username
return render_template('userHome.html', user=session['user'].split('@')[0], calendar_src="https://calendar.google.com/calendar/embed?src=" + session.get("user"))
except:
if "wirtualna.uczelnia.2018" in gmail_username:
session["role"] = "admin"
else:
session["role"] = "user"
connection = sqlite3.connect('database.db', isolation_level = None)
cur = connection.cursor()
cursor = cur.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='tests'")
results = cursor.fetchall()
if results is not None and session["role"] == "admin" and len(results) != 0:
cursor = cur.execute("SELECT title from tests")
results = cursor.fetchone()
if results is not None and len(results) != 0:
test = True
else:
test = False
else:
test = False
connection.close()
return render_template('userHome.html', user=session['user'].split('@')[0], calendar_src="https://calendar.google.com/calendar/embed?src=" + session.get("user"), test = test)
# else:
# return render_template('error.html',error = 'Zły email lub hasło!')
except smtplib.SMTPAuthenticationError:
return render_template('error.html',error = 'Zły email lub hasło!')
'''
con = mysql.connect()
cursor = con.cursor()
#cursor.callproc('logowanie',(_username,))
args = (_username, _password)
query = "SELECT * from Users where login = %s and password = %s"
cursor.execute(query, args)
data = cursor.fetchall()
if len(data) > 0:
#if check_password_hash(str(data[0][3]),_password):
#if str(data[0][3]) == _password:
if str(data[0][1]) == _password:
session['user'] = data[0][0]
#return redirect('/userHome', user=session['user'])
return render_template('userHome.html', user=session['user'])
else:
return render_template('error.html',error = 'Zły email lub hasło!')
else:
return render_template('error.html',error = 'Zły email lub hasło!')
except Exception as e:
return render_template('error.html',error = str(e))
finally:
if cursor:
cursor.close()
if con:
con.close()
'''
@app.route('/validateLoginENG',methods=['POST'])
def validateLoginENG():
@ -286,7 +298,7 @@ def validateLoginENG():
server.ehlo()
server.login(gmail_username, gmail_password)
session['user'] = gmail_username#.split('@')[0]
return render_template('userHomeENG.html', user=gmail_username.split('@')[0])
return render_template('userHomeENG.html', user=gmail_username.split('@')[0], test = False)
except:
return render_template('errorENG.html',error = 'Wrong email or password!')
@ -295,7 +307,7 @@ def validateLoginENG():
cursor = con.cursor()
#cursor.callproc('logowanie',(_username,))
args = (_username, _password)
query = "SELECT * from Users where login = %s and password = %s"
query = "SELECT * from Users where login = ? and password = ?"
cursor.execute(query, args)
data = cursor.fetchall()
@ -323,20 +335,30 @@ def validateLoginENG():
@app.route('/userHome')
def userHome():
if session.get('user'):
return render_template('userHome.html', user=session['user'].split('@')[0], calendar_src="https://calendar.google.com/calendar/embed?src=" + session.get("user"))
connection = sqlite3.connect('database.db', isolation_level = None)
cur = connection.cursor()
cursor = cur.execute("SELECT title from tests")
results = cursor.fetchall()
connection.close()
if len(results) != 0:
test = True
else:
test = False
return render_template('userHome.html', user=session['user'].split('@')[0], calendar_src="https://calendar.google.com/calendar/embed?src=" + session.get("user"), test = test)
else:
return render_template('error.html',error = 'Nieautoryzowany dostęp!')
@app.route('/userHomeENG')
def userHomeENG():
if session.get('user'):
return render_template('userHomeENG.html', user=session['user'].split('@')[0])
return render_template('userHomeENG.html', user=session['user'].split('@')[0], test = False)
else:
return render_template('errorENG.html',error = 'Unauthorized access!')
@app.route('/logout')
def logout():
session.pop('user',None)
session.pop('user', None)
session.pop('role', None)
return redirect('/')
@app.route('/logoutENG')
@ -533,7 +555,21 @@ def signInWithFace():
# When everything is done, release the capture
video_capture.release()
cv2.destroyAllWindows()
return render_template('userHome.html', info="Zapisano twarz", user=session.get('user').split('@')[0], calendar_src="https://calendar.google.com/calendar/embed?src=" + session.get("user"))
connection = sqlite3.connect('database.db', isolation_level = None)
cur = connection.cursor()
cursor = cur.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='tests")
results = cursor.fetchall()
connection.close()
if len(results) != 0:
cursor = cur.execute("SELECT title from tests")
results = cursor.fetchone()
if len(results) != 0:
test = True
else:
test = False
else:
test = False
return render_template('userHome.html', info="Zapisano twarz", user=session.get('user').split('@')[0], calendar_src="https://calendar.google.com/calendar/embed?src=" + session.get("user"), test = test)
@app.route('/signInWithFaceENG')
def signInWithFaceENG():
@ -599,7 +635,7 @@ def signInWithFaceENG():
# When everything is done, release the capture
video_capture.release()
cv2.destroyAllWindows()
return render_template('userHomeENG.html', info="A face has been saved", user=session.get('user').split('@')[0])
return render_template('userHomeENG.html', info="A face has been saved", user=session.get('user').split('@')[0], test = False)
@app.route('/addEvent', methods=['POST'])
def addEvent():
@ -654,7 +690,21 @@ def addEvent():
creds = tools.run_flow(flow, store)
service = build('calendar', 'v3', http=creds.authorize(Http()))
service.events().insert(calendarId='primary', body=event).execute()
return render_template('userHome.html', user=session['user'].split('@')[0], calendar_src="https://calendar.google.com/calendar/embed?src=" + session.get("user"))
connection = sqlite3.connect('database.db', isolation_level = None)
cur = connection.cursor()
cursor = cur.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='tests")
results = cursor.fetchall()
connection.close()
if len(results) != 0:
cursor = cur.execute("SELECT title from tests")
results = cursor.fetchone()
if len(results) != 0:
test = True
else:
test = False
else:
test = False
return render_template('userHome.html', user=session['user'].split('@')[0], calendar_src="https://calendar.google.com/calendar/embed?src=" + session.get("user"), test = test)
@app.route('/streaming')
def streaming():
@ -733,7 +783,21 @@ def resources():
#file = request.form["fileToUpload"]
filename = secure_filename(file.filename)
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
return render_template('userHome.html', user=session['user'].split('@')[0], calendar_src="https://calendar.google.com/calendar/embed?src=" + session.get("user"))
connection = sqlite3.connect('database.db', isolation_level = None)
cur = connection.cursor()
cursor = cur.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='tests")
results = cursor.fetchall()
connection.close()
if len(results) != 0:
cursor = cur.execute("SELECT title from tests")
results = cursor.fetchone()
if len(results) != 0:
test = True
else:
test = False
else:
test = False
return render_template('userHome.html', user=session['user'].split('@')[0], calendar_src="https://calendar.google.com/calendar/embed?src=" + session.get("user"), test = False)
else:
return redirect(url_for('toResources'))
@ -834,9 +898,201 @@ def downloadResource():
else:
return render_template('error.html',error = 'Nieautoryzowany dostęp!')
'''
@app.route('/create_test', methods = ["GET", "POST"])
def create_test():
if session["role"] == "admin":
test_name = request.form["inputTestName"]
users = request.form["inputUsers"]
splitted_users = users.split(",")
emails = []
for splitted_user in splitted_users:
if "@gmail.com" not in splitted_user:
emails.append(splitted_user.strip() + "@gmail.com")
else:
emails.append(splitted_user.strip())
# msg = Message("Zostałeś przydzielony do nowego testu",
# sender = "wirtualna.uczelnia.2018@gmail.com",
# recipients = emails)
print(users)
# msg.body = "Link do testu:\n" + "http://150.254.78.161:5000/solve_test/1"
# msg.body = "Pojawił się nowy test, zaloguj się i go rozwiąż:\n" + "http://150.254.78.161:5000/showSignIn"
# msg = MIMEMultipart('alternative')
# msg.set_charset('utf8')
# msg['Subject'] = Header("Zostałeś przydzielony do nowego testu", "utf-8")
# msg['From'] = me
# html = "Pojawił się nowy test, zaloguj się i go rozwiąż:\n" + "http://150.254.78.161:5000/showSignIn"
# part2 = MIMEText(html, 'html', _charset="UTF-8")
# msg.attach(part2)
# s = smtplib.SMTP_SSL('smtp.gmail.com')
# s.login(me, my_password)
# for email in emails:
# msg['To'] = email
# s.sendmail(me, email, msg.as_string())
# mail.send(msg)
msg = mail.send_message(
'Zostałeś przydzielony do nowego testu',
sender='wirtualna.uczelnia.2018@gmail.com',
recipients=emails,
body="Pojawił się nowy test, zaloguj się i go rozwiąż:\n" + "http://150.254.78.161:5000/showSignIn"
)
connection = sqlite3.connect('database.db', isolation_level = None)
cur = connection.cursor()
cur.execute('DROP TABLE IF EXISTS tests')
cur.execute('DROP TABLE IF EXISTS questions')
cur.execute('DROP TABLE IF EXISTS users')
cur.execute('DROP TABLE IF EXISTS results')
cur.execute('CREATE TABLE tests (title TEXT PRIMARY KEY)')
cur.execute('CREATE TABLE users (nickname TEXT PRIMARY KEY)')
cur.execute('CREATE TABLE questions (id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, answer_a TEXT, answer_b TEXT, answer_c TEXT, answer_d TEXT, correct_answer TEXT)')
cur.execute('CREATE TABLE results (nickname TEXT PRIMARY KEY, points INTEGER)')
print (test_name)
cur.execute('INSERT INTO tests(title) values(?)', (test_name,))
for splitted_user in splitted_users:
user = splitted_user.split("@")
cur.execute('INSERT INTO users values(?)', (user[0].strip(),))
cursor = cur.execute('SELECT * from tests')
connection.close()
# return render_template("add_question.html", test_title = test_name)
return redirect("show_test_owner")
else:
return render_template("error.html", error = "Brak dostępu!")
@app.route("/show_test_owner")
def show_test_owner():
connection = sqlite3.connect('database.db', isolation_level = None)
cur = connection.cursor()
cursor = cur.execute("SELECT title from tests")
test_name = cursor.fetchone()
connection.close()
return render_template("add_question.html", test_title = test_name[0])
@app.route('/add_question', methods = ["POST"])
def add_question():
if session["role"] == "admin":
if request.form["submit"] == "Dodaj kolejne pytanie":
name = request.form["inputTitle"]
answer_a = request.form["inputA"]
answer_b = request.form["inputB"]
answer_c = request.form["inputC"]
answer_d = request.form["inputD"]
correct_answer = request.form["inputCorrect"]
connection = sqlite3.connect('database.db', isolation_level = None)
cur = connection.cursor()
cur.execute("INSERT INTO questions(title, answer_a, answer_b, answer_c, answer_d, correct_answer) values(?, ?, ?, ?, ?, ?)", (name, answer_a, answer_b, answer_c, answer_d, correct_answer,))
connection.close()
return redirect("show_test_owner")
elif request.form["submit"] == "Zatwierdź test":
name = request.form["inputTitle"]
answer_a = request.form["inputA"]
answer_b = request.form["inputB"]
answer_c = request.form["inputC"]
answer_d = request.form["inputD"]
correct_answer = request.form["inputCorrect"]
connection = sqlite3.connect('database.db', isolation_level = None)
cur = connection.cursor()
print (name)
# print (answer_a)
# print (correct_answer)
cursor = cur.execute("INSERT INTO questions(title, answer_a, answer_b, answer_c, answer_d, correct_answer) values(?, ?, ?, ?, ?, ?)", (name, answer_a, answer_b, answer_c, answer_d, correct_answer,))
cursor = cur.execute("SELECT * from questions")
print (cursor.fetchone())
# print (cursor)
# connection.close()
return render_template("userHome.html", user=session['user'].split('@')[0], calendar_src="https://calendar.google.com/calendar/embed?src=" + session.get("user"), test = True)
else:
return render_template("error.html", error = "Brak dostępu!")
@app.route("/show_test", methods = ["GET", "POST"])
def show_test():
connection = sqlite3.connect('database.db', isolation_level = None)
cur = connection.cursor()
cursor = cur.execute("SELECT nickname from results")
users = cursor.fetchall()
# if session["user"] + "@gmail.com" in users:
print (users)
if (session["user"].split("@")[0],) not in users:
cursor = cur.execute("SELECT * from questions")
questions = cursor.fetchall()
print (questions)
cursor = cur.execute("SELECT title from tests")
title = cursor.fetchone()
print (title)
connection.close()
return render_template("test.html", questions = questions, test = title[0])
else:
return render_template("error.html", error = "Nie możesz wypełnić tego testu!")
@app.route("/test", methods = ["POST"])
def test():
# if session["role"] == "admin":
# return render_template("end_test_owner.html")
# if session["user"] in users:
if session["role"] == "user":
points = 0
answers = []
connection = sqlite3.connect('database.db', isolation_level = None)
cursor = connection.execute('SELECT correct_answer from questions')
correct_answers = cursor.fetchall()
for i in range(len(correct_answers)):
answers.append(request.form["inputAnswer"+str(i)])
print (correct_answers)
for j in range(len(correct_answers)):
if answers[j] == correct_answers[j][0]:
points += 1
cursor.execute("INSERT INTO results values(?, ?)", (session["user"].split("@")[0], points))
connection.close()
if points == 1:
sentence = "punkt"
elif points == 2 or points == 3 or points == 4:
sentence = "punkty"
elif points > 4 or points == 0:
sentence = "punktów"
return render_template("userHome.html", user=session['user'].split('@')[0] + ". Twój wynik wyniósł " + str(points) + sentence, calendar_src="https://calendar.google.com/calendar/embed?src=" + session.get("user"), test = False)
# if answer == correct_answer:
# cursor = connection.execute('SELECT points from results where nickname = ?', session["user"])
# points = cursor.fetchone()
# connection.execute('UPDATE TABLE results SET points = ?', points + 1)
# connection.close()
# if question_number != count_questions:
# return redirect(url_for("solve_test", question_number + 1))
# else:
# return render_template("end_test.html", points = points)
else:
return render_template("error.html", error = "Brak dostępu!")
@app.route("/end_test", methods = ["GET", "POST"])
def end_test():
connection = sqlite3.connect('database.db', isolation_level = None)
cur = connection.cursor()
if session["role"] == "admin":
cursor = cur.execute('SELECT MAX(points), nickname from results group by nickname')
results = cursor.fetchall()
cur.execute('DROP TABLE IF EXISTS tests')
cur.execute('DROP TABLE IF EXISTS questions')
cur.execute('DROP TABLE IF EXISTS users')
cur.execute('DROP TABLE IF EXISTS results')
connection.close()
if len(results) != 0:
print (results)
if results[0][0] == 1:
sentence = "punkt, a uzyskał go: "
elif results[0][0] == 2 or results[0][0] == 3 or results[0][0] == 4:
sentence = "punkty, a uzyskał go: "
elif results[0][0] > 4 or results[0][0] == 0:
sentence = "punktów, a uzyskał go: "
return render_template("userHome.html", user=session['user'].split('@')[0] + "\nNajlepszy wynik z ostatniego testu wyniósł " + str(results[0][0]) + sentence + str(results[0][1]), calendar_src="https://calendar.google.com/calendar/embed?src=" + session.get("user"), test = False)
else:
return render_template("userHome.html", user=session['user'].split('@')[0], calendar_src="https://calendar.google.com/calendar/embed?src=" + session.get("user"), test = False)
else:
return render_template("error.html", error = "Brak dostępu!")
if __name__ == "__main__":
#app.run(host='0.0.0.0')
# Port: 5000
#socketio.run(app, debug=True)
socketio.run(app, host="0.0.0.0")#, ssl_context=("cert.pem", "key.pem"))

24
camera.py Normal file
View File

@ -0,0 +1,24 @@
import cv2
class VideoCamera(object):
def __init__(self):
# Using OpenCV to capture from device 0. If you have trouble capturing
# from a webcam, comment the line below out and use a video file
# instead.
self.video = cv2.VideoCapture(0)
# If you decide to use video.mp4, you must have this file in the folder
# as the main.py.
# self.video = cv2.VideoCapture('video.mp4')
def __del__(self):
self.video.release()
def get_frame(self):
success, image = self.video.read()
# We are using Motion JPEG, but OpenCV defaults to capture raw images,
# so we must encode it into JPEG in order to correctly display the
# video stream.
if cv2.waitKey(1) & 0xFF == ord('q'):
return
ret, jpeg = cv2.imencode('.jpg', image)
return jpeg.tobytes()

BIN
database.db Normal file

Binary file not shown.

166
templates/add_question.html Normal file
View File

@ -0,0 +1,166 @@
<!DOCTYPE html>
<!--<html lang="en">-->
<html lang="pl-PL">
<head>
<meta charset="UTF-8">
<title>Python Flask App</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="signup.css">
<!-- <link href="http://getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet"> -->
<link href="http://getbootstrap.com/examples/jumbotron-narrow/jumbotron-narrow.css" rel="stylesheet">
<link href="../static/css/signup.css" rel="stylesheet">
<link rel="stylesheet" href="../static/css/calendar.css">
<style>
table, td, th {
border: 1px solid;
text-align: left;
}
table {
border-collapse: collapse;
/*width: 100%;*/
}
th, td {
padding: 5px;
}
ul {list-style-type: none;}
body {font-family: Verdana, sans-serif;}
/* Month header */
.month {
/*padding: 70px 25px;*/
width: 100%;
background: #1abc9c;
text-align: center;
}
/* Month list */
.month ul {
margin: 0;
padding: 0;
}
.month ul li {
color: white;
font-size: 20px;
text-transform: uppercase;
letter-spacing: 3px;
}
/* Previous button inside month header */
.month .prev {
float: left;
padding-top: 10px;
}
/* Next button */
.month .next {
float: right;
padding-top: 10px;
}
/* Weekdays (Mon-Sun) */
.weekdays {
margin: 0;
padding: 10px 0;
background-color:#ddd;
}
.weekdays li {
display: inline-block;
width: 13.6%;
color: #666;
text-align: center;
}
/* Days (1-30) */
.days {
padding: 10px 0;
background: cyan;
margin: 0;
}
.days li {
list-style-type: none;
display: inline-block;
width: 13.6%;
text-align: center;
margin-bottom: 5px;
font-size:12px;
color: #777;
}
/* Highlight the "current" day */
.days li .active {
padding: 5px;
background: #1abc9c;
color: white !important
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<nav>
<ul class="nav nav-pills pull-left">
<li><img src="/static/logo.jpg" alt="Logo" height="150" width="150" border="5" style="padding: 25px;"></li>
<!--<form><input type="button" value="Back" onClick="history.go(-1);return true;"></form>-->
<!--<li role="presentation" class="active"><input type="button" value="Back" onClick="history.go(-1);return true;">
</li>-->
<!--<li role="presentation" class="active"><form action="http://google.com"><input type="button" value="Wstecz" onClick="history.go(-1);return true;"></form></li>-->
<!-- <li role="presentation" class="active"><a href="userHomeENG">ENG</a> -->
<!-- </li> -->
</ul>
<ul class="nav nav-pills pull-right">
<li role="presentation" class="active"><a href="/logout">Wyloguj</a>
</li>
</ul>
</nav>
<h3 class="text-muted"><center>Python Flask</center></h3>
</div>
<div class="jumbotron" style="height: 550px;">
<h1>{{test_title}}</h1>
<p class="lead"></p>
<p>
<!-- <a class="btn btn-lg btn-success" href="#" role="button">Moje zajęcia</a> -->
<!-- <a class="btn btn-lg btn-success" href="#" role="button">Test</a> -->
<!-- <a class="btn btn-lg btn-success" href="#" role="button">Wyniki</a> -->
<form class="form-signin" action="/add_question" method="post">
<input type="text" name="inputTitle" id="inputTitle" class="form-control" placeholder="Wpisz nazwę pytania" required>
A) <input type="text" name="inputA" id="inputA" class="form-control" placeholder="Odpowiedź A" required>
B) <input type="text" name="inputB" id="inputB" class="form-control" placeholder="Odpowiedź B" required>
C) <input type="text" name="inputC" id="inputC" class="form-control" placeholder="Odpowiedź C" required>
D) <input type="text" name="inputD" id="inputD" class="form-control" placeholder="Odpowiedź D" required>
Prawidłowa odpowiedź: <input type="text" name="inputCorrect" id="inputCorrect" class="form-control" required>
</br>
<input name="submit" class="btn btn-lg btn-success" type="submit" value="Dodaj kolejne pytanie">
</input>
<input name="submit"class="btn btn-lg btn-success" type="submit" value="Zatwierdź test">
</input>
</form>
<!-- <form action="ch"> -->
<!-- <input type="submit" value="Wejdź na czat grupowy" /> -->
<!-- </form> -->
</p>
</div>
<footer class="footer">
<p>&copy; UAM 2018</p>
</footer>
</div>
</body>
</html>

158
templates/end_test.html Normal file
View File

@ -0,0 +1,158 @@
<!DOCTYPE html>
<!--<html lang="en">-->
<html lang="pl-PL">
<head>
<meta charset="UTF-8">
<title>Python Flask App</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="signup.css">
<!-- <link href="http://getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet"> -->
<link href="http://getbootstrap.com/examples/jumbotron-narrow/jumbotron-narrow.css" rel="stylesheet">
<link href="../static/css/signup.css" rel="stylesheet">
<link rel="stylesheet" href="../static/css/calendar.css">
<style>
table, td, th {
border: 1px solid;
text-align: left;
}
table {
border-collapse: collapse;
/*width: 100%;*/
}
th, td {
padding: 5px;
}
ul {list-style-type: none;}
body {font-family: Verdana, sans-serif;}
/* Month header */
.month {
/*padding: 70px 25px;*/
width: 100%;
background: #1abc9c;
text-align: center;
}
/* Month list */
.month ul {
margin: 0;
padding: 0;
}
.month ul li {
color: white;
font-size: 20px;
text-transform: uppercase;
letter-spacing: 3px;
}
/* Previous button inside month header */
.month .prev {
float: left;
padding-top: 10px;
}
/* Next button */
.month .next {
float: right;
padding-top: 10px;
}
/* Weekdays (Mon-Sun) */
.weekdays {
margin: 0;
padding: 10px 0;
background-color:#ddd;
}
.weekdays li {
display: inline-block;
width: 13.6%;
color: #666;
text-align: center;
}
/* Days (1-30) */
.days {
padding: 10px 0;
background: cyan;
margin: 0;
}
.days li {
list-style-type: none;
display: inline-block;
width: 13.6%;
text-align: center;
margin-bottom: 5px;
font-size:12px;
color: #777;
}
/* Highlight the "current" day */
.days li .active {
padding: 5px;
background: #1abc9c;
color: white !important
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<nav>
<ul class="nav nav-pills pull-left">
<li><img src="/static/logo.jpg" alt="Logo" height="150" width="150" border="5" style="padding: 25px;"></li>
<!--<form><input type="button" value="Back" onClick="history.go(-1);return true;"></form>-->
<!--<li role="presentation" class="active"><input type="button" value="Back" onClick="history.go(-1);return true;">
</li>-->
<!--<li role="presentation" class="active"><form action="http://google.com"><input type="button" value="Wstecz" onClick="history.go(-1);return true;"></form></li>-->
<!-- <li role="presentation" class="active"><a href="userHomeENG">ENG</a> -->
<!-- </li> -->
</ul>
<ul class="nav nav-pills pull-right">
<li role="presentation" class="active"><a href="/logout">Wyloguj</a>
</li>
</ul>
</nav>
<h3 class="text-muted"><center>Python Flask</center></h3>
</div>
<div class="jumbotron" style="height: 550px;">
<h1>Witaj w domu {{user}}!</h1>
<p class="lead"></p>
<p>
<!-- <a class="btn btn-lg btn-success" href="#" role="button">Moje zajęcia</a> -->
<!-- <a class="btn btn-lg btn-success" href="#" role="button">Test</a> -->
<!-- <a class="btn btn-lg btn-success" href="#" role="button">Wyniki</a> -->
Twój wynik to {{points}} punktów.
<!-- <audio controls> -->
<!-- <source src="{{ url_for('audiofeed') }}" type="audio/x-wav;codec=pcm"> -->
<!-- Your browser does not support the audio element. -->
<!-- </audio> -->
<!-- <form action="ch"> -->
<!-- <input type="submit" value="Wejdź na czat grupowy" /> -->
<!-- </form> -->
</p>
</div>
<footer class="footer">
<p>&copy; UAM 2018</p>
</footer>
</div>
</body>
</html>

148
templates/streaming.html Normal file
View File

@ -0,0 +1,148 @@
<!DOCTYPE html>
<!--<html lang="en">-->
<html lang="pl-PL">
<head>
<meta charset="UTF-8">
<title>Python Flask App</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="signup.css">
<!-- <link href="http://getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet"> -->
<link href="http://getbootstrap.com/examples/jumbotron-narrow/jumbotron-narrow.css" rel="stylesheet">
<link href="../static/css/signup.css" rel="stylesheet">
<link rel="stylesheet" href="../static/css/calendar.css">
<style>
table, td, th {
border: 1px solid;
text-align: left;
}
table {
border-collapse: collapse;
/*width: 100%;*/
}
th, td {
padding: 5px;
}
ul {list-style-type: none;}
body {font-family: Verdana, sans-serif;}
/* Month header */
.month {
/*padding: 70px 25px;*/
width: 100%;
background: #1abc9c;
text-align: center;
}
/* Month list */
.month ul {
margin: 0;
padding: 0;
}
.month ul li {
color: white;
font-size: 20px;
text-transform: uppercase;
letter-spacing: 3px;
}
/* Previous button inside month header */
.month .prev {
float: left;
padding-top: 10px;
}
/* Next button */
.month .next {
float: right;
padding-top: 10px;
}
/* Weekdays (Mon-Sun) */
.weekdays {
margin: 0;
padding: 10px 0;
background-color:#ddd;
}
.weekdays li {
display: inline-block;
width: 13.6%;
color: #666;
text-align: center;
}
/* Days (1-30) */
.days {
padding: 10px 0;
background: cyan;
margin: 0;
}
.days li {
list-style-type: none;
display: inline-block;
width: 13.6%;
text-align: center;
margin-bottom: 5px;
font-size:12px;
color: #777;
}
/* Highlight the "current" day */
.days li .active {
padding: 5px;
background: #1abc9c;
color: white !important
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<nav>
<ul class="nav nav-pills pull-left">
<li><img src="/static/logo.jpg" alt="Logo" height="150" width="150" border="5" style="padding: 25px;"></li>
<!--<form><input type="button" value="Back" onClick="history.go(-1);return true;"></form>-->
<!--<li role="presentation" class="active"><input type="button" value="Back" onClick="history.go(-1);return true;">
</li>-->
<!--<li role="presentation" class="active"><form action="http://google.com"><input type="button" value="Wstecz" onClick="history.go(-1);return true;"></form></li>-->
<!-- <li role="presentation" class="active"><a href="userHomeENG">ENG</a> -->
<!-- </li> -->
</ul>
<ul class="nav nav-pills pull-right">
<li role="presentation" class="active"><a href="/logout">Wyloguj</a>
</li>
</ul>
</nav>
<h3 class="text-muted"><center>Python Flask</center></h3>
</div>
<div class="jumbotron" style="height: 550px;">
<h1>Witaj w domu {{user}}!</h1>
<div class="col-xs-12">
<img id="bg" src="{{ url_for('stream') }}">
</div>
</p>
</div>
<footer class="footer">
<p>&copy; UAM 2018</p>
</footer>
</div>
</body>
</html>

166
templates/test.html Normal file
View File

@ -0,0 +1,166 @@
<!DOCTYPE html>
<!--<html lang="en">-->
<html lang="pl-PL">
<head>
<meta charset="UTF-8">
<title>Python Flask App</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="signup.css">
<!-- <link href="http://getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet"> -->
<link href="http://getbootstrap.com/examples/jumbotron-narrow/jumbotron-narrow.css" rel="stylesheet">
<link href="../static/css/signup.css" rel="stylesheet">
<link rel="stylesheet" href="../static/css/calendar.css">
<style>
table, td, th {
border: 1px solid;
text-align: left;
}
table {
border-collapse: collapse;
/*width: 100%;*/
}
th, td {
padding: 5px;
}
ul {list-style-type: none;}
body {font-family: Verdana, sans-serif;}
/* Month header */
.month {
/*padding: 70px 25px;*/
width: 100%;
background: #1abc9c;
text-align: center;
}
/* Month list */
.month ul {
margin: 0;
padding: 0;
}
.month ul li {
color: white;
font-size: 20px;
text-transform: uppercase;
letter-spacing: 3px;
}
/* Previous button inside month header */
.month .prev {
float: left;
padding-top: 10px;
}
/* Next button */
.month .next {
float: right;
padding-top: 10px;
}
/* Weekdays (Mon-Sun) */
.weekdays {
margin: 0;
padding: 10px 0;
background-color:#ddd;
}
.weekdays li {
display: inline-block;
width: 13.6%;
color: #666;
text-align: center;
}
/* Days (1-30) */
.days {
padding: 10px 0;
background: cyan;
margin: 0;
}
.days li {
list-style-type: none;
display: inline-block;
width: 13.6%;
text-align: center;
margin-bottom: 5px;
font-size:12px;
color: #777;
}
/* Highlight the "current" day */
.days li .active {
padding: 5px;
background: #1abc9c;
color: white !important
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<nav>
<ul class="nav nav-pills pull-left">
<li><img src="/static/logo.jpg" alt="Logo" height="150" width="150" border="5" style="padding: 25px;"></li>
<!--<form><input type="button" value="Back" onClick="history.go(-1);return true;"></form>-->
<!--<li role="presentation" class="active"><input type="button" value="Back" onClick="history.go(-1);return true;">
</li>-->
<!--<li role="presentation" class="active"><form action="http://google.com"><input type="button" value="Wstecz" onClick="history.go(-1);return true;"></form></li>-->
<!-- <li role="presentation" class="active"><a href="userHomeENG">ENG</a> -->
<!-- </li> -->
</ul>
<ul class="nav nav-pills pull-right">
<li role="presentation" class="active"><a href="/logout">Wyloguj</a>
</li>
</ul>
</nav>
<h3 class="text-muted"><center>Python Flask</center></h3>
</div>
<div class="jumbotron" style="height: 550px;">
<h1>{{test}}</h1>
<form class="form-signin" action="/test" method="post">
{% for question in questions %}
<div class="col-xs-12">
</br>
{{ question[1] }}
</br>
A) {{ question[2] }}
</br>
B) {{ question[3] }}
</br>
C) {{ question[4] }}
</br>
D) {{ question[5] }}
</br>
<input type="text" maxlength="1" name="inputAnswer{{ questions.index(question)|string}}" width="10px"></input>
</br>
<input type="submit" value="Zakończ test" class="btn-success"></input>
</div>
{% endfor %}
</form>
</div>
<footer class="footer">
<p>&copy; UAM 2018</p>
</footer>
</div>
</body>
</html>

View File

@ -133,6 +133,7 @@ body {font-family: Verdana, sans-serif;}
<!-- <iframe src="https://calendar.google.com/calendar/embed?src=micik220@gmail.com" style="border-width:0" width="500" height="350" frameborder="0" scrolling="no"></iframe> -->
<iframe src="{{ calendar_src }}" style="border-width:0" width="500" height="350" frameborder="0" scrolling="no"></iframe>
</div>
<div class="col-xs-4">
<p class="lead"></p>
<p>
<!-- <a class="btn btn-lg btn-success" href="#" role="button">Moje zajęcia</a> -->
@ -142,11 +143,29 @@ body {font-family: Verdana, sans-serif;}
<a class="btn btn-lg btn-success" href="chat" role="button" style="margin-top: 5px;">Czat grupowy</a>
<!-- <a class="btn btn-lg btn-success" href="toResources" role="button" style="margin-top: 5px;">Dodaj materiały</a> -->
<a class="btn btn-lg btn-success" href="toResources" role="button" style="margin-top: 5px;">Podejrzyj materiały</a>
<!-- <a class="btn btn-lg btn-success" href="stream" role="button" style="margin-top: 5px;">Uruchom testowy stream</a> -->
<a class="btn btn-lg btn-success" href="stream" role="button" style="margin-top: 5px;">Uruchom testowy stream</a>
{% if session['role'] == 'admin' %}
{% if test %}
<form class="form-signin" action="/end_test" method="post">
<input class="btn btn-lg btn-success" type="submit" value="Zakończ trwający test"></input>
</form>
{% else %}
<form class="form-signin" action="/create_test" method="post">
<input type="text" name="inputTestName" id="inputTestName" class="form-control" placeholder="Wpisz nazwę testu" required>
<input type="text" name="inputUsers" id="inputUsers" class="form-control" placeholder="Podaj loginy uczestników" required>
<input class="btn btn-lg btn-success" type="submit" value="Utwórz test"></input>
</form>
{% endif %}
{% elif session['role'] == 'user' %}
<form class="form-signin" action="/show_test" method="post">
<input class="btn btn-lg btn-success" type="submit" value="Rozwiąż test"></input>
</form>
{% endif %}
<!-- <form action="ch"> -->
<!-- <input type="submit" value="Wejdź na czat grupowy" /> -->
<!-- </form> -->
</p>
</div>
</div>