Skip to content

Commit 0951b6f

Browse files
committed
done
1 parent 918cf1b commit 0951b6f

12 files changed

+276
-54
lines changed

app/account/account.html

+17-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<div ng-controller="AccountController">
2-
<div class="container" style="color:#fff">
2+
<div class="container">
33
<p>Hey Prof, to go to a lecture room, you may either add a new lecture or select an existing lecture</p>
44
<div class="row">
5-
<div class="col-xs-6">
5+
<div class="col-xs-6" class="jumbotron">
66
<h3>Add a Lecture</h3>
77
<!-- <form>
88
<label>Name: <input type="text" ng-model="newLectureName" placeholder="CS101"></label>
@@ -11,8 +11,22 @@ <h3>Add a Lecture</h3>
1111
<label><input type="checkbox" ng-value="l" name="Name" ng-model="selectedLecture"> {{l['Name']}}</label>
1212
</div>
1313
</form> -->
14+
<div class="profForm" style="float: left;">
15+
<form role="form"> <!-- action="" method="GET"-->
16+
Name of lecture<br>
17+
<input type="text" placeholder="CS101">
18+
<br>
19+
<br>
20+
Enroll students<br>
21+
<div ng-repeat="s in allStudentsEverCreated">
22+
<input type="checkbox" name="student"> {{s['Name']}}<br>
23+
</div>
24+
<br><br>
25+
<button class="btn btn-success" style="margin-top: 10px">Submit</button>
26+
</form>
27+
</div>
1428
</div>
15-
<div class="col-xs-6">
29+
<div class="col-xs-6" class="jumbotron">
1630
<h3>Select a Lecture</h3>
1731
<div ng-repeat="l in lectures">
1832
<label><input type="radio" ng-value="l" name="Name" ng-model="selectedLecture"> {{l['Name']}}</label>

app/account/accountcontroller.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
$scope.allStudentsEverCreated = res.data.results;
1717
}, function(res) {
1818
alert(res);
19-
})
19+
});
2020
}
2121
$scope.newLectureName;
2222

app/app.js

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
'ngRoute',
77
'landingpage',
88
'lectureroom',
9+
'mylectures',
910
'nav',
1011
'account'
1112
]);
@@ -26,6 +27,10 @@
2627
templateUrl: 'app/lectureroom/lectureroom.html',
2728
controller: 'LectureroomController as lectureroom'
2829
}).
30+
when('/mylectures', {
31+
templateUrl: 'app/mylectures/mylectures.html',
32+
controller: 'MylecturesController as mylectures'
33+
}).
2934
when('/404', {
3035
templateUrl: '404/404.html'
3136
}).

app/landingpage/landingpage.html

+61-33
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,71 @@
1-
<div ng-controller="LandingPageController">
1+
<div ng-controller="LandingPageController"> <!-- class="maincontent"-->
22
<div class="container-fluid centeringlol text-center">
33

4-
<h1 class="text-center signuph1">Tagline goes here</h1>
4+
<h1 class="text-center signuph1" style="margin-top: -50px;">Ask questions during lecture anonymously!</h1>
55

