Skip to content

Commit

Permalink
Merge pull request #1582 from cayb0rg/question-generation
Browse files Browse the repository at this point in the history
Qset Generator
  • Loading branch information
clpetersonucf authored Oct 2, 2024
2 parents 10c249c + 0c79507 commit 7b4655a
Show file tree
Hide file tree
Showing 31 changed files with 1,321 additions and 44 deletions.
13 changes: 12 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# Only `BOOL_` options become boolean values, and ONLY `true` evaluates to true
#
# Docker/Dev notes:
# docker/config/materia-docker.env.local is loaded instead of .env.local
# docker/.env.local is used instead of .env.local

# GENERAL ===================

Expand Down Expand Up @@ -93,3 +93,14 @@ LTI_KEY="materia-production-lti-key"
#BOOL_LTI_USE_LAUNCH_ROLES=true
#BOOL_LTI_GRACEFUL_CONFIG_FALLBACK=true
#BOOL_LTI_LOG_FOR_DEBUGGING=false

# Question Generation ===

#GENERATION_ENABLED=true
#GENERATION_ALLOW_IMAGES=false
#GENERATION_API_PROVIDER=<MUST_SET>
#GENERATION_API_ENDPOINT=
#GENERATION_API_KEY=
#GENERATION_API_VERSION=
#GENERATION_API_MODEL=
#GENERATION_LOG_STATS=true
7 changes: 7 additions & 0 deletions .github/workflows/test_and_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Create .env.local to satisfy build requirements
run: |
cd docker
if [ ! -f .env.local ]; then
touch .env.local
fi
- name: Build App Image
run: |
cd docker
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public/js/materia.storage.table.js
public/js/student.js
public/js/vendor/*

public/openai_usage.txt

# Installed Widgets
public/widget
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"eher/oauth": "1.0.7",
"aws/aws-sdk-php": "^3.314",
"symfony/dotenv": "^5.1",
"ucfopen/materia-theme-ucf": "2.0.4"
"ucfopen/materia-theme-ucf": "2.0.4",
"openai-php/client": "^0.8.5"
},
"suggest": {
"ext-memcached": "*"
Expand Down
227 changes: 227 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 28 additions & 4 deletions docker/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Database settings
## docker/.env contains environment variables used by Materia during local development
## we do not recommend making edits directly to this file. Instead, make a .env.local in the same directory (docker/) and override the values below as desired.

# database settings
MYSQL_ROOT_PASSWORD=drRoots
MYSQL_USER=materia
MYSQL_PASSWORD=odin
Expand All @@ -12,12 +15,33 @@ DEV_ONLY_AUTH_SIMPLEAUTH_SALT=33e0d379060e3877d634632853c10a70dff9710b751e5af00a
DEV_ONLY_SECRET_CIPHER_KEY=e0beaea1704555ae3c75650703bb106fac24b8967c77a667124fbe745c3346ed

# s3-specific asset storage values
ASSET_STORAGE_DRIVER=s3 # overrides default value in the base .env (which isn't loaded into dev environment)

ASSET_STORAGE_S3_CREDENTIAL_PROVIDER=env # env | imds
# overrides default value in the base .env (which isn't loaded into dev environment)
ASSET_STORAGE_DRIVER=s3
# provider must be one of the following: env | imds
ASSET_STORAGE_S3_CREDENTIAL_PROVIDER=env
ASSET_STORAGE_S3_BUCKET=fake_bucket
ASSET_STORAGE_S3_ENDPOINT=http://fakes3:10001
ASSET_STORAGE_S3_KEY=KEY
ASSET_STORAGE_S3_SECRET=SECRET
# set to true if using real S3 on development
# DEV_ONLY_FAKES3_DISABLED=false

# question generation environment variables. Different variables are required depending on provider.

# DEV_ONLY_FAKES3_DISABLED=false # set to true if using real S3 on development
# required to be true for generation to be enabled
GENERATION_ENABLED=false
# explicitly enable or disable image generation. defaults to false if not provided.
GENERATION_ALLOW_IMAGES=false
# required. provider must be one of the following: openai | azure_openai
GENERATION_API_PROVIDER=openai
# required for both
GENERATION_API_KEY=
# required for azure
GENERATION_API_ENDPOINT=
# required for azure
GENERATION_API_VERSION=
# required for openai
GENERATION_API_MODEL=
# not required. stat logging is set to debug threshold
GENERATION_LOG_STATS=true
11 changes: 3 additions & 8 deletions docker/docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,9 @@ services:
- ./config/nginx/nginx-dev.conf:/etc/nginx/nginx.conf:ro

app:
environment:
# values sourced from docker/env
- ASSET_STORAGE_DRIVER
- ASSET_STORAGE_S3_CREDENTIAL_PROVIDER
- ASSET_STORAGE_S3_BUCKET
- ASSET_STORAGE_S3_ENDPOINT
- ASSET_STORAGE_S3_KEY
- ASSET_STORAGE_S3_SECRET
env_file:
- .env
- .env.local
volumes:
- ..:/var/www/html/
- uploaded_widgets:/var/www/html/public/widget/
Expand Down
1 change: 1 addition & 0 deletions fuel/app/classes/basetest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ protected function make_disposable_widget(string $name = 'TestWidget', bool $res
'is_playable' => true,
'is_editable' => true,
'in_catalog' => true,
'is_generable' => false,
'restrict_publish' => $restrict_publish,
'api_version' => 2,
],
Expand Down
21 changes: 21 additions & 0 deletions fuel/app/classes/controller/qsets.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,25 @@ public function action_import()

return Response::forge($theme->render());
}

public function action_generate()
{
// Validate Logged in
if (\Service_User::verify_session() !== true ) throw new HttpNotFoundException;

$theme = Theme::instance();
$theme->set_template('layouts/react');
$theme->get_template()
->set('title', 'QSet Generation')
->set('page_type', 'generate');

Js::push_inline('var BASE_URL = "'.Uri::base().'";');
Js::push_inline('var WIDGET_URL = "'.Config::get('materia.urls.engines').'";');
Js::push_inline('var STATIC_CROSSDOMAIN = "'.Config::get('materia.urls.static').'";');

Css::push_group(['qset_generator']);
Js::push_group(['react', 'qset_generator']);

return Response::forge($theme->render());
}
}
Loading

0 comments on commit 7b4655a

Please sign in to comment.