Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skil group #799

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1ea9a9b
fix: SKIL-503 bug showing completed assessment tasks in "My Assessmen…
malloc-nbytes Nov 2, 2024
aa70a3e
Added unlock button for viewing assesment tasks as an admin.
malloc-nbytes Nov 4, 2024
7d574b5
Started work on implementation for the API call for locking ATs.
malloc-nbytes Nov 6, 2024
1819637
the lock feature now communicates with the DB
malloc-nbytes Nov 7, 2024
9ab391a
The assessment tasks that are locked for the student can no longer be…
malloc-nbytes Nov 7, 2024
8594b3f
removed broken lock code
malloc-nbytes Nov 14, 2024
fb2f1ad
test comit
malloc-nbytes Nov 14, 2024
a0d4f10
added lock buttons
malloc-nbytes Nov 14, 2024
4c0d913
temporary redirect when viewing a CAT as a student
malloc-nbytes Nov 14, 2024
214cab3
added unit of assessment in student view ATs
malloc-nbytes Nov 14, 2024
094125a
added getting team users route
malloc-nbytes Nov 18, 2024
021293a
added lock column to CAT db table
malloc-nbytes Nov 18, 2024
ba8bbf6
assessment tasks now have a lock DB column
malloc-nbytes Nov 20, 2024
f011ab7
ATs that are past due are now shown in the completed ATs.
malloc-nbytes Nov 20, 2024
3258fed
dashboard now gets ATs and CATs.
malloc-nbytes Nov 25, 2024
8e178df
ATs and CATs now use filtered results
malloc-nbytes Nov 25, 2024
cc3da72
team members show up again
malloc-nbytes Nov 26, 2024
fea81f2
added locking to all CATs
malloc-nbytes Nov 26, 2024
8993d79
added locking to reg. assessments. started on new readme
malloc-nbytes Dec 2, 2024
0655b1e
added temporary error message
malloc-nbytes Dec 2, 2024
06261ba
Merge branch 'master' into SKIL-group
malloc-nbytes Dec 6, 2024
1a43350
restored changes
malloc-nbytes Dec 6, 2024
856e828
added dbinsert helper scripts
malloc-nbytes Dec 6, 2024
9aeda8a
added back the locking multiple CATs.
malloc-nbytes Dec 7, 2024
7c43076
updated new README
malloc-nbytes Dec 9, 2024
07a2eb7
Merge branch 'master' into SKIL-group
malloc-nbytes Dec 9, 2024
49360ff
Merge branch 'SKIL-group' of https://www.github.com/Lunatic-Labs/rubr…
malloc-nbytes Dec 9, 2024
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
54 changes: 49 additions & 5 deletions BackEndFlask/controller/Routes/Assessment_task_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
get_assessment_tasks,
get_assessment_task,
create_assessment_task,
replace_assessment_task
replace_assessment_task,
toggle_lock_status,
toggle_published_status,
)

from models.completed_assessment import (
Expand Down Expand Up @@ -101,8 +103,7 @@ def get_all_assessment_tasks():
user_course.course_id
)

for assessment_task in assessment_tasks:
all_assessment_tasks.append(assessment_task)
for assessment_task in assessment_tasks: all_assessment_tasks.append(assessment_task)

return create_good_response(
assessment_tasks_schema.dump(all_assessment_tasks),
Expand Down Expand Up @@ -253,6 +254,47 @@ def update_assessment_task():
)


@bp.route('/assessment_task_toggle_lock', methods=['PUT'])
@jwt_required()
@bad_token_check()
@AuthCheck()
def toggle_lock_status_route():
try:
assessmentTaskId = request.args.get('assessmentTaskId')

toggle_lock_status(assessmentTaskId)

return create_good_response(
assessment_task_schema.dump(get_assessment_task(assessmentTaskId)),
201,
"assessment_tasks"
)
except Exception as e:
return create_bad_response(
f"An error occurred toggling the lock status for assessment {e}", "assessment_tasks", 400
)


@bp.route('/assessment_task_toggle_published', methods=['PUT'])
@jwt_required()
@bad_token_check()
@AuthCheck()
def toggle_published_status_route():
try:
assessmentTaskId = request.args.get('assessmentTaskId')

toggle_published_status(assessmentTaskId)

