Skip to content

Commit 074758c

Browse files
committed
feat: implement new VisiQuate internal scenarios with admin-only information
- Replace challenges with 12 new internal scenarios from TSV file - Add admin_sql_example and admin_notes columns to challenges table - Implement conditional display of internal information only for admins - Update challenge descriptions with structured HTML format - Include real scenario data: Balance Validity, Rollup Validations, Date Patterns, etc. - Add database schema migration for admin columns - Secure admin information from candidates while showing to administrators
1 parent 9574bc6 commit 074758c

File tree

4 files changed

+285
-87
lines changed

4 files changed

+285
-87
lines changed

app.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -616,17 +616,27 @@ def api_challenges():
616616

617617

618618
@app.route('/api/challenge/<int:challenge_id>')
619-
@require_admin
620619
def api_challenge_detail(challenge_id):
621-
"""Get challenge details (ADMIN ONLY)"""
622-
admin_user = session.get('admin_user', {})
623-
log_admin_action(admin_user.get('id'), 'api_challenge_detail', f'Viewed challenge {challenge_id}')
620+
"""Get challenge details - includes admin info only for admins"""
621+
# Check if user has admin or candidate access
622+
if not (session.get('is_admin') or session.get('user_id')):
623+
return jsonify({'error': 'Access denied'}), 403
624624

625625
challenge = get_challenge_by_id(challenge_id, session.get('user_id'))
626-
if challenge:
627-
return jsonify(challenge)
628-
else:
626+
if not challenge:
629627
return jsonify({'error': 'Challenge not found'}), 404
628+
629+
# Remove admin information if not an admin
630+
if not session.get('is_admin'):
631+
challenge.pop('admin_sql_example', None)
632+
challenge.pop('admin_notes', None)
633+
634+
# Log admin access
635+
if session.get('is_admin'):
636+
admin_user = session.get('admin_user', {})
637+
log_admin_action(admin_user.get('id'), 'api_challenge_detail', f'Viewed challenge {challenge_id}')
638+
639+
return jsonify(challenge)
630640

631641

632642
@app.route('/api/challenge/<int:challenge_id>/attempt', methods=['POST'])

0 commit comments

Comments
 (0)