Home Backend Development PHP Tutorial Using ThinkPHP5 to implement the processing method of students' unsubmitted homework and submitted homework information in the homework management system

Using ThinkPHP5 to implement the processing method of students' unsubmitted homework and submitted homework information in the homework management system

Jun 08, 2018 am 09:48 AM
thinkphp5 information deal with student

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;
 }
Copy after login

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;
 }
Copy after login

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;
 }
Copy after login

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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1655
14
PHP Tutorial
1252
29
C# Tutorial
1226
24
The operation process of WIN10 service host occupying too much CPU The operation process of WIN10 service host occupying too much CPU Mar 27, 2024 pm 02:41 PM

1. First, we right-click the blank space of the taskbar and select the [Task Manager] option, or right-click the start logo, and then select the [Task Manager] option. 2. In the opened Task Manager interface, we click the [Services] tab on the far right. 3. In the opened [Service] tab, click the [Open Service] option below. 4. In the [Services] window that opens, right-click the [InternetConnectionSharing(ICS)] service, and then select the [Properties] option. 5. In the properties window that opens, change [Open with] to [Disabled], click [Apply] and then click [OK]. 6. Click the start logo, then click the shutdown button, select [Restart], and complete the computer restart.

A quick guide to CSV file manipulation A quick guide to CSV file manipulation Dec 26, 2023 pm 02:23 PM

Quickly learn how to open and process CSV format files. With the continuous development of data analysis and processing, CSV format has become one of the widely used file formats. A CSV file is a simple and easy-to-read text file with different data fields separated by commas. Whether in academic research, business analysis or data processing, we often encounter situations where we need to open and process CSV files. The following guide will show you how to quickly learn to open and process CSV format files. Step 1: Understand the CSV file format First,

Learn how to handle special characters and convert single quotes in PHP Learn how to handle special characters and convert single quotes in PHP Mar 27, 2024 pm 12:39 PM

In the process of PHP development, dealing with special characters is a common problem, especially in string processing, special characters are often escaped. Among them, converting special characters into single quotes is a relatively common requirement, because in PHP, single quotes are a common way to wrap strings. In this article, we will explain how to handle special character conversion single quotes in PHP and provide specific code examples. In PHP, special characters include but are not limited to single quotes ('), double quotes ("), backslash (), etc. In strings

Which computer should Geographic Information Science majors choose? Which computer should Geographic Information Science majors choose? Jan 13, 2024 am 08:00 AM

Recommended computers suitable for students majoring in geographic information science 1. Recommendation 2. Students majoring in geographic information science need to process large amounts of geographic data and conduct complex geographic information analysis, so they need a computer with strong performance. A computer with high configuration can provide faster processing speed and larger storage space, and can better meet professional needs. 3. It is recommended to choose a computer equipped with a high-performance processor and large-capacity memory, which can improve the efficiency of data processing and analysis. In addition, choosing a computer with larger storage space and a high-resolution display can better display geographic data and results. In addition, considering that students majoring in geographic information science may need to develop and program geographic information system (GIS) software, choose a computer with better graphics processing support.

How to write a simple student attendance management system using Java? How to write a simple student attendance management system using Java? Nov 02, 2023 pm 03:17 PM

How to write a simple student attendance management system using Java? With the continuous development of technology, school management systems are also constantly updated and upgraded. The student attendance management system is an important part of it. It can help the school track students' attendance and provide data analysis and reports. This article will introduce how to write a simple student attendance management system using Java. 1. Requirements Analysis Before starting to write, we need to determine the functions and requirements of the system. Basic functions include registration and management of student information, recording of student attendance data and

How to solve the problem after the upgrade from win7 to win10 fails? How to solve the problem after the upgrade from win7 to win10 fails? Dec 26, 2023 pm 07:49 PM

If the operating system we use is win7, some friends may fail to upgrade from win7 to win10 when upgrading. The editor thinks we can try upgrading again to see if it can solve the problem. Let’s take a look at what the editor did for details~ What to do if win7 fails to upgrade to win10. Method 1: 1. It is recommended to download a driver first to evaluate whether your computer can be upgraded to Win10. 2. Then use the driver test after upgrading. Check if there are any driver abnormalities, and then fix them with one click. Method 2: 1. Delete all files under C:\Windows\SoftwareDistribution\Download. 2.win+R run "wuauclt.e

How to get the GPU in Windows 11 and check the graphics card details How to get the GPU in Windows 11 and check the graphics card details Nov 07, 2023 am 11:21 AM

Using System Information Click Start and enter System Information. Just click on the program as shown in the image below. Here you can find most of the system information, and one thing you can find is graphics card information. In the System Information program, expand Components, and then click Show. Let the program gather all the necessary information and once it's ready, you can find the graphics card-specific name and other information on your system. Even if you have multiple graphics cards, you can find most content related to dedicated and integrated graphics cards connected to your computer from here. Using the Device Manager Windows 11 Just like most other versions of Windows, you can also find the graphics card on your computer from the Device Manager. Click Start and then

How NameDrop works on iPhone (and how to disable it) How NameDrop works on iPhone (and how to disable it) Nov 30, 2023 am 11:53 AM

In iOS17, there is a new AirDrop feature that allows you to exchange contact information with someone by touching two iPhones at the same time. It's called NameDrop, and here's how it actually works. NameDrop eliminates the need to enter a new person's number to call or text them so they have your number, you can simply hold your iPhone close to their iPhone to exchange contact information. Putting the two devices together will automatically pop up the contact sharing interface. Clicking on the popup will display a person's contact information and their contact poster (a photo of your own that you can customize and edit, also new to iOS 17). This screen also includes "Receive Only" or share your own contact information in response

See all articles