Critical Incident Survey

Critical Incident Survey

by Jim Rollo -
Number of replies: 4
Hi Everyone,

I'm using 1.4.2 and I cannot view any response to the "critical incident" surveys.
No matter how many surveys I complete.  The status says no has completed this survey yet.  Any ideas?  BTW all other surveys work fine.

Thanks.
Average of ratings: -
In reply to Jim Rollo

Re: Critical Incident Survey

by leslie nielson -

hi

im having the same problem i did a bit of code cheking and it seems that he doesnt get past this point

// Sort through the data and arrange it
// This is necessary because some of the questions
// may have two answers, eg Question 1 -> 1 and P1

$answers = array();
foreach ($formdata as $key => $val) {     // he doesnt get past this line even though the other surveys do
      if ($key <> "userid" && $key <> "id")
      {
            if ( substr($key,0,1) == "q")
             {
                 $key = substr($key,1); // keep everything but the 'q'
             }
                  if ( substr($key,0,1) == "P")
             {
                 $realkey = substr($key,1);
                  $answers[$realkey][1] = $val;
              } else 
              {
                  $answers[$key][0] = $val;
               }
        }
}

then when he tries to insert the data he wants to insert the value id (gotten from $key) into the question field wich is numeric so he stops the insert and says that the survey is complete.

these are the values for key and val

key=id || val=7
key=69 || val=value for question 1
key=70 || val=value for question 2
key=71 || val=value for question 3
key=72 || val=value for question 4
key=73 || val=value for question 5

you would think that he would go trough the if statement with all values but the first but for some reason he doesent

any help is appreciated

this is on moodle 1.4.4

In reply to leslie nielson

Re: Critical Incident Survey

by L H -

I found this too when I made a custom survey which contained CI style questions and radio (multi) questions.

It spawns from the fact that CI questions do not have a "q" appended to the $formdata array (print_object($formdata) to see) so the above code wont put it into the $answers array.

I found this is to do with the  "survey_print_single" function in survey\lib.php. I altered it slightly by placing a "q" in front of the question and it now saves out answers. I have not been able to break this yet or see any changes in any other questions/survey types except that now CI surveys saves answers.

PS sorry for bumping an old topic blush

 

In reply to L H

Re: Critical Incident Survey

by Skip Marshall -
Would you clarify your modification?  I have a user that is experiencing the same problem with the critical incidents survey.  The other work fine, but this one doesn't save any responses.

Thanks,
In reply to Skip Marshall

Re: Critical Incident Survey

by L H -

HI Skip sure no worries.

In the file: mod/survey/lib.php there is a function called "survey_print_single". It should look like the following:

function survey_print_single($question) {
    GLOBAL $db, $qnum;

    $rowclass = survey_question_rowclass(0);
 
    echo "<br />\n";
    echo "<table align=\"center\" width=\"90%\" cellpadding=\"4\" cellspacing=\"0\">\n";
    echo "<tr class=\"$rowclass\">";
    echo "<td valign=\"top\"><b>$qnum</b></td>";
    echo "<td width=\"50%\" valign=\"top\">$question->text</td>\n";
    echo "<td width=\"50%\" valign=\"top\"><font size=\"+1\">\n";

 if ($question->type == 0) {           // Plain text field

        echo "<textarea rows=\"3\" cols=\"30\" name=\"$question->id\">$question->options</textarea>";

    } else if ...........

I found that the answers were not being saved as the "name=\$question->id" bit did not have the letter q in front of it. I changed the code to:

function survey_print_single($question) {
    GLOBAL $db, $qnum;

    $rowclass = survey_question_rowclass(0);

    echo "<br />\n";
    echo "<table align=\"center\" width=\"90%\" cellpadding=\"4\" cellspacing=\"0\">\n";
    echo "<tr class=\"$rowclass\">";
    echo "<td valign=\"top\"><b>$qnum</b></td>";
    echo "<td width=\"50%\" valign=\"top\">$question->text</td>\n";
    echo "<td width=\"50%\" valign=\"top\"><font size=\"+1\">\n";

 if ($question->type == 0) {           // Plain text field
  
  //added "q" in front of $question->id
  //this is so the answers will be saved to the db
        echo "<textarea rows=\"3\" cols=\"30\" name=\"q$question->id\">$question->options</textarea>";

    } else if ........

I am still unsure as to why this "q" was left off and by looking at the code it is deliberate.

I am not an educational person and as such I do not know the signifigance of this question/survey type. I was hoping that someone with knowledge of the critical incidents would enlighten me but this has not happened.

So please be aware that while adding the "q" there will save the answers and they are displayed properly in the reports I am not sure if there was a reason for omitting this functionality.

HTH smile