How to adjust the size of Moodle embedded-answer (Cloze) questions? - moodle

When students encounter a Short Answer or a Numerical question, they are presented with a text box in which they can enter their answer. Their answers will be compared to a list of allowed answers provided during the question authoring. I'm trying to adjust the size of the questions text boxes in case of a question consisting of multiple subquestions.
The length of the text box is computed based on the length of the longest answer including the wrong answers. In case of multiple SA subquestions, I've added the same dummy wrong answer to all embedded-answers.
Subquestion 1: {1:SA:%100%A~%0%XXXX}
Subquestion 2: {1:SA:%100%BB~%0%XXXX}
Subquestion 3: {1:SA:%100%CCC~%0%XXXX}
Subquestion 4: {1:SA:%100%DDDD~%0%XXXX}
where XXXX is the dummy wrong answer.
In the example below, I also show the HTML code to show the use of tables for a better control over question and embedded-answer boxes alignment.
<table>
<tbody>
<tr>
<td>
Subquestion 1:
</td>
<td>{1:SA:%100%A~%0%XXXXX}</td>
</tr>
<tr>
<td>
Subquestion 2:
</td>
<td>{1:SA:%100%BB~%0%XXXXX}</td>
</tr>
<tr>
<td>
Subquestion 3:
</td>
<td>{1:SA:%100%CCC~%0%XXXXX}</td>
</tr>
<tr>
<td>
Subquestion 4:
</td>
<td>{1:SA:%100%DDDD~%0%XXXX}</td>
</tr>
</tbody>
</table>
Markup text and preview of Moodle embedded-answers
The same length dummy answers seems to work. Is there any other known way to adjust the sizes of the embedded-answer text boxes?

Related

Find and Replace with Visual Studio Code to replace cell alignment with a class

Since the align attribute is considered obselete I am cleaning up code to remove it and replace with a CSS class. I'm trying to determine if there is a way to do this using find and replace (or something else) in VS Code.
As an example, I might have some html that looks like this:
<table>
<tr>
<td align="left" class="someclass" id="mainTitleCell" title="Title1">Title1</td>
<td align="center" title="Title2">Title2</td>
<td class="someclass" align="right" title="Title3">Title3</td> <!-- attributes are not always in the same order -->
</tr>
<tr>
<td align="left">Title</td>
<td align="center">Title</td>
<td align="right">Title</td>
</tr>
</table>
which I would like to change to
<table>
<tr>
<td class="left someclass" id="mainTitleCell" title="Title1">Title1</td>
<td class="center" title="Title2">Title2</td>
<td class="right someclass" title="Title3">Title3</td>
</tr>
<tr>
<td class="left">Content</td>
<td class="center">Content</td>
<td class="right">Content</td>
</tr>
</table>
Basically removing the align attribute and either adding a class attribute with a specific value OR adding a specific value to an existing class attribute. Is there a way to do this with the Edit...Replace option in VS Code? I know I can find based on a regex but not sure how I would go about the replace since this becomes
Find the align tag
Remove it
Find a class attribute in the <td> or <th> tag and add the appropriate class
If there is no class attribute, add one with the appropriate class.
Obviously step #1 & 2 are easy, it's #3 & 4 that I'm not sure of. I'd be totally happy with having to run 3 separate find and replace commands (one for left, center and right).
Do I have any options here (I am open to extensions)?
UPDATE:
#Mark had the right answer and I was able to chain together several find and replace commands using the Replace Rules extension. With that I can open a file, run a single keystroke to find and replace everything and clean up the extra spaces in the class attribute.
Try this:
Find: align="(.*?)"(.*?) class="(.*?)"|class="(.*?)"(.*?) align="(.*?)"|align="(.*?)"
Replace: class="$7$1$6 $3$4"$2$5
See regex101 demo.
I'm a little surprised this works as well as it does (I included a couple of other test cases you didn't). The only issue (thus far...) is that it can result in one stray space, as in:
<td class="left ">Title</td> // only happens when there is no class attribute
as you can see in the demo page. You could then search for " and replace with just ". It could be handled by a conditional replacement but vscode find/replace doesn't allow those.
To some degree attributes will be re-ordered so that the class attribute is first, but not always - you didn't mention that as a concern - any attribute that occurs before either the first class or align attribute will not be moved. Otherwise, attributes like id or title if they are between class<->attribute (in any order) will be put last.

Selenium IDE target of subsequent cell in table based on first cells content

Basically, in English I want to tell Selenium "look for the content ttc202 in column one, of a multi-row, multicolumn table, then mouseOver on the Edit link"
HTML is as follows:
<tr id="86" class="ui-widget-content jqgrow ui-row-ltr ui-state-highlight" tabindex="0" role="row" aria-selected="true">
<td aria-describedby="jqLst_Short Name" style="text-align:left;" role="gridcell">
ttc202
</td>
<td aria-describedby="jqLst_Long Name" style="text-align:left;" role="gridcell">
Testing Training Company 202
</td>
<td aria-describedby="jqLst_Actions" title="" style="text-align:center;" role="gridcell">
<a class="act avw" title="View this Organisation" href="company/view?lcId=86"></a>
<a class="act aed" title="Edit this Organisation" href="company/edit?lcId=86"></a>
</td>
</tr>
I have tried this:
//td[contains(text(),'ttc202')]/following-sibling::td[contains(a/title(),'Edit this Organisation')]/a
All help appreciated. I assume I am missing something to skip over the first column, but can't imagine what will enable me to do that...
Progress:
I have found the following as an alternative which should get to the correct cell, but I am not able to workout how to target the title in the link code:
//td[normalize-space() ="ttc202"])[1]/following-sibling::td[2]/a[. = 'Edit']
I think this is progress just not sufficient to get me to the finish line!
After much investigation I found the following answer, perhaps this might help others who come across this question:
//tr[contains(td[1], "ttc202")]/td[3]/a[#title='Edit this Organisation']
The trick was realising which cell the information was in (represented by the square brackets).

