Skip to content

Commit

Permalink
Merge pull request sakaiproject#1515 from plukasew/SAM-2688
Browse files Browse the repository at this point in the history
SAM-2688: Improve on-screen instructions for Calculated Question type
  • Loading branch information
bjones86 committed Jan 5, 2016
2 parents 5f24911 + d45d946 commit 0aeb746
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,26 +94,38 @@ calc_question_walkthrough3=Change the Min, Max, and Decimal Places for all of th
calc_question_walkthrough4=Enter the mathematical expression for each Formula, inserting the Variables where needed.
calc_question_walkthrough5=Press the Save button to save your work.
calc_question_walkthrough6=Any errors will be displayed at the top of the page. They must be fixed before saving. Fields with errors will be highlighted to show you where you have problems.
calc_question_extract_button=Extract Variables and Formulas
calc_question_define_vars=Define variables to use in this question below. Reference them in the question text by putting them in single curly braces eg. {x}. Variable names are alpha-numeric but must begin with an alpha character
calc_question_answer_expression=Place double curly braces (e.g. {{y}} around a formula name, to define where the student's input box will display. Formula names are alpha-numeric but must begin with an alpha character.
calc_question_extract_button=Extract Variables and Formulas from Question Text
calc_question_define_vars=Define variables in the question text and in formula expressions by putting them in single curly braces ( e.g. {a}, {b}, and {c} ).
calc_question_define_vars2=Enclose variable names in single curly braces (e.g. {x}).
calc_question_answer_expression=Place double curly braces around a formula name ( e.g. {{z}} ). This also defines where the student's input box will display.
calc_question_answer_variance=You may define acceptable tolerance as a constant (0.01) or percentage (1.5%) of the answer. (Defaults to 0.01.)
calc_question_answer_decimal=Variables and formulas support decimals. Default is 3.
calc_question_example1=Kevin has {x} apples. Jane eats {y}. How many does Kevin have now? {{z}}
calc_question_example1=Kevin has {x} apples. Jane eats {y}. Kevin now has {{z}} apples.
calc_question_example1_formula=The formula z in the example above would be defined as: {x} - {y}
calc_question_functions=You can use the following math functions: SIN, COS, TAN, ASIN, ACOS, ATAN, ABS, EXP, SIGN, SQRT, FACTORIAL, LOG10, LOG, and LN.
calc_question_example2=Solve: COS({a}) * ({c} - {b}) = {{z}} Formula z would be COS({a}) * ({c}-{b})
calc_question_constants=There are two built-in constants, PI(3.14...) and e(2.718...). Use them in your answer expression.
calc_question_unique_names=Variables and Formulas cannot have the same name.
calc_question_example2=Solve: COS({a}) * ({c} - {b}) = {{z}}.
calc_question_example2_formula=The formula z in the example above would be defined as: COS({a}) * ({c} - {b})
calc_question_constants=There are two built-in constants, PI(3.14...) and e(2.718...). Use them in your formula expression.
calc_question_var_names=Variable and formula names are alpha-numeric but must begin with an alpha character
calc_question_unique_names=Variables and formulas cannot have the same name.
calc_question_preview=You are strongly encouraged to use the Preview Assessment feature to check for mistakes. Extract and Save buttons both validate formulas.
calc_question_hideshow=Show/Hide more instructions and examples
calc_question_operators=Valid Operators: + - * / ^ ()
calc_question_operators=Valid operators: + - * / ^ ()
calc_question_error_syntax=Your answer's acceptable variance and expected decimal places must be formatted in this fashion: {x+y|1%,2} or {x+y|1,2}. The expected decimal places can be omitted e.g. {x+y|1%}. 6 is the limit on decimal places.
calc_question_error_expression=There is a mathematical error in your answer expression.
calc_question_error_expression_variables=The mathematical formula references a variable that used in the instructions.
calc_question_prompt_preview=After you save, be sure to use Preview Assessment to ensure this questions functions as you expect!
calc_question_no_calculations=No calculations have been defined
calc_question_calculation_sample_col=Sample
calc_question_calculation_status_col=Status
calc_question_instructions_label=Instructions
calc_question_simple_instructions_step_1=Define variables in the question text by surrounding the variable name with single curly braces ( e.g. {x} and {y} )
calc_question_simple_instructions_step_1a=When a student views the question, variable placeholders will be replaced with the variable values
calc_question_simple_instructions_step_2=Define formula placeholders in the question text by surrounding the formula name with double curly braces ( e.g. {{z}} )
calc_question_simple_instructions_step_2a=When the student views the question, formula placeholders will be replaced with input boxes
calc_question_simple_instructions_step_3=After writing the question text, press the button to Extract Variables and Formulas
calc_question_simple_instructions_step_3a=Set the min and max values for the variables
calc_question_simple_instructions_step_3b=Define formula expressions in terms of the variables, using single curly braces ( e.g. {x} - {y} )

# CALCULATED QUESTION ERRORS
empty_field=Field cannot be empty
Expand Down
18 changes: 13 additions & 5 deletions samigo/samigo-app/src/webapp/js/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,23 @@ function toggleGroups(clickedElement) {
}

// Change the triangle disclosure icon as appropriate
if (clickedElement.className === "collapsed") {
clickedElement.className = "expanded";
} else {
clickedElement.className = "collapsed";
}
toggleCollapse(clickedElement);
}
}
}

