Beispiel #1
0
 def del_q(self, row_id):
     confirm_message = messagebox.askquestion(
         'Delete Question',
         'Are you sure you want to delete this question?',
         icon='warning')
     if confirm_message == "yes":
         Multiplechoice.delete_question(self.table.data[row_id]["id"])
     self.show()
Beispiel #2
0
        def send_q_data(self):
            prompt = self.prompt.get("1.0", END).rstrip()
            answer = self.correct.get()
            in1 = self.incorrect1.get()
            in2 = self.incorrect2.get()
            in3 = self.incorrect3.get()
            p_id = self.page.package_id

            field_checker(prompt,
                          answer,
                          in1,
                          in2,
                          in3,
                          f_commiter=lambda: Multiplechoice.create_question(
                              prompt=prompt,
                              answer=answer,
                              incorrect1=in1,
                              incorrect2=in2,
                              incorrect3=in3,
                              package_id=p_id))

            self.grid_forget()
            self.page.b_add.configure(text="Add new Question",
                                      command=self.page.new_q_form)
            self.page.show()
Beispiel #3
0
    def save_q(self):
        id = self.question["id"]
        prompt = self.question["text"].get("1.0", END).rstrip()
        correct = self.question["correct"].get()
        in1 = self.question["in1"].get()
        in2 = self.question["in2"].get()
        in3 = self.question["in3"].get()

        field_checker(prompt,
                      correct,
                      in1,
                      in2,
                      in3,
                      f_commiter=lambda: Multiplechoice.save_question(
                          id, prompt, correct, in1, in2, in3))
        self.show()
Beispiel #4
0
    def edit_form(self, row_id):

        self.question = {
            "correct": StringVar(),
            "in1": StringVar(),
            "in2": StringVar(),
            "in3": StringVar()
        }

        for i in range(self.table.columns):
            property = self.table.prop_names[i]
            if len(property) > 0:
                if property == "text":

                    def constructor(frame):
                        self.question["text"] = Text(frame, width=30, height=2)
                        return self.question["text"]
                else:

                    def constructor(frame):
                        return Entry(frame,
                                     textvariable=self.question[property])

                self.table.set_cell(row=row_id, column=i, func=constructor)
            else:
                for row in range(len(self.table.data)):
                    self.table.get_cell(row=row, column=i).hide()
        self.table.set_cell(
            row=row_id,
            column=5,
            func=lambda f: HoverButton(f, text="Save", command=self.save_q))

        self.question[
            "id"], text, correct, inc1, inc2, inc3 = Multiplechoice.get_question(
                self.table.data[row_id]["id"])

        self.question["text"].insert(END, text)
        self.question["correct"].set(correct)
        self.question["in1"].set(inc1)
        self.question["in2"].set(inc2)
        self.question["in3"].set(inc3)

        self.mainUI.update_window_size()
Beispiel #5
0
 def get_question():
     m = Multiplechoice()
     shuffle(m.qbank)
     return m.qbank[0]
Beispiel #6
0
 def before_showing(self, package_id=None):
     if package_id: self.package_id = package_id
     self.table.data = Multiplechoice(self.package_id, True).qbank
Beispiel #7
0
from Quiz.multiplechoice import Multiplechoice
from Quiz.package import Package
from Quiz.statistics import Statistics
from data.connection import Connection
import random

# !!Nukes current data!!
for t_name in ["questions", "statistics", "packages"]:
    with Connection() as con:
        with con:
            con.execute("DROP TABLE IF EXISTS " + t_name)

# Ensures that databases are created
Multiplechoice()
Statistics()
Package()


# helper function
def gen_num():
    return str(random.randint(100, 999))


data = [{
    "Harry Potter trivia":
    [[
        "What was Nearly Headless Nick's last name?", "de Mimsy-Porpington",
        "von Grieve", "van Orton", "Delaney-Podmore"
    ],
     [
         "How old was Nicholas Flamel in the Sorcerer's Stone?", "655",