Skip to content

Commit

Permalink
Merge pull request #182 from Arquisoft/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
baraganio authored Apr 28, 2024
2 parents b79f872 + f78283e commit f8a962a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions gatewayservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ RUN npm install --ignore-scripts
# Copy the app source code to the working directory
COPY . .

ARG API_ORIGIN_URI="http://localhost:3000"
ENV REACT_APP_API_ORIGIN_ENDPOINT=$API_ORIGIN_URI

# Define the command to run your app
CMD ["node", "gateway-service.js"]
10 changes: 7 additions & 3 deletions questions/creationservice/creation-service.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const express = require('express');
const mongoose = require('mongoose');
const fetch = require('node-fetch');
const crypto = require('crypto');
const Question = require('./creation-model');

const app = express();
Expand Down Expand Up @@ -37,7 +38,8 @@ function getQuestionInfo(info){

// Select 4 random rows of the data
for (let i = 0; i<optionsNumber; i++){
let indexRow = Math.floor(Math.random() * numEles);
//let indexRow = Math.floor(Math.random() * numEles);
let indexRow = crypto.randomInt(0,numEles);
if(info[indexRow].answerLabel.value.charAt(0)=='Q' || info[indexRow].questionObjectLabel.value.charAt(0)=='Q'){
i = i - 1;
}else{
Expand All @@ -48,14 +50,16 @@ function getQuestionInfo(info){
}

// Select the row where it will extract the country and capital
var indexQuestion = Math.floor(Math.random() * optionsNumber);
//var indexQuestion = Math.floor(Math.random() * optionsNumber);
var indexQuestion = crypto.randomInt(0,optionsNumber);
// Store the country choosen and its capital
questionObject= questions[randomQuerySelector] + fourRows[indexQuestion].questionObjectLabel.value + "?";
correctOption = fourRows[indexQuestion].answerLabel.value;
}

function selectRandomQuery(){
randomQuerySelector = Math.floor(Math.random() * queries.length);
//randomQuerySelector = Math.floor(Math.random() * queries.length);
randomQuerySelector = crypto.randomInt(0,queries.length);
}

async function saveQuestion(){
Expand Down

0 comments on commit f8a962a

Please sign in to comment.