-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathexerciceTemplate.sol
45 lines (33 loc) · 933 Bytes
/
exerciceTemplate.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "./ERC20TD.sol";
/*
Common behavior in exercices
This contract describes functions that are common to most exercices. They help
- Authentify students and teacher
- Credit students
*/
contract exerciceTemplate {
ERC20TD TDERC20;
mapping(address => bool) public hasCompletedExercice;
event constructedCorrectly(address erc20Address);
constructor(ERC20TD _TDERC20)
{
TDERC20 = _TDERC20;
emit constructedCorrectly(address(TDERC20));
}
function creditStudent(uint _points, address _studentAddress) internal {
if (!hasCompletedExercice[_studentAddress])
{
TDERC20.distributeTokens(_studentAddress, _points);
}
}
function validateExercice(address _studentAddress) internal {
hasCompletedExercice[_studentAddress] = true;
}
modifier onlyTeachers()
{
require(TDERC20.teachers(msg.sender));
_;
}
}