|
From: <lo...@us...> - 2010-03-25 16:15:34
|
Revision: 2397
http://qtitools.svn.sourceforge.net/qtitools/?rev=2397&view=rev
Author: loccy
Date: 2010-03-25 16:15:27 +0000 (Thu, 25 Mar 2010)
Log Message:
-----------
MQ: First bash at a MCQ quick creation screen. Changes to SnuggleTexView to accommodate it. Not yet hooked up in any of the MQ code proper though.
Modified Paths:
--------------
Mathqurate/trunk/mathqurate/src/main/java/org/qtitools/mathqurate/model/MQContentPackage.java
Mathqurate/trunk/mathqurate/src/main/java/org/qtitools/mathqurate/view/SnuggleTeXView.java
Added Paths:
-----------
Mathqurate/trunk/mathqurate/src/main/java/org/qtitools/mathqurate/utilities/SimpleChoiceQuickCreator.java
Mathqurate/trunk/mathqurate/src/main/java/org/qtitools/mathqurate/view/SimpleChoiceWizard.java
Mathqurate/trunk/mathqurate/src/main/resources/org/qtitools/mathqurate/resources/simpleChoiceTemplate.xml
Modified: Mathqurate/trunk/mathqurate/src/main/java/org/qtitools/mathqurate/model/MQContentPackage.java
===================================================================
--- Mathqurate/trunk/mathqurate/src/main/java/org/qtitools/mathqurate/model/MQContentPackage.java 2010-03-23 12:31:55 UTC (rev 2396)
+++ Mathqurate/trunk/mathqurate/src/main/java/org/qtitools/mathqurate/model/MQContentPackage.java 2010-03-25 16:15:27 UTC (rev 2397)
@@ -794,7 +794,8 @@
// private methods for quick and dirty pretty printing of XML from a string. Used
// so that what we get of the metadata to XML methods aren't a horrible mess.
- private static String format(String unformattedXml) {
+ // Also used in the Simple Choice wizard.
+ public static String format(String unformattedXml) {
try {
final Document document = parseXmlFile(unformattedXml);
@@ -812,7 +813,7 @@
return null;
}
- private static Document parseXmlFile(String in) {
+ public static Document parseXmlFile(String in) {
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Added: Mathqurate/trunk/mathqurate/src/main/java/org/qtitools/mathqurate/utilities/SimpleChoiceQuickCreator.java
===================================================================
--- Mathqurate/trunk/mathqurate/src/main/java/org/qtitools/mathqurate/utilities/SimpleChoiceQuickCreator.java (rev 0)
+++ Mathqurate/trunk/mathqurate/src/main/java/org/qtitools/mathqurate/utilities/SimpleChoiceQuickCreator.java 2010-03-25 16:15:27 UTC (rev 2397)
@@ -0,0 +1,156 @@
+package org.qtitools.mathqurate.utilities;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+
+import org.qtitools.mathqurate.model.MQContentPackage;
+
+public class SimpleChoiceQuickCreator {
+
+ public static final int CORRECT = 1;
+ public static final int ALMOST = 2;
+ public static final int WRONG = 0;
+
+ /**
+ * Generates a complete XML for a simple choice question, based on a template.
+ * Used by the simple choice wizard.
+ * Pass it an array list of string. Each entry in the array list should be
+ * [0] simple choice text to add (String can contain HTML and MathML)
+ * [1] correct flag (int - either 0, wrong, 1 right, 2 "almost right")
+ * @param choices array as above
+ * @param markForCorrect float with the mark given for the correct answer
+ * @param markForAlmost float with the mark given for "almost" right
+ * @param questionPreamble blurb printed at top of question
+ * @param questionSuffix blurb printed at bottom of question
+ * @param blurbForCorrect blurb printed on correct answer
+ * @param blurbForAlmost blurb printed on "almost correct" answer
+ * @param blurbForWrong blurb printed on wrong answer
+ * @return a complete assessmentItem in the form of a string
+ */
+ public static String generateSimpleChoiceXML(ArrayList<Object[]> choices, String title, double markForCorrect,
+ double markForAlmost, int hintDivider, String questionPreamble, String questionSuffix, String blurbForCorrect,
+ String blurbForAlmost, String blurbForWrong, String blurbForHint, String blurbForAnswer)
+ {
+ // first, get template file into our string
+ InputStream is = MQContentPackage.class.
+ getClassLoader().getResourceAsStream("org/qtitools/mathqurate/resources/simpleChoiceTemplate.xml");
+ StringBuilder sb = new StringBuilder();
+ String line;
+ try {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+ while ((line = reader.readLine()) != null) {
+ sb.append(line).append("\n");
+ }
+ } catch (UnsupportedEncodingException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } finally {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ String template = sb.toString();
+
+ // do our static, single fields
+ template = template.replace("{{PREAMBLE}}",questionPreamble);
+ template = template.replace("{{TITLE}}",title);
+ template = template.replace("{{SUFFIX}}",questionSuffix);
+ template = template.replace("{{CORRECTBLURB}}",blurbForCorrect);
+ template = template.replace("{{WRONGBLURB}}",blurbForWrong);
+ template = template.replace("{{ALMOSTBLURB}}",blurbForAlmost);
+ template = template.replace("{{ANSWERBLURB}}",blurbForAnswer);
+ template = template.replace("{{HINTBLURB}}",blurbForHint);
+ template = template.replace("{{CORRECTMARK}}",String.valueOf(markForCorrect));
+ template = template.replace("{{HINTDIVIDER}}",String.valueOf(markForCorrect));
+
+ // first, compile our simplechoices
+ String simpleChoiceElement = "";
+ String almostBlock = "";
+ char letterID = 'A';
+
+ for (Object[] choice : choices)
+ {
+ String choiceBlurb = (String)choice[0];
+ int choiceCorrect = (Integer)choice[1];
+
+ if (choiceCorrect == CORRECT) // this is our correct Answer
+ {
+ template = template.replace("{{CORRECT-ID}}","Choice"+letterID);
+ }
+
+ if (choiceCorrect == ALMOST) // "almost" correct
+ {
+ almostBlock += "<responseElseIf>"+
+ "<match>"+
+ "<variable identifier=\"RESPONSE\"/>"+
+ "<baseValue baseType=\"identifier\">{{ALMOSTID}}</baseValue>"+
+ "</match>"+
+ "<setOutcomeValue identifier=\"SCORE\">"+
+ "<baseValue baseType=\"float\">{{ALMOSTMARK}}</baseValue>"+
+ "</setOutcomeValue>"+
+ "<setOutcomeValue identifier=\"FEEDBACK\">"+
+ "<multiple>"+
+ "<baseValue baseType=\"identifier\">PARTRIGHT</baseValue>"+
+ "</multiple>"+
+ "</setOutcomeValue>"+
+ "</responseElseIf>";
+
+ almostBlock = almostBlock.replace("{{ALMOSTID}}","Choice"+letterID);
+ almostBlock = almostBlock.replace("{{ALMOSTMARK}}",String.valueOf(markForAlmost));
+ }
+
+ simpleChoiceElement += "<simpleChoice identifier=\"Choice"+letterID+"\">";
+ simpleChoiceElement += choiceBlurb+"</simpleChoice>";
+ letterID++;
+ }
+
+ template = template.replace("<!-- MOREQUESTIONS -->", simpleChoiceElement);
+ template = template.replace("<!-- ALMOSTBLOCK -->",almostBlock);
+
+ String returnVal = MQContentPackage.format(template);
+ System.out.println(returnVal);
+ return returnVal;
+ }
+
+ public static void main(String[] args)
+ {
+ ArrayList<Object[]> choices = new ArrayList<Object[]>();
+
+ Object[] x = {"Option 1 (correct)",CORRECT};
+ choices.add(x);
+
+ Object[] y = {"Option 2 (almost)",ALMOST};
+ choices.add(y);
+
+ Object[] z = {"Option 3 (wrong)",WRONG};
+ choices.add(z);
+
+ Object[] z1 = {"Option 4 (wrong)",WRONG};
+ choices.add(z1);
+
+ generateSimpleChoiceXML(
+ choices, // array with questions in
+ "A test question", // title
+ 20.0, // marks for correct
+ 10.0, // marks for almost correct
+ 2, // divider for viewing the hint
+ "This is a test question", // preamble
+ "Enjoy answering it!", // suffix
+ "Well done, this is right!",
+ "Close, but not quite!",
+ "Sorry, that's wrong!",
+ "This is where the hint appears",
+ "This is where we give the answer away!");
+ }
+
+}
Added: Mathqurate/trunk/mathqurate/src/main/java/org/qtitools/mathqurate/view/SimpleChoiceWizard.java
===================================================================
--- Mathqurate/trunk/mathqurate/src/main/java/org/qtitools/mathqurate/view/SimpleChoiceWizard.java (rev 0)
+++ Mathqurate/trunk/mathqurate/src/main/java/org/qtitools/mathqurate/view/SimpleChoiceWizard.java 2010-03-25 16:15:27 UTC (rev 2397)
@@ -0,0 +1,833 @@
+/*
+ *
+ Open Source License
+
+ Copyright (c) 2009, Kingston University.
+
+ All rights reserved.
+
+ Redistribution and use of this software in source and binary forms
+ (where applicable), with or without modification, are permitted provided
+ that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * Neither the name of the Kingston University, nor the names of any other
+ contributors to the software, may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
+ OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+ OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+package org.qtitools.mathqurate.view;
+
+
+import java.awt.KeyboardFocusManager;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.layout.LayoutConstants;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.CheckboxCellEditor;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ComboBoxCellEditor;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.ApplicationWindow;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.RowData;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.qtitools.mathqurate.utilities.SimpleChoiceQuickCreator;
+
+
+/**
+ * The class SettingsWindow - displays a window of settings
+ * @author Paul Neve
+ *
+ */
+public class SimpleChoiceWizard extends ApplicationWindow {
+
+ Text preamble;
+ Text title;
+ Table table;
+ TableViewer tableViewer;
+ Text choiceInput;
+ Combo choiceCorrect;
+ Text suffix;
+ Text correctBlurb;
+ Text almostBlurb;
+ Text hintBlurb;
+ Text wrongBlurb;
+ Text solutionBlurb;
+ Text correctScore;
+ Text almostScore;
+ Text hintDivider;
+
+ String htmlString;
+ String mathMLString;
+
+ Image addImage;
+ Image removeImage;
+
+ Button ok;
+ Button cancel;
+ Button editMaths;
+
+ ArrayList<String[]> values = new ArrayList<String[]>();
+ String[] newEntry = {
+ "Answer here",
+ "Wrong",
+ };
+
+ ArrayList<String[]> mathMLs = new ArrayList<String[]>();
+
+ SimpleChoiceWizard dis = this;
+
+ static boolean snuggle = false;
+
+ /**
+ * The mouse click listener
+ */
+ MouseListener listener = new MouseListener()
+ {
+
+ public void mouseDoubleClick(MouseEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void mouseDown(MouseEvent arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void mouseUp(MouseEvent arg0) {
+ if (arg0.getSource() == cancel)
+ {
+ close();
+ }
+
+ if ((arg0.getSource() == editMaths) && (!snuggle))
+ {
+ Control c = getShell().getDisplay().getFocusControl();
+
+ int tableRow = -1;
+ int pos = -1;
+
+ if (c.getParent() instanceof Table)
+ {
+ System.out.println("table");
+ tableRow = tableViewer.getTable().getSelectionIndex();
+ }
+
+ System.out.println(c.getParent());
+ if (c instanceof Text)
+ {
+ //System.out.println(c);
+ Text t = (Text)c;
+ String s = t.getSelectionText();
+ pos = t.getSelection().x;
+
+ Pattern p = Pattern.compile("#maths\\d+#");
+ Matcher m = p.matcher(s);
+
+ if (m.find())
+ {
+ snuggle = true;
+ String x[] = s.split("#maths");
+ String y[] = x[1].split("#");
+ int number = Integer.valueOf(y[0]);
+ String[] result = SnuggleTeXView.unboundSnuggle(mathMLs.get(number-1)[1]);
+ if (result != null) mathMLs.set(number-1, result);
+ snuggle = false;
+ }
+ else
+ {
+ snuggle = true;
+ String[] result = SnuggleTeXView.unboundSnuggle("\\[\\]");
+ if (result != null)
+ {
+ mathMLs.add(result);
+ if (tableRow == -1)
+ t.insert(" #maths"+mathMLs.size()+"# ");
+ else
+ {
+ TableItem currentTI = tableViewer.getTable().getItem(tableRow);
+ String currentText = currentTI.getText(0);
+ String beginning = currentText.substring(0, pos);
+ String end = currentText.substring(pos,currentText.length());
+ values.get(tableRow)[0] = beginning+" #maths"+mathMLs.size()+"# "+end;
+ tableViewer.refresh();
+ }
+ }
+ snuggle = false;
+ }
+ }
+
+ }
+
+ if (arg0.getSource() == ok)
+ {
+ // get our array values
+ ArrayList<Object[]> finalArray = new ArrayList<Object[]>();
+
+ for (String[] value : values)
+ {
+ int correctVal = SimpleChoiceQuickCreator.WRONG;
+ if (value[1].equals("Correct")) correctVal = SimpleChoiceQuickCreator.CORRECT;
+ if (value[1].equals("\"Almost\"")) correctVal = SimpleChoiceQuickCreator.ALMOST;
+ if (value[1].equals("Wrong")) correctVal = SimpleChoiceQuickCreator.WRONG;
+
+ Object[] o = { putBackMathMLs(value[0]), correctVal };
+ finalArray.add(o);
+ }
+
+ float correctScoreFloat = Float.valueOf(correctScore.getText().trim());
+ float almostScoreFloat = Float.valueOf(almostScore.getText().trim());
+ int hintDividerInt = Integer.valueOf(hintDivider.getText().trim());
+ String titleString = title.getText().trim();
+ String preambleString = preamble.getText().trim();
+ String suffixString = suffix.getText().trim();
+ String correctString = correctBlurb.getText().trim();
+ String almostString = almostBlurb.getText().trim();
+ String wrongString = wrongBlurb.getText().trim();
+ String hintString = hintBlurb.getText().trim();
+ String solutionString = solutionBlurb.getText().trim();
+
+ titleString = putBackMathMLs(titleString);
+ preambleString = putBackMathMLs(preambleString);
+ suffixString = putBackMathMLs(suffixString);
+ correctString = putBackMathMLs(correctString);
+ almostString = putBackMathMLs(almostString);
+ wrongString = putBackMathMLs(wrongString);
+ hintString = putBackMathMLs(hintString);
+ solutionString = putBackMathMLs(solutionString);
+
+ SimpleChoiceQuickCreator.generateSimpleChoiceXML(finalArray, titleString, correctScoreFloat, almostScoreFloat,
+ hintDividerInt, preambleString, suffixString, correctString, almostString,
+ wrongString, hintString, solutionString);
+
+ close();
+ }
+ }
+
+ };
+
+ public String putBackMathMLs(String s)
+ {
+ Pattern p = Pattern.compile("#maths\\d+#");
+ Matcher m = p.matcher(s);
+
+ if (m.find())
+ {
+ // we have maths!
+ String x[] = s.split("#maths");
+ // x[0] should be everything before the #maths,
+ // x[1] everything after
+ String y[] = x[1].split("#");
+ // y[0] should be everything after #maths and before the tailing #,
+ // y[1] everything after. Net result is that we *should* have our
+ // number in y[0] now.
+ int number = Integer.valueOf(y[0]);
+ s = s.replace("#maths"+number+"#",mathMLs.get(number-1)[0]);
+ // keep going until no more.
+ s = putBackMathMLs(s);
+ }
+ return s;
+ }
+
+ /**
+ * The Class AbstractEditingSupport.
+ */
+ protected abstract class AbstractEditingSupport extends EditingSupport {
+
+ /** The editor. */
+ private CellEditor editor;
+
+ /**
+ * Instantiates a new abstract editing support.
+ *
+ * @param viewer the viewer
+ */
+ public AbstractEditingSupport(TableViewer viewer) {
+ super(viewer);
+ this.editor = new TextCellEditor(viewer.getTable());
+ }
+
+ /**
+ * Instantiates a new abstract editing support.
+ *
+ * @param viewer the viewer
+ * @param editor the editor
+ */
+ public AbstractEditingSupport(TableViewer viewer, CellEditor editor) {
+ super(viewer);
+ this.editor = editor;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.EditingSupport#canEdit(java.lang.Object)
+ */
+ @Override
+ protected boolean canEdit(Object element) {
+ return true;
+ }
+
+ /**
+ * Do set value.
+ *
+ * @param element the element
+ * @param value the value
+ */
+ protected abstract void doSetValue(Object element, Object value);
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.EditingSupport#getCellEditor(java.lang.Object)
+ */
+ @Override
+ protected CellEditor getCellEditor(Object element) {
+ return editor;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.EditingSupport#setValue(java.lang.Object, java.lang.Object)
+ */
+ @Override
+ protected void setValue(Object element, Object value) {
+ doSetValue(element, value);
+ getViewer().update(element, null);
+
+ boolean enableOK = false;
+ // scan through, if no correct, disable OK
+ for (String[] s : values)
+ {
+ if (s[1].equals("Correct"))
+ {
+ enableOK = true;
+ }
+ }
+ ok.setEnabled(enableOK);
+ }
+ }
+
+ class SCWizContentProvider implements
+ IStructuredContentProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose() {
+ //controller.changeMetadataHelper(metadataarray);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ @SuppressWarnings("unchecked")
+ public Object[] getElements(Object arg0) {
+
+ ArrayList<String[]> array = (ArrayList<String[]>) arg0;
+
+ return array.toArray();
+// return x;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
+
+ }
+
+ }
+
+
+ /**
+ * Instantiates a new SimpleChoiceWizard package import view.
+ *
+ * @param parentShell the parent shell
+ *
+ */
+ public SimpleChoiceWizard(Shell parentShell) {
+ super(parentShell);
+
+ addItem();
+
+ addImage = new Image(parentShell.getDisplay(),
+ SimpleChoiceWizard.class.getResourceAsStream(
+ "/org/qtitools/mathqurate/resources/32px-Crystal_Clear_action_edit_add.png"));
+
+ addImage = new Image(parentShell.getDisplay(),addImage.getImageData().scaledTo(18,18));
+
+ removeImage = new Image(parentShell.getDisplay(),
+ SimpleChoiceWizard.class.getResourceAsStream(
+ "/org/qtitools/mathqurate/resources/32px-Crystal_Clear_action_edit_remove.png"));
+
+ removeImage = new Image(parentShell.getDisplay(),removeImage.getImageData().scaledTo(18,18));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.window.ApplicationWindow#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ @Override
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ shell.setText("Simple Choice Wizard");
+ }
+
+ /* (non-Javadoc)
+ * @see uk.ac.kingston.cism.mathqurate.view.AbstractApplicationWindow#createContents(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createContents(Composite bigParent) {
+
+ GridData preambleLayout;
+
+ Composite twoPanes = new Composite(bigParent,SWT.NONE);
+ {
+
+ Composite parent = new Composite(twoPanes,SWT.BORDER);
+ {
+ // title text text
+ new Label(parent,SWT.NONE).setText("Question Title");
+ title = new Text(parent,SWT.WRAP);
+ GridData titlelayout = new GridData(SWT.DEFAULT,SWT.DEFAULT);
+ titlelayout.horizontalAlignment = GridData.FILL;
+ titlelayout.grabExcessHorizontalSpace = true;
+ title.setLayoutData(titlelayout);
+ title.setToolTipText("The question title. This will usually appear at the top of the page when a question is displayed.");
+
+ // preamble text
+ new Label(parent,SWT.NONE).setText("Question Preamble");
+ preamble = new Text(parent,SWT.WRAP);
+ preambleLayout = new GridData(1,50);
+ preambleLayout.horizontalAlignment = GridData.FILL;
+ preambleLayout.grabExcessHorizontalSpace = true;
+ preamble.setLayoutData(preambleLayout);
+
+ tableViewer = createTableViewer(parent);
+ tableViewer.setInput(values);
+ tableViewer.refresh();
+
+ GridData tableLayout = new GridData();
+ tableLayout.minimumHeight = 200;
+ tableLayout.minimumWidth = 400;
+ tableLayout.horizontalAlignment = GridData.FILL;
+ tableLayout.verticalAlignment = GridData.FILL;
+ tableLayout.grabExcessHorizontalSpace = true;
+ tableLayout.grabExcessVerticalSpace = true;
+ tableViewer.getControl().setLayoutData(tableLayout);
+
+/* Composite choiceBit = new Composite(parent, SWT.BORDER);
+ {
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.makeColumnsEqualWidth = false;
+
+ layout.horizontalSpacing = 10;
+ layout.verticalSpacing = 0;
+ layout.marginTop = 0;
+ layout.marginBottom = 0;
+
+ choiceBit.setLayout(layout);
+ new Label(choiceBit,SWT.NONE).setText("Choice text");
+ new Label(choiceBit,SWT.NONE).setText("Correct?");
+ //new Label(choiceBit,SWT.NONE).setText("");
+
+ GridData inputWidth = new GridData(GridData.FILL_HORIZONTAL);
+ inputWidth.widthHint = 300;
+ choiceInput = new Text(choiceBit,SWT.NONE);
+ choiceInput.setLayoutData(inputWidth);
+
+ choiceCorrect = new Combo(choiceBit,SWT.READ_ONLY);
+ choiceCorrect.add("Correct");
+ choiceCorrect.add("\"Almost\"");
+ choiceCorrect.add("Wrong");
+ choiceCorrect.select(2);
+ //choiceCorrect.pack();
+
+ Composite choiceButtons = new Composite(choiceBit, SWT.NONE);
+ {
+ GridLayout choiceLayout = new GridLayout();
+ choiceLayout.numColumns = 4;
+ choiceLayout.marginHeight = 0;
+ choiceLayout.marginWidth = 0;
+ layout.horizontalSpacing = 0;
+ layout.verticalSpacing = 0;
+ layout.marginTop = 0;
+ layout.marginBottom = 0;
+
+ choiceButtons.setLayout(choiceLayout);
+
+ mathML = new Button(choiceButtons,SWT.NONE);
+ mathML.setText("MathML");
+
+ html = new Button(choiceButtons,SWT.NONE);
+ html.setText("HTML");
+
+ clear = new Button(choiceButtons,SWT.NONE);
+ clear.setText("Clear");
+ }
+
+ addButton = new Button(choiceBit,SWT.NONE);
+ GridData abgd = new GridData();
+ abgd.horizontalAlignment = SWT.RIGHT;
+ addButton.setText("+");
+ addButton.setLayoutData(abgd);
+
+ addButton.addMouseListener(listener);
+
+ } */
+
+ // Suffix text
+ new Label(parent,SWT.NONE).setText("Question Suffix Text");
+ suffix = new Text(parent,SWT.WRAP);
+ //GridData suffixLay = new GridData(1,50);
+ //preambleLayout.horizontalAlignment = GridData.FILL;
+ //preambleLayout.grabExcessHorizontalSpace = true;
+ suffix.setLayoutData(preambleLayout);
+
+ GridLayoutFactory.fillDefaults().numColumns(1).margins(
+ LayoutConstants.getMargins()).generateLayout(parent);
+
+ }
+
+ Composite secondParent = new Composite(twoPanes,SWT.BORDER);
+ {
+ new Label(secondParent,SWT.NONE).setText("Response for correct answer");
+ correctBlurb = new Text(secondParent,SWT.WRAP);
+ correctBlurb.setLayoutData(preambleLayout);
+ correctBlurb.setText("Well done! That is correct!");
+
+ new Label(secondParent,SWT.NONE).setText("Response for \"almost correct\" answer");
+ almostBlurb = new Text(secondParent,SWT.WRAP);
+ almostBlurb.setLayoutData(preambleLayout);
+ almostBlurb.setText("Almost right, but not quite!");
+
+ new Label(secondParent,SWT.NONE).setText("Response for wrong answer");
+ wrongBlurb = new Text(secondParent,SWT.WRAP);
+ wrongBlurb.setLayoutData(preambleLayout);
+ wrongBlurb.setText("Sorry, that's the wrong answer.");
+
+ new Label(secondParent,SWT.NONE).setText("Hint text");
+ hintBlurb = new Text(secondParent,SWT.WRAP);
+ hintBlurb.setLayoutData(preambleLayout);
+
+ new Label(secondParent,SWT.NONE).setText("Solution text");
+ solutionBlurb = new Text(secondParent,SWT.WRAP);
+ solutionBlurb.setLayoutData(preambleLayout);
+
+ GridLayoutFactory.fillDefaults().numColumns(1).margins(
+ LayoutConstants.getMargins()).generateLayout(secondParent);
+
+ Composite scoreField = new Composite(secondParent,SWT.NONE);
+ {
+ RowLayout oddLayout = new RowLayout();
+ scoreField.setLayout(oddLayout);
+ new Label(scoreField,SWT.NONE).setText("Score for correct answer ");
+ correctScore = new Text(scoreField,SWT.NONE);
+ correctScore.setText("10");
+ correctScore.setLayoutData(new RowData(40,SWT.DEFAULT));
+ }
+
+ Composite almostField = new Composite(secondParent,SWT.NONE);
+ {
+ RowLayout oddLayout = new RowLayout();
+ almostField.setLayout(oddLayout);
+ new Label(almostField,SWT.NONE).setText("Score for \"almost\" correct ");
+ almostScore = new Text(almostField,SWT.NONE);
+ almostScore.setText("5");
+ almostScore.setLayoutData(new RowData(40,SWT.DEFAULT));
+ }
+
+ Composite dividerField = new Composite(secondParent,SWT.NONE);
+ {
+ RowLayout oddLayout = new RowLayout();
+ dividerField.setLayout(oddLayout);
+ new Label(dividerField,SWT.NONE).setText("Hint score divider ");
+ hintDivider = new Text(dividerField,SWT.NONE);
+ hintDivider.setText("2");
+ hintDivider.setLayoutData(new RowData(40,SWT.DEFAULT));
+ }
+ }
+
+ Composite buttonBar = new Composite(twoPanes, SWT.NONE);
+ {
+ editMaths = new Button(buttonBar,SWT.NONE);
+ editMaths.setText("Edit Maths");
+ editMaths.addMouseListener(listener);
+
+ ok = new Button(buttonBar,SWT.NONE);
+
+ ok.setText("OK");
+
+ ok.addMouseListener(listener);
+ ok.setEnabled(false);
+
+ cancel = new Button(buttonBar, SWT.NONE);
+ cancel.setText("Cancel");
+
+ cancel.addMouseListener(listener);
+ GridLayoutFactory.fillDefaults().numColumns(3).generateLayout(
+ buttonBar);
+ }
+ GridDataFactory.fillDefaults().span(2, 1).align(SWT.RIGHT,
+ SWT.BOTTOM).applyTo(buttonBar);
+
+
+ GridLayoutFactory.fillDefaults().numColumns(2).margins(
+ LayoutConstants.getMargins()).generateLayout(twoPanes);
+
+ }
+
+ //parent.pack();
+
+ return (bigParent);
+ }
+
+ private void addItem()
+ {
+ String[] newOne = Arrays.copyOf(newEntry, newEntry.length);
+ values.add(newOne);
+ }
+
+ /**
+ * Creates the table viewer.
+ */
+ private TableViewer createTableViewer(Composite parent) {
+
+ final TableViewer tableViewer = new TableViewer(parent, SWT.FULL_SELECTION);
+
+ tableViewer
+ .setContentProvider(new SCWizContentProvider());
+
+ // COLUMN 1: Answer text //
+
+ TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.FILL);
+ column.getColumn().setWidth(350);
+ column.getColumn().setText("Answer text");
+ column.setLabelProvider(new ColumnLabelProvider() {
+
+ @Override
+ public String getText(Object element) {
+ //Object[] row = (Object[])element;
+ return ((String[])element)[0];
+ }
+ });
+
+ column.setEditingSupport(new AbstractEditingSupport(tableViewer) {
+
+ @Override
+ protected void doSetValue(Object element, Object value) {
+ ((String[])element)[0] = value.toString();
+
+ // ((AttribValue) element).setValue(value.toString());
+ getViewer().update(element, null);
+ }
+
+ @Override
+ protected Object getValue(Object element) {
+ return ((String[])element)[0];
+ }
+
+ });
+
+ // COLUMN 2: Answer status - i.e. coreect, wrong, etc - pulldown
+
+ column = new TableViewerColumn(tableViewer, SWT.FILL);
+ column.getColumn().setWidth(80);
+ column.getColumn().setText("Correct?");
+ column.setLabelProvider(new ColumnLabelProvider() {
+
+ @Override
+ public String getText(Object element) {
+ //Object[] row = (Object[])element;
+ return ((String[])element)[1];
+ }
+ });
+
+ final String[] basetypes = {"Correct","\"Almost\"","Wrong"};
+ ComboBoxCellEditor comboeditor = new ComboBoxCellEditor(tableViewer
+ .getTable(), basetypes, SWT.READ_ONLY);
+ //comboeditor
+ // .setActivationStyle();
+
+ column.setEditingSupport(new AbstractEditingSupport(tableViewer,
+ comboeditor)
+ {
+
+ @Override
+ protected void doSetValue(Object element, Object value) {
+ //((String[])element)[1] = value.toString();
+ int ival = ((Integer) value).intValue();
+ if (ival>-1&&ival<basetypes.length){
+ ((String[])element)[1] = basetypes[ival];
+ }
+
+ }
+
+ @Override
+ protected Object getValue(Object element) {
+ String value = ((String[])element)[1];
+ int i;
+ for (i = 0; i < basetypes.length; i++) {
+ if (value.trim().equals(basetypes[i].trim())) {
+ break;
+ }
+ }
+ return new Integer(i);
+ // TODO Auto-generated method stub
+ // return ((String[])element)[1];
+ }
+
+ });
+
+ // COLUMN 3: +
+
+ column = new TableViewerColumn(tableViewer, SWT.FILL);
+ column.getColumn().setWidth(20);
+ column.getColumn().setText("");
+
+ CheckboxCellEditor cbeditor = new CheckboxCellEditor(tableViewer.getTable());
+ //BooleanCellEditor cbeditor = new BooleanCellEditor(tableViewer.getTable());
+
+
+ column.setLabelProvider(new ColumnLabelProvider() {
+
+ @Override
+ public Image getImage(Object element) {
+ //Object[] row = (Object[])element;
+ return addImage;
+ }
+ @Override
+ public String getText(Object element)
+ {
+ return "";
+ }
+ });
+
+ column.setEditingSupport(new AbstractEditingSupport(tableViewer,
+ cbeditor)
+ {
+
+ @Override
+ protected void doSetValue(Object element, Object value) {
+ addItem();
+ tableViewer.refresh();
+ tableViewer.getTable().select(tableViewer.getTable().getItemCount()-1);
+ }
+
+ @Override
+ protected Object getValue(Object arg0) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ });
+
+ // COLUMN 4: Latex button
+
+ column = new TableViewerColumn(tableViewer, SWT.FILL);
+ column.getColumn().setWidth(20);
+ column.getColumn().setText("");
+
+ cbeditor = new CheckboxCellEditor(tableViewer.getTable());
+ //BooleanCellEditor cbeditor = new BooleanCellEditor(tableViewer.getTable());
+
+
+ column.setLabelProvider(new ColumnLabelProvider() {
+
+ @Override
+ public Image getImage(Object element) {
+ //Object[] row = (Object[])element;
+ return removeImage;
+ }
+ @Override
+ public String getText(Object elemet)
+ {
+ return "";
+ }
+ });
+
+ column.setEditingSupport(new AbstractEditingSupport(tableViewer,
+ cbeditor)
+ {
+
+ @Override
+ protected void doSetValue(Object element, Object value) {
+ values.remove(element);
+ tableViewer.refresh();
+ }
+
+ @Override
+ protected Object getValue(Object arg0) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ });
+
+ tableViewer.getTable().setLinesVisible(true);
+ tableViewer.getTable().setHeaderVisible(true);
+
+ return tableViewer;
+
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#initializeBounds()
+ */
+ @Override
+ protected void initializeBounds() {
+ getShell().setMinimumSize(750,600);
+ getShell().setSize(900, 600);
+ getShell().setLocation(0, 0);
+ }
+
+ public static void main (String[] args)
+ {
+ SimpleChoiceWizard sw = new SimpleChoiceWizard(new Shell());
+ sw.setBlockOnOpen(true);
+ sw.open();
+ }
+
+/* public static void main(String[] args)
+ {
+ putBackMathMLs("#maths12112#");
+ } */
+
+}
Modified: Mathqurate/trunk/mathqurate/src/main/java/org/qtitools/mathqurate/view/SnuggleTeXView.java
===================================================================
--- Mathqurate/trunk/mathqurate/src/main/java/org/qtitools/mathqurate/view/SnuggleTeXView.java 2010-03-23 12:31:55 UTC (rev 2396)
+++ Mathqurate/trunk/mathqurate/src/main/java/org/qtitools/mathqurate/view/SnuggleTeXView.java 2010-03-25 16:15:27 UTC (rev 2397)
@@ -178,6 +178,12 @@
/** Convenience access to this */
private SnuggleTeXView dis = this;
+ /** Used when being used in a static context */
+ private boolean amIstatic = false;
+
+ /** default text **/
+ private String defaultText = "\\[\\]";
+
/**
* Instantiates a new snuggle tex view.
*
@@ -218,7 +224,7 @@
| SWT.H_SCROLL);
text.addModifyListener(new MyModifyListener());
- text.setText("\\[\\]");
+ text.setText(defaultText);
GridData textSizing = new GridData(450,70);
textSizing.horizontalAlignment = GridData.FILL;
textSizing.grabExcessHorizontalSpace = true;
@@ -240,25 +246,28 @@
Composite buttonBar = new Composite(parent, SWT.NONE);
{
- Button buttonApply = new Button(buttonBar,SWT.NONE);
- buttonApply.setText("Apply");
+ if (!amIstatic)
+ {
+ Button buttonApply = new Button(buttonBar,SWT.NONE);
+ buttonApply.setText("Apply");
+
+ buttonApply.addMouseListener(new MouseListener(){
+
+ public void mouseDoubleClick(MouseEvent arg0) {
+
+ }
+
+ public void mouseDown(MouseEvent arg0) {
+ controller.newMathType(mathMLXML);
+ }
+
+ public void mouseUp(MouseEvent arg0) {
+ }
+
+ });
+ dis.buttonApply = buttonApply;
+ }
- buttonApply.addMouseListener(new MouseListener(){
-
- public void mouseDoubleClick(MouseEvent arg0) {
-
- }
-
- public void mouseDown(MouseEvent arg0) {
- controller.newMathType(mathMLXML);
- }
-
- public void mouseUp(MouseEvent arg0) {
- }
-
- });
- dis.buttonApply = buttonApply;
-
Button buttonOK = new Button(buttonBar,SWT.NONE);
buttonOK.setText("OK");
@@ -269,7 +278,7 @@
}
public void mouseDown(MouseEvent arg0) {
- controller.newMathType(mathMLXML);
+ if (!amIstatic) controller.newMathType(mathMLXML);
}
public void mouseUp(MouseEvent arg0) {
@@ -293,6 +302,10 @@
}
public void mouseUp(MouseEvent arg0) {
+ if (amIstatic)
+ {
+ mathMLXML = null;
+ }
close();
}
@@ -306,6 +319,11 @@
GridLayoutFactory.fillDefaults().numColumns(1).margins(
LayoutConstants.getMargins()).generateLayout(parent);
+ if (amIstatic)
+ {
+ updateBrowserView();
+ }
+
return (parent);
}
@@ -391,5 +409,57 @@
protected void createCoolBars(int style) {
}
+
+ @Override
+ protected void initializeBounds() {
+ getShell().setMinimumSize(400,400);
+ //getShell().setSize(900, 600);
+ getShell().setLocation(0, 0);
+ }
+ public boolean close()
+ {
+ if (amIstatic)
+ {
+ // kludgey, but append the latex on the end with a quantifiable seperator.
+ // We'll use this to pull back the final contents of the text field after
+ // SWT disposal.
+ if (mathMLXML != null) mathMLXML += "###SEP###"+text.getText();
+ this.getShell().dispose();
+ return true;
+ }
+ else
+ {
+ return super.close();
+ }
+ }
+
+ /**
+ * Convenience method for calling the math editor without any coupling to the MQ model.
+ * Returns a string of MathML and the final latex
+ * @param latex string of latex to start with
+ * @return [0]MathML [1]Latex - both strings
+ */
+ public static String[] unboundSnuggle(String latex)
+ {
+ SnuggleTeXView st = new SnuggleTeXView(new Shell());
+ st.amIstatic = true;
+ st.defaultText = latex;
+ st.setBlockOnOpen(true);
+ st.open();
+ String retval = st.mathMLXML;
+ st = null;
+ if (retval == null)
+ {
+ return null;
+ }
+ return retval.split("###SEP###");
+ }
+
+ public static void main (String[] args)
+ {
+ String[] bits = unboundSnuggle("\\[e=mc^2\\]");
+ System.out.println("MathML "+bits[0]);
+ System.out.println("Latex:"+ bits[1]);
+ }
}
Added: Mathqurate/trunk/mathqurate/src/main/resources/org/qtitools/mathqurate/resources/simpleChoiceTemplate.xml
===================================================================
--- Mathqurate/trunk/mathqurate/src/main/resources/org/qtitools/mathqurate/resources/simpleChoiceTemplate.xml (rev 0)
+++ Mathqurate/trunk/mathqurate/src/main/resources/org/qtitools/mathqurate/resources/simpleChoiceTemplate.xml 2010-03-25 16:15:27 UTC (rev 2397)
@@ -0,0 +1,184 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p1" xmlns:lip="http://www.imsglobal.org/xsd/imslip_v1p0" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:ma="http://mathassess.qtitools.org/xsd/mathassess" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" adaptive="true" identifier="pn-123" timeDependent="false" title="{{TITLE}}" toolName="Mathqurate" toolVersion="0.9.7">
+ <!--<responseDeclaration cardinality="record" identifier="RESPONSE"/>-->
+ <responseDeclaration identifier="RESPONSE"
+ cardinality="single" baseType="identifier">
+ <!-- correct answer here -->
+ <correctResponse>
+ <value>{{CORRECT-ID}}</value>
+ </correctResponse>
+ </responseDeclaration>
+ <responseDeclaration baseType="boolean" cardinality="single" identifier="HINTREQUEST"/>
+ <responseDeclaration baseType="boolean" cardinality="single" identifier="SOLREQUEST"/>
+ <outcomeDeclaration baseType="identifier" cardinality="multiple" identifier="FEEDBACK"/>
+ <outcomeDeclaration baseType="identifier" cardinality="single" identifier="EMPTY"/>
+ <outcomeDeclaration baseType="float" cardinality="single" identifier="SCORE">
+ <defaultValue>
+ <value>0</value>
+ </defaultValue>
+ </outcomeDeclaration>
+ <outcomeDeclaration baseType="boolean" cardinality="single" identifier="seenSolution">
+ <defaultValue>
+ <value>false</value>
+ </defaultValue>
+ </outcomeDeclaration>
+ <outcomeDeclaration baseType="boolean" cardinality="single" identifier="seenHint">
+ <defaultValue>
+ <value>false</value>
+ </defaultValue>
+ </outcomeDeclaration>
+ <outcomeDeclaration baseType="identifier" cardinality="single" identifier="ASKHINT">
+ <defaultValue>
+ <value>askhint</value>
+ </defaultValue>
+ </outcomeDeclaration>
+ <outcomeDeclaration baseType="identifier" cardinality="single" identifier="ASKSOLUTION">
+ <defaultValue>
+ <value>asksolution</value>
+ </defaultValue>
+ </outcomeDeclaration>
+ <itemBody class=""><div>{{PREAMBLE}}<br/><br/>
+ <choiceInteraction responseIdentifier="RESPONSE" shuffle="true" maxChoices="1">
+ <!-- MOREQUESTIONS -->
+ </choiceInteraction><br/>{{SUFFIX}}<br/><br/>
+ <feedbackInline outcomeIdentifier="FEEDBACK" identifier="CORRECT" showHide="show">{{CORRECTBLURB}} - <printedVariable class="" id="printedVariable0" identifier="SCORE"/> marks.</feedbackInline>
+ <feedbackInline outcomeIdentifier="FEEDBACK" identifier="INCORRECT" showHide="show">{{WRONGBLURB}}</feedbackInline>
+ <feedbackInline outcomeIdentifier="FEEDBACK" identifier="PARTRIGHT" showHide="show">{{ALMOSTBLURB}} - <printedVariable class="" id="printedVariable1" identifier="SCORE"/> marks.</feedbackInline>
+ <feedbackBlock class="" id="feedbackBlock3" identifier="SOLUTION" outcomeIdentifier="FEEDBACK" showHide="show">
+ <div>{{ANSWERBLURB}}</div>
+ </feedbackBlock>
+ <feedbackBlock id="feedbackBlock4" identifier="HINT" outcomeIdentifier="FEEDBACK" showHide="show">
+ <div>{{HINTBLURB}}</div>
+ </feedbackBlock>
+ <feedbackBlock id="feedbackBlock5" identifier="SEEN-SOLUTION" outcomeIdentifier="FEEDBACK" showHide="show">
+ <div>Since you have viewed the solution, your score for this question will be 0.</div>
+ </feedbackBlock>
+ <feedbackBlock id="feedbackBlock6" identifier="SEEN-HINT" outcomeIdentifier="FEEDBACK" showHide="show">
+ <div>Since you have viewed the hint, your score for this question will be halved.</div>
+ </feedbackBlock>
+ <feedbackBlock id="feedbackBlock7" identifier="askhint" outcomeIdentifier="ASKHINT" showHide="show">
+ <div>
+ <endAttemptInteraction id="endAttemptInteraction1" responseIdentifier="HINTREQUEST" title="Show Hint"/> </div>
+ </feedbackBlock>
+ <feedbackBlock id="feedbackBlock8" identifier="asksolution" outcomeIdentifier="ASKSOLUTION" showHide="show">
+ <div>
+ <endAttemptInteraction id="endAttemptInteraction2" responseIdentifier="SOLREQUEST" title="Show Solution"/> </div>
+ </feedbackBlock>
+ </div> </itemBody>
+ <responseProcessing>
+ <responseCondition>
+ <responseIf>
+ <variable identifier="HINTREQUEST"/>
+ <setOutcomeValue identifier="FEEDBACK">
+ <multiple>
+ <baseValue baseType="identifier">HINT</baseValue>
+ </multiple>
+ </setOutcomeValue>
+ <setOutcomeValue identifier="seenHint">
+ <baseValue baseType="boolean">true</baseValue>
+ </setOutcomeValue>
+ <setOutcomeValue identifier="ASKHINT">
+ <baseValue baseType="identifier">null</baseValue>
+ </setOutcomeValue>
+ </responseIf>
+ <responseElseIf>
+ <variable identifier="SOLREQUEST"/>
+ <setOutcomeValue identifier="FEEDBACK">
+ <multiple>
+ <baseValue baseType="identifier">SOLUTION</baseValue>
+ </multiple>
+ </setOutcomeValue>
+ <setOutcomeValue identifier="seenSolution">
+ <baseValue baseType="boolean">true</baseValue>
+ </setOutcomeValue>
+ <setOutcomeValue identifier="ASKHINT">
+ <baseValue baseType="identifier">null</baseValue>
+ </setOutcomeValue>
+ <setOutcomeValue identifier="ASKSOLUTION">
+ <baseValue baseType="identifier">null</baseValue>
+ </setOutcomeValue>
+ <setOutcomeValue identifier="completionStatus">
+ <baseValue baseType="identifier">completed</baseValue>
+ </setOutcomeValue>
+ </responseElseIf>
+ <responseElse>
+ <responseCondition>
+ <responseIf>
+ <isNull>
+ <variable identifier="RESPONSE"/>
+ </isNull>
+ <setOutcomeValue identifier="SCORE">
+ <baseValue baseType="float">0.0</baseValue>
+ </setOutcomeValue>
+ </responseIf>
+ <responseElse>
+ <responseCondition>
+ <!-- scoring here -->
+ <responseIf> <!-- if correct answer -->
+ <match>
+ <variable identifier="RESPONSE"/>
+ <correct identifier="RESPONSE"/>
+ </match>
+ <setOutcomeValue identifier="SCORE">
+ <baseValue baseType="float">{{CORRECTMARK}}</baseValue>
+ </setOutcomeValue>
+ <setOutcomeValue identifier="FEEDBACK">
+ <multiple>
+ <baseValue baseType="identifier">CORRECT</baseValue>
+ </multiple>
+ </setOutcomeValue>
+ </responseIf>
+ <!-- ALMOSTBLOCK -->
+ <responseElse> <!-- otherwise -->
+ <setOutcomeValue identifier="SCORE">
+ <baseValue baseType="float">0</baseValue>
+ </setOutcomeValue>
+ <setOutcomeValue identifier="FEEDBACK">
+ <multiple>
+ <baseValue baseType="identifier">INCORRECT</baseValue>
+ </multiple>
+ </setOutcomeValue>
+ </responseElse>
+ </responseCondition>
+ <setOutcomeValue identifier="completionStatus">
+ <baseValue baseType="identifier">completed</baseValue>
+ </setOutcomeValue>
+ <setOutcomeValue identifier="ASKHINT">
+ <baseValue baseType="identifier">null</baseValue>
+ </setOutcomeValue>
+ <responseCondition>
+ <responseIf>
+ <variable identifier="seenSolution"/>
+ <setOutcomeValue identifier="FEEDBACK">
+ <multiple>
+ <variable identifier="FEEDBACK"/>
+ <baseValue baseType="identifier">SEEN-SOLUTION</baseValue>
+ </multiple>
+ </setOutcomeValue>
+ <setOutcomeValue identifier="SCORE">
+ <baseValue baseType="float">0.0</baseValue>
+ </setOutcomeValue>
+ </responseIf>
+ <responseElseIf>
+ <variable identifier="seenHint"/>
+ <setOutcomeValue identifier="FEEDBACK">
+ <multiple>
+ <variable identifier="FEEDBACK"/>
+ <baseValue baseType="identifier">SEEN-HINT</baseValue>
+ </multiple>
+ </setOutcomeValue>
+ <setOutcomeValue identifier="SCORE">
+ <divide>
+ <variable identifier="SCORE"/>
+ <baseValue baseType="float">{{HINTDIVIDER}}</baseValue>
+ </divide>
+ </setOutcomeValue>
+ </responseElseIf>
+ </responseCondition>
+ </responseElse>
+ </responseCondition>
+ </responseElse>
+ </responseCondition>
+ </responseProcessing>
+</assessmentItem>
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|