Skip to content

This Solidity project implements a decentralized Student Grading System, This contract was written and tested as part of a blockchain education cohort focused on building real-world decentralized applications using Solidity and Foundry.

Notifications You must be signed in to change notification settings

otsimaofficial/GradingSystem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📚 Student Grading System Smart Contract

This Solidity project implements a decentralized Student Grading System where:

  • The Principal (Owner) deploys the contract and assigns Teachers.
  • Teachers (Admins) are allowed to add students’ scores and associate them with subjects.
  • Students can view their individual scores and grade remarks by subject.
  • Teachers and Principal can view all the student records across subjects.

✅ This contract does not use OpenZeppelin libraries — all access control is handled with custom logic and modifiers.


🚀 Features

  • 👑 Principal Role:

    • Deploys the contract.
    • Assigns teacher addresses.
  • 👨‍🏫 Teacher/Admin Role:

    • Adds student grades per subject.
    • Can view all students’ records.
  • 👩‍🎓 Student Role:

    • Views their subject-specific score, grade, and remark.
  • 🧾 Grading Logic:

    • Automatically assigns:

      • A: 70–100 ✅
      • B: 60–69 ✅
      • C: 50–59 ✅
      • D: 40–49 ✅
      • F: below 40 ❌

🏗️ Contract Structure

  • Structs:

    • Student: contains name, subjects, scores, and grades.
    • Score: encapsulates subject, marks, grade.
  • Mappings:

    • students: maps student addresses to their record.
    • teachers: maps teacher addresses to boolean.
  • Modifiers:

    • onlyPrincipal: restricts actions to the contract owner.
    • onlyTeacher: restricts score input to verified teachers.
    • onlyStudent: for student-specific views.
    • onlyAdmin: for teachers or the principal.

🔍 How It Works

  1. Principal assigns one or more teacher addresses.

  2. Teachers add student scores using:

    addStudentScore(studentAddress, studentName, subject, score)
  3. Students view their result by calling:

    viewMyGradeBySubject("Mathematics")
  4. Admin can retrieve all student results via:

    getStudentRecords(studentAddress)

🧪 Testing

This project includes comprehensive tests written in Foundry to ensure:

  • Role-based restrictions are enforced.
  • Score grading is accurate.
  • Students can only access their records.
  • Admins can view all records.

Run test with:

forge test

📁 Project Structure

├── src/
│   └── StudentGradingSystem.sol
├── test/
│   └── StudentGradingSystemTest.t.sol
├── foundry.toml
└── README.md

📜 License

MIT License


🙌 Acknowledgements

This contract was written and tested as part of a blockchain education cohort focused on building real-world decentralized applications using Solidity and Foundry.

About

This Solidity project implements a decentralized Student Grading System, This contract was written and tested as part of a blockchain education cohort focused on building real-world decentralized applications using Solidity and Foundry.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published