From fe0dfee47595240517e18a419f95df02932b930e Mon Sep 17 00:00:00 2001 From: kholoudfann <141060@ppu.edu.ps> Date: Tue, 25 Feb 2020 16:09:46 +0200 Subject: [PATCH 1/3] create bulid sql #15 --- database/config/build.sql | 125 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) diff --git a/database/config/build.sql b/database/config/build.sql index e69de29..b2cfa4a 100644 --- a/database/config/build.sql +++ b/database/config/build.sql @@ -0,0 +1,125 @@ +BEGIN; + +DROP TABLE IF EXISTS students, teachers, grades, courses; + + +CREATE TABLE IF NOT EXISTS courses( + course_id SERIAL PRIMARY KEY, + course_title TEXT NOT NULL + +); + +INSERT INTO courses (course_id, course_title) VALUES(1,'Physics'); +INSERT INTO courses (course_id, course_title) VALUES(2,'Maths'); +INSERT INTO courses (course_id, course_title) VALUES(3,'Chemistry'); +INSERT INTO courses (course_id, course_title) VALUES(4,'Arabic'); +INSERT INTO courses (course_id, course_title) VALUES(5,'Biology'); +INSERT INTO courses (course_id, course_title) VALUES(6,'coding'); +INSERT INTO courses (course_id, course_title) VALUES(7,'English'); + +CREATE TABLE IF NOT EXISTS students( + student_id SERIAL PRIMARY KEY, + student_name TEXT NOT NULL , + student_birth INTEGER , + student_sex TEXT NOT NULL, + student_address TEXT , + student_EMAIL VARCHAR(320), + student_img VARCHAR(250) NoT NULL + +); + +INSERT INTO students (student_id , student_name, student_birth, student_sex, student_address, student_EMAIL,student_img) VALUES (1,'Tasnin' , 8/8/1996, 'Female', 'Bethlehem' ,'tasninbhiri1996@gmail.com','https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.forbes.com%2Fsites%2Fangelauyeung%2F2019%2F10%2F24%2Fjeff-bezos-is-no-longer-the-richest-person-in-the-world%2F&psig=AOvVaw0aqN38lJLcC_x4z05J8o3B&ust=1582725738852000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCPjl3f3u7OcCFQAAAAAdAAAAABAU'); +INSERT INTO students (student_id, student_name, student_birth, student_sex, student_address, student_EMAIL,student_img) VALUES (2,'Matt' , 25/5/1995, 'Male', 'Bethlehem' ,'Matt1996@gmail.com','https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.pexels.com%2Fsearch%2Fperson%2F&psig=AOvVaw0aqN38lJLcC_x4z05J8o3B&ust=1582725738852000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCPjl3f3u7OcCFQAAAAAdAAAAABAD'); +INSERT INTO students (student_id, student_name, student_birth, student_sex, student_address, student_EMAIL,student_img) VALUES (3,'karmel' , 4/9/1996, 'Female', 'Bethlehem' ,'Karmel1996@gmail.com','https://www.google.com/url?sa=i&url=https%3A%2F%2Fengineering.unl.edu%2Fkayla-person%2F&psig=AOvVaw0aqN38lJLcC_x4z05J8o3B&ust=1582725738852000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCPjl3f3u7OcCFQAAAAAdAAAAABAb'); +INSERT INTO students (student_id, student_name, student_birth, student_sex, student_address, student_EMAIL,student_img) VALUES (4,'Harry' , 17/11/1996, 'Male', 'Bethlehem' ,'Harry1996@gmail.com','https://www.google.com/url?sa=i&url=https%3A%2F%2Fp-upload.facebook.com%2Fnasdaily%2Fphotos%2F%3Fref%3Dpage_internal&psig=AOvVaw0aqN38lJLcC_x4z05J8o3B&ust=1582725738852000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCPjl3f3u7OcCFQAAAAAdAAAAABAO'); + + +CREATE TABLE IF NOT EXISTS relation( +relation_id SERIAL PRIMARY KEY, +course_id INT , +FOREIGN KEY course_id REFERENCES courses (course_id) +student_id INT, +FOREIGN KEY student_id REFERENCES students (student_id), + +); + +INSERT INTO relation( course_id , student_id) VALUES (1,1); +INSERT INTO relation( course_id , student_id) VALUES (2,1); +INSERT INTO relation( course_id , student_id) VALUES (3,1); +INSERT INTO relation( course_id , student_id) VALUES (4,1); +INSERT INTO relation( course_id , student_id) VALUES (5,1); +INSERT INTO relation( course_id , student_id) VALUES (6,1); +INSERT INTO relation( course_id , student_id) VALUES (7,1); +INSERT INTO relation( course_id , student_id) VALUES (1,2); +INSERT INTO relation( course_id , student_id) VALUES (2,2); +INSERT INTO relation( course_id , student_id) VALUES (3,2); +INSERT INTO relation( course_id , student_id) VALUES (4,2); +INSERT INTO relation( course_id , student_id) VALUES (5,2); +INSERT INTO relation( course_id , student_id) VALUES (6,2); +INSERT INTO relation( course_id , student_id) VALUES (7,2); +INSERT INTO relation( course_id , student_id) VALUES (1,3); +INSERT INTO relation( course_id , student_id) VALUES (2,3); +INSERT INTO relation( course_id , student_id) VALUES (3,3); +INSERT INTO relation( course_id , student_id) VALUES (4,3); +INSERT INTO relation( course_id , student_id) VALUES (5,3); +INSERT INTO relation( course_id , student_id) VALUES (6,3); +INSERT INTO relation( course_id , student_id) VALUES (7,3); +INSERT INTO relation( course_id , student_id) VALUES (1,4); +INSERT INTO relation( course_id , student_id) VALUES (2,4); +INSERT INTO relation( course_id , student_id) VALUES (3,4); +INSERT INTO relation( course_id , student_id) VALUES (4,4); +INSERT INTO relation( course_id , student_id) VALUES (5,4); +INSERT INTO relation( course_id , student_id) VALUES (6,4); +INSERT INTO relation( course_id , student_id) VALUES (7,4); + + +CREATE TABLE IF NOT EXISTS grades( + grade_id SERIAL PRIMARY KEY, + grade_mark VARCHAR(50) , + course_id INT , + FOREIGN KEY course_id REFERENCES courses (course_id) , + student_id INT, + FOREIGN KEY student_id REFERENCES students (student_id) +); + +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(84,1 ,1 ); +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(90, 2 ,1 ); +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(94,3 ,1 ); +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(88,4,1 ); +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(70,5 ,1 ); +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(57,6 ,1 ); +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(50,7,1 ); +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(77,1 ,2); +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(70,2 ,2); +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(87,3 ,2); +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(88,4,2); +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(99,5 ,2); +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(60,6 ,2); +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(90,7,2); +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(91,1 ,3 ); +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(80,2 ,3 ); +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(98,3 ,3 ); +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(94,4,3 ); +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(99,5 ,3 ); +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(91,6 ,3 ); +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(90,7,3); +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(64,1 ,4); +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(83,2 ,4); +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(57,3 ,4); +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(50,4,4); +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(90,5 ,4); +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(70,6 ,4); +INSERT INTO grades( grade_mark , course_id , student_id) VALUES(88,7,4); + + + + + +CREATE TABLE IF NOT EXISTS teachers( + teacher_id SERIAL PRIMARY KEY, + teacher_address TEXT , + teacher_phone INTEGER + +); + +COMMIT; From 2856eb864e8f2e243abe8ea6365dd97c847b6115 Mon Sep 17 00:00:00 2001 From: karmelyoei Date: Tue, 25 Feb 2020 16:30:24 +0200 Subject: [PATCH 2/3] Bulding the Grades Page with HTML and CSS #17 --- public/grades.html | 31 ++++++++++++++++++++++++++++++- public/style.css | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/public/grades.html b/public/grades.html index 97e79ba..68d9292 100644 --- a/public/grades.html +++ b/public/grades.html @@ -8,6 +8,11 @@ href="https://fonts.googleapis.com/css?family=Anton&display=swap" rel="stylesheet" /> + + Student Managment System @@ -15,7 +20,31 @@ school picture

