Skip to content

Commit 50f6912

Browse files
plukasewottenhoff
authored andcommitted
SAM-2899: Improve usability of question pool interfaces (sakaiproject#2706)
1 parent 7442737 commit 50f6912

14 files changed

+154
-118
lines changed

samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/bundle/QuestionPoolMessages.properties

+1
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ t_checkAll=Check All
182182
t_uncheckAll=Uncheck All
183183
t_sharePool = Share
184184
t_unsharePool = Remove me
185+
t_updateSharedPoolAccess = Update
185186

186187
# alt tag for images: start with alt_
187188
alt_sortTitleAscending=Sort by Title in Ascending

samigo/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/bean/questionpool/QuestionPoolBean.java

+9-12
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public class QuestionPoolBean implements Serializable
114114
private String[] destPools = { }; // for multibox
115115
private String[] destItems = { }; // items to delete
116116
private String sourcePart = null; // copy all questions from part
117-
private String destPool=""; // for Move Pool Destination
117+
private String destPool="0"; // for Move Pool Destination
118118
private FormFile filename; // for import /export
119119
private int htmlIdLevel; // pass this to javascript:collapseAll()
120120
private String questionType; // the question type to add
@@ -2115,20 +2115,17 @@ public String cancelImport(){
21152115

21162116
public boolean getSelfOrDescendant(){
21172117
// check if currentPool is ancester of tree.getCurrentObject
2118-
boolean isDescendant = false;
2119-
boolean isSelf= false;
21202118

2121-
isDescendant = tree.isDescendantOf(tree.getCurrentId(), this.getCurrentPool().getId());
2122-
if (tree.getCurrentId().equals(this.getCurrentPool().getId())){
2123-
isSelf= true;
2124-
}
2125-
if (isSelf || isDescendant) {
2126-
return true ;
2127-
}
2128-
else {
2129-
return false;
2119+
QuestionPoolDataBean curPool = getCurrentPool();
2120+
if (tree == null || tree.getCurrentId() == null || curPool == null)
2121+
{
2122+
return false;
21302123
}
21312124

2125+
boolean isDescendant = tree.isDescendantOf(tree.getCurrentId(), curPool.getId());
2126+
boolean isSelf = tree.getCurrentId().equals(curPool.getId());
2127+
2128+
return isSelf || isDescendant;
21322129
}
21332130

21342131
private HashMap buildHash(Collection objects){

samigo/samigo-app/src/webapp/js/authoring.js

-15
Original file line numberDiff line numberDiff line change
@@ -219,21 +219,6 @@ function initCalcQuestion() {
219219
});
220220
}
221221

222-
// this is to disable the 'copy' button when importing questions from pool to assessement. itemtype =10
223-
224-
var disabledImport= 'false';
225-
function disableImport(){
226-
if (disabledImport== 'false'){
227-
disabledImport= 'true'
228-
}
229-
else{ // any subsequent click disable button & action
230-
if (document.forms[0].elements['editform:import'])
231-
{
232-
document.forms[0].elements['editform:import'].disabled=true;
233-
}
234-
}
235-
}
236-
237222
$( document ).ready( function() {
238223

239224
// inputText with class ConvertPoint changes

samigo/samigo-app/src/webapp/js/samigotree.js

+35
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,41 @@ function checkUpdate(){
480480
}
481481
}
482482

483+
// convenience function for single button arrays, see next function
484+
function updateButtonStatusOnCheck(button, checkboxContainer)
485+
{
486+
updateButtonStatusesOnCheck([button], checkboxContainer);
487+
}
488+
489+
// enables/disables the given buttons depending on whether or not
490+
// any checkbox child element of the given container is checked
491+
function updateButtonStatusesOnCheck(buttons, checkboxContainer)
492+
{
493+
if (buttons === null || checkboxContainer === null)
494+
{
495+
return;
496+
}
497+
498+
var inputs = checkboxContainer.getElementsByTagName("input");
499+
var foundChecked = false;
500+
for (i = 0; i < inputs.length; ++i)
501+
{
502+
if (inputs[i].type === "checkbox" && inputs[i].checked)
503+
{
504+
foundChecked = true;
505+
break;
506+
}
507+
}
508+
509+
for (i = 0; i < buttons.length; ++i)
510+
{
511+
if (buttons[i] !== null)
512+
{
513+
buttons[i].disabled = !foundChecked;
514+
}
515+
}
516+
}
517+
483518
function inIt()
484519
{
485520
var inputs= document.getElementsByTagName("INPUT");

samigo/samigo-app/src/webapp/jsf/questionpool/copyPool.jsp

+24-5
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,23 @@
3838
collapseAllRowsForSelectList();
3939
flagRows();
4040
}
41-
window.onload = flagFolders;
41+
function initPage()
42+
{
43+
var poolSubmitButton = document.getElementById('copyPool:copypoolsubmit');
44+
if (poolSubmitButton !== null)
45+
{
46+
poolSubmitButton.disabled=true;
47+
}
48+
var itemSubmitButton = document.getElementById('copyPool:copyitemsubmit');
49+
if (itemSubmitButton !== null)
50+
{
51+
itemSubmitButton.disabled=true;
52+
}
53+
flagFolders();
54+
}
55+
window.onload = initPage;
4256
</script>
57+
<script src="/library/js/spinner.js" type="text/javascript"></script>
4358
</head>
4459
<body onload="collapseAllRowsForSelectList();flagRows();;<%= request.getAttribute("html.body.onload") %>">
4560
<!-- content... -->
@@ -88,19 +103,23 @@
88103
<p class="act">
89104

90105
<h:commandButton id="copypoolsubmit" immediate="true" value="#{questionPoolMessages.copy}"
91-
action="#{questionpool.copyPool}" styleClass="active" rendered="#{questionpool.actionType == 'pool'}">
106+
action="#{questionpool.copyPool}" styleClass="active" rendered="#{questionpool.actionType == 'pool'}"
107+
onclick="SPNR.disableControlsAndSpin(this, null);">
92108
</h:commandButton>
93109

94110
<h:commandButton id="copyitemsubmit" immediate="true" value="#{questionPoolMessages.copy}"
95-
action="#{questionpool.copyQuestion}" styleClass="active" rendered="#{questionpool.actionType == 'item'}">
111+
action="#{questionpool.copyQuestion}" styleClass="active" rendered="#{questionpool.actionType == 'item'}"
112+
onclick="SPNR.disableControlsAndSpin(this, null);">
96113
</h:commandButton>
97114

98-
<h:commandButton id="cancel" value="#{commonMessages.cancel_action}" action="#{questionpool.cancelPool}" immediate="true" rendered="#{questionpool.actionType == 'pool'}">
115+
<h:commandButton id="cancel" value="#{commonMessages.cancel_action}" action="#{questionpool.cancelPool}" immediate="true"
116+
rendered="#{questionpool.actionType == 'pool'}" onclick="SPNR.disableControlsAndSpin(this, null);">
99117
<f:actionListener type="org.sakaiproject.tool.assessment.ui.listener.questionpool.CancelPoolListener" />
100118
<f:attribute name="returnToParentPool" value="true"/>
101119
</h:commandButton>
102120

103-
<h:commandButton id="cancelItem" value="#{commonMessages.cancel_action}" action="#{questionpool.cancelPool}" immediate="true" rendered="#{questionpool.actionType == 'item'}">
121+
<h:commandButton id="cancelItem" value="#{commonMessages.cancel_action}" action="#{questionpool.cancelPool}" immediate="true"
122+
rendered="#{questionpool.actionType == 'item'}" onclick="SPNR.disableControlsAndSpin(this, null);">
104123
<f:actionListener type="org.sakaiproject.tool.assessment.ui.listener.questionpool.CancelPoolListener" />
105124
<f:attribute name="returnToParentPool" value="false"/>
106125
</h:commandButton>

samigo/samigo-app/src/webapp/jsf/questionpool/copyPoolTree.jsp

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
-->
2222
<h:panelGrid rendered="#{questionpool.actionType == 'pool'}" columns="2">
2323

24-
<h:selectManyCheckbox id="checkboxes" layout="pageDirection" value="#{questionpool.destPools}">
24+
<h:selectManyCheckbox id="checkboxes" layout="pageDirection" value="#{questionpool.destPools}" onclick="updateButtonStatusOnCheck(document.getElementById('copyPool:copypoolsubmit'), document.getElementById('copyPool'));">
2525
<f:selectItem itemValue="0" itemLabel=""/>
2626
</h:selectManyCheckbox>
2727

@@ -39,7 +39,7 @@
3939
</f:facet>
4040

4141
<h:selectManyCheckbox rendered="#{!(questionpool.selfOrDescendant && questionpool.actionType == 'pool')}" id="checkboxes" layout="pageDirection"
42-
value="#{questionpool.destPools}">
42+
value="#{questionpool.destPools}" onclick="updateButtonStatusesOnCheck([document.getElementById('copyPool:copypoolsubmit'), document.getElementById('copyPool:copyitemsubmit')], document.getElementById('copyPool'));">
4343
<f:selectItem itemValue="#{pool.questionPoolId}" itemLabel=""/>
4444
</h:selectManyCheckbox>
4545

samigo/samigo-app/src/webapp/jsf/questionpool/editPool.jsp

+9-5
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,18 @@ function textCounter(field, maxlimit) {
4747
}
4848
4949
</script>
50+
<script src="/library/js/spinner.js" type="text/javascript"></script>
5051
<script type="text/javascript">
5152
function flagFolders() {
5253
collapseRowsByLevel(<h:outputText value="#{questionpool.htmlIdLevel}"/>);
5354
flagRows();
5455
}
55-
window.onload = flagFolders;
56+
function initPage()
57+
{
58+
disableIt();checkUpdate();document.getElementById('editform:import').disabled=true;
59+
flagFolders();
60+
}
61+
window.onload = initPage;
5662
</script>
5763
</head>
5864

@@ -237,17 +243,15 @@ function textCounter(field, maxlimit) {
237243
<!-- disable copy button once clicked. show processing... -->
238244

239245
<h:commandButton id="import" rendered="#{(questionpool.importToAuthoring == 'true') && (questionpool.currentPool.numberOfQuestions > 0)}" action="#{questionpool.doit}"
240-
onclick="disableImport(); showNotif('submitnotif',this.name,'editform');" onkeypress="disableImport(); showNotif('submitnotif',this.name,'editform');"
241-
value="#{questionPoolMessages.copy}">
246+
onclick="SPNR.disableControlsAndSpin(this, null);" value="#{questionPoolMessages.copy}">
242247
<f:actionListener type="org.sakaiproject.tool.assessment.ui.listener.questionpool.ImportQuestionsToAuthoring" />
243248
</h:commandButton>
244249

245-
<h:commandButton style="act" value="#{commonMessages.cancel_action}" action="#{questionpool.cancelPool}">
250+
<h:commandButton style="act" value="#{commonMessages.cancel_action}" action="#{questionpool.cancelPool}" onclick="SPNR.disableControlsAndSpin(this, null);">
246251
<f:actionListener type="org.sakaiproject.tool.assessment.ui.listener.questionpool.CancelPoolListener" />
247252
<f:attribute name="returnToParentPool" value="true"/>
248253
</h:commandButton>
249254

250-
<h:outputText escape="false" value="<span id=\"submitnotif\" style=\"visibility:hidden\"> #{deliveryMessages.processing}</span>"/>
251255
</div>
252256

253257
</h:form>

samigo/samigo-app/src/webapp/jsf/questionpool/movePool.jsp

+9-4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
}
4242
window.onload = flagFolders;
4343
</script>
44+
<script src="/library/js/spinner.js" type="text/javascript"></script>
4445
</head>
4546
<body onload="collapseAllRowsForSelectList();flagRows();;<%= request.getAttribute("html.body.onload") %>">
4647

@@ -89,20 +90,24 @@
8990

9091
<p class="act">
9192
<h:commandButton type="submit" immediate="true" id="poolSubmit" value="#{questionPoolMessages.move}"
92-
action="#{questionpool.movePool}" rendered="#{questionpool.actionType == 'pool'}" styleClass="active">
93+
action="#{questionpool.movePool}" rendered="#{questionpool.actionType == 'pool'}" styleClass="active"
94+
onclick="SPNR.disableControlsAndSpin(this, null);">
9395
<f:param name="qpid" value="#{questionpool.currentPool.parentPoolId}"/>
9496
</h:commandButton>
9597

9698
<h:commandButton type="submit" immediate="true" id="itemSubmit" value="#{questionPoolMessages.move}"
97-
action="#{questionpool.moveQuestion}" rendered="#{questionpool.actionType == 'item'}" styleClass="active">
99+
action="#{questionpool.moveQuestion}" rendered="#{questionpool.actionType == 'item'}" styleClass="active"
100+
onclick="SPNR.disableControlsAndSpin(this, null);">
98101
</h:commandButton>
99102

100-
<h:commandButton id="cancel" value="#{commonMessages.cancel_action}" action="#{questionpool.cancelPool}" rendered="#{questionpool.actionType == 'pool'}">
103+
<h:commandButton id="cancel" value="#{commonMessages.cancel_action}" action="#{questionpool.cancelPool}"
104+
rendered="#{questionpool.actionType == 'pool'}" onclick="SPNR.disableControlsAndSpin(this, null);">
101105
<f:actionListener type="org.sakaiproject.tool.assessment.ui.listener.questionpool.CancelPoolListener" />
102106
<f:attribute name="returnToParentPool" value="true"/>
103107
</h:commandButton>
104108

105-
<h:commandButton id="cancelItem" value="#{commonMessages.cancel_action}" action="#{questionpool.cancelPool}" rendered="#{questionpool.actionType == 'item'}">
109+
<h:commandButton id="cancelItem" value="#{commonMessages.cancel_action}" action="#{questionpool.cancelPool}"
110+
rendered="#{questionpool.actionType == 'item'}" onclick="SPNR.disableControlsAndSpin(this, null);">
106111
<f:actionListener type="org.sakaiproject.tool.assessment.ui.listener.questionpool.CancelPoolListener" />
107112
<f:attribute name="returnToParentPool" value="false"/>
108113
</h:commandButton>

samigo/samigo-app/src/webapp/jsf/questionpool/questionTreeTable.jsp

+7-7
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@
9999
<h:column id="colimport" rendered="#{questionpool.importToAuthoring == 'true'}" >
100100
<f:facet name="header">
101101
<h:panelGroup>
102-
<h:outputText value="#{questionPoolMessages.impToAuthor} "/>
103-
<h:outputText value="#{questionPoolMessages.select_all}"/>
104-
<h:selectBooleanCheckbox id="importSelectAllCheck" onclick="toggleCheckboxes(this,'importCheckbox');" value="" />
105-
</h:panelGroup>
102+
<h:outputText value="#{questionPoolMessages.impToAuthor} "/>
103+
<h:outputText value="#{questionPoolMessages.select_all}"/>
104+
<h:selectBooleanCheckbox id="importSelectAllCheck" onclick="toggleCheckboxes(this,'importCheckbox');updateButtonStatusOnCheck(document.getElementById('editform:import'), document.getElementById('editform'));" value="" />
105+
</h:panelGroup>
106106
</f:facet>
107-
<h:selectManyCheckbox immediate="true" id="importCheckbox" value="#{questionpool.destItems}" onclick="toggleSelectAllCheck(this,'importSelectAllCheck');">
107+
<h:selectManyCheckbox immediate="true" id="importCheckbox" value="#{questionpool.destItems}" onclick="toggleSelectAllCheck(this,'importSelectAllCheck');updateButtonStatusOnCheck(document.getElementById('editform:import'), document.getElementById('editform'));">
108108
<f:selectItem itemValue="#{question.itemIdString}" itemLabel=""/>
109-
</h:selectManyCheckbox>
110-
</h:column>
109+
</h:selectManyCheckbox>
110+
</h:column>
111111

112112

113113
</t:dataTable>

0 commit comments

Comments
 (0)