Software Dev Project
Software Dev Project
break it down into three main components: front end, back end, and database. I’ll provide a
detailed plan and sample code snippets to guide you through the implementation.
Project Overview
The project involves the following steps:
Data Collection: Course teachers collect student semester results in an Excel sheet.
Approval by Dean: Dean approves the results via the admin portal.
Result Upload: Approved results are sent to the IT department for upload (although our goal is to
eliminate this step).
Result Publication: Results are published on the result portal after validation.
Dean Recheck: The dean can recheck and publish or discard the results.
Front End
We'll use HTML, CSS, and JavaScript for the front end. The front end will consist of:
UserName NVARCHAR(50),
Password NVARCHAR(50),
Role NVARCHAR(20)
);
CREATE TABLE Results (
StudentId NVARCHAR(50),
CourseId NVARCHAR(50),
Marks INT,
);
UserId INT,
Action NVARCHAR(100),
);
cd UniversityResultSystem
// Models/Result.cs
// Models/AuditLog.cs
// Data/ApplicationDbContext.cs
optionsBuilder.UseSqlServer("YourConnectionStringHere");
Sh:
API Controllers: C#
// Controllers/AuthController.cs
[ApiController]
[Route("api/[controller]")]
public class AuthController : ControllerBase {
private readonly ApplicationDbContext _context;
[HttpPost("login")]
public IActionResult Login([FromBody] LoginRequest request) {
var user = _context.Users.SingleOrDefault(u => u.UserName ==
request.UserName && u.Password == request.Password);
if (user == null) {
return Unauthorized();
}
return Ok(new { token = "fake-jwt-token", userId = user.UserId, role =
user.Role });
}
}
// Controllers/ResultsController.cs
[ApiController]
[Route("api/[controller]")]
public class ResultsController : ControllerBase {
private readonly ApplicationDbContext _context;
[HttpPost("upload")]
public IActionResult UploadResults([FromBody] List<Result> results) {
_context.Results.AddRange(results);
_context.SaveChanges();
return Ok();
}
[HttpGet("pending")]
public IActionResult GetPendingResults() {
var pendingResults = _context.Results.Where(r => r.Status ==
"Pending").ToList();
return Ok(pendingResults);
}
[HttpPost("approve")]
public IActionResult ApproveResult([FromBody] int resultId) {
var result = _context.Results.SingleOrDefault(r => r.ResultId == resultId);
if (result == null) {
return NotFound();
}
result.Status = "Approved";
_context.SaveChanges();
return Ok();
}
[HttpPost("discard")]
public IActionResult DiscardResult([FromBody] int resultId) {
var result = _context.Results.SingleOrDefault(r => r.ResultId == resultId);
if (result == null) {
return NotFound();
}
result.Status = "Discarded";
_context.SaveChanges();
return Ok();
}
}
Login Page:
<!-- login.html -->
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
</head>
<body>
<h2>Login</h2>
<form id="loginForm">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<button type="submit">Login</button>
</form>
<script>
document.getElementById('loginForm').addEventListener('submit',
function(event) {
event.preventDefault();
var username = document.getElementById('username').value;
var password = document.getElementById('password').value;
fetch('api/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ userName: username, password: password })
})
.then(response => response.json())
.then(data => {
if (data.token) {
localStorage.setItem('token', data.token);
window.location.href = 'admin.html';
} else {
alert('Invalid credentials');
}
});
});
</script>
</body>
</html>
Admin Dashboard:
<script>
function fetchPendingResults() {
fetch('api/results/pending', {
headers: { 'Authorization': 'Bearer ' + localStorage.getItem('token') }
})
.then(response => response.json())
.then(data => {
var resultsDiv = document.getElementById('results');
resultsDiv.innerHTML = '';
data.forEach(result => {
resultsDiv.innerHTML += `<div>
<p>Student ID: ${result.studentId}, Course ID: ${result.courseId},
Marks: ${result.marks}</p>
<button
onclick="approveResult(${result.resultId})">Approve</button>
<button
onclick="discardResult(${result.resultId})">Discard</button>
</div>`;
});
});
}
function approveResult(resultId) {
fetch('api/results/approve', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' +
localStorage.getItem('token') },
body: JSON.stringify(resultId)
})
.then(response => response.json())
.then(data => {
alert('Result approved');
fetchPendingResults();
});
}
function discardResult(resultId) {
fetch('api/results/discard', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' +
localStorage.getItem('token') },
body: JSON.stringify(resultId)
})
.then(response => response.json())
.then(data => {
alert('Result discarded');
fetchPendingResults();
});
}
</script>
</body>
</html>
Summary
This project involves setting up a web application where university results
can be uploaded, approved, and published by authorized personnel (Dean).
The project uses ASP.NET Core for the back end, SQL Server for the
database, and HTML, CSS, and JavaScript for the front end.
By following the steps and code snippets provided, you can develop a
functional "University Result Auto Authentication & Publish" system. Make
sure to test each component thoroughly to ensure the application meets the
requirements and works as expected.