Problem with questionnaire name

Problem with questionnaire name

by Yaniv Cohen -
Number of replies: 10

Hi,

When I set my questionnaire name to a hebrew word  (I guess any non-latin language), I can't change any setting on the 'advanced settings' tab.

The error message is "Could not create a new survey!".

Apart from that, the questionnaire is functioning as usual.

I think it's related to the questionnaire "title" setting on the 'advanced settings' tab.

Can anyone check that?

Thanks!

Yaniv.

Average of ratings: -
In reply to Yaniv Cohen

Re: Problem with questionnaire name

by Yaniv Cohen -
Should I report this as a bug?
In reply to Yaniv Cohen

Re: Problem with questionnaire name

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Not yet, I will conduct some tests first and see if I can fix it. Just be patient.
Joseph
In reply to Yaniv Cohen

Re: Problem with questionnaire name

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hello,
The naming of questionnaire instances is complicated (for historical reasons of its complicated development). There are in fact 2 "names" for a questionnaire instance: the usual module name, which appears in the list of activities, as for all other activities and another name, or "title", which you can change in the Advanced settings tab.
Anyway, before Moodle was fully UTF-8, and as far as I can remamber, it was necessary to use an ASCII character string to save the "survey name" in the database. This is no longer necessary. So, to fix this bug, all we have to do is to remove some string handling in questionnaire/locallib.php. Because it is difficult for me to test this in Hebrew, could you please test it on your local test moodle site and, if you report that it works, then I can fix it for good.
Around line 900, comment out the lines (with /* ... */, as shown below:

// new survey if(empty($this->survey->id)) { if (isset($sdata->name)) { /* $sdata->name = eregi_replace( "[^A-Z0-9]+", "_", trim($sdata->name) ); $sdata->name = ereg_replace('_$',"",$sdata->name);*/ } // create a new survey in the database $fields = array('name','realm','title','subtitle','email','theme','thanks_page','thank_head','thank_body','info'); $record = new Object(); $record->id = 0; $record->owner = $sdata->owner; foreach($fields as $f) { if(isset($sdata->$f)) { $record->$f = $sdata->$f; } } $this->survey->id = insert_record('questionnaire_survey', $record); $this->add_survey($this->survey->id); if(!$this->survey->id) { $tab = "general"; $errstr = get_string('errnewname', 'questionnaire') .' [ : ]'; return(false); } } else { if (isset($sdata->name)) { /* $sdata->name = eregi_replace( "[^A-Z0-9]+", "_", trim($sdata->name) ); $sdata->name = ereg_replace('_$',"",$sdata->name);*/ }
Joseph
In reply to Joseph Rézeau

Re: Problem with questionnaire name

by Yaniv Cohen -

That solved the problem, thanks!

Are you sure you don't want to include the IF line like this:


  /*          if (isset($sdata->name)) {
                $sdata->name = eregi_replace(
                    "[^A-Z0-9]+", "_", trim($sdata->name) );
                $sdata->name = ereg_replace('_$',"",$sdata->name);
            } */

In reply to Yaniv Cohen

Re: Problem with questionnaire name

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Yes of course, the IF statement should be removed completely...
In reply to Joseph Rézeau

Re: Problem with questionnaire name

by Yaniv Cohen -

One more thing.

I think the "Settings saved" confirmation is unnecessary and disturbes questionnaire navigation.

Maybe it should appear on the top of the page, like the confirmation on the moodle administration settings pages.

In reply to Yaniv Cohen

Re: Problem with questionnaire name

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
I don't really understand the problem here. We need a redirect to main Questionnaire View page. The default wait time is 3 seconds. If preferred you can set it at 0 here:
in /mod/questionnaire/qsettings.php line 57:
redirect ($CFG->wwwroot.'/mod/questionnaire/view.php?id='.$questionnaire->cm->id,
get_string('settingssaved', 'questionnaire'),$delay=0);
This will very briefly display the Settings saved message; I do not see how it can disturb navigation and I do not know how to do it otherwise.
Joseph
In reply to Joseph Rézeau

Re: Problem with questionnaire name

by Randy Orwin -
Joseph,

I have found a similar problem even using english as the primary language. This involves a survey that the initial name used contains an apostrophe. In my case I created a survey called "What's my Moodle IQ". When I clicked on the "Advanced settings" tab and then tried to save the settings I got the same error "Could not create a new survey". I went into the mdl_questionnaire_survey table and manually removed the apostrophes and now everything works as advertised. Is this a bug and should I report it, or is it related to the issue that Yaniv was having and will be repaired in the next version?

BTW I am running 1.95 with the newest 1.9 version of the Questionnaire module on a Centos shared host.

Randy
In reply to Randy Orwin

Re: Problem with questionnaire name

by Marc Couture -
We are experiencing the same problem as Randy on our 1.9+ installation of Moodle. The problem occurs with apostrophes (') and quotes (") in questionnaire titles.

Cheers,

Marc C.