コード例 #1
0
ファイル: updates.py プロジェクト: 0Jihad/uqhs
def subject_position_updates(request, pk, term):  #all
    if int(term) == 4:
        query = ANNUAL.objects.select_related('subject_by').filter(
            subject_by__exact=BTUTOR.objects.get(pk=pk))
        students = [
            x[:] for x in list(query.values_list('Agr', 'id')) if x[0] != None
        ]
    else:
        query = QSUBJECT.objects.select_related('tutor').filter(
            tutor__exact=BTUTOR.objects.get(pk=pk))
        students = [
            x[:] for x in list(query.values_list('agr', 'id')) if x[0] != None
        ]
    agr = [r[0] for r in students]  ###############news
    posi = do_positions(agr[:])
    ids = [r[1] for r in students]
    if int(term) == 4:
        for i in range(0, len(agr)):
            objs = ANNUAL.objects.get(pk=ids[i])
            objs.grade = do_grades([int(objs.Agr)],
                                   cader(BTUTOR.objects.get(pk=pk).Class))[0]
            objs.Posi = posi[i]
            objs.save()
        return redirect('subject_view', pk=pk, md=2)
    else:
        for i in range(0, len(agr)):
            objs = QSUBJECT.objects.get(pk=ids[i])
            objs.posi = posi[i]
            objs.save()
        return redirect('subject_view', pk=pk, md=1)
コード例 #2
0
ファイル: updates.py プロジェクト: 0Jihad/uqhs
def single_student_update(request, pk):  #student
    obj = QSUBJECT.objects.get(pk=pk)
    if obj.tutor != None:
        obj.total = obj.test + obj.agn + obj.atd
        obj.agr = obj.exam + obj.total
        obj.grade = do_grades([obj.agr], cader(obj.tutor.Class))[0]
        obj.save()
        return redirect('position_updates', pk=obj.tutor.id, term=3)
    else:
        return redirect('home')
コード例 #3
0
ファイル: updates.py プロジェクト: 0Jihad/uqhs
def many_student_updates(request, pk):  #tutor
    query = QSUBJECT.objects.select_related('tutor').filter(
        tutor__exact=BTUTOR.objects.get(pk=pk))
    students = list(query.values_list('id'))
    ids = [r[0] for r in students]
    for i in range(0, query.count()):
        obj = QSUBJECT.objects.get(pk=ids[i])
        obj.total = obj.test + obj.agn + obj.atd
        obj.agr = obj.exam + obj.total
        obj.grade = do_grades([obj.agr], cader(obj.tutor.Class))[0]
        obj.save()
    return redirect('position_updates', pk=pk, term=3)
コード例 #4
0
ファイル: creates.py プロジェクト: 0Jihad/uqhs
def create_new_subject_teacher(
    request
):  # teacher form for every new term, class, subjects, subject_per_name
    if request.method == 'POST':
        result = subject_class_term_Form(request.POST)
        if result.is_valid():
            unique = BTUTOR.objects.filter(
                accounts__exact=request.user,
                term__exact='1st Term',
                Class__exact=result.cleaned_data['Class'],
                subject__exact=result.cleaned_data['subject'],
                teacher_name__exact=
                f'{request.user.profile.title}{request.user.profile.last_name} : {request.user.profile.first_name}',
                session__exact=session).count()
            if unique == 0:
                new_teacher = BTUTOR(
                    accounts=request.user,
                    subject=result.cleaned_data['subject'],
                    Class=result.cleaned_data['Class'],
                    term='1st Term',
                    cader=cader(result.cleaned_data['Class']),
                    teacher_name=
                    f'{request.user.profile.title}{request.user.profile.last_name} : {request.user.profile.first_name}',
                    session=session)
                new_teacher.save()
                TUTOR_HOME(
                    tutor=request.user,
                    teacher_name=
                    f'{request.user.profile.title}{request.user.profile.last_name} : {request.user.profile.first_name}',
                    first_term=new_teacher).save()
                return redirect('upload_txt', pk=new_teacher.id)
            else:
                others = BTUTOR.objects.filter(
                    accounts__exact=request.user,
                    subject__exact=result.cleaned_data['subject']).order_by(
                        'id')
                page = request.GET.get('page', 1)
                paginator = Paginator(others, 30)
                try:
                    all_page = paginator.page(page)
                except PageNotAnInteger:
                    all_page = paginator.page(1)
                except EmptyPage:
                    all_page = paginator.page(paginator.num_pages)
                return render(request, 'result/first_term_record_notify.html',
                              {
                                  'all_page': all_page,
                                  'tutor': result.cleaned_data['subject']
                              })
    else:
        result = subject_class_term_Form()
        return render(request, 'result/create_new_teacher.html',
                      {'result': result})
