示例#1
0
def get_next_problem(request):
    if request.user.userprofile.sequential:
        strategy = 'sequential'
    else:
        strategy = 'random'
        # TODO: Temp hack while EER strategy is not updated with new clusters and problems
        ## strategy = request.user.userprofile.strategy
    problem_id = STRATEGIES_FUNC[strategy](request.user)
    LOGGER.debug("Got problem %s", problem_id)
    if not problem_id:
        return render(request, 'questions/finished.html',
                      {'title': _('Finished')})
    context = get_problem(problem_id)
    return render(request, 'questions/show_problem.html', context)
示例#2
0
def get_user_solution(request, id):
    userlog = UserLog.objects.get(pk=id)
    context = get_problem(userlog.problem_id)
    comments = Comment.objects.filter(userlog=userlog)
    if request.method == "POST":
        form = CommentForm(request.POST)
        if form.is_valid():
            comment = form.save(commit=False)
            comment.user = request.user
            comment.userlog = userlog
            comment.save()
            return redirect('past_solutions', id=userlog.id)
    else:
        form = CommentForm()
    context.update({
        'log': userlog,
        'title': _('Solution'),
        'comments': comments,
        'form': form
    })
    return render(request, 'questions/past_solutions.html', context)
示例#3
0
def show_problem(request, problem_id):
    #try:
    context = get_problem(problem_id)
    #except Problem.DoesNotExist:
    #raise Http404("Problem does not exist")
    return render(request, 'questions/show_problem.html', context)