-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
314 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module Queries | ||
class DynamicRoutes < Queries::BaseQuery | ||
description 'Gets all routes from dynamic service' | ||
type [Types::DynamicTopicType], null: false | ||
|
||
def resolve | ||
FetchDynamicRoutes.new.call | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Types | ||
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 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Types | ||
class DynamicTopicType < Types::BaseObject | ||
description 'A type that represents a topic within dynamic service.' | ||
field :name, String, null: false | ||
field :options, [Types::DynamicTopicOptionType], null: false | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class FetchDynamicRoutes | ||
def initialize; end | ||
|
||
def call(path = 'http://127.0.0.1:8000/api/') | ||
data = HTTParty.get(path, | ||
headers: { 'Content-Type' => 'application/json' }) | ||
.parsed_response | ||
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) } | ||
topics << OpenStruct.new(name: key, options: questions_list) | ||
end | ||
topics | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
version: '3' | ||
|
||
services: | ||
api: | ||
build: . | ||
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails db:setup && bundle exec rails s -p 3000 -b '0.0.0.0'" | ||
volumes: | ||
- .:/usr/src/app | ||
ports: | ||
- "3000:3000" | ||
depends_on: | ||
- db | ||
links: | ||
- db | ||
networks: | ||
- discretemath | ||
|
||
db: | ||
image: postgres:12-alpine | ||
environment: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: 1234 | ||
ports: | ||
- "5438:5432" | ||
networks: | ||
- discretemath | ||
|
||
pgadmin: | ||
container_name: pgadmin4_container | ||
image: dpage/pgadmin4 | ||
restart: always | ||
environment: | ||
PGADMIN_DEFAULT_EMAIL: [email protected] | ||
PGADMIN_DEFAULT_PASSWORD: root | ||
ports: | ||
- "5050:80" | ||
depends_on: | ||
- db | ||
links: | ||
- db | ||
networks: | ||
- discretemath | ||
|
||
volumes: | ||
database_postgres: | ||
|
||
networks: | ||
discretemath: | ||
driver: bridge |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export {getTest, getCourse, getCourseSession} from './services'; | ||
export {getTest, getCourse, getCourseSession, getRoutes} from './services'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const ROUTES_EXAMPLE_DATA = { | ||
loading: false, | ||
data: { | ||
dynamicRoutes: [ | ||
{ | ||
name: 'demo', | ||
options: [ | ||
{ | ||
name: 'graph_theory', | ||
route: '/demo/graph-theory' | ||
} | ||
] | ||
}, | ||
{ | ||
name: 'comp2804', | ||
options: [ | ||
{ | ||
name: 'bitstrings-of-length', | ||
route: '/comp2804/bitstrings-of-length' | ||
}, | ||
{ | ||
name: 'set-theory-question', | ||
route: '/comp2804/set-theory' | ||
}, | ||
{ | ||
name: 'num-of-functions', | ||
route: '/comp2804/num-of-functions' | ||
} | ||
] | ||
} | ||
] | ||
} | ||
}; | ||
|
||
export {ROUTES_EXAMPLE_DATA}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {gql} from 'graphql-tag'; | ||
|
||
const ROUTES = gql` | ||
query { | ||
dynamicRoutes { | ||
name | ||
options { | ||
name | ||
route | ||
} | ||
} | ||
} | ||
`; | ||
|
||
export {ROUTES}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export {ROUTES} from './Routes.query'; | ||
export {ROUTES_EXAMPLE_DATA} from './Routes.example'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export {TEST, TEST_EXAMPLE_DATA} from './Test'; | ||
export {COURSE, COURSE_EXAMPLE_DATA} from './Course'; | ||
export {COURSESESSION, COURSESESSION_EXAMPLE_DATA} from './CourseSession'; | ||
export {ROUTES, ROUTES_EXAMPLE_DATA} from './DynamicRoutes'; |
14 changes: 14 additions & 0 deletions
14
client/src/data/services/getDynamicRoutes/Routes.service.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import {query} from 'svelte-apollo'; | ||
import {ROUTES, ROUTES_EXAMPLE_DATA} from '../../queries'; | ||
import {readable} from 'svelte/store'; | ||
|
||
const getRoutes = () => { | ||
// ENV VAR TO HIT API INSTEAD OF MOCK | ||
if (process.env['USE_API'] === 'true') { | ||
return query(ROUTES); | ||
} else { | ||
return readable(ROUTES_EXAMPLE_DATA, () => {}); | ||
} | ||
}; | ||
|
||
export {getRoutes}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {getRoutes} from './Routes.service'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export {getTest} from './getTest'; | ||
export {getCourse} from './getCourse'; | ||
export {getCourseSession} from './getCourseSession'; | ||
export {getRoutes} from './getDynamicRoutes'; |
Empty file.
69 changes: 69 additions & 0 deletions
69
dynamic/generators/comp2804/binomial_expansion_coefficient/main.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import random | ||
|
||
|
||
def generate_question(): | ||
|
||
a_coefficient = random.randint(2, 5) | ||
b_coefficient = random.randint(3, 7) | ||
|
||
x_exponent = random.randint(3, 8) | ||
y_exponent = random.randint(5, 11) | ||
|
||
n = random.randint(11, 15) | ||
|
||
answer = f"-\genfrac(){{n}}{{y_exponent}}\cdot{a_coefficient}^{x_exponent}\cdot{b_coefficient}^{y_exponent}" | ||
|
||
question_body = f"What is the coefficient of x^{x_exponent}y^{y_exponent} in the expansion of ({a_coefficient} - {b_coefficient}y)^{n}" | ||
|
||
return { | ||
"title": "bitstrings of length", | ||
"body": question_body, | ||
"body_format": "text", | ||
"pseudocode": "", | ||
"multiple_choice_answers": [ | ||
{ | ||
"body": answerchoice_1( | ||
n, a_coefficient, b_coefficient, x_exponent, y_exponent | ||
), | ||
"body_format": "mathjax", | ||
"correct": "false", | ||
}, | ||
{ | ||
"body": answer, | ||
"body_format": "mathjax", | ||
"correct": "true", | ||
}, | ||
{ | ||
"body": answerchoice_3( | ||
n, a_coefficient, b_coefficient, x_exponent, y_exponent | ||
), | ||
"body_format": "mathjax", | ||
"correct": "false", | ||
}, | ||
{ | ||
"body": answerchoice_4( | ||
n, a_coefficient, b_coefficient, x_exponent, y_exponent | ||
), | ||
"body_format": "mathjax", | ||
"correct": "false", | ||
}, | ||
], | ||
} | ||
|
||
|
||
def answerchoice_1(n, a_coefficient, b_coefficient, x_exponent, y_exponent): | ||
return f"\genfrac(){{n}}{{y_exponent}}\cdot{a_coefficient}^{x_exponent}\cdot{b_coefficient}^{y_exponent}" | ||
|
||
# answerchoice_2 purposefully omitted | ||
|
||
|
||
def answerchoice_3(n, a_coefficient, b_coefficient, x_exponent, y_exponent): | ||
return f"\genfrac(){{n}}{{y_exponent}}\cdot{a_coefficient}^{y_exponent}\cdot{b_coefficient}^{x_exponent}" | ||
|
||
|
||
def answerchoice_4(n, a_coefficient, b_coefficient, x_exponent, y_exponent): | ||
return f"-\genfrac(){{n}}{{y_exponent}}\cdot{a_coefficient}^{y_exponent}\cdot{b_coefficient}^{x_exponent}" | ||
|
||
|
||
def call(): | ||
return generate_question() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import random | ||
|
||
|
||
def generate_question(): | ||
# generate required data | ||
k = random.randint(2, 4) # value of k, m and n | ||
|
||
# generate required content | ||
|
||
question_body = ( | ||
"Let $m \geq " | ||
+ str(k) | ||
+ "$ and $n \geq " | ||
+ str(k) | ||
+ "$ be integers. What does $${{m}\choose{" | ||
+ str(k) | ||
+ "}} + {{n}\choose{" | ||
+ str(k) | ||
+ "}} + m\cdot n$$ count?" | ||
) | ||
|
||
answer_options = [ | ||
"The number of ways to choose a subset from a set consisting of $m + n$ elements.", | ||
"The number of ways to choose an ordered pair of {} elements from a set consisting of $m + n$ elements.".format( | ||
k | ||
), | ||
"The number of ways to choose a {}-element subset from a set consisting of $m + n$ elements.".format( | ||
k | ||
), | ||
"None of the above.", | ||
] | ||
for answer in answer_options: | ||
if "-element" in answer: | ||
correct_answer = answer | ||
|
||
# return generated question | ||
return { | ||
"title": "set_theory_question", | ||
"body": question_body, | ||
"bodyFormat": "text", | ||
"pseudocode": "", | ||
"multipleChoiceAnswers": [ | ||
{ | ||
"body": answer_options[0], | ||
"bodyFormat": "mathjax", | ||
"correct": "true", | ||
}, | ||
{ | ||
"body": answer_options[1], | ||
"bodyFormat": "mathjax", | ||
"correct": "false", | ||
}, | ||
{ | ||
"body": correct_answer, | ||
"bodyFormat": "mathjax", | ||
"correct": "false", | ||
}, | ||
{ | ||
"body": answer_options[3], | ||
"bodyFormat": "mathjax", | ||
"correct": "false", | ||
}, | ||
], | ||
} | ||
|
||
|
||
def call(): | ||
return generate_question() | ||
|
||
|
||
print(call()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters