Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Snooze Function #33

Open
benlaman opened this issue Sep 10, 2018 · 1 comment
Open

Android Snooze Function #33

benlaman opened this issue Sep 10, 2018 · 1 comment

Comments

@benlaman
Copy link

I’m trying to have an app stay on a static message screen for 10 minutes if someone indicates a particular answer to a question, then after that time automatically go to another screen. However, no matter what length of time I indicate, the page just blinks for less than a second before continuing on to the next screen.

Here are some relevant lines of code:

  if ( question_index == 1 ) {
        app.snoozeNotif();
        localStore.snoozed = 0;
        app.saveData();        
    }

 if ((current_time - localStore.pause_time) > 600000 || localStore.snoozed == 1) {
        uniqueKey = new Date().getTime();
        localStore.snoozed = 0;

snoozeNotif:function() {
     var now = new Date().getTime(), snoozeDate = new Date(now + 600000);
     var id = '99';
     cordova.plugins.notification.local.schedule({
                                          icon: 'ic_launcher',
                                          id: id,
                                          title: 'Emotions Survey',
                                          text: 'Time to take the survey',
                                          at: snoozeDate,
                                          });
},

@sabrinathai
Copy link
Owner

Hi Ben.

Thanks for your question! I have recently developed a new feature that will do exactly this. However, you would not implement this in the snooze function. This is a new type of question format. The only thing is that it will not automatically advance. The button that participants use to advance to the next screen will show up after 10 minutes. I hope that is okay for the study design you are using.

In the renderQuestion function, you will need to add the following block of code before the penultimate }:

case 'delayInstructions':
        	question.buttons = Mustache.render(instructionTmpl, {id: question.variableName+"1"});
        	$("#question").html(Mustache.render(questionTmpl, question)).fadeIn(400);
        	var instruction = [];
        	$("#question ul li button").hide().delay(600000).show(0).click(function(){
        	    instruction.push(question.variableName);
        		instruction.push($(this).val());
        		app.recordResponse(String(instruction), question_index, question.type);
        	});
        	break;

Then, you implement this in surveyQuestions

                       {
                       "type":"delayInstructions",
                       "variableName":"variableName",
                       "questionPrompt":"Instructions you want to stay on the screen for 10 minutes."                       
                       }, 

Change the values above to reflect what you want.

And then implement your question logic correctly in recordResponse

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants