Exemple #1
0
 def create_labelled_entry(self, item):
     my_frame = Frame(self)
     max_score = self.max_mark[item] 
     self.labels[item] = Label(my_frame, text="%s out of %.1f"%(item,max_score))
     self.labels[item].pack({"side":"left"})
     raw_enterbox = Entry(my_frame)
     raw_enterbox.pack({"side":"left"})
     raw_enterbox["textvariable"] = self.raw[item]
     percent = mf.percentage(self.raw[item].get(), max_score)
     self.percent[item] = Label(my_frame, text="%.2f percent"%(percent))
     self.percent[item].pack({"side":"left"})
     raw_enterbox.bind('<Key-Return>', self.recalculate_percentages)
     raw_enterbox.bind('<Key-Tab>', self.recalculate_percentages)
     my_frame.pack()
import mark_functions

print('calling mark_functions.percentage(15, 20)')
print('expected 75.0, returned', mark_functions.percentage(15, 20))

print('calling mark_functions.percentage(4.5, 4.5)')
print('expected 100.0, returned', mark_functions.percentage(4.5, 4.5))

#print ('calling mark_functions.contribution(50, 12.5)')
#print ('expected 6.25, returned',mark_functions.contribution(50, 12.5))

#print ('calling mark_functions.raw_contribution(13.5, 15, 10)')
#print ('expected 9.0, returned',mark_functions.raw_contribution(13.5, 15, 10))

#print ('calling mark_functions.assignments_contribution(30, 32, 20)')
#print ('expected 21.6, returned',mark_functions.assignments_contribution(30, 32, 20))

#print ('calling mark_functions.term_work_mark(16, 7.5, 4, 80)')
#print ('expected 35.5, returned', mark_functions.term_work_mark(16, 7.5, 4, 80))

#print ('calling mark_functions.exam_required(56, 91)')
#print ('expected 100.0, returned', mark_functions.exam_required(56, 91))
Exemple #3
0
 def recalculate_percentages(self, event):
     for work in self.term_work_items:
         new_val = mf.percentage(self.raw[work].get(),
                                             self.max_mark[work])
         self.percent[work]["text"] = "(%.2f percent)"%(new_val)
Exemple #4
0
import mark_functions as mf

print ('Calling mark_functions.percentage(15, 20)')
print ('Expected 75.0, returned', mf.percentage(15, 20), '\n')

print ('Calling mark_functions.percentage(4.5, 4.5)')
print ('Expected 100.0, returned', mf.percentage(4.5, 4.5), '\n')

print ('Calling mark_functions.contribution(100, 7)')
print ('Expected 7.0, returned', mf.contribution(100, 7), '\n')

print ('Calling mark_functions.raw_contribution(13.5, 15, 10)')
print ('Expected 9.0, returned', mf.raw_contribution(13.5, 15, 10), '\n')

print ('Calling mark_functions.assignments_contribution(32, 30)')
print ('Expected 15.5, returned', mf.assignments_contribution(32, 30), '\n')
    
print ('Calling mark_functions.exercises_contribution(10, 10, 5, 10)')
print ('Expected 10.5, returned',
       mf.exercises_contribution(10, 10, 5, 10), '\n')

print ('Calling mark_functions.test_contribution(21)')
print ('Expected 11.76, returned', mf.test_contribution(21), '\n')

print ('Calling mark_functions.term_work_mark(16, 10.5, 4, 5, 12)')
print ('Expected 47.5, returned', mf.term_work_mark(16, 10.5, 4, 5, 12), '\n')

print ('Calling mark_functions.exam_required(47, 80)')
print ('Expected 75.0, returned', mf.exam_required(47, 80), '\n')