Skip to content

Commit 459d641

Browse files
committed
Added labs page
1 parent 9ff4285 commit 459d641

File tree

7 files changed

+62
-34
lines changed

7 files changed

+62
-34
lines changed

api/app/graphql/types/dynamic_topic_option_type.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ class DynamicTopicOptionType < Types::BaseObject
33
description 'A type that represents a options for generating a dynamic question.'
44
field :name, String, null: false
55
field :route, String, null: false
6+
field :display_name, String, null: false
67
end
78
end

api/app/services/fetch_dynamic_routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def call(path = 'http://127.0.0.1:8000/api/')
88
topics = []
99
data.each_key do |key|
1010
question_routes = data[key.to_s]
11-
questions_list = question_routes.map { |k, v| OpenStruct.new(name: k, route: v) }
11+
questions_list = question_routes.map { |k, v| OpenStruct.new(name: k, route: v['route'], display_name: v['display_name']) }
1212
topics << OpenStruct.new(name: key, options: questions_list)
1313
end
1414
topics

client/src/components/ContentCard/ContentCard.svelte

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
faClipboard, //Test
1414
faPencilAlt, //Midterm
1515
faPenAlt, //Exam
16-
faUser // Person
16+
faUser, // Person
17+
faVial // Test Tube
1718
} from '@fortawesome/free-solid-svg-icons';
1819
1920
const tagIcons = {
@@ -30,7 +31,8 @@
3031
Test: faQuestion,
3132
Midterm: faQuestion,
3233
Exam: faQuestion,
33-
User: faUser
34+
User: faUser,
35+
Vial: faVial
3436
};
3537
</script>
3638

client/src/data/queries/DynamicRoutes/Routes.example.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,18 @@ const ROUTES_EXAMPLE_DATA = {
1616
options: [
1717
{
1818
name: 'bitstrings-of-length',
19-
route: '/comp2804/bitstrings-of-length'
19+
route: '/comp2804/bitstrings-of-length',
20+
displayName: 'Bitstrings of Length'
2021
},
2122
{
2223
name: 'set-theory-question',
23-
route: '/comp2804/set-theory'
24+
route: '/comp2804/set-theory',
25+
displayName: 'Set Theory'
2426
},
2527
{
2628
name: 'num-of-functions',
27-
route: '/comp2804/num-of-functions'
29+
route: '/comp2804/num-of-functions',
30+
displayName: 'Number of Functions'
2831
}
2932
]
3033
}