コード例 #5
0
ファイル: creates.py プロジェクト: 0Jihad/uqhs
def update_teacher_class(request, pk, tr):
    previous = TUTOR_HOME.objects.get(first_term=BTUTOR.objects.get(pk=pk))
    term = ['1st Term', '2nd Term', '3rd Term'][int(tr)]
    if BTUTOR.objects.filter(
            accounts__exact=request.user,
            subject__exact=previous.first_term.subject,
            Class__exact=previous.first_term.Class,
            term__exact=term,
            cader__exact=cader(previous.first_term.Class),
            teacher_name__exact=
            f'{request.user.profile.title}{request.user.profile.last_name} : {request.user.profile.first_name}',
            session=session).count() == 0:
        new_term = BTUTOR(
            accounts=request.user,
            subject=previous.first_term.subject,
            Class=previous.first_term.Class,
            term=term,
            cader=cader(previous.first_term.Class),
            teacher_name=
            f'{request.user.profile.title}{request.user.profile.last_name} : {request.user.profile.first_name}',
            session=session)
        new_term.save()
        if term == '2nd Term':
            previous.second_term = new_term
        else:
            if term == '3rd Term':
                previous.third_term = new_term
        previous.save()
        pk = new_term.id
    if term == '3rd Term' and BTUTOR.objects.filter(
            accounts__exact=request.user,
            subject__exact=previous.first_term.subject,
            Class__exact=previous.first_term.Class,
            term__in=['1st Term', '2nd Term'],
            cader__exact=cader(previous.first_term.Class),
            teacher_name__exact=
            f'{request.user.profile.title}{request.user.profile.last_name} : {request.user.profile.first_name}',
            session=session).count() == 1:
        return redirect('home')
    return redirect('upload_txt', pk=pk)
コード例 #6
0
ファイル: models.py プロジェクト: 0Jihad/uqhs
 def save(self):
     if self.subject_by.term == '3rd Term':
         from statistics import mean
         from result.utils import do_grades, cader
         qsubject = QSUBJECT.objects.filter(student_name__exact = self.student_name, tutor__Class__exact = self.subject_by.Class, tutor__subject__exact = self.subject_by.subject, tutor__session__exact = self.subject_by.session)
         listed = [i[0] for i in list(qsubject.values_list('agr'))]
         if len(listed) != 0:
             if len(listed) == 3:
                 self.first = qsubject[0]
                 self.second = qsubject[1]
                 self.anual = qsubject[0].agr + qsubject[1].agr + self.third.agr 
                 self.Agr = round(mean([qsubject[0].agr , qsubject[1].agr, self.third.agr]), 2)
                 self.Grade = do_grades([int(mean([qsubject[0].agr , qsubject[1].agr, self.third.agr]))], cader(self.third.tutor.Class))[0]
             elif len(listed) == 2:
                 self.second = qsubject[1]
                 self.anual = qsubject[1].agr + self.third.agr 
                 self.Agr = round(mean([qsubject[1].agr, self.third.agr]), 2)
                 self.Grade = do_grades([int(mean([qsubject[1].agr, self.third.agr]))], cader(self.third.tutor.Class))[0]
             elif len(listed) == 1:
                 self.anual = self.third.agr 
                 self.Agr = self.third.agr
                 self.Grade = do_grades([int(mean([self.third.agr]))], cader(self.third.tutor.Class))[0]
     super(ANNUAL, self).save()
