From c73e69fd30b84824cc115c9be9a679773dac086a Mon Sep 17 00:00:00 2001 From: Shibily-kms Date: Mon, 15 May 2023 20:31:52 +0530 Subject: [PATCH] var change to Const --- controllers/admin/group-controller.js | 18 +++++++++--------- controllers/admin/items-controller.js | 2 +- controllers/admin/mark-controller.js | 10 +++++----- controllers/admin/result-controller.js | 20 ++++++++++---------- controllers/group/item-controller.js | 2 +- controllers/group/notification-controller.js | 2 +- controllers/group/students-controller.js | 8 ++++---- controllers/user/result-controller.js | 8 ++++---- helpers/event-helpers.js | 4 ++-- helpers/mark-helpers.js | 4 ++-- helpers/user-helpers.js | 12 ++++++------ package.json | 2 +- routes/group.js | 4 ++-- 13 files changed, 48 insertions(+), 48 deletions(-) diff --git a/controllers/admin/group-controller.js b/controllers/admin/group-controller.js index ca9176d..6bd9380 100644 --- a/controllers/admin/group-controller.js +++ b/controllers/admin/group-controller.js @@ -35,8 +35,8 @@ const getGroupViewPage = async (req, res) => { } const getGroupStudentsList = async (req, res) => { - var Event = req.session.event - var GroupId = req.params.GroupId + const Event = req.session.event + const GroupId = req.params.GroupId let GroupDetails = await groupHelpers.getGroupDetails(GroupId, Event.EventId) let Category = req.params.Category let EventLimit = await itemHelpers.findOneItemInCategory(Event.EventId, Category) @@ -51,7 +51,7 @@ const getGroupStudentsList = async (req, res) => { } const getAddStudentPage = async (req, res) => { - var Event = req.session.event + const Event = req.session.event let GroupDetails = await groupHelpers.getGroupDetails(req.params.GroupId, Event.EventId) let Category = req.params.Category @@ -93,9 +93,9 @@ const postAddStudent = async (req, res) => { } const deleteStudent = (req, res) => { - var EventId = req.session.event.EventId - var GroupId = req.params.GroupId - var Category = req.params.Category + const EventId = req.session.event.EventId + const GroupId = req.params.GroupId + const Category = req.params.Category let ChestNo = req.params.ChestNo studentHelpers.removeStudent(EventId, GroupId, ChestNo, Category).then((response) => { res.redirect('/event/' + EventId + '/groups/' + GroupId + '/' + Category + '/students') @@ -127,9 +127,9 @@ const getStudentsEventPage = async (req, res) => { } const deleteItemFormStudent = async (req, res) => { - var EventId = req.session.event.EventId - var GroupId = req.params.GroupId - var Category = req.params.Category + const EventId = req.session.event.EventId + const GroupId = req.params.GroupId + const Category = req.params.Category let ChestNo = req.params.ChestNo let ItemId = req.params.ItemId diff --git a/controllers/admin/items-controller.js b/controllers/admin/items-controller.js index d43f91a..38e97ac 100644 --- a/controllers/admin/items-controller.js +++ b/controllers/admin/items-controller.js @@ -47,7 +47,7 @@ const getAddItemPage = async (req, res) => { const Event = req.session.event const Category = req.params.Category const SubCategory = req.params.SubCategory - var pointCategoryOptions = await eventHelpers.getPointCategoryOptions(Event.EventId) + const pointCategoryOptions = await eventHelpers.getPointCategoryOptions(Event.EventId) if (req.session.Success) { res.render('event/items/add-item', { diff --git a/controllers/admin/mark-controller.js b/controllers/admin/mark-controller.js index 6648f36..feb19a4 100644 --- a/controllers/admin/mark-controller.js +++ b/controllers/admin/mark-controller.js @@ -80,11 +80,11 @@ const getAddGroupMarkPage = async (req, res) => { } const postAddGroupMarkPage = (req, res) => { - var Event = req.session.event - var Category = req.params.Category - var SubCategory = req.params.SubCategory - var ItemId = req.params.ItemId - var ItemName = req.params.ItemName + const Event = req.session.event + const Category = req.params.Category + const SubCategory = req.params.SubCategory + const ItemId = req.params.ItemId + const ItemName = req.params.ItemName markHelpers.addGroupMark(req.body, Event.EventId, Category, SubCategory, ItemId).then(() => { res.redirect('/event/' + Event.EventId + '/mark/' + Category + '-' + SubCategory + '/Group/' + ItemId + '-' + ItemName + '/add-mark') diff --git a/controllers/admin/result-controller.js b/controllers/admin/result-controller.js index c5baaf7..a7f66f4 100644 --- a/controllers/admin/result-controller.js +++ b/controllers/admin/result-controller.js @@ -28,7 +28,7 @@ const getCategoryBaisePublishedStatus = async (req, res) => { const getItemBaiseResultPage = async (req, res) => { let Event = req.session.event - var ItemCategorys = await itemHelpers.getAllItemCategory(Event.EventId) + const ItemCategorys = await itemHelpers.getAllItemCategory(Event.EventId) res.render('event/result/item-baise', { title: Event.Name, eventHeader: true, Event, createAccout: true, adminHeader: true, @@ -44,9 +44,9 @@ const searchItemBaise = (req, res) => { const getItemBaiseSubPage = async (req, res) => { let Event = req.session.event - var Category = req.params.Category - var SubCategory = req.params.SubCategory - var allItems = await itemHelpers.getAllItems(Event.EventId, Category, SubCategory) + const Category = req.params.Category + const SubCategory = req.params.SubCategory + const allItems = await itemHelpers.getAllItems(Event.EventId, Category, SubCategory) res.render('event/result/category-item', { title: Event.Name, eventHeader: true, Event, createAccout: true, adminHeader: true, SubCategory, Category, @@ -83,8 +83,8 @@ const getItemBaiseGroupStudents = async (req, res) => { } const getStudentBaiseResultPage = async (req, res) => { - var Event = req.session.event - var AllGroups = await groupHelpers.getAllGroups(Event.EventId) + const Event = req.session.event + const AllGroups = await groupHelpers.getAllGroups(Event.EventId) res.render('event/result/student-baise', { title: Event.Name, eventHeader: true, Event, createAccout: true, adminHeader: true, AllGroups }) } @@ -106,8 +106,8 @@ const getStudentBaiseSubPage = async (req, res) => { } const getStudentBaiseList = async (req, res) => { - var Event = req.session.event - var GroupId = req.params.GroupId + const Event = req.session.event + const GroupId = req.params.GroupId let GroupDetails = await groupHelpers.getGroupDetails(GroupId, Event.EventId) let Category = req.params.Category let AllStudents = await studentHelpers.getAllStudentsInGroup(Event.EventId, GroupId, Category) @@ -119,8 +119,8 @@ const getStudentBaiseList = async (req, res) => { } const getStudentBaiseItems = async (req, res) => { - var Event = req.session.event - var GroupId = req.params.GroupId + const Event = req.session.event + const GroupId = req.params.GroupId let Category = req.params.Category let ChestNo = req.params.ChestNo let GroupDetails = await groupHelpers.getGroupDetails(GroupId, Event.EventId) diff --git a/controllers/group/item-controller.js b/controllers/group/item-controller.js index 51e6cf5..8a5ef09 100644 --- a/controllers/group/item-controller.js +++ b/controllers/group/item-controller.js @@ -48,7 +48,7 @@ const getItemStudents = async (req, res) => { let SubCategory = req.params.SubCategory let ItemId = req.params.ItemId let ItemName = req.params.ItemName - var Event = await eventHelpers.getEventDetails(Group.EventId) + const Event = await eventHelpers.getEventDetails(Group.EventId) let ItemStudents = await itemHelpers.getItemStudentsFromOneGroup(Group.EventId, Group.GroupId, ItemId) let GroupDetails = await groupHelpers.getGroupDetails(Group.GroupId, Group.EventId) if (req.session.Success) { diff --git a/controllers/group/notification-controller.js b/controllers/group/notification-controller.js index 1b09a77..03d0d87 100644 --- a/controllers/group/notification-controller.js +++ b/controllers/group/notification-controller.js @@ -45,7 +45,7 @@ const readAllNotifi = (req, res) => { const viewNotifi = async (req, res) => { let Group = req.session.group - var EventDetails = await eventHelpers.getEventDetails(Group.EventId) + const EventDetails = await eventHelpers.getEventDetails(Group.EventId) let MessageId = req.params.MessageId let Message = await notificationHelpers.getOneMessage(Group.EventId, Group.GroupId, MessageId) res.render('group/notifi/view-notification', { diff --git a/controllers/group/students-controller.js b/controllers/group/students-controller.js index d520f01..8e60dc0 100644 --- a/controllers/group/students-controller.js +++ b/controllers/group/students-controller.js @@ -88,7 +88,7 @@ const getStudentViewpage = async (req, res) => { let Category = req.params.Category let Group = req.session.group let ChestNo = req.params.ChestNo - var Event = await eventHelpers.getEventDetails(Group.EventId) + const Event = await eventHelpers.getEventDetails(Group.EventId) let Student = await studentHelpers.getOneStudentItems(Group.EventId, ChestNo) let EventLimit = await itemHelpers.findOneItemInCategory(Group.EventId, Category) @@ -142,8 +142,8 @@ const postStudentEditPage = (req, res) => { }) } const deleteStudent = (req, res) => { - var Group = req.session.group - var Category = req.params.Category + const Group = req.session.group + const Category = req.params.Category let ChestNo = req.params.ChestNo studentHelpers.removeStudent(Group.EventId, Group.GroupId, ChestNo, Category).then((response) => { res.redirect('/group/students/' + Category) @@ -151,7 +151,7 @@ const deleteStudent = (req, res) => { } const getStudentWithOutItem = async (req, res) => { - var Group = req.session.group + const Group = req.session.group studentHelpers.GroupBaiseStudentWithOutItems(Group.EventId, Group.GroupId).then((Students) => { res.render('group/students/student-without-item', { title: Group.GroupName, group: true, groupHeader: true, Group, Students }) }) diff --git a/controllers/user/result-controller.js b/controllers/user/result-controller.js index 1e14c61..8ee809c 100644 --- a/controllers/user/result-controller.js +++ b/controllers/user/result-controller.js @@ -92,8 +92,8 @@ const getStudentBaiseSubPage = async (req, res) => { } const getStudentBaiseList = async (req, res) => { - var eventDetails = req.session.e - var GroupId = req.params.GroupId + const eventDetails = req.session.e + const GroupId = req.params.GroupId let GroupDetails = await groupHelpers.getGroupDetails(GroupId, eventDetails.EventId) let Category = req.params.Category let AllStudents = await studentHelpers.getAllStudentsInGroup(eventDetails.EventId, GroupId, Category) @@ -103,8 +103,8 @@ const getStudentBaiseList = async (req, res) => { } const getStudentBaiseItems = async (req, res) => { - var eventDetails = req.session.e - var GroupId = req.params.GroupId + const eventDetails = req.session.e + const GroupId = req.params.GroupId let Category = req.params.Category let ChestNo = req.params.ChestNo let GroupDetails = await groupHelpers.getGroupDetails(GroupId, eventDetails.EventId) diff --git a/helpers/event-helpers.js b/helpers/event-helpers.js index 5f34622..f2eb238 100644 --- a/helpers/event-helpers.js +++ b/helpers/event-helpers.js @@ -1,5 +1,5 @@ -var db = require('../config/db') -var collection = require('../config/collections') +const db = require('../config/db') +const collection = require('../config/collections') const bcrypt = require('bcrypt') const { createRandomId } = require('./function-helpers') diff --git a/helpers/mark-helpers.js b/helpers/mark-helpers.js index 03e1520..23b0154 100644 --- a/helpers/mark-helpers.js +++ b/helpers/mark-helpers.js @@ -1,5 +1,5 @@ -var db = require('../config/db') -var collection = require('../config/collections') +const db = require('../config/db') +const collection = require('../config/collections') const eventHelpers = require('./event-helpers'); const studentHelpers = require('./student-helpers'); const itemHelpers = require('./item-helpers'); diff --git a/helpers/user-helpers.js b/helpers/user-helpers.js index dc09145..f0919e8 100644 --- a/helpers/user-helpers.js +++ b/helpers/user-helpers.js @@ -1,5 +1,5 @@ -var db = require('../config/db') -var collection = require('../config/collections') +const db = require('../config/db') +const collection = require('../config/collections') module.exports = { @@ -45,10 +45,10 @@ module.exports = { } else { let searchValue = body.searchValue; - var myPattern = new RegExp('(\\w*' + searchValue + '\\w*)', 'gi'); + const myPattern = new RegExp('(\\w*' + searchValue + '\\w*)', 'gi'); for (let b = 0; b < AllStudents.length; b++) { - var Group = await db.get().collection(collection.GROUP_COLLECTION).findOne({ FestId: body.FestId, GroupId: AllStudents[b].GroupId }) + const Group = await db.get().collection(collection.GROUP_COLLECTION).findOne({ FestId: body.FestId, GroupId: AllStudents[b].GroupId }) let searchName = AllStudents[b].FullName.split(/\s/) let NameString = null @@ -57,8 +57,8 @@ module.exports = { NameString = searchName[c].slice(0, searchValue.length).match(myPattern) } } - var searchChestNo = AllStudents[b].ChestNo.slice(0, searchValue.length).match(myPattern); - var searchCIC = AllStudents[b].CicNo.slice(0, searchValue.length).match(myPattern); + const searchChestNo = AllStudents[b].ChestNo.slice(0, searchValue.length).match(myPattern); + const searchCIC = AllStudents[b].CicNo.slice(0, searchValue.length).match(myPattern); let student = {} student.GroupName = Group.GroupName diff --git a/package.json b/package.json index 8861c76..bec521a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "event", - "version": "2.1.2", + "version": "2.1.", "private": true, "scripts": { "start": "nodemon ./bin/www" diff --git a/routes/group.js b/routes/group.js index afe2424..79197f2 100644 --- a/routes/group.js +++ b/routes/group.js @@ -1,5 +1,5 @@ -var express = require('express'); -var router = express.Router(); +const express = require('express'); +const router = express.Router(); const { verifyGroupLogin } = require('../middleware/verify-middleware')