コード例 #1
0
def get_dataset(request, course=None, use_cgpa=True):
    data = {}
    students = None
    active_students = [
        student for student in Student.objects.all()
        if student.user.studentsetup.allow_my_result_for_analysis
    ]
    preferred_students = [
        student for student in Student.objects.all()
        if cgpaData.get_fcgpa(student.id) >= float(
            0.75 * max(cp.get_grades(student.institution)))
        and student.user.studentsetup.allow_my_result_for_analysis
    ]
    if use_cgpa:
        students = preferred_students
        if request.user.student not in students:
            students.append(request.user.student)
    else:
        students = active_students
    for student in students:
        tmp_data = {}
        results = None
        if course:
            results = get_result_queryset(student).filter(course=course)
        else:
            results = get_result_queryset(student)
        for result in results:
            tmp_data[result.course] = float(result.total_score) / 10
        data[student] = tmp_data

    return data
コード例 #2
0
def course_recommendation(request):
    try:
        own_student = request.user.student
    except:
        pass
    courses = {}
    data = {}
    is_new = True
    if request.user.is_authenticated() and hasattr(request.user, 'student'):
        for result in Result.objects.filter(student=request.user.student):
            if result.total_score < 62.5 and cgpaData.get_fcgpa(
                    own_student.id) < float(
                        max(cp.get_grades(own_student.institution)) * 0.8):
                courses[result.course] = result.total_score
        #get the recommendation for each poorly performed course
        for course in courses:
            dataset = get_dataset(request, course=course)
            matches = top_matches(dataset,
                                  request.user.student,
                                  length=5,
                                  algorithm=euclidean_distance_score)
            data['match'] = matches
    if hasattr(request.user, 'student'):
        is_new = not Result.objects.filter(
            student=request.user.student).exists()
    return {'recommendations': data, 'student_is_new': is_new}
コード例 #3
0
ファイル: views.py プロジェクト: pastorenue/result_analytics
def cgpa_by_level(request,
                  student_slug,
                  chartID='container',
                  chart_type='area',
                  chart_height=300):
    student = get_object_or_404(Student, slug=student_slug)
    fcgpa = cgpaData.get_fcgpa(student.id)
    grades = cp.get_grades(student.institution)
    degree = cp.get_cgpa_comment(student.institution, fcgpa)

    cgpa = []
    level = []
    pseudo_level = []
    data = {'level': [], 'cgpa': []}
    res = Result.objects.filter(student_id=student.id)
    for r in res:
        pseudo_level.append(r.level)
    for i in range(100, 700, 100):
        if i in pseudo_level:
            data['level'].append(i)
            data['cgpa'].append(cgpaData.get_level_cgpa(i, student.id))

    chart = {
        "renderTo": chartID,
        "type": chart_type,
        "height": chart_height,
        "zoomType": 'xy'
    }
    title = {"text": "%s's CGPA Breakdown" % (student)}
    xAxis = {"title": {"text": 'Level'}, "categories": data['level']}
    yAxis = {
        "title": {
            "text": "CGPA values"
        },
        "min": 0,
        "max": max(grades),
        "tickInterval": 0.5
    }
    series = [{"name": "Student CGPA", "data": data['cgpa']}]

    context = {
        'fcgpa': fcgpa,
        'max_grade': max(grades),
        'degree': degree,
        'chartID': chartID,
        'chart': chart,
        'title': title,
        'xAxis': xAxis,
        'student': student,
        'yAxis': yAxis,
        'series': series,
    }

    return render(request, "analyzer/cgpa_level.html", context)
コード例 #4
0
ファイル: views.py プロジェクト: pastorenue/result_analytics
 def get_context_data(self, **kwargs):
     context = super(StudentAnalyticsView, self).get_context_data(**kwargs)
     if Result.objects.filter(student=self.request.user.student).exists():
         context['fcgpa'] = cgpaData.get_fcgpa(self.request.user.student.id)
         context['exam_no'] = Result.objects.filter(student_id=self.request.user.student.id).count()
         context['avg_score'] = "%.2f" % (Result.objects.filter(student_id=self.request.user.student.id).values('total_score')\
                                 .aggregate(avg=Avg('total_score'))['avg'])
         context['high_score'] = Result.objects.filter(student_id=self.request.user.student.id).order_by('-total_score')[0]
     else:
         context['fcgpa'] = max(cp.get_grades(self.request.user.student.institution))
         context['avg_score'] = float(0)
     return context
コード例 #5
0
def performances(request):
    performance_list = {}
    for student in Student.objects.all():
        tmp_dict = {}
        tmp_dict['name'] = student
        tmp_dict['department'] = student.department
        tmp_dict['reg_number'] = student.reg_number
        tmp_dict['user'] = student.user
        try:
            tmp_dict['are_friends'] = Friend.objects.are_friends(
                request.user, student.user)
        except:
            pass
        if student.photo:
            tmp_dict['img'] = student.photo
        else:
            tmp_dict['img'] = 'None'
        tmp_dict['institution'] = student.institution
        if student.result_set.count() > 0:
            tmp_dict['cgpa'] = cgpaData.get_fcgpa(student.id)
        else:
            tmp_dict['cgpa'] = float(max(cp.get_grades(student.institution)))
        performance_list[student] = tmp_dict

    key_list = sorted(performance_list.keys(),
                      key=lambda x: performance_list[x]['cgpa'],
                      reverse=True)
    trending_performances = []
    current_student_rank = None
    count = 0
    for key in key_list:
        count += 1
        if not request.user.is_anonymous() and hasattr(request.user,
                                                       'student'):
            if key == request.user.student:
                current_student_rank = count
        trending_performances.append(performance_list[key])
    return {
        'trending_performances': trending_performances[:5],
        'student_rank': current_student_rank,
    }