return create_good_response(
assessment_task_schema.dump(get_assessment_task(assessmentTaskId)),
201,
"assessment_tasks"
)
except Exception as e:
return create_bad_response(
f"An error occurred toggling the published status for assessment {e}", "assessment_tasks", 400
)


# /assessment_task/ POST
# copies over assessment_tasks from an existing course to another course
Expand Down Expand Up @@ -314,9 +356,11 @@ class Meta:
"comment",
"number_of_teams",
"max_team_size",
"notification_sent"
"notification_sent",
"locked",
"published",
)


assessment_task_schema = AssessmentTaskSchema()
assessment_tasks_schema = AssessmentTaskSchema(many=True)
assessment_tasks_schema = AssessmentTaskSchema(many=True)
61 changes: 55 additions & 6 deletions BackEndFlask/controller/Routes/Completed_assessment_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
create_completed_assessment,
replace_completed_assessment,
completed_assessment_exists,
get_completed_assessment_count
get_completed_assessment_count,
toggle_lock_status,
make_complete_assessment_locked,
make_complete_assessment_unlocked,
)

from models.queries import (
Expand All @@ -29,6 +32,51 @@
from models.assessment_task import get_assessment_tasks_by_course_id


@bp.route('/completed_assessment_toggle_lock', methods=['PUT'])
@jwt_required()
@bad_token_check()
@AuthCheck()
def toggle_complete_assessment_lock_status():
try:
assessmentTaskId = request.args.get('assessment_task_id')
toggle_lock_status(assessmentTaskId)
return create_good_response(None, 201, "completed_assessments")

except Exception as e:
return create_bad_response(
f"An error occurred toggling CAT lock: {e}", "completed_assessments", 400
)

@bp.route('/completed_assessment_lock', methods=['PUT'])
@jwt_required()
@bad_token_check()
@AuthCheck()
def lock_complete_assessment():
try:
assessmentTaskId = request.args.get('assessment_task_id')
make_complete_assessment_locked(assessmentTaskId)
return create_good_response(None, 201, "completed_assessments")

except Exception as e:
return create_bad_response(
f"An error occurred locking a CAT: {e}", "completed_assessments", 400
)

@bp.route('/completed_assessment_unlock', methods=['PUT'])
@jwt_required()
@bad_token_check()
@AuthCheck()
def unlock_complete_assessment():
try:
assessmentTaskId = request.args.get('assessment_task_id')
make_complete_assessment_unlocked(assessmentTaskId)
return create_good_response(None, 201, "completed_assessments")

except Exception as e:
return create_bad_response(
f"An error occurred unlocking a CAT: {e}", "completed_assessments", 400
)

@bp.route('/completed_assessment', methods=['GET'])
@jwt_required()
@bad_token_check()
Expand Down Expand Up @@ -96,7 +144,7 @@ def get_all_completed_assessments():
completed_assessments = get_completed_assessment_with_team_name(assessment_task_id)
else:
completed_assessments = get_completed_assessment_with_user_name(assessment_task_id)

completed_count = get_completed_assessment_count(assessment_task_id)
result = [
{**completed_assessment_schema.dump(assessment), 'completed_count': completed_count}
Expand All @@ -106,7 +154,7 @@ def get_all_completed_assessments():

if request.args and request.args.get("assessment_task_id"):
assessment_task_id = int(request.args.get("assessment_task_id"))

get_assessment_task(assessment_task_id) # Trigger an error if not exists.
completed_assessments = get_completed_assessment_with_team_name(assessment_task_id)

Expand All @@ -119,7 +167,7 @@ def get_all_completed_assessments():
for assessment in completed_assessments
]
return create_good_response(result, 200, "completed_assessments")

if request.args and request.args.get("completed_assessment_task_id"):
completed_assessment_task_id = int(request.args.get("completed_assessment_task_id"))
one_completed_assessment = get_completed_assessment_with_team_name(completed_assessment_task_id)
Expand Down Expand Up @@ -214,9 +262,10 @@ class Meta:
'team_name',
'user_id',
'first_name',
'last_name',
'last_name',
'initial_time',
'done',
'locked',
'last_update',
'rating_observable_characteristics_suggestions_data',
'course_id',
Expand All @@ -226,4 +275,4 @@ class Meta:


completed_assessment_schema = CompletedAssessmentSchema()
completed_assessment_schemas = CompletedAssessmentSchema(many=True)
completed_assessment_schemas = CompletedAssessmentSchema(many=True)
2 changes: 1 addition & 1 deletion BackEndFlask/controller/Routes/Rating_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ class Meta:
)

