Hi

I'm not sure if I'm doing something wrong but with having the module set to automatically import the answers/surveys is there a way to ensure that all the responded surveys are published (please note I have ensured they have the permission to create the content)? At the moment when a survey is completed it sits in the 'content' section but with published set to 'no'. Is there a way around this? At the moment I need them to be published (yes) to fire a Rule.

Thank you

Stephen

Comments

thedut’s picture

The Limesurvey Sync module already takes care of this : you just have to check the option : Adapt the response status depending on the answer is completed or is being edited. then all your completed answers will be set to published.

spessex’s picture

I just thought I'd add the rule so you might understand. The main reason is that my rule is only firing when I login as Admin and edit and save the content. The rule is meant to fire on any user completing a survey. I've created this rule as I need to create second rule that prevents flagged users from completing the same survey (if you know of a better rule that prevents users from completing the same survey I'm all ears :-))

{ "rules_survey_repeat_block_drupal_survey_test" : {
"LABEL" : "Survey Repeat Block - Drupal Survey Test",
"PLUGIN" : "reaction rule",
"WEIGHT" : "-10",
"REQUIRES" : [ "rules", "flag", "ls_answ" ],
"ON" : [ "ls_answ_sync_completed" ],
"IF" : [
{ "node_is_of_type" : {
"node" : [ "node" ],
"type" : { "value" : { "drupal_test_survey_1" : "drupal_test_survey_1" } }
}
}
],
"DO" : [
{ "flag_flagnode" : {
"flag" : "survey_completed",
"node" : [ "node" ],
"flagging_user" : [ "node:author" ],
"permission_check" : 1
}
},
{ "drupal_message" : {
"message" : "Unfortunately the system has recognised you as having already participated in this survey and in this instance for this survey it will only allow for one submission.\u000D\u000A\u000D\u000AThank you\u000D\u000A\u000D\u000AThe MRFGR Team",
"type" : "warning"
}
}
]
}
}

spessex’s picture

I hadn't noticed the comment in 1 somehow. I'll take a look at this and work it out. Thanks again for your time.

spessex’s picture

I've just taken a look and the 'Adapt the response status depending on the answer is completed or is being edited' was already checked??

spessex’s picture

StatusFileSize
new308.32 KB

See attached screenshot

spessex’s picture

spessex’s picture

StatusFileSize
new97.99 KB

Screen shot of recent survey completion with Publish set to No.

thedut’s picture

I've created this rule as I need to create second rule that prevents flagged users from completing the same survey (if you know of a better rule that prevents users from completing the same survey I'm all ears :-))

Yes ! I know an easier way to do it, without using the Rules module : use the Node Limit module ! Thanks to this module, set 1 answer per user !

spessex’s picture

