Skip to content

Commit

Permalink
SAM-2731 Negative points feature was always disable
Browse files Browse the repository at this point in the history
There are 3 competing features in samigo:
- Partial credit
- Negative Points
- Minimum Points

It would appear that these features were not meant to be used together,
in this change the negative points feature is disabled when on of the other 2
features is enabled.
  • Loading branch information
ern committed Apr 18, 2016
1 parent 2d462a0 commit 7fd41f3
Show file tree
Hide file tree
Showing 16 changed files with 94 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,8 @@ upload=Upload
browse=Browse

note_negative_point_value_part=REQUIRED: Overrides corresponding value in originating pool. Pertains only to 'True False' or 'Multiple Choice, Single Correct' questions.
note_negative_point_value_question=Optional. Pertains only to 'True False' or 'Multiple Choice, Single Correct' questions.
negative_point_value=* Negative point value for incorrect answer selection
negative_point_value=Negative point value for incorrect answer selection
negative_point_value_note=Negative point is disabled due to the use of minimum point or partial credit features.

select_action=-- Select Action --
action_scores=Scores
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1554,4 +1554,24 @@ public void setAllowMinScore(Boolean allowMinScore) {
this.allowMinScore = allowMinScore;
}

public boolean isDisableNegativePoints() {
Long type = null;
try {
type = Long.parseLong(currentItem.getItemType());
} catch (NumberFormatException nfe) {
return true;
}
boolean value = true;
if (currentItem != null && !getAllowMinScore() && // disable if using min score
(currentItem.getPartialCreditFlag().equals("false") || !currentItem.isPartialCreditEnabled()) && // disable if using partial credit
(type == TypeFacade.MULTIPLE_CHOICE || // enable for single correct
type == TypeFacade.MULTIPLE_CORRECT_SINGLE_SELECTION || // enable for multiple correct single selection
type == TypeFacade.TRUE_FALSE || // enable for multiple correct single selection
(type == TypeFacade.MULTIPLE_CORRECT && // enable for multiple correct multiple selection and
(currentItem.getMcmsPartialCredit().equals("false"))))) { // not using multiple choice multiple correct partial credit
value = false;
}
log.debug("Disable negative points: " + Boolean.toString(value));
return value;
}
}
59 changes: 42 additions & 17 deletions samigo/samigo-app/src/webapp/js/authoring.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,48 @@ function disableImport(){
}
}