コード例 #7
0
ファイル: explorer.py プロジェクト: 0Jihad/uqhs
def create_student_annual(request):
        global dim
        trace = [['CHE', 'ACC', 'ARB'], ['GOV', 'ICT', 'HIS'], ['GEO', 'AGR', 'YOR'], ['BST', 'BIO', 'ECO'], ['BUS', 'PHY', 'LIT', 'COM'], ['ELE', 'CTR', 'GRM', 'PRV']]
        annuals = ANNUAL.objects.select_related('subject_by').filter(subject_by__subject__name__exact= 'ENG', subject_by__Class__exact=request.user.profile.class_in, subject_by__session__exact = session)
        if len(annuals) != 0:
            ids = [x for x in list(annuals.values_list('id'))]
            c, j = [None, None]
            for r in range(0, len(ids)):
                name = ANNUAL.objects.get(id=ids[r][0])
                a = return_value_or_None(request, ids[r][0], trace[0])
                b = return_value_or_None(request, ids[r][0], trace[1])
                if name.subject_by.Class== 'SSS 1' or name.subject_by.Class== 'SSS 2' or name.subject_by.Class== 'SSS 3':#yor
                    c = return_value_or_None(request, ids[r][0], trace[2])
                d = return_value_or_None(request, ids[r][0], trace[3])
                e = return_value_or_None(request, ids[r][0], trace[4])   
                f = return_value_or_None(request, ids[r][0], trace[5])
                #['MAT', 'NAV', 'IRS', 'AGR'] ['MAT', 'CIV', 'IRS']
                g = return_value_or_None(request, ids[r][0], ['MAT'])
                h = return_value_or_None(request, ids[r][0], ['CIV', 'NAV'])
                i = return_value_or_None(request, ids[r][0], ['IRS'])     
                if name.subject_by.Class== 'JSS 1' or name.subject_by.Class== 'JSS 2' or name.subject_by.Class== 'JSS 3':#agr
                    c = return_value_or_None(request, ids[r][0], ['YOR'])
                    j = return_value_or_None(request, ids[r][0], ['AGR'])            #i
                if len(dim) != 0:
                    OVERALL_ANNUAL.objects.create(student_name=name.student_name, class_in=name.subject_by.Class, teacher_in=request.user,  session=name.subject_by.session, acc = a, ict = b, yor = c, bst = d, bus = e, prv = f, eng = name, mat = g, nva = h, irs = i, agr = j, AGR = round(sum(dim),2), AVR = round(mean(dim),2), GRD = do_grades([int(mean(dim))], cader(get_object_or_404(ANNUAL, pk=ids[r][0]).third.tutor.Class))[0]).save()
                dim = []  
        else:
             return redirect('home')
