Skip to content

Commit e09e238

Browse files
committed
Added labs page
1 parent e2ae772 commit e09e238

7 files changed

Lines changed: 38 additions & 22 deletions

File tree

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: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,25 @@
1111

1212
routes = {
1313
'demo': {
14-
'graph_theory': "/demo/graph-theory"
14+
'graph_theory': {
15+
'display_name': "Graph Theory",
16+
'route': "/demo/graph-theory"
17+
}
1518
},
1619
'comp2804': {
17-
'bitstrings-of-length': "/comp2804/bitstrings-of-length",
18-
'set-theory-question': "/comp2804/set-theory",
19-
'num-of-functions': "/comp2804/num-of-functions"
20+
'bitstrings-of-length': {
21+
'display_name': "Bitstrings of Length",
22+
'route': "/comp2804/bitstrings-of-length"
23+
},
24+
'set-theory-question': {
25+
'display_name': "Set Theory",
26+
'route': "/comp2804/set-theory"
27+
},
28+
'num-of-functions': {
29+
'display_name': "Number of Functions",
30+
'route': "/comp2804/num-of-functions"
31+
}
2032
}
21-
2233
}
2334

2435

@@ -27,23 +38,23 @@ async def get_generators():
2738
return routes
2839

2940

30-
@router.get(routes['demo']['graph_theory'])
41+
@router.get(routes['demo']['graph_theory']['route'])
3142
async def generate_graph_theory_question():
3243
return graph_theory_question_generator.call()
3344

3445

35-
@router.get(routes['comp2804']['set-theory-question'])
46+
@router.get(routes['comp2804']['set-theory-question']['route'])
3647
async def generate_set_theory_question():
3748
return set_theory_question_generator.call()
3849

3950

40-
@router.get(routes['comp2804']['num-of-functions'])
51+
@router.get(routes['comp2804']['num-of-functions']['route'])
4152
async def generate_num_of_functions_question(
4253
lower_range: int = 0, upper_range: int = 10
4354
):
4455
return num_of_functions_generator.call(lower_range, upper_range)
4556

4657

47-
@router.get(routes['comp2804']['bitstrings-of-length'])
58+
@router.get(routes['comp2804']['bitstrings-of-length']['route'])
4859
async def bitstrings_of_length_question():
4960
return bitstrings_of_length_generator.call()

0 commit comments

Comments
 (0)