6-
<div ng-show="showSignIn">
7-
<h2 class="text-center signuph1">Sign In!</h2>
8-
<div ng-show="showButtons">
9-
<div class="btn btn-default btnsignup" ng-click="setMode(true)">
10-
I am a Professor
6+
<div class="jumbotron" style="padding-bottom: 150px;">
7+
<div ng-show="showSignIn">
8+
<h2 class="text-center">Sign In!</h2>
9+
<div ng-show="showButtons">
10+
<div class="btn btn-primary btn-lg" ng-click="setMode(true)">
11+
I am a Professor
12+
</div>
13+
<div class="btn btn-primary btn-lg" ng-click="setMode(false)">
14+
I am a Student
15+
</div>
1116
</div>
12-
<div class="btn btn-default btnsignup" ng-click="setMode(false)">
13-
I am a Student
17+
</div>
18+
19+
<div ng-show="!showSignIn">
20+
<h2 class="text-center">Sign Up!</h2>
21+
<div ng-show="showButtons">
22+
<button class="btn btn-primary btn-lg" ng-click="setMode(true)">
23+
I am a Professor
24+
</button>
25+
<button class="btn btn-primary btn-lg" ng-click="setMode(false)">
26+
I am a Student
27+
</button>
1428
</div>
1529
</div>
16-
</div>
17-
18-
<div ng-show="!showSignIn">
19-
<h2 class="text-center signuph1">Sign Up!</h2>
20-
<div ng-show="showButtons">
21-
<button class="btn btn-default btnsignup" ng-click="setMode(true)">
22-
I am a Professor
23-
</button>
24-
<button class="btn btn-default btnsignup" ng-click="setMode(false)">
25-
I am a Student
26-
</button>
30+
31+
<span>Dont have an account? Create one <a href="#" ng-click="showSignIn = false">here!</a></span>
32+
<div ng-show="!showButtons">
33+
<div ng-show="showSignIn">
34+
<form class="navbar-form navbar-left" ng-submit="signIn()" >
35+
<div class="form-group">
36+
<div class="row" style="margin-top: 10px; width: 100%">
37+
<div class="col-md-6">
38+
<input type="email" class="form-control" placeholder="Email" ng-model="email">
39+
</div>
40+
<div class="col-md-6">
41+
<input type="password" class="form-control" placeholder="Password" ng-model="password">
42+
</div>
43+
</div>
44+
<br>
45+
<button type="submit" class="btn btn-success btn-lg" style="margin-top: 10px">Sign in</button>
46+
</div>
47+
</form>
48+
</div>
49+
<div ng-show="!showSignIn">
50+
<form class="navbar-form navbar-left" ng-submit="signUp()" >
51+
<div class="form-group">
52+
<div class="row" style="margin-top: 10px; width: 100%">
53+
<div class="col-md-4">
54+
<input type="text" class="form-control" placeholder="Name" ng-model="name">
55+
</div>
56+
<div class="col-md-4">
57+
<input type="email" class="form-control" placeholder="Email" ng-model="email">
58+
</div>
59+
<div class="col-md-4">
60+
<input type="password" class="form-control" placeholder="Password" ng-model="password">
61+
</div>
62+
</div>
63+
<br>
64+
<button type="submit" class="btn btn-success btn-lg" style="margin-top: 10px">Sign up</button>
65+
</div>
66+
</form>
67+
</div>
2768
</div>
2869
</div>
29-
30-
<span>Dont have an account? Create one <a href="#" ng-click="showSignIn = false">here!</a></span>
31-
<div ng-show="!showButtons">
32-
<form class="navbar-form navbar-left" ng-submit="signUp()" >
33-
<div class="form-group">
34-
<input type="text" class="form-control" placeholder="Name" ng-model="name">
35-
<input type="email" class="form-control" placeholder="Email" ng-model="email">
36-
<input type="password" class="form-control" placeholder="Password" ng-model="password">
37-
<br>
38-
<button type="submit" class="btn btn-default" style="margin-top: 10px">Sign up</button>
39-
</div>
40-
</form>
41-
</div>
4270
</div>
4371
</div>

app/landingpage/landingpagecontroller.js

