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

Trainer and Trainee (complete) module added #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Empty file added .gitignore
Empty file.
3 changes: 0 additions & 3 deletions .idea/dictionaries/shafaqat.xml

This file was deleted.

9 changes: 0 additions & 9 deletions .idea/inspectionProfiles/profiles_settings.xml

This file was deleted.

29 changes: 0 additions & 29 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

25 changes: 0 additions & 25 deletions .idea/trainingportal.iml

This file was deleted.

1,013 changes: 0 additions & 1,013 deletions .idea/workspace.xml

This file was deleted.

40 changes: 40 additions & 0 deletions static/css/add_trainer_modal_style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* The Modal (background) */
.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}

/* Modal Content/Box */
.modal-content {
background-color: #fefefe;
margin: 3% auto; /* 15% from the top and centered */
padding: 10px;
border: 1px solid #888;
width: 50%; /* Could be more or less, depending on screen size */
overflow: auto;
height: 85%;

}

/* The Close Button */
.close {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
}

.close:hover,
.close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
49 changes: 49 additions & 0 deletions static/js/trainingportal/add_task.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* Created by shafaqat on 2/21/18.
*/

$(document).ready(function () {

$("#submitBtn").click(function (event) {
$('#validate_text').html('');
var title = $("#id_title").val();
var description = $("#id_description").val();

if (title == null || title == '' ||
description == null || description == '') {
$('#validate_text').html('Required fields are empty.<br/>');
event.preventDefault();
}
});

var frm = $('#taskForm');
frm.submit(function (event) {
event.preventDefault();
$('#validate_text').html('');
var data = new FormData(frm.get(0));
$.ajax({
type: frm.attr('method'),
url: frm.attr('action'),
data: frm.serialize(),
success: function (data) {
data = JSON.parse(data);
if (data['failure_message']) {
$('#validate_text').html('Required fields are empty.<br/>');
}
else {
frm.find("input, textarea").val("");
var modal = document.getElementById('myModal');
modal.style.display = "none";
alert('Task added successfully');
window.location.href = '/tasks/?trainer_id=' + data['trainer_id']
+ '&training_id=' + data['training_id']
+ '&trainee_id=' + data['trainee_id']
}
},
error: function (data) {
$('#validate_text').html('Required fields are empty.<br/>');
}
});
return false;
});
});
28 changes: 28 additions & 0 deletions static/js/trainingportal/add_training_modal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Created by shafaqat on 2/15/18.
*/
// Get the modal
var modal = document.getElementById('myModal');

// Get the button that opens the modal
var btn = document.getElementById("trainingBtn");

// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];

// When the user clicks on the button, open the modal
btn.onclick = function () {
modal.style.display = "block";
}

// When the user clicks on <span> (x), close the modal
span.onclick = function () {
modal.style.display = "none";
}

// When the user clicks anywhere outside of the modal, close it
window.onclick = function (event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
92 changes: 92 additions & 0 deletions static/js/trainingportal/assignment_form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/**
* Created by shafaqat on 2/22/18.
*/

$(document).ready(function () {

$("#submitBtn").click(function (event) {
$('#validate_text').html('');
var title = $("#id_title").val();
var description = $("#id_description").val();
var due_date = $("#id_due_date").val();

if (title == null || title == '' ||
description == null || description == '' ||
due_date == null || due_date == '') {
$('#validate_text').html('Required fields are empty.<br/>');
event.preventDefault();
}
});

var frm = $('#assignmentForm');
frm.submit(function (event) {
event.preventDefault();
$('#validate_text').html('');
var data = new FormData(frm.get(0));
$.ajax({
type: frm.attr('method'),
url: frm.attr('action'),
processData: false,
contentType: false,
data: data,
success: function (data) {
data = JSON.parse(data);
if (data['failure_message']) {
$('#validate_text').html('Required fields are empty.<br/>');
}
else {
frm.find("input, textarea").val("");
var modal = document.getElementById('myModal');
modal.style.display = "none";
alert('Assignment added successfully');
window.location.href = '/assignments/?task_id=' + data['task_id']
}
},
error: function (data) {
$('#validate_text').html('Required fields are empty.<br/>');
}
});
return false;
});

$("#evaluateBtn").click(function (event) {
$('#validate_text').html('');
var score = $("#id_score").val();
var remarks = $("#id_remarks").val();

if (score == null || score == '' ||
remarks == null || remarks == '') {
$('#validate_text').html('Required fields are empty.<br/>');
event.preventDefault();
}
});

var evaluateForm = $('#evaluateAssignmentForm');
evaluateForm.submit(function (event) {
event.preventDefault();
$('#validate_text').html('');
var data = new FormData(evaluateForm.get(0));
$.ajax({
type: evaluateForm.attr('method'),
url: evaluateForm.attr('action'),
processData: false,
contentType: false,
data: data,
success: function (data) {
data = JSON.parse(data);
if (data['failure_message']) {
$('#validate_text').html('Required fields are empty.<br/>');
}
else {
evaluateForm.find("input, textarea").val("");
alert('Assignment Evaluated successfully');
window.location.href = data['redirect_path']
}
},
error: function (data) {
$('#validate_text').html('Required fields are empty.<br/>');
}
});
return false;
});
});
16 changes: 9 additions & 7 deletions static/js/trainingportal/loginformvalidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
$(document).ready(function () {

$('#error_msg').hide();
$("#submitBtn").click(function(event) {
var username = $("#id_username").val();
var password = $("#id_password").val();
Expand All @@ -12,10 +13,6 @@ $(document).ready(function () {
$('#validate_text').html('Username or password is empty<br/>');
event.preventDefault();
}
else
{

}
});

var frm = $('#loginForm');
Expand All @@ -25,11 +22,16 @@ $(document).ready(function () {
url: frm.attr('action'),
data: frm.serialize(),
success: function (data) {
alert(data);
$('html').html(data);
data = JSON.parse(data);
if (data['failure_message'])
{$('#error_msg').show(1000);}
else
{
window.location.href = data['redirect_path'];
}
},
error: function(data) {
alert('Request failed.');
$('#error_msg').show(1000);
}
});
return false;
Expand Down
35 changes: 35 additions & 0 deletions static/js/trainingportal/submit_assignment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Created by shafaqat on 2/22/18.
*/

$(document).ready(function () {

var submitAssignmentForm = $('#submitAssignmentForm');
submitAssignmentForm.submit(function (event) {
event.preventDefault();
var data = new FormData(submitAssignmentForm.get(0));
$.ajax({
type: submitAssignmentForm.attr('method'),
url: submitAssignmentForm.attr('action'),
processData: false,
contentType: false,
data: data,
success: function (data) {
data = JSON.parse(data);
if (data['failure_message']) {
alert('File not uploaded.');
}
else {
submitAssignmentForm.find("input, textarea").val("");
alert('Assignment Submitted successfully');
window.location.href = data['redirect_path']
}
},
error: function (data) {
alert('Required field(s) are empty');
}
});
return false;
});
});

Loading