在每个条目中扩展 limesurvey 的控件
Extending limesurvey's controls in each entry
我想用一些图形库(例如 go.js)创建的自定义控件来扩展 limesurvey,这样用户就可以从树中选择他的答案。标题说 "entry" 而不是 "question" 因为标题中不允许使用该词。
我已经阅读:
https://manual.limesurvey.org/Plugins
https://manual.limesurvey.org/Plugin_events
http://codelogic.ws/2015/12/07/limesurvey-plug-in-hello-world/
但我找不到有关潜在可能性的详细信息。你知道一些书吗?教程?手动的?演示?等等?
提前致谢
我不认为你需要这里的插件事件,你可以在 javascript 中完成。 LimeSUrvey 包含 jquery,那就很简单了。
看这个例子:http://demonstration.sondages.pro/21764
<script type="text/javascript">
$(document).ready(function() {
//$('#question{QID} .survey-question-answer ').hide(); //uncomment to hide radio button
$("path").click(function() {
if ($(this).attr('id') != "selected")
{
$("[name={SGQ}]").filter("[value='"+$(this).attr('id')+"']").attr("checked",true);
$("#selected").css('fill',$(this).css('fill'));
}
else
{
$("#selected").css('fill','none');
$("[name={SGQ}]").attr("checked",false);
}
});
});
</script>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="150" height="150" style="margin-left:25px">
<path
d="M 73.21875,0.03125 A 74.999999,74.999999 0 0 0 37.5,10.0625 l 18.75,32.5 a 37.5,37.5 0 0 1 37.5,-0.03125 L 112.5,10.0625 A 74.999999,74.999999 0 0 0 73.21875,0.03125 z"
id="C1"
style="fill:#008000;fill-opacity:1;stroke:none;cursor:pointer" />
<path
d="M 112.5,10.0625 93.75,42.53125 A 37.5,37.5 0 0 1 112.5,75 L 150,75 A 74.999999,74.999999 0 0 0 112.5,10.0625 z"
id="C2"
style="fill:#ffff00;fill-opacity:1;stroke:none;cursor:pointer" />
<path
d="m 112.5,75 a 37.5,37.5 0 0 1 -18.75,32.4375 l 18.75,32.5 A 74.999999,74.999999 0 0 0 150,75 l -37.5,0 z"
id="C3"
style="fill:#ff8000;fill-opacity:1;stroke:none;cursor:pointer" />
<path
d="m 93.75,107.4375 a 37.5,37.5 0 0 1 -37.5,0.0312 L 37.5,139.9375 a 74.999999,74.999999 0 0 0 75,0 l -18.75,-32.5 z"
id="C4"
style="fill:#ff0000;fill-opacity:1;stroke:none;cursor:pointer" />
<path
d="m 0,75 a 74.999999,74.999999 0 0 0 37.5,64.9375 L 56.25,107.46875 A 37.5,37.5 0 0 1 37.5,75 L 0,75 z"
id="C5"
style="fill:#800080;fill-opacity:1;stroke:none;cursor:pointer" />
<path
d="M 37.5,10.0625 A 74.999999,74.999999 0 0 0 0,75 l 37.5,0 A 37.5,37.5 0 0 1 56.25,42.5625 l -18.75,-32.5 z"
id="C6"
style="fill:#0000ff;fill-opacity:1;stroke:none;cursor:pointer" />
<path
d="m -182.40128,-1.5888613 a 48.619156,48.619156 0 1 1 -97.23831,0 48.619156,48.619156 0 1 1 97.23831,0 z"
transform="matrix(0.23653228,0,0,0.23653228,129.64379,75.375816)"
id="selected"
style="fill:none;stroke:#000000;stroke-width:8.45550537;stroke-miterlimit:4;stroke-dasharray:none" />
</svg>
对于插件开发:有一些代码示例:https://framagit.org/groups/SondagePro-LimeSurvey-plugin
破解答案部分并在不涉及问题文本的情况下做同样的事情,只需使用特定的 class:参见 https://framagit.org/SondagePro-LimeSurvey-plugin/radioToStarRating 这个
我想用一些图形库(例如 go.js)创建的自定义控件来扩展 limesurvey,这样用户就可以从树中选择他的答案。标题说 "entry" 而不是 "question" 因为标题中不允许使用该词。
我已经阅读: https://manual.limesurvey.org/Plugins https://manual.limesurvey.org/Plugin_events http://codelogic.ws/2015/12/07/limesurvey-plug-in-hello-world/
但我找不到有关潜在可能性的详细信息。你知道一些书吗?教程?手动的?演示?等等?
提前致谢
我不认为你需要这里的插件事件,你可以在 javascript 中完成。 LimeSUrvey 包含 jquery,那就很简单了。
看这个例子:http://demonstration.sondages.pro/21764
<script type="text/javascript">
$(document).ready(function() {
//$('#question{QID} .survey-question-answer ').hide(); //uncomment to hide radio button
$("path").click(function() {
if ($(this).attr('id') != "selected")
{
$("[name={SGQ}]").filter("[value='"+$(this).attr('id')+"']").attr("checked",true);
$("#selected").css('fill',$(this).css('fill'));
}
else
{
$("#selected").css('fill','none');
$("[name={SGQ}]").attr("checked",false);
}
});
});
</script>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="150" height="150" style="margin-left:25px">
<path
d="M 73.21875,0.03125 A 74.999999,74.999999 0 0 0 37.5,10.0625 l 18.75,32.5 a 37.5,37.5 0 0 1 37.5,-0.03125 L 112.5,10.0625 A 74.999999,74.999999 0 0 0 73.21875,0.03125 z"
id="C1"
style="fill:#008000;fill-opacity:1;stroke:none;cursor:pointer" />
<path
d="M 112.5,10.0625 93.75,42.53125 A 37.5,37.5 0 0 1 112.5,75 L 150,75 A 74.999999,74.999999 0 0 0 112.5,10.0625 z"
id="C2"
style="fill:#ffff00;fill-opacity:1;stroke:none;cursor:pointer" />
<path
d="m 112.5,75 a 37.5,37.5 0 0 1 -18.75,32.4375 l 18.75,32.5 A 74.999999,74.999999 0 0 0 150,75 l -37.5,0 z"
id="C3"
style="fill:#ff8000;fill-opacity:1;stroke:none;cursor:pointer" />
<path
d="m 93.75,107.4375 a 37.5,37.5 0 0 1 -37.5,0.0312 L 37.5,139.9375 a 74.999999,74.999999 0 0 0 75,0 l -18.75,-32.5 z"
id="C4"
style="fill:#ff0000;fill-opacity:1;stroke:none;cursor:pointer" />
<path
d="m 0,75 a 74.999999,74.999999 0 0 0 37.5,64.9375 L 56.25,107.46875 A 37.5,37.5 0 0 1 37.5,75 L 0,75 z"
id="C5"
style="fill:#800080;fill-opacity:1;stroke:none;cursor:pointer" />
<path
d="M 37.5,10.0625 A 74.999999,74.999999 0 0 0 0,75 l 37.5,0 A 37.5,37.5 0 0 1 56.25,42.5625 l -18.75,-32.5 z"
id="C6"
style="fill:#0000ff;fill-opacity:1;stroke:none;cursor:pointer" />
<path
d="m -182.40128,-1.5888613 a 48.619156,48.619156 0 1 1 -97.23831,0 48.619156,48.619156 0 1 1 97.23831,0 z"
transform="matrix(0.23653228,0,0,0.23653228,129.64379,75.375816)"
id="selected"
style="fill:none;stroke:#000000;stroke-width:8.45550537;stroke-miterlimit:4;stroke-dasharray:none" />
</svg>
对于插件开发:有一些代码示例:https://framagit.org/groups/SondagePro-LimeSurvey-plugin
破解答案部分并在不涉及问题文本的情况下做同样的事情,只需使用特定的 class:参见 https://framagit.org/SondagePro-LimeSurvey-plugin/radioToStarRating 这个