python project sharing - smart campus examination system based on Django

0 Preface

Hi, everyone, today I will introduce to you a python management system that you can use in your own course design or graduation design!

What I want to share today is: graduation project smart campus examination system based on Django

Project sharing:

https://gitee.com/sinonfin/system-sharing

1 Design description

Enter the command "python manage.py runserver" in the virtual environment to start the project, and then visit "http://127.0.0.1:8000" to enter the homepage of the website, as shown in Figure 1.

Insert image description here
registered user

When the mouse hovers over the "Login" button in the top navigation, click "Password" to log in, and the login box will pop up, as shown in Figure 2. If you do not have an account, you need to click the "Register" button in the login box to register, as shown in Figure 3.

Insert image description here

On the registration page, you need to fill in a real and available email address. After successful registration, email verification is required, as shown in Figure 4. Click the "Send Email" button to be prompted to send the information, as shown in Figure 5.

Insert image description here

Check the mailbox, as shown in Figure 6.

Insert image description here

Since we are testing locally, we cannot directly click the email verification link. We can manually assign the link and then add "http://127.0.0.1:8000" before the link address, that is, the completed link address is: "http://127.0 .0.1:8000/auth/[email protected]&sign=53ec094a-4acf-11e9-8b5b-b0d59d3cadab". Then use the browser to access the address to complete the verification and log in automatically, as shown in Figure 7.

Insert image description here

After registering as a user, you can participate in answering questions, such as selecting popular competitions. Click on a competition to enter the competition information page, as shown in Figure 8.
Insert image description hereClick the "Start Challenge" button to start answering questions, as shown in Figure 9. Click the "View Ranking" button to view the ranking.

Insert image description here
On the answer page, click the "Back" button to return to the previous question; click the "Forward" button to enter the next question; click the "Submit" button to display the answer results, as shown in Figure 10.

Insert image description here

Registration authority

Institutional users can participate in setting questions. Users need to register the structure before they can become institutional users. Click the "Become an Institution" button in the top navigation to enter the registration institution page, as shown in Figure 11. On this page, fill in the email address when the user registered on the website.

Insert image description here
After registration is completed, click the "Quick Question Setting" button at the top of the navigation bar to enter the question setting page. As shown in Figure 12.

Insert image description here
On the quick question creation page, you need to record the question bank first and then configure the competition. Click the "Start Recording" button, as shown in Figure 13. When creating a question bank, you need to download the question bank module first, and then create your own Excel question bank according to the template prompts. Then fill in the question bank name, select the question bank type, upload the Excel file, and finally click the "Start Recording" button to upload the question bank.

Insert image description here

After uploading the question bank, start configuring the competition. On the quick question creation page, click the "Configure Competition" hyperlink to enter the configuration competition page. When configuring the competition, select the question bank and fill in the configuration information. If users need to fill in user information before the competition, they need to check "Enable information entry function" and then check the following fields, as shown in Figure 14. After the configuration is completed, the page jumps to the answering page, click the "Start Challenge" button, and a form pops up to fill in the answering user information. The fields in the form are the content set in the configuration information, as shown in Figure 15.

Insert image description here
Insert image description here

Backstage administrator

The backend administrator can log in to the backend through the account and password, enter the URL "http://127.0.0.1:8000/admin/", and enter the following account and password to log in.
Account: mr
Password: mrsoft
After successful login, enter the backend homepage, as shown in Figure 16. On the background homepage, administrators can perform corresponding management work according to the corresponding menu.

Insert image description here

Some related source codes

# -*- coding: utf-8 -*-

import datetime

from django.conf import settings
from django.contrib.auth import login, logout
from django.contrib.auth.models import User
from django.db import transaction
from django.shortcuts import redirect, render, reverse

from account.models import Profile
from utils.errors import VeriCodeError, VerifyFailed, PasswordResetFailed, UserNotFound, VeriCodeTimeOut
from utils.redis.rprofile import get_signcode, get_passwd


def web_index(request):
    """
    首页渲染视图
    :param request:请求对象
    :return: 渲染视图并返回: user_info:用户信息;upgrade_info: 用户会员信息;has_login: 是否已登录;kinds: 比赛数据
    """

    uid = request.session.get('uid', '')

    try:
        profile = Profile.objects.get(uid=uid)
    except Profile.DoesNotExist:
        profile = None

    return render(request, 'web/index.html', {
    
    
        'user_info': profile and profile.data,
        'upgrade_info': profile and profile.upgrade_data,
        'has_login': bool(profile),
    })


def web_login(request):
    """
    登录页面渲染视图
    :param request: 请求对象
    :return: 渲染视图并返回: login_info: 用户登录所需配置信息;has_login:是否已经登录;user_info:用户信息;upgrade_info: 用户会员信息
    """

    uid = request.session.get('uid', '')

    if uid:
        try:
            profile = Profile.objects.get(uid=uid)
        except Profile.DoesNotExist:
            profile = None

        if profile:
            return render(request, 'web/index.html', {
    
    
                'user_info': profile and profile.data,
                'upgrade_info': profile and profile.upgrade_data,
                'has_login': bool(uid)
            })
        else:
            try:
                del request.session['uid']
            except KeyError:
                pass

    return render(request, 'web/login.html', {
    
    
        'login_info': settings.WXWEB_LOGIN_PARAMS or {
    
    },
        'has_login': False
    })


def web_logout(request):
    """
    用户注销视图
    :param request: 请求对象
    :return: 重定向首页
    """

    logout(request)

    try:
        del request.session['uid']
    except KeyError:
        pass

    return redirect(reverse('web_index'))


def signup_redirect(request):
    """

    :param request: 请求对象
    :return:emai邮箱地址,sign注册验证码
    """

    email = request.GET.get('email', '')
    sign = request.GET.get('sign', '')

    return render(request, 'web/sign_email.html', {
    
    
        'email': email,
        'sign': sign
    })


@transaction.atomic
def email_notify(request):
    email = request.GET.get('email', '')  # 获取要验证的邮箱
    sign = request.GET.get('sign', '')  # 获取校验码
    signcode = get_signcode(sign)  # 在redis校验邮箱
    if not signcode:
        return render(request, 'err.html', VeriCodeTimeOut)  # 校验失败返回错误视图
    if not (email == signcode.decode('utf-8')):
        return render(request, 'err.html', VeriCodeError)  # 校验失败返回错误视图
    try:
        user = User.objects.get(email=email)  # 获取用户
    except User.DoesNotExist:
        user = None
    if user is not None:  # 激活用户
        user.is_active = True
        user.is_staff = True
        user.save()
        login(request, user)  # 登录用户
        profile, created = Profile.objects.select_for_update().get_or_create(  # 配置用户信息
            name=user.username,
            email=user.email,
        )
        profile.user_src = Profile.NORMAL_USER  # 配置用户为普通登录用户
        profile.save()

        request.session['uid'] = profile.uid  # 配置session
        request.session['username'] = profile.name
        return render(request, 'web/index.html', {
    
      # 渲染视图,并返回已登录信息
            'user_info': profile.data,
            'has_login': True,
            'msg': "激活成功",
        })
    else:
        return render(request, 'err.html', VerifyFailed)  # 校验失败返回错误视图

@transaction.atomic
def reset_notify(request):
    email = request.GET.get('email', '')
    sign = request.GET.get('sign', '')
    is_biz = request.GET.get('is_biz')

    password = get_passwd(sign)

    if not password:
        return render(request, 'err.html', PasswordResetFailed)

    try:
        u = User.objects.get(email=email)
    except User.DoesNotExist:
        return render(request, 'err.html', UserNotFound)

    if is_biz == '1':
        u.is_staff = True
        u.is_active = True
    u.set_password(password)
    u.save()

    return render(request, 'web/index.html', {
    
    
        'has_login': False,
        'msg': '密码修改成功!'
    })


def error(request):
    return render(request, 'err.html', {
    
    "errtitle": "页面发生错误", "errmsg": "页面发生未知错误,请联系管理员解决~"})

Project sharing

Project sharing: complete source code + environment configuration document + design manual

https://gitee.com/sinonfin/system-sharing

Guess you like

Origin blog.csdn.net/switch_mooood/article/details/135426892