Skip to content

Instantly share code, notes, and snippets.

def get_highest_score(test_id):
test_attempts = db.session.query(TestAttempt).filter_by(test_id=test_id)
scores = []
if test_attempts.count() < 1:
return {'max_score': 0}
for each in test_attempts:
user_id = each.user_id
test_id = each.test_id
if each.is_complete:
k = get_college_test_attempt_score(test_id, user_id)['score']
@time_analysis_controller.route('/time/question/track', methods=['POST'])
@login_required
def update_question_time():
"""
Update the time spent on a question using the 'heartbeat' signal.
The question attempt is fetched based on the current user and question id.
And a random number between 1 and 5 is added to the time spent.
The update is added to the total time spent for that question attempt
:return: 404 if the question attempt didnt exist, 200 if time was successfully updated
if request.method == 'POST':
json = request.get_json()
question = db.session.query(Question).filter_by(id=question_id).first()
if question.type == 'TITA':
question_attempt = QuestionAttempt(section_attempt_id=section_attempt_id,
question_id=question_id,
tita_choice=json['tita_choice'])
else:
test_attempt_id,test_attempt_user_id,test_attempt_test_id,test_attempt_is_complete,test_attempt_date,test_attempt_score,question_attempt_1_section_attempt_id,question_attempt_1_question_id,question_attempt_1_choice_id,question_attempt_1_tita_choice,question_attempt_1_attempt_status,question_attempt_1_time_spent,section_attempt_1_id,section_attempt_1_section_id,section_attempt_1_test_attempt_id,section_attempt_1_time_left,section_attempt_1_is_complete
1085,2424,105,1,2017-07-21 17:32:45,0,,,,,,,2820,178,1085,1,0
1085,2424,105,1,2017-07-21 17:32:45,0,2821,3751,25352,,submitted,0,2821,179,1085,5,0
1085,2424,105,1,2017-07-21 17:32:45,0,2821,3752,25349,,submitted,0,2821,179,1085,5,0
1085,2424,105,1,2017-07-21 17:32:45,0,2821,3763,25409,,submitted,0,2821,179,1085,5,0
1085,2424,105,1,2017-07-21 17:32:45,0,2821,3764,25412,,submitted,0,2821,179,1085,5,0
1085,2424,105,1,2017-07-21 17:32:45,0,2822,3730,25465,,submitted,0,2822,180,1085,0,0
1176,2424,59,1,2017-07-23 11:33:52,0,3085,1029,9257,,submitted,2,3085,73,1176,1824
@payment_controller.route('/enable_tests', methods=['POST'])
def enable_tests():
json = request.get_json()
test_ids = json['test_ids']
user_id = json['user_id']
wallet_amount_used = json['wallet_amount_used']
user = db.session.query(User).filter_by(id=user_id).first()
if user.wallet is None:
user.wallet = 0
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
def calculate_distance(self,ax,ay,bx,by):
patch_a = self.get_patch_for_coords(self.a_padded,ax,ay)
patch_b = self.get_patch_for_coords(self.b_padded,bx,by)
diff = patch_a - patch_b
distances = np.linalg.norm(diff,axis=0,ord=2)
__global__ void upSample_kernel(unsigned int * ann, unsigned int * ann_tmp,int * params, int aw_half,int ah_half) {
int ax = blockIdx.x*blockDim.x + threadIdx.x;
int ay = blockIdx.y*blockDim.y + threadIdx.y;
int ah = params[1];
int aw = params[2];
int bh = params[3];
int bw = params[4];
sort:
addi $sp,$sp,-40 # allocate space for the return address
sw $ra,4($sp)
sw $s0,8($sp)
sw $s1,12($sp)
sw $s2,16($sp)
sw $s3,20($sp)
sw $s4,24($sp)
sw $s5,28($sp)
sw $s6,32($sp)
#
# FILE: $File$
# AUTHOR: Phil White, RIT 2016
# CONTRIBUTORS:
# W. Carithers
# <<<YOUR NAME HERE>>>
#
# DESCRIPTION:
# This program is an implementation of merge sort in MIPS
# assembly