Mailchimp repeatable blocks issue

I have next table in my template:
<table ...>
<tr mc:repeatable mc:hideable>
<td mc:edit="mc-news-item-image"><img .../></td>
<td mc:edit="mc-news-item-h3"><h3>Lorem ipsum.</h3></td>
<td mc:edit="mc-news-item-date"><span>22.10.13</span></td>
</tr>
</table>
In edit campaign mode if I try to dublicate a row I get copy of it but can't edit any block in template. Any help would be much appreciated!
It appears that Mailchimp doesn't allow the hideable and repeatable tags to be on the same table/div.
So you are going to have to use one or the other.

storeTextPresent by ID selenium IDE

---Jump down to my edit with a simplistic example---
I have searched Ad Nauseum, and spent hours getting this close, but still not solving my automation problem.
Here's the thing I convert the local paper from the print edition to the online edition through PDF's, the content gets pushed to the website and is not live, until I go in and edit some settings, a lot of these are redundant. so if I can get past this one point I'm golden and can shave literally hours off of the time it takes to do this work.
The paper has twenty or thirty writers, and the one_off_byline can vary a bit here is some examples.
id=id_one_off_byline value="Michael Reid" however it may also look like the these next two or some variation thereoff even.
id=id_one_off_byline value="By Michael Reid"
id=id_one_off_byline value="By Michael Reid - Your Daily Paper"
I have used storeTextPresent to find Michael on the page. however the problem is there is another select value box on the page that contains every writers name in a selection box, which is what I'm actually trying to populate. So here is what I have
<tr>
<td>storeTextPresent</td>
<td>Jeff</td>
<td>IsTextAppears</td>
</tr>
<tr>
<td>gotoIf</td>
<td>${isTextAppears}</td>
<td>Jeff</td>
</tr>
<tr>
<td>storeTextPresent</td>
<td>Graham</td>
<td>IsTextAppears</td>
</tr>
<tr>
<td>gotoIf</td>
<td>${isTextAppears}</td>
<td>Graham</td>
</tr>
<tr>
<td>label</td>
<td>Jeff</td>
</tr>
<tr>
<td>label</td>
<td>Graham</td>
</tr>
Another way to phrase this I hope___
Form Field 1 (ignore syntax, I'm just setting up an example here) the id= is the important part in the two form fields.
<select name="select" id="pick_animal" value="">
< option="the fast cat" id="1">
< option="the fast dog" id="2">
</select>
Form Field 2
<input type="text" id="some_animal" value="the fast cat from dover">
I need to detect that id="some_animal" contains cat
so I can perform an action on the correct option in field 1.
I can do the second part just fine, I just can't detect "cat" in only the input with id "some_animal"
storeTextPresent just looks for cat to exist anywhere on the page. ugh!!
<tr>
<td>storeTextPresent</td>
<td>Jeff</td>
<td>IsTextAppears</td>
</tr>
<tr>
<td>gotoIf</td>
<td>${isTextAppears}==Jeff</td>
<td>Jeff</td>
</tr>
<tr>
<td>goto</td>
<td>END</td>
<td></td>
</tr>
<tr>
<td>label</td>
<td>Jeff</td>
<td></td>
</tr>
<tr>
<td>echo</td>
<td>something</td>
<td></td>
</tr>
<tr>
<td>label</td>
<td>END</td>
<td></td>
</tr>
Try like this.

vb.net inline IF with OR... not evaluating

I'm working on a small problem where I'm trying to show/hide a panel based on two criteria
A specific data field must not be blank
The specific data filed must also not equal "Not Relocatable"
Unfortunately this doesn't seem to be working for me (note that setting either one or the other criteria works just fine.)
<asp:Panel runat="server" Visible='<%#If(Not String.IsNullOrEmpty(DataBinder.Eval(Container.DataItem, "_236")) Or Not DataBinder.Eval(Container.DataItem, "_236") = "Not Relocatable", True, False)%>'>
<tr>
<td>
</td>
<td class="align-right lightgreen">
Buyer would consider relocating a business, if it is:
</td>
<td>
</td>
<td colspan="3">
<%#DataBinder.Eval(Container.DataItem, "_236")%>
</td>
<td>
</td>
</tr>
</asp:Panel>
Can anyone lend a hand to rectify this problem for me?
The syntax <%# %> is a data binding syntax, not an inline expression syntax. You cannot use procedural code inside of it like you can in the inline code <% %> tags.
Data binding tags must contain a single Eval or Bind function. If you need to do conditional branching based on those functions, you will need to do it using inline code around the binding tags.