student_feedback_schema = StudentFeedbackSchema()
student_feedbacks_schema = StudentFeedbackSchema(many=True)
student_feedbacks_schema = StudentFeedbackSchema(many=True)
90 changes: 88 additions & 2 deletions BackEndFlask/controller/Routes/Team_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@

from models.queries import (
get_team_by_course_id_and_user_id,
get_all_nonfull_adhoc_teams
get_all_nonfull_adhoc_teams,
get_students_by_team_id,
get_team_users,
)

@bp.route('/team', methods = ['GET'])
Expand All @@ -45,6 +47,7 @@ def get_all_teams():
except Exception as e:
return create_bad_response(f"An error occurred retrieving all teams: {e}", "teams", 400)

# WIP
@bp.route('/team_by_user', methods = ['GET'])
@jwt_required()
@bad_token_check()
Expand All @@ -57,11 +60,79 @@ def get_all_teams_by_user():

teams = get_team_by_course_id_and_user_id(course_id, user_id)

return create_good_response(teams_schema.dump(teams), 200, "teams")
json = []

for i in range(0, len(teams)):
team_id = teams[i].team_id
team_name = teams[i].team_name
team_users = get_team_users(course_id, team_id, user_id)
users = []

# Get the names of each team member w/ the LName shortened.
for user in team_users:
# users.append((user[1]+' '+user[2][0]+'.'))
users.append(user[1])

data = {
'team_id': teams[i].team_id,
'team_name': teams[i].team_name,
'observer_id': teams[i].observer_id,
'course_id': teams[i].course_id,
'date_created': teams[i].date_created,
'active_until': teams[i].active_until,
'team_users': users,
}
json.append(data)

return create_good_response(json, 200, "teams")
# return create_good_response(teams_schema.dump(teams), 200, "teams")

except Exception as e:
return create_bad_response(f"An error occurred retrieving all teams: {e}", "teams", 400)

# @bp.route('/team_by_user', methods=['GET'])
# @jwt_required()
# @bad_token_check()
# @AuthCheck()
# def get_all_teams_by_user():
# try:
# if request.args and request.args.get("course_id"):
# course_id = int(request.args.get("course_id"))
# user_id = int(request.args.get("user_id"))
#
# # Get the teams that the user is associated with
# teams = get_team_by_course_id_and_user_id(course_id, user_id)
#
# # Prepare a list to store teams and their users
# teams_with_users = []
#
# for team in teams:
# # Access team data directly since 'team' is a Team object
# team_id = team.team_id
# team_name = team.team_name
#
# # Get the users of the current team
# team_users = get_team_users(course_id, team_id, user_id)
#
# # Add team information along with its users to the result
# teams_with_users.append({
# "team": {
# "team_id": team_id,
# "team_name": team_name,
# "course_id": team.course_id,
# "observer_id": team.observer_id,
# "date_created": team.date_created,
# "active_until": team.active_until
# },
# "users": team_users
# })
#
# # Return the teams along with their users
# return create_good_response(teams_with_users, 200, "teams_with_users")
#
# except Exception as e:
# return create_bad_response(f"An error occurred retrieving all teams: {e}", "teams", 400)

@bp.route('/team_by_observer', methods = ['GET'])
@jwt_required()
@bad_token_check()
Expand Down Expand Up @@ -207,6 +278,21 @@ def delete_selected_teams():
except Exception as e:
return create_bad_response(f"An error occurred deleting a team: {e}", "teams", 400)

@bp.route('/get_all_team_users', methods=['GET'])
@jwt_required()
@bad_token_check()
@AuthCheck()
def get_all_team_users():
try:
course_id = request.args.get("course_id")
team_id = request.args.get("team_id")
users = get_students_by_team_id(course_id, team_id)
users_json = [{"name": user[1]} for user in users]
return create_good_response(users_json, 200, "teams")
except Exception as e:
return create_bad_response(f"An error occurred getting team users: {e}", "teams", 400)


class TeamSchema(ma.Schema):
class Meta:
fields = (
Expand Down
Loading
Loading