Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
115 changes: 115 additions & 0 deletions _exam.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
POST http://localhost:3000/api/v1/exam HTTP/1.1
content-type: application/json

{
"moduleId": 1,
"name": "JS X"
}

###
GET http://localhost:3000/api/v1/exam HTTP/1.1
content-type: application/json

###
GET http://localhost:3000/api/v1/exam/6 HTTP/1.1
content-type: application/json

###
PUT http://localhost:3000/api/v1/exam/6 HTTP/1.1
content-type: application/json

{
"moduleId": 1,
"name": "js VI"
}

### Exam closed for editing because it is running
PATCH http://localhost:3000/api/v1/exam/close/6 HTTP/1.1
content-type: application/json

### Exam closed for editing because it is running
DELETE http://localhost:3000/api/v1/exam/6 HTTP/1.1
content-type: application/json

### ######################### QUESTION #########################
###
POST http://localhost:3000/api/v1/question HTTP/1.1
content-type: application/json

{
"examId": 6,
"typeQuestionId": 2,
"code":"q1.1",
"content": "pregunta 41"
}
###
POST http://localhost:3000/api/v1/question HTTP/1.1
content-type: application/json

{
"examId": 6,
"typeQuestionId": 4,
"code":"q1.1",
"content": "pregunta 2",
"minimum": 2,
"tope":50
}
###
GET http://localhost:3000/api/v1/question HTTP/1.1
content-type: application/json

###
GET http://localhost:3000/api/v1/question/107 HTTP/1.1
content-type: application/json

###
PUT http://localhost:3000/api/v1/question/5 HTTP/1.1
content-type: application/json

{
"examId": 3,
"typeQuestionId": 4,
"code":"q1.1",
"content": "Pregunta 2da.",
"minimum": 2,
"tope":50
}

###
DELETE http://localhost:3000/api/v1/question/5 HTTP/1.1
content-type: application/json

### ######################### ANSWER #########################
###
POST http://localhost:3000/api/v1/answer HTTP/1.1
content-type: application/json

{
"questionId": 22,
"content": "red q1",
"code":"a1.1",
"isTrue": 1,
"score": 20
}

###
GET http://localhost:3000/api/v1/answer HTTP/1.1
content-type: application/json

###
GET http://localhost:3000/api/v1/answer/1 HTTP/1.1
content-type: application/json

###
PUT http://localhost:3000/api/v1/answer/1 HTTP/1.1
content-type: application/json

