diff --git a/lessonarc/README.txt b/lessonarc/README.txt new file mode 100644 index 0000000..5cec56d --- /dev/null +++ b/lessonarc/README.txt @@ -0,0 +1,2 @@ +Create a virtual environment and install the packages. +pip install -r requirements.txt diff --git a/lessonarc/app.py b/lessonarc/app.py new file mode 100644 index 0000000..736b60b --- /dev/null +++ b/lessonarc/app.py @@ -0,0 +1,72 @@ +from flask import Flask, render_template, request +import openai +import requests + +# Initialize the Flask app +app = Flask(__name__) + +# Set your OpenAI API key +openai.api_key = "" # Replace with your OpenAI API key + +# Function to generate course material using OpenAI +def generate_course_material(prompt, max_tokens=200, temperature=0.7, n=1): + try: + response = openai.ChatCompletion.create( + model="gpt-3.5-turbo", # Updated to use GPT-3.5 + messages=[{"role": "user", "content": prompt}], + max_tokens=max_tokens, + temperature=temperature, + n=n, + ) + return [choice['message']['content'].strip() for choice in response['choices']] + except Exception as e: + return [f"Error generating content: {str(e)}"] + +# Fetch an image from Unsplash based on the topic +def fetch_image(topic): + access_key = "" # Replace with your Unsplash API access key + url = f"https://api.unsplash.com/photos/random?query={topic}&client_id={access_key}" + response = requests.get(url) + if response.status_code == 200: + return response.json()['urls']['regular'] + return None + +# Generate quiz questions based on the topic +def generate_quiz(topic): + prompt = f"Create a quiz with 5 questions about {topic}." + return generate_course_material(prompt, max_tokens=150, temperature=0.5, n=1) + +# Generate assignments based on the topic +def generate_assignment(topic): + prompt = f"Create an assignment based on {topic}." + return generate_course_material(prompt, max_tokens=150, temperature=0.5, n=1) + +@app.route('/') +def index(): + return render_template('index.html') + +@app.route('/generate', methods=['POST']) +def generate(): + topic = request.form['topic'] + level = request.form['level'] + max_tokens = int(request.form['max_length']) + temperature = float(request.form['temperature']) + num_return_sequences = int(request.form['num_return_sequences']) + + # Prompt to generate advanced course material + prompt = f"Create a detailed course outline on {topic} for {level} level, including an introduction, chapters, and key learning points." + + # Generate course material + content = generate_course_material(prompt, max_tokens, temperature, num_return_sequences) + + # Fetch an image for the topic + image_url = fetch_image(topic) + + # Generate quiz and assignments + quiz = generate_quiz(topic)[0] + assignment = generate_assignment(topic)[0] + + return render_template('result.html', content=content, image_url=image_url, quiz=quiz, assignment=assignment, topic=topic) + +if __name__ == '__main__': + app.run(debug=True) diff --git a/lessonarc/course_content.db b/lessonarc/course_content.db new file mode 100644 index 0000000..084cb8d Binary files /dev/null and b/lessonarc/course_content.db differ diff --git a/lessonarc/requirements.txt b/lessonarc/requirements.txt new file mode 100644 index 0000000..18b5099 --- /dev/null +++ b/lessonarc/requirements.txt @@ -0,0 +1,3 @@ +Flask +openai +Flask-CORS diff --git a/lessonarc/static/style.css b/lessonarc/static/style.css new file mode 100644 index 0000000..216823e --- /dev/null +++ b/lessonarc/static/style.css @@ -0,0 +1,105 @@ +/* Reset some default styles */ +body, h1, h2, h3, p { + margin: 0; + padding: 0; +} + +/* General body styles */ +body { + font-family: 'Arial', sans-serif; + line-height: 1.6; + background-color: #f4f4f4; + color: #333; +} + +/* Main container styles */ +.container { + max-width: 900px; + margin: 20px auto; + padding: 20px; + background: #ffffff; + box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1); + border-radius: 8px; +} + +/* Form styles */ +form { + display: flex; + flex-direction: column; +} + +/* Input styles */ +input[type="text"], +input[type="number"], +select { + padding: 12px; + margin-bottom: 15px; + border: 1px solid #ccc; + border-radius: 4px; +} + +/* Button styles */ +button { + padding: 12px 20px; + background-color: #007bff; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + transition: background-color 0.3s; +} + +button:hover { + background-color: #0056b3; +} + +/* Result section styles */ +.result-section { + margin-top: 20px; +} + +.variation { + margin-bottom: 20px; + padding: 15px; + border: 1px solid #ddd; + border-radius: 4px; + background-color: #f9f9f9; +} + +.result-image { + max-width: 100%; + height: auto; + border-radius: 4px; +} + +/* Quiz and assignment section styles */ +.quiz, .assignment { + background-color: #e9ecef; + padding: 15px; + margin-top: 20px; + border-left: 4px solid #007bff; +} + +/* Footer styles */ +footer { + text-align: center; + margin-top: 40px; + color: #777; +} + +/* Responsive adjustments */ +@media (max-width: 600px) { + .container { + padding: 15px; + } + + input[type="text"], + input[type="number"], + select { + margin-bottom: 10px; + } + + button { + padding: 10px 15px; + } +} diff --git a/lessonarc/templates/index.html b/lessonarc/templates/index.html new file mode 100644 index 0000000..a99bbe8 --- /dev/null +++ b/lessonarc/templates/index.html @@ -0,0 +1,32 @@ + + +
+ + +