Skip to content

Commit

Permalink
Merge pull request #1214 from BCStudentSoftwareDevTeam/vungc-courses
Browse files Browse the repository at this point in the history
Changed faculty and course labels and made the course name to also show the course number
  • Loading branch information
BrianRamsay committed Jul 8, 2024
2 parents 88cfd8b + 944bb9f commit 68787b3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
18 changes: 17 additions & 1 deletion app/logic/serviceLearningCourses.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,28 @@ def getSLProposalInfoForUser(user: User) -> Dict[int, Dict[str, Any]]:

courseDict[course.id] = {"id":course.id,
"creator":f"{course.createdBy.firstName} {course.createdBy.lastName}",
"name":course.courseName if course.courseName else course.courseAbbreviation,
"name": course.courseName,
"abbr": course.courseAbbreviation,
"courseDisplayName": createCourseDisplayName(course.courseName, course.courseAbbreviation),
"faculty": faculty,
"term": course.term,
"status": course.status.status}
return courseDict

def createCourseDisplayName(name, abbreviation):
'''
This function combines course name and numbers with conditions
inputs: course name, course abbreviation
'''
if name and abbreviation:
return f"{abbreviation} - {name}"
elif not name and not abbreviation:
return ''
elif not name:
return abbreviation
elif not abbreviation:
return name

def saveCourseParticipantsToDatabase(cpPreview: Dict[str, Dict[str, Dict[str, List[Dict[str, Any]]]]]) -> None:
for term, terminfo in cpPreview.items():
termObj: Term = Term.get_or_none(description = term) or addPastTerm(term)
Expand Down
2 changes: 1 addition & 1 deletion app/templates/serviceLearning/slcManagement.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h1 class="text-center mb-2">{{user.firstName}} {{user.lastName}}'s SLC Proposal
<tbody>
{% for course in courseDict %}
<tr>
<td id="name-{{courseDict[course]['id']}}">{{courseDict[course]['name']}}</td>
<td id="name-{{ courseDict[course]['id'] }}">{{courseDict[course]['courseDisplayName']}}</td>
<td id="creator-{{courseDict[course]['id']}}">{{courseDict[course]['creator']}}</td>
<td id="faculty-{{courseDict[course]['id']}}">{{courseDict[course]['faculty']|join(", ")}}</td>
<td id="term-{{courseDict[course]['id']}}">{{courseDict[course]['term'].description}}</td>
Expand Down
20 changes: 20 additions & 0 deletions tests/code/test_serviceLearningCourses.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from app.logic.serviceLearningCourses import *


@pytest.mark.integration
def test_getServiceLearningCoursesData():
'''tests for the successful implementation of populating the proposal table'''
Expand All @@ -22,14 +23,18 @@ def test_getServiceLearningCoursesData():
assert "Submitted" == courseDict[2]['status']
assert 'Spring 2021' in courseDict[2]['term'].description
assert "Scott Heggen" == courseDict[2]['creator']
assert "SPN 104 - Spanish Help" == courseDict[2]['courseDisplayName']


courseDict = getSLProposalInfoForUser('heggens')
assert 3 in courseDict
assert 'Scott Heggen' in courseDict[3]['faculty']
assert not ['Brian Ramsay', 'Zach Neill'] == courseDict[3]['faculty']
assert "Approved" == courseDict[3]['status']
assert 'Summer 2021' in courseDict[3]['term'].description
assert "Brian Ramsay" == courseDict[3]['creator']
assert "FRN 103 - Frenchy Help" == courseDict[3]['courseDisplayName']


courseDict = getSLProposalInfoForUser('heggens')
assert 4 in courseDict
Expand All @@ -38,6 +43,21 @@ def test_getServiceLearningCoursesData():
assert "In Progress" == courseDict[4]['status']
assert 'Spring 2021' in courseDict[4]['term'].description
assert "Scott Heggen" == courseDict[4]['creator']
assert "Testing" == courseDict[4]['courseDisplayName']



@pytest.mark.integration
def test_createCourseDisplayName():
'''tests for the successful implementation of combining course name and number to proper format'''

assert 'Databases' == createCourseDisplayName("Databases", '')
assert 'Databases' == createCourseDisplayName("Databases", "")
assert 'FRN 103 - Frenchy Help' == createCourseDisplayName("Frenchy Help", 'FRN 103')
assert 'FRN 103' == createCourseDisplayName("", 'FRN 103')
assert '' == createCourseDisplayName ("", '')



@pytest.mark.integration
def test_getInstructorCourses():
Expand Down

0 comments on commit 68787b3

Please sign in to comment.