コード例 #8
0
ファイル: imports.py プロジェクト: 0Jihad/uqhs
def upload_new_subject_scores(request, pk):
    start_time = time.time()
    tutor = get_object_or_404(BTUTOR, pk=pk) 
    if request.method == "POST":
        my_file = request.FILES['files'] # get the uploaded file
        if not my_file.name.endswith('.txt'):
            return render(request, 'result/file_extension_not_txt.html')
        file_txt = my_file.read().decode("ISO-8859-1")
        if tutor.term == '3rd Term':
            if len(set([i[0] for i in[x for x in list(QSUBJECT.objects.filter(tutor__Class__exact = tutor.Class, tutor__subject__exact = tutor.subject, tutor__session__exact = tutor.session).values_list('tutor'))]])) != 2:
                return redirect('home')
        contents = file_txt.split('\n');
        named_scores = [[], [], []]#[compltet_data_for_each_student, scores, name_only]
        for line in contents:
            each_student = [new.strip() for new in line.split(',')]
            named_scores[0] += [each_student]
        serial_no = [named_scores[0].index(x) for x in named_scores[0]]#get name indexes
        valid_input = [n[:] for n in named_scores[0] if len(n) > 2]
        males = serial_no[-1]#last_no on male list
        females = len(valid_input) - males
        tutor.males = males
        tutor.females = females
        
        #####################REPEATED NAMES######################################
        word_counts = Counter([r[0] for r in valid_input])
        repeated_name = word_counts.most_common()
        ideces = [list(x) for x in repeated_name if x[1] != 1]
        for i in range(0, len(ideces)):
            repeated_names = [valid_input[valid_input.index(x)][0] + str(valid_input.index(x)) for x in valid_input if x[0] == ideces[i][0]]
            each = [valid_input.index(x) for x in valid_input if x[0] == ideces[i][0]]
            for r in range(0, len(repeated_names)):
                valid_input[each[r]] = str(repeated_names[r])
        
        ##########################ERROR CHECK##############################
        sd = []
        for i in range(0, len(valid_input)):
            output = [check(s) for s in valid_input[i]]
            if len(output) == 9:
                if output != [False, True, True, True, True, True, True, True, True]:
                    return render(request, 'result/InputTypeError.html', {'int':i, 'invalid': valid_input[i], 'pk':tutor.id})
            elif len(output) == 5:
                if output != [False, True, True, True, True]:
                    return render(request, 'result/InputTypeError.html', {'int':i, 'invalid': valid_input[i], 'pk':tutor.id})
            else:
                return render(request, 'result/InputTypeError.html', {'int':i, 'invalid': valid_input[i], 'pk':tutor.id}) 
        ##########################ERROR CHECK##############################
            sd += [[valid_input[i][0]]+[[int(float(ints)) for ints in valid_input[i][1:]]][0]]
        
        if len(sd) == 9:#BST ONLY: Reduced 8 to 4 columns by averaging.
            from statistics import mean
            valid_input = [[round(mean(x[1:3])), round(mean(x[3:5])), round(mean(x[5:7])), round(mean(x[7:9]))] for x in sd]
        else:
            valid_input = sd
            
        x = cader(tutor.Class)
        raw_scores = [[x[0], x[1], x[2], x[3], sum(x[1:4]), x[4], sum([sum(x[1:4]), x[4]])] for x in valid_input]
        
        posi = do_positions([int(i[-1]) for i in raw_scores][:])
        grade = do_grades([int(i[-1]) for i in raw_scores][:], x)
        
        
        #####################NAMES QUERIES######################################
        Genders = [sorted(raw_scores[:males]), sorted(raw_scores[males:])]#sorted_list
        for i in range(0, 2):
            splited = sorted([x[0].split(' ') for x in Genders[i]])
            for r in range(0, len(splited)):
                unspaced = [i for i in splited[r] if len(i) > 2]+['first_name']
                Genders[i][r][0] = unspaced[0] +" "+ unspaced[1]
        Males = [[list(x) for x in list(CNAME.objects.filter(full_name__in=[x[0] for x in Genders[0]]).values_list('full_name', 'id'))], sorted([x for x in [x[0] for x in Genders[0]] if x not in [x[0] for x in list(CNAME.objects.filter(full_name__in=[x[0] for x in Genders[0]]).values_list('full_name'))]])]
        [[CNAME(full_name = i, gender = 1).save() for i in Males[1] if len(Males[1]) != 0]]#remainder
        if len(Males[1]) != 0:
            Males[0] + [list(x) for x in list(CNAME.objects.filter(full_name__in=[x[0] for x in Genders[0]]).values_list('full_name', 'id'))][0]

        Females = [[list(x) for x in list(CNAME.objects.filter(full_name__in=[x[0] for x in Genders[1]]).values_list('full_name', 'id'))], sorted([x for x in [x[0] for x in Genders[1]] if x not in [x[0] for x in list(CNAME.objects.filter(full_name__in=[x[0] for x in Genders[1]]).values_list('full_name'))]])]
        [[CNAME(full_name = i, gender = 2).save() for i in Females[1] if len(Females[1]) != 0]]#remainder
        if len(Females[1]) != 0:
            Females[0] + [list(x) for x in list(CNAME.objects.filter(full_name__in=[x[0] for x in Genders[1]]).values_list('full_name', 'id'))][0]
        
        
        Both_sex_scores = Genders[0] + Genders[1]
               
        final = [x+[y]+[z] for x,y,z in zip(Both_sex_scores, grade, posi)]#complete scores
        Both_sex_ids = sorted(Males[0], key=sort_key) + sorted(Females[0], key=sort_key)#compltes ids 
        joined_scores_ids = [[str(i[1])]+x[:] for i,x in zip(Both_sex_ids, final)]
        #from django.http import HttpResponse
        #return HttpResponse([len(joined_scores_ids)], content_type='text/plain')#
                                     ########################QUERY SUBJECT MODEL FOR CONTINUATIONS###############################
        
        Both_sex_ids_final = [x for x in joined_scores_ids if x[1] not in [r[0] for r in [list(QSUBJECT.objects.filter(student_name__in=CNAME.objects.filter(full_name__in=[x[1] for x in joined_scores_ids])).distinct().values_list('student_name'))]]]
        
        [QSUBJECT(student_name=CNAME.objects.get(pk=i[0]), test=i[2], agn=i[3], atd=i[4], exam=i[6], total=i[5], agr=i[7], posi=i[9], grade=i[8], tutor = tutor, cader = x).save() for i in Both_sex_ids_final]
        elapsed_time_secs = time.time() - start_time
        msg = "Execution took: %s secs (Wall clock time)" % timedelta(seconds=round(elapsed_time_secs))
        messages.success(request, msg)
        print(msg)
        tutor.save()
        if tutor.term == '3rd Term':
            qs = QSUBJECT.objects.select_related('tutor').filter(tutor__id__exact=pk)
            [ANNUAL(student_name = x.student_name, third = x, subject_by = BTUTOR.objects.get(pk=pk)).save() for x in qs]
    else:#
        return render(request, 'result/loader.html', {'pk':pk, 'qry':tutor})
    ######################STAGE 2 ::: UPLOAD SCORES##################ENDS
    return redirect('subject_view', pk=pk)#summarise all tutor's uploads
