Пример #1
0
    def update_submission_time(self):
        '''
        gets the current time upon submission and calls a db function to update
        the user's attempt row with the new submission time
        '''
        now = time.strftime("%d/%m/%Y\n%H:%M:%S")
        db.update_assignment_submission_for_user_for_nth_attempt(
            self.aid, self.uid,
            len(db.get_user_attempts(self.aid, self.uid, conn)), now, conn)

        # LEADERBOARD
        # Update user's time
        user_attempts = db.get_user_attempts(self.aid, self.uid, conn)
        assignment_start = db.get_assignment_details(self.aid, conn)[3]

        # Update user's overall grade and time from recalculating all latest
        # submissions they made for all assignments
        ##num_of_assignments = len(db.get_assignments_ids(conn))
        all_assignments = db.get_assignments_ids(conn)
        user_total_grade = 0
        user_total_time = 0

        i = 1
        for assignment in all_assignments:
            ##print(db.get_latest_user_attempts(i, self.uid, conn)[1]) # Index problem with latest a#?
            print("====================")
            print("|||", db.get_latest_user_attempts(i, self.uid, conn)[0])
            assignment_start = db.get_assignment_details(i, conn)[3]
            print("CONDITIONAL",
                  db.get_latest_user_attempts(i, self.uid, conn)[0][5])
            print("CONDITIONAL",
                  type(db.get_latest_user_attempts(i, self.uid, conn)[0][5]))

            # Ensure current user's attempt is not one that has 0 attempt.
            if (db.get_latest_user_attempts(i, self.uid, conn)[0][5] != '0'):
                # Ensure data from latest submission is retrieved
                if (db.get_latest_user_attempts(i, self.uid, conn)[0][5] !=
                        ''):
                    latest_id = 0
                else:
                    latest_id = 1
                print("LATEST ID", latest_id)
                curr_aid_time = self.start_to_end_sec(
                    assignment_start,
                    db.get_latest_user_attempts(i, self.uid,
                                                conn)[latest_id][5])
                print("CURR_AID_TIME:", curr_aid_time)
                user_total_grade += int(
                    db.get_latest_user_attempts(i, self.uid,
                                                conn)[latest_id][4])
                user_total_time += int(curr_aid_time)
                i += 1

        average_grade = user_total_grade / len(all_assignments)

        db.update_user_grade(self.uid, average_grade, conn)
        db.update_user_time(self.uid, user_total_time, conn)
Пример #2
0
    def display_attempts(self, uid, aid):
        '''
		Create a listbox to display student attempts for assignment
		selected on the screen ViewStudentGrades
		'''
        #split the selection strng to get the 'aid'
        user_attempts = db.get_user_attempts(aid, uid, conn)
        filter_frame = ttk.Frame(self)
        # create a new scrollbar
        scrollbar = ttk.Scrollbar(filter_frame, orient='vertical')
        # create a listbox widget
        self.list_box = tk.Listbox(filter_frame,
                                   yscrollcommand=scrollbar.set,
                                   width=30,
                                   height=8)
        #configure the scrollbar
        scrollbar.config(command=self.list_box.yview)
        scrollbar.pack(side="right", fill="y")
        # adds the listbox to a listbox dictionary with given key
        self.list_box.pack(side="left", fill="both")

        last_a = user_attempts[-1]
        self.stu_grade = int(last_a[3])
        a_num = 1
        for attempt in user_attempts:
            # go through each of the user's attempt
            list_entry = self.update_attempts_table(self, *attempt, a_num)
            self.list_box.insert(END, list_entry)
            a_num += 1
        self.display_labels()
        filter_frame.grid(row=4, column=2, padx=10)
Пример #3
0
    def gen_rows(self, uid, aid):

        all_attempts = db.get_user_attempts(str(aid), uid, conn)
        # set iterator for grid rows
        i = 0
        atid = 1

        # for each id create a row
        for attempts in all_attempts:

            # create new entries
            submission_label = Label(self, font=REGULAR_FONT, text=attempts[5])
            grade_label = Label(self, font=REGULAR_FONT, text=attempts[4])

            # add to corresponding dictonaries with user ids as keys
            self.submissions.append(submission_label)
            self.grades.append(grade_label)

            # create new buttons
            view_attempt_button = self.create_button(self, "View")
            view_attempt_button.config(command=lambda j=atid: self.cont.
                                       show_frame("ViewAttempt", uid, aid, j))
            self.buttons.append(view_attempt_button)

            # add to corresponding dictonaries with user ids as keys

            # set everything nicely on the grid using an iterator i
            submission_label.grid(row=i + 3, column=0)
            grade_label.grid(row=i + 3, column=1)
            view_attempt_button.grid(row=i + 3, column=2)

            atid += 1
            i += 1
