Skip to content

Instantly share code, notes, and snippets.

@gchristian
Last active October 28, 2020 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gchristian/1c2d4aaa366ba13a90e99efbe80dd115 to your computer and use it in GitHub Desktop.
Save gchristian/1c2d4aaa366ba13a90e99efbe80dd115 to your computer and use it in GitHub Desktop.
classattendance.cohort.content.footer.txt
<script>
$j("#attendance-table tr:first").append("<th>Cohort</th>");
$j(".studentrow").each(function() {
$j(this).append("<td id=\"cohort_"+ $j(this).attr('id').replace("ccid_","")+"\"></td>");
});
default_attend = [~[tlist_sql;select cc.id, U_STU64.COHORT
from cc
join students on cc.studentid = students.id
left outer join U_STU64 on students.dcid = U_STU64.studentsdcid
where sectionid = ~(gpv.sectionid)]{"ccid" : "~(ccid)", "code" : "~(U_STU64.COHORT)"},[/tlist_sql]];
default_attend.forEach(displayCohort);
function displayCohort(value, index, array) {
var day = $j("[name*='att_periodpopup'] :selected").html().split(" ")[0];
if (day == "Mon" || day == "Tue"){
if (value["code"] == "A"){
$j("#cohort_"+value["ccid"]).html("&#127979; In School ("+value["code"]+")");
}
else if (value["code"] == "B" || value["code"] == "R"){
$j("#cohort_"+value["ccid"]).html("&#128187; Remote ("+value["code"]+")");
}
}
else if (day == "Thu" || day == "Fri"){
if (value["code"] == "A" || value["code"] == "R"){
$j("#cohort_"+value["ccid"]).html("&#128187; Remote ("+value["code"]+")");
}
else if (value["code"] == "B"){
$j("#cohort_"+value["ccid"]).html("&#127979; In School ("+value["code"]+")");
}
}
else if (day == "Wed" && (value["code"] == "A" || value["code"] == "B" || value["code"] == "R")){
$j("#cohort_"+value["ccid"]).html("&#128187; Remote ("+value["code"]+")");
}
}
$j("#id_btn_show_multiple_sections").after(" <a id=\"fillCohort\" class=\"button\" href=\"\" style=\"margin: 0px;\">Fill Cohort Default</a>");
$j("#fillCohort").after(" <a id=\"allremote\" class=\"button\" href=\"\" style=\"margin: 0px;\">Fill All Remote</a>");
$j('#fillCohort').click( function(e) {e.preventDefault(); default_attend.forEach(fillAttendance); return false; } );
$j('#allremote').click( function(e) {e.preventDefault(); $j(".studentrow").children().find(":text").val('PR'); return false; } );
var dayItems = $j("[name*='att_periodpopup'] :selected").split(" ");
function fillAttendance(value, index, array) {
var day = $j("[name*='att_periodpopup'] :selected").html().split(" ")[0];
if (day == "Mon" || day == "Tue"){
if (value["code"] == "A"){
$j("#ccid_"+value["ccid"]).children().find(":text").val('P');
}
else if (value["code"] == "B" || value["code"] == "R"){
$j("#ccid_"+value["ccid"]).children().find(":text").val('PR');
}
}
else if (day == "Thu" || day == "Fri"){
if (value["code"] == "A" || value["code"] == "R"){
$j("#ccid_"+value["ccid"]).children().find(":text").val('PR');
}
else if (value["code"] == "B"){
$j("#ccid_"+value["ccid"]).children().find(":text").val('P');
}
}
else if (day == "Wed" && (value["code"] == "A" || value["code"] == "B" || value["code"] == "R")){
$j("#ccid_"+value["ccid"]).children().find(":text").val('PR');
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment