def getsubtop(self, i):
        from dbinterface.DBAlgoAPI import KeyCodeTools
        q = self.e_questions[i]
        self.subject = KeyCodeTools().get_all_subject_id_name_pairs()[int(q.q_key.split(".")[0])]
        self.topic = KeyCodeTools().get_all_topics_id_name_pairs(self.subject)[int(q.q_key.split(".")[1])]

        return self.subject, self.topic
    def attempts_gen_GUI(self, i):                     # Output exam text and collect/record exams attempts results
        from src.Classes_dict import Attempt
        from dbinterface.DBAlgoAPI import KeyCodeTools

        q = self.e_questions[i]
        self.subject = KeyCodeTools().get_all_subject_id_name_pairs()[int(q.q_key.split(".")[0])]
        self.topic = KeyCodeTools().get_all_topics_id_name_pairs(self.subject)[int(q.q_key.split(".")[1])]
    def attempts_gen_dev(self):                     # Output exam text and collect/record exams attempts results
        from src.Classes_dict import Attempt
        from dbinterface.DBAlgoAPI import KeyCodeTools

        for i in range(len(self.e_questions)):
            q = self.e_questions[i]
            subject = KeyCodeTools().get_all_subject_id_name_pairs()[int(q.q_key.split(".")[0])]
            topic = KeyCodeTools().get_all_topics_id_name_pairs(subject)[int(q.q_key.split(".")[1])]

            print(".....................")
            print("Subject:", subject)
            print("Topic:", topic)
            print("\n")
            print("Q:", i+1)                    # Print question number
            print(q.q_str)                      # Print question text
            print("\n")
            # input("Hit ENTER to display ANSWER")  # TODO uncomment display answer
            print("Answer:", q.q_ans)           # Print question answer
            print("\n")

            # Request user input on attempts for the questions generated
            x = int(input("Did you get the question right? 0- No ; 1- Yes :"))  # Request attempt results

            while not x == 0 and not x == 1:
                print("Wrong entry")
                x = int(input("Enter attempt result again: 0-No ; 1-Yes :"))

            self.attempts.append(Attempt(q.q_key, x))             # Log attempts on Attempts_log
Example #4
0
 def edit_answer_for_given_keycode(self, keycode, new_answer_str):
     """
     :param keycode: keycode of a question i.e. "1.3.4"
     :param new_answer_str: the new answer string to replace the old answer string
     :return: None
     """
     names = KeyCodeTools().get_keycode_to_english_translation(keycode)
     topic_name = names.split('.')[1]
     edit_answer_str_sql = """UPDATE {0} SET Answer = '{1}'
     WHERE KeyCode = '{2}'""".format(topic_name, new_answer_str, keycode)
     self.cursor.execute(edit_answer_str_sql)
     self.connection.commit()
Example #5
0
 def edit_question_for_given_keycode(self, keycode, new_question_str):
     """
     Modifies the question string for a given question corresponding with the keycode provided
     :param keycode: keycode of a question i.e. "1.3.4"
     :param new_question_str: the new question string to replace the old question string
     :return: None
     """
     names = KeyCodeTools().get_keycode_to_english_translation(keycode)
     topic_name = names.split('.')[1]
     edit_question_str_sql = """UPDATE {0} SET Question = '{1}' 
     WHERE KeyCode = '{2}'""".format(topic_name, new_question_str, keycode)
     self.cursor.execute(edit_question_str_sql)
     self.connection.commit()
        def update_nb(attempts_lst, question):
            for attempt in reversed(attempts_lst):  # Go through attempts log backward to locate last attempt
                if attempt.split(" ")[0] == question.q_key:     # Check for attempt question key

                    if int(attempt.split(" ")[1]) == 0:         # Check matching question Leitner number status
                        question.leitner_nb = 1                 # and update accordingly
                        KeyCodeTools().update_leitner_number(question.q_key, question.leitner_nb)
                        return print("Q.Key:", question.q_key, "New Leitner nb:", question.leitner_nb)
                    else:
                        if question.leitner_nb != 3:
                            question.leitner_nb = question.leitner_nb + 1
                            KeyCodeTools().update_leitner_number(question.q_key, question.leitner_nb)
                        return print("Q.Key:", question.q_key, "New Leitner nb:", question.leitner_nb)
Example #7
0
def compile_questions(topic_table_name):
    data = KeyCodeTools().combine_exam_gen_data(topic_table_name)

    keys = data['keycodes']
    q_str = data['questions']
    q_ans = data['answers']
    q_leitner = data['leitnernums']

    new_questions = [Question(keys[i], q_str[i], q_ans[i], q_leitner[i]) for i in range(len(q_str))]
    return new_questions
def stats_gen_process():
    # _____________________________________________ FIRST CHECK IF ATTEMPTS_LOG NOT EMPTY

    if os.stat('./../src/Attempts_log.txt').st_size == 0:
        print(
            "\nGenerate an exam first to be able to see performance statistics"
        )
        print(
            "\n___________________________________________________________________\n"
        )
        return

    # _____________________________________________ SUB-MENU FOR SELECTING STATS GENERATION PARAMETERS

    print("\nSelect topics to generate statistics about:\n")
    print(KeyCodeTools().get_all_subject_id_name_pairs())
    subject = input(
        "Type the name of the subject requested or 'all' if you would like statistics about everything:\n"
    )

    if subject == "all":
        # Generate a list of all keycodes possible
        keylst = []
        for i in range(100):
            for j in range(100):
                key = str(i) + "." + str(j)
                keylst.append(key)
    else:
        print(KeyCodeTools().get_all_topics_id_name_pairs(subject))
        topic = input(
            "Type the topic requested or 'all' if you would like statistics about everything:\n"
        )

        if topic == "all":
            # Generate a list of all topic keycodes possible
            keylst = []
            for j in range(100):
                key = str(KeyCodeTools().get_all_subject_name_id_pairs()
                          [subject]) + "." + str(j)
                keylst.append(key)

        else:
            keylst = str(KeyCodeTools().get_all_subject_name_id_pairs(
            )[subject]) + "." + str(
                KeyCodeTools().get_all_topic_name_id_pairs(subject)[topic])
    # print("Selected keys:", keylst)
    # _____________________________________________ STATS GENERATION PROCESS

    print(
        "\n_STATISTICS:_______________________________________________________\n"
    )

    df, df2 = format_attempts(
        keylst)  # Process attempts log according to selection
    dates = plot_pre_processing(
        df)  # Process and format dates for plot generation
    display_dataframe(df)  # Display dataframe

    basic_stats(df)  # Display basic statistics

    # ___________________________________________________________PLOT/PRINT CALLS FOR DEV MENU
    # display_df_description(df)                      # Display df description (not yet confirmed as part of stats!!!)
    print_basic_stats(df)
    plot_error_rate(df, dates)  # Display plot of error rate over time
    plot_fail_success(
        df, dates)  # Display plot of failures and successes over time
def test_compile_data_bank():
    data_bank = compile_data_bank(['CapitalsOfTheAmericas'])
    q = KeyCodeTools().get_all_questions('CapitalsOfTheAmericas')
    assert len(data_bank) == len(q)