コード例 #9
0
ファイル: imports.py プロジェクト: 0Jihad/uqhs
def mass_upload(request):
    start_time = time.time()
    for entry in os.listdir(basepath):#6 entries {JSS1, JSS 2, JSS 3, SSS 1, SSS 2, SSS 3}
        for files in os.listdir(os.path.join(basepath, entry)): #33 + 60
            os.chdir(os.path.join(basepath, entry))
            with open(files, 'r') as file:
                new = files.split("_")#['99', 'SSS 3', '3', 'MAT.txt']
                user = User.objects.get(pk=int(new[0]))#99   'MAT'                     'SSS 3'                                                     '3rd Term'                 's'
                unique = BTUTOR.objects.filter(accounts__exact=user, term__exact=['empty', '1st Term', '2nd Term', '3rd Term'][int(new[2])], Class__exact=new[1], subject__exact = ASUBJECTS.objects.get(name=new[-1].split('.')[0]), session__exact = session)
                if unique.count() == 0:
                    tutor = BTUTOR(accounts=user, subject = ASUBJECTS.objects.get(name=new[-1].split('.')[0]), Class = new[1], term = ['empty', '1st Term', '2nd Term', '3rd Term'][int(new[2])], cader=cader(new[1]), teacher_name = f'{user.profile.title}{user.profile.last_name} : {user.profile.first_name}', session = session)
                    tutor.save()
                else:
                    tutor = BTUTOR.objects.get(accounts=user, term=['empty', '1st Term', '2nd Term', '3rd Term'][int(new[2])], Class=new[1], subject = ASUBJECTS.objects.get(name=new[-1].split('.')[0]), session = session)
                
                file_txt = file.read()#.decode("ISO-8859-1")
                contents = file_txt.split('\n');
                named_scores = [[], [], []]#[compltet_data_for_each_student, scores, name_only]
                for line in contents:
                    each_student = [new.strip() for new in line.split(',')]
                    named_scores[0] += [each_student]
                serial_no = [named_scores[0].index(x) for x in named_scores[0]]#get name indexes
                valid_input = [n[:] for n in named_scores[0] if len(n) > 2]
                males = serial_no[-1]#last_no on male list
                females = len(valid_input) - males
                tutor.males = males
                tutor.females = females
                tutor.save()
                #####################REPEATED NAMES######################################
                word_counts = Counter([r[0] for r in valid_input])
                repeated_name = word_counts.most_common()
                ideces = [list(x) for x in repeated_name if x[1] != 1]
                for i in range(0, len(ideces)):
                    repeated_names = [valid_input[valid_input.index(x)][0] + str(valid_input.index(x)) for x in valid_input if x[0] == ideces[i][0]]
                    each = [valid_input.index(x) for x in valid_input if x[0] == ideces[i][0]]
                    for r in range(0, len(repeated_names)):
                        valid_input[each[r]] = str(repeated_names[r])
                
                ##########################ERROR CHECK##############################
                sd = []
                for i in range(0, len(valid_input)):
                    output = [check(s) for s in valid_input[i]]
                    if len(output) == 9:
                        if output != [False, True, True, True, True, True, True, True, True]:
                            return render(request, 'result/InputTypeError.html', {'int':i, 'invalid': valid_input[i], 'pk':tutor.id, 'subject':ASUBJECTS.objects.get(name=new[-1].split('.')[0])})
                    elif len(output) == 5:
                        if output != [False, True, True, True, True]:
                            return render(request, 'result/InputTypeError.html', {'int':i, 'invalid': valid_input[i], 'pk':tutor.id, 'subject':ASUBJECTS.objects.get(name=new[-1].split('.')[0])})
                    else:
                        return render(request, 'result/InputTypeError.html', {'int':i, 'invalid': valid_input[i], 'pk':tutor.id, 'subject':ASUBJECTS.objects.get(name=new[-1].split('.')[0])}) 
                ##########################ERROR CHECK##############################
                    sd += [[valid_input[i][0]]+[[int(float(ints)) for ints in valid_input[i][1:]]][0]]
                
                if len(sd) == 9:#BST ONLY: Reduced 8 to 4 columns by averaging.
                    from statistics import mean
                    valid_input = [[round(mean(x[1:3])), round(mean(x[3:5])), round(mean(x[5:7])), round(mean(x[7:9]))] for x in sd]
                else:
                    valid_input = sd
                    
                x = cader(tutor.Class)
                raw_scores = [[x[0], x[1], x[2], x[3], sum(x[1:4]), x[4], sum([sum(x[1:4]), x[4]])] for x in valid_input]
                
                posi = do_positions([int(i[-1]) for i in raw_scores][:])
                grade = do_grades([int(i[-1]) for i in raw_scores][:], x)
                
                
                #####################NAMES QUERIES######################################
                Genders = [sorted(raw_scores[:males]), sorted(raw_scores[males:])]#sorted_list
                for i in range(0, 2):
                    splited = sorted([x[0].split(' ') for x in Genders[i]])
                    for r in range(0, len(splited)):
                        unspaced = [i for i in splited[r] if len(i) > 2]+['first_name']
                        Genders[i][r][0] = unspaced[0] +" "+ unspaced[1]
                Males = [[list(x) for x in list(CNAME.objects.filter(full_name__in=[x[0] for x in Genders[0]]).values_list('full_name', 'id'))], sorted([x for x in [x[0] for x in Genders[0]] if x not in [x[0] for x in list(CNAME.objects.filter(full_name__in=[x[0] for x in Genders[0]]).values_list('full_name'))]])]
                [[CNAME(full_name = i, gender = 1).save() for i in Males[1] if len(Males[1]) != 0]]#remainder
                if len(Males[1]) != 0:
                    Males[0] + [list(x) for x in list(CNAME.objects.filter(full_name__in=[x[0] for x in Genders[0]]).values_list('full_name', 'id'))][0]
        
                Females = [[list(x) for x in list(CNAME.objects.filter(full_name__in=[x[0] for x in Genders[1]]).values_list('full_name', 'id'))], sorted([x for x in [x[0] for x in Genders[1]] if x not in [x[0] for x in list(CNAME.objects.filter(full_name__in=[x[0] for x in Genders[1]]).values_list('full_name'))]])]
                [[CNAME(full_name = i, gender = 2).save() for i in Females[1] if len(Females[1]) != 0]]#remainder
                if len(Females[1]) != 0:
                    Females[0] + [list(x) for x in list(CNAME.objects.filter(full_name__in=[x[0] for x in Genders[1]]).values_list('full_name', 'id'))][0]
                
                
                Both_sex_scores = Genders[0] + Genders[1]
               
                final = [x+[y]+[z] for x,y,z in zip(Both_sex_scores, grade, posi)]#complete scores
                Both_sex_ids = sorted(Males[0], key=sort_key) + sorted(Females[0], key=sort_key)#compltes ids 
                joined_scores_ids = [[str(i[1])]+x[:] for i,x in zip(Both_sex_ids, final)]
                                             ########################QUERY SUBJECT MODEL FOR CONTINUATIONS###############################
                
                Both_sex_ids_final = [x for x in joined_scores_ids if x[1] not in [r[0] for r in [list(QSUBJECT.objects.filter(student_name__in=CNAME.objects.filter(full_name__in=[x[1] for x in joined_scores_ids])).distinct().values_list('student_name'))]]]
                
                [QSUBJECT(student_name=CNAME.objects.get(pk=i[0]), test=i[2], agn=i[3], atd=i[4], exam=i[6], total=i[5], agr=i[7], posi=i[9], grade=i[8], tutor = tutor, cader = x).save() for i in Both_sex_ids_final]
                elapsed_time_secs = time.time() - start_time
                msg = "Execution took: %s secs (Wall clock time)" % timedelta(seconds=round(elapsed_time_secs))
                messages.success(request, msg)
                print(msg)
                tutor.save()
                if tutor.term == '3rd Term':
                    qs = QSUBJECT.objects.select_related('tutor').filter(tutor__id__exact=tutor.id)
                    [ANNUAL(student_name = x.student_name, third = x, subject_by = BTUTOR.objects.get(pk=tutor.id)).save() for x in qs]                    
                    #agr = [r[0] for r in [x[:] for x in list(ANNUAL.objects.filter(subject_by__exact=tutor).values_list('Agr'))]]###############news
                    agr = [r[0] for r in [x[:] for x in list(ANNUAL.objects.filter(subject_by__exact=tutor).values_list('Agr'))]]###############news
                    posi = do_positions(agr[:])
                    ids = [r[0] for r in [x[:] for x in list(ANNUAL.objects.filter(subject_by__exact=tutor).values_list('id'))]]
                    for i in range(0, len(agr)):
                        objs = ANNUAL.objects.get(pk=ids[i])
                        objs.grade = do_grades([int(objs.Agr)], cader(tutor.Class))[0]
                        objs.Posi = posi[i]
                        objs.save()
                    objs = ANNUAL.objects.get(pk=ids[0])
                    TUTOR_HOME(tutor = objs.first.tutor.accounts, teacher_name = objs.first.tutor.teacher_name, first_term = objs.first.tutor, second_term = objs.second.tutor, third_term = objs.third.tutor).save()
                elapsed_time_secs = time.time() - start_time
                msg = "Execution took: %s secs (Wall clock time)" % timedelta(seconds=round(elapsed_time_secs))
                messages.success(request, msg)
                print(msg)
                file.close()
                new_file = os.path.join(os.path.join(reloadpath, entry), files)
                old_file = os.path.join(os.path.join(basepath, entry), files)
                shutil.move(old_file, new_file)

    ######################STAGE 2 ::: UPLOAD SCORES##################ENDS
    return redirect('home')