Best JavaScript code snippet using puppeteer
index.js
Source:index.js
1const cheerio = require('cheerio');2const fs = require('fs');3let classes = [];4main();5function main(){6 var files = ["AF","BIO","BUS", "CHE", "CJLG", "COM", "CON1", "CSMP", "EDU", "ET", "FIN", "HON", "HP", "MIL", "NURS", "PSY", "SSH"]7 8 9 for (var file in files) {10 console.log(files[file]);11 getData(files[file]); 12 }13 console.log(classes);14 createJson();15}16//17function getData(filename){18 var data = cheerio.load(fs.readFileSync("htmlPages/"+filename+".html"));19 //console.log(data(".detail_row").html());20 parseData(data)21}22function parseData(data){23 //console.log(data);24 var detailRowList = [];25 data('.results').find('tbody > .detail_row' ).each(function (index, element) {26 detailRowList.push(data(element));27 });28 //pareseDetailRows(data, detailRowList);29 var listRowList = [];30 data('.results').find('tbody > .list_row' ).each(function (index, element) {31 listRowList.push(data(element));32 });33 listRowList = fixListCount(listRowList);34 //console.log("got into parseData")35 for( var x in listRowList){36 parseRows(data, listRowList[x], detailRowList[x])37 }38}39function fixListCount(list){40 var all = []41 var ver = []42 for (var x in list){43 //console.log(ver)44 if(list[x].children().html() === " "){45 ver.push(list[x]);46 continue;47 }48 if(x!=0){49 all.push(ver);50 }51 ver = []52 ver.push(list[x]);53 } 54 all.push(ver);55 return all56}57function parseRows(data, listRow, details){58 59 var courseSeats = "";60 var courseFull = "";61 var courseDesc = "";62 var courseMess = "";63 var courseTerm = "";64 var courseBegin = "";65 var courseEnd = "";66 var i;67 details.find(".course_enrollment > .course_seats").each(function (index, element) {68 //console.log(data(element).html());69 courseSeats = data(element).text().trim().split("\t");70 courseSeats = courseSeats.filter(function (item, pos) {71 return courseSeats.indexOf(item) == pos;72 })73 courseSeats = courseSeats.filter(function (item) {74 return item !== '\n';75 })76 courseSeats = courseSeats.filter(function (item) {77 return item !== '';78 })79 for (var i in courseSeats) {80 courseSeats[i] = courseSeats[i].replace('\n', '');81 }82 });83 details.find(".course_enrollment > .course_full").each(function (index, element) {84 //console.log(data(element).html());85 courseFull = data(element).text().trim();86 });87 details.find(".detail_cell").each(function (index, element) {88 //console.log(data(element).text().trim());89 courseDesc = data(element).text().trim();90 });91 details.find('.course_enrollment').remove();92 details.find('.course_messages').remove();93 details.find('.course_term').remove();94 details.find('.course_dates').remove();95 details.not('detail_cell').each(function (index, element) {96 //console.log(data(element).html());97 courseDesc = data(element).text().trim().split('\t');98 courseDesc = courseDesc.filter(function (item, pos) {99 return courseDesc.indexOf(item) == pos;100 })101 courseDesc = courseDesc.filter(function (item) {102 return item !== '\n'103 })104 courseDesc = courseDesc.filter(function (item) {105 return item !== ''106 })107 for (var enn in courseDesc) {108 courseDesc[enn] = courseDesc[enn].replace('\n', '')109 }110 courseDesc = courseDesc.join(" ")111 });112 details.find(".course_messages > .course_xl").each(function (index, element) {113 //console.log(data(element).html());114 courseMess = data(element).text().trim().split("\t");115 courseMess = courseMess.filter(function (item, pos) {116 return courseMess.indexOf(item) == pos;117 })118 courseMess = courseMess.filter(function (item) {119 return item !== '\n';120 })121 courseMess = courseMess.filter(function (item) {122 return item !== '';123 })124 for (var i in courseMess) {125 courseMess[i] = courseMess[i].replace('\n', '');126 }127 });128 details.find(".course_term").each(function (index, element) {129 //console.log(data(element).html());130 courseTerm = data(element).text().trim();131 });132 details.find(".course_dates > .course_begins").each(function (index, element) {133 //console.log(data(element).html());134 courseBegin = data(element).text().trim();135 });136 details.find(".course_dates > .course_ends").each(function (index, element) {137 //console.log(data(element).html());138 courseEnd = data(element).text().trim();139 });140 //dont run the next line of code unless you hate yourself141 //console.log(courseSeats, courseFull, courseDesc, courseMess, courseTerm, courseBegin, courseEnd);142 //-----------------------------list row data parseing-----------------------------------143 var crn = data(listRow[0].find("td")[0]).text().trim()144 var course = data(listRow[0].find("td")[1]).text().trim()145 var sec = data(listRow[0].find("td")[2]).text().trim()146 var type = data(listRow[0].find("td")[3]).text().trim()147 var title = data(listRow[0].find("td")[4]).text().trim()148 var hours = data(listRow[0].find("td")[5]).text().trim()149 var days = [data(listRow[0].find("td")[6]).text().trim()]150 var times = [data(listRow[0].find("td")[7]).text().trim()]151 var rooms = [data(listRow[0].find("td")[8]).text().trim()]152 var instructor = data(listRow[0].find("td")[9]).text().trim()153 var getdepts = getdept(course)154 var subject= getdepts[0]155 var subjectName = getdepts[1]156 var department = getdepts[2]157 var departmentName = getdepts[3]158 //console.log(crn,course,sec,type,title,hours,days,times,rooms,instructors)159 160 for(var i = 1;i<listRow.length;i++){161 //console.log(data(listRow[i].find("td")[1]).text())162 days.push(data(listRow[i].find("td")[1]).text())163 times.push(data(listRow[i].find("td")[2]).text())164 rooms.push(data(listRow[i].find("td")[3]).text())165 } 166 console.log("----------new part of the list --------------")167 courseSeats = "";168 courseFull = "";169 courseDesc = "";170 courseMess = "";171 courseTerm = "";172 courseBegin = "";173 courseEnd = "";174 let finalArr = {};175 finalArr.crn = crn;176 finalArr.course = course;177 finalArr.sec = sec;178 finalArr.type = type;179 finalArr.title = title;180 finalArr.hours = hours;181 finalArr.days = days;182 finalArr.times = times;183 finalArr.rooms = rooms;184 finalArr.instructor = instructor;185 finalArr.subject = subject;186 finalArr.subjectName = subjectName;187 finalArr.department = department;188 finalArr.departmentName = departmentName;189 finalArr.courseSeats = courseSeats;190 finalArr.courseDesc = courseDesc;191 finalArr.courseMess = courseMess;192 finalArr.courseTerm = courseTerm;193 finalArr.courseBegin = courseBegin;194 finalArr.courseEnd = courseEnd;195 classes.push(finalArr);196 //console.log(finalArr)197}198function getdept(course){199 var subject= ""200 var subjectName = ""201 var department = ""202 var departmentName = ""203 if(course.includes("LDR")){204 subject= "LDR"205 subjectName = "Leadership"206 department = "AF"207 departmentName = "Academic Affairs"208 }209 else if(course.includes("RDG")){210 subject= "RDG"211 subjectName = "Reading"212 department = "AF"213 departmentName = "Academic Affairs"214 }215 else if(course.includes("UNV")){216 subject= "UNV"217 subjectName = "University Orientation"218 department = "AF"219 departmentName = "Academic Affairs"220 }221 else if(course.includes("BIO")){222 subject= "BIO"223 subjectName = "Biology"224 department = "BIO"225 departmentName = "Biology"226 }227 else if(course.includes("ESC")){228 subject= "ESC"229 subjectName = "Earth Science"230 department = "BIO"231 departmentName = "Biology"232 }233 else if(course.includes("GEO")){234 subject= "GEO"235 subjectName = "Geography"236 department = "BIO"237 departmentName = "Biology"238 }239 else if(course.includes("ACC")){240 subject= "ACC"241 subjectName = "Accounting"242 department = "BUS"243 departmentName = "Business"244 }245 else if(course.includes("ENT")){246 subject= "ENT"247 subjectName = "Entrepreneurship"248 department = "BUS"249 departmentName = "Business"250 }251 else if(course.includes("FIN")){252 subject= "FIN"253 subjectName = "Finance"254 department = "BUS"255 departmentName = "Business"256 }257 else if(course.includes("GBA")){258 subject= "GBA"259 subjectName = "General Business"260 department = "BUS"261 departmentName = "Business"262 }263 else if(course.includes("MIM")){264 subject= "MIM"265 subjectName = "Information Management"266 department = "BUS"267 departmentName = "Business"268 }269 else if(course.includes("MGT")){270 subject= "MGT"271 subjectName = "Management"272 department = "BUS"273 departmentName = "Business"274 }275 else if(course.includes("MKT")){276 subject= "MKT"277 subjectName = "Manufacturing Engineering Tech"278 department = "BUS"279 departmentName = "Business"280 }281 else if(course.includes("SCM")){282 subject= "SCM"283 subjectName = "Supply Chain Management"284 department = "BUS"285 departmentName = "Business"286 }287 else if(course.includes("CHE")){288 subject= "CHE"289 subjectName = "Chemistry"290 department = "CHE"291 departmentName = "Chemistry"292 }293 else if(course.includes("CLS")){294 subject= "CLS"295 subjectName = "Clinical Laboratory Science"296 department = "CHE"297 departmentName = "Chemistry"298 }299 else if(course.includes("MTE")){300 subject= "MTE"301 subjectName = "Medical Technology"302 department = "CHE"303 departmentName = "Chemistry"304 }305 else if(course.includes("LAW")){306 subject= "MTE"307 subjectName = "Medical Technology"308 department = "CJLG"309 departmentName = "Crim Justice & Legal Studies"310 }311 else if(course.includes("LAT")){312 subject= "LAT"313 subjectName = "Legal Assistant"314 department = "CJLG"315 departmentName = "Crim Justice & Legal Studies"316 }317 else if(course.includes("POL")){318 subject= "POL"319 subjectName = "Policing"320 department = "CJLG"321 departmentName = "Crim Justice & Legal Studies"322 }323 else if(course.includes("COM")){324 subject= "COM"325 subjectName = "Communication Studies"326 department = "COM"327 departmentName = "Communication"328 }329 else if(course.includes("ENG")){330 subject= "ENG"331 subjectName = "English"332 department = "COM"333 departmentName = "Communication"334 }335 else if(course.includes("ETC")){336 subject= "ETC"337 subjectName = "English Technical Communication"338 department = "COM"339 departmentName = "Communication"340 }341 else if(course.includes("JOU")){342 subject= "JOU"343 subjectName = "Journalism"344 department = "COM"345 departmentName = "Communication"346 }347 else if(course.includes("SPA")){348 subject= "SPA"349 subjectName = "Spanish"350 department = "COM"351 departmentName = "Communication"352 }353 else if(course.includes("CED")){354 subject= "CED"355 subjectName = "Continuing Education (WI)"356 department = "CON"357 departmentName = "Western Institute"358 }359 else if(course.includes("ACT")){360 subject= "ACT"361 subjectName = "Applications of Computer Tech"362 department = "CSMP"363 departmentName = "Comp Science, Math & Physics"364 }365 else if(course.includes("CSC")){366 subject= "CSC"367 subjectName = "Computer Science"368 department = "CSMP"369 departmentName = "Comp Science, Math & Physics"370 }371 else if(course.includes("MAT")){372 subject= "MAT"373 subjectName = "Mathematics"374 department = "CSMP"375 departmentName = "Comp Science, Math & Physics"376 }377 else if(course.includes("PHY")){378 subject= "PHY"379 subjectName = "Physics"380 department = "CSMP"381 departmentName = "Comp Science, Math & Physics"382 }383 else if(course.includes("MAS")){384 subject= "MAS"385 subjectName = "Applied Science"386 department = "EDU"387 departmentName = "Education"388 }389 else if(course.includes("EDU")){390 subject= "MAS"391 subjectName = "Education"392 department = "EDU"393 departmentName = "Education"394 }395 else if(course.includes("TSL")){396 subject= "TSL"397 subjectName = "Teaching Second Language"398 department = "EDU"399 departmentName = "Education"400 }401 else if(course.includes("CET")){402 subject= "CET"403 subjectName = "Construction Engineering Techn"404 department = "ET"405 departmentName = "Engineering Technology"406 }407 else if(course.includes("EET")){408 subject= "EET"409 subjectName = "Electronics Engineering Technology"410 department = "ET"411 departmentName = "Engineering Technology"412 }413 else if(course.includes("EGT")){414 subject= "EGT"415 subjectName = "Engineering Technology"416 department = "ET"417 departmentName = "Engineering Technology"418 }419 else if(course.includes("MET")){420 subject= "MET"421 subjectName = "Manufacturing Engineering Tech"422 department = "ET"423 departmentName = "Engineering Technology"424 }425 else if(course.includes("ART")){426 subject= "ART"427 subjectName = "Art"428 department = "FIN"429 departmentName = "Fine Arts"430 }431 else if(course.includes("CIN")){432 subject= "CIN"433 subjectName = "Cinema"434 department = "FIN"435 departmentName = "Fine Arts"436 }437 else if(course.includes("MUS")){438 subject= "MUS"439 subjectName = "Music"440 department = "FIN"441 departmentName = "Fine Arts"442 }443 else if(course.includes("THR")){444 subject= "THR"445 subjectName = "Theatre"446 department = "FIN"447 departmentName = "Fine Arts"448 }449 else if(course.includes("HON")){450 subject= "HON"451 subjectName = "Honors Program"452 department = "HON"453 departmentName = "Honors Program"454 }455 else if(course.includes("ALH")){456 subject= "ALH"457 subjectName = "Allied Health"458 department = "HP"459 departmentName = "Health Professions"460 }461 else if(course.includes("HDA")){462 subject= "HDA"463 subjectName = "Health Data Analytics"464 department = "HP"465 departmentName = "Health Professions"466 }467 else if(course.includes("HIF")){468 subject= "HIF"469 subjectName = "Health Information Management"470 department = "HP"471 departmentName = "Health Professions"472 }473 else if(course.includes("PED")){474 subject= "PED"475 subjectName = "Physical Education"476 department = "HP"477 departmentName = "Health Professions"478 }479 else if(course.includes("PTA")){480 subject= "PTA"481 subjectName = "Physical Therapist Assistant"482 department = "HP"483 departmentName = "Health Professions"484 }485 else if(course.includes("RSM")){486 subject= "RSM"487 subjectName = "Recreation Sport Management"488 department = "HP"489 departmentName = "Health Professions"490 }491 else if(course.includes("SWK")){492 subject= "SWK"493 subjectName = "Social Work"494 department = "HP"495 departmentName = "Health Professions"496 }497 else if(course.includes("SFM")){498 subject= "SFM"499 subjectName = "Sport and Fitness Management"500 department = "HP"501 departmentName = "Health Professions"502 }503 else if(course.includes("MIL")){504 subject= "MIL"505 subjectName = "Sport and Fitness Management"506 department = "MIL"507 departmentName = "Military Science"508 }509 else if(course.includes("MIL")){510 subject= "MIL"511 subjectName = "Sport and Fitness Management"512 department = "MIL"513 departmentName = "Military Science"514 }515 else if(course.includes("NUR")){516 subject= "NUR"517 subjectName = "Nursing"518 department = "NUR"519 departmentName = "Nursing"520 }521 else if(course.includes("PSY")){522 subject= "PSY"523 subjectName = "Psychology"524 department = "PSY"525 departmentName = "Psychology"526 }527 else if(course.includes("ECO")){528 subject= "ECO"529 subjectName = "Economics"530 department = "SSH"531 departmentName = "Social Sciences & Humanities"532 }533 else if(course.includes("HIS")){534 subject= "HIS"535 subjectName = "History"536 department = "SSH"537 departmentName = "Social Sciences & Humanities"538 }539 else if(course.includes("HUM")){540 subject= "HUM"541 subjectName = "Humanities"542 department = "SSH"543 departmentName = "Social Sciences & Humanities"544 }545 else if(course.includes("PHL")){546 subject= "PHL"547 subjectName = "Philosophy"548 department = "SSH"549 departmentName = "Social Sciences & Humanities"550 }551 else if(course.includes("PSC")){552 subject= "PSC"553 subjectName = "Political Science"554 department = "SSH"555 departmentName = "Social Sciences & Humanities"556 }557 else if(course.includes("REL")){558 subject= "REL"559 subjectName = "Religion"560 department = "SSH"561 departmentName = "Social Sciences & Humanities"562 }563 else if(course.includes("SOC")){564 subject= "SOC"565 subjectName = "Sociology"566 department = "SSH"567 departmentName = "Social Sciences & Humanities"568 }569 return [subject,subjectName,department,departmentName]570 571}572console.log("*********************new item in array******************************")573function createJson(){574 fs.writeFile('classes.json',JSON.stringify(classes),err=>{575 if(err){576 console.log("Error Writing File:", err)577 }else{578 console.log("semester.json file created")579 }580 })...
data.js
Source:data.js
1export const data = [2 {3 id: crypto.randomUUID(),4 className: "Class A",5 students: [6 {7 studentName: "Marko",8 subject: [9 {10 subjectName: "Matematik",11 grade: 8012 },13 {14 subjectName: "Fizik",15 grade: 7016 },17 {18 subjectName: "Geometri",19 grade: 8020 }21 ]22 },23 {24 studentName: "Recep",25 subject: [26 {27 subjectName: "Matematik",28 grade: 029 },30 {31 subjectName: "Fizik",32 grade: 5033 },34 {35 subjectName: "Geometri",36 grade: 10037 }38 ]39 },40 {41 studentName: "Emre",42 subject: [43 {44 subjectName: "Matematik",45 grade: 6546 },47 {48 subjectName: "Fizik",49 grade: 7250 },51 {52 subjectName: "Kimya",53 grade: 4154 },55 {56 subjectName: "Geometri",57 grade: 9058 }59 ]60 },61 ],62 },63 {64 id: crypto.randomUUID(),65 className: "Class B",66 students: [67 {68 studentName: "Rafaelle",69 subject: [70 {71 subjectName: "Matematik",72 grade: 2073 },74 {75 subjectName: "Fizik",76 grade: 4077 },78 {79 subjectName: "Geometri",80 grade: 1081 }82 ]83 },84 {85 studentName: "Tom",86 subject: [87 {88 subjectName: "Matematik",89 grade: 9090 },91 {92 subjectName: "Fizik",93 grade: 6094 },95 {96 subjectName: "Kimya",97 grade: 10098 },99 {100 subjectName: "Geometri",101 grade: 10102 }103 ]104 },105 ],106 },107 {108 id: crypto.randomUUID(),109 className: "Class C",110 students: [111 {112 studentName: "Mario",113 subject: [114 {115 subjectName: "Fizik",116 grade: 70117 },118 {119 subjectName: "Kimya",120 grade: 25121 },122 {123 subjectName: "Geometri",124 grade: 43125 }126 ]127 },128 {129 studentName: "Silvia ",130 subject: [131 {132 subjectName: "Matematik",133 grade: 15134 },135 {136 subjectName: "Fizik",137 grade: 75138 },139 {140 subjectName: "Geometri",141 grade: 80142 }143 ]144 },145 {146 studentName: "Daria",147 subject: [148 {149 subjectName: "Matematik",150 grade: 90151 },152 {153 subjectName: "Fizik",154 grade: 70155 },156 {157 subjectName: "Kimya",158 grade: 80159 },160 {161 subjectName: "Geometri",162 grade: 80163 }164 ]165 },166 {167 studentName: "Mateo",168 subject: [169 {170 subjectName: "Matematik",171 grade: 90172 },173 {174 subjectName: "Fizik",175 grade: 70176 },177 {178 subjectName: "Kimya",179 grade: 80180 },181 {182 subjectName: "Geometri",183 grade: 80184 }185 ]186 },187 {188 studentName: "Mehmet",189 subject: [190 {191 subjectName: "Matematik",192 grade: 90193 },194 {195 subjectName: "Fizik",196 grade: 70197 },198 {199 subjectName: "Kimya",200 grade: 80201 },202 {203 subjectName: "Geometri",204 grade: 80205 }206 ]207 },208 ]209 },210 {211 id: crypto.randomUUID(),212 className: "Class D",213 students: [214 {215 studentName: "Mario",216 subject: [217 {218 subjectName: "Matematik",219 grade: 58220 },221 {222 subjectName: "Fizik",223 grade: 58224 },225 {226 subjectName: "Kimya",227 grade: 25228 }229 ]230 },231 {232 studentName: "Silvia ",233 subject: [234 {235 subjectName: "Matematik",236 grade: 15237 },238 {239 subjectName: "Fizik",240 grade: 87.5241 },242 {243 subjectName: "Geometri",244 grade: 80245 }246 ]247 },248 {249 studentName: "Mateo",250 subject: [251 {252 subjectName: "Matematik",253 grade: 25254 },255 {256 subjectName: "Fizik",257 grade: 80258 },259 {260 subjectName: "Kimya",261 grade: 55262 },263 {264 subjectName: "Geometri",265 grade: 55.6266 }267 ]268 },269 {270 studentName: "Mehmet",271 subject: [272 {273 subjectName: "Matematik",274 grade: 96.99275 },276 {277 subjectName: "Kimya",278 grade: 75279 },280 {281 subjectName: "Geometri",282 grade: 37.5283 }284 ]285 },286 ]287 },288 {289 id: crypto.randomUUID(),290 className: "Class E",291 students: [292 {293 studentName: "Silvia ",294 subject: [295 {296 subjectName: "Matematik",297 grade: 45298 },299 {300 subjectName: "Fizik",301 grade: 87.5302 },303 {304 subjectName: "Geometri",305 grade: 73306 }307 ]308 },309 {310 studentName: "Daria",311 subject: [312 {313 subjectName: "Matematik",314 grade: 25315 },316 {317 subjectName: "Fizik",318 grade: 55319 },320 {321 subjectName: "Kimya",322 grade: 40323 },324 {325 subjectName: "Geometri",326 grade: 25327 }328 ]329 },330 {331 studentName: "Mateo",332 subject: [333 {334 subjectName: "Matematik",335 grade: 45336 },337 {338 subjectName: "Fizik",339 grade: 28340 },341 {342 subjectName: "Kimya",343 grade: 55344 },345 {346 subjectName: "Geometri",347 grade: 55.6348 }349 ]350 },351 {352 studentName: "Mehmet",353 subject: [354 {355 subjectName: "Matematik",356 grade: 96.99357 }358 ]359 },360 {361 studentName: "Samir",362 subject: [363 {364 subjectName: "Matematik",365 grade: 55366 },367 {368 subjectName: "Fizik",369 grade: 63370 },371 {372 subjectName: "Kimya",373 grade: 78374 },375 {376 subjectName: "Geometri",377 grade: 42.9378 }379 ]380 },381 {382 studentName: "Pamir",383 subject: [384 {385 subjectName: "Matematik",386 grade: 41387 },388 {389 subjectName: "Kimya",390 grade: 82.5391 },392 {393 subjectName: "Geometri",394 grade: 69395 }396 ]397 },398 {399 studentName: "Hansel",400 subject: [401 {402 subjectName: "Matematik",403 grade: 55404 },405 {406 subjectName: "Fizik",407 grade: 55408 },409 {410 subjectName: "Kimya",411 grade: 55412 },413 {414 subjectName: "Geometri",415 grade: 88416 }417 ]418 },419 {420 studentName: "Gratel",421 subject: [422 {423 subjectName: "Matematik",424 grade: 60425 },426 {427 subjectName: "Fizik",428 grade: 42429 },430 {431 subjectName: "Kimya",432 grade: 59433 },434 {435 subjectName: "Geometri",436 grade: 3437 }438 ]439 },440 {441 studentName: "Daria",442 subject: [443 {444 subjectName: "Matematik",445 grade: 100446 },447 {448 subjectName: "Fizik",449 grade: 100450 },451 {452 subjectName: "Kimya",453 grade: 100454 },455 {456 subjectName: "Geometri",457 grade: 100458 }459 ]460 },461 {462 studentName: "Teya",463 subject: [464 {465 subjectName: "Matematik",466 grade: 71467 },468 {469 subjectName: "Fizik",470 grade: 84471 },472 {473 subjectName: "Kimya",474 grade: 66475 },476 {477 subjectName: "Geometri",478 grade: 89479 }480 ]481 },482 {483 studentName: "Massimo",484 subject: [485 {486 subjectName: "Matematik",487 grade: 64488 },489 {490 subjectName: "Fizik",491 grade: 99492 },493 {494 subjectName: "Kimya",495 grade: 51496 },497 {498 subjectName: "Geometri",499 grade: 90500 }501 ]502 }503 ]504 },505 {506 id: crypto.randomUUID(),507 className: "Class F",508 students: [509 {510 studentName: "Alice",511 subject: [512 {513 subjectName: "Matematik",514 grade: 85515 },516 {517 subjectName: "Fizik",518 grade: 100519 },520 {521 subjectName: "Kimya",522 grade: 73523 },524 {525 subjectName: "Geometri",526 grade: 67527 }528 ]529 },530 {531 studentName: "Kalimerhaba ",532 subject: [533 {534 subjectName: "Matematik",535 grade: 97536 },537 {538 subjectName: "Fizik",539 grade: 89540 },541 {542 subjectName: "Kimya",543 grade: 65544 },545 {546 subjectName: "Geometri",547 grade: 89548 }549 ]550 },551 {552 studentName: "Ahmet ",553 subject: [554 {555 subjectName: "Matematik",556 grade: 48557 },558 {559 subjectName: "Fizik",560 grade: 69561 },562 {563 subjectName: "Kimya",564 grade: 83565 },566 {567 subjectName: "Geometri",568 grade: 76569 }570 ]571 },572 ]573 },574 {575 id: crypto.randomUUID(),576 className: "Class G",577 students: [578 {579 studentName: "Silvia ",580 subject: [581 {582 subjectName: "Matematik",583 grade: 45584 },585 {586 subjectName: "Fizik",587 grade: 87.5588 },589 {590 subjectName: "Geometri",591 grade: 73592 }593 ]594 },595 ]596 }597]...
Stream.js
Source:Stream.js
1var Stream,2 hasProp = {}.hasOwnProperty;3import Util from '../util/Util.js';4// Stream is standalone base class for all publish and subscribe steams5// StreamRx extends Stream for RxJS6// SteamsXs extends Stream for xstream7Stream = class Stream {8 constructor(subjectNames, info) {9 var i, len, ref, subjectName;10 this.subjectNames = subjectNames;11 this.info = info;12 this.subjects = {};13 ref = this.subjectNames;14 for (i = 0, len = ref.length; i < len; i++) {15 subjectName = ref[i];16 this.addSubject(subjectName);17 }18 Util.noop(this.allInfo);19 }20 subscribe(subjectName, subscriberName, onCallback) {21 var subject;22 subject = this.getSubject(subjectName, false);23 subject['subscribers'][subscriberName] = onCallback;24 if (this.isInfo(subjectName, 'subscribe')) {25 console.info('Strean.subscribe()', {26 subject: subjectName,27 subscriber: subscriberName28 });29 }30 }31 publish(subjectName, object) {32 var onCallback, ref, subject, subscriberName;33 subject = this.getSubject(subjectName, false);34 ref = subject['subscribers'];35 for (subscriberName in ref) {36 if (!hasProp.call(ref, subscriberName)) continue;37 onCallback = ref[subscriberName];38 onCallback(object);39 }40 if (this.isInfo(subjectName, 'publish')) {41 console.info('Stream.publish()', {42 subject: subjectName,43 object: object44 });45 }46 }47 event(subjectName, object, element, eventType) {48 var onEvent;49 onEvent = (event) => {50 if (event != null) {51 event.stopPropagation();52 }53 if (event != null) {54 event.preventDefault();55 }56 this.publish(subjectName, object);57 };58 element.addEventListener(eventType, onEvent);59 }60 complete(subjectName, object, completeName, onComplete, completeObject) {61 var onCallback, onSubscribe, ref, ref1, subject, subscriberName;62 subject = this.getSubject(subjectName, false);63 subject[completeName] = {};64 ref = subject['subscribers'];65 for (subscriberName in ref) {66 if (!hasProp.call(ref, subscriberName)) continue;67 onCallback = ref[subscriberName];68 subject[completeName][subscriberName] = false;69 }70 ref1 = subject['subscribers'];71 for (subscriberName in ref1) {72 if (!hasProp.call(ref1, subscriberName)) continue;73 onCallback = ref1[subscriberName];74 onSubscribe = (object) => {75 onCallback(object);76 subject[completeName][subscriberName] = true;77 if (this.isComplete(subject, completeName)) {78 onComplete(completeObject);79 if (this.isInfo(subjectName, 'complete')) {80 return console.info('Stream.complete()', {81 subject: subjectName,82 object: object,83 complete: completeName,84 completeObject: completeObject85 });86 }87 }88 };89 onSubscribe(object);90 }91 }92 isComplete(subject, completeName) {93 var ref, status, subscriberName;94 ref = subject[completeName];95 for (subscriberName in ref) {96 if (!hasProp.call(ref, subscriberName)) continue;97 status = ref[subscriberName];98 if (status === false) {99 return false;100 }101 }102 return true;103 }104 unsubscribe(subjectName, subscriberName) {105 if (this.hasSubject(subjectName)) {106 if (this.hasSubscriber(subjectName, subscriberName)) {107 delete this.subjects[subjectName].subscribers[subscriberName];108 } else {109 console.error('Strean.unsubscribe() unknown subscriber', {110 subject: subjectName,111 subscriber: subscriberName112 });113 }114 } else {115 console.error('Strean.unsubscribe() unknown subject', {116 subject: subjectName,117 subscriber: subscriberName118 });119 }120 if (this.isInfo(subjectName, 'subscribe')) {121 console.info('Stream.unsubscribe()', {122 subject: subjectName,123 subscriber: subscriberName124 });125 }126 }127 unsubscribeAll() {128 var onCallback, ref, ref1, subject, subjectName, subscriberName;129 ref = this.subjects;130 for (subjectName in ref) {131 if (!hasProp.call(ref, subjectName)) continue;132 subject = ref[subjectName];133 ref1 = subject['subscribers'];134 for (subscriberName in ref1) {135 if (!hasProp.call(ref1, subscriberName)) continue;136 onCallback = ref1[subscriberName];137 this.unsubscribe(subjectName, subscriberName);138 }139 }140 }141 addSubject(subjectName, warn = true) {142 var subject;143 if (!this.hasSubject(subjectName)) {144 subject = {};145 subject['subscribers'] = {};146 this.subjects[subjectName] = subject;147 } else {148 if (warn) {149 console.warn('Stream.addSubject() subject already exists', subjectName);150 }151 }152 }153 hasSubject(subjectName) {154 return this.subjects[subjectName] != null;155 }156 hasSubscriber(subjectName, subscriberName) {157 return this.hasSubject(subjectName) && (this.subjects[subjectName]['subscribers'][subscriberName] != null);158 }159 // Get a subject by name. Create a new one if need with a warning160 getSubject(subjectName, warn = true) {161 if (!this.hasSubject(subjectName)) {162 if (warn) {163 console.warn('Stream.getSubject() unknown name for subject so creating one for', subjectName);164 }165 this.addSubject(subjectName, false);166 }167 return this.subjects[subjectName];168 }169 isInfo(subjectName, op) {170 return Util.inArray(this.info.subjects, subjectName) && (this.info[op] != null) && this.info[op];171 }172 allInfo() {173 var ref, ref1, subject, subjectName, subscriber, subscriberName;174 console.info('--- Stream.Subjects --- ');175 ref = this.subjects;176 for (subjectName in ref) {177 if (!hasProp.call(ref, subjectName)) continue;178 subject = ref[subjectName];179 console.info(` Subject ${subjectName}`);180 ref1 = subject.subscribers;181 for (subscriberName in ref1) {182 if (!hasProp.call(ref1, subscriberName)) continue;183 subscriber = ref1[subscriberName];184 console.info(` Subscriber ${subscriberName}`);185 }186 }187 }188};...
dbConfig.js
Source:dbConfig.js
1class Database{2 constructor(){}3 async createDatabase(){4 const mysqlCreate = require("mysql2");5 const conn = mysqlCreate.createConnection({6 host:'localhost',7 user: 'root',8 password: 'a'9 });10 conn.query("CREATE DATABASE IF NOT EXISTS EngSoftDB");11 conn.end();12 }13 14 async createTables(){15 const conn = await this.connect();16 const createUsers = "CREATE TABLE IF NOT EXISTS Users (id INT AUTO_INCREMENT, email VARCHAR(100) NOT NULL UNIQUE, name VARCHAR(20) NOT NULL, password VARCHAR(100) NOT NULL, professor BOOLEAN NOT NULL DEFAULT FALSE, PRIMARY KEY (id, email))";17 const createSubjects = "CREATE TABLE IF NOT EXISTS Subjects (code VARCHAR(6) NOT NULL PRIMARY KEY, subjectName VARCHAR(60) NOT NULL)";18 const createProfData = "CREATE TABLE IF NOT EXISTS ProfData (id INT PRIMARY KEY, description VARCHAR(2000), price INT, FOREIGN KEY (id) REFERENCES Users (id) ON DELETE CASCADE)";19 const createMessages = "CREATE TABLE IF NOT EXISTS Messages (idSender INT, idReceiver INT, time DATETIME, status BOOLEAN NOT NULL DEFAULT FALSE, text VARCHAR(2000), PRIMARY KEY (idSender, idReceiver, time), FOREIGN KEY (idSender) REFERENCES Users (id) ON DELETE CASCADE, FOREIGN KEY (idReceiver) REFERENCES Users (id) ON DELETE CASCADE)";20 const createSubProf = "CREATE TABLE IF NOT EXISTS SubProf (professor INT, subject VARCHAR(6), FOREIGN KEY (professor) REFERENCES Users (id) ON DELETE CASCADE, FOREIGN KEY (subject) REFERENCES Subjects (code) ON DELETE CASCADE )";21 conn.query(createUsers);22 conn.query(createSubjects);23 conn.query(createSubProf);24 conn.query(createProfData);25 conn.query(createMessages);26 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('DCC203', 'Programação e Desenvolvimento de Software I')");27 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('DCC638', 'Introdução à Lógica Computacional')");28 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('MAT038', 'Geometria AnalÃtica e Ãlgebra Linear')");29 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('DCC204', 'Programação e Desenvolvimento de Software II')");30 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('DCC216', 'Matemática Discreta')");31 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('DCC639', 'Ãlgebra Linear Computacional')");32 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('MAT001', 'Calculo Diferencial e Integral I')");33 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('DCC011', 'Introdução a Banco de Dados')");34 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('DCC114', 'Introdução a Sistemas Lógicos')");35 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('DCC205', 'Estruturas de Dados')");36 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('EST032', 'Probabilidade')");37 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('MAT039', 'Calculo Diferencial e Integral II')");38 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('DCC006', 'Organização de Computadores I')");39 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('DCC129', 'Fundamentos da Teoria da Computação')");40 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('DCC206', 'Algoritmos I')");41 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('DCC212', 'Introdução à Ciência dos Dados')");42 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('MAT034', 'Ãlgebra A')");43 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('DCC299', 'Linguagens de Programação')");44 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('DCC035', 'Pesquisa Operacional')");45 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('DCC207', 'Algoritmos II')");46 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('MAT040', 'Equações Diferenciais C')");47 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('DCC053', 'Compiladores I')");48 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('DCC603', 'Engenharia de Software')");49 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('DCC605', 'Sistemas Operacionais')");50 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('FIS156', 'Introdução à FÃsica EstatÃstica Computacional')");51 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('DCC023', 'Redes de Computadores')");52 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('DCC636', 'Ãtica na Computação')");53 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('DCC641', 'Fundamentos de Sistemas Paralelos e DistribuÃdos')");54 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('DCC642', 'Introdução à Inteligência Artificial')");55 conn.query("INSERT INTO Subjects (code, subjectName) VALUES ('DCC637', 'Computação e Sociedade')");56 conn.end();57 }58 async connect(){59 const mysql = require("mysql2/promise");60 const connection = await mysql.createConnection("mysql://root:a@localhost:3306/EngSoftDB");61 return connection;62 }63 async disconnect(conn){64 conn.end();65 }66}...
studentsProgress.directive.js
Source:studentsProgress.directive.js
1'use strict';2angular.module('fsaApp')3 .directive('studentsProgress', function (Auth, $location, $http, User, filterFilter, usSpinnerService) {4 return {5 templateUrl: 'components/studentsProgress/studentsProgress.html',6 restrict: 'EA',7 link: function (scope) {8 scope.currentPage = 1;9 scope.maxPage = 1;10 scope.lim = 10;11 scope.students = [];12 scope.selectedSubject = {};13 scope.filter = {};14 scope.examDetails = [];15 //Prevent Route from Unauthorized user16 if (!Auth.isAdmin() && !Auth.isTeacher()) {17 $location.path('/');18 }19 //Get Current User20 scope.currentUser = Auth.getCurrentUser();21 //Get subjectsTaught from User Object22 if (Auth.isTeacher()) {23 scope.subjectsTaught = scope.currentUser.subjectsTaught;24 scope.students = scope.currentUser.referral.usersReferred;25 }26 //Fetch Students27 scope.getStudents = function () {28 scope.startSpin('spinner-search');29 var queryString = '/api/users/students/list/' + scope.selectedSubject.subject + '/' + scope.currentPage + '/' + scope.lim;30 if (scope.filter.search !== '' && typeof (scope.filter.search) !== 'undefined') {31 queryString = '/api/users/students/list/' + scope.selectedSubject.subject + '/' + scope.currentPage + '/' + scope.lim + '/' + scope.filter.search;32 }33 $http.get(queryString).success(function (students) {34 scope.students = students.users;35 scope.filtered = students.users;36 scope.totalStudents = students.count;37 scope.examDetails = students.examDetails;38 //socket.syncUpdates('betaKey', scope.betaKeys);39 scope.maxPage = Math.ceil(scope.totalStudents / scope.lim);40 scope.stopSpin('spinner-search');41 });42 };43 //If Admin: Allow all subjects44 if (Auth.isAdmin()) {45 scope.subjectsTaught = [46 {subjectName: 'APCalcAB'},47 {subjectName: 'APCalcBC'},48 {subjectName: 'APStats'},49 {subjectName: 'APPhysics1'},50 {subjectName: 'APPhysics2'},51 {subjectName: 'APEurHistory'},52 {subjectName: 'APUSHistory'},53 {subjectName: 'APWorldHistory'},54 {subjectName: 'APMicroecon'},55 {subjectName: 'APMacroecon'},56 {subjectName: 'APPsych'},57 {subjectName: 'APBio'},58 {subjectName: 'APChem'},59 {subjectName: 'APEnvSci'},60 {subjectName: 'APUSGovt'},61 {subjectName: 'APHumGeo'}62 ];63 }64 //Set Initial subject65 if (scope.subjectsTaught.length > 0) {66 scope.selectedSubject.subject = scope.subjectsTaught[0].subjectName;67 }68 //Check if teacher has subjectsTaught69 scope.hasSubjectTaught = function () {70 return scope.subjectsTaught.length > 0;71 };72 scope.$watch('filtered', function (filtered) {73 if (filtered) {74 var filterLen = filtered.length;75 if (filterLen > 0) {76 scope.maxPage = Math.ceil(scope.totalStudents / scope.lim);77 }78 else {79 scope.maxPage = 1;80 }81 }82 });83 //Changes the page of the users.84 scope.page = function (step) {85 var newPage = scope.currentPage + step;86 if ((newPage < 1 ) || (newPage > scope.maxPage)) {87 return;88 }89 else {90 scope.currentPage = newPage;91 scope.getStudents();92 }93 };94 //Update Filter95 scope.updateFiltered = function () {96 scope.currentPage = 1;97 scope.getStudents();98 };99 //Get Exam Attempts100 scope.getExamAttempts = function (student) {101 for (var i = 0; i < student.exams.length; ++i) {102 for (var j = 0; j < scope.examDetails.length; ++j) {103 if (student.exams[i].examId === scope.examDetails[j]._id && scope.examDetails[j].subject === scope.selectedSubject.subject) {104 return student.exams[i].attempts;105 }106 }107 }108 return 0;109 };110 //Get Exam High Score111 scope.getHighScore = function (student) {112 for (var i = 0; i < student.exams.length; ++i) {113 for (var j = 0; j < scope.examDetails.length; ++j) {114 if (student.exams[i].examId === scope.examDetails[j]._id && scope.examDetails[j].subject === scope.selectedSubject.subject) {115 return student.exams[i].score;116 }117 }118 }119 return 0;120 };121 //Update Students List122 scope.updateStudentsList = function () {123 scope.currentPage = 1;124 scope.getStudents();125 };126 scope.startSpin = function (spinner) {127 usSpinnerService.spin(spinner);128 };129 scope.stopSpin = function (spinner) {130 usSpinnerService.stop(spinner);131 };132 scope.getStudents();133 }134 };...
seedReports.js
Source:seedReports.js
1const mongoose = require('mongoose');2require('dotenv').config();3const colors = require('colors');4const User = require('./models/user');5const connectDB = require('./config/db');6connectDB();7// This stops a deprecation warning appearing8mongoose.set('useFindAndModify', false);9const importReport = async () => {10 try {11 // findOneAndUpdate12 // 1 Query object13 // 2 data object14 // 3 Options object15 await User.findOneAndUpdate(16 {17 email: '19tuser@frieslandschool.com',18 },19 {20 $push: {21 reportData: {22 year: 2020,23 datapoint: 1,24 data: [25 {26 subjectName: 'Maths',27 effort: 5,28 subjectGrade: 6,29 },30 {31 subjectName: 'English',32 effort: 4,33 subjectGrade: 6,34 },35 {36 subjectName: 'Science',37 effort: 5,38 subjectGrade: 4,39 },40 {41 subjectName: 'History',42 effort: 3,43 subjectGrade: 4,44 },45 {46 subjectName: 'Geography',47 effort: 4,48 subjectGrade: 6,49 },50 {51 subjectName: 'French',52 effort: 2,53 subjectGrade: 5,54 },55 {56 subjectName: 'Computer Science',57 effort: 5,58 subjectGrade: 8,59 },60 {61 subjectName: 'Physical Education',62 effort: 3,63 subjectGrade: 4,64 },65 ],66 },67 },68 }69 );70 await User.findOneAndUpdate(71 {72 email: '19tuser@frieslandschool.com',73 },74 {75 $push: {76 reportData: {77 year: 2020,78 datapoint: 2,79 data: [80 {81 subjectName: 'Maths',82 effort: 4,83 subjectGrade: 5,84 },85 {86 subjectName: 'English',87 effort: 4,88 subjectGrade: 6,89 },90 {91 subjectName: 'Science',92 effort: 4,93 subjectGrade: 6,94 },95 {96 subjectName: 'History',97 effort: 3,98 subjectGrade: 4,99 },100 {101 subjectName: 'Geography',102 effort: 4,103 subjectGrade: 5,104 },105 {106 subjectName: 'French',107 effort: 2,108 subjectGrade: 3,109 },110 {111 subjectName: 'Computer Science',112 effort: 5,113 subjectGrade: 6,114 },115 {116 subjectName: 'Physical Education',117 effort: 4,118 subjectGrade: 6,119 },120 ],121 },122 },123 },124 {125 timestamps: true,126 }127 );128 await User.findOneAndUpdate(129 {130 email: '19tuser@frieslandschool.com',131 },132 {133 $push: {134 reportData: {135 year: 2020,136 datapoint: 3,137 data: [138 {139 subjectName: 'Maths',140 effort: 3,141 subjectGrade: 3,142 },143 {144 subjectName: 'English',145 effort: 4,146 subjectGrade: 5,147 },148 {149 subjectName: 'Science',150 effort: 5,151 subjectGrade: 7,152 },153 {154 subjectName: 'History',155 effort: 3,156 subjectGrade: 5,157 },158 {159 subjectName: 'Geography',160 effort: 4,161 subjectGrade: 6,162 },163 {164 subjectName: 'French',165 effort: 3,166 subjectGrade: 4,167 },168 {169 subjectName: 'Computer Science',170 effort: 5,171 subjectGrade: 8,172 },173 {174 subjectName: 'Physical Education',175 effort: 2,176 subjectGrade: 4,177 },178 ],179 },180 },181 },182 {183 timestamps: true,184 }185 );186 console.log('Data Imported!'.green.inverse);187 process.exit();188 } catch (error) {189 console.error(`${error}`.red.inverse);190 process.exit(1);191 }192};193const destroyData = async () => {194 try {195 await User.deleteMany();196 console.log('Data Destroyed!'.red.inverse);197 process.exit();198 } catch (error) {199 console.error(`${error}`.red.inverse);200 process.exit(1);201 }202};...
subject.js
Source:subject.js
1export let subjects = [2 {subjectId: 'GEN101',subjectName:'PHYSICAL EDUCATION',subjectCredit: 1,subjectSemester: '1/2563'},3 {subjectId: 'GEN121',subjectName:'LEARNING AND PROBLEM SOLVING SKILLS',subjectCredit: 3,subjectSemester: '1/2563'},4 {subjectId: 'INT100',subjectName:'INFORMATION TECHNOLOGY FUNDAMENTALS',subjectCredit: 3,subjectSemester: '1/2563'},5 {subjectId: 'INT101',subjectName:'PROGRAMMING FUNDAMENTALS',subjectCredit: 3,subjectSemester: '1/2563'},6 {subjectId: 'INT102',subjectName:'WEB TECHNOLOGY',subjectCredit: 1,subjectSemester: '1/2563'},7 {subjectId: 'INT114',subjectName:'DISCRETE MATHEMATICS FOR INFORMATION TECHNOLOGY',subjectCredit: 3,subjectSemester: '1/2563'},8 {subjectId: 'LNG120',subjectName:'GENERAL ENGLISH',subjectCredit: 3,subjectSemester: '1/2563'},9 {subjectId: 'GEN111',subjectName:'MAN AND ETHICS OF LIVING',subjectCredit: 3,subjectSemester: '2/2563'},10 {subjectId: 'INT103',subjectName:'ADVANCED PROGRAMMING',subjectCredit: 3,subjectSemester: '2/2563'},11 {subjectId: 'INT104',subjectName:'USER EXPERIENCE DESIGN',subjectCredit: 3,subjectSemester: '2/2563'},12 {subjectId: 'INT105',subjectName:'BASIC SQL',subjectCredit: 1,subjectSemester: '2/2563'},13 {subjectId: 'INT107',subjectName:'COMPUTING PLATFORMS TECHNOLOGY',subjectCredit: 3,subjectSemester: '2/2563'},14 {subjectId: 'INT200',subjectName:'DATA STRUCTURE & ALGORITHM',subjectCredit: 1,subjectSemester: '2/2563'},15 {subjectId: 'LNG220',subjectName:'ACADEMIC ENGLISH',subjectCredit: 3,subjectSemester: '2/2563'},16 {subjectId: 'GEN231',subjectName:'MIRACLE OF THINKING',subjectCredit: 3,subjectSemester: '1/2564'},17 {subjectId: 'INT201',subjectName:'CLIENT-SIDE WEB PROGRAMMING I',subjectCredit: 2,subjectSemester: '1/2564'},18 {subjectId: 'INT202',subjectName:'SERVER-SIDE WEB PROGRAMMING I',subjectCredit: 2,subjectSemester: '1/2564'},19 {subjectId: 'INT205',subjectName:'DATABASE MANAGEMENT SYSTEM',subjectCredit: 3,subjectSemester: '1/2564'},20 {subjectId: 'INT207',subjectName:'NETWORK I',subjectCredit: 3,subjectSemester: '1/2564'},21 {subjectId: 'INT214',subjectName:'STATISTICS FOR INFORMATION TECHNOLOGY',subjectCredit: 3,subjectSemester: '1/2564'},22 {subjectId: 'LNG202',subjectName:'BASIC READING FOR SCIENCE AND TECHNOLOGY',subjectCredit: 1,subjectSemester: '1/2564'}...
subjectsTaught.controller.js
Source:subjectsTaught.controller.js
1'use strict';2angular.module('fsaApp')3 .controller('SubjectsTaughtCtrl', function ($scope, ngDialog, $http) {4 var teacher = $scope.ngDialogData;5 $scope.subjectsTaught = [];6 $scope.subjects = [7 {ticked: false, subjectName: 'APCalcAB', name: 'AP Calculus AB'},8 {ticked: false, subjectName: 'APCalcBC', name: 'AP Calculus BC'},9 {ticked: false, subjectName: 'APStats', name: 'AP Statistics'},10 {ticked: false, subjectName: 'APPhysics1', name: 'AP Physics 1'},11 {ticked: false, subjectName: 'APPhysics2', name: 'AP Physics 2'},12 {ticked: false, subjectName: 'APEurHistory', name: 'AP European History'},13 {ticked: false, subjectName: 'APUSHistory', name: 'AP US History'},14 {ticked: false, subjectName: 'APWorldHistory', name: 'AP World History'},15 {ticked: false, subjectName: 'APMicroecon', name: 'AP Microeconomics'},16 {ticked: false, subjectName: 'APMacroecon', name: 'AP Macroeconomics'},17 {ticked: false, subjectName: 'APPsych', name: 'AP Psychology'},18 {ticked: false, subjectName: 'APBio', name: 'AP Biology'},19 {ticked: false, subjectName: 'APChem', name: 'AP Chemistry'},20 {ticked: false, subjectName: 'APEnvSci', name: 'AP Env. Science'},21 {ticked: false, subjectName: 'APUSGovt', name: 'AP US Gov. & Pol.'},22 {ticked: false, subjectName: 'APHumGeo', name: 'AP Human Geography'}23 ];24 for (var i = 0; i < teacher.subjectsTaught.length; ++i) {25 for (var j = 0; j < $scope.subjects.length; ++j) {26 if (teacher.subjectsTaught[i].subjectName === $scope.subjects[j].subjectName) {27 $scope.subjects[j].ticked = true;28 }29 }30 }31 //Save Subjects Taught to DB32 $scope.saveSubjectsTaught = function () {33 var finalSubjectsTaught = [];34 for (var i = 0; i < $scope.subjectsTaught.length; ++i) {35 finalSubjectsTaught.push({subjectName: $scope.subjectsTaught[i].subjectName});36 }37 $http.put('/api/users/' + teacher._id + '/savesubjectstaught', {subjectsTaught: JSON.stringify(finalSubjectsTaught)}).then(function (res) {38 if (res.status === 200) {39 //Update local user Object40 $scope.ngDialogData.subjectsTaught = finalSubjectsTaught;41 }42 });43 ngDialog.closeAll(true);44 }...
Using AI Code Generation
1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch();4 const page = await browser.newPage();5 await page.screenshot({path: 'example.png'});6 await browser.close();7})();
Using AI Code Generation
1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch({headless: false});4 const page = await browser.newPage();5 await page.waitForSelector('h1');6 const h1 = await page.evaluate(() => document.querySelector('h1').innerText);7 console.log(h1);8 await browser.close();9})();10const puppeteer = require('puppeteer');11(async () => {12 const browser = await puppeteer.launch({headless: false});13 const page = await browser.newPage();14 await page.waitForSelector('h1');15 const h1 = await page.evaluate(() => document.querySelector('h1').innerText);16 console.log(h1);17 await browser.close();18})();19const puppeteer = require('puppeteer');20(async () => {21 const browser = await puppeteer.launch({headless: false});22 const page = await browser.newPage();23 await page.waitForSelector('h1');24 const h1 = await page.evaluate(() => document.querySelector('h1').innerText);25 console.log(h1);26 await browser.close();27})();28const puppeteer = require('puppeteer');29(async () => {30 const browser = await puppeteer.launch({headless: false});31 const page = await browser.newPage();32 await page.waitForSelector('h1');33 const h1 = await page.evaluate(() => document.querySelector('h1').innerText);34 console.log(h1);35 await browser.close();36})();37const puppeteer = require('puppeteer');38(async () => {39 const browser = await puppeteer.launch({headless: false});40 const page = await browser.newPage();41 await page.waitForSelector('h1');42 const h1 = await page.evaluate(() => document.querySelector('h1').innerText);43 console.log(h1);44 await browser.close();45})();
Using AI Code Generation
1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch();4 const page = await browser.newPage();5 const title = await page.title();6 console.log(title);7 await browser.close();8})();9const puppeteer = require('puppeteer');10(async () => {11 const browser = await puppeteer.launch();12 const page = await browser.newPage();13 const title = await page.title();14 console.log(title);15 await browser.close();16})();17const puppeteer = require('puppeteer');18(async () => {19 const browser = await puppeteer.launch();20 const page = await browser.newPage();21 const title = await page.title();22 console.log(title);23 await browser.close();24})();25const puppeteer = require('puppeteer');26(async () => {27 const browser = await puppeteer.launch();28 const page = await browser.newPage();29 const title = await page.title();30 console.log(title);31 await browser.close();32})();33const puppeteer = require('puppeteer');34(async () => {35 const browser = await puppeteer.launch();36 const page = await browser.newPage();37 const title = await page.title();38 console.log(title);39 await browser.close();40})();41const puppeteer = require('puppeteer');42(async () => {43 const browser = await puppeteer.launch();44 const page = await browser.newPage();45 const title = await page.title();46 console.log(title);47 await browser.close();48})();
Using AI Code Generation
1const puppeteer = require('puppeteer');2const fs = require('fs');3(async () => {4 const browser = await puppeteer.launch({5 });6 const page = await browser.newPage();7 const url = await page.url();8 console.log(url);9 await browser.close();10})();11const puppeteer = require('puppeteer');12const fs = require('fs');13(async () => {14 const browser = await puppeteer.launch({15 });16 const page = await browser.newPage();17 const url = await page.url();18 console.log(url);19 await browser.close();20})();21const puppeteer = require('puppeteer');22const fs = require('fs');23(async () => {24 const browser = await puppeteer.launch({25 });26 const page = await browser.newPage();27 const url = await page.url();28 console.log(url);29 await browser.close();30})();31const puppeteer = require('puppeteer');32const fs = require('fs');33(async () => {34 const browser = await puppeteer.launch({35 });36 const page = await browser.newPage();37 const url = await page.url();38 console.log(url);39 await browser.close();40})();41const puppeteer = require('puppeteer');42const fs = require('fs');43(async () => {44 const browser = await puppeteer.launch({45 });46 const page = await browser.newPage();47 const url = await page.url();48 console.log(url);49 await browser.close();50})();51const puppeteer = require('puppeteer');52const fs = require('fs');53(async () => {
Using AI Code Generation
1const puppeteer = require('puppeteer');2const fs = require("fs");3(async () => {4 const browser = await puppeteer.launch({headless: false});5 const page = await browser.newPage();6 await page.screenshot({path: 'google.png'});7 await browser.close();8})();9const puppeteer = require('puppeteer');10const fs = require("fs");11(async () => {12 const browser = await puppeteer.launch({headless: false});13 const page = await browser.newPage();14 await page.screenshot({path: 'google.png'});15 await page.subjectName((err, subjectName) => {16 if (err) {17 console.log(err);18 } else {19 console.log(subjectName);20 }21 });22 await browser.close();23})();24const puppeteer = require('puppeteer');25const fs = require("fs");26(async () => {27 const browser = await puppeteer.launch({headless: false});28 const page = await browser.newPage();29 await page.screenshot({path: 'google.png'});30 await page.issuerName((err, issuerName) => {31 if (err) {32 console.log(err);33 } else {34 console.log(issuerName);35 }36 });
Using AI Code Generation
1const puppeteer = require('puppeteer');2const subjectName = require('subjectName');3(async () => {4 const browser = await puppeteer.launch();5 const page = await browser.newPage();6 await page.screenshot({path: 'google.png'});7 await browser.close();8})();9const puppeteer = require('puppeteer');10const subjectName = require('subjectName');11(async () => {12 const browser = await puppeteer.launch();13 const page = await browser.newPage();14 await page.screenshot({path: 'google.png'});15 await browser.close();16})();17#### subjectName()18const puppeteer = require('puppeteer');19const subjectName = require('subjectName');20(async () => {21 const browser = await puppeteer.launch();22 const page = await browser.newPage();23 const subject = await subjectName(page);24 console.log(subject);25 await page.screenshot({path: 'google.png'});26 await browser.close();27})();
Using AI Code Generation
1const puppeteer = require('puppeteer');2const { PuppeteerSubject } = require('./index');3(async () => {4 const browser = await puppeteer.launch();5 const page = await browser.newPage();6 const element = await page.$('.gsfi');7 const subject = PuppeteerSubject.fromElement(element);8 console.log(subject.name);9 await browser.close();10})();11const puppeteer = require('puppeteer');12const { PuppeteerSubject } = require('./index');13(async () => {14 const browser = await puppeteer.launch();15 const page = await browser.newPage();16 const element = await page.$('.gsfi');17 const subject = PuppeteerSubject.fromElement(element);18 console.log(subject.value);19 await browser.close();20})();21const puppeteer = require('puppeteer');22const { PuppeteerSubject } = require('./index');23(async () => {24 const browser = await puppeteer.launch();25 const page = await browser.newPage();26 const element = await page.$('.gsfi');27 const subject = PuppeteerSubject.fromElement(element);28 console.log(subject.text);29 await browser.close();30})();31const puppeteer = require('puppeteer');32const { PuppeteerSubject } = require('./index');33(async () => {34 const browser = await puppeteer.launch();35 const page = await browser.newPage();36 const element = await page.$('.gsfi');37 const subject = PuppeteerSubject.fromElement(element);38 console.log(subject.html);39 await browser.close();40})();41#### `subject.attribute(attributeName)`
Using AI Code Generation
1const puppeteer = require('puppeteer');2const config = require('./config');3async function run() {4 const browser = await puppeteer.launch({5 });6 const page = await browser.newPage();7 await page.waitForSelector('input[name="q"]');8 await page.type('input[name="q"]', 'Puppeteer');9 await page.keyboard.press('Enter');10 await page.waitForSelector('div[class="yuRUbf"] a');11 await page.click('div[class="yuRUbf"] a');12 await page.waitForSelector('input[name="q"]');13 await page.type('input[name="q"]', 'Puppeteer');14 await page.keyboard.press('Enter');15 await page.waitForSelector('div[class="yuRUbf"] a');16 await page.click('div[class="yuRUbf"] a');17 await page.waitForSelector('input[name="q"]');18 await page.type('input[name="q"]', 'Puppeteer');19 await page.keyboard.press('Enter');20 await page.waitForSelector('div[class="yuRUbf"] a');21 await page.click('div[class="yuRUbf"] a');22 await page.waitForSelector('input[name="q"]');23 await page.type('input[name="q"]', 'Puppeteer');24 await page.keyboard.press('Enter');25 await page.waitForSelector('div[class="yuRUbf"] a');26 await page.click('div[class="yuRUbf"] a');27 await page.waitForSelector('input[name="q"]');28 await page.type('input[name="q"]', 'Puppeteer');29 await page.keyboard.press('Enter');30 await page.waitForSelector('div[class="yuRUbf"] a');31 await page.click('div[class="yuRUbf"] a');32 await page.waitForSelector('input[name="q"]');33 await page.type('input[name="q"]', 'Puppeteer');34 await page.keyboard.press('Enter');35 await page.waitForSelector('div[class="yuRUbf"] a');36 await page.click('div[class="yuRUbf"] a');37 await page.waitForSelector('input[name="q"]');38 await page.type('input[name="q"]', 'Puppeteer');
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!