diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000..174a5cca3 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "github.copilot" + ] +} \ No newline at end of file diff --git a/FETCH_HEAD b/FETCH_HEAD new file mode 100644 index 000000000..e69de29bb diff --git a/app/controllers/admin_routes/termManagement.py b/app/controllers/admin_routes/termManagement.py index 69c6373d4..76638f2ae 100644 --- a/app/controllers/admin_routes/termManagement.py +++ b/app/controllers/admin_routes/termManagement.py @@ -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) diff --git a/app/controllers/main_routes/studentLaborEvaluation.py b/app/controllers/main_routes/studentLaborEvaluation.py index 1ca83af1b..01cee2de2 100644 --- a/app/controllers/main_routes/studentLaborEvaluation.py +++ b/app/controllers/main_routes/studentLaborEvaluation.py @@ -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'}) @@ -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 @@ -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, @@ -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("/") @@ -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 ) diff --git a/app/logic/download.py b/app/logic/download.py index b9532446d..ecb517263 100644 --- a/app/logic/download.py +++ b/app/logic/download.py @@ -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 @@ -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 [] diff --git a/app/models/studentLaborEvaluation.py b/app/models/studentLaborEvaluation.py index aa3021fb3..e0746abf3 100644 --- a/app/models/studentLaborEvaluation.py +++ b/app/models/studentLaborEvaluation.py @@ -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) diff --git a/app/models/term.py b/app/models/term.py index bc4c7420e..1fe500211 100755 --- a/app/models/term.py +++ b/app/models/term.py @@ -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 diff --git a/app/static/js/ckeditor/.DS_Store b/app/static/js/ckeditor/.DS_Store new file mode 100644 index 000000000..5008ddfcf Binary files /dev/null and b/app/static/js/ckeditor/.DS_Store differ diff --git a/app/static/js/ckeditor/samples/toolbarconfigurator/lib/codemirror/.DS_Store b/app/static/js/ckeditor/samples/toolbarconfigurator/lib/codemirror/.DS_Store new file mode 100644 index 000000000..5008ddfcf Binary files /dev/null and b/app/static/js/ckeditor/samples/toolbarconfigurator/lib/codemirror/.DS_Store differ diff --git a/app/static/js/studentLaborEvaluation.js b/app/static/js/studentLaborEvaluation.js index 455eab37f..f955cbb71 100644 --- a/app/static/js/studentLaborEvaluation.js +++ b/app/static/js/studentLaborEvaluation.js @@ -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); - } -}) diff --git a/app/static/js/termManagement.js b/app/static/js/termManagement.js index 2d4d2c469..238a9a1fe 100755 --- a/app/static/js/termManagement.js +++ b/app/static/js/termManagement.js @@ -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('
- {% if existing_final_evaluation %} - {{existing_final_evaluation.attendance_score}}/20 + {% if existing_evaluation %} + {{existing_evaluation.attendance_score}}/20 {% else %} {{form.attendance.data}} {% endif %} @@ -99,13 +88,9 @@
{{existing_final_evaluation.attendance_comment}}
+ {{form.attendanceComments}} + {% if existing_evaluation %} +{{existing_evaluation.attendance_comment}}
{% endif %}- {% if existing_final_evaluation %} - {{existing_final_evaluation.accountability_score}}/10 + {% if existing_evaluation %} + {{existing_evaluation.accountability_score}}/10 {% else %} {{form.accountability.data}} {% endif %} @@ -155,13 +138,9 @@
{{existing_final_evaluation.accountability_comment}}
+ {{form.accountabilityComments}} + {% if existing_evaluation %} +{{existing_evaluation.accountability_comment}}
{% endif %}- {% if existing_final_evaluation %} - {{existing_final_evaluation.teamwork_score}}/10 + {% if existing_evaluation %} + {{existing_evaluation.teamwork_score}}/10 {% else %} {{form.teamwork.data}} {% endif %} @@ -210,13 +187,9 @@
{{existing_final_evaluation.teamwork_comment}}
+ {{form.teamworkComments}} + {% if existing_evaluation %} +{{existing_evaluation.teamwork_comment}}
{% endif %}- {% if existing_final_evaluation %} - {{existing_final_evaluation.initiative_score}}/10 + {% if existing_evaluation %} + {{existing_evaluation.initiative_score}}/10 {% else %} {{form.initiative.data}} {% endif %} @@ -264,13 +235,9 @@
{{existing_final_evaluation.initiative_comment}}
+ {{form.initiativeComments}} + {% if existing_evaluation %} +{{existing_evaluation.initiative_comment}}
{% endif %}- {% if existing_final_evaluation %} - {{existing_final_evaluation.respect_score}}/10 + {% if existing_evaluation %} + {{existing_evaluation.respect_score}}/10 {% else %} {{form.respect.data}} {% endif %} @@ -318,13 +283,9 @@
{{existing_final_evaluation.respect_comment}}
+ {{form.respectComments}} + {% if existing_evaluation %} +{{existing_evaluation.respect_comment}}
{% endif %}- {% if existing_final_evaluation %} - {{existing_final_evaluation.learning_score}}/20 + {% if existing_evaluation %} + {{existing_evaluation.learning_score}}/20 {% else %} {{form.learning.data}} {% endif %} @@ -373,13 +332,9 @@
{{existing_final_evaluation.learning_comment}}
+ {{form.learningComments}} + {% if existing_evaluation %} +{{existing_evaluation.learning_comment}}
{% endif %}- {% if existing_final_evaluation %} - {{existing_final_evaluation.jobSpecific_score}}/20 + {% if existing_evaluation %} + {{existing_evaluation.jobSpecific_score}}/20 {% else %} {{form.jobSpecific.data}} {% endif %} @@ -426,13 +379,9 @@
{{existing_final_evaluation.jobSpecific_comment}}
+ {{form.jobSpecificComments}} + {% if existing_evaluation %} +{{existing_evaluation.jobSpecific_comment}}
{% endif %}{{existing_final_evaluation.transcript_comment}}
- {% else %} - {{form.transcriptComments}} + {{form.transcriptComments}} + {% if existing_evaluation %} +{{existing_evaluation.transcript_comment}}
{% endif %}