Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

[V3] Validazione in domanda array

  • cesoielampo
  • cesoielampo's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
2 years 9 months ago #217059 by cesoielampo
[V3] Validazione in domanda array was created by cesoielampo
Ciao a tutti,
ho un problema di questo tipo. Ho una domanda array testi che ha 4 colonne: 3 colonne devono ricevere risposte numeriche e la quarta colonna è disabilitata e si attiva solo se nella terza c'è uno specifico valore. Tutto funziona ma ho un dubbio:
  • Se imposto la domanda come obbligatoria, non mi permette di andare avanti anche se fisicamente non posso rispondere alle domande disabilitate.
  • Se non imposto la domanda come obbligatoria, devo lavorare sull'equazione di validazione e anche qui ho due alternative:
    • Se imposto l'equazione di validazione senza prevedere i campi vuoti, il compilatore arriverà alla domanda che è già tutta "rossa" per gli errori
    • dall'altra parte se imposto la validazione tipo:
      Code:
      ((is_empty(self.sq_RIGA1_COL1.NAOK) OR regexMatch('/^\d{1,10}$/', self.sq_RIGA1_COL1.NAOK)) AND (is_empty(self.sq_RIGA1_COL2.NAOK) OR regexMatch('/^\d{1,10}$/', self.sq_RIGA1_COL2.NAOK)) AND (is_empty(self.sq_RIGA1_COL3.NAOK) OR regexMatch('/^\d{1,10}$/', self.sq_RIGA1_COL3.NAOK)) OR (self.sq_RIGA1_COL3.NAOK == 0 AND !is_empty(self.sq_RIGA1_COL4.NAOK))) AND ((is_empty(self.sq_RIGA2_COL1.NAOK) OR regexMatch('/^\d{1,10}$/', self.sq_RIGA2_COL1.NAOK)) AND (is_empty(self.sq_RIGA2_COL2.NAOK) OR regexMatch('/^\d{1,10}$/', self.sq_RIGA2_COL2.NAOK)) AND (is_empty(self.sq_RIGA2_COL3.NAOK) OR regexMatch('/^\d{1,10}$/', self.sq_RIGA2_COL3.NAOK)) OR (self.sq_RIGA2_COL3.NAOK == 0 AND !is_empty(self.sq_RIGA2_COL4.NAOK))) AND ((is_empty(self.sq_RIGA3_COL1.NAOK) OR regexMatch('/^\d{1,10}$/', self.sq_RIGA3_COL1.NAOK)) AND (is_empty(self.sq_RIGA3_COL2.NAOK) OR regexMatch('/^\d{1,10}$/', self.sq_RIGA3_COL2.NAOK)) AND (is_empty(self.sq_RIGA3_COL3.NAOK) OR regexMatch('/^\d{1,10}$/', self.sq_RIGA3_COL3.NAOK)) OR (self.sq_RIGA3_COL3.NAOK == 0 AND !is_empty(self.sq_RIGA3_COL4.NAOK))) AND ((is_empty(self.sq_RIGA4_COL1.NAOK) OR regexMatch('/^\d{1,10}$/', self.sq_RIGA4_COL1.NAOK)) AND (is_empty(self.sq_RIGA4_COL2.NAOK) OR regexMatch('/^\d{1,10}$/', self.sq_RIGA4_COL2.NAOK)) AND (is_empty(self.sq_RIGA4_COL3.NAOK) OR regexMatch('/^\d{1,10}$/', self.sq_RIGA4_COL3.NAOK)) OR (self.sq_RIGA4_COL3.NAOK == 0 AND !is_empty(self.sq_RIGA4_COL4.NAOK))) AND ((is_empty(self.sq_RIGA5_COL1.NAOK) OR regexMatch('/^\d{1,10}$/', self.sq_RIGA5_COL1.NAOK)) AND (is_empty(self.sq_RIGA5_COL2.NAOK) OR regexMatch('/^\d{1,10}$/', self.sq_RIGA5_COL2.NAOK)) AND (is_empty(self.sq_RIGA5_COL3.NAOK) OR regexMatch('/^\d{1,10}$/', self.sq_RIGA5_COL3.NAOK)) OR (self.sq_RIGA5_COL3.NAOK == 0 AND !is_empty(self.sq_RIGA5_COL4.NAOK))) AND ((is_empty(self.sq_RIGA6_COL1.NAOK) OR regexMatch('/^\d{1,10}$/', self.sq_RIGA6_COL1.NAOK)) AND (is_empty(self.sq_RIGA6_COL2.NAOK) OR regexMatch('/^\d{1,10}$/', self.sq_RIGA6_COL2.NAOK)) AND (is_empty(self.sq_RIGA6_COL3.NAOK) OR regexMatch('/^\d{1,10}$/', self.sq_RIGA6_COL3.NAOK)) OR (self.sq_RIGA6_COL3.NAOK == 0 AND !is_empty(self.sq_RIGA6_COL4.NAOK)))
      quei is_empty() possono far bypassare la domanda al compilatore.
C'è un modo per evitare che i campi input disabilitati siano considerati "validi" da LS? Come affrontereste la cosa?

Grazie,
Saluti,

 
The topic has been locked.
More
2 years 9 months ago #217066 by lfanfoni
Replied by lfanfoni on topic [V3] Validazione in domanda array
Io affronterei la cosa evitando sia il Javascript che equazioni di validazione eccessivamente complicate.
Farei due domande array separate con le stesse sottodomande. Nella prima mostrerei solo le prime 3 colonne. Nella seconda metterei solo la quarta colonna, impostando la rilevanza a livello di sottodomanda, in modo da richiedere il quarto valore solo nel caso si verificassero le condizioni che sai tu nella prima domanda array

Se mi vuoi contattare, non mandare messaggi privati qui, bensì scrivi a lfanfoni at gmail.com
Per le livestream in italiano vai su: www.youtube.com/playlist?list=PLOSjjxAG9...SiiCsSz_JxIH7xJwLdPd
Le soluzioni LimeSurvey per l'Italia si trovano su: github.com/lfanfoni
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose