Skip to content

Commit

Permalink
allotment working great, other fixes
Browse files Browse the repository at this point in the history
allotment working, registered students view, undo allotment option added
  • Loading branch information
Rishabh04-02 committed Jun 27, 2018
1 parent 850b0ce commit a4b31ad
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 24 deletions.
74 changes: 71 additions & 3 deletions api-dbconnect.php
Original file line number Diff line number Diff line change
Expand Up @@ -1961,7 +1961,7 @@ public static function departmentsname($name) {
$name = "Unknown Department";
break;
}
echo $name;
//echo $name;
return $name;
}

Expand All @@ -1982,6 +1982,8 @@ public static function createbackup() {

//allotting electives
public static function startallotment() {

echo "Allotment in Progress, Please don't refresh/close page.<br>This might take few minutes.<br>";
//selects the total no. of students in the table
$pdo = Database::connect();
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
Expand Down Expand Up @@ -2025,7 +2027,7 @@ public static function startallotment() {
Database::disconnect();

//no. of available seats
$seats_available = $total_seats - $alloted_seats;
$seats_available = $total_seats - $alloted_seats;

//if seat available then allot priority
if ($seats_available != 0) {
Expand Down Expand Up @@ -2062,14 +2064,80 @@ public static function startallotment() {
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "CALL delete_specific_priority(?)";
$q = $pdo->prepare($sql);
$q->execute($rollno);
$q->execute(array($rollno));
Database::disconnect();
}
}

return 1;
}

//electives allotment result
public static function Allotmentresult() {

$pdo = Database::connect();
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "SELECT rollno,subj_code FROM students_allotted WHERE 1";
$q = $pdo->prepare($sql);
$q->execute();

while($data = $q->fetch(PDO::FETCH_ASSOC)) {
echo '<tr><td>';
echo $data['rollno'];
echo '</td><td>';
echo $data['subj_code'];
echo "</td></tr>";
}
Database::disconnect();

if ($data['rollno'] != NULL) {
return 1;
}
else return 0;
}

//undo allotment
public static function UndoAllotment() {

$pdo = Database::connect();
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "CALL undo_allotment()";
$q = $pdo->prepare($sql);
$q->execute();
$sql = "CALL clear_priorities()";
$q = $pdo->prepare($sql);
$q->execute();
$sql = "CALL clear_students_allotted()";
$q = $pdo->prepare($sql);
$q->execute();
$sql = "CALL resave_priorities()";
$q = $pdo->prepare($sql);
$q->execute();
Database::disconnect();

return 1;
}

public static function RegisteredStudents() {

$pdo = Database::connect();
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "SELECT rollno, name, branch FROM students WHERE 1";
$q = $pdo->prepare($sql);
$q->execute();

while($data = $q->fetch(PDO::FETCH_ASSOC)) {
echo '<tr><td>';
echo $data['rollno'];
echo '</td><td class="mdl-data-table__cell--non-numeric">';
echo $data['name'];
echo '</td><td class="mdl-data-table__cell--non-numeric">';
echo Database::departmentsname($data['branch']);
echo "</td></tr>";
}
Database::disconnect();
}

//generating the tokens (random strings)
public static function generateRandomString($length = 10) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
Expand Down
19 changes: 17 additions & 2 deletions views/admin/admin_alloted.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<div class="mdl-card__actions mdl-card--border"></div>

<div class="table-responsive">
<button class="mdl-button mdl-js-button mdl-button--raised mdl-button--accent mdl-js-ripple-effect">Print Allotment Result</button><br><br>
<table id="result" class="mdl-data-table mdl-js-data-table">
<thead>
<tr>
Expand All @@ -29,9 +28,25 @@
</tr>
</thead>
<tbody>
<?php Database::Allotmentresult(); ?>
<?php $result = Database::Allotmentresult();

if ($result!=1) {
echo "No result found for :";
}
else {
?>
<button id="thiss" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect">Print Allotment Result</button><br><br>
<?php
}
?>
</tbody>
</table>

<form class="update" action="" method="post">
<button name="undo" type="submit" value="true" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--colored">Undo Allotment</button>
</form>
<br>Note (for debugging) - This will clear the priorities table and will unset value to allotment in student profile and will resave priorities from backup table.

</div>
<script>
function printData() {
Expand Down
23 changes: 23 additions & 0 deletions views/admin/admin_dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,29 @@ function r(f){ /in/.test(document.readyState)?setTimeout('r('+f+')',9):f()}
<?php
}
}

//catching the markread form values
if(isset($_POST['undo'])) {

Database::UndoAllotment();
?>
<!-- Snackbar starts -->
<div id="snackbar" class="mdl-js-snackbar mdl-snackbar">
<div class="mdl-snackbar__text"></div>
<button class="mdl-snackbar__action" type="button"></button>
</div>

<script>
r(function(){
var snackbarContainer = document.querySelector('#snackbar');
var data = { message: 'Allotments Undo Successful.',timeout: 4000};
snackbarContainer.MaterialSnackbar.showSnackbar(data);
});
function r(f){ /in/.test(document.readyState)?setTimeout('r('+f+')',9):f()}
</script>
<!-- Snackbar ends -->
<?php
}
?>
<body>
<!-- Always shows a header, even in smaller screens. -->
Expand Down
3 changes: 2 additions & 1 deletion views/admin/admin_profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
<!-- The hidden div -->
<div id="Hideit" style="display: none;">
<br><p>Once you are ready for allotment (All departments have registered and all students have filled their priorities), just start the allotment by clicking on the button below.</p>
<br><p><b>Note - Allotment once started can't be undone.</b><br>But you can create a backup of the priorities filled by students.</p><br>
When allotment is started, Please don't refresh/close page.<br>This might take few minutes.<br>
<br><p><b>Note - Allotment once started can be undone.</b><br>Also It is recommended to create a backup of the priorities filled by students. Using the button below.</p><br>
<form class="update" action="" method="post">
<button name="backup" type="submit" value="true" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--colored">Create priorities backup</button>
</form>
Expand Down
39 changes: 22 additions & 17 deletions views/admin/admin_registered.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,28 @@
<div class="page-content">
<!-- Your content goes here -->

<div class="mdl-grid">
<div class="mdl-cell mdl-cell--12-col">


<div class="mdl-card__title">
<h2 class="mdl-card__title-text">View Registered students</h2>
</div>
<div class="mdl-card__supporting-text">
Registered students from various departments will appear here
<h2 class="mdl-card__title-text">Registered students</h2>
</div>
<div class="mdl-card__actions mdl-card--border">
<?php
for ($i=1; $i < 5; $i++) {

?>
<a class="mdl-button mdl-button--raised mdl-js-button mdl-js-ripple-effect">
Department <?php echo $i; ?>
</a>
<?php
}
?>
<br><br>On clicking the button the registered students of the particular department will be shown.
</div>
<div class="table-responsive">
<table id="result" class="mdl-data-table mdl-js-data-table">
<thead>
<tr>
<th class="mdl-data-table__cell--non-numeric">Roll no.</th>
<th class="mdl-data-table__cell--non-numeric">Name of Student</th>
<th class="mdl-data-table__cell--non-numeric">Department of Student</th>
</tr>
</thead>
<tbody>
<?php $result = Database::RegisteredStudents(); ?>


</tbody>
</table>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion views/design/js/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ $(document).ready(function(){

//print allotment result
$(document).ready(function(){
$("button").click(function(){
$("#thiss").click(function(){
printData();
});
});

0 comments on commit a4b31ad

Please sign in to comment.