Skip to content

Commit

Permalink
Added labs page
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaSaikali committed Dec 3, 2021
1 parent 9ff4285 commit 459d641
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 34 deletions.
1 change: 1 addition & 0 deletions api/app/graphql/types/dynamic_topic_option_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ class DynamicTopicOptionType < Types::BaseObject
description 'A type that represents a options for generating a dynamic question.'
field :name, String, null: false
field :route, String, null: false
field :display_name, String, null: false
end
end
2 changes: 1 addition & 1 deletion api/app/services/fetch_dynamic_routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def call(path = 'http://127.0.0.1:8000/api/')
topics = []
data.each_key do |key|
question_routes = data[key.to_s]
questions_list = question_routes.map { |k, v| OpenStruct.new(name: k, route: v) }
questions_list = question_routes.map { |k, v| OpenStruct.new(name: k, route: v['route'], display_name: v['display_name']) }
topics << OpenStruct.new(name: key, options: questions_list)
end
topics
Expand Down
6 changes: 4 additions & 2 deletions client/src/components/ContentCard/ContentCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
faClipboard, //Test
faPencilAlt, //Midterm
faPenAlt, //Exam
faUser // Person
faUser, // Person
faVial // Test Tube
} from '@fortawesome/free-solid-svg-icons';
const tagIcons = {
Expand All @@ -30,7 +31,8 @@
Test: faQuestion,
Midterm: faQuestion,
Exam: faQuestion,
User: faUser
User: faUser,
Vial: faVial
};
</script>

Expand Down
9 changes: 6 additions & 3 deletions client/src/data/queries/DynamicRoutes/Routes.example.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ const ROUTES_EXAMPLE_DATA = {
options: [
{
name: 'bitstrings-of-length',
route: '/comp2804/bitstrings-of-length'
route: '/comp2804/bitstrings-of-length',
displayName: 'Bitstrings of Length'
},
{
name: 'set-theory-question',
route: '/comp2804/set-theory'
route: '/comp2804/set-theory',
displayName: 'Set Theory'
},
{
name: 'num-of-functions',
route: '/comp2804/num-of-functions'
route: '/comp2804/num-of-functions',
displayName: 'Number of Functions'
}
]
}
Expand Down
1 change: 1 addition & 0 deletions client/src/data/queries/DynamicRoutes/Routes.query.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const ROUTES = gql`
options {
name
route
displayName
}
}
}
Expand Down
12 changes: 5 additions & 7 deletions client/src/pages/Labs.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import {ContentCard, CourseNavbar as Navbar, Loading} from '../components';
import {getRoutes} from '../data';
const response = getRoutes();
console.log($response.data.dynamicRoutes.options)
</script>

<Navbar />
Expand All @@ -18,14 +17,13 @@

{#if !$response.loading && $response}
<div class="content-container">
<!-- GIVES ERROR: Error: {#each} only iterates over array-like objects. -->
{#each $response.data.dynamicRoutes.options as routes}
{#each $response.data.dynamicRoutes[1].options as routes}
<a href={'#/labs'}>
<ContentCard
title={routes.name}
info= {$response.data.dynamicRoutes.name}
tag={'Test'}
type="Test"
title={routes.displayName}
info="Lab"
tag={'Lab'}
type="Vial"
/>
</a>
{/each}
Expand Down
65 changes: 44 additions & 21 deletions dynamic/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,44 @@
)

routes = {
"demo": {"graph_theory": "/demo/graph-theory"},
"books_shelves": {
"books_shelves_0": "/books_shelves/books_shelves_0",
"books_shelves_1": "/books_shelves/books_shelves_1",
"books_shelves_2": "/books_shelves/books_shelves_2",
"books_shelves_3": "/books_shelves/books_shelves_3",
'books_shelves': {
"books_shelves_0": {
'display_name': "Book Shelves",
'route': "/books_shelves/books_shelves_0"
},
"books_shelves_1": {
'display_name': "Book Shelve",
'route': "/books_shelves/books_shelves_1"
},
"books_shelves_2": {
'display_name': "Book Shelve",
'route': "/books_shelves/books_shelves_2"
},
"books_shelves_3": {
'display_name': "Book Shelve",
'route': "/books_shelves/books_shelves_3"
},
},
"comp2804": {
"bitstrings-of-length": "/comp2804/bitstrings-of-length",
"set-theory-question": "/comp2804/set-theory",
"num-of-functions": "/comp2804/num-of-functions",
'demo': {
'graph_theory': {
'display_name': "Graph Theory",
'route': "/demo/graph-theory"
}
},
'comp2804': {
'bitstrings-of-length': {
'display_name': "Bitstrings of Length",
'route': "/comp2804/bitstrings-of-length"
},
'set-theory-question': {
'display_name': "Set Theory",
'route': "/comp2804/set-theory"
},
'num-of-functions': {
'display_name': "Number of Functions",
'route': "/comp2804/num-of-functions"
}
}
}


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


@router.get(routes["demo"]["graph_theory"])
@router.get(routes['demo']['graph_theory']['route'])
async def generate_graph_theory_question():
return graph_theory_question_generator.call()


############___Books_Shelves_Questions___############
@router.get(routes["books_shelves"]["books_shelves_0"])
@router.get(routes["books_shelves"]["books_shelves_0"]['route'])
async def generate_books_shelves_0_question():
return books_shelves_0_generator.call()


@router.get(routes["books_shelves"]["books_shelves_1"])
@router.get(routes["books_shelves"]["books_shelves_1"]['route'])
async def generate_books_shelves_1_question():
return books_shelves_1_generator.call()


@router.get(routes["books_shelves"]["books_shelves_2"])
@router.get(routes["books_shelves"]["books_shelves_2"]['route'])
async def generate_books_shelves_2_question():
return books_shelves_2_generator.call()


@router.get(routes["books_shelves"]["books_shelves_3"])
@router.get(routes["books_shelves"]["books_shelves_3"]['route'])
async def generate_books_shelves_3_question():
return books_shelves_3_generator.call()


######################################################


@router.get(routes["comp2804"]["set-theory-question"])
@router.get(routes['comp2804']['set-theory-question']['route'])
async def generate_set_theory_question():
return set_theory_question_generator.call()


@router.get(routes["comp2804"]["num-of-functions"])
@router.get(routes['comp2804']['num-of-functions']['route'])
async def generate_num_of_functions_question(
lower_range: int = 0, upper_range: int = 10
):
return num_of_functions_generator.call(lower_range, upper_range)


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

0 comments on commit 459d641

Please sign in to comment.