Skip to content
Open
Show file tree
Hide file tree
Changes from 8 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
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"github.copilot"
]
}
Empty file added FETCH_HEAD
Empty file.
19 changes: 0 additions & 19 deletions app/controllers/admin_routes/termManagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,22 +115,3 @@ def termStatusCheck():
except Exception as e:
print(e)
return jsonify({"Success": False})

@admin.route('/termManagement/manageEval', methods=['POST'])
def manageEval():
try:
rsp = eval(request.data.decode("utf-8")) # This fixes byte indices must be integers or slices error
if rsp:
term = Term.get(rsp['evalBtn'])
if rsp["isMidyear"]:
term.isMidyearEvaluationOpen = not term.isMidyearEvaluationOpen
term.isFinalEvaluationOpen = False
else:
term.isFinalEvaluationOpen = not term.isFinalEvaluationOpen
term.isMidyearEvaluationOpen = False
term.save()
flasherInfo = {'termChanged': term.termName}
return jsonify(flasherInfo)
except Exception as e:
print(e)
return jsonify({}, 500)
86 changes: 17 additions & 69 deletions app/controllers/main_routes/studentLaborEvaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,24 @@ class SLEForm(FlaskForm):

attendance = IntegerRangeField("Attendance", default = 15, render_kw={'class':'form-control slider'})
attendanceComments = TextAreaField("Comments about attendance:", [Length(max=65535)], render_kw={'class':'form-control'})
attendanceCommentsMidyear = TextAreaField("Attendance comments from Midyear :", render_kw={'class':'form-control', 'readonly': True})

accountability = IntegerRangeField("Accountability", default = 7, render_kw={'class':'form-control slider'})
accountabilityComments = TextAreaField("Comments about accountability:", [Length(max=65535)], render_kw={'class':'form-control'})
accountabilityCommentsMidyear = TextAreaField("Attendance comments from Midyear :", render_kw={'class':'form-control', 'readonly': True})

teamwork = IntegerRangeField("Teamwork", default = 7, render_kw={'class':'form-control slider'})
teamworkComments = TextAreaField("Comments about teamwork:", [Length(max=65535)], render_kw={'class':'form-control'})
teamworkCommentsMidyear = TextAreaField("Attendance comments from Midyear :", render_kw={'class':'form-control', 'readonly': True})

initiative = IntegerRangeField("Initiative", default = 7, render_kw={'class':'form-control slider'})
initiativeComments = TextAreaField("Comments about initiative:", [Length(max=65535)], render_kw={'class':'form-control'})
initiativeCommentsMidyear = TextAreaField("Attendance comments from Midyear :", render_kw={'class':'form-control', 'readonly': True})

respect = IntegerRangeField("Respect", default = 7, render_kw={'class':'form-control slider'})
respectComments = TextAreaField("Comments about respect:", [Length(max=65535)], render_kw={'class':'form-control'})
respectCommentsMidyear = TextAreaField("Attendance comments from Midyear :", render_kw={'class':'form-control', 'readonly': True})

learning = IntegerRangeField("Learning", default = 15, render_kw={'class':'form-control slider'})
learningComments = TextAreaField("Comments about learning:", [Length(max=65535)], render_kw={'class':'form-control'})
learningCommentsMidyear = TextAreaField("Attendance comments from Midyear :", render_kw={'class':'form-control', 'readonly': True})

jobSpecific = IntegerRangeField("Job Specific", default = 15, render_kw={'class':'form-control slider'})
jobSpecificComments = TextAreaField("Comments about this job, specifically:", [Length(max=65535)], render_kw={'class':'form-control'})
jobSpecificCommentsMidyear = TextAreaField("Attendance comments from Midyear :", render_kw={'class':'form-control', 'readonly': True})

transcriptComments = TextAreaField("Labor Transcript comments:", [Length(max=65535)], render_kw={'class':'form-control'})

Expand Down Expand Up @@ -73,30 +66,15 @@ def sle(statusKey):
return render_template('errors/403.html'), 403

sleForm = SLEForm()
existing_final_evaluation = StudentLaborEvaluation.get_or_none(formHistoryID = laborHistoryForm, is_midyear_evaluation = False, is_submitted = True)
existing_midyear_evaluation = StudentLaborEvaluation.get_or_none(formHistoryID = laborHistoryForm, is_midyear_evaluation = True, is_submitted = True)
existing_evaluation = (StudentLaborEvaluation.select()
.where(StudentLaborEvaluation.formHistoryID == laborHistoryForm, StudentLaborEvaluation.is_submitted == True)
.order_by(StudentLaborEvaluation.date_submitted.desc(nulls="LAST"), StudentLaborEvaluation.ID.desc())
.first())
existing_saved_evaluation = StudentLaborEvaluation.select().where(StudentLaborEvaluation.formHistoryID == laborHistoryForm, StudentLaborEvaluation.is_submitted == False)
if existing_saved_evaluation:
existing_saved_evaluation = existing_saved_evaluation[-1]

