


This article mainly introduces the thinkingPHP5 implementation of the method of handling students' unpaid homework and handed-in homework information in the homework management system, involving thinkPHP's implementation skills for data table query and traversal operations. Friends in need can refer to the following
The example of this article describes the method of using ThinkPHP5 to handle students' unsubmitted homework and handed-in homework information in the homework management system. Share it with everyone for your reference, the details are as follows:
In the homework management system, after students log in to the personal center, they can view their submitted homework and unsubmitted homework through the menu on the left. So how to query these data in the system? First, we need to figure out the relationship between the three tables of Student, Class, and Submit.
1. Every student belongs to a class
2. Every student in the class will be assigned the same homework
3. After students submit their homework, they will Add response records to the submission table, such as student ID, assignment ID, submitted content, etc.
You can follow the following steps to obtain the submitted homework and unsubmitted homework of students
1. Get all the homework of the student's class
//获取学生所在班级的所有作业 public function getTasks($stuno) { $stu=$this::get(['stu_no'=>$stuno]); $clas=Clas::get(['clas_id'=>$stu['clas_id']]); return $clas->task; }
As can be seen from the above code lesson, first according to Obtain student information through the student ID ($stuno), obtain the class information of the student through the class ID (clas_id) saved in the student information table, and finally obtain the many-to-many relationship between the class and the homework sheet (see the Thinkphp5 official manual for details about the model The related part of the content) to obtain all the assignments assigned by the student's class.
2. Get students’ unsubmitted assignments
//获取某学生所有未交作业 public function getUnSubmitTasks($stuno) { $stu=$this::get(['stu_no'=>$stuno]); $alltask=$this->getTasks($stuno); foreach($alltask as $key=>$value) { if(Submit::get(['task_id'=>$value['task_id'],'stu_id'=>$stu['stu_id']])) { unset($alltask[$key]);//删除已提交作业 } } return $alltask; }
This function first calls the function to obtain all assignments ($this->getTasks($stuno)) to obtain all assignments in the student’s class. This data set is a two-dimensional array. Traverse the two-dimensional array to see if there is any homework in the two-dimensional array that has been submitted to Submit by the student. If so, delete the element.
3. Obtain the homework submitted by students
With the above two functions, it becomes simple to obtain the homework submitted by the students. The two-dimensional array obtained by the first function is subtracted from the second The arrays returned by the two functions are the collection of homework that students have submitted. Just do the difference of the two-dimensional arrays
//获取某学生所有已交作业(所有作业和未交作业的差集) public function getSubmitTasks($stuno) { $unsubmit=$this->getUnSubmitTasks($stuno); $alltasks=$this->getTasks($stuno); $submittasks=array(); foreach ($alltasks as $key=>$value) { if(!in_array($value,$unsubmit)) { $submittasks[]=$value; } } return $submittasks; }
The above is the entire content of this article. I hope it will be helpful to everyone's learning. More Please pay attention to the PHP Chinese website for related content!
Related recommendations:
ThinkPHP realizes the conversion of database query result data into the corresponding type
thinkPHP3.2.3 combines with Laypage to realize the paging function
The above is the detailed content of Using ThinkPHP5 to implement the processing method of students' unsubmitted homework and submitted homework information in the homework management system. For more information, please follow other related articles on the PHP Chinese website!

PDF文件作为一种通用的文件格式,被广泛应用于各种应用场景,如电子书、报表、合同等等。在开发过程中,我们常常需要对PDF文件进行生成、编辑、读取等操作。而PHP作为一种脚本语言,也能够轻松地完成这些任务。本文将介绍使用PHP处理PDF文件的方法。一、生成PDF文件生成PDF文件有许多方法,其中最常见的是使用PDF库。PDF库是一种生成PDF文档的工具,它为

CakePHP是一个开源的Web应用程序框架,它基于PHP语言构建,可以简化Web应用程序的开发过程。在CakePHP中,处理文件上传是一个常见的需求,无论是上传头像、图片还是文档,都需要在程序中实现相应的功能。本文将介绍CakePHP中如何处理文件上传的方法和一些注意事项。在Controller中处理上传文件在CakePHP中,上传文件的处理通常在Cont

宝塔部署thinkphp5报错的解决办法:1、打开宝塔服务器,安装php pathinfo扩展并启用;2、配置“.access”文件,内容为“RewriteRule ^(.*)$ index.php?s=/$1 [QSA,PT,L]”;3、在网站管理里面,启用thinkphp的伪静态即可。

CakePHP是一个流行的PHP开发框架,它可以帮助开发者快速构建高质量的Web应用程序。随着全球化的发展,越来越多的应用需要支持多语言,CakePHP也提供了相应的支持。本文将介绍CakePHP如何处理多语言。一、多语言支持多语言支持是CakePHP的一项重要功能。从版本2.0开始,CakePHP支持gettext文件格式,该

在进行JavaFX应用程序开发的过程中,我们常常会遇到JavaFX线程卡顿错误。这种错误的严重程度不同,可能会对程序的稳定性和性能产生不利的影响。为了保证程序的正常运行,我们需要了解JavaFX线程卡顿错误的原因和解决方法,以及如何预防这种错误的发生。一、JavaFX线程卡顿错误的原因JavaFX是一个多线程的UI应用程序框架,它允许程序在后台线程中执行长时

随着现代Web应用不断发展,PHP作为其中最流行的编程语言之一,被广泛地应用于网站开发中。但在开发过程中,经常会遇到空值错误,而这些错误会导致应用程序抛出异常,进而影响用户的使用体验。因此,在PHP开发过程中,如何检测和处理空值错误,是程序员们需要掌握的重要技能。一、什么是空值错误在PHP开发过程中,空值错误通常指的是两种情况:变量未初始化和变

thinkphp5 post得不到值是因为TP5是通过strpos函数在Header的content-type值中查找app/json字符串的,其解决办法就是设置Header的content-type值为app/json即可。

随着Excel文件在商业领域和日常生活中的不断普及和应用,我们经常需要使用PHP处理Excel文件,例如数据的导入导出,数据的筛选和排序等。因此,本文将介绍如何使用PHP进行Excel文件处理。安装PHPExcel库PHPExcel是一款强大的PHP操作Excel文件的开源库,其支持读取、写入Excel文件,并提供了许多便捷的操作方法。在使用之前需要先安装P


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Zend Studio 13.0.1
Powerful PHP integrated development environment

SublimeText3 Chinese version
Chinese version, very easy to use

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
