Click để truy cậpClick để truy cập

Đề Thi PE PRN222 - SU26 - PE - RE - NO3

adminadmin is verified member.

Well-known member
Thành viên BQT
Administrator
Moderating
Học kỳ
SU2026
Thời Gian
8/8/26
Loại tài liệu
PE
PRN222 SU26 PE RE NO3

Hướng dẫn và đề thi thực hành môn lập trình .NET 8.0 PRN222​

Tài liệu cung cấp hướng dẫn chi tiết và đề thi thực hành cho môn học PRN222 sử dụng nền tảng .NET 8.0 và Visual Studio 2022. Nội dung bao gồm việc xây dựng ứng dụng console quản lý phim qua giao thức TCP và phát triển ứng dụng web xử lý đánh giá sản phẩm. Bên cạnh đó, tài liệu còn quy định cụ thể các yêu cầu giao diện, bộ lọc dữ liệu cùng danhς sách các ID phần tử HTML cần thiết cho bài kiểm tra.

PRN222 Summer Practical Exam Paper No. 3​


Paper No: 3

INSTRUCTIONS

Please read the instructions carefully before doing the questions.
- You can use materials in your computer, notebook and text book.
- You are NOT allowed to use any device to share data with others.

Beside the above conditions, students must follow the following requirements:
1. The work must complete by using Visual Studio 2022++
2. The Framework must be .NET 8.0
3. THIS PART IS VERY IMPORTANT, PLEASE READ IT CAREFULLY AND FOLLOW THE INSTRUCTIONS.
- You are given a database script (.sql file) in Zip file. Execute the script before doing questions.
- You must use the given solution.
- You are not allowed to add any more libraries via NuGet Package Manager into given solution.
- Submission Guideline:
Submit your work for each question separately. For each question, please:
- Publish your project using the command:
dotnet publish -c Release -o ./[QuestionNumber_StudentAccount]
Example:
dotnet publish -c Release -o ./Q1_trungnthe123432
- Submit the root folder of the project into the PEA_Client application.
- If the root folder of the project is too large, you may delete the following subfolders to reduce its size before submitting: /bin, /obj

Just one of above requirements is violated, your work will be considered as invalid.

Question 1:
(4 points)
You are provided with a console application MovieServer in the given materials, which acts as a TCP server. The server listens on 127.0.0.1:5500 and responds to three types of commands. The server operates as follows:
- The server listens for incoming TCP connections on 127.0.0.1:5500.
- For each connection, the server receives one command: a Genre name (e.g., "Action") to filter movies, "CLASSIC" to retrieve movies released before 2005 (classic films), or "ALL" to retrieve the complete list.
- The server processes the command and returns the result as a JSON string.
- The server closes the connection immediately after sending the response.
- For each connected client, the server displays: "Client connected from {IP}:{Port}"

Your task is to develop a .NET 8 console application that acts as a TCP client, connects to the server, and implements the functionality described below.

Movie Data
The following movie data is maintained by the server for your reference.

Movie ID | Title | Genre | Year
M001 | Inception | Action | 2010
M002 | The Notebook | Drama | 2004
M003 | Interstellar | Action | 2014
M004 | Titanic | Drama | 1997
M005 | The Avengers | Action | 2012

Important Notes:
- The server returns JSON with field names exactly: "movieId", "title", "genre", "year".
- The error response JSON field names are exactly: "genre", "status", "message".
- Genre names are case-sensitive when sending to the server.
- The commands "ALL" and "CLASSIC" must be sent exactly as uppercase.
- "CLASSIC" returns all movies across all genres whose release year is strictly less than 2005.
- Zero (0) marks will be awarded for any requirement if the client does not correctly connect to or communicate with the server as specified.

Requirements:
1. Setup and Connect to Server
- When the application starts, display: "Movie Client started. Server: 127.0.0.1:5500"
- For each request, establish a new TCP connection to the server at 127.0.0.1:5500.

2. User Input Loop
- Continuously prompt the user with: "Enter Genre (or CLASSIC / ALL / EXIT):"
- The application loops until the user types "EXIT".
- For each command, establish a TCP connection, send it as plain text, receive the response, display it, then close the connection.

3. Send Genre Query and Display Response
- When the user enters a Genre name, send it to the server. If the server returns a JSON array, display the response: [{"movieId":"M001","title":"Inception","genre":"Action","year":2010},{"movieId":"M003","title":"Interstellar","genre":"Action","year":2014},{"movieId":"M005","title":"The Avengers","genre":"Action","year":2012}]
- Display on the client console: "Received: 3 movie(s) in Action"
- If the server returns a "not found" JSON object, display it as-is: {"genre":"Horror","status":"not found","message":"No movies found from this genre"}
- Display on the client console: "Received: Not found - Horror"

4. Send "CLASSIC" Command and Display Response
- When the user enters "CLASSIC", send it to the server. Display the returned JSON array: [{"movieId":"M002","title":"The Notebook","genre":"Drama","year":2004},{"movieId":"M004","title":"Titanic","genre":"Drama","year":1997}]
- Display on the client console: "Received: 2 classic movie(s) (year < 2005)"

5. Send "ALL" Command and Display Response
- When the user enters "ALL", send it to the server and display the complete JSON array: &#91;{"movieId":"M001","title":"Inception","genre":"Action","year":2010},{"movieId":"M002","title":"The Notebook","genre":"Drama","year":2004},...&#93;
- Display on the client console: "Received: 5 movie(s) in total"

6. Handle Connection Errors
- Handle connection errors gracefully (server unavailable, connection refused). Display an error message without crashing.
- After each request, properly close the NetworkStream and TcpClient.
- If the server is not running, display: "Cannot connect to server at 127.0.0.1:5500"

Additional Notes:
- Use try-catch blocks for exception handling.
- Use using statements or try-finally blocks for proper disposal of NetworkStream and TcpClient.
- The client uses a request-response model: one new connection per command, close after receiving the response.
- Parse the server's JSON response using System.Text.Json or Newtonsoft.Json.
- The year field in the JSON response is a number. Example: "year":2010.

Question 2:
Product Review Management
6 points
In this question, you are asked to write a web application using ASP.NET Core MVC, Razor Pages, or Blazor (your choice), using a database that has the following schema:

Database Schema:
Table: Products
Column: ProductId | Data Type / Notes: INT - Primary Key, auto-increment
Column: ProductName | Data Type / Notes: NVARCHAR(100) - product name
Column: Category | Data Type / Notes: NVARCHAR(50) - category

Table: Reviews
Column: ReviewId | Data Type / Notes: INT - Primary Key, auto-increment
Column: ProductId | Data Type / Notes: INT - Foreign Key -> Products.ProductId
Column: ReviewerName | Data Type / Notes: NVARCHAR(100) - reviewer full name
Column: Rating | Data Type / Notes: INT - rating from 1 to 5
Column: Comment | Data Type / Notes: NVARCHAR(250) - review comment
Column: ReviewDate | Data Type / Notes: DATETIME - review date

1. Important Notes:
- It is required to assign the URL to access the web pages exactly as given in the requirements. A wrong URL means the examiner cannot access the page, and you will receive zero marks for that feature.
- Zero marks will be awarded if the database connection string is not stored in the file appsettings.json.

PRN222 SU26 PE RE NO3 Paper No 3​


6 of 7 Paper No: 3
- All input and output HTML elements must have an id attribute exactly as specified. The examiner uses an automated tool that checks element IDs and their innerText / value to grade your work.
- For elements whose IDs contain a record ID, the record ID is the primary key value stored in the database.
- Use the provided SQL script to create the database and sample data before running the application. The seeding data in the project solution must match the SQL script.
2. Given Materials:
The following files are provided along with this question. You may use them as reference for the expected UI layout and required HTML element IDs:
- list.html - A demo HTML page showing the expected layout of the /Review/List page.
- create.html - A demo HTML page showing the expected layout of the /Review/Create page.
- script.sql - A SQL Server script for creating and seeding the database.
These files are provided for UI reference only. You are not required to use them directly in your project; however, your implementation must produce HTML element IDs that match the IDs shown in these demo files.
3. Requirements
Requirement 1 - Review List Page
The web application must have a page accessible at the URL /Review/List.
1.1 Review List Table
Display all reviews sorted by ReviewId ascending. The table must include: ReviewId, ProductName, ReviewerName, Rating, Comment.
- Each <td> cell must have id td_{columnName}_{reviewId}. Examples: td_productName_1, td_rating_2.
- Above the table, display <span id="span_reviewCount"> for the number of currently displayed reviews and <span id="span_averageRating"> for the average rating formatted to 2 decimal places.
1.2 Product Filter and Minimum Rating Filter
- The product dropdown must have id sl_product.