if not request.method == "POST": # Doesn't override submitted POST data!
if existing_midyear_evaluation: # TODO Or there's savedforlater data
sleForm.attendance.data = existing_midyear_evaluation.attendance_score
sleForm.accountability.data = existing_midyear_evaluation.accountability_score
sleForm.teamwork.data = existing_midyear_evaluation.teamwork_score
sleForm.initiative.data = existing_midyear_evaluation.initiative_score
sleForm.respect.data = existing_midyear_evaluation.respect_score
sleForm.learning.data = existing_midyear_evaluation.learning_score
sleForm.jobSpecific.data = existing_midyear_evaluation.jobSpecific_score

sleForm.attendanceCommentsMidyear.data = "Midyear comments: \n" + existing_midyear_evaluation.attendance_comment
sleForm.accountabilityCommentsMidyear.data = "Midyear comments: \n" + existing_midyear_evaluation.accountability_comment
sleForm.teamworkCommentsMidyear.data = "Midyear comments: \n" + existing_midyear_evaluation.teamwork_comment
sleForm.initiativeCommentsMidyear.data = "Midyear comments: \n" + existing_midyear_evaluation.initiative_comment
sleForm.respectCommentsMidyear.data = "Midyear comments: \n" + existing_midyear_evaluation.respect_comment
sleForm.learningCommentsMidyear.data = "Midyear comments: \n" + existing_midyear_evaluation.learning_comment
sleForm.jobSpecificCommentsMidyear.data = "Midyear comments: \n" + existing_midyear_evaluation.jobSpecific_comment

if existing_saved_evaluation:
sleForm.attendance.data = existing_saved_evaluation.attendance_score
sleForm.accountability.data = existing_saved_evaluation.accountability_score
Expand All @@ -115,48 +93,23 @@ def sle(statusKey):
sleForm.jobSpecificComments.data = existing_saved_evaluation.jobSpecific_comment
sleForm.transcriptComments.data = existing_saved_evaluation.transcript_comment


if not (laborHistoryForm.formID.termCode.isFinalEvaluationOpen or laborHistoryForm.formID.termCode.isMidyearEvaluationOpen) and not existing_final_evaluation and not existing_midyear_evaluation:
return render_template('errors/403.html'), 403

overall_score = 73 # The default value
if existing_final_evaluation:
overall_score = (existing_final_evaluation.attendance_score +
existing_final_evaluation.accountability_score +
existing_final_evaluation.teamwork_score +
existing_final_evaluation.initiative_score +
existing_final_evaluation.respect_score +
existing_final_evaluation.learning_score +
existing_final_evaluation.jobSpecific_score)
elif existing_midyear_evaluation:
overall_score = (existing_midyear_evaluation.attendance_score +
existing_midyear_evaluation.accountability_score +
existing_midyear_evaluation.teamwork_score +
existing_midyear_evaluation.initiative_score +
existing_midyear_evaluation.respect_score +
existing_midyear_evaluation.learning_score +
existing_midyear_evaluation.jobSpecific_score)
if existing_evaluation:
overall_score = (existing_evaluation.attendance_score +
existing_evaluation.accountability_score +
existing_evaluation.teamwork_score +
existing_evaluation.initiative_score +
existing_evaluation.respect_score +
existing_evaluation.learning_score +
existing_evaluation.jobSpecific_score)

if sleForm.validate_on_submit():
# Handling Booleanfields are tricky...
try:
submitAsFinal = True if request.form["submit_as_final"] else False
except BadRequestKeyError:
submitAsFinal = False

# First delete any temporarily saved data (is_submitted = False)
if not laborHistoryForm.formID.termCode.isMidyearEvaluationOpen: # Final eval
is_midyear_evaluation = False
elif submitAsFinal: # Midyear submitted as final
is_midyear_evaluation = False
else: # Midyear
is_midyear_evaluation = True
try:
sle = StudentLaborEvaluation.get(formHistoryID = laborHistoryForm, is_submitted = False, is_midyear_evaluation = is_midyear_evaluation)
sle = StudentLaborEvaluation.get(formHistoryID = laborHistoryForm, is_submitted = False)
sle.delete_instance()
except DoesNotExist:
pass
# Then, save the new record