Yes, I've tried it but it wan't the ideal solution what with the Access Denied page. Not a pretty solution as such (I know it can be changed but I don't think it can be changed on a per instance basis - i.e the 403 page will cover any aspect of a Access Denied page and not just because someone has completed more than 1 survey). Additionally when trying to assign a rule by node:url of the Access Denied page the rule will not fire. Hence why I am hoping that there is reason why the survey responses are not being published (if they were published I could fire the rules).

spessex’s picture

Sorry to be a pain but I'm only a small part away from finishing this part of the project using Lime Sync (which is great and integral to my whole site).

Could you advise on what event the 'Create [survey]' happens upon in respect of rules only I've tried various options to fire a Rule on the basis of this event but nothing appears to be getting recognised i.e. 'Node: Content is viewed', 'Node: Before saving content'. I have even tried to use the URL of the node/add/[survey title] in a Condition (node:url) and even that doesn't appear to get recognised and equates to FALSE.

For your information considering 'Node Limit' is not an ideal solution for me I have the following 3 rules (I have pasted them at the bottom just incase):

1st Rule - After saving saving a 'Create [survey] for that particular user they are 'flagged' for that particular survey.

2nd Rule - Once they are flagged they then receive points for the that particular survey.

3rd Rule (which I can't get to work) - once they have been flagged and try to access the survey again it redirects them to another page and prompts a screen message telling them have been redirected because they have already completed the survey'. This is where the issue lies. I can't get the Rule to fire on an event on creating a 'another/second' survey of the same content type.

Rules Export

1st Rule

{ "rules_surveys_points_drupal_survey_test_2" : {
"LABEL" : "Surveys - Flag - Drupal Survey Test 2",
"PLUGIN" : "reaction rule",
"WEIGHT" : "-10",
"TAGS" : [ "drupal survey test 2", "flag", "surveys" ],
"REQUIRES" : [ "rules", "flag" ],
"ON" : [ "node_insert" ],
"IF" : [
{ "node_is_of_type" : {
"node" : [ "node" ],
"type" : { "value" : { "drupal_test_survey_2" : "drupal_test_survey_2" } }
}
},
{ "AND" : [ ] },
{ "data_is" : { "data" : [ "node:type" ], "value" : "drupal_test_survey_2" } }
],
"DO" : [
{ "flag_flaguser" : {
"flag" : "survey_completed_drupal_test_2",
"user" : [ "node:author" ],
"flagging_user" : [ "node:author" ],
"permission_check" : 1
}
}
]
}
}

2nd Rule

{ "rules_surveys_points_drupal_survey_test_2_" : {
"LABEL" : "Surveys - Points - Drupal Survey Test 2 ",
"PLUGIN" : "reaction rule",
"WEIGHT" : "-9",
"TAGS" : [ "drupal survey test 2", "points", "surveys" ],
"REQUIRES" : [ "rules", "userpoints_rules", "flag" ],
"ON" : [ "flag_flagged_survey_completed_drupal_test_2" ],
"IF" : [
{ "user_has_role" : { "account" : [ "flagged-user" ], "roles" : { "value" : { "6" : "6" } } } }
],
"DO" : [
{ "userpoints_action_grant_points" : {
"user" : [ "flagged-user" ],
"points" : "999",
"tid" : "150280",
"entity" : [ "flagged-user" ],
"description" : "You have been granted 999 points for successfully completing a survey.",
"operation" : "Insert",
"reference" : "999 survey completion reference",
"display" : 1,
"moderate" : "approved"
}
}
]
}
}

3rd Rule (which I cannot to get to work and this is one of several attempts this time using 'LS response is being edited'. Please note I have also tried content is being viewed etc)

{ "rules_survey_block_drupal_test_survey_2" : {
"LABEL" : "Survey - Block - Drupal Test Survey 2",
"PLUGIN" : "reaction rule",
"WEIGHT" : "-8",
"TAGS" : [ "block", "drupal survey test 2", "surveys" ],
"REQUIRES" : [ "rules", "flag", "ls_answ" ],
"ON" : [ "ls_answ_sync_editing" ],
"IF" : [
{ "data_is" : {
"data" : [ "node:url" ],
"value" : "mrfgr2\u002Fnode\u002Fadd\u002Fdrupal-test-survey-2"
}
},
{ "AND" : [ ] },
{ "flag_flagged_user" : {
"flag" : "survey_completed_drupal_test_2",
"user" : [ "site:current-user" ],
"flagging_user" : [ "site:current-user" ]
}
}
],
"DO" : [
{ "drupal_message" : {
"message" : "Sorry but you cannot re-attempt to take this survey has our systems show that you have already completed it. If you have any questions please do not hesitate to contact the the MRFGR Team.",
"type" : "warning"
}
},
{ "redirect" : { "url" : "profile-live_surveys" } }
]
}
}

spessex’s picture

StatusFileSize
new53.67 KB

It's not ideal but I've kind of fiddled together Rule 3 (using Node on save) which is okay...ish. See rule export below. The only minor issue is that it looks like it still creates the survey and displays this to the user which might be a little confusing for them and to the Lime Surveys in terms of surveys responses (I will look into this). See screenshot attached..

{ "rules_survey_block_drupal_test_survey_2" : {
"LABEL" : "Survey - Block - Drupal Test Survey 2",
"PLUGIN" : "reaction rule",
"WEIGHT" : "-8",
"TAGS" : [ "block", "drupal survey test 2", "surveys" ],
"REQUIRES" : [ "rules", "flag" ],
"ON" : [ "node_insert" ],
"IF" : [
{ "node_is_of_type" : {
"node" : [ "node" ],
"type" : { "value" : { "drupal_test_survey_2" : "drupal_test_survey_2" } }
}
},
{ "AND" : [ ] },
{ "flag_flagged_user" : {
"flag" : "survey_completed_drupal_test_2",
"user" : [ "site:current-user" ],
"flagging_user" : [ "site:current-user" ]
}
}
],
"DO" : [
{ "drupal_message" : {
"message" : "Sorry but you cannot re-attempt to take this survey has our systems show that you have already completed it. If you have any questions please do not hesitate to contact the the MRFGR Team.",
"type" : "warning"
}
},
{ "redirect" : { "url" : "profile-live_surveys" } }
]
}
}

spessex’s picture

Scratch that. It's not working. It's somehow not even allowing even one survey to be created now before kicking out and redirecting the user.

thedut’s picture

concerning the third rule :

You should not use the "ls_answ_sync_editing" event : it is fired after the node saving/creating process : that why you met the message : 'the node has been created'. This is not an issue. Here, 'editing' reflects the LimeSurvey answer state, not the Drupal node state.

You should retry using the 'node_presave' event, adding a condition for matching the survey content type.

spessex’s picture

Okay. I will have a go. I'm sure I'll get there in the end!

spessex’s picture

Thanks. I followed up on your suggestion and it looks like I've done it!

Basically there's 4 rules - see below - (they could probably be condensed).

The general gist of it is that it only allows a user to have only 1 attempt at a survey regardless of whether they have been accepted to the survey (not been screened out using LS quotas) and have completed or have been screened out (using afore mentioned LS quotas). Additionally, those that have completed are awarded points and those that have been screened out are not awarded points. Additionally, Node Limit is not required with this system.

My only issue (and it's pretty small), to get the Rule absolutely perfect the only thing it can't do at the moment is allow someone to have another go at the survey if in the occasional instance they have saved/published the survey type but have decided not to continue with it. So technically at the moment this Rule would not allow the user to have another go (because they have saved the content type) even though they have not answered a single question. Is there a way to get Rules to check whether a question on the survey (perhaps the first one) has been answered? Obviously if it hasn't been answered I could then allow the user access to the survey again at some other time?

Additionally in regard to this but what does the Rule ' LS Answer - Response has been completed' actually refer to i.e. how does it fire? I gave it a test to see if it solved my issue above but it didn't do the job.... I'd assumed it worked out to see if a question has been completed or similar?

{ "rules_surveys_points_drupal_survey_test_2" : {
"LABEL" : "Surveys - Flag - Passed - Drupal Survey Test 2",
"PLUGIN" : "reaction rule",
"WEIGHT" : "-10",
"TAGS" : [ "drupal survey test 2", "flag", "surveys" ],
"REQUIRES" : [ "rules", "flag" ],
"ON" : [ "node_insert" ],
"IF" : [
{ "node_is_of_type" : {
"node" : [ "node" ],
"type" : { "value" : { "drupal_test_survey_2" : "drupal_test_survey_2" } }
}
}
],
"DO" : [
{ "flag_flaguser" : {
"flag" : "survey_completed_drupal_test_2",
"user" : [ "node:author" ],
"flagging_user" : [ "node:author" ],
"permission_check" : 1
}
}
]
}
}

{ "rules_survey_points_drupal_test_2" : {
"LABEL" : "Survey - Points - Drupal Test 2",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules", "flag", "userpoints_rules" ],
"ON" : [ "node_view" ],
"IF" : [
{ "data_is" : {
"data" : [ "node:url" ],
"value" : "content\u002Fthank-you-completing-our-drupal-test-survey-2"
}
},
{ "AND" : [ ] },
{ "flag_flagged_user" : {
"flag" : "survey_completed_drupal_test_2",
"user" : [ "site:current-user" ],
"flagging_user" : [ "site:current-user" ]
}
},
{ "AND" : [ ] },
{ "NOT flag_flagged_user" : {
"flag" : "survey_failed_drupal_test_2",
"user" : [ "site:current-user" ],
"flagging_user" : [ "site:current-user" ]
}
}
],
"DO" : [
{ "userpoints_action_grant_points" : {
"user" : [ "site:current-user" ],
"points" : "222",
"tid" : "150280",
"entity" : [ "site:current-user" ],
"description" : "222 points for completing survey",
"operation" : "Insert",
"reference" : "222 reference",
"display" : 1,
"moderate" : "approved"
}
}
]
}
}

{ "rules_surveys_flag_failed_drupal_survey_test_2" : {
"LABEL" : "Surveys - Flag - Failed - Drupal Survey Test 2",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules", "flag" ],
"ON" : [ "node_view" ],
"IF" : [
{ "data_is" : {
"data" : [ "node:url" ],
"value" : "content\u002Fyou-are-not-suitable-drupal-survey-test-2"
}
}
],
"DO" : [
{ "flag_flaguser" : {
"flag" : "survey_failed_drupal_test_2",
"user" : [ "site:current-user" ],
"flagging_user" : [ "site:current-user" ],
"permission_check" : 0
}
}
]
}
}

{ "rules_surveys_block_drupal_survey_test_2" : {
"LABEL" : "Surveys - Block - Drupal Survey Test 2",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules", "flag" ],
"ON" : [ "node_presave" ],
"IF" : [
{ "node_is_of_type" : {
"node" : [ "node" ],
"type" : { "value" : { "drupal_test_survey_2" : "drupal_test_survey_2" } }
}
},
{ "AND" : [ ] },
{ "flag_flagged_user" : {
"flag" : "survey_completed_drupal_test_2",
"user" : [ "site:current-user" ],
"flagging_user" : [ "site:current-user" ]
}
}
],
"DO" : [
{ "drupal_message" : { "message" : "Steve..... you\u0027ve succeeded!!! This user isn\u0027t allowed to the do the survey." } },
{ "redirect" : { "url" : "profile-live_surveys" } }
]
}
}

thedut’s picture

My only issue [...] is allow someone to have another go at the survey if in the occasional instance they have saved/published the survey type but have decided not to continue with it. So technically at the moment this Rule would not allow the user to have another go (because they have saved the content type) even though they have not answered a single question. Is there a way to get Rules to check whether a question on the survey (perhaps the first one) has been answered? Obviously if it hasn't been answered I could then allow the user access to the survey again at some other time?

I suggest to edit your first rule, flagging user only when they have completed the survey and not when they start to fill the survey : Fire the first rule on the even : LS Answer - Response has been completed

thedut’s picture

Status: Active » Closed (works as designed)

I guess this issue is fixed.

thedut’s picture

Issue summary: View changes
Status: Closed (works as designed) » Closed (fixed)

Note : the LimeSurvey Sync 7.x-1.6 release provide a new powerfull support for Rules : 1 new event and 2 new Rules are availables by default : you can custom them with advanced features (as if the answer status is "editing" or "completed"). One allow to limit 1 answer per user and the other one force a connected user to completed its editing answer.
Just enable the install and enable the Rules module, the new rules will be available.