-
Notifications
You must be signed in to change notification settings - Fork 1
/
newContract.sol
68 lines (53 loc) · 1.75 KB
/
newContract.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
pragma solidity >=0.4.21 <0.6.0;
// This contract will be the backend smart contract for the course-feedback system, to interact with our blockchain
contract CourseFeedback{
// Store students Count
uint public studentsCount;
//Store number of students who have voted till now
uint numberOfVotedStudents=0;
// Store admin credentials
address admin;
//Modifier which allows only the admin to perform certain tasks
modifier onlyAdmin() {
require (msg.sender==admin);
_;
}
//structure to store candidate's details
struct Student{
uint studentID;
string studentname;
bool validStud;
bool hasVoted;
}
//Store the Feedback received from the form
struct Feedback {
uint q1;
uint q2;
//Question variables go here
}
//Mappings
// mapping of all the students :studentsList
mapping (address=>Student) internal studentsList;
//voted
mapping (address=>bool) public voted;
//constructor
constructor() public {
//initialise admin credentials
admin=msg.sender;
setNumberOfStudents(0);
addStudent(1,"Shubham",web3.eth.account[1]);
addStudent(2,"Atharv",web3.eth.account[2]);
}
function addStudent (uint _studentid,string memory _studentname) onlyAdmin public {
//add to studentsList
studentsList[msg.sender]=Student(_studentid,_studentname,true);
//increase studentsCount
studentsCount++;
}
function giveFeedback (uint a, uint b) public returns(uint) {
// requires that they are in studentsList
require(studentsList[msg.sender].validStud=true);
// requires that they haven't given feedback before
require(voted[msg.sender]==false);
}
}