studentLaborEvaluation = StudentLaborEvaluation.create(
formHistoryID = laborHistoryForm,
attendance_score = sleForm.attendance.data,
Expand All @@ -178,10 +131,7 @@ def sle(statusKey):
submitted_by = currentUser,
date_submitted = date.today()
)
if laborHistoryForm.formID.termCode.isMidyearEvaluationOpen and not submitAsFinal:
studentLaborEvaluation.is_midyear_evaluation = True
studentLaborEvaluation.save()
# Use first and last (so preferred name works)
msg = f"Thank you for submitting a labor evaluation for {laborHistoryForm.formID.studentSupervisee.FIRST_NAME} {laborHistoryForm.formID.studentSupervisee.LAST_NAME}!"
flash(msg, "success")
return redirect("/")
Expand All @@ -190,18 +140,16 @@ def sle(statusKey):
# Only approved evaluations get an SLE, so send them home.
return redirect("/")

if existing_final_evaluation and existing_final_evaluation.date_submitted:
submittedDate = existing_final_evaluation.date_submitted.strftime("%m-%d-%Y")
if existing_evaluation and existing_evaluation.date_submitted:
submittedDate = existing_evaluation.date_submitted.strftime("%m-%d-%Y")
else:
submittedDate = None

return render_template("main/studentLaborEvaluation.html",
form = sleForm,
laborHistoryForm = laborHistoryForm,
existing_final_evaluation = existing_final_evaluation,
existing_midyear_evaluation = existing_midyear_evaluation,
existing_evaluation = existing_evaluation,
date_submitted = submittedDate,
overall_score = overall_score,
isFinalEvaluationOpen = laborHistoryForm.formID.termCode.isFinalEvaluationOpen,
currentUser = currentUser
)
14 changes: 3 additions & 11 deletions app/logic/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, downloadName, requestedLSFs: ModelSelect, includeEvals = Fals
@staticmethod
def _validateAdditionalSpreadsheetFields(additionalFields):
for additionalField in additionalFields:
if additionalField not in {'overloads', 'finalEvaluations', 'midYearEvaluations', 'allEvaluations'}:
if additionalField not in {'overloads', 'allEvaluations'}:
raise ValueError(f'Invalid spreadsheet fields: {additionalField}')
return additionalFields