Пример #4
0
    def create_listbox(self, eventObject):
        self.all_grades = 0
        self.num_users = 0
        self.drop_down_selection = self.dropdown.get()
        #split the selection strng to get the 'aid'
        result = self.drop_down_selection.split()
        aid = int(result[1])
        user_ids = db.get_users_ids_assignment(aid, conn)
        new_frame = ttk.Frame(self)
        # create a new scrollbar
        scrollbar = ttk.Scrollbar(new_frame, orient='vertical')
        # create a listbox widget
        self.list_box = tk.Listbox(new_frame,
                                   yscrollcommand=scrollbar.set,
                                   width=40,
                                   height=8)
        #configure the scrollbar
        scrollbar.config(command=self.list_box.yview)
        scrollbar.pack(side="right", fill="y")
        # adds the listbox to a listbox dictionary with given key
        self.list_box.pack(side="left", fill="both")
        new_frame.grid(row=4, column=1, padx=15)
        for uid in user_ids:
            # get all the attempts for the user id
            attempts = db.get_user_attempts(aid, uid, conn)
            # get the last attempt
            last_a = attempts[-1]
            user_result = self.update_grades_table(self, *last_a)
            # return it
            self.list_box.insert(END, user_result)

        self.show_average()
Пример #5
0
    def create_listbox(self, eventObject):
        ''' Create a listbox for the last 
		attempt of each user for selected assignment
		@param eventObject, dropdown menu item selected		
		'''
        my_frame = ttk.Frame(self.lb_frame)
        drop_results = self.dropdown.get()
        #split the selection strng to get the 'aid'
        aid = drop_results.split()[1]
        self.aid = int(aid)
        user_ids = db.get_users_ids_assignment(self.aid, conn)
        lb_frame = self.create_list_box_loc(my_frame, "results")
        lb_frame.grid(row=1, column=0)
        max_len = self.get_longest_username(user_ids)
        #label_string = "Uid   Name   Grade  Attempts"
        label_string = "{:>4}   {:<7}   {:>7}  {:>4}"
        label_string = label_string.format("Uid", "Name", "Grade", "Attempts")
        lb = self.list_box["results"]
        lb.insert(END, label_string)
        for user in user_ids:
            # get all the attempts for the user id
            attempts = db.get_user_attempts(self.aid, user, conn)
            user_result = self.update_grades_table(self.uids[user], user,
                                                   attempts, max_len)
            # place it in the lists_box
            lb.insert(END, user_result)

        self.average_labels(my_frame, user_ids).grid(row=0,
                                                     column=0,
                                                     columnspan=3)
        self.contents = lb.get(1, lb.size())
        my_frame.grid(row=0, column=0, rowspan=2)
Пример #6
0
    def test_view_graded_submission_upon_submit(self):

        test = db.get_user_attempts(str(row + 1), 200, conn)
        for x in test:
            if x[4] != "":
                self.assertTrue(x[5] != "")
            if x[5] != "":
                self.assertTrue(x[4] != "")
Пример #7
0
 def update_submission_time(self):
     '''
     gets the current time upon submission and calls a db function to update
     the user's attempt row with the new submission time
     '''
     now = time.strftime("%d/%m/%Y\n%H:%M:%S")
     db.update_assignment_submission_for_user_for_nth_attempt(
         self.aid, self.uid,
         len(db.get_user_attempts(self.aid, self.uid, conn)), now, conn)
Пример #8
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()
Пример #9
0
    def gen_rows(self):
        ids = db.get_assignments_ids(conn)
        # set iterator for grid rows
        i = 1

        # for each id create a row
        for aid in ids:
            # get the attempts for the user
            attempts = db.get_user_attempts(str(aid), self.uid, conn)
            # get the assignment details
            dets = db.get_assignment_details(aid, conn)
            # create new entries

            name_label = self.create_label(self,
                                           text=dets[1],
                                           font=REGULAR_FONT)
            deadline_label = self.create_label(self,
                                               text=dets[4],
                                               font=REGULAR_FONT)
            try:
                grade_label = self.create_label(self,
                                                text=attempts[-2][4],
                                                font=REGULAR_FONT)
            except IndexError:
                grade_label = self.create_label(self,
                                                text=attempts[-1][4],
                                                font=REGULAR_FONT)

            # add to corresponding dictonaries with user ids as keys
            self.names[aid] = name_label
            self.deadlines[aid] = deadline_label
            self.grades[aid] = grade_label

            # create new buttons
            past_attempt_button = self.create_button(self, "Past Attempts")
            new_attempt_button = self.create_button(self, "Current Attempt")
            new_attempt_button.config(
                command=lambda j=[aid, self.atid]: self.cont.show_frame(
                    "Attempt", self.real_uid, j[0], j[1]))
            past_attempt_button.config(
                command=lambda j=[aid, self.atid]: self.cont.show_frame(
                    "ViewPastAttempt", self.real_uid, j[0], j[1]))

            # add to corresponding dictonaries with user ids as keys
            self.past_attempts[aid] = past_attempt_button
            self.new_attempts[aid] = new_attempt_button

            # set everything nicely on the grid using an iterator i
            name_label.grid(row=i + 3, column=0)
            deadline_label.grid(row=i + 3, column=1)
            grade_label.grid(row=i + 3, column=2)
            new_attempt_button.grid(row=i + 3, column=3)
            past_attempt_button.grid(row=i + 3, column=4)

            i += 1
