forked from jamesfebin/GradesDapp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGrades.sol
More file actions
30 lines (24 loc) · 717 Bytes
/
Copy pathGrades.sol
File metadata and controls
30 lines (24 loc) · 717 Bytes
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
pragma solidity ^0.4.18;
contract Grades{
mapping (bytes32 => string) public grades;
bytes32[] public studentList;
function Grades(bytes32[] studentNames) public {
studentList = studentNames;
}
function getGradeForStudent(bytes32 student) view public returns (string) {
require(validStudent(student));
return grades[student];
}
function giveGradeToStudent(bytes32 student, string grade) public {
require(validStudent(student));
grades[student] = grade;
}
function validStudent(bytes32 student) view public returns (bool) {
for(uint i = 0; i < studentList.length; i++) {
if (studentList[i] == student) {
return true;
}
}
return false;
}
}