Student Managment System

-
+ +
+ + +
+ +
+ + + + + + + + + +
Course + Grades +
+ 90 + 80
+
+ diff --git a/public/style.css b/public/style.css index 6bd56f8..0cb19b2 100644 --- a/public/style.css +++ b/public/style.css @@ -40,3 +40,47 @@ margin-top: 36px; box-shadow: 30px 10px 10px 10px #aaaaaa; } +.searchForm { + width: 100%; + height: 60px; + display: flex; + align-items: center; + margin-left: 56px; + padding-bottom: 5px; + padding-top: 10px; +} + +.searchForm input { + height: 25px; + border: 1px solid grey; + width: 46vw; + background: #f1f1f1; +} +.searchForm button { + width: 76px; + height: 26px; + background-color: #4e9cc9; + color: beige; + font-size: 3vw; +} + +.gradesTable { + margin-left: 51px; + padding-top: 20px; +} +.gradesTable_std td, +.gradesTable_std th { + border: 1px solid #ddd; + padding: 21px; + font-size: 25px; + text-align: center; +} + +.gradesTable_std th { + padding-top: 12px; + padding-bottom: 12px; + text-align: left; + background-color: #4e9cc9; + color: white; + font-size: 25px; +} From 4b7c2ad2cd8354174c00abee45c307c149770cb2 Mon Sep 17 00:00:00 2001 From: tasneembhiri <141059@ppu.edu.ps> Date: Wed, 26 Feb 2020 08:52:30 +0200 Subject: [PATCH 3/3] intilaize database #19 --- database/config/build.js | 18 ++++++++++++++++++ database/config/connection.js | 19 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/database/config/build.js b/database/config/build.js index e69de29..c24a4f8 100644 --- a/database/config/build.js +++ b/database/config/build.js @@ -0,0 +1,18 @@ +const fs = require("fs"); +const path = require("path"); + +const dbConnection = require("./connection.js"); + + +const dbBuild = () => { + const sqlPath = readFileSync (join(__dirname, "build.sql")).toString(); +return dbConnection.query(sql,( err,res)=>{ + if(err) throw new Error('error build.js'); + else console.log('build sucsess'); + +}); +}; + + + +module.exports = {dbBuild}; \ No newline at end of file diff --git a/database/config/connection.js b/database/config/connection.js index e69de29..159dbb2 100644 --- a/database/config/connection.js +++ b/database/config/connection.js @@ -0,0 +1,19 @@ +require("env2")("./config.env"); +const { Pool } = require("pg"); +const url = ''; + +let connectionString = process.env.DB_URL; + +if (process.env.NODE_ENV === "test") { + connectionString = process.env.TEST_DB_URL; +} +if (!connectionString) { + throw new Error("please set a DB_URL env variable"); + +} +const options = { + connectionString: url, + sll: true +}; + +module.exports = new Pool(options); \ No newline at end of file