Пример #1
0
    def done(self):
        '''
        create formula, update table,
        create new assignment table->add row for each user
        '''
        self.create_formula()
        num = self.update_assignments_table()
        # create the assignment table with it's proper name in the format: a#
        db.create_assignment_table(num, conn)

        # get a list of currently existing user ids in the system
        ids = db.get_user_ids(conn)

        progress = ''
        grade = 0
        sub_date = 0

        # for each user id, create a first attempt entry using a unique set
        # of questions
        for uid in ids:
            # unique set of questions
            quests = self.create_problem_set(self.formula)
            # ectract a list of problem ids
            prob_ids = []
            # add all ids to the list
            for quest in quests:
                prob_ids.append(quest[0])
            # create the user attempt entry
            db.add_attempt("a" + str(num), uid, prob_ids, progress, grade,
                           sub_date, conn)

        self.refresh()
Пример #2
0
    def submit_progress(self):
        # update progress
        answers = self.get_entries()
        progress = ""
        for ans in answers:
            progress += (str(ans) + ',')
        progress = progress[:-1]
        db.update_assignment_progress_for_user_for_nth_attempt(
            self.aid, self.uid,
            len(db.get_user_attempts(self.aid, self.uid, conn)), progress,
            conn)

        # get problem set
        # get a list of all the problem ids for the user for that assignment
        problem_set = db.get_user_nth_attempt(self.aid, self.uid, -1, conn)[2]

        # get stored solutions according to the problem set
        solution_set = db.get_solution_set(problem_set, conn)

        # get and update grade according to solution set
        try:
            grade = self.calc_grade(solution_set, progress)
            db.update_attempt_grade_for_user_for_nth_attempt(
                self.aid, self.uid,
                len(db.get_user_attempts(self.aid, self.uid, conn)), grade,
                conn)
        except (IndexError, SyntaxError):
            print("not complete")

        # create the new attempt
        # create a problem set with same formula
        quests = self.create_problem_set(
            db.get_assignment_details(self.aid, conn)[2])
        new_problem_set = []
        # add all ids to the list
        for quest in quests:
            new_problem_set.append(quest[0])

        self.update_submission_time()

        db.add_attempt('a' + str(self.aid), self.uid, new_problem_set, '', '',
                       '', conn)

        self.refresh()
Пример #3
0
 def table_functions(self, num, formula):
     '''
     create formula, update table, 
     create new assignment table->add row for each user
     '''
     # create the assignment table with it's proper name in the format: a#
     db.create_assignment_table(num, conn)
     # get a list of currently existing user ids in the system
     ids = db.get_user_ids(conn)
     # for each user id, create a first attempt entry using a unique set
     # of questions
     for uid in ids:
         # unique set of questions
         quests = self.create_problem_set(formula)
         # extract a list of problem ids
         prob_ids = []
         # add all ids to the list
         for quest in quests:
             prob_ids.append(quest[0])
         # create the user attempt entry
         db.add_attempt("a" + str(num), uid, prob_ids, "", "", "", conn)
Пример #4
0
 def setUp(self):
     db.create_assignment_table(row + 1, conn)
     db.add_attempt("a" + str(row + 1), 200, "[1,2,3]", "[60,0,2]", "100",
                    "8", conn)
Пример #5
0
 def test_add_attempts_for_non_existant_assign(self):
     self.assertRaises(
         sqlite3.OperationalError,
         lambda: db.add_attempt("a" + str(row + 10000), 3, "[3,5,7]",
                                "[60,0,2]", "100", "2015/17/5/22", conn))
Пример #6
0
 def test_duplicate_submission_dates(self):
     db.add_attempt("a" + str(row + 1), 3, "[3,5,7]", "[60,0,2]", "100",
                    "2015/17/5/22", conn)
     db.add_attempt("a" + str(row + 1), 3, "[5,5,5]", "[0,2,1]", "100",
                    "2015/17/5/22", conn)
Пример #7
0
 def test_add_empty_attempt(self):
     db.add_attempt("a" + str(row + 1), 3, "[3,5,7]", "", "", "", conn)
Пример #8
0
 def test_add_attempt(self):
     db.add_attempt("a" + str(row + 1), 2, "[1,2,3]", "[60,0,2]", "100", "",
                    conn)