Пример #10
0
 def test_update_user_nth_attempt_assignment_submission(self):
     db.update_assignment_submission_for_user_for_nth_attempt(
         row + 1, 200, 2, "2018/15/04", conn)
     test = db.get_user_attempts(str(row + 1), 200, conn)
     self.assertEqual(test[0][5], "8")
     self.assertEqual(test[1][5], "2018/15/04")
Пример #11
0
 def test_update_user_nth_attempt_assignment_progress(self):
     db.update_assignment_progress_for_user_for_nth_attempt(
         row + 1, 200, 1, "[1,1,4]", conn)
     test = db.get_user_attempts(str(row + 1), 200, conn)
     self.assertEqual(test[0][3], "[1,1,4]")
     self.assertEqual(test[1][3], "[0,0,0]")
Пример #12
0
 def test_update_all_user_attempt_grades(self):
     db.update_attempt_grade_for_user(row + 1, 200, "100", conn)
     test = db.get_user_attempts(str(row + 1), 200, conn)
     self.assertEqual(test[0][4], "100")
     self.assertEqual(test[1][4], "100")
Пример #13
0
 def test_update_user_nth_attempt_grade(self):
     db.update_attempt_grade_for_user_for_nth_attempt(
         row + 1, 200, 1, "20", conn)
     test = db.get_user_attempts(str(row + 1), 200, conn)
     self.assertEqual(test[0][4], "20")
Пример #14
0
 def test_get_user_attempts(self):
     test = db.get_user_attempts(str(row + 1), 200, conn)
     self.assertEqual(test, [(1, 200, '[1,2,3]', '[60,0,2]', '100', '8')])
Пример #15
0
        self.atid = atid
        self.gen_rows()

    def gen_rows(self):
        ids = db.get_assignments_ids(conn)
        # set iterator for grid rows
<<<<<<< HEAD
        i = 0
=======
        i = 1
>>>>>>> working_final

        # for each id create a row
        for aid in ids:
            # get the attempts for the user
            attempts = db.get_user_attempts(str(aid), self.uid, conn)
            # get the assignment details
            dets = db.get_assignment_details(aid, conn)
            # create new entries

            name_label = self.create_label(self, text=dets[1], font=REGULAR_FONT)
            deadline_label = self.create_label(self, text=dets[4], font=REGULAR_FONT)
            try :
                grade_label = self.create_label(self, text=attempts[-2][4], font=REGULAR_FONT)
            except IndexError:
                grade_label = self.create_label(self, text=attempts[-1][4], font=REGULAR_FONT)

            # add to corresponding dictonaries with user ids as keys
            self.names[aid] = name_label
            self.deadlines[aid] = deadline_label
            self.grades[aid] = grade_label
Пример #16
0
 def test_update_all_user_assignment_progress(self):
     db.update_assignment_progress_for_user(row + 1, 200, "[42,42,42]",
                                            conn)
     test = db.get_user_attempts(str(row + 1), 200, conn)
     self.assertEqual(test[0][3], "[42,42,42]")
     self.assertEqual(test[1][3], "[42,42,42]")
Пример #17
0
		user_ids = db.get_users_ids_assignment(self.aid,conn)
		lb_frame = self.create_list_box_loc(my_frame, "results")
		lb_frame.grid(row=1, column=0)
		max_len = self.get_longest_username(user_ids)
		#label_string = "Uid   Name   Grade  Attempts"
<<<<<<< HEAD
		label_string = "{:>4}   {:<7}   {:>7}  {:>4}"
=======
		label_string = "{:>3}    {:<7}    {:>3}    {:>3}"
>>>>>>> working_final
		label_string = label_string.format("Uid", "Name", "Grade", "Attempts")
		lb = self.list_box["results"]
		lb.insert(END, label_string)
		for user in user_ids:
			# get all the attempts for the user id
			attempts = db.get_user_attempts(self.aid, user, conn)
			user_result = self.update_grades_table(self.uids[user],
			                                user, attempts,
			                                max_len)
			# place it in the lists_box
			lb.insert(END, user_result)
			
		self.average_labels(my_frame, user_ids).grid(row=0, column=0,
		                                   columnspan=3)
		self.contents = lb.get(1, lb.size())
		my_frame.grid(row=0, column=0, rowspan=2)
		
	
	def filter_options(self):
		'''opens up the filter menu to filter results
		in the assignment'''