refactor: exercise model sort function
This commit is contained in:
parent
3d2697c29b
commit
1732c55d84
|
|
@ -531,7 +531,7 @@ export const createExercises = async (req, res) => {
|
||||||
let generatedTitle = TITLE;
|
let generatedTitle = TITLE;
|
||||||
if (!TITLE) {
|
if (!TITLE) {
|
||||||
lastTitleNumber++;
|
lastTitleNumber++;
|
||||||
generatedTitle = `Soal ${lastTitleNumber}`;
|
generatedTitle = `Question ${lastTitleNumber}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const existingExercise = await models.Exercise.findOne({
|
const existingExercise = await models.Exercise.findOne({
|
||||||
|
|
@ -871,7 +871,14 @@ export const updateExerciseTitle = async (req, res) => {
|
||||||
IS_DELETED: 0,
|
IS_DELETED: 0,
|
||||||
ID_LEVEL,
|
ID_LEVEL,
|
||||||
},
|
},
|
||||||
order: [["TITLE", "ASC"]],
|
order: [
|
||||||
|
[
|
||||||
|
models.Sequelize.literal(
|
||||||
|
"CAST(SUBSTRING_INDEX(TITLE, ' ', -1) AS UNSIGNED)"
|
||||||
|
),
|
||||||
|
"ASC",
|
||||||
|
],
|
||||||
|
],
|
||||||
transaction,
|
transaction,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,14 @@ export const checkFirstFiveCorrect = async (req, res, next) => {
|
||||||
ID_LEVEL: stdLearning.ID_LEVEL,
|
ID_LEVEL: stdLearning.ID_LEVEL,
|
||||||
IS_DELETED: 0,
|
IS_DELETED: 0,
|
||||||
},
|
},
|
||||||
order: [["TITLE", "ASC"]],
|
order: [
|
||||||
|
[
|
||||||
|
models.Sequelize.literal(
|
||||||
|
"CAST(SUBSTRING_INDEX(TITLE, ' ', -1) AS UNSIGNED)"
|
||||||
|
),
|
||||||
|
"ASC",
|
||||||
|
],
|
||||||
|
],
|
||||||
limit: 5,
|
limit: 5,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user