{
"questionId": 3,
"content": "blue",
"code":"a1.1",
"isTrue": 0
}
###
DELETE http://localhost:3000/api/v1/answer/1 HTTP/1.1
content-type: application/json
7 changes: 5 additions & 2 deletions database/migrations/20200830010509-create-exam.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ module.exports = {
moduleId: {
type: Sequelize.INTEGER,
allowNull: false,
references: { model: 'modules', key: 'id' }
},
type: {
type: Sequelize.STRING
},
name_exam: {
name: {
type: Sequelize.STRING,
allowNull: false,
},
publishedAt: {
allowNull: true,
type: Sequelize.DATE
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
Expand Down
9 changes: 5 additions & 4 deletions database/migrations/20200830010511-create-answer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
"use strict";
module.exports = {
up: async(queryInterface, Sequelize) => {
await queryInterface.createTable('answers', {
await queryInterface.createTable("answers", {
id: {
type: Sequelize.INTEGER,
allowNull: false,
Expand All @@ -15,7 +15,8 @@ module.exports = {
questionId: {
type: Sequelize.INTEGER,
allowNull: false,
references: { model: 'questions', key: 'id' }
onDelete: "CASCADE",
references: { model: "questions", key: "id" }
},
content: {
type: Sequelize.STRING
Expand Down Expand Up @@ -45,6 +46,6 @@ module.exports = {
});
},
down: async(queryInterface, Sequelize) => {
await queryInterface.dropTable('answers');
await queryInterface.dropTable("answers");
}
};
8 changes: 4 additions & 4 deletions database/seeders/20200828135836-exams.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ module.exports = {
up: async(queryInterface, Sequelize) => {

let obj = [
{ moduleId: 1, type: '1', name_exam: faker.name.findName(), createdAt: new Date(), updatedAt: new Date() },
{ moduleId: 1, type: '1', name_exam: faker.name.findName(), createdAt: new Date(), updatedAt: new Date() },
{ moduleId: 1, type: '1', name_exam: faker.name.findName(), createdAt: new Date(), updatedAt: new Date() },
{ moduleId: 1, type: '1', name_exam: faker.name.findName(), createdAt: new Date(), updatedAt: new Date() },
{ id: 1, moduleId: 1, type: '1', name: faker.name.findName(), createdAt: new Date(), updatedAt: new Date() },
{ id: 2, moduleId: 1, type: '1', name: faker.name.findName(), createdAt: new Date(), updatedAt: new Date() },
{ id: 3, moduleId: 1, type: '1', name: faker.name.findName(), createdAt: new Date(), updatedAt: new Date() },
{ id: 4, moduleId: 1, type: '1', name: faker.name.findName(), createdAt: new Date(), updatedAt: new Date() },
];
await queryInterface.bulkInsert('exams', obj, {});
},
Expand Down
8 changes: 4 additions & 4 deletions database/seeders/20200830142608-type_questions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ const faker = require('faker');
module.exports = {
up: async(queryInterface, Sequelize) => {
let data = [
{ type_question: '1', content: 'abierta', createdAt: new Date(), updatedAt: new Date() },
{ type_question: '2', content: 'cerrada', createdAt: new Date(), updatedAt: new Date() },
{ type_question: '3', content: 'multiple', createdAt: new Date(), updatedAt: new Date() },
{ type_question: '4', content: 'numerica', createdAt: new Date(), updatedAt: new Date() },
{ id: 1, type_question: '1', content: 'abierta', createdAt: new Date(), updatedAt: new Date() },
{ id: 2, type_question: '2', content: 'cerrada', createdAt: new Date(), updatedAt: new Date() },
{ id: 3, type_question: '3', content: 'multiple', createdAt: new Date(), updatedAt: new Date() },
{ id: 4, type_question: '4', content: 'numerica', createdAt: new Date(), updatedAt: new Date() },
];

await queryInterface.bulkInsert('type_questions', data, {});
Expand Down
21 changes: 9 additions & 12 deletions database/seeders/20200830142733-questions.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
'use strict';
const faker = require('faker');
"use strict";
const faker = require("faker");
module.exports = {
up: async(queryInterface, Sequelize) => {
let obj = [
{ examId: 1, typeQuestionId: 1, code: 'p1', content: faker.name.findName(), minimum: 9, length: 100, createdAt: new Date(), updatedAt: new Date() },
{ examId: 1, typeQuestionId: 1, code: 'p2', content: faker.name.findName(), minimum: 1, length: 100, createdAt: new Date(), updatedAt: new Date() },
{ examId: 1, typeQuestionId: 2, code: 'p3', content: faker.name.findName(), createdAt: new Date(), updatedAt: new Date() },
{ examId: 1, typeQuestionId: 2, code: 'p4', content: faker.name.findName(), createdAt: new Date(), updatedAt: new Date() },
{ examId: 1, typeQuestionId: 3, code: 'p5', content: faker.name.findName(), createdAt: new Date(), updatedAt: new Date() },
{ examId: 1, typeQuestionId: 3, code: 'p6', content: faker.name.findName(), createdAt: new Date(), updatedAt: new Date() },
{ examId: 1, typeQuestionId: 4, code: 'p7', content: faker.name.findName(), minimum: 1, tope: 100, createdAt: new Date(), updatedAt: new Date() },
{ examId: 1, typeQuestionId: 4, code: 'p8', content: faker.name.findName(), minimum: 1, tope: 100, createdAt: new Date(), updatedAt: new Date() },
{ examId: 1, typeQuestionId: 1, code: "p1", content: faker.name.findName(), minimum: 10, length: 100, createdAt: new Date(), updatedAt: new Date() },
{ examId: 1, typeQuestionId: 2, code: "p2", content: faker.name.findName(), createdAt: new Date(), updatedAt: new Date() },
{ examId: 1, typeQuestionId: 3, code: "p3", content: faker.name.findName(), createdAt: new Date(), updatedAt: new Date() },
{ examId: 1, typeQuestionId: 4, code: "p4", content: faker.name.findName(), minimum: 10, tope: 100, createdAt: new Date(), updatedAt: new Date() },
{ examId: 1, typeQuestionId: 4, code: "p5", content: faker.name.findName(), minimum: 10, tope: 100, createdAt: new Date(), updatedAt: new Date() },
];
await queryInterface.bulkInsert('questions', obj, {});
await queryInterface.bulkInsert("questions", obj, {});
},

down: async(queryInterface, Sequelize) => {
await queryInterface.bulkDelete('questions', null, {});
await queryInterface.bulkDelete("questions", null, {});
}
};
29 changes: 11 additions & 18 deletions database/seeders/20200830142801-answers.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
'use strict';
const faker = require('faker');
"use strict";
const faker = require("faker");

module.exports = {
up: async(queryInterface, Sequelize) => {
let obj = [
{ code: 'rta31', questionId: 3, content: faker.name.findName(), isTrue: 0, score: 0, createdAt: new Date(), updatedAt: new Date() },
{ code: 'rta32', questionId: 3, content: faker.name.findName(), isTrue: 0, score: 0, createdAt: new Date(), updatedAt: new Date() },
{ code: 'rta33', questionId: 3, content: faker.name.findName(), isTrue: 1, score: 10, createdAt: new Date(), updatedAt: new Date() },
{ code: 'rta41', questionId: 4, content: faker.name.findName(), isTrue: 0, score: 0, createdAt: new Date(), updatedAt: new Date() },
{ code: 'rta42', questionId: 4, content: faker.name.findName(), isTrue: 1, score: 10, createdAt: new Date(), updatedAt: new Date() },
{ code: 'rta43', questionId: 4, content: faker.name.findName(), isTrue: 0, score: 0, createdAt: new Date(), updatedAt: new Date() },
{ code: 'rta51', questionId: 5, content: faker.name.findName(), isTrue: 1, score: 5, createdAt: new Date(), updatedAt: new Date() },
{ code: 'rta52', questionId: 5, content: faker.name.findName(), isTrue: 0, score: 0, createdAt: new Date(), updatedAt: new Date() },
{ code: 'rta53', questionId: 5, content: faker.name.findName(), isTrue: 1, score: 5, createdAt: new Date(), updatedAt: new Date() },
{ code: 'rta61', questionId: 6, content: faker.name.findName(), isTrue: 1, score: 5, createdAt: new Date(), updatedAt: new Date() },
{ code: 'rta62', questionId: 6, content: faker.name.findName(), isTrue: 1, score: 5, createdAt: new Date(), updatedAt: new Date() },
{ code: 'rta63', questionId: 6, content: faker.name.findName(), isTrue: 1, score: 5, createdAt: new Date(), updatedAt: new Date() },
{ code: 'rta7', questionId: 7, content: '70', isTrue: 1, score: 10, createdAt: new Date(), updatedAt: new Date() },
{ code: 'rta8', questionId: 8, content: '17', isTrue: 1, score: 10, createdAt: new Date(), updatedAt: new Date() },
{ code: "rta21", questionId: 2, content: faker.name.findName(), isTrue: 0, score: 0, createdAt: new Date(), updatedAt: new Date() },
{ code: "rta22", questionId: 2, content: faker.name.findName(), isTrue: 0, score: 0, createdAt: new Date(), updatedAt: new Date() },
{ code: "rta23", questionId: 2, content: faker.name.findName(), isTrue: 1, score: 10, createdAt: new Date(), updatedAt: new Date() },
{ code: "rta31", questionId: 3, content: faker.name.findName(), isTrue: 1, score: 5, createdAt: new Date(), updatedAt: new Date() },
{ code: "rta32", questionId: 3, content: faker.name.findName(), isTrue: 0, score: 0, createdAt: new Date(), updatedAt: new Date() },
{ code: "rta33", questionId: 3, content: faker.name.findName(), isTrue: 1, score: 5, createdAt: new Date(), updatedAt: new Date() },
{ code: "rta42", questionId: 5, content: "70", isTrue: 1, score: 10, createdAt: new Date(), updatedAt: new Date() },
];
await queryInterface.bulkInsert('answers', obj, {});
await queryInterface.bulkInsert("answers", obj, {});
},

down: async(queryInterface, Sequelize) => {
await queryInterface.bulkDelete('answers', null, {});
await queryInterface.bulkDelete("answers", null, {});
}
};
20 changes: 8 additions & 12 deletions database/seeders/20200830142900-student_answers.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
'use strict';
const faker = require('faker');
"use strict";
const faker = require("faker");

module.exports = {
up: async(queryInterface, Sequelize) => {
let obj = [

{ examId: 1, questionId: 1, typeQuestionId: 1, studentId: 1, date_of_answer: new Date(), code_answer: '0', student_answer: faker.name.findName(), createdAt: new Date(), updatedAt: new Date() },
{ examId: 1, questionId: 2, typeQuestionId: 1, studentId: 1, date_of_answer: new Date(), code_answer: '0', student_answer: faker.name.findName(), createdAt: new Date(), updatedAt: new Date() },
{ examId: 1, questionId: 3, typeQuestionId: 2, studentId: 1, date_of_answer: new Date(), code_answer: 'id1,cod1', student_answer: 'content 1', createdAt: new Date(), updatedAt: new Date() },
{ examId: 1, questionId: 4, typeQuestionId: 2, studentId: 1, date_of_answer: new Date(), code_answer: 'id2,cod2', student_answer: 'content 2', createdAt: new Date(), updatedAt: new Date() },
{ examId: 1, questionId: 5, typeQuestionId: 3, studentId: 1, date_of_answer: new Date(), code_answer: 'id1,cod1;id2,cod2', student_answer: 'content 1;content 2', createdAt: new Date(), updatedAt: new Date() },
{ examId: 1, questionId: 6, typeQuestionId: 3, studentId: 1, date_of_answer: new Date(), code_answer: 'id1,cod1;id2,cod2', student_answer: 'content 1;content 2', createdAt: new Date(), updatedAt: new Date() },
{ examId: 1, questionId: 7, typeQuestionId: 4, studentId: 1, date_of_answer: new Date(), code_answer: '0', student_answer: faker.random.number(), createdAt: new Date(), updatedAt: new Date() },
{ examId: 1, questionId: 8, typeQuestionId: 4, studentId: 1, date_of_answer: new Date(), code_answer: '0', student_answer: faker.random.number(), createdAt: new Date(), updatedAt: new Date() },
{ examId: 1, questionId: 1, typeQuestionId: 1, studentId: 1, date_of_answer: new Date(), code_answer: "0", student_answer: faker.name.findName(), createdAt: new Date(), updatedAt: new Date() },
{ examId: 1, questionId: 2, typeQuestionId: 2, studentId: 1, date_of_answer: new Date(), code_answer: "id2,cod2", student_answer: "content 2", createdAt: new Date(), updatedAt: new Date() },
{ examId: 1, questionId: 3, typeQuestionId: 3, studentId: 1, date_of_answer: new Date(), code_answer: "id1,cod1;id2,cod2", student_answer: "content 1;content 2", createdAt: new Date(), updatedAt: new Date() },
{ examId: 1, questionId: 4, typeQuestionId: 4, studentId: 1, date_of_answer: new Date(), code_answer: "0", student_answer: faker.random.number(), createdAt: new Date(), updatedAt: new Date() },
];
await queryInterface.bulkInsert('student_answers', obj, {});
await queryInterface.bulkInsert("student_answers", obj, {});
},

down: async(queryInterface, Sequelize) => {
await queryInterface.bulkDelete('student_answers', null, {});
await queryInterface.bulkDelete("student_answers", null, {});
}
};
6 changes: 3 additions & 3 deletions database/seeders/20200830142910-student_exams.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';
"use strict";

module.exports = {
up: async(queryInterface, Sequelize) => {
Expand All @@ -8,10 +8,10 @@ module.exports = {
{ studentId: 1, examId: 3, createdAt: new Date(), updatedAt: new Date() },
{ studentId: 1, examId: 4, createdAt: new Date(), updatedAt: new Date() },
];
await queryInterface.bulkInsert('student_exams', obj, {});
await queryInterface.bulkInsert("student_exams", obj, {});
},

down: async(queryInterface, Sequelize) => {
await queryInterface.bulkDelete('student_exams', null, {});
await queryInterface.bulkDelete("student_exams", null, {});
}
};
2 changes: 1 addition & 1 deletion src/api/routes/answers.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ router.post("/", validator(AnswerService.validate()), AnswerController.createAns
router.get("/:id", AnswerController.getAnswer);
router.get("/question/:questionId", AnswerController.getByQuestion);
router.delete("/:id", AnswerController.deleteAnswer);
router.put("/:id", AnswerController.updateAnswer);
router.put("/:id", validator(AnswerService.validate()), AnswerController.updateNormal);
router.get("/", AnswerController.listAll);

module.exports = router;
4 changes: 4 additions & 0 deletions src/api/routes/exams.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ const ExamService = require("../../services/examService");
const { validator } = require("../middlewares/validator");

router.post("/", validator(ExamService.validate()), ExamController.createExam);
router.get("/", ExamController.getAll);
router.get("/:id", ExamController.getExamComplet);
router.put("/:id", ExamController.updateNormal);
router.patch("/close/:id", ExamController.close);
router.delete("/:id", ExamController.delete);

module.exports = router;

Expand Down
3 changes: 3 additions & 0 deletions src/api/routes/questions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const QuestionService = require("../../services/questionService");
const { validator } = require("../middlewares/validator");

router.post("/", validator(QuestionService.validate()), QuestionController.createQuestion);
router.get("/", QuestionController.getAll);
router.get("/:id", QuestionController.getQuestion);
router.put("/:id", validator(QuestionService.validate()), QuestionController.updateQuestion);
router.delete("/:id", QuestionController.delete);

module.exports = router;
Loading