client/src/data/queries/DynamicRoutes/Routes.query.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const ROUTES = gql`
77
options {
88
name
99
route
10+
displayName
1011
}
1112
}
1213
}

client/src/pages/Labs.svelte

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import {ContentCard, CourseNavbar as Navbar, Loading} from '../components';
44
import {getRoutes} from '../data';
55
const response = getRoutes();
6-
console.log($response.data.dynamicRoutes.options)
76
</script>
87

98
<Navbar />
@@ -18,14 +17,13 @@
1817

1918
{#if !$response.loading && $response}
2019
<div class="content-container">
21-
<!-- GIVES ERROR: Error: {#each} only iterates over array-like objects. -->
22-
{#each $response.data.dynamicRoutes.options as routes}
20+
{#each $response.data.dynamicRoutes[1].options as routes}
2321
<a href={'#/labs'}>
2422
<ContentCard
25-
title={routes.name}
26-
info= {$response.data.dynamicRoutes.name}
27-
tag={'Test'}
28-
type="Test"
23+
title={routes.displayName}
24+
info="Lab"
25+
tag={'Lab'}
26+
type="Vial"
2927
/>
3028
</a>
3129
{/each}

dynamic/router.py

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,44 @@
1515
)
1616

1717
routes = {
18-
"demo": {"graph_theory": "/demo/graph-theory"},
19-
"books_shelves": {
20-
"books_shelves_0": "/books_shelves/books_shelves_0",
21-
"books_shelves_1": "/books_shelves/books_shelves_1",
22-
"books_shelves_2": "/books_shelves/books_shelves_2",
23-
"books_shelves_3": "/books_shelves/books_shelves_3",
18+
'books_shelves': {
19+
"books_shelves_0": {
20+
'display_name': "Book Shelves",
21+
'route': "/books_shelves/books_shelves_0"
22+
},
23+
"books_shelves_1": {
24+
'display_name': "Book Shelve",
25+
'route': "/books_shelves/books_shelves_1"
26+
},
27+
"books_shelves_2": {
28+
'display_name': "Book Shelve",
29+
'route': "/books_shelves/books_shelves_2"
30+
},
31+
"books_shelves_3": {
32+
'display_name': "Book Shelve",
33+
'route': "/books_shelves/books_shelves_3"
34+
},
2435
},
25-
"comp2804": {
26-
"bitstrings-of-length": "/comp2804/bitstrings-of-length",
27-
"set-theory-question": "/comp2804/set-theory",
28-
"num-of-functions": "/comp2804/num-of-functions",
36+
'demo': {
37+
'graph_theory': {
38+
'display_name': "Graph Theory",
39+
'route': "/demo/graph-theory"
40+
}
2941
},
42+
'comp2804': {
43+
'bitstrings-of-length': {
44+
'display_name': "Bitstrings of Length",
45+
'route': "/comp2804/bitstrings-of-length"
46+
},
47+
'set-theory-question': {
48+
'display_name': "Set Theory",
49+
'route': "/comp2804/set-theory"
50+
},
51+
'num-of-functions': {
52+
'display_name': "Number of Functions",
53+
'route': "/comp2804/num-of-functions"
54+
}
55+
}
3056
}
3157

3258

@@ -35,47 +61,44 @@ async def get_generators():
3561
return routes
3662

3763

38-
@router.get(routes["demo"]["graph_theory"])
64+
@router.get(routes['demo']['graph_theory']['route'])
3965
async def generate_graph_theory_question():
4066
return graph_theory_question_generator.call()
4167

4268

4369
############___Books_Shelves_Questions___############
44-
@router.get(routes["books_shelves"]["books_shelves_0"])
70+
@router.get(routes["books_shelves"]["books_shelves_0"]['route'])
4571
async def generate_books_shelves_0_question():
4672
return books_shelves_0_generator.call()
4773

4874

49-
@router.get(routes["books_shelves"]["books_shelves_1"])
75+
@router.get(routes["books_shelves"]["books_shelves_1"]['route'])
5076
async def generate_books_shelves_1_question():
5177
return books_shelves_1_generator.call()
5278

5379

54-
@router.get(routes["books_shelves"]["books_shelves_2"])
80+
@router.get(routes["books_shelves"]["books_shelves_2"]['route'])
5581
async def generate_books_shelves_2_question():
5682
return books_shelves_2_generator.call()
5783

5884

59-
@router.get(routes["books_shelves"]["books_shelves_3"])
85+
@router.get(routes["books_shelves"]["books_shelves_3"]['route'])
6086
async def generate_books_shelves_3_question():
6187
return books_shelves_3_generator.call()
6288

6389

64-
######################################################
65-
66-
67-
@router.get(routes["comp2804"]["set-theory-question"])
90+
@router.get(routes['comp2804']['set-theory-question']['route'])
6891
async def generate_set_theory_question():
6992
return set_theory_question_generator.call()
7093

7194

72-
@router.get(routes["comp2804"]["num-of-functions"])
95+
@router.get(routes['comp2804']['num-of-functions']['route'])
7396
async def generate_num_of_functions_question(
7497
lower_range: int = 0, upper_range: int = 10
7598
):
7699
return num_of_functions_generator.call(lower_range, upper_range)
77100

78101

79-
@router.get(routes["comp2804"]["bitstrings-of-length"])
102+
@router.get(routes['comp2804']['bitstrings-of-length']['route'])
80103
async def bitstrings_of_length_question():
81104
return bitstrings_of_length_generator.call()

0 commit comments

Comments
 (0)