7 of 8 Paper No: 3
- Add a default first option with text "All Products" and id opt_default.
- Each product option must have id opt_{index}.
- The minimum rating dropdown must have id sl_minRating.
- The &#91;Filter&#93; button must have id btn_filter.
- The &#91;Clear&#93; button/link must have id btn_clear.
Requirement 2 - Add New Review
The user can add a new review at URL /Review/Create.
2.1 Add New Review Link
- The &#91;Add New Review&#93; link must have id lnk_addNew and navigate to /Review/Create.
2.2 Create Form
- Product dropdown: id sl_product; each option id opt_{index}.
- ReviewerName input: id txt_reviewerName.
- Rating input: id txt_rating.
- Comment input or textarea: id txt_comment.
- &#91;Save&#93; button: id btn_save.
- &#91;Back to List&#93; link: id btn_back.
2.3 Form Processing
- Validate Product, ReviewerName, Rating, and Comment. Rating must be between 1 and 5.
- Set ReviewDate to the current date.
- Redirect to /Review/List after a successful insert.
4. Summary of HTML Element IDs
The table below summarises all required HTML element IDs. Elements not listed here are left to the student's discretion.
Element: Each cell in review table | Tag: <td> | ID Format: td_{columnName}_{reviewId} | Example: td_rating_1
Element: Review count | Tag: <span> | ID Format: span_reviewCount | Example: span_reviewCount
Element: Average rating | Tag: <span> | ID Format: span_averageRating | Example: span_averageRating
Element: Product filter dropdown | Tag: <select> | ID Format: sl_product | Example: sl_product
Element: Default option | Tag: <option> | ID Format: opt_default | Example: opt_default
Element: Each product option | Tag: <option> | ID Format: opt_{index} | Example: opt_1
Element: Minimum rating dropdown | Tag: <select> | ID Format: sl_minRating | Example: sl_minRating

8 of 8 Paper No: 3
Element: Filter button | Tag: <button> or <input> | ID Format: btn_filter | Example: btn_filter
Element: Clear button/link | Tag: <button> or <a> | ID Format: btn_clear | Example: btn_clear
Element: Add New Review link | Tag: <a> | ID Format: lnk_addNew | Example: lnk_addNew
Element: ReviewerName input | Tag: <input> | ID Format: txt_reviewerName | Example: txt_reviewerName
Element: Rating input | Tag: <input> | ID Format: txt_rating | Example: txt_rating
Element: Comment input | Tag: <input> or <textarea> | ID Format: txt_comment | Example: txt_comment
Element: Save button | Tag: <button> or <input> | ID Format: btn_save | Example: btn_save
Element: Back to List link | Tag: <a> | ID Format: btn_back | Example: btn_back
 

Đính kèm

  • PRN222 SU26 PE RE NO3_001.webp
    PRN222 SU26 PE RE NO3_001.webp
    211.9 KB · Lượt xem: 67
  • PRN222 SU26 PE RE NO3_002.webp
    PRN222 SU26 PE RE NO3_002.webp
    164.5 KB · Lượt xem: 51
  • PRN222 SU26 PE RE NO3_003.webp
    PRN222 SU26 PE RE NO3_003.webp
    175.2 KB · Lượt xem: 49
  • PRN222 SU26 PE RE NO3_004.webp
    PRN222 SU26 PE RE NO3_004.webp
    192.5 KB · Lượt xem: 44
  • PRN222 SU26 PE RE NO3_005.webp
    PRN222 SU26 PE RE NO3_005.webp
    173.9 KB · Lượt xem: 35
  • PRN222 SU26 PE RE NO3_006.webp
    PRN222 SU26 PE RE NO3_006.webp
    228.4 KB · Lượt xem: 35
  • PRN222 SU26 PE RE NO3_007.webp
    PRN222 SU26 PE RE NO3_007.webp
    186.2 KB · Lượt xem: 26
  • PRN222 SU26 PE RE NO3_008.webp
    PRN222 SU26 PE RE NO3_008.webp
    49.7 KB · Lượt xem: 58
  • PRN222_SU26_B1_PE_L2_No3_materials.zip
    PRN222_SU26_B1_PE_L2_No3_materials.zip
    307.9 KB · Lượt xem: 5
Sửa lần cuối:

Tạo tài khoản hoặc đăng nhập để bình luận

Bạn phải là thành viên mới có thể bình luận.

Tạo tài khoản

Hãy tạo tài khoản trên cộng đồng của chúng tôi. Thật dễ dàng!

Đăng nhập

Bạn đã có tài khoản? Đăng nhập tại đây.

X
Back
Top