<commit_before>from django.shortcuts import render, redirect
from django.template import RequestContext
from django.contrib.auth import logout as auth_logout
from repo.models import Course, ICan, LearningObjective, MultipleChoiceItem, GlossaryItem, ReferenceText, TrueFalseItem


def index(request):
    course_list = Course.objects.order_by('id')
    context = RequestContext(request, {'course_list': course_list})
    return render(request, 'repo/index.html', context)


def detail(request, course_id):
    course = Course.objects.get(id=course_id)
    objective_list = LearningObjective.objects.filter(course=course_id).order_by('id')
    context = RequestContext(request, {'objective_list': objective_list,
                                       'course': course,
                                       'course_id': course_id})
    return render(request, 'repo/course.html', context)


def by_objective(request, course_id, objective_id):
    objective = LearningObjective.objects.get(id=objective_id)
    ican_items = ICan.objects.filter(learning_objective=objective_id)
    glossary_items = GlossaryItem.objects.filter(learning_objective=objective_id)
    multiple_choice_items = MultipleChoiceItem.objects.filter(learning_objective=objective_id)
    tf_items = TrueFalseItem.objects.filter(learning_objective=objective_id)
    reference_text = ReferenceText.objects.filter(learning_objective=objective_id)
    if reference_text:<commit_msg>better ordering for reference list of courses<commit_after>from django.shortcuts import render, redirect
from django.template import RequestContext
from django.contrib.auth import logout as auth_logout
from repo.models import Course, ICan, LearningObjective, MultipleChoiceItem, GlossaryItem, ReferenceText, TrueFalseItem


def index(request):
    course_list = Course.objects.order_by('cat__id', 'id')
    context = RequestContext(request, {'course_list': course_list})
    return render(request, 'repo/index.html', context)


def detail(request, course_id):
    course = Course.objects.get(id=course_id)
    objective_list = LearningObjective.objects.filter(course=course_id).order_by('id')
    context = RequestContext(request, {'objective_list': objective_list,
                                       'course': course,
                                       'course_id': course_id})
    return render(request, 'repo/course.html', context)


def by_objective(request, course_id, objective_id):
    objective = LearningObjective.objects.get(id=objective_id)
    ican_items = ICan.objects.filter(learning_objective=objective_id)
    glossary_items = GlossaryItem.objects.filter(learning_objective=objective_id)
    multiple_choice_items = MultipleChoiceItem.objects.filter(learning_objective=objective_id)
    tf_items = TrueFalseItem.objects.filter(learning_objective=objective_id)
    reference_text = ReferenceText.objects.filter(learning_objective=objective_id)
    if reference_text:
{'fraction_non_alphanumeric': 0.08960817717206133, 'fraction_numerical': 0.0, 'mean_word_length': 4.734375, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3594663', 'n_tokens_mistral': 833, 'n_tokens_neox': 819, 'n_words': 154}