poetos / moodle-mod_questionnaire Goto Github PK
View Code? Open in Web Editor NEWQuestionnaire module for Moodle - Contributed module
License: GNU General Public License v3.0
Questionnaire module for Moodle - Contributed module
License: GNU General Public License v3.0
The questionnaire module allows you to construct questionnaires (surveys) from a variety of question type. It was originally based on phpESP, and Open Source survey tool. -------------------------------------------------------------------------------- Developers Note: There is no main branch. Questionnaire is maintained in MOODLE_XX_STABLE branches. Use the latest STABLE branch for development or installation. The current stable branch is MOODLE_400_STABLE, and supports Moodle 4.0 and up. Use the MOODLE_311_STABLE branch for Moodle 3.9 through 3.11. -------------------------------------------------------------------------------- To Install: 1. Load the questionnaire module directory into your "mod" subdirectory. 2. Visit your admin page to create all of the necessary data tables. -------------------------------------------------------------------------------- To Upgrade: 1. Copy all of the files into your 'mod/questionnaire' directory. 2. Visit your admin page. The database will be updated. -------------------------------------------------------------------------------- Please read the CHANGES.md file for more info about successive changes
Hi there,
I was wondering what was the purpose of the 'sec' required param that you can see in print.php
It seems to do nothing except prevent access to url without it, the only use of it beeing adding this parameter to $url...
I've seen this trying to create a moodle url and I didn't know what value I should give to the sec parameter.
Have a nice day,
Guillaume
Hi,
when I create a Backup of my questionnaire instance, the XML file has the rate options in a different order. I have to basically reorder them after Restore to fix it.
Don't know if it has anything to do with the other bugs...
While running https://github.com/sstalle/php7cc - spotted this:
File: mod/questionnaire/classes/question/numeric.php
> Line 28: Name "numeric" that is reserved for future use (does not cause an error in PHP 7) used as a class, interface or trait name
class numeric extends \mod_questionnaire\question\base
{
}
As the error says, it won't cause an error, but if you want to future proof your code, you will need to rename the class. Cheers!
Hello! I need help.
I transfered my moodle for a different server with moodle version 3.3 and used a backup file to recover a course in the new site.
During this process, I lost all the data from my questionnare. It lost the connection it had with the original survey (public).
I tought of updating the data from the public course. Does that make sense? How can I solve this?
Thanks in advance,
Gustavo
in 3.0 branch when creating a new yes/no question you are able to set the parent question.
in 3.1 branch the drop-list to choose the parent question does not show on the creation form. It does show when updating the question though.
using postgres on this machine (not sure if that makes a difference)
We experienced a problem apparently caused by a non-positive section number. I couldn't identify why that would happen, but our error logs had more than 8 million errors like:
PHP Notice: Undefined offset: -1141949 in /opt/moodle/moodle/mod/questionnaire/questionnaire.class.php on line 708, referer: https://moodle.xxxxxx.edu/mod/questionnaire/complete.php?id=999999&resume=1
In looking at the code to calculate number of questions on a page, there is a while loop that will continue looping (forever?) if the section number is less than one. I created #112 that stops the loop if the section number is less than one.
Were on Questionnaire version 2017050101 and Moodle 3.3.
In the questionnaire class, you take it for granted that the choices for a question always have consecutive IDs. When you check for a choice value, you look for the "firstcidid".
You also run a SQL query:
$firstcid[$qid] = $DB->get_record('questionnaire_quest_choice', array('question_id' => $qid), 'id', IGNORE_MULTIPLE);
But you don't ever check that the results come back ordered by an ascending id. When the IDs come back random, it is possible that you don't get the lowest ID, but the highest.
Then you just add the rank from there, and then the calculation is effed up.
Also, what if you remove a choice and later replace it with another choice with text?
P.S.: And why isn't the "1=bla" part separated into two fields?
An issue that we have observed can be reproduced as follows:
It would be ideal if the grades were not pushed to the grade book until after the questionnaire closed.
when editing an existing label that has previously had a parent question set - the interface gives no ability to change/view the selected parent. The parent still shows on the main questions overview page.
(using postgres if that makes any difference.)
When looking at the questionnaire report for question types "Radio buttons", the title above the responses display the word "Average" where it should be displaying "Distribution" or somthing similar to that meaning.
Since what is displayed is the distribution of choices the users made on that specific question. (plus, the count. at the end of each line)
Am I correct or or misunderstanding something?
BTW, on earlier versions of the plugin, I remember it used to display an actual average calculation in brackets. Where did it go?
Answers of parent questions can be edited and changes are not checked whether they break some dependend behaviour.
Changing the answers for a parent question can lead to missing or wrong references in the corresponding child questions.
Tested with MOODLE_32_STABLE.
Questions that are marked as required but not reachable according to choices mode are being flagged as required when a preview is submitted.
This results in database errors in the "Recent Activity" block when a user has completed a questionnaire recently.
The error is as follows and the sql that causes it is on line 773 of lib.php:
"ERROR: operator does not exist: bigint = character varying
LINE 5: JOIN mdl_user u ON u.id = qr.username
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
SELECT qr.*,
u.id AS useridagain,u.picture,u.firstname,u.lastname,u.firstnamephonetic,u.lastnamephonetic,u.middlename,u.alternatename,u.imagealt,u.email
FROM mdl_questionnaire_response qr
JOIN mdl_user u ON u.id = qr.username
"
I assume that u.id is meant to be u.username (or similar) in the join statement, but I am unfamiliar with the code around this area.
Hello,
I'm testing Questionnaire-plugin 3.1beta (Build - 2016020200) on Moodle 3.1dev
build: 20160422)
When I'm adding any new question to my questionnaire and press "add question" it flashes an error for a few seconds then takes me to an white page. No questions are added and if I come back to the questionnare and click the course name in the breadcrumb it displays only a white page
See attachement for error
From https://docs.moodle.org/32/en/Editing_Questionnaire_questions#Possible_answers_2
"Please note that in former versions of Questionnaire the separator between "short label" and "options text" used to be the equal sign (=). In Questionnaire 2.5 and later, please use two colons (::) as a separator. "
When using the mentioned new syntax with the two colons, the question using the new syntax is displayed incorrectly (multiple scales, one per value, instead of just one scale)
It would be more logical to have separate form fields for "question choices" and "subquestion labels" (the "possible answer" part in the form field), I think
Given that the MOODLE_25_STABLE branch sets the savepoint to 2013122201 without questionnaire_fb_sections and that the MOODLE_27_STABLE compares against this savepoint, this table will not be setup when upgrading from 25 to 27.
I suggest the following patch to circumvent this issue:
From 3e8f9ad7015e3c7dacbc5ba913bd8b3ef12c3945 Mon Sep 17 00:00:00 2001
From: Didier 'OdyX' Raboud <[email protected]>
Date: Mon, 28 Jul 2014 17:08:56 +0200
Subject: [PATCH] Let the upgrade work from MOODLE_25 to MOODLE_27
---
db/upgrade.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/db/upgrade.php b/db/upgrade.php
index 75195aa..93651be 100644
--- a/db/upgrade.php
+++ b/db/upgrade.php
@@ -427,7 +427,7 @@ function xmldb_questionnaire_upgrade($oldversion=0) {
upgrade_mod_savepoint(true, 2013100500, 'questionnaire');
}
- if ($oldversion < 2013122201) {
+ if ($oldversion < 2013122202) {
// Personality test feature.
$table = new xmldb_table('questionnaire_survey');
@@ -485,7 +485,7 @@ function xmldb_questionnaire_upgrade($oldversion=0) {
}
// Questionnaire savepoint reached.
- upgrade_mod_savepoint(true, 2013122201, 'questionnaire');
+ upgrade_mod_savepoint(true, 2013122202, 'questionnaire');
}
if ($oldversion < 2014010300) {
--
2.0.1
Current master branch saves rate question incorrectly. No matter what value is chosen, after saving answer all results show 1 (leftmost value). Probably this was broken with fix for non-respondents emails
Hi.
Since the recent Questionnaire update, one of our admin staff have tried to duplicate a previous questionnaire and received this message:
Coding error detected, it must be fixed by a programmer: encode_content_links() method needs to be overridden in each subclass of backup_activity_task
Any ideas on what might be wrong?
Moodle 3.2.2+ (Build: 20170407) Version 2016120502.05
Regards
bobby
Hi, here an example:
Create a qs with 4 questions.
1 (yes/no)
2
3 -> depends on 1->yes
4 -> depends on 1->yes
A page break will be created between 2 and 3.
Change the dependency of 4 to 1->no.
A page break will be created between 3 and 4.
Change the dependency of 4 back to 1->yes.
-> The page break between 4 and 3 will stay and will remain uneditable despite both questions sharing the same dependency again.
Tested with MOODLE_32_STABLE.
Fatal error: 'break' not in the 'loop' or 'switch' context in /warehouse/lampp/htdocs/moodle/mod/questionnaire/questiontypes/questiontypes.class.php on line 297
Hi,
Printing the results for an individual response gives a blank page.
The issues seems in the print.php line 44 where the used output page object is the wrong one.
Changing it to the reportpage object
$questionnaire->add_page(new \mod_questionnaire\output\reportpage());
fixes the problem
Kind regards
Mario
Questionnaire 3.2.4. Sometimes two digits, sometimes three digits make a choice.
Sources:
rate.php, line 538:
if (preg_match("/^[0-9]{1,3}=/", $choice)) {
base.php, line 902:
$r = preg_match_all("/^(\d{1,2})(=.*)$ /", $newchoices[$nidx], $matches);
Proposed solution: Define one or more global regular expression constants. Use brackets in these to define capturing groups. Use capturing groups when necessary.
Found that questionnaire caused quiz and other features to fail. This was due to modification of the $COURSE
global which then cause bad behavior in other parts of Moodle. Fix is in the attached behat.patch
.
Found some output during PHPUnit tests. Fix is in the attached phpunit.patch
.
Import/Restore not working for dependencies, if the parent question (RADIO or DROPDOWN) was created after the child question and has been moved before the to-be-child afterwards.
The parent-question is stored AFTER the child question due to its higher ID in the Backup-XML-File inside the mbz-File. While iterating through the file, moodle can't get the new mappingid for the depending record, because it doesn't exist yet.
This leads to the result: dependquestion = 0, dependchoice = old choice ID
Example:
Create a questionnaire with some questions (IDs 1 2 3 4 5). Move the last question (ID 5) somewhere before the second last question (ID 4). Set the new last question to be dependend on the answer in (ID 5).
Now create a backup. The questions in the questionnaire are stored sequentially according to the question-ID.
Now import the mbz-File and restore the questionnaire. The questionnaire gets importet smoothly, but misses the correct dependency between former ID4 to ID5.
Tested with MOODLE_32_STABLE.
Hi,
I got a notice for $this->notifications being an undefined property
Here is the path followed after the submission of the questionnaire :
And de facto, there was no public/private $notifications at the beginning of the class
I Hope this will help,
Guillaume
partly related to pull request #68 (same code - slightly different error.)
We are using a Moodle 2.3 version with Questionnaire (branch stable 23) and we needed to regrade our users. We enabled (lib.php line 217)
// JR removed line because triggers error in moodle 2.3 STRICT STANDARDS mode ???
questionnaire_update_grades($questionnaire);
Which seems to work fine.
Why is it disabled?
Hello,
I ran into a minor issue. In order to replicate I clicked on the tabs in this sequential order:
View All Responses -> Individual Responses -> Then I "clicked" on a student's name
From there, a page pops up showing the individual students response. The tabs "Print this Response" and delete response are misaligned. Furthermore, the text for "Print this Response" is grey, which is should be blue to coincide with the rest of the tabs text color. Please reference the attached screenshot for your reference.
Thank you,
The preview mode has some issues in the new multi-dependency mode.
The "Show/hide" question is still active in some cases.
Hi,
the year 2017 is hardcoded in expected_output()
from tests/csvexport_test.php
, but in generate_response()
from tests/generator/lib.php
the year is actually the current one ($date = mktime(0, 0, 0, 12, 28, date('Y'));
), making the tests fail now that we are in 2018. I guess we should use date('Y')
in the expected output.
Cheers,
Pierre
inside function has_required() the foreach runs on object questionsbysec with [$section],
but sometimes the value of $section is lower then the value of the first key in questionsbysec object.
foreach ($this->questionsbysec[$section] as $question) {
if ($question->required == 'y') {
return true;
}
exactly the same problem exists in function survey_render()
thanks Lihi
When using Moodle's base 'clean' theme, or any other bootstrap-based theme, the radio buttons shown when viewing an individual response to a "rate" question are displayed with an offset to the left.
The effect of this is that users viewing an individual response believe that the choice the respondent made was one choice further to the left.
Note that my examples here used named ranks, but this appears to be a problem with standard 1..5 ranks as well.
In this example, the user chose Strongly agree for the first entry in the table ("Test"), and Agree for the second ("Two").
This does not match the view when answering the same question, where the buttons appear correctly:
My brief analysis suggests that /templates/response_rate.mustache
is adding the radio
class of the div containing the table. https://github.com/remotelearner/moodle-mod_questionnaire/blob/MOODLE_32_STABLE/templates/response_rate.mustache#L60
The .radio input[type="radio"], .checkbox input[type="checkbox"]
rule in the bootstrap CSS appears to set float: left; margin-left: -20px;
.
If I remove the radio
class from the div
on L60 of response_rate.mustache
, the radio buttons appear correctly in an individiual response.
I would submit a PR, but I'm not sure if there are other implications to removing this class!
When you want to upgrade to 2017111101 (I reckon it happens in the update to 2017050100)
The following error is thrown when your database is PostgreSQL
Debug info: ERROR: column "username" cannot be cast automatically to type bigint
HINT: You might need to specify "USING username::bigint".
BEGIN ISOLATION LEVEL SERIALIZABLE;
ALTER TABLE mdl_questionnaire_response ALTER COLUMN username TYPE BIGINT
; COMMIT
Error code: ddlexecuteerror
"QUESTIONNAIRE_STUDENTVIEWRESPONSES_NEVER" is defined in "locallib.php". But it's not listed in array $questionnaireresponseviewers. Sometime teacher wants to hide enquete result from students.
Hello,
I would like to see an feature in Questionnare that lets you export/download answers in .xlxs-format, at the moment you can only export .csv file
In Moodle 2.8 when using the questionnaire module and response emailing I get the following error:
Notice: Trying to get property of non-object in /var/www/html/engage/releases/20150720122227/learn/lib/moodlelib.php on line 5884
Looking into the code the error is happening here in the email_to_user
function in the lib/moodlelib.php
file:
if (!empty($CFG->emailonlyfromnoreplyaddress)) {
$usetrueaddress = false;
if (empty($replyto) && $from->maildisplay) {
$replyto = $from->email;
$replytoname = fullname($from);
}
}
The $from
in this case is a string so the maildisplay
is not there. In the questionnaire module the email_to_user
function is being called from response_send_email
in the questionnaire.class.php
file:
$return = true;
$mailaddresses = preg_split('/,|;/', $email);
foreach ($mailaddresses as $email) {
$userto = new Object();
$userto->email = $email;
$userto->mailformat = 1;
// Dummy userid to keep email_to_user happy in moodle 2.6.
$userto->id = -10;
$userfrom = $CFG->noreplyaddress;
if (email_to_user($userto, $userfrom, $subject, $altbody, $bodyhtml)) {
$return = $return && true;
} else {
$return = false;
}
}
While the email_to_user function does seem to work with strings the function does specify that the $from
argument is stdClass $from A {@link $USER} object
.
Would it be possible to fake the stdClass object for this to keep the error from happening?
The link should be a button like the other UI links. See https://moodle.org/mod/forum/discuss.php?d=361634
Moodle 3.0 / Questionnaire 3.0.0 (Build - 2015102800) / Database: MySQL
Question type: Dropdown Box
If, for example a teacher defines a list of students in alphabetical order in the Dropdown box for tutors to select when filling out a questionnaire. Assuming that some students will come and go, if they add new students in that list alphabetically it will screw up all prior submissions because questionnaire stores the value for the position in the dropdown rather than the actual value.
Sure, we can add additions at the bottom of the list and not remove withdrawn students to prevent this from occurring but since the list is in alphabetical order, having randomly some students at the bottom not in alphabetical order is confusing the users filling out the questionnaire.
In the question form where you have to enter stuff with the syntax
1=Text
2=Other Text
and so on, when you have an empty line at the end, that line is still saved as a choice of this question.
After it is saved, you can't even delete the choice by removing the empty choice when editing the question.
This leads to other bad behaviour, see separate ticket.
TinyMCE does not load properly. Student's can't add images.
Hi,
A client recently asked us to improve the accessibility of their moodle. They did an audit of their platform (I think its was following the RGAA 2.2 or 3.0 standart) and we had to work on the problems they puted in light.
Since this moodle platform do use your plugin (great work by the way :D ), we though it might be a good idea to share our work with you and the community.
So here is some description of the problems we've faced and I will provide the pull requests in a near future.
The idea was to link the header with every <input type="radio">
of the same column.
To do so, we added an id for every header (named q<question_number>_resp<response_number>) and we used the HTML property aria-labelledby
to do the link.
We also added a role="presentation"
to the table.
So the desired HTML looks like this :
<table style="width:99.9%" role="presentation">
<tbody>
<tr>
<td id="q1_resp1">religiously agree</td>
<td id="q1_resp2">agree</td>
<td id="q1_resp3">meh</td>
<td id="q1_resp4">disagree</td>
<td id="q1_resp5">outrageously disagree</td>
</tr>
<tr class="raterow" role="radiogroup group" aria-labelledby="q1">
<td id="q1" >Sharks are stronger than gorillas</td>
<td style="text-align:center" class="c1 raterow"><input aria-labelledby="q1_resp1" name="q1977_4965" value="0" id="q1977_4965_0" type="radio"></td>
<td style="text-align:center" class="c1 raterow"><input aria-labelledby="q1_resp2" name="q1977_4965" value="1" id="q1977_4965_1" type="radio"></td>
<td style="text-align:center" class="c0 raterow"><input aria-labelledby="q1_resp3" name="q1977_4965" value="2" id="q1977_4965_2" type="radio"></td>
<td style="text-align:center" class="c1 raterow"><input aria-labelledby="q1_resp4" name="q1977_4965" value="3" id="q1977_4965_3" type="radio"></td>
<td style="text-align:center" class="c0 raterow"><input aria-labelledby="q1_resp5" name="q1977_4965" value="4" id="q1977_4965_4" type="radio"></td>
</tr>
...
</table>
Here is an ugly output of a likert scale question :
religiously agree | agree | meh | disagree | outrageously disagree | |
Sharks are stronger than gorillas |
It seems that there was no legend saying that the required fields were marked by a red asterisk. So we had to add one.
Since the red asterisks are <img>
tags, the HTML tags have to contain the alt
attribute.
The HTML for the essay box was like this :
<div class="qn-question ">
<label for="edit-q1777">
<div class="no-overflow"><p><span>This is my question</span></p></div>
</label>
</div>
<div class="qn-answer">
<textarea id="q1777" name="q1777" rows="5" cols="80"></textarea>
</div>
You easily see that the id of the textarea is close but not equal to the id given in the for
attribute of the <label>
tag
This is a 'nice-to-have' request. The following CSS allows the most of the table cell containing the radio button to be clickable.
.qn-answer td input[type="radio"] { width:100%;}
I guess the the CSS rule at ~line 286 in styles.css could be modified to
.qn-answer input[type="radio"], .qn-answer input[type="checkbox"] { width:100%; }
I also removed the margin-right: 3px;
because it no longer seems necessary at least with the themes that I've used. Thanks!
The issue can be reproduced as follows:
Hey,
I just wondered, why the export of the report as csv-file uses ".txt" as file extension. It confused one of our users. In the code there is the comment:
// SEP. 2007 JR changed file extension to *.txt for non-English Excel users' sake
Since it is 10 years old, I wonder if this comment is this still relevant?
Otherwise, could you change the extension to csv at https://github.com/remotelearner/moodle-mod_questionnaire/blob/master/report.php#L494
Cheers,
Tobias
From the moodle.org forum - https://moodle.org/mod/forum/discuss.php?d=363212#p1464677
version : 3.1.7 (Build - 2017042800) (2016071102)
locallib.php : function questionnaire_delete_responses($qid)
parameter is $qid, but in deletion processing of 'questionnaire_response' and 'questionnaire_attempts' it is coded as if it is $rid.
In this case, irrelevant responses are deleted.
function questionnaire_delete_responses($qid) {
:
$status = $status && $DB->delete_records('questionnaire_response', array('id' => $qid)); //Problem
$status = $status && $DB->delete_records('questionnaire_attempts', array('rid' => $qid)); //Problem
return $status;
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.