Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding TA/Student sides #53

Open
wants to merge 28 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b967235
~Creating a style.css to modify the html
Nildham21 Apr 24, 2020
e25cdc0
~Adding Student side function that will load the html that the studen…
Nildham21 Apr 25, 2020
44c29d2
~Adding the first select drop down that the student will select from
Nildham21 Apr 25, 2020
23a26d7
~Creating functions that will add html to the index.html
Nildham21 Apr 25, 2020
12fba21
~sending username,topic and subtopic to the server
Nildham21 Apr 25, 2020
2791017
~Working on the html of the TA side, adding a button
Nildham21 Apr 26, 2020
dc82636
~Debugging the queue, so that it does not show up in the first html l…
Nildham21 Apr 26, 2020
6990e30
~ Setting up database to work with mySQL
Nildham21 Apr 28, 2020
0ba76c1
~ Broadcasting Queue after each DisconnectionListener
Nildham21 Apr 28, 2020
e46a526
~ Loading the Queue for the TA side
Nildham21 Apr 28, 2020
e8cc3a8
~ Adding new columns into my table to store data for topic and subtopic
Nildham21 Apr 28, 2020
c1ec139
~ Fixing upper and lower case issues for topic namings
Nildham21 Apr 28, 2020
53d7fea
~ Centering the Queue
Nildham21 Apr 29, 2020
de46d1a
~ Adding bottom margin to space the viewing queue
Nildham21 Apr 29, 2020
25fc633
~ Adding alerts when a student is up
Nildham21 Apr 30, 2020
7b61fea
~ Fixing the bug where null would be passed if no one is in queue
Nildham21 May 1, 2020
bdb9007
~ A issue that was present in my code was that i manually add div que…
Nildham21 May 1, 2020
e89f95e
~ Fixing same name issues, every time a user enters a name a random i…
Nildham21 May 1, 2020
f5a489c
~ Adding Background Color
Nildham21 May 1, 2020
3fdf6bf
~ adding username label for student side
Nildham21 May 2, 2020
5a57eff
~ Adding a login page for the the TA before helping students
Nildham21 May 2, 2020
55973c6
~ Adding a data structure that keeps track of which TA is online, so …
Nildham21 May 2, 2020
e00c2a8
~ Created A TA database that keeps track of how many students that TA…
Nildham21 May 3, 2020
f5d33e1
~ Adding a google pie chart that will display the number of students …
Nildham21 May 3, 2020
aee3983
~ changing google charts background color
Nildham21 May 3, 2020
33508c4
~ made the stats button collapse once the the user was done looking a…
Nildham21 May 3, 2020
c14a95f
~ Cleaned up the Database for the TAstats, i was adding 2 entries by …
Nildham21 May 4, 2020
3dda81f
~ lower cased the word Time
Nildham21 May 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
~ Adding a google pie chart that will display the number of students …
…that asked for help for a certain topic/subtopic
  • Loading branch information
Nildham21 committed May 3, 2020
commit f5d33e1b15a685114c669c4111b96e27e6ac317b
2 changes: 2 additions & 0 deletions nginx/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<!--stylesheets Css-->
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js"></script>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>

</head>
<body onload="firstcounter()">

Expand Down
92 changes: 91 additions & 1 deletion nginx/public/officeHours.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const socket = io.connect("http://localhost:8080", {transports: ['websocket']});
google.charts.load('current', {'packages':['corechart']});



socket.on('queue', displayQueue);
socket.on('message', displayMessageTA);
Expand All @@ -8,6 +11,12 @@ socket.on('done', studentDone);
socket.on('count', counter);
socket.on('valid_Check',displayTA);
socket.on("invalid",displayInvalid);
socket.on("showTopicPie",getTopicPieData);
socket.on("showSubtopicPie",getSubtopicPieData);







Expand All @@ -21,6 +30,14 @@ let lecture=Array("Unit-Testing","Test-Factoring","Voting-Class","Reference-Refe
let hw=Array("Physics-Engine","Rhyming-Dictionary","Calculator","Microwave","Genetic-Algorithm","Recommendations","Decision-Tree","Maze-Solver","Clicker")
let appObj=Array("Program-Execution","Object-Oriented-Programming","Functional-Programming","Data-Structures-&-Algorithms","Event-Based-Architectures")
let lab=Array("Program-Execution","Object-Oriented-Programming","Functional-Programming","Data-Structures-&-Algorithms","Event-Based-Architectures")
let topics=Array( "Lecture","Hw","AppObj","Lab")
let subtopics=Array("Unit-Testing","Test-Factoring","Voting-Class","Reference-Referee","Reference-Trader","Reference-Batteries",
"Inheritance-Batteries","Polymorphic-Electronics","JSON-Store","Player-States","TV-States","Car-States",
"Function-and-Type-Parameters","Recursive-Fibonacci","Recursive-Factoring","Average-in-Range","Immutable-Point",
"Linked-List-Reduce","Backlog","Expression-Trees","BST-toList","Graph-Connections","Graph-Distance",
"Actors","Banking-Actor","Traffic-Actors","Websocket","Echo-Server","DM-Server","Physics-Engine","Rhyming-Dictionary","Calculator",
"Microwave","Genetic-Algorithm","Recommendations","Decision-Tree","Maze-Solver","Clicker","Program-Execution","Object-Oriented-Programming",
"Functional-Programming","Data-Structures-&-Algorithms","Event-Based-Architectures")

let topicMap={
"Lecture":lecture,
Expand All @@ -30,6 +47,9 @@ let topicMap={
}
let username=""

var data=[]
var data2=[]

function displayMessageTA(newMessage) {
username=newMessage
var studentValues=newMessage.split("#")
Expand Down Expand Up @@ -131,6 +151,9 @@ function enterQueue() {
}

function displayTA() {

document.getElementById("HelpInfo").innerHTML=""

let TAname=document.getElementById("username").value
document.getElementById("optionButtons").innerHTML="";
document.getElementById("subtitle").innerText="You are viewing the student queue";
Expand Down Expand Up @@ -224,8 +247,75 @@ function getStatsOption() {
" <option value=\"statTopic\">Topic Stats</option>\n" +
" <option value=\"statSubtopic\">Subtopic Stats</option>\n" +
" </select><br/>" +
" <button id=\"buttonNext\" class= \"addSpace\">Next</button>"
" <button id=\"buttonNext\" class= \"addSpace\" onclick=\"getInfo();\">Next</button>"+
" <div id=\"displayinfo\" class= \"addSpace\" align='center' ></div>"

document.getElementById("statOption").innerHTML=selections;
}
function getInfo() {
let option=document.getElementById("statsValue").value;
if(option=="TaHelpCount"){
socket.emit("get_TA_Stat")
}
else{
socket.emit("get_Student_Stat",option)
}
}



function getTopicPieData(message) {
var pasred=JSON.parse(message)
var tempdata=[]
tempdata.push(['Subject',"# of times asked"])

for( let value of topics){
if(value in pasred){
var temp=[value,pasred[value]]
tempdata.push(temp)
}
}

data=tempdata;
callPie();
}

function getSubtopicPieData(message) {
var pasred=JSON.parse(message)
var tempdata=[]
tempdata.push(['Subject',"# of times asked"])

for( let value of subtopics){
if(value in pasred){
var temp=[value,pasred[value]]
tempdata.push(temp)
}
}

data2=tempdata;
socket.emit("ad",data2)
callPie2();
}
function callPie() {
google.charts.setOnLoadCallback(displayPie);

}
function callPie2() {
google.charts.setOnLoadCallback(displayPie2);

}
function displayPie() {
document.getElementById('displayinfo').innerHTML=""
var chartload = google.visualization.arrayToDataTable(data);
var options = {'title':'What Students needed help with', 'width':550, 'height':500};
var chart = new google.visualization.PieChart(document.getElementById('displayinfo'));
chart.draw(chartload, options);
}
function displayPie2() {
document.getElementById('displayinfo').innerHTML=""
var chartload = google.visualization.arrayToDataTable(data2);
var options = {'title':'What Students needed help with', 'width':550, 'height':500};
var chart = new google.visualization.PieChart(document.getElementById('displayinfo'));
chart.draw(chartload, options);
}

29 changes: 29 additions & 0 deletions src/main/scala/model/OfficeHoursServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class OfficeHoursServer() {
server.addEventListener("done_helping", classOf[String], new doneHelpingListener(this))
server.addEventListener("first_count", classOf[Nothing], new countListener(this))
server.addEventListener("check_login", classOf[String], new loginListener(this))
server.addEventListener("get_TA_Stat", classOf[Nothing], new TAStatListener(this))
server.addEventListener("get_Student_Stat", classOf[String], new StudentStatListener(this))




server.start()
Expand Down Expand Up @@ -267,4 +271,29 @@ class loginListener(server: OfficeHoursServer) extends DataListener[String] {
}
}

class TAStatListener(server:OfficeHoursServer) extends DataListener[Nothing]{
override def onData(socketIOClient: SocketIOClient, t: Nothing, ackRequest: AckRequest): Unit = {
val TAinfo:Map[String,Int]=server.database.getTAHelpInfo()
println(TAinfo)
}
}

class StudentStatListener(server: OfficeHoursServer) extends DataListener[String] {
override def onData(socket: SocketIOClient, option: String, ackRequest: AckRequest): Unit = {

if(option=="statTopic"){
val Studentinfo:Map[String,Int]=server.database.getTopicStat()
println(Studentinfo)
socket.sendEvent("showTopicPie",Json.stringify(Json.toJson(Studentinfo)))
}
else{
val Studentinfo:Map[String,Int]=server.database.getSubtopicStat()
println(Studentinfo)
socket.sendEvent("showSubtopicPie",Json.stringify(Json.toJson(Studentinfo)))

}

}
}


69 changes: 68 additions & 1 deletion src/main/scala/model/database/Database.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,33 @@ class Database extends DatabaseAPI{

def setupTable(): Unit = {
val statement = connection.createStatement()

// statement.execute("DROP TABLE queue")
// statement.execute("DROP TABLE TaStats")
// statement.execute("DROP TABLE questions")


statement.execute("CREATE TABLE IF NOT EXISTS queue(username TEXT, timestamp BIGINT, topic TEXT, subtopic TEXT)")
statement.execute("CREATE TABLE IF NOT EXISTS TaStats(username TEXT, numOfStudentsHelped INT)")
statement.execute("CREATE TABLE IF NOT EXISTS questions(topic TEXT, subtopic TEXT)")

}


override def addStudentToQueue(student: StudentInQueue): Unit = {
val statement = connection.prepareStatement("INSERT INTO queue VALUES (?,?,?,?)")

var statement = connection.prepareStatement("INSERT INTO queue VALUES (?,?,?,?)")

statement.setString(1, student.username)
statement.setLong(2, student.timestamp)
statement.setString(3, student.topic)
statement.setString(4, student.subtopic)
statement.execute()

statement = connection.prepareStatement("INSERT INTO questions VALUES (?,?)")
statement.setString(1, student.topic)
statement.setString(2, student.subtopic)


statement.execute()
}
Expand Down Expand Up @@ -106,4 +121,56 @@ class Database extends DatabaseAPI{
statement.execute()
}

override def getTAHelpInfo():Map[String,Int]={
var TAtoCount:Map[String,Int]=Map()

val statement = connection.prepareStatement("SELECT * FROM TaStats")
val result: ResultSet = statement.executeQuery()

while(result.next()){
val username = result.getString("username")
val count = result.getInt("numOfStudentsHelped")
TAtoCount=TAtoCount+(username->count)
}
TAtoCount
}
override def getTopicStat():Map[String,Int]={
var TopictoCount:Map[String,Int]=Map()

val statement = connection.prepareStatement("SELECT * FROM questions")
val result: ResultSet = statement.executeQuery()

while(result.next()){
val topic = result.getString("topic")

if(TopictoCount.contains(topic)){
val count=TopictoCount(topic)
TopictoCount=TopictoCount+(topic->(count+1))
}
else{
TopictoCount=TopictoCount+(topic->1)
}
}
TopictoCount

}
override def getSubtopicStat():Map[String,Int]={
var SubtopictoCount:Map[String,Int]=Map()

val statement = connection.prepareStatement("SELECT * FROM questions")
val result: ResultSet = statement.executeQuery()

while(result.next()){
val subtopic = result.getString("subtopic")

if(SubtopictoCount.contains(subtopic)){
val count=SubtopictoCount(subtopic)
SubtopictoCount=SubtopictoCount+(subtopic->(count+1))
}
else{
SubtopictoCount=SubtopictoCount+(subtopic->1)
}
}
SubtopictoCount
}
}
4 changes: 4 additions & 0 deletions src/main/scala/model/database/DatabaseAPI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ trait DatabaseAPI {
def getQueue: List[StudentInQueue]
def addTA(username:String):Unit
def addStudentHelped(usernameTA:String): Unit
def getTAHelpInfo():Map[String,Int]
def getTopicStat():Map[String,Int]
def getSubtopicStat():Map[String,Int]



}
10 changes: 10 additions & 0 deletions src/main/scala/model/database/TestingDatabase.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,14 @@ class TestingDatabase extends DatabaseAPI {

}

override def getTAHelpInfo():Map[String,Int]={
???
}
override def getTopicStat():Map[String,Int]={
???
}
override def getSubtopicStat():Map[String,Int]={
???
}

}