Skip to content

Commit

Permalink
Merge pull request sakaiproject#1680 from jonespm/SAM-948
Browse files Browse the repository at this point in the history
SAM-948 - 'Minimum value' option for questions
  • Loading branch information
jonespm committed Feb 9, 2016
2 parents 0877396 + ac87168 commit 3bd0a16
Show file tree
Hide file tree
Showing 26 changed files with 308 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2926,6 +2926,10 @@
# syllabus.new.published.default=true

## TEST & QUIZZES (SAMIGO)
# SAM-948 - Minimum value option for questions
# DEFAULT: FALSE
# samigo.allowMinScore=true

# Samigo File Upload question type settings default settings:
# DEFAULT: 1024
# samigo.sizeThreshold=512
Expand Down
6 changes: 6 additions & 0 deletions reference/docs/conversion/sakai_11_mysql_conversion.sql
Original file line number Diff line number Diff line change
Expand Up @@ -590,3 +590,9 @@ CREATE INDEX IDX_QRTZ_FT_JG ON QRTZ_FIRED_TRIGGERS(SCHED_NAME,JOB_GROUP);
CREATE INDEX IDX_QRTZ_FT_T_G ON QRTZ_FIRED_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP);
CREATE INDEX IDX_QRTZ_FT_TG ON QRTZ_FIRED_TRIGGERS(SCHED_NAME,TRIGGER_GROUP);

--
-- SAM-948 - MIN_SCORE option in Samigo
--

alter table SAM_ITEM_T add column MIN_SCORE double NULL;
alter table SAM_PUBLISHEDITEM_T add column MIN_SCORE double NULL;
7 changes: 7 additions & 0 deletions reference/docs/conversion/sakai_11_oracle_conversion.sql
Original file line number Diff line number Diff line change
Expand Up @@ -634,3 +634,10 @@ create index idx_qrtz_ft_j_g on qrtz_fired_triggers(SCHED_NAME,JOB_NAME,JOB_GROU
create index idx_qrtz_ft_jg on qrtz_fired_triggers(SCHED_NAME,JOB_GROUP);
create index idx_qrtz_ft_t_g on qrtz_fired_triggers(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP);
create index idx_qrtz_ft_tg on qrtz_fired_triggers(SCHED_NAME,TRIGGER_GROUP);

--
-- SAM-948 - MIN_SCORE option in Samigo
--

alter table SAM_ITEM_T add MIN_SCORE double precision NULL;
alter table SAM_PUBLISHEDITEM_T add MIN_SCORE double precision NULL;
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ public interface ItemDataIfc extends Comparable<ItemDataIfc>, java.io.Serializab
void setScore(Double score);

Double getDiscount();

Double getMinScore();

void setMinScore(Double minScore);

void setDiscount(Double discount);

String getHint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ answer_options_count=Number of options in this question (e.g. A to G = 7)
required_options_count=Number of required answers
answers_required=answer(s) required
answer_point_value=Answer Point Value
answer_min_point_value=Minimum Point Value (optional)
answer_min_point_info=*Points assigned to the user for attempting the question
answer_provide_a_mo=Answer: Provide a model answer to show students and to assist graders along with any feedback.
answer_text_predefi=Answer Text: Predefined set of scales for survey reporting.
answers=Answers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.sakaiproject.component.cover.ServerConfigurationService;
import org.sakaiproject.authz.api.SecurityAdvisor;
import org.sakaiproject.authz.cover.SecurityService;
import org.sakaiproject.content.api.ContentCollectionEdit;
Expand Down Expand Up @@ -150,7 +152,7 @@ public class ItemAuthorBean
private String[] matchAnswers;
private String[] matchFeedbackList;
private String[] answerFeedbackList;

private Boolean allowMinScore;
// for navigation
private String outcome;

Expand Down Expand Up @@ -1541,4 +1543,15 @@ public AnswerBean getCurrentAnswer() {
public void setCurrentAnswer(AnswerBean currentAnswer) {
this.currentAnswer = currentAnswer;
}
public Boolean getAllowMinScore() {
if(allowMinScore == null){
allowMinScore = ServerConfigurationService.getBoolean("samigo.allowMinScore", Boolean.FALSE);
}
return allowMinScore;
}

public void setAllowMinScore(Boolean allowMinScore) {
this.allowMinScore = allowMinScore;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public class ItemBean
private String itemId;
private String itemType;
private double itemScore= 0.0d;
private double itemMinScore = 0.0d;
private double itemDiscount = 0.0d;
private String partialCreditFlag = "Defualt";
private String[] answers;
Expand Down Expand Up @@ -2056,4 +2057,11 @@ public void setMcmsPartialCredit(String mcmsPartialCredit) {
this.mcmsPartialCredit = mcmsPartialCredit;
}

public double getItemMinScore() {
return itemMinScore;
}

public void setItemMinScore(double itemMinScore) {
this.itemMinScore = itemMinScore;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@ public void saveItem(ItemAuthorBean itemauthor) throws FinFormatException{
}
item.setScore(Double.valueOf(bean.getItemScore()));
item.setDiscount(Double.valueOf(bean.getItemDiscount()));
item.setMinScore(Double.valueOf(bean.getItemMinScore()));
item.setHint("");

item.setStatus(ItemDataIfc.ACTIVE_STATUS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,17 @@ public boolean populateItemBean(ItemAuthorBean itemauthorbean, String itemId) {
score = 0.0d;
}
bean.setItemScore(score);

Double minPoints = itemfacade.getMinScore();
Double minScore;
if (minPoints!=null && !"".equals(minPoints))
{
minScore = minPoints;
bean.setItemMinScore(minScore);
}else{
bean.setItemMinScore(0.0d);
}


Double discount = itemfacade.getDiscount();
if (discount == null)
Expand Down
11 changes: 11 additions & 0 deletions samigo/samigo-app/src/webapp/jsf/author/item/audioRecording.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@
<h:message for="answerptr" styleClass="validate"/>
</div>
<br/>
<!-- 1.2 MIN POINTS
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);">
<f:validateDoubleRange/>
</h:inputText><br/>
<h:message for="answerminptr" styleClass="validate"/>
</div>
<br/>
-->
<!-- 2 TEXT -->
<div class="longtext"> <h:outputLabel value="#{authorMessages.q_text}" />

Expand Down
11 changes: 11 additions & 0 deletions samigo/samigo-app/src/webapp/jsf/author/item/fileUpload.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,18 @@
</h:inputText>
<h:message for="answerptr" styleClass="validate"/><br/>
</div>
<br/>
<!-- 1.2 Min POINTS
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);">
<f:validateDoubleRange/>
</h:inputText>
<h:message for="answerminptr" styleClass="validate"/><br/>
</div>
<br/>
-->
<!-- 2 TEXT -->
<div class="longtext">
<h:outputLabel value="#{authorMessages.q_text}" />
Expand Down
22 changes: 21 additions & 1 deletion samigo/samigo-app/src/webapp/jsf/author/item/fillInNumeric.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<title><h:outputText value="#{authorMessages.item_display_author}"/></title>
<samigo:script path="/js/authoring.js"/>
</head>
<body onload="countNum();<%= request.getAttribute("html.body.onload") %>">
<body onload="countNum();<%= request.getAttribute("html.body.onload") %>">

<div class="portletBody">
<%-- content... --%>
Expand Down Expand Up @@ -77,6 +77,26 @@
<br/> <h:message for="answerptr" styleClass="validate"/>
</div>
<br/>
<%-- 1.2 MIN POINTS --%>
<f:subview id="minPoints" rendered="#{itemauthor.allowMinScore}">
<f:verbatim>
<div class="shorttext">
</f:verbatim>
<h:outputLabel value="#{authorMessages.answer_min_point_value}" />
<h:inputText id="answerminptr" value="#{itemauthor.currentItem.itemMinScore}" onchange="toPoint(this.id);">
<f:validateDoubleRange />
</h:inputText>
<f:verbatim><div></f:verbatim>
<h:outputText value="#{authorMessages.answer_min_point_info}" style="font-size: x-small" />
<f:verbatim></div></f:verbatim>
<br/> <h:message for="answerminptr" styleClass="validate"/>
<f:verbatim>
</div>
<br/>
</f:verbatim>
</f:subview>


<%-- 2 QUESTION TEXT --%>
<div class="longtext"> <h:outputLabel value="#{authorMessages.q_text}" />
<br/></div>
Expand Down
19 changes: 19 additions & 0 deletions samigo/samigo-app/src/webapp/jsf/author/item/fillInTheBlank.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,25 @@
<br/> <h:message for="answerptr" styleClass="validate"/>
</div>
<br/>
<!-- 1.2 Min POINTS -->
<f:subview id="minPoints" rendered="#{itemauthor.allowMinScore}">
<f:verbatim>
<div class="shorttext">
</f:verbatim>
<h:outputLabel value="#{authorMessages.answer_min_point_value}" />
<h:inputText id="answerminptr" value="#{itemauthor.currentItem.itemMinScore}" onchange="toPoint(this.id);">
<f:validateDoubleRange/>
</h:inputText>
<f:verbatim><div></f:verbatim>
<h:outputText value="#{authorMessages.answer_min_point_info}" style="font-size: x-small" />
<f:verbatim></div></f:verbatim>
<h:message for="answerminptr" styleClass="validate"/><br/>
<f:verbatim>
</div>
<br/>
</f:verbatim>
</f:subview>

<%-- 2 QUESTION TEXT --%>
<div class="longtext"> <h:outputLabel value="#{authorMessages.q_text}" />
<br/></div>
Expand Down
18 changes: 18 additions & 0 deletions samigo/samigo-app/src/webapp/jsf/author/item/matching.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,24 @@
<br/><h:message for="answerptr" styleClass="validate"/>
</div>
<br/>
<!-- 1.2 Min POINTS -->
<f:subview id="minPoints" rendered="#{itemauthor.allowMinScore}">
<f:verbatim>
<div class="shorttext">
</f:verbatim>
<h:outputLabel value="#{authorMessages.answer_min_point_value}" />
<h:inputText id="answerminptr" value="#{itemauthor.currentItem.itemMinScore}" onchange="toPoint(this.id);">
<f:validateDoubleRange/>
</h:inputText>
<f:verbatim><div></f:verbatim>
<h:outputText value="#{authorMessages.answer_min_point_info}" style="font-size: x-small" />
<f:verbatim></div></f:verbatim>
<br/><h:message for="answerminptr" styleClass="validate"/>
<f:verbatim>
</div>
<br/>
</f:verbatim>
</f:subview>
<!-- 2 TEXT -->
<div class="longtext"> <h:outputLabel value="#{authorMessages.q_text}" />
<br/>
Expand Down
44 changes: 44 additions & 0 deletions samigo/samigo-app/src/webapp/jsf/author/item/multipleChoice.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,37 @@
</div>
<br/>

<script type="text/javascript">
function toggleNegativePointVal(val){
var negPointField = document.getElementById('itemForm:answerdsc');
if(negPointField){
if(val){
negPointField.value = 0;
negPointField.disabled = true;
}else{
negPointField.disabled = false;
}
}
}
</script>

<f:subview id="minPoints" rendered="#{itemauthor.allowMinScore}">
<f:verbatim>
<div class="shorttext">
</f:verbatim>
<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);">
<f:validateDoubleRange /></h:inputText>
<f:verbatim><div></f:verbatim>
<h:outputText value="#{authorMessages.answer_min_point_info}" style="font-size: x-small" />
<f:verbatim></div></f:verbatim>
<h:message for="answerminptr" styleClass="validate"/>
<f:verbatim>
</div>
<br/>
</f:verbatim>
</f:subview>

<!-- 1 ANSWER -->
<div class="longtext">
<h:outputLabel value="#{authorMessages.answer} " />
Expand Down Expand Up @@ -425,6 +456,19 @@
</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
21 changes: 21 additions & 0 deletions samigo/samigo-app/src/webapp/jsf/author/item/shortAnswer.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,27 @@
<h:message for="answerptr" styleClass="validate"/>
</div>
<br/>
<!-- 1.2 MIN POINTS -->

<f:subview id="minPoints" rendered="#{itemauthor.allowMinScore}">
<f:verbatim>
<div class="shorttext">
</f:verbatim>
<h:outputLabel value="#{authorMessages.answer_min_point_value}" />
<h:inputText id="answerminptr" value="#{itemauthor.currentItem.itemMinScore}" onchange="toPoint(this.id);">
<f:validateDoubleRange/>
</h:inputText>
<f:verbatim><div></f:verbatim>
<h:outputText value="#{authorMessages.answer_min_point_info}" style="font-size: x-small" />
<f:verbatim></div></f:verbatim>
<br/>
<h:message for="answerminptr" styleClass="validate"/>
<f:verbatim>
</div>
<br/>
</f:verbatim>
</f:subview>

<!-- 2 TEXT -->
<div class="longtext"><h:outputLabel value="#{authorMessages.q_text}" />
<br/>
Expand Down
19 changes: 19 additions & 0 deletions samigo/samigo-app/src/webapp/jsf/author/item/trueFalse.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,25 @@
<h:message for="answerptr" styleClass="validate"/>
</div><br/>

<!-- 1.2 MIN POINTS -->
<f:subview id="minPoints" rendered="#{itemauthor.allowMinScore}">
<f:verbatim>
<div class="shorttext">
</f:verbatim>
<h:outputLabel value="#{authorMessages.answer_min_point_value}"/>
<h:inputText id="answerminptr" value="#{itemauthor.currentItem.itemMinScore}" onchange="toPoint(this.id);">
<f:validateDoubleRange />
</h:inputText>
<f:verbatim><div></f:verbatim>
<h:outputText value="#{authorMessages.answer_min_point_info}" style="font-size: x-small" />
<f:verbatim></div></f:verbatim>
<h:message for="answerminptr" styleClass="validate"/>
<f:verbatim>
</div>
<br/>
</f:verbatim>
</f:subview>

<!-- DISCOUNT -->
<div class="longtext">
<h:panelGrid columns="2" border="0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<property name="typeId" type="long" column="TYPEID" not-null="true" />
<property name="grade" type="string" length="80" column="GRADE" not-null="false" />
<property name="score" type="double" column="SCORE" not-null="false" />
<property name="minScore" type="double" column="MIN_SCORE" not-null="false" />
<property name="partialCreditFlag" type="boolean" column="PARTIAL_CREDIT_FLAG" not-null="false"/>
<property name="discount" type="double" column="DISCOUNT" not-null="false" />
<property name="answerOptionsRichCount" type="integer" column="ANSWER_OPTIONS_RICH_COUNT" not-null="false" />
Expand Down
Loading

0 comments on commit 3bd0a16

Please sign in to comment.