# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'QuizPortal_v3.ui'
#
# Created by: PyQt5 UI code generator 5.9.2
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore, QtGui, QtWidgets
import sqlite3 as db
from Quiz import Ui_QuizWindow


class Ui_QuizPortal(object):
    dbname='UniversityQuizPortal.db'

    def Quizwindow_show(self):
        
        self.QuizWin=QtWidgets.QMainWindow()
        self.ui_qp=Ui_QuizWindow()
        self.ui_qp.setupUi(self.QuizWin)
        self.QuizWin.show()

    def Credential_check(self):
        
        print("Quiz Click success")
        qid=self.input_Quiz_id.text()
        sid=self.inuput_student_id.text()
        cid=self.input_course_id.text()
        
        con=db.connect('UniversityQuizPortal_new.db')
        print("db connect success")
        credential_check=con.execute("SELECT * FROM student_detail WHERE student_id=? and course_id=? and quiz_id=?",(sid,cid,qid))
        if (len(credential_check.fetchall())==1):
            print("credential check success")
            #ques=con.execute("select * from question_set where quiz_id=?",qid)
            self.Quizwindow_show()
        else:
            print("Incorrect Details")
            

    def Upload_CSV(self):
        print("Upload Click success")
            
    def setupUi(self, QuizPortal):
        QuizPortal.setObjectName("QuizPortal")
        QuizPortal.setWindowModality(QtCore.Qt.WindowModal)
        QuizPortal.resize(966, 780)
        QuizPortal.setBaseSize(QtCore.QSize(100, 100))
        font = QtGui.QFont()
        font.setFamily("Lucida Sans")
        font.setPointSize(16)
        font.setBold(True)
        font.setItalic(True)
        font.setUnderline(False)
        font.setWeight(75)
        QuizPortal.setFont(font)
        QuizPortal.setMouseTracking(True)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap("pyc.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        QuizPortal.setWindowIcon(icon)
        QuizPortal.setWindowOpacity(1.0)
        QuizPortal.setAutoFillBackground(False)
        QuizPortal.setStyleSheet("background-color: qlineargradient(spread:pad, x1:0.94, y1:0.909, x2:1, y2:1, stop:0 rgba(176, 179, 218, 255), stop:1 rgba(255, 255, 255, 255));\n"
"border-color: rgb(0, 0, 0)")
        QuizPortal.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
        QuizPortal.setAnimated(False)
        self.MainFrame = QtWidgets.QWidget(QuizPortal)
        font = QtGui.QFont()
        font.setFamily("Lucida Sans")
        font.setPointSize(16)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.MainFrame.setFont(font)
        self.MainFrame.setObjectName("MainFrame")
        self.horizontalLayout = QtWidgets.QHBoxLayout(self.MainFrame)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.Admin_Tab = QtWidgets.QTabWidget(self.MainFrame)
        font = QtGui.QFont()
        font.setFamily("Lucida Sans")
        font.setPointSize(16)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.Admin_Tab.setFont(font)
        self.Admin_Tab.setAutoFillBackground(False)
        self.Admin_Tab.setObjectName("Admin_Tab")
        self.AdminTab = QtWidgets.QWidget()
        font = QtGui.QFont()
        font.setFamily("Lucida Sans")
        font.setPointSize(16)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.AdminTab.setFont(font)
        self.AdminTab.setObjectName("AdminTab")
        self.verticalLayout = QtWidgets.QVBoxLayout(self.AdminTab)
        self.verticalLayout.setObjectName("verticalLayout")
        self.frame_Admin = QtWidgets.QFrame(self.AdminTab)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.frame_Admin.sizePolicy().hasHeightForWidth())
        self.frame_Admin.setSizePolicy(sizePolicy)
        self.frame_Admin.setMinimumSize(QtCore.QSize(0, 0))
        self.frame_Admin.setMaximumSize(QtCore.QSize(16777215, 16777215))
        font = QtGui.QFont()
        font.setFamily("Lucida Sans")
        font.setPointSize(16)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.frame_Admin.setFont(font)
        self.frame_Admin.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame_Admin.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame_Admin.setLineWidth(2)
        self.frame_Admin.setMidLineWidth(1)
        self.frame_Admin.setObjectName("frame_Admin")
        self.textBrowser = QtWidgets.QTextBrowser(self.frame_Admin)
        self.textBrowser.setGeometry(QtCore.QRect(30, 250, 831, 151))
        font = QtGui.QFont()
        font.setFamily("Lucida Sans")
        font.setPointSize(14)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.textBrowser.setFont(font)
        self.textBrowser.setObjectName("textBrowser")
        self.btn_Browse = QtWidgets.QPushButton(self.frame_Admin)
        self.btn_Browse.setGeometry(QtCore.QRect(400, 180, 171, 41))
        font = QtGui.QFont()
        font.setFamily("Lucida Sans")
        font.setPointSize(14)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.btn_Browse.setFont(font)
        self.btn_Browse.setObjectName("btn_Browse")
        self.L_Admin_info = QtWidgets.QLabel(self.frame_Admin)
        self.L_Admin_info.setGeometry(QtCore.QRect(100, 40, 731, 71))
        font = QtGui.QFont()
        font.setFamily("Lucida Sans")
        font.setPointSize(14)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.L_Admin_info.setFont(font)
        self.L_Admin_info.setObjectName("L_Admin_info")
        self.input_file_path = QtWidgets.QLineEdit(self.frame_Admin)
        self.input_file_path.setGeometry(QtCore.QRect(150, 110, 451, 31))
        font = QtGui.QFont()
        font.setFamily("Lucida Sans")
        font.setPointSize(14)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.input_file_path.setFont(font)
        self.input_file_path.setInputMethodHints(QtCore.Qt.ImhUrlCharactersOnly)
        self.input_file_path.setObjectName("input_file_path")
        self.btn_UploadFile = QtWidgets.QPushButton(self.frame_Admin)
        self.btn_UploadFile.setGeometry(QtCore.QRect(180, 180, 171, 41))
        font = QtGui.QFont()
        font.setFamily("Lucida Sans")
        font.setPointSize(14)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.btn_UploadFile.setFont(font)
        self.btn_UploadFile.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
        self.btn_UploadFile.setAutoFillBackground(False)
        self.btn_UploadFile.setObjectName("btn_UploadFile")
        #----------Upload file--------
        self.btn_UploadFile.clicked.connect(self.Upload_CSV)
        #-----------------------------
        self.verticalLayout.addWidget(self.frame_Admin)
        self.input_file_path.raise_()
        self.L_Admin_info.raise_()
        self.btn_UploadFile.raise_()
        self.frame_Admin.raise_()
        self.Admin_Tab.addTab(self.AdminTab, "")
        self.Quiz_Login_tab = QtWidgets.QWidget()
        font = QtGui.QFont()
        font.setPointSize(10)
        self.Quiz_Login_tab.setFont(font)
        self.Quiz_Login_tab.setObjectName("Quiz_Login_tab")
        self.frame_Student_Reg_Input = QtWidgets.QFrame(self.Quiz_Login_tab)
        self.frame_Student_Reg_Input.setGeometry(QtCore.QRect(10, 10, 671, 621))
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.frame_Student_Reg_Input.sizePolicy().hasHeightForWidth())
        self.frame_Student_Reg_Input.setSizePolicy(sizePolicy)
        self.frame_Student_Reg_Input.setBaseSize(QtCore.QSize(100, 100))
        self.frame_Student_Reg_Input.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame_Student_Reg_Input.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame_Student_Reg_Input.setObjectName("frame_Student_Reg_Input")
        self.L_Student_Reg_info = QtWidgets.QLabel(self.frame_Student_Reg_Input)
        self.L_Student_Reg_info.setGeometry(QtCore.QRect(120, 10, 431, 51))
        font = QtGui.QFont()
        font.setFamily("Lucida Sans")
        font.setPointSize(14)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.L_Student_Reg_info.setFont(font)
        self.L_Student_Reg_info.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.L_Student_Reg_info.setFrameShadow(QtWidgets.QFrame.Plain)
        self.L_Student_Reg_info.setIndent(0)
        self.L_Student_Reg_info.setObjectName("L_Student_Reg_info")
        self.L_Quiz_id = QtWidgets.QLabel(self.frame_Student_Reg_Input)
        self.L_Quiz_id.setGeometry(QtCore.QRect(160, 80, 441, 31))
        font = QtGui.QFont()
        font.setFamily("Lucida Sans")
        font.setPointSize(14)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.L_Quiz_id.setFont(font)
        self.L_Quiz_id.setIndent(0)
        self.L_Quiz_id.setObjectName("L_Quiz_id")
        self.input_Quiz_id = QtWidgets.QLineEdit(self.frame_Student_Reg_Input)
        self.input_Quiz_id.setGeometry(QtCore.QRect(150, 120, 461, 41))
        font = QtGui.QFont()
        font.setFamily("Lucida Sans")
        font.setPointSize(14)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.input_Quiz_id.setFont(font)
        self.input_Quiz_id.setPlaceholderText("")
        self.input_Quiz_id.setClearButtonEnabled(True)
        self.input_Quiz_id.setObjectName("input_Quiz_id")
        self.L_Course_id = QtWidgets.QLabel(self.frame_Student_Reg_Input)
        self.L_Course_id.setGeometry(QtCore.QRect(160, 190, 441, 31))
        font = QtGui.QFont()
        font.setFamily("Lucida Sans")
        font.setPointSize(14)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.L_Course_id.setFont(font)
        self.L_Course_id.setIndent(0)
        self.L_Course_id.setObjectName("L_Course_id")
        self.input_course_id = QtWidgets.QLineEdit(self.frame_Student_Reg_Input)
        self.input_course_id.setGeometry(QtCore.QRect(150, 240, 461, 41))
        font = QtGui.QFont()
        font.setFamily("Lucida Sans")
        font.setPointSize(14)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.input_course_id.setFont(font)
        self.input_course_id.setPlaceholderText("")
        self.input_course_id.setClearButtonEnabled(True)
        self.input_course_id.setObjectName("input_course_id")
        self.L_student_id = QtWidgets.QLabel(self.frame_Student_Reg_Input)
        self.L_student_id.setGeometry(QtCore.QRect(160, 310, 441, 41))
        font = QtGui.QFont()
        font.setFamily("Lucida Sans")
        font.setPointSize(14)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.L_student_id.setFont(font)
        self.L_student_id.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.L_student_id.setTextFormat(QtCore.Qt.PlainText)
        self.L_student_id.setIndent(0)
        self.L_student_id.setObjectName("L_student_id")
        self.inuput_student_id = QtWidgets.QLineEdit(self.frame_Student_Reg_Input)
        self.inuput_student_id.setGeometry(QtCore.QRect(150, 370, 451, 51))
        font = QtGui.QFont()
        font.setFamily("Lucida Sans")
        font.setPointSize(14)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.inuput_student_id.setFont(font)
        self.inuput_student_id.setText("")
        self.inuput_student_id.setPlaceholderText("")
        self.inuput_student_id.setClearButtonEnabled(True)
        self.inuput_student_id.setObjectName("inuput_student_id")
        self.btn_Start_Quiz = QtWidgets.QPushButton(self.frame_Student_Reg_Input)
        self.btn_Start_Quiz.setGeometry(QtCore.QRect(220, 490, 191, 41))
        font = QtGui.QFont()
        font.setFamily("Lucida Sans")
        font.setPointSize(14)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.btn_Start_Quiz.setFont(font)
        self.btn_Start_Quiz.setObjectName("btn_Start_Quiz")
        #----- Start Quiz btn------
        self.btn_Start_Quiz.clicked.connect(self.Credential_check)
        #--------------------------
        self.frame_Studetn_Reg_Status = QtWidgets.QFrame(self.Quiz_Login_tab)
        self.frame_Studetn_Reg_Status.setGeometry(QtCore.QRect(670, 10, 271, 621))
        self.frame_Studetn_Reg_Status.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame_Studetn_Reg_Status.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame_Studetn_Reg_Status.setObjectName("frame_Studetn_Reg_Status")
        self.input_sql_status = QtWidgets.QLineEdit(self.frame_Studetn_Reg_Status)
        self.input_sql_status.setGeometry(QtCore.QRect(30, 90, 221, 511))
        font = QtGui.QFont()
        font.setFamily("Lucida Sans")
        font.setPointSize(14)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.input_sql_status.setFont(font)
        self.input_sql_status.setObjectName("input_sql_status")
        self.L_Status = QtWidgets.QLabel(self.frame_Studetn_Reg_Status)
        self.L_Status.setGeometry(QtCore.QRect(70, 40, 81, 31))
        font = QtGui.QFont()
        font.setFamily("Lucida Sans")
        font.setPointSize(14)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.L_Status.setFont(font)
        self.L_Status.setObjectName("L_Status")
        self.Admin_Tab.addTab(self.Quiz_Login_tab, "")
        self.horizontalLayout.addWidget(self.Admin_Tab)
        QuizPortal.setCentralWidget(self.MainFrame)
        self.menubar = QtWidgets.QMenuBar(QuizPortal)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 966, 38))
        font = QtGui.QFont()
        font.setFamily("Lucida Sans")
        font.setPointSize(16)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.menubar.setFont(font)
        self.menubar.setObjectName("menubar")
        self.menuMain = QtWidgets.QMenu(self.menubar)
        font = QtGui.QFont()
        font.setFamily("Lucida Sans")
        font.setPointSize(16)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.menuMain.setFont(font)
        self.menuMain.setObjectName("menuMain")
        QuizPortal.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(QuizPortal)
        self.statusbar.setObjectName("statusbar")
        QuizPortal.setStatusBar(self.statusbar)
        self.actionExit = QtWidgets.QAction(QuizPortal)
        font = QtGui.QFont()
        font.setFamily("Lucida Sans")
        font.setPointSize(16)
        font.setBold(True)
        font.setItalic(True)
        font.setWeight(75)
        self.actionExit.setFont(font)
        self.actionExit.setObjectName("actionExit")
        self.actionAbout = QtWidgets.QAction(QuizPortal)
        self.actionAbout.setObjectName("actionAbout")
        self.actionPython_Version_Used = QtWidgets.QAction(QuizPortal)
        self.actionPython_Version_Used.setObjectName("actionPython_Version_Used")
        self.actionAbout_2 = QtWidgets.QAction(QuizPortal)
        self.actionAbout_2.setObjectName("actionAbout_2")
        self.actionHelp = QtWidgets.QAction(QuizPortal)
        self.actionHelp.setObjectName("actionHelp")
        self.menuMain.addSeparator()
        self.menuMain.addAction(self.actionHelp)
        self.menuMain.addAction(self.actionAbout_2)
        self.menuMain.addSeparator()
        self.menuMain.addAction(self.actionExit)
        self.menubar.addAction(self.menuMain.menuAction())

        self.retranslateUi(QuizPortal)
        self.Admin_Tab.setCurrentIndex(0)
        self.btn_Start_Quiz.clicked.connect(self.input_Quiz_id.selectAll)
        self.btn_Start_Quiz.clicked.connect(self.input_course_id.selectAll)
        self.btn_Start_Quiz.clicked.connect(self.inuput_student_id.selectAll)
        self.btn_Start_Quiz.clicked.connect(self.input_sql_status.show)
        QtCore.QMetaObject.connectSlotsByName(QuizPortal)
        QuizPortal.setTabOrder(self.Admin_Tab, self.input_file_path)
        QuizPortal.setTabOrder(self.input_file_path, self.btn_UploadFile)
        QuizPortal.setTabOrder(self.btn_UploadFile, self.btn_Browse)
        QuizPortal.setTabOrder(self.btn_Browse, self.textBrowser)
        QuizPortal.setTabOrder(self.textBrowser, self.input_Quiz_id)
        QuizPortal.setTabOrder(self.input_Quiz_id, self.input_course_id)
        QuizPortal.setTabOrder(self.input_course_id, self.inuput_student_id)
        QuizPortal.setTabOrder(self.inuput_student_id, self.btn_Start_Quiz)
        QuizPortal.setTabOrder(self.btn_Start_Quiz, self.input_sql_status)

    def retranslateUi(self, QuizPortal):
        _translate = QtCore.QCoreApplication.translate
        QuizPortal.setWindowTitle(_translate("QuizPortal", "Quiz Portal"))
        self.textBrowser.setHtml(_translate("QuizPortal", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Lucida Sans\'; font-size:14pt; font-weight:600; font-style:italic;\">\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:\'Cambria\'; font-style:normal; text-decoration: underline;\">Note</span><span style=\" font-family:\'Cambria\'; font-style:normal;\"> : </span><span style=\" font-family:\'Cambria\'; font-weight:400; font-style:normal;\">Only CSV file in the following format is accepted. </span></p>\n"
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:\'Cambria\'; font-weight:400; font-style:normal;\"><br /></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:\'Cambria\'; font-weight:400; font-style:normal;\">The header should have following cells</span></p>\n"
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:\'Cambria\'; font-weight:400; font-style:normal;\"><br /></p>\n"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-family:\'Cambria\'; font-weight:400; font-style:normal;\">Question_text,Option_1,Option_2,Option_3,Option_4,Answer_text</span></p></body></html>"))
        self.btn_Browse.setAccessibleName(_translate("QuizPortal", "btn_Browse"))
        self.btn_Browse.setAccessibleDescription(_translate("QuizPortal", "btn_Browse"))
        self.btn_Browse.setText(_translate("QuizPortal", "Browse"))
        self.L_Admin_info.setText(_translate("QuizPortal", "Browse or enter the file path to upload your CSV file"))
        self.input_file_path.setAccessibleName(_translate("QuizPortal", "file_input"))
        self.btn_UploadFile.setText(_translate("QuizPortal", "Upload"))
        self.Admin_Tab.setTabText(self.Admin_Tab.indexOf(self.AdminTab), _translate("QuizPortal", "Admin"))
        self.L_Student_Reg_info.setText(_translate("QuizPortal", "Students can register for new courses here"))
        self.L_Quiz_id.setText(_translate("QuizPortal", "Quiz ID/Number"))
        self.L_Course_id.setText(_translate("QuizPortal", "Course ID (like DATA650)"))
        self.L_student_id.setText(_translate("QuizPortal", "Student ID (axy@31)"))
        self.btn_Start_Quiz.setText(_translate("QuizPortal", "Start Quiz"))
        self.L_Status.setText(_translate("QuizPortal", "Status"))
        self.Admin_Tab.setTabText(self.Admin_Tab.indexOf(self.Quiz_Login_tab), _translate("QuizPortal", "Quiz_Login"))
        self.menuMain.setTitle(_translate("QuizPortal", "Main"))
        self.actionExit.setText(_translate("QuizPortal", "Exit"))
        self.actionAbout.setText(_translate("QuizPortal", "About"))
        self.actionPython_Version_Used.setText(_translate("QuizPortal", "Python Version Used"))
        self.actionAbout_2.setText(_translate("QuizPortal", "About"))
        self.actionHelp.setText(_translate("QuizPortal", "Help"))


if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    QuizPortal = QtWidgets.QMainWindow()
    ui = Ui_QuizPortal()
    ui.setupUi(QuizPortal)
    QuizPortal.show()
    sys.exit(app.exec_())