function toPoint(id)
{
var x=document.getElementById(id).value
document.getElementById(id).value=x.replace(',','.')
$( document ).ready( function() {

// inputText with class ConvertPoint changes
$( "input.ConvertPoint[type='text']" ).change( function() {
var value = $( this ).val();
if (value) {
$( this ).val(value.replace(',','.'));
} else {
$( this ).val("0")
}
});

// validation for minPoints
$( "#itemForm\\:minPoints\\:answerminptr" ).change( function() {
var pointValue = parseFloat( $( "#itemForm\\:answerptr" ).val() );
var minValue = parseFloat ( $( this ).val() );
if (!pointValue.isNaN && !minValue.isNaN) {
// minValue should not be equal to or greater than pointValue
if (minValue < 0 || minValue >= pointValue) {
validationWarningSetDefault($( this ), "0")
}
}
});

// validation for negative points
$( "#itemForm\\:answerdsc" ).change( function() {
var pointValue = parseFloat( $( "#itemForm\\:answerptr" ).val() );
var negativeValue = parseFloat ( $( this ).val() );
if (!pointValue.isNaN && !negativeValue.isNaN) {
// minValue should not be equal to or greater than pointValue
if (negativeValue < 0 || negativeValue > pointValue) {
validationWarningSetDefault($( this ), "0")
}
}
});

});

function validationWarningSetDefault(element, value) {
$( element ).animate({ backgroundColor: "red" });
$( element ).val(value);
$( element ).animate({ backgroundColor: "transparent" });
}

/**
Expand Down Expand Up @@ -654,18 +692,6 @@ function mySetMainFrameHeight(id, minHeight)
}
}

function toggleNegativePointVal(val){
var negPointField = document.getElementById('itemForm:answerdsc');
if(negPointField){
if(val){
negPointField.value = 0;
negPointField.disabled = true;
}else{
negPointField.disabled = false;
}
}
}

function resetSelectMenus(){
var selectlist = document.getElementsByTagName("SELECT");

Expand All @@ -681,4 +707,3 @@ function clickInsertLink(field){
var hiddenSelector = "#" + insertlinkid.replace( /(:|\.|\[|\]|,)/g, "\\$1" );
$(hiddenSelector).click();
}

2 changes: 1 addition & 1 deletion samigo/samigo-app/src/webapp/jsf/author/editAssessment.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ $(window).load( function() {
<h:outputText rendered="#{question.itemData.typeId== 16}" value=" #{authorMessages.image_map_question}"/><!-- IMAGEMAP_QUESTION -->

<h:outputText value=" #{authorMessages.dash} " />
<h:inputText id="answerptr" value="#{question.updatedScore}" required="true" disabled="#{author.isEditPoolFlow || (question.itemData.typeId== 14)}" label="#{authorMessages.pt}" size="6" onkeydown="inIt()" onchange="toPoint(this.id);" rendered="#{question.itemData.typeId!= 3}">
<h:inputText id="answerptr" value="#{question.updatedScore}" required="true" disabled="#{author.isEditPoolFlow || (question.itemData.typeId== 14)}" label="#{authorMessages.pt}" size="6" onkeydown="inIt()" styleClass="ConvertPoint" rendered="#{question.itemData.typeId!= 3}">
<f:validateDoubleRange minimum="0.00"/></h:inputText>
<h:outputText rendered="#{question.itemData.typeId== 3}" value="#{question.updatedScore}"/>
<h:outputText rendered="#{question.itemData.score > 1}" value=" #{authorMessages.points_lower_case}"/>
Expand Down
4 changes: 2 additions & 2 deletions samigo/samigo-app/src/webapp/jsf/author/editPart.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@
<t:fieldset styleClass="roundedBorder" legend="#{authorMessages.scoring}" rendered="#{sectionBean.type == '2'}">
<t:div id="pointsOption" rendered="#{sectionBean.type == '2'}">
<h:outputText rendered="#{sectionBean.type == '2'}" value="#{authorMessages.random_draw_correct_prefix}"/>
<h:inputText rendered="#{sectionBean.type == '2'}" id="numPointsRandom" disabled="#{sectionBean.type == '1' || !author.isEditPendingAssessmentFlow}" value="#{sectionBean.randomPartScore}" onchange="toPoint(this.id);"/>
<h:inputText rendered="#{sectionBean.type == '2'}" id="numPointsRandom" disabled="#{sectionBean.type == '1' || !author.isEditPendingAssessmentFlow}" value="#{sectionBean.randomPartScore}" styleClass="ConvertPoint"/>
<h:outputText rendered="#{sectionBean.type == '2'}" value="#{authorMessages.random_draw_correct_suffix}"/>
</t:div>
<t:div id="deductOption" rendered="#{sectionBean.type == '2'}">
<h:outputText rendered="#{sectionBean.type == '2'}" value="#{authorMessages.random_draw_deduct_prefix}"/>
<h:inputText rendered="#{sectionBean.type == '2'}" id="numDiscountRandom" disabled="#{sectionBean.type == '1' || !author.isEditPendingAssessmentFlow}" value="#{sectionBean.randomPartDiscount}" onchange="toPoint(this.id);"/>
<h:inputText rendered="#{sectionBean.type == '2'}" id="numDiscountRandom" disabled="#{sectionBean.type == '1' || !author.isEditPendingAssessmentFlow}" value="#{sectionBean.randomPartDiscount}" styleClass="ConvertPoint"/>
<h:outputText rendered="#{sectionBean.type == '2'}" value="#{authorMessages.random_draw_deduct_suffix}"/>
</t:div>
</t:fieldset>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@
<h:outputLabel value="#{authorMessages.answer_point_value}" styleClass="col-md-4 form-control-label"/>
<div class="col-md-2">
<h:inputText id="answerptr" label="#{authorMessages.pt}" value="#{itemauthor.currentItem.itemScore}"
required="true" disabled="#{author.isEditPoolFlow}" onchange="toPoint(this.id);"
styleClass="form-control">
required="true" disabled="#{author.isEditPoolFlow}" styleClass="form-control ConvertPoint">
<f:validateDoubleRange minimum="0.00"/>
</h:inputText>
<h:message for="answerptr" styleClass="validate"/>
Expand All @@ -100,7 +99,7 @@
Ths is commented out since it doesn't make sense to have a min value for a question that doesn't automatically calculate a score
<div class="shorttext">
<h:outputLabel value="#{authorMessages.answer_min_point_value}" />
<h:inputText id="answerminptr" value="#{itemauthor.currentItem.itemMinScore}" onchange="toPoint(this.id);">
<h:inputText id="answerminptr" value="#{itemauthor.currentItem.itemMinScore}" styleClass="ConvertPoint">
<f:validateDoubleRange/>
</h:inputText><br/>
<h:message for="answerminptr" styleClass="validate"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@
<f:verbatim>
<br />
</f:verbatim>
<h:inputText id="itemScore" value="#{answer.score}" onchange="toPoint(this.id);"
<h:inputText id="itemScore" value="#{answer.score}" styleClass="ConvertPoint"
style="" size="4" maxlength="4" >
<f:validateDoubleRange minimum="0.00"/>
</h:inputText>
Expand Down
8 changes: 2 additions & 6 deletions samigo/samigo-app/src/webapp/jsf/author/item/fileUpload.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,13 @@
</h:commandButton>
</p>


<!-- QUESTION PROPERTIES -->
<!-- 1 POINTS -->
<div class="form-group row">
<h:outputLabel for="answerptr" value="#{authorMessages.answer_point_value}" styleClass="col-md-2 form-control-label"/>
<div class="col-md-2">
<h:inputText id="answerptr" label="#{authorMessages.pt}" value="#{itemauthor.currentItem.itemScore}"
required="true" disabled="#{author.isEditPoolFlow}" onchange="toPoint(this.id);" styleClass="form-control">
required="true" disabled="#{author.isEditPoolFlow}" styleClass="form-control ConvertPoint">
<f:validateDoubleRange minimum="0.00"/>
</h:inputText>
<h:message for="answerptr" styleClass="validate"/><br/>
Expand All @@ -87,7 +86,7 @@
Ths is commented out since it doesn't make sense to have a min value for a question that doesn't automatically calculate a score
<div class="shorttext">
<h:outputLabel value="#{authorMessages.answer_min_point_value}" />
<h:inputText id="answerminptr" value="#{itemauthor.currentItem.itemMinScore}" onchange="toPoint(this.id);">
<h:inputText id="answerminptr" value="#{itemauthor.currentItem.itemMinScore}" styleClass="form-control ConvertPoint">
<f:validateDoubleRange/>
</h:inputText>
<h:message for="answerminptr" styleClass="validate"/><br/>
Expand Down Expand Up @@ -183,9 +182,6 @@
</div>
</h:panelGroup>




<p class="act">

<h:commandButton rendered="#{itemauthor.target=='assessment'}" value="#{commonMessages.action_save}" action="#{itemauthor.currentItem.getOutcome}" styleClass="active">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@
<h:outputLabel for="answerptr" value="#{authorMessages.answer_point_value}" styleClass="col-md-4 form-control-label"/>
<div class="col-md-2">
<h:inputText id="answerptr" label="#{authorMessages.pt}" value="#{itemauthor.currentItem.itemScore}"
required="true" disabled="#{author.isEditPoolFlow}" onchange="toPoint(this.id);"
styleClass="form-control">
required="true" disabled="#{author.isEditPoolFlow}" styleClass="form-control ConvertPoint">
<f:validateDoubleRange minimum="0.00"/>
</h:inputText>
<h:message for="answerptr" styleClass="validate"/>
Expand All @@ -82,8 +81,7 @@
<div class="form-group row">
<h:outputLabel for="answerminptr" value="#{authorMessages.answer_min_point_value}" styleClass="col-md-4 form-control-label"/>
<div class="col-md-2">
<h:inputText id="answerminptr" value="#{itemauthor.currentItem.itemMinScore}"
onchange="toPoint(this.id);" styleClass="form-control">
<h:inputText id="answerminptr" value="#{itemauthor.currentItem.itemMinScore}" styleClass="form-control ConvertPoint">
<f:validateDoubleRange />
</h:inputText>
<h:outputText value="#{authorMessages.answer_min_point_info}"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<h:outputLabel for="answerptr" value="#{authorMessages.answer_point_value}" styleClass="col-md-4 form-control-label"/>
<div class="col-md-2">
<h:inputText id="answerptr" label="#{authorMessages.pt}" value="#{itemauthor.currentItem.itemScore}"
required="true" disabled="#{author.isEditPoolFlow}" onchange="toPoint(this.id);" styleClass="form-control">
required="true" disabled="#{author.isEditPoolFlow}" styleClass="form-control ConvertPoint">
<f:validateDoubleRange minimum="0.00"/>
</h:inputText>
<h:message for="answerptr" styleClass="validate"/>
Expand All @@ -102,8 +102,7 @@
<div class="form-group row">
<h:outputLabel value="#{authorMessages.answer_min_point_value}" styleClass="col-md-4 form-control-label"/>
<div class="col-md-2">
<h:inputText id="answerminptr" value="#{itemauthor.currentItem.itemMinScore}" onchange="toPoint(this.id);"
styleClass="form-control">
<h:inputText id="answerminptr" value="#{itemauthor.currentItem.itemMinScore}" styleClass="form-control ConvertPoint">
<f:validateDoubleRange/>
</h:inputText>
<h:outputText value="#{authorMessages.answer_min_point_info}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
<!-- 1 POINTS -->
<div class="tier2">
<div class="shorttext"> <h:outputLabel value="#{authorMessages.answer_point_value}" />
<h:inputText id="answerptr" label="#{authorMessages.pt}" value="#{itemauthor.currentItem.itemScore}" required="true" disabled="#{author.isEditPoolFlow}" onchange="toPoint(this.id);">
<h:inputText id="answerptr" label="#{authorMessages.pt}" value="#{itemauthor.currentItem.itemScore}" required="true" disabled="#{author.isEditPoolFlow}" styleClass="ConvertPoint">
<f:validateDoubleRange minimum="0.00"/>
</h:inputText>
<br/><h:message for="answerptr" styleClass="validate"/>
Expand Down
7 changes: 3 additions & 4 deletions samigo/samigo-app/src/webapp/jsf/author/item/matching.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<h:outputLabel for="answerptr" value="#{authorMessages.answer_point_value}" styleClass="col-md-4 form-control-label"/>
<div class="col-md-2">
<h:inputText id="answerptr" label="#{authorMessages.pt}" value="#{itemauthor.currentItem.itemScore}"
required="true" disabled="#{author.isEditPoolFlow}" onchange="toPoint(this.id);" styleClass="form-control">
required="true" disabled="#{author.isEditPoolFlow}" styleClass="form-control ConvertPoint">
<f:validateDoubleRange minimum="0.00"/>
</h:inputText>
<h:message for="answerptr" styleClass="validate"/>
Expand All @@ -114,8 +114,7 @@
<div class="form-group row">
<h:outputLabel value="#{authorMessages.answer_min_point_value}" styleClass="col-md-4 form-control-label"/>
<div class="col-md-2">
<h:inputText id="answerminptr" value="#{itemauthor.currentItem.itemMinScore}" onchange="toPoint(this.id);"
styleClass="form-control">
<h:inputText id="answerminptr" value="#{itemauthor.currentItem.itemMinScore}" styleClass="form-control ConvertPoint">
<f:validateDoubleRange/>
</h:inputText>
<h:outputText value="#{authorMessages.answer_min_point_info}" />
Expand All @@ -139,7 +138,7 @@

<!-- 2a ATTACHMENTS -->
<%@ include file="/jsf/author/item/attachment.jsp" %>

<!-- 3 ANSWER -->
<div class="longtext">
<h:outputLabel value="#{authorMessages.create_pairing} " />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,14 @@
</h:commandButton>
</p>


<div>

<!-- 1 POINTS -->
<div class="form-group row">
<h:outputLabel value="#{authorMessages.answer_point_value}" styleClass="col-md-4 form-control-label"/>
<div class="col-md-2">
<h:inputText id="answerptr" label="#{authorMessages.pt}" value="#{itemauthor.currentItem.itemScore}"
required="true" size="6" onchange="toPoint(this.id);" styleClass="form-control">
required="true" size="6" styleClass="form-control ConvertPoint">
<f:validateDoubleRange />
</h:inputText>
<h:message for="answerptr" styleClass="validate" />
Expand Down
24 changes: 5 additions & 19 deletions samigo/samigo-app/src/webapp/jsf/author/item/multipleChoice.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<div class="form-group row">
<h:outputLabel styleClass="col-md-2" value="#{authorMessages.answer_point_value}" />
<div class="col-md-2">
<h:inputText id="answerptr" label="#{authorMessages.pt}" value="#{itemauthor.currentItem.itemScore}" required="true" styleClass="form-control" disabled="#{author.isEditPoolFlow}" onchange="toPoint(this.id);">
<h:inputText id="answerptr" label="#{authorMessages.pt}" value="#{itemauthor.currentItem.itemScore}" required="true" styleClass="form-control ConvertPoint" disabled="#{author.isEditPoolFlow}">
<f:validateDoubleRange minimum="0.00" />
</h:inputText>
<h:message for="answerptr" styleClass="validate" />
Expand All @@ -81,7 +81,7 @@
<f:subview id="minPoints" rendered="#{itemauthor.allowMinScore}">
<div class="shorttext">
<h:outputLabel value="#{authorMessages.answer_min_point_value}" />
<h:inputText id="answerminptr" value="#{itemauthor.currentItem.itemMinScore}" size="6" onchange="toPoint(this.id); toggleNegativePointVal(this.value);">
<h:inputText id="answerminptr" value="#{itemauthor.currentItem.itemMinScore}" size="6" styleClass="ConvertPoint">
<f:validateDoubleRange />
</h:inputText>
<small>
Expand Down Expand Up @@ -153,14 +153,13 @@
</div>

<div id="discountDiv" class="longtext">
<h:panelGroup id="discountTable"
rendered="#{(itemauthor.currentItem.itemType==1 &&(itemauthor.currentItem.partialCreditFlag=='false'||itemauthor.currentItem.partialCreditEnabled==false))
|| itemauthor.currentItem.itemType==12 || (itemauthor.currentItem.itemType==2 && itemauthor.currentItem.mcmsPartialCredit=='false')}">
<h:panelGroup id="discountTable">
<h:outputText value="&nbsp;&nbsp;" escape="false" />
<h:outputLabel value="#{authorMessages.negative_point_value}"/>
<h:inputText id="answerdsc" value="#{itemauthor.currentItem.itemDiscount}" required="true" onchange="toPoint(this.id);">
<h:inputText id="answerdsc" value="#{itemauthor.currentItem.itemDiscount}" required="true" styleClass="ConvertPoint" disabled="#{itemauthor.disableNegativePoints}">
<f:validateDoubleRange/>
</h:inputText>
<small><h:outputText value="#{authorMessages.negative_point_value_note}" rendered="#{itemauthor.disableNegativePoints==true}"/></small>
<f:verbatim> <script type="text/javascript" defer='defer'>
var itemType = "${itemauthor.currentItem.itemType}";
var discDiv=document.getElementById('discountDiv');
Expand Down Expand Up @@ -417,19 +416,6 @@
</h:commandButton>

</p>

<f:subview id="disableNegVal" rendered="#{!empty itemauthor.currentItem.itemMinScore}">
<f:verbatim>
<script type="text/javascript">
var negPointField = document.getElementById('itemForm:answerdsc');
if(negPointField){
negPointField.value = 0;
negPointField.disabled = true;
}
</script>
</f:verbatim>
</f:subview>

</h:form>
<!-- end content -->
</div>
Expand Down
Loading

0 comments on commit 7fd41f3

Please sign in to comment.