Expand Down Expand Up @@ -184,19 +184,11 @@ def addEvaluationData(self, formID):
Adds data for SLE
'''
multipleRows = []
if "finalEvaluations" in self.additionalSpreadsheetFields:
finalEvaluation = StudentLaborEvaluation.get_or_none(StudentLaborEvaluation.formHistoryID == formID, StudentLaborEvaluation.is_midyear_evaluation == 0, StudentLaborEvaluation.is_submitted == True)
if finalEvaluation:
multipleRows.append(self.insertEvaluationData(finalEvaluation, "Final"))
elif "midYearEvaluations" in self.additionalSpreadsheetFields:
midyearEvaluation = StudentLaborEvaluation.get_or_none(StudentLaborEvaluation.formHistoryID == formID, StudentLaborEvaluation.is_midyear_evaluation == 1, StudentLaborEvaluation.is_submitted == True)
if midyearEvaluation:
multipleRows.append(self.insertEvaluationData(midyearEvaluation, "Midyear"))
elif self.includeEvals == True:
if self.includeEvals == True:
anyEvaluation = StudentLaborEvaluation.select().where(StudentLaborEvaluation.formHistoryID == formID, StudentLaborEvaluation.is_submitted == True)
if anyEvaluation:
for evaluation in anyEvaluation:
multipleRows.append(self.insertEvaluationData(evaluation, "Midyear" if evaluation.is_midyear_evaluation else "Final"))
multipleRows.append(self.insertEvaluationData(evaluation, "Evaluation"))
else:
return []

Expand Down
1 change: 0 additions & 1 deletion app/models/studentLaborEvaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class StudentLaborEvaluation(baseModel):
jobSpecific_score = IntegerField(null=False)
jobSpecific_comment = TextField(null=False)
transcript_comment = TextField(null=True)
is_midyear_evaluation = BooleanField(default=False)
is_submitted = BooleanField(default=False)
submitted_by = CharField(null=False)
date_submitted = DateField(null=False)
Expand Down
2 changes: 0 additions & 2 deletions app/models/term.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ class Term(baseModel):
isBreak = BooleanField(default=False)
isSummer = BooleanField(default=False)
isAcademicYear = BooleanField(default=False)
isFinalEvaluationOpen = BooleanField(default=False)
isMidyearEvaluationOpen = BooleanField(default=False)


@staticmethod
Expand Down
Binary file added app/static/js/ckeditor/.DS_Store
Binary file not shown.
Binary file not shown.
9 changes: 0 additions & 9 deletions app/static/js/studentLaborEvaluation.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,3 @@ function update_sum() {
$("#finalSubmitButton").click(function() {
$("#isSubmitted").val("True");
});

$('#submit_as_final').change(function() {
if (this.checked) {
$("#transcriptComments").attr("disabled", false);
} else {
$("#transcriptComments").attr("disabled", true);
$("#transcriptComments").val(null);
}
})
42 changes: 1 addition & 41 deletions app/static/js/termManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,44 +125,4 @@ function termStatus(term) {
$("#flasher").delay(5000).fadeOut();
}
})
};

function toggleEval(term, isMidyear) {
if (isMidyear) {
var clickedBtn = $("#midyear_eval_btn_" + term);
var otherBtn = $("#eval_btn_" + term);
} else {
var clickedBtn = $("#eval_btn_" + term);
var otherBtn = $("#midyear_eval_btn_" + term);
}

$.ajax({
method: "POST",
url: "/termManagement/manageEval",
dataType: "json",
contentType: "application/json",
data: JSON.stringify({"evalBtn": term, "isMidyear": isMidyear}),
processData: false,
success: function(response) {
otherBtn.removeClass("btn-success").addClass("btn-danger").text("Closed");
if($(clickedBtn).hasClass("btn-success")) {
$(clickedBtn).removeClass("btn-success");
$(clickedBtn).addClass("btn-danger");
$(clickedBtn).text("Closed");
category = "danger";
state = "'Closed'.";
}
else {
$(clickedBtn).removeClass("btn-danger");
$(clickedBtn).addClass("btn-success");
$(clickedBtn).text("Open");
category = "success";
state = "'Open'.";
}
term = response['termChanged']
message = "The "+ (isMidyear ? "midyear ":"final ") +"evaluations for "+ term +' is set to '+ state
$("#flash_container").html('<div class="alert alert-'+ category +'" role="alert" id="flasher">' + message + '</div>');
$("#flasher").delay(5000).fadeOut();
}
});
}
};
38 changes: 1 addition & 37 deletions app/templates/admin/termManagement.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,6 @@ <h4 class="mb-0">
class="glyphicon glyphicon-bookmark"
tabindex="0">
</span>
</th>
<th>Evaluations <br />(Midyear | Final)
<span data-toggle="tooltip"
title="Toggle the midyear/final student labor evaluation (SLE) states."
data-placement="right"
class="glyphicon glyphicon-bookmark"
tabindex="0">
</span>
</th>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -166,33 +157,6 @@ <h4 class="mb-0">
onclick="termStatus({{term.termCode}})"
value="{{term.termState}}">{% if term.termState == True %} Open {% elif term.termState == False %} Closed {% endif %}
</button>
</td>
<td style="text-align:center">
<div class="btn-group" role="group" aria-label="button group for evaluations">
{% if (term.termCode|string)[-2:] == "00" %}
<button
id="midyear_eval_btn_{{term.termCode}}"
name="midyearEvalBtn"
style='width: 50%'
type="button"
class="btn btn-med {% if term.isMidyearEvaluationOpen == True %} btn-success {% elif term.isMidyearEvaluationOpen == False %} btn-danger {% endif %}"
onclick="toggleEval({{term.termCode}}, 1)"
value="{{term.isMidyearEvaluationOpen}}">{% if term.isMidyearEvaluationOpen == True %} Open {% elif term.isMidyearEvaluationOpen == False %} Closed {% endif %}
</button>
{% endif %}
{% if (term.termCode|string)[-2:] == "00" or (term.termCode|string)[-2:] == "13" %} {# AY and Summer only #}
<button
id="eval_btn_{{term.termCode}}"
name="evalBtn"
{% if (term.termCode|string)[-2:] == "00" %} style='width: 50%' {% else %} style='width: auto;' {% endif %}
type="button"
class="btn btn-med {% if term.isFinalEvaluationOpen == True %} btn-success {% elif term.isFinalEvaluationOpen == False %} btn-danger {% endif %}"
onclick="toggleEval({{term.termCode}}, 0)"
value="{{term.isFinalEvaluationOpen}}">{% if term.isFinalEvaluationOpen == True %} Open {% elif term.isFinalEvaluationOpen == False %} Closed {% endif %}
</button>
{% endif %}
</div>
</td>
</tr>
{% endfor %}
</tbody>
Expand All @@ -202,4 +166,4 @@ <h4 class="mb-0">
{% endfor %}
</div>
</div>
{% endblock %}
{% endblock %}
Loading