npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

survey_management

v1.0.0

Published

This package contains a backend of what would be the logic of a survey management software

Readme

Survey Management

This package contains a backend of what would be the logic of a surveys management software

Usage


const { DataCustomer } = require("./data/DataCustomer");
const { DataCustomerResponses } = require("./data/DataCustomerResponses");
const { DataQuestions } = require("./data/DataQuestions");
const { DataSurvey } = require("./data/DataSurvey");
const { DTOCustomerResponses } = require("./entity/DTOCustomerResponses");
const { DTOSurvey } = require("./entity/DTOSurvey");

#region SURVEY

async function registerSurvey() {

        for (let index = 1; index < 8; index++) {

            let dtosurvey = new DTOSurvey();
            dtosurvey.Title = "Title" + index.toString();
            dtosurvey.Descriptionn = "Description" + index.toString();
            dtosurvey.StartDate = `2023-12-02`;
            dtosurvey.EndDate = `2023-12-19`;

            let registerSurvey = await DataSurvey.registerSurvey(dtosurvey);
            if (registerSurvey===-1) {
               throw new
             Error("The End Date must be higher than Start Date");
              }
                console.log("Survey registered successfully");
        }
    }
    registerSurvey().then()

async function updateSurveyNameDescription() {

  let SurveyID = 5;
  let Title = "TitleUpdate";
  let Descriptionn = "DescriptionnUpdate";

  let updateSurveyNameDescription =
   await DataSurvey.updateSurveyNameDescription(
   SurveyID,Title,Descriptionn);
  if (updateSurveyNameDescription===-1) {
      throw new
       Error("The Survey does not exists");
  }
  console.log("Survey updated successfully");
}
updateSurveyNameDescription().then()


async function updateEndDateSurvey() {


  let SurveyID = 5;
  let EndDate = '2023-12-30';


  let updateEndDateSurvey =
   await DataSurvey.updateEndDateSurvey(SurveyID,EndDate);
  if (updateEndDateSurvey===-1) {
      throw new
       Error("The Survey does not exists");
  }
  if (updateEndDateSurvey===-2) {
      throw new
      Error("The End Date must be higher than Start Date");
  }
  console.log("Survey updated successfully");
}

updateEndDateSurvey().then()




async function getSurveyById() {

  let getSurveyById =
  await DataSurvey.getSurveyById(1);
    if (getSurveyById===-1) {
      throw new
       Error("The Survey does not exists");
  }
  console.log(getSurveyById);
}
getSurveyById().then()



async function getAllSurvey() {

  let getAllSurvey =
  await DataSurvey.getAllSurvey();

  console.log(getAllSurvey);
}
getAllSurvey().then()


async function getActiveSurvey() {

  let getActiveSurvey =
  await DataSurvey.getActiveSurvey();

  console.log(getActiveSurvey);
}
getActiveSurvey().then()



async function getSurveysByDate() {
   let stardate=`2023-11-05`;
   let enddate=`2023-12-20`;
  let getSurveysByDate =
  await DataSurvey.getSurveysByDate(stardate,enddate);

  console.log(getSurveysByDate);
}
getSurveysByDate().then()


async function getCurrentSurveys() {

  let getCurrentSurveys =
  await DataSurvey.getCurrentSurveys();

  console.log(getCurrentSurveys);
}
getCurrentSurveys().then()



async function getFinishedSurveys() {

  let getFinishedSurveys =
  await DataSurvey.getFinishedSurveys();

  console.log(getFinishedSurveys);
}
getFinishedSurveys().then()





#endregion SURVEY

#region QUESTIONS

async function registerQuestions() {

        for (let index = 1; index < 8; index++) {

            let QuestionText="QuestionText"+index.toString();
            let SurveyID=index;

            let registerQuestions = await DataQuestions.registerQuestions(QuestionText,SurveyID);
            if (registerQuestions===-1) {
               throw new
             Error("Survey Not Found");
              }
                console.log("Question registered successfully");
        }
    }
    registerQuestions().then()


async function updateTextQuestion() {

  let QuestionID = 5;
  let QuestionText = "QuestionTextUpdate";
 

  let updateTextQuestion =
   await DataQuestions.updateTextQuestion(
    QuestionID,QuestionText);
  if (updateTextQuestion===-1) {
      throw new
       Error("The Question does not exists");
  }
  console.log("Question updated successfully");
}
updateTextQuestion().then()


async function getQuestionBySurvey() {

  let getQuestionBySurvey =
  await DataQuestions.getQuestionBySurvey(5);

  console.log(getQuestionBySurvey);
}
getQuestionBySurvey().then()