function toggleCollapse(element)
{
if (element.className === "collapsed")
{
element.className = "expanded";
}
else
{
element.className = "collapsed";
}
}

// Utility function equivalent to String.endsWith()
function endsWith(string, suffix) {
return string.indexOf(suffix, string.length - suffix.length) !== -1;
Expand Down
64 changes: 44 additions & 20 deletions samigo/samigo-app/src/webapp/jsf/author/item/calculatedQuestion.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ confirmation dialog
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head><%= request.getAttribute("html.head") %>
<title><h:outputText value="#{authorMessages.item_display_author}"/></title>
<script type="text/javascript" src="/samigo-app/js/info.js"></script>
<!-- AUTHORING -->
<samigo:script path="/js/authoring.js"/>
<script type="text/javascript">
Expand Down Expand Up @@ -116,14 +117,32 @@ confirmation dialog
<div class="longtext"> <h:outputLabel value="#{authorMessages.q_text}" />
<br/></div>
<div class="tier2">

<h:outputText value="#{authorMessages.calc_question_define_vars}" /><br/>
<h:outputText value="#{authorMessages.calc_question_answer_expression}" /><br/>
<h:outputText value="#{authorMessages.calc_question_answer_variance}" /><br/><br/>

<h:outputLink onclick="$('#calcQInstructions').toggle();" value="#">
<p><h:outputText value="#{authorMessages.calc_question_general_instructions1 }" /></p>
<label><h:outputText value="#{authorMessages.calc_question_instructions_label}"/></label>
<ol>
<li><h:outputText value="#{authorMessages.calc_question_simple_instructions_step_1}" /></li>
<ul>
<li><h:outputText value="#{authorMessages.calc_question_simple_instructions_step_1a}" /></li>
</ul>
<li><h:outputText value="#{authorMessages.calc_question_simple_instructions_step_2}" /></li>
<ul>
<li><h:outputText value="#{authorMessages.calc_question_simple_instructions_step_2a}" /></li>
</ul>
<li><h:outputText value="#{authorMessages.calc_question_simple_instructions_step_3}" /></li>
<ol type="a">
<li><h:outputText value="#{authorMessages.calc_question_simple_instructions_step_3a}" /></li>
<li><h:outputText value="#{authorMessages.calc_question_simple_instructions_step_3b}" /></li>
</ol>
</ol>
<label><h:outputText value="#{authorMessages.calc_question_example_label}"/></label>
<p class="tier2"><h:outputText value="#{authorMessages.calc_question_example1}"/></p>
<p class="tier2"><h:outputText value="#{authorMessages.calc_question_example1_formula}"/></p>

<div id="calcQShowHide" class="collapsed">
<h:outputLink onclick="$('#calcQInstructions').toggle();toggleCollapse(document.getElementById('calcQShowHide'));" value="#">
<h:outputText value="#{authorMessages.calc_question_hideshow}"/>
</h:outputLink>
</div>
<div id="calcQInstructions" style='display:none;'>
<div class="longtext"><h:outputLabel value="#{authorMessages.calc_question_general_instructsion_label}" /></div>
<div class="tier2">
Expand All @@ -146,18 +165,13 @@ confirmation dialog
<div class="tier2">
<h:outputText value="#{authorMessages.calc_question_define_vars}" />
</div>
<div class="longtext"><h:outputLabel value="#{authorMessages.calc_question_example_label}" /></div>
<div class="tier2">
<h:outputText value="#{authorMessages.calc_question_example1}" />
</div>
<div class="longtext"><h:outputLabel value="#{authorMessages.calc_question_formula_label}" /></div>
<div class="tier2">
<h:outputText value="#{authorMessages.calc_question_answer_expression}" />
</div>
<div class="longtext"><h:outputLabel value="#{authorMessages.calc_question_example_label}" /></div>
<div class="tier2">
<h:outputText value="#{authorMessages.calc_question_example2}" />
</div>
<p class="tier2"><h:outputText value="#{authorMessages.calc_question_example2}" /></p>
<p class="tier2"><h:outputText value="#{authorMessages.calc_question_example2_formula}" /></p>
<div class="longtext"><h:outputLabel value="#{authorMessages.calc_question_additional_label}" /></div>
<div class="tier2">
<ul>
Expand All @@ -166,6 +180,7 @@ confirmation dialog
<li><h:outputText value="#{authorMessages.calc_question_operators}" /></li>
<li><h:outputText value="#{authorMessages.calc_question_functions}" /></li>
<li><h:outputText value="#{authorMessages.calc_question_constants}" /></li>
<li><h:outputText value="#{authorMessages.calc_question_var_names}"/></li>
<li><h:outputText value="#{authorMessages.calc_question_unique_names}"/></li>
</ul>
</div>
Expand All @@ -181,18 +196,19 @@ confirmation dialog

</h:panelGrid>

<h:commandButton rendered="#{itemauthor.target=='assessment' || itemauthor.target=='questionpool'}"
value="#{authorMessages.calc_question_extract_button}"
action="calculatedQuestion"
styleClass="active">
<f:actionListener type="org.sakaiproject.tool.assessment.ui.listener.author.CalculatedQuestionExtractListener" />
</h:commandButton>
</div>

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

<!-- 3 ANSWER -->

<h:commandButton rendered="#{itemauthor.target=='assessment' || itemauthor.target=='questionpool'}"
value="#{authorMessages.calc_question_extract_button}"
action="calculatedQuestion"
styleClass="active">
<f:actionListener type="org.sakaiproject.tool.assessment.ui.listener.author.CalculatedQuestionExtractListener" />
</h:commandButton>
<!-- display variables -->
<div class="longtext"> <h:outputLabel value="#{authorMessages.calc_question_var_label} " /></div>
<div class="tier2">
Expand Down Expand Up @@ -247,7 +263,15 @@ confirmation dialog
</div>

<!-- display formulas -->
<div class="longtext"> <h:outputLabel value="#{authorMessages.calc_question_formula_label} " /></div>
<div class="longtext">
<h:outputLabel value="#{authorMessages.calc_question_formula_label} " />
<ul>
<li><h:outputText value="#{authorMessages.calc_question_simple_instructions_step_3b}" /></li>
<li><h:outputText value="#{authorMessages.calc_question_operators}" /></li>
<li><h:outputText value="#{authorMessages.calc_question_functions}" /></li>
<li><h:outputText value="#{authorMessages.calc_question_constants}" /></li>
</ul>
</div>
<div class="tier2">
<h:dataTable cellpadding="0" cellspacing="0" styleClass="listHier" id="formulas"
value="#{itemauthor.currentItem.calculatedQuestion.formulasList}" var="formula">
Expand Down

0 comments on commit 0aeb746

Please sign in to comment.