0% found this document useful (0 votes)
6 views1 page

Lecture Verification Contract

The document outlines a Solidity smart contract for verifying military lecture attendance. It includes structures for lectures and student progress, allowing for the uploading of lectures, tracking of watch time, and checking if students have completed the required viewing time. The contract maintains a mapping of lectures and their respective progress for each student.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

Lecture Verification Contract

The document outlines a Solidity smart contract for verifying military lecture attendance. It includes structures for lectures and student progress, allowing for the uploading of lectures, tracking of watch time, and checking if students have completed the required viewing time. The contract maintains a mapping of lectures and their respective progress for each student.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

pragma solidity ^0.8.

0;

contract MilitaryLectureVerification {
struct Lecture {
string title;
uint256 duration; // Thời lượng bài giảng (giây)
uint256 requiredWatchTime; // Thời gian tối thiểu phải xem
mapping(address => LectureProgress) studentProgress;
}

struct LectureProgress {
uint256 totalWatchTime;
uint256 startTime;
bool completed;
}

mapping(uint256 => Lecture) public lectures;


uint256 public lectureCounter;

function uploadLecture(
string memory _title,
uint256 _duration,
uint256 _requiredWatchTime
) public {
lectureCounter++;
Lecture storage newLecture = lectures[lectureCounter];

newLecture.title = _title;
newLecture.duration = _duration;
newLecture.requiredWatchTime = _requiredWatchTime;
}

function startWatchingLecture(uint256 _lectureId) public {


lectures[_lectureId].studentProgress[msg.sender].startTime =
block.timestamp;
}

function updateWatchProgress(uint256 _lectureId, uint256 _watchTime) public {


Lecture storage lecture = lectures[_lectureId];
LectureProgress storage progress = lecture.studentProgress[msg.sender];

progress.totalWatchTime = _watchTime;

// Kiểm tra đã xem đủ thời gian


if (progress.totalWatchTime >= lecture.requiredWatchTime) {
progress.completed = true;
}
}

function isLectureCompleted(uint256 _lectureId, address _student) public view


returns (bool) {
return lectures[_lectureId].studentProgress[_student].completed;
}
}

You might also like