async function getQuestionById() {

    let getQuestionById =
    await DataQuestions.getQuestionById(1);
    if (getQuestionById===-1) {
      throw new
       Error("The Question does not exists");
  }
    console.log(getQuestionById);
  }
  getQuestionById().then()
  
async function getQuestionUnanswered() {

  let getQuestionUnanswered =
  await DataQuestions.getQuestionUnanswered();

  console.log(getQuestionUnanswered);
}
getQuestionUnanswered().then()



#endregion QUESTIONS

#region CUSTOMER

async function registerCustomer() {

        for (let index = 1; index < 8; index++) {

            let Name="CustomerName"+index.toString();
            let Email=`email${index}@gmail.com`;

            let registerCustomer = await DataCustomer.registerCustomer(Name,Email);
            if (registerCustomer===-1) {
                 throw new
                  Error("Incorrect Email");
                 }
             if (registerCustomer===-2) {
                 throw new
                   Error("Email already exists in the system");
                 }
                console.log("Customer registered successfully");
        }
    }
    registerCustomer().then()

       async function updateCustomerEmail() {

        let idcustomer = 5;
        let PhoneCustomer = "[email protected]";

        let updateCustomerEmail =
         await DataCustomer.updateCustomerEmail(idcustomer,PhoneCustomer);
        if (updateCustomerEmail===-1) {
            throw new
             Error("The Customer does not exists");
        }
        if (updateCustomerEmail===-2) {
            throw new
            Error("Incorrect Email");
        }
        if (updateCustomerEmail===-3) {
         throw new
         Error("Email already exists in the system");

        }

        console.log("Customer updated successfully");
    }
    updateCustomerEmail().then()



      async function updateCustomerName() {

        let idcustomer = 1;
        let customername = "CustomerUpdate";

        let updateCustomerName =
         await DataCustomer.updateCustomerName(idcustomer,customername);
        if (updateCustomerName===-1) {
            throw new
             Error("The Customer does not exists");
        }
        console.log("Customer updated successfully");
    }
    updateCustomerName().then()




async function getCustomerById() {

    let getCustomerById =
    await DataCustomer.getCustomerById(1);
    if (getCustomerById===-1) {
      throw new
       Error("The Customer does not exists");
  }
    console.log(getCustomerById);
  }
  getCustomerById().then()
  



async function getCustomerByEmail() {

    let email="[email protected]"

    let getCustomerByEmail =
    await DataCustomer.getCustomerByEmail(email);
   
    console.log(getCustomerByEmail);
  }
  getCustomerByEmail().then()



async function getAllCustomers() {

   

    let getAllCustomers =
    await DataCustomer.getAllCustomers();
   
    console.log(getAllCustomers);
  }
  getAllCustomers().then()




#endregion CUSTOMER


#region  CUSTOMER RESPONSE

async function registerResponse() {

        for (let index = 1; index < 8; index++) {

            let dtoresponse = new DTOCustomerResponses();
            dtoresponse.ResponseText = "ResponseText" + index.toString();
            dtoresponse.QuestionID = index;
            dtoresponse.CustomerID = index;
           

            let registerResponse = await DataCustomerResponses.registerResponse(dtoresponse);
            if (registerResponse===-1) {
               throw new
             Error("Question not exists");
              }
              if (registerResponse===-2) {
                throw new
              Error("Customer not exists");
               }

                console.log("Response registered successfully");
        }
    }
    registerResponse().then()



      async function updateTextResponse() {

      
  let ResponseID = 5;
  let ResponseText = "ResponseTextUpdate";
 

        let updateTextResponse =
         await DataCustomerResponses.updateTextResponse(ResponseID,ResponseText);
        if (updateTextResponse===-1) {
            throw new
             Error("The Response does not exists");
        }
        console.log("Response updated successfully");
    }
    updateTextResponse().then()


async function getResponseById() {

    let getResponseById =
    await DataCustomerResponses.getResponseById(1);
    if (getResponseById===-1) {
      throw new
       Error("The Response does not exists");
  }
    console.log(getResponseById);
  }
  getResponseById().then()




async function getAllRespones() {
    let getAllRespones =
    await DataCustomerResponses.getAllRespones();
   
    console.log(getAllRespones);
  }
  getAllRespones().then()
  
  
async function getResponseByQuestion() {

    let getResponseByQuestion =
    await DataCustomerResponses.getResponseByQuestion(1);
  
    console.log(getResponseByQuestion);
  }
  getResponseByQuestion().then()


#endregion CUSTOMER RESPONSE