Skip to content

Commit

Permalink
more gui work and some work for #32
Browse files Browse the repository at this point in the history
  • Loading branch information
obcode committed Dec 5, 2017
1 parent 8bd7155 commit e23ab0b
Show file tree
Hide file tree
Showing 11 changed files with 280 additions and 36 deletions.
62 changes: 57 additions & 5 deletions elexams/elexams.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,33 @@ th {
}

td.exams {
height: 40px;
height: 50px;
}

td.times {
width: 20px;
}

.hardconstraints {
.HardConstraintBroken {
font-weight: bold;
color: red;
}

.SoftConstraintBroken {
font-weight: bold;
color: blue;
}

.Info {
font-weight: bold;
color: grey;
}

.lecturer {
font-weight: bold;
color: blue;
}

div#description {
padding: 4px;
user-select: text;
Expand Down Expand Up @@ -51,13 +66,21 @@ div#description {
}

div.inner {
padding: 2px;
top: 0px;
padding: 5px;
top: 5px;
overflow: hidden;
border: 1px solid white;
background-color: rgb(255, 255, 204);
vertical-align: top;
display: block;
}

div.examsBySameLecturer {
font-weight: bold;
color: blue;
border: 2px solid blue;
}

div.overlap {
padding: 2px;
top: 0px;
Expand All @@ -67,6 +90,25 @@ div.overlap {
background-color: rgb(237, 236, 107);
}

div.conflicts {
padding: 2px;
top: 0px;
overflow: hidden;
vertical-align: top;
display: block;
font-weight: bold;
background-color: rgb(200, 0, 0);
}

div.notPlannedByMe {
padding: 2px;
top: 0px;
overflow: hidden;
vertical-align: top;
display: block;
background-color: rgb(179, 179, 204);
}

div.innerUnscheduled {
padding: 2px;
top: 0px;
Expand Down Expand Up @@ -99,7 +141,7 @@ div.inner:hover {
}

div.div_select {
background-color: rgb(212, 81, 81) !important;
background-color: rgb(0, 200, 0) !important;
}


Expand All @@ -118,6 +160,16 @@ div.description {
min-width: 400px;
}

ul#conflictingAncodes,
li#conflictingAncodes {
padding-left: 1.4em;
}

ul#registeredGroups,
li#registeredGroups {
padding-left: 1.4em;
}

ul#groups,
li#groups {
padding-left: 1.4em;
Expand Down
59 changes: 55 additions & 4 deletions elexams/elexams.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,34 @@ function viewDetails (event, anCode) {
}
}
let groupsOutput = groupsToHTML(exam.groups)
let registeredGroupsOutput = registeredGroupsToHTML(exam.registeredGroups)
output += ` <h2 >${exam.name}</h1></br>
AnCode: ${exam.anCode}</br>
Rooms: </br>
Groups: ${groupsOutput}
Registered Groups: ${registeredGroupsOutput}
PlannedByMe: ${exam.plannedByMe}</br>
StudentsWithHandicaps: </br>
Lecturer: ${exam.lecturer.personShortName}</br>
Lecturer: <span class="lecturer">${exam.lecturer.personShortName}</span></br>
PersonFK: ${exam.lecturer.personFK}</br>
PersonIsLBA: ${exam.lecturer.personIsLBA}</br>
PersonIsLBA: <span class="lecturer">${exam.lecturer.personIsLBA}</span></br>
PersonID: ${exam.lecturer.personID}</br>
PersonEmail: ${exam.lecturer.personEmail}</br>
Duration: ${exam.duration}</br>
ReExam: ${exam.reExam} </br>
ExamType: ${exam.examType} </br>
Overlaps: <div id='overlaps'></div>`
Conflicting Ancodes:
<ul id='conflictingAncodes'>`
for (let i = 0; i < exam.conflictingAncodes.length; i++) {
let conflictingAncode = exam.conflictingAncodes[i]
output += `<li>${conflictingAncode}</li>`
}
output += `<ul>`
output += `<br>Overlaps: <div id='overlaps'></div>`
$('#description').html(output)
fetchOverlaps(anCode)
setConflicts(anCode, exam.conflictingAncodes)
fetchExamsBySameLecturer(anCode)
}).fail(function (jqXHR, textStatus, errorThrown) {
$('#error').append(`Error on viewDetails: `)
$('#error').append(jqXHR.responseText)
Expand All @@ -62,10 +73,14 @@ function toggleSelect (thisObj) {
thisObj.parents('table').find('div').removeClass('div_select')
thisObj.parents('div').find('div').removeClass('div_select')
thisObj.parents('div').find('div').removeClass('overlap')
thisObj.parents('div').find('div').removeClass('conflicts')
thisObj.parents('div').find('div').removeClass('examsBySameLecturer')
} else {
thisObj.parents('table').find('div').removeClass('div_select')
thisObj.parents('div').find('div').removeClass('div_select')
thisObj.parents('div').find('div').removeClass('overlap')
thisObj.parents('div').find('div').removeClass('conflicts')
thisObj.parents('div').find('div').removeClass('examsBySameLecturer')
thisObj.addClass('div_select')
}
}
Expand Down Expand Up @@ -101,6 +116,22 @@ function fetchOverlaps (anCode) {
})
}

function fetchExamsBySameLecturer (anCode) {
var request = $.ajax({
type: 'POST',
url: host + endpointExamsBySameLecturer,
data: JSON.stringify(anCode),
contentType: 'application/json',
dataType: 'json'
})
request.done(function (otherExams) {
for (let i in otherExams) {
let otherExam = otherExams[i]
$('#'.concat(otherExam.anCode)).addClass('examsBySameLecturer')
}
})
}

function selectOverlapExams (overlaps, anCode) {
for (var i = 0; i < overlaps.length; i++) {
let group = overlaps[i]
Expand All @@ -111,12 +142,31 @@ function selectOverlapExams (overlaps, anCode) {
}
}

function setConflicts (anCode, conflictingAncodes) {
for (var i in conflictingAncodes) {
let conflictingAncode = conflictingAncodes[i]
$('#'.concat(conflictingAncode)).addClass('conflicts')
}
}

function registeredGroupsToHTML (groups) {
let output = `<ul id='registeredGroups'>`
for (var i in groups) {
let group = groups[i]
output += `<li id='group'>
${group.registeredGroupDegree} (${group.registeredGroupStudents})
</li>`
}
output += `</ul>`
return output
}

function groupsToHTML (groups) {
let output = `
<ul id='groups'>
`
for (var i in groups) {
let group = groups[i];
let group = groups[i]
let groupDegree = group.groupDegree != null ? group.groupDegree + ` ` : ``
let groupSemester = group.groupSemester != null ? group.groupSemester + ` ` : ``
let groupSubgroup = group.groupSubgroup != null ? group.groupSubgroup + ` ` : ``
Expand Down Expand Up @@ -173,6 +223,7 @@ function dropExam (ev) {
} else if (ev.currentTarget.className === 'outerUnscheduled') {
document.getElementById(data).className = 'innerUnscheduled'
}
_fetchValidation()
}
}

Expand Down
12 changes: 10 additions & 2 deletions elexams/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
window.$ = window.jQuery = nodeRequire('./resources/jquery-3.2.1.min.js')
</script>
<script src="resources/jquery.tablesorter.min.js"></script>
<script src="elexams.js"></script>
<script src="renderer.js"></script>
<script src="elexams.js"></script>

</head>

Expand All @@ -45,8 +45,16 @@

<li class="tab">
<input type="radio" name="tabs" id="tab2" />
<label for="tab2">Prüfungsliste</label>
<label for="tab2">Validation</label>
<div id="tab-content2" class="content">
<div id="validation-full"></div>
</div>
</li>

<li class="tab">
<input type="radio" name="tabs" id="tab3" />
<label for="tab3">Prüfungsliste</label>
<div id="tab-content3" class="content">
<div id="plexams-api"></div>
</div>
</li>
Expand Down
65 changes: 56 additions & 9 deletions elexams/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,34 @@ const endpointSlotsPerDay = '/slotsPerDay'
const endpointAddExam = '/addExam'
const endpointOverlaps = '/overlaps'
const endpointUnscheduledExams = '/unscheduledExams'
const endpointNotPlannedByMeExams = '/notPlannedByMeExams'
const endpointValidation = '/validation'
const endpointExamsBySameLecturer = '/examsBySameLecturer'

let _fetchValidation = () => {
$.getJSON(host + endpointValidation, (validation) => {
let output = `<h1>${validation.result}</h1><ul>`
for (let i in validation.brokenConstraints) {
let constraint = validation.brokenConstraints[i]
if (constraint.tag === 'HardConstraintBroken') {
output += `<li><span class="hardconstraints"> ${constraint.contents}</span></li>`
output += `<li><span class="${constraint.tag}">
${constraint.contents}</span>
</li>`
}
}
output += `</ul>`
$('#validation').html(output)

output = `<h1>${validation.result}</h1><ul>`
for (let i in validation.brokenConstraints) {
let constraint = validation.brokenConstraints[i]
output += `<li><span class="${constraint.tag}">
${constraint.contents}</span>
</li>`
}
output += `</ul>`
$('#validation-full').html(output)

})
}

Expand Down Expand Up @@ -68,24 +83,43 @@ let _fetchExams = function () {
let _fetchUnscheduledExams = function () {
$.getJSON(host + endpointUnscheduledExams, function (uExams) {
let outputPlannedByMe = ``
let outputNotPlannedByMe = ``
for (var i in uExams) {
var exam = uExams[i]
var draggable = false
outputPlannedByMe +=
`<div id="${exam.anCode}" `
if (exam.plannedByMe) {
outputPlannedByMe +=
`<div id="${exam.anCode}" class="innerUnscheduled" ondrop="return false;"
draggable="true" ondragstart="dragExam(event)"
outputPlannedByMe += `class="innerUnscheduled" draggable="true"`
} else {
outputPlannedByMe += `class="innerUnscheduled notPlannedByMe" draggable="false"`
}
outputPlannedByMe += ` ondrop="return false;" ondragstart="dragExam(event)"
onclick="viewDetails(event, ${exam.anCode})"
>${exam.anCode}</br>${exam.name}</div>`
} else {
outputNotPlannedByMe +=
}
$('#unscheduled').html(outputPlannedByMe)
}).fail(function (jqXHR, textStatus, errorThrown) {
$('#error').append(`Error on endpoint \\unscheduledExams: `)
$('#error').append(jqXHR.responseText)
$('#error').append(`<br>`)
$('#error').css({
'border': '3px solid #e22d2d'
})
})
}

let _fetchNotPlannedByMeExams = function () {
$.getJSON(host + endpointNotPlannedByMeExams, function (uExams) {
let outputNotPlannedByMe = ``
for (var i in uExams) {
var exam = uExams[i]
var draggable = false

outputNotPlannedByMe +=
`<div id="${exam.anCode}" class="innerUnNotPbyMe" ondrop="return false;"
draggable="false" onclick="viewDetails(event, ${exam.anCode})"
>${exam.anCode}</br>${exam.name}</div>`
}
}
$('#unscheduled').html(outputPlannedByMe)
$('#notPlannedByMe').html(outputNotPlannedByMe)
}).fail(function (jqXHR, textStatus, errorThrown) {
$('#error').append(`Error on endpoint \\unscheduledExams: `)
Expand Down Expand Up @@ -216,6 +250,17 @@ let _fetchExamDays = function () {
})
}

function setNotPlannedByMe () {
$.getJSON(host + endpointNotPlannedByMeExams, function (exams) {
for (var i in exams) {
let ancode = exams[i].anCode
$('#'.concat(ancode)).addClass('notPlannedByMe')
}
})
}

setNotPlannedByMe()

// Convenience function for _fetchExams
let fetchExams = function () {
_fetchExams()
Expand All @@ -240,4 +285,6 @@ fetchExamDays()
// Start to fetch the unscheduled exams
fetchUnscheduledExams()

_fetchNotPlannedByMeExams()

_fetchValidation()
9 changes: 8 additions & 1 deletion plexams-core/src/Plexams/Export/Common.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Plexams.Export.Common
( unscheduledExamsSortedByRegistrations
, notPlannedByMeExams
) where

import Data.List (sortBy)
Expand All @@ -9,7 +10,13 @@ import Plexams.Types
unscheduledExamsSortedByRegistrations :: Plan -> [Exam]
unscheduledExamsSortedByRegistrations =
sortBy (\e1 e2 -> compare (registrations e2)
(registrations e1))
(registrations e1))
. filter plannedByMe
. M.elems
. unscheduledExams

notPlannedByMeExams :: Plan -> [Exam]
notPlannedByMeExams =
filter (not . plannedByMe)
. M.elems
. unscheduledExams
Loading

0 comments on commit e23ab0b

Please sign in to comment.