Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mmrichi committed Nov 20, 2019
2 parents 17daa81 + 16a5a6f commit a2d86ad
Show file tree
Hide file tree
Showing 17 changed files with 163 additions and 96 deletions.
File renamed without changes.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ Digital Student Record project. Softeng 2 Course @ PoliTo

### 29/10/2019 - Project presentation
[Electronic Student Record Management System](https://softeng.polito.it/courses/SE2/ESRMS.pdf)
### 19/11/2019 - Demo 1
- 5 Stories completed out of 6 committed
- 40 StoryPoints out of 43
- [Retrospective](https://docs.google.com/presentation/d/1rePNnXa-uKxZ5X8VvkPPjaG4cFXc6gZvnldOUE48JQI/edit?usp=sharing)

## Use cases collection
[Use cases](https://github.com/sordinho/Group-J---Digital-Student-Record/tree/master/UseCases)
## Trello Board :memo: :pushpin:
[Board](https://trello.com/b/R01iRsVf)

## Demo :computer:
[You can see a demo by clicking here](http://softeng2.my.to)
## The Team :busts_in_silhouette:
- [Vittorio Di Leo](https://github.com/VittorioDiLeo)
- [Riccardo Mamone](https://github.com/mmrichi)
Expand Down
2 changes: 1 addition & 1 deletion classes/cpage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __destruct(){
public function render(){

//La funzione render crea il contenuto della pagina in html
echo "<div class='container' id='content'>";
echo "<div class='container min_container' id='content'>";
$mtitle = "<center><h2>{$this->title}</h2></center>";
echo $mtitle;
echo $this->content;
Expand Down
5 changes: 3 additions & 2 deletions classes/officer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public function get_Students_By_Class_ID($classID){
return $IDs;
}
public function retrive_classless_students(){
$conn = $this->connectMySQL();
/*$conn = $this->connectMySQL();
$res= $conn->query("SELECT ID,Name,Surname
FROM Student
Expand All @@ -233,7 +233,8 @@ public function retrive_classless_students(){
array_push($students,$row);
}
$res->close();
return $students;
return $students;*/
return $this->get_Students_By_Class_ID(-1);
}
/**
* @param $studentID
Expand Down
7 changes: 3 additions & 4 deletions classes/sparent.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ public function retrieve_and_register_childs() {
$childs = array();
$children_info = array();
$conn = $this->connectMySql();
print($_SESSION['parentID']);
$stmt = $conn->prepare("SELECT S.ID AS StudentID, P.ID AS ParentID, S.Name, S.Surname
FROM Parent P,Student S
WHERE P.ID = ?
WHERE P.UserID = ?
AND P.StudentID = S.ID;");
//$stmt->bind_param('d',$this->parent_id);
$stmt->bind_param('d', $_SESSION['parentID']);//use getter
//todo: use getter
$stmt->bind_param('d', $_SESSION['id']);//use getter
$stmt->execute();
$res = $stmt->get_result();
/*while($row = $res->fetch_row()){
Expand Down
53 changes: 41 additions & 12 deletions classes/teacher.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ public function modify_lecture_topic($newDescription, $topicRecordID) {
$lecture_date = strtotime($row[0]);
if (!$this->by_the_end_of_the_week($actual_date, $lecture_date))
return false;
if ($row[1] != $this->teacherID)
if ($row[1] != $_SESSION['teacherID'])
return false;
$res->close();
$stmt = $conn->prepare("UPDATE TopicRecord SET Description=? WHERE ID=$topicRecordID");
$stmt = $conn->prepare("UPDATE TopicRecord SET Description=? WHERE ID=?;");
if (!$stmt)
return false;
$stmt->bind_param("s", $newDescription);
$stmt->bind_param("si", $newDescription,$topicRecordID);
return $stmt->execute();
}
}
Expand All @@ -112,20 +112,29 @@ public function modify_lecture_topic($newDescription, $topicRecordID) {
* return empty if successful
* array of array otherwise
* */
public function get_topics() {
public function get_topics($selectedClass=0) {
$topics = array();
// TODO create TopicTeacherClass table logic scheme TopicTeacherClass(TopicID, TeacherID, SpecificClassID)
// Write correct query, use AS to define alias with following names (TopicID, TopicName, TopicDescription)
$conn = $this->connectMySQL();
$stmt = $conn->prepare("SELECT ttc.SpecificClassID as ClassID, tc.ID as TopicID, tc.Name as TopicName, tc.Description as TopicDescription FROM TopicTeacherClass as ttc, Topic as tc, Teacher as t WHERE ttc.TeacherID=t.ID and tc.ID=ttc.TopicID and t.ID=? and ttc.SpecificClassID=?");
// todo manage class selection
$selectedClass = 3;
$teacherID = $this->get_teacher_ID();
$stmt->bind_param('ii', $teacherID, $selectedClass);

// todo manage class selection
if($selectedClass){
$stmt = $conn->prepare("SELECT ttc.SpecificClassID as ClassID, tc.ID as TopicID, tc.Name as TopicName, tc.Description as TopicDescription FROM TopicTeacherClass as ttc, Topic as tc, Teacher as t WHERE ttc.TeacherID=t.ID and tc.ID=ttc.TopicID and t.ID=? and ttc.SpecificClassID=?");
$stmt->bind_param('ii', $teacherID, $selectedClass);

} else{
$stmt = $conn->prepare("SELECT tc.ID as TopicID, tc.Name as TopicName, tc.Description as TopicDescription FROM TopicTeacherClass as ttc, Topic as tc, Teacher as t WHERE ttc.TeacherID=t.ID and tc.ID=ttc.TopicID and t.ID=? ");
$stmt->bind_param('i', $teacherID);
}
$stmt->execute();
$res = $stmt->get_result();
if ($res->num_rows <= 0) {
return false;
$dummy["TopicID"] = 0;
$dummy["TopicName"] = "No topic";
$dummy["TopicDescription"] = "No topic for this teacher";
array_push($topics, $dummy);
} else {
$row = $res->fetch_assoc();
array_push($topics, $row);
Expand All @@ -135,7 +144,7 @@ public function get_topics() {

// Return the teacher ID from teacher table
public function get_teacher_ID() {
return isset($_SESSION['teacherID']) ? $_SESSION['id'] : -1;
return isset($_SESSION['teacherID']) ? $_SESSION['teacherID'] : -1;
}

/*
Expand Down Expand Up @@ -167,11 +176,11 @@ public function get_topics_record() {
$topicRecords = array();
$conn = $this->connectMySQL();
$stmt = $conn->prepare("SELECT TopicRecord.Timestamp as TimeStamps,
TopicRecord.Description as TopicDescription, Topic.Name as TopicName
TopicRecord.Description as TopicDescription, Topic.Name as TopicName, TopicRecord.ID as RecordID
FROM TopicRecord, Topic
WHERE TopicRecord.TopicID=Topic.ID AND TopicRecord.TeacherID=?");
// $teacherID = $this->get_teacher_ID();
$teacherID = 1;
$teacherID = $_SESSION['teacherID'];
$stmt->bind_param('i', $teacherID);
$stmt->execute();
$res = $stmt->get_result();
Expand All @@ -184,4 +193,24 @@ public function get_topics_record() {
}
return $topicRecords;
}
public function get_lecture_by_id($lectureID){
$conn = $this->connectMySQL();
$stmt = $conn->prepare("SELECT TopicRecord.Timestamp as TimeStamp,
TopicRecord.Description as TopicDescription,
TopicRecord.ID as TopicRecordID,
Topic.Name as TopicName
FROM TopicRecord , Topic
WHERE TopicRecord.TopicID=Topic.ID and TopicRecord.ID=?");

$stmt->bind_param('i', $lectureID);
$stmt->execute();
$res = $stmt->get_result();
if ($res->num_rows <= 0) {
return false;
} else {
$lecture_info = array();
$lecture_info=$res->fetch_assoc();
return $lecture_info;
}
}
}
4 changes: 2 additions & 2 deletions classes/user.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ function user_login($post_data) {
}
$queryID->store_result();
$queryID->bind_result($specificID);
// In case of success there should be just 1 user for a given (username is also a primary key for its table)
if ($queryID->num_rows != 1) {
// In case of success there should be just 1 *USER* for a given (username is also a primary key for its table)
if ($queryID->num_rows < 1) {
return false;
}
$queryID->fetch();
Expand Down
5 changes: 4 additions & 1 deletion css/style.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
body {
background-color: rgb(225, 235, 240);
padding-top: 5rem;
}
.starter-template {
Expand All @@ -13,7 +14,9 @@ body {
-ms-user-select: none;
user-select: none;
}

.min_container{
min-height: 510px;
}
@media (min-width: 768px) {
.bd-placeholder-img-lg {
font-size: 3.5rem;
Expand Down
19 changes: 11 additions & 8 deletions dbsetup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Creato il: Nov 19, 2019 alle 10:25
-- Creato il: Nov 19, 2019 alle 17:19
-- Versione del server: 5.7.27-0ubuntu0.16.04.1
-- Versione PHP: 7.2.24-1+ubuntu16.04.1+deb.sury.org+1

Expand Down Expand Up @@ -84,7 +84,9 @@ CREATE TABLE `Parent` (

INSERT INTO `Parent` (`ID`, `StudentID`, `UserID`) VALUES
(2, 2, 2),
(5, 2, 1);
(5, 2, 1),
(7, 3, 2),
(8, 3, 44);

-- --------------------------------------------------------

Expand Down Expand Up @@ -136,7 +138,7 @@ INSERT INTO `Student` (`ID`, `Name`, `Surname`, `AverageLastSchool`, `CF`, `Spec
(6, 'Riccardo', 'Mamone', 10, 'rf5', 1),
(8, 'Antonio', 'Santoro', 10, 'cf6', 1),
(9, 'Michael', 'Bing', 7, 'cf7', -1),
(10, 'Francesco', 'Riba', 8, 'Cf8', -1);
(11, 'Mario', 'Rossi', 7, 'Fc11', -1);

-- --------------------------------------------------------

Expand Down Expand Up @@ -220,7 +222,7 @@ INSERT INTO `Topic` (`ID`, `Name`, `Description`) VALUES
CREATE TABLE `TopicRecord` (
`ID` int(11) NOT NULL,
`TeacherID` int(11) NOT NULL,
`Timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`Timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`Description` varchar(512) NOT NULL,
`TopicID` int(11) NOT NULL,
`SpecificClassID` int(11) NOT NULL
Expand Down Expand Up @@ -287,7 +289,8 @@ INSERT INTO `User` (`ID`, `Name`, `Surname`, `Email`, `Password`, `UserGroup`) V
(8, 'Bartolo', 'Montrucchio', '[email protected]', '$2y$12$ZOB4hLXsBQmRWwU7u0hP4e3GUbyOEg7Gll1ZJMEDd4d4sWiqDE8by', 'teacher'),
(9, 'Tony', 'Lioy', '[email protected]', '$2y$12$ZOB4hLXsBQmRWwU7u0hP4e3GUbyOEg7Gll1ZJMEDd4d4sWiqDE8by', 'teacher'),
(10, 'John', 'Price', '[email protected]', '$2y$12$ZOB4hLXsBQmRWwU7u0hP4e3GUbyOEg7Gll1ZJMEDd4d4sWiqDE8by', 'officer'),
(11, 'Paul', 'MacMillan', '[email protected]', '$2y$12$ZOB4hLXsBQmRWwU7u0hP4e3GUbyOEg7Gll1ZJMEDd4d4sWiqDE8by', 'officer');
(11, 'Paul', 'MacMillan', '[email protected]', '$2y$12$ZOB4hLXsBQmRWwU7u0hP4e3GUbyOEg7Gll1ZJMEDd4d4sWiqDE8by', 'officer'),
(44, 'name', 'surname', '[email protected]', '$2y$12$30A4FAueTEgqlQBS8tFsbeRcqpB6MNvkEfSk5odHdJHoEJkF7Z4h2', 'parent');

--
-- Indici per le tabelle scaricate
Expand Down Expand Up @@ -390,7 +393,7 @@ ALTER TABLE `Officer`
-- AUTO_INCREMENT per la tabella `Parent`
--
ALTER TABLE `Parent`
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT per la tabella `SpecificClass`
--
Expand All @@ -400,7 +403,7 @@ ALTER TABLE `SpecificClass`
-- AUTO_INCREMENT per la tabella `Student`
--
ALTER TABLE `Student`
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;
--
-- AUTO_INCREMENT per la tabella `Teacher`
--
Expand Down Expand Up @@ -430,7 +433,7 @@ ALTER TABLE `TopicTeacherClass`
-- AUTO_INCREMENT per la tabella `User`
--
ALTER TABLE `User`
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=42;
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=45;
--
-- Limiti per le tabelle scaricate
--
Expand Down
6 changes: 4 additions & 2 deletions footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

?>
<!-- Footer -->
<footer class="page-footer font-small blue fixed-bottom">
<footer class="page-footer font-small blue ">
<!-- Copyright notice! -->

<div class="footer-copyright text-center py-3">© 2019 TeamJ Copyright
<h4>Online at <a href="#">http://softeng2.my.to</a></h4>
</div>
</footer>
<!-- Footer -->

Expand Down
3 changes: 2 additions & 1 deletion header.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@
<i class="fas fa-bars" id="sidebarToggle"></i>
</a>
<a class="text-white text-decoration-none p-2" id="title" href="#">
<img src="' . PLATFORM_PATH . '/media/logopoli2.jpg" alt="logopoli" style="height: 100%; width: 100%; object-fit: contain"/>
<img src="' . PLATFORM_PATH . '/media/logopoli2.jpg" alt="logopoli" style="width: 100%; object-fit: contain"/>
</a>
</div>
</li>
'.
Expand Down
24 changes: 13 additions & 11 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@
$site->setPage($page);


$page->setContent($content);
$site->render();
$content = "";

if(!isset($_SESSION['id']) && isset($_POST['username'])) {
echo '<div class="d-flex justify-content-center"><div class="spinner-grow text-warning" style="width: 10rem; height: 10rem;" role="status">
<span class="sr-only">Loading...</span>
</div></div>
$content .= '<div class="article-clean">
<div class="d-flex justify-content-center">
<div class="spinner-grow text-warning" style="width: 10rem; height: 10rem;" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
<div class="text-center"><button type="button" class="btn btn-outline-warning">Loading...</button></div>';
<div class="text-center"><button type="button" class="btn btn-outline-warning">Loading...</button></div>
</div>';
$usr = new user;

$post_data["username"] = $_POST['username'];
Expand All @@ -35,7 +38,6 @@
$url = "/usergroup/parent/index.php";
// Register children infos
$sparent = new sparent();
print($sparent->get_parent_ID());
$sparent->retrieve_and_register_childs();
break;
case "officer":
Expand All @@ -45,19 +47,19 @@
//$url = "/TODO.php";
break;
}
$html = "<meta http-equiv='refresh' content='1; url=" . PLATFORM_PATH . $url ."' />";
die($html);
$content .= "<meta http-equiv='refresh' content='1; url=" . PLATFORM_PATH . $url ."' />";
} else {
$usr->get_error(11);
}
} else {
$usr = new user();
if($usr->is_logged()){
// TODO reset refresh to 1 sec. Set to 5 for debug print
$html = "<meta http-equiv='refresh' content='5; url=" . PLATFORM_PATH . $usr->get_base_url() . "' />";
die($html);
$content .= "<meta http-equiv='refresh' content='5; url=" . PLATFORM_PATH . $usr->get_base_url() . "' />";
}
}
$page->setContent($content);
$site->render();


?>
11 changes: 9 additions & 2 deletions usergroup/officer/classCompositionModification.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function addStudent(elem){
<tr>
<td>".$student['Surname']."</td>
<td>".$student['Name']."</td>
<td><button class='btn btn-primary' value='Rimuovi Dalla Classe' id=".$student['ID'] ." type='button' onclick='removeStudent(id);'> Rimuovi </button></td>
<td><button class='btn btn-primary' value='Rimuovi Dalla Classe' id=".$student['ID'] ." type='button' onclick='removeStudent(id);'> Remove </button></td>
</tr>";
}
$content.="
Expand All @@ -80,6 +80,13 @@ function addStudent(elem){

// Print now the second table (to add student to class)
$ustudents = $officer->retrive_classless_students();
$content.="
<div class=\"card\">
<h5 class=\"card-header info-color white-text text-center py-4\">
<strong>Students without class</strong>
</h5>
<div class=\"card-body\">
";
$content.="
<form>
<table class=\"table table - sm\">
Expand All @@ -98,7 +105,7 @@ function addStudent(elem){
<tr>
<td>".$student['Surname']."</td>
<td>".$student['Name']."</td>
<td><button class='btn btn-primary' value='Aggiungi alla classe' id=".$student['ID'] ." type='button' onclick='addStudent(id);'> Aggiungi </button></td>
<td><button class='btn btn-primary' value='Aggiungi alla classe' id=".$student['ID'] ." type='button' onclick='addStudent(id);'> Add </button></td>
</tr>";
}
$content.="
Expand Down
Loading

0 comments on commit a2d86ad

Please sign in to comment.