-
Notifications
You must be signed in to change notification settings - Fork 0
/
Student.sol
executable file
·129 lines (103 loc) · 3.17 KB
/
Student.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
pragma solidity ^0.4.15;
contract Student {
address schoolOwner;
address selfStudent;
bytes32 firstName;
bytes32 lastName;
bytes32 mailingAddress;
bytes32 transcript;
bytes32 visa;
bool accntOnHold;
uint aidAmnt;
uint tuitionDue;
struct User{
address userID;
}
User[] authorizedToView;
mapping(address => bool) canView;
function Student(bytes32 _fName, bytes32 _lName, bytes32 _mailingAdd, bytes32 _transcript, bytes32 _visa) public{
schoolOwner = msg.sender;
firstName = _fName;
lastName = _lName;
mailingAddress = _mailingAdd;
transcript = _transcript;
visa = _visa;
aidAmnt = 0;
tuitionDue = 0;
}
modifier onlySchool{
if (schoolOwner != msg.sender){
revert();
}
_;
}
function setStudentAddress(address _studentAdd) onlySchool public{
selfStudent = _studentAdd;
authorizedToView.push(User({
userID: _studentAdd
}));
canView[_studentAdd] = true;
}
modifier onlyStudent{
if (selfStudent != msg.sender){
revert();
}
_;
}
modifier onlyAuthViewer{
if (canView[msg.sender] == false){// && msg.sender != selfStudent){
revert();
}
_;
}
function newAuthViewer(address _newUser) onlySchool public{
authorizedToView.push(User({
userID: _newUser
}));
canView[_newUser] = true;
}
function updateTranscript(bytes32 _updatedTscript) onlySchool public{
transcript = _updatedTscript;
}
function viewTranscript() onlyAuthViewer public constant returns(bytes32){
return transcript;
}
//This might need to be updated by the government, so it would need a new modifier like onlyGovBody
function updateVisa(bytes32 _updatedVisa) onlySchool public{
visa = _updatedVisa;
}
function viewTranscript() onlyAuthViewer public constant returns(bytes32){
return visa;
}
function changeHold() onlySchool public{
accntOnHold = !accntOnHold;
}
function changeFinances(uint _newTuition, uint _newAid) onlySchool public{
tuitionDue = _newTuition;
aidAmnt = _newAid;
}
function checkHold() constant public returns(bool){
if (msg.sender != selfStudent && msg.sender != schoolOwner){ revert(); }
return accntOnHold;
}
function checkTuition() constant public returns(uint){
if (msg.sender != selfStudent){// && msg.sender != schoolOwner){
revert(); }
return tuitionDue;
}
function checkAid() constant public returns(uint){
if (msg.sender != selfStudent){// && msg.sender != schoolOwner){
revert(); }
return aidAmnt;
}
function recieveFunds() public payable{
}
function getBalance() onlyStudent constant public returns(uint){
return this.balance;
}
function payTuition(uint _amount) onlyStudent public{
if(_amount > this.balance || _amount > tuitionDue) { revert(); }
schoolOwner.transfer(_amount);
tuitionDue = tuitionDue - _amount;
}
}