Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload container #35

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
76ab05b
create qg service
pelazas Feb 21, 2024
cc77134
make docker image work
pelazas Feb 22, 2024
48faa7a
make sparql query
pelazas Feb 22, 2024
ee6b976
check docker for development
pelazas Feb 22, 2024
235ab8b
First view with register and login button with no style applied yet
carolbgmm Feb 22, 2024
0ba9fd4
Small error in tsconfig.json fixed
carolbgmm Feb 22, 2024
28df9dd
Added jsx:react compiler option to tsconfig.json
carolbgmm Feb 22, 2024
09212df
generate question about population in united states
pelazas Feb 23, 2024
d9bf7b4
organize code
pelazas Feb 23, 2024
e454103
question population spain
pelazas Feb 23, 2024
acfcda9
save questions in db
pelazas Feb 23, 2024
af892d7
endpoint in gateway service
pelazas Feb 23, 2024
2a696ad
tests for population question
pelazas Feb 23, 2024
21890a3
fix test
pelazas Feb 23, 2024
387f3c1
Removed unused imports
carolbgmm Feb 23, 2024
93e3911
Changed test
carolbgmm Feb 23, 2024
2e3be49
I18n of the init, adduser and login views
carolbgmm Feb 25, 2024
3150c61
Small change in test
carolbgmm Feb 26, 2024
43978a3
Tests should be working now
carolbgmm Feb 26, 2024
2098203
NOW all test pass
carolbgmm Feb 26, 2024
6a7c622
Merge pull request #30 from Arquisoft/front-end
carolbgmm Feb 26, 2024
219bf25
add small comments
pelazas Feb 27, 2024
e1328c6
generate chatgpt questions 1
pelazas Feb 27, 2024
f24bd60
generate chatgpt questions 2
pelazas Feb 27, 2024
9b11145
Added questions of spain capitals and countries capitals
UO277274 Feb 27, 2024
c0e27ab
Minor fix(typo loggin instead of login) and gapi,react-google-login d…
UO287741 Feb 27, 2024
4265d21
Google Login Menu, Login Button and Logout Button components created
UO287741 Feb 27, 2024
f4feb5e
Internationalization for login button was missing
UO287741 Feb 27, 2024
a2da5b7
merge with dev
pelazas Feb 28, 2024
7dd7e26
make spain capitals question work
pelazas Feb 28, 2024
abfbd8c
make world capitals work
pelazas Feb 28, 2024
4b6a811
put questions toguether into /game endpoint
pelazas Feb 28, 2024
b37a4ee
add math questions
pelazas Feb 28, 2024
bbd29a7
gateway endpoint
pelazas Feb 28, 2024
75825ca
make tests work
pelazas Feb 28, 2024
085ffb0
fix gateway tests
pelazas Feb 28, 2024
2ddef72
Merge pull request #29 from Arquisoft/questiongenerator1
pelazas Feb 28, 2024
a22b37d
Google Login V1
UO287741 Feb 28, 2024
29dd022
Google Login V2
UO287741 Feb 28, 2024
0ea5e47
Trying to fix dependency issues with react-google-login
UO287741 Feb 28, 2024
e1b0162
Google Login functionality halted temporaly
UO287741 Feb 28, 2024
1b0189e
Merge pull request #34 from Arquisoft/front-end
UO287741 Feb 28, 2024
0fce784
publish image 1
pelazas Feb 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: users/authservice

docker-push-userservice:
name: Push user service Docker Image to GitHub Packages
runs-on: ubuntu-latest
Expand All @@ -93,6 +94,25 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: users/userservice

docker-push-qgservice:
name: Push question generator service Docker Image to GitHub Packages
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: arquisoft/wiq_en2a/qgservice
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: users/qgservice

docker-push-gatewayservice:
name: Push gateway service Docker Image to GitHub Packages
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
coverage
docs/build
docs/build
game/qgservice/.env
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,22 @@ services:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/userdb

questiongeneratorservice:
container_name: qgservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_en2a/qgservice:latest
profiles: ["dev", "prod"]
build: ./game/qgservice
depends_on:
- mongodb
ports:
- "8003:8003"
networks:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/userdb
volumes:
- ./game/qgservice:/usr/src/questiongeneratorservice

gatewayservice:
container_name: gatewayservice-${teamname:-defaultASW}
Expand All @@ -55,6 +71,7 @@ services:
environment:
AUTH_SERVICE_URL: http://authservice:8002
USER_SERVICE_URL: http://userservice:8001
QG_SERVICE_URL: http://qgservice:8003

webapp:
container_name: webapp-${teamname:-defaultASW}
Expand Down
2 changes: 2 additions & 0 deletions game/qgservice/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
coverage
1 change: 1 addition & 0 deletions game/qgservice/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
OPENAI_API_KEY="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"
20 changes: 20 additions & 0 deletions game/qgservice/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use an official Node.js runtime as a parent image
FROM node:20

# Set the working directory in the container
WORKDIR /usr/src/questiongeneratorservice

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

# Install app dependencies
RUN npm install

# Copy the app source code to the working directory
COPY . .

# Expose the port the app runs on
EXPOSE 8003

# Define the command to run your app
CMD ["node", "qg-service.js"]
54 changes: 54 additions & 0 deletions game/qgservice/MathQuestions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const Question4Answers = require("./Question4Answers");

function generateRandomMathQuestion() {
const operators = ['+', '-', '*', '/'];

const operator = operators[Math.floor(Math.random() * operators.length)];
let num1 = Math.floor(Math.random() * 100) + 1;
let num2 = Math.floor(Math.random() * 100) + 1;

// Ensure division results in integers
if (operator === '/' && num2 !== 0) {
const divisionResult = num1 / num2;
num1 = divisionResult * num2; // Adjust num1 to get an integer result
}

const question = `${num1} ${operator} ${num2}`;
const correctAnswer = eval(question).toString();

// Generate incorrect answers
const incorrectAnswers = [];
while (incorrectAnswers.length < 3) {
const randomAnswer = Math.floor(Math.random() * 200) - 100; // Random integer between -100 and 100
if (incorrectAnswers.indexOf(randomAnswer.toString()) === -1 && randomAnswer.toString() !== correctAnswer) {
incorrectAnswers.push(randomAnswer.toString());
}
}

return {
question,
correctAnswer,
incorrectAnswer1: incorrectAnswers[0],
incorrectAnswer2: incorrectAnswers[1],
incorrectAnswer3: incorrectAnswers[2],
};
}

async function saveMathQuestions(numberOfQuestions) {
const questions = [];

for (let i = 0; i < numberOfQuestions; i++) {
const mathQuestion = generateRandomMathQuestion();
questions.push(mathQuestion);
}

try {
const savedQuestions = await Question4Answers.insertMany(questions);
console.log(`${numberOfQuestions} math questions saved to MongoDB:`, savedQuestions);
return questions;
} catch (error) {
console.error('Error saving math questions to MongoDB:', error.message);
}
}

module.exports = { saveMathQuestions };
28 changes: 28 additions & 0 deletions game/qgservice/Question4Answers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const mongoose = require('mongoose');

const question4AnswersSchema = new mongoose.Schema({
question: {
type: String,
required: true,
},
correctAnswer: {
type: String,
required: true,
},
incorrectAnswer1: {
type: String,
required: true,
},
incorrectAnswer2: {
type: String,
required: true,
},
incorrectAnswer3: {
type: String,
required: true,
},
});

const Question4Answers = mongoose.model('Question4Answers', question4AnswersSchema);

module.exports = Question4Answers;
Loading