+50-1
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@
2525
if (res.data.success == false) {
2626
alert("Email already exists");
2727
}
28+
else {
2829
console.log(res);
2930
var id = res.data.Professor_id;
3031
// get id and pass it
3132

3233
$location.url("/account/?type='professor'&id="+id);
33-
34+
}
3435
}, function(res){
3536
console.log(res);
3637

@@ -44,8 +45,56 @@
4445
}).then(function(res){
4546
if (res.data.success == false) {
4647
alert("Email already exists");
48+
} else {
49+
var id = res.data.Student_id;
50+
$location.url("/mylectures/?type='student'&id="+id);
51+
}
52+
console.log(res);
53+
}, function(res){
54+
console.log(res);
55+
56+
});
57+
}
58+
}
59+
60+
$scope.signIn = function () {
61+
console.log("signIn");
62+
if ($scope.isProf) {
63+
$http.post('https://vast-earth-4742.herokuapp.com/professor_sign_in', {
64+
"Email": $scope.email,
65+
"Password": $scope.password
66+
}).then(function(res){
67+
console.log(res);
68+
if (res.data.success == false) {
69+
alert("Invalid credentials");
70+
}
71+
else {
72+
console.log(res);
73+
var id = res.data.Professor_id;
74+
// get id and pass it
75+
76+
$location.url("/account/?type='professor'&id="+id);
4777
}
78+
}, function(res){
4879
console.log(res);
80+
81+
});
82+
} else {
83+
$http.post('https://vast-earth-4742.herokuapp.com/student_sign_in', {
84+
"Email": $scope.email,
85+
"Password": $scope.password
86+
}).then(function(res){
87+
console.log(res);
88+
if (res.data.success == false) {
89+
alert("Invalid credentials");
90+
}
91+
else {
92+
console.log(res);
93+
var id = res.data.Student_id;
94+
// get id and pass it
95+
96+
$location.url("/mylectures/?type='student'&id="+id);
97+
}
4998
}, function(res){
5099
console.log(res);
51100

app/lectureroom/lectureroom.html

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
<div ng-controller="LectureroomController">
2-
<div class="container" style="color:#fff">
2+
<div class="container">
3+
<h3>No. of students in the lecture room: {{allStudentsIdsInLecture.length}}</h3>
4+
<h3>Lecture Name: {{currentLecture.Name}}</h3>
5+
<!-- <h3>Professor Name: </h3> -->
6+
<p ng-show="currentLectureQuestions.length == 0">There are no questions in this lecture room so far!</p>
7+
<p ng-show="currentLectureQuestions.length > 0">
8+
Here is the list of accumulated questions</p>
9+
10+
<div class="panel panel-primary">
11+
<div ng-repeat="q in currentLectureQuestions">
12+
<div class="panel-heading">
13+
<h3 class="panel-title">{{q.Text}}</h3>
14+
</div>
15+
<div class="panel-body">
16+
No. of votes: {{q.Votes}}
17+
</div>
18+
</div>
19+
</div>
320
</div>
4-
</div>
21+
</div>
22+

app/lectureroom/lectureroomcontroller.js

+36
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,42 @@
55

66
lectureroom.controller('LectureroomController', ["$scope", "$http", "$location", function($scope, $http, $location){
77
console.log("This is lectureroom controller");
8+
console.log($location.search());
9+
$scope.lectureId = $location.search()['lectureid'];
10+
11+
$scope.getLecture = function() {
12+
$http.get('https://vast-earth-4742.herokuapp.com/get_lecture_by_id/'+$scope.lectureId).then(function(res){
13+
$scope.currentLecture = res.data;
14+
$scope.allStudentsIdsInLecture = $scope.currentLecture['Student_Ids'].split(',');
15+
}, function(res) {
16+
alert(res);
17+
});
18+
}
19+
$scope.getLecture();
20+
21+
$scope.getAllQuestionsInLectureRoom = function() {
22+
$http.get('https://vast-earth-4742.herokuapp.com/get_all_questions_by_lecture/'+$scope.lectureId).then(function(res){
23+
console.log(res);
24+
$scope.currentLectureQuestions = res.data.results;
25+
26+
// Identify when there is no question in lecture room
27+
28+
// If there are question, display them in order of number of votes
29+
30+
//$scope.allStudentsIdsInLecture = $scope.currentLecture['Student_Ids'].split(',');
31+
console.log($scope.currentLecture);
32+
}, function(res) {
33+
alert(res);
34+
});
35+
}
36+
$scope.getAllQuestionsInLectureRoom();
37+
38+
39+
$scope.answerQuestion = function() {
40+
41+
}
42+
43+
// delete lecture room and return to accounts
844
}])
945
})()
1046

app/mylectures/mylectures.html

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<div ng-controller="MylecturesController">
2+
<div class="container">
3+
<h3>Ask a question</h3>
4+
<div class="input-group" style="width: 100%">
5+
<input type="text" ng-model="question" class="form-control" placeholder="Could you go over the iterator design pattern again?">
6+
</div>
7+
<button ng-click="askQuestion()" class="btn btn-success" style="margin-top: 10px">Ask!</button>
8+
</div>
9+
</div>
+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
(function(){
2+
'use strict';
3+
4+
var lectureroom = angular.module('mylectures', [])
5+
6+
lectureroom.controller('MylecturesController', ["$scope", "$http", "$location", function($scope, $http, $location){
7+
console.log("This is mylectures controller");
8+
console.log($location.search());
9+
$scope.question = "";
10+
$scope.askQuestion = function() {
11+
$http.post('https://vast-earth-4742.herokuapp.com/ask_a_question', {
12+
"Text": $scope.question,
13+
"Student_id": $location.search()['id'],
14+
"Lecture_id": "6rY7tZqIJB"
15+
}).then(function(res){
16+
if (res.data.success == false) {
17+
alert("Email already exists");
18+
}
19+
else {
20+
console.log(res);
21+
var id = res.data.Professor_id;
22+
// get id and pass it
23+
24+
$location.url("/account/?type='professor'&id="+id);
25+
}
26+
}, function(res){
27+
console.log(res);
28+
29+
});
30+
}
31+
}]);
32+
})()
33+
34+
35+
36+
37+
38+
39+
40+
41+
42+
43+
44+
//(function(){
45+
// 'use strict';
46+
//
47+
// var account = angular.module('account', ["ngResource"])
48+
//
49+
// account.controller('AccountController', ["$resource","$scope", function($resource, $scope){
50+
//
51+
// var account = this;
52+
// var Account = $resource('/account/:accountId')
53+
// $scope.emails = [];
54+
//
55+
// $scope.addemail = function (){
56+
// console.log("yo");
57+
// $scope.emails.push(account.newemail)
58+
// }
59+
//
60+
// account = Account.get({accountID:1});
61+
// }])
62+
//})()

0 commit comments

Comments
 (0)