Possible to have multiple crowd-classifier elements in mturk? - mechanicalturk

Is it possible to have two crowd-classifier elements? I tried the follow, for example, but it just duplicates the form and results in two submissions buttons. How do I make it so that there is only one submission button and one set of instructions/shortcuts?
<crowd-form>
<crowd-classifier
name="category"
categories="['Optimism', 'Neutral', 'Other']"
header="Select the relevant categories"
>
<classification-target> ${text} </classification-target>
</crowd-classifier>
<crowd-classifier-multi-select
name="category"
categories="['Admiration', 'Gratitude', 'Curiousity', 'Optimism', 'Neutral', 'Other']"
header="Select the relevant categories"
exclusion-category="{ text: 'None of the above' }"
>
<classification-target> ${text} </classification-target>
</crowd-classifier-multi-select>
</crowd-form>

Related

odoo 8 make button invisible from compute result

This is my .py
#api.depends('product_id')
def get_sales_divisi(self):
for line in self:
if line.product_id.divisi_update:
line.sales_divisi_id = line.product_id.divisi_update.id
elif line.product_id.divisi_ids:
line.sales_divisi_id = line.product_id.divisi_ids.ids[0]
this is my .xml
<button name="action_approve" string="Approve Checker" type="object" attrs="{'invisible':['|',('sales_divisi_id', '=', '2'),('sales_divisi_id', 'in', ('VET'))]}" groups="ts_addons_tbk.group_tbk_checker" />
I'm tying to make the button invisible when the sales_divisi_id is Vet but it doesn't work. Any advice please? Thank you
Assuming sales_divisi_id is a relation, in operator will query by id or name field.
Furthermore, in order to use fields in queries inside your views, you need to define them first.
For example:
<field name="sales_divisi_id" invisible="1" />
<button name="action_approve" attrs="{'invisible':[('sales_divisi_id', 'in', [1,2])]}" groups="ts_addons_tbk.group_tbk_checker" />
action_approve button will show only if sales_divisi_id is related to a record having id 1 or 2.

placeholder in <aui:select> for dropdown liferay

How can I have a placeholder value in a dropdown ? Something a user will be shown in a dropdown but he will not be able to 'Select' that option.
For example: I'll have a placeholder as 'Please Select an Item' as a selected text in dropdown(placeholder) but user will not be able to select 'Please Select an Item' as an item from dropdown list.
Currently I do have to use things as shown in below code
<aui:select label="" id="admin" name="optionsSelect">
<aui:option value="1">Please Select an Item</aui:option>
<aui:option value="2">Item1</aui:option>
<aui:option value="3">Item2</aui:option>
<aui:option value="4">Item3</aui:option>
<aui:option value="5">Item4</aui:option>
</aui:select>
the only option to have a select with something like a placeholder is to add as you did a first option to the select, but adding also the options "selected" and "disabled" and its value empty, that is:
<aui:select label="" id="admin" name="optionsSelect">
<aui:option value="" selected="true" disabled= "true">Please Select an Item</aui:option>
<aui:option value="2">Item1</aui:option>
<aui:option value="3">Item2</aui:option>
<aui:option value="4">Item3</aui:option>
<aui:option value="5">Item4</aui:option>
</aui:select>
Hope that help.

Selenium2Library - Safari not selecting from drop down list

I have two drop downs on a page. I need to verify that the item in drop down list 1 has a class of "selected" added to it when the item in drop down list 2 has been selected. Drop down list 1 has more than 3 options in it but I wanted to save space in the post. The first chunk of steps gets the values for all the items in the list and randomly selects one.
The second portion uses the value that was randomly selected in the first few steps to target the option and see check for the selected class to be true.
Here is the HTML:
<ol>
<li class="select input required" id="message_recipient_input">
<select id="message_recipient_id">
<option value></option>
<option value="1">Smith, Bob</option>
<option value="2">Smith, Steve</option>
<option value="3">Smith, Joe</option>
</select>
</li>
</ol>
<ol>
<li class="select input required" id="message_template_input">
<select id="message_template_id">
<option value></option>
<option value="9">Message Template</option>
<option value="10">Survey Template</option>
<option value="11">Coupon Template</option>
</select>
</li>
</ol>
Here are the steps in RF:
${RecipientCount}= Get Matching Xpath Count xpath=//*[#id="message_recipient_id"]/option
Log ${RecipientCount}
#{ValueList}= Create List
: FOR ${INDEX} IN RANGE 1 ${RecipientCount}
\ ${recipient_value}= Get Element Attribute xpath=//*[#id="message_recipient_id"]/option[contains(text(), '#')] [${INDEX}]#value
\ Log ${recipient_value}
\ Append To List ${ValueList} ${recipient_value}
Log ${ValueList}
${recipient}= Evaluate random.choice(${ValueList}) random
Log ${recipient}
Sleep 2s
Select From List id=message_recipient_id ${recipient}
Sleep 2s
${message_template_dropdown}= Select From List By Value id=message_template_id 9
Sleep 2s
${selected_recipient}= Get Element Attribute xpath=//option[#value=${recipient}] #selected
Log ${selected_recipient}
Should Contain ${selected_recipient} true
This works fine in Chrome and Firefox on Mac OS X but Safari isn't selecting any of the items in the lists. The steps pass as if it is selecting them but fails on the "Should Contain" step because ${selected_recipient} has None for the selected class.

How do I conditionally add an id attribute in TAL (PHPTAL)?

I'm creating a form elements template file in PHPTAL. I would like to be able to OPTIONALLY pass in an id attribute for a field...
So far the code looks like this:
<xml>
<tal:block metal:define-macro="text">
<label tal:condition="php: !isset(hideLabel) || isset(hideLabel) && !hideLabel">${field/label}</label>
<input name="${name}" type="text" value="${field/value}" />
<p tal:condition="exists:field/error">${field/error}</p>
</tal:block>
</xml>
This works as advertised. What I'd like to add is something, like
<input name="${name}" tal:attributes="id exists: id $id | $name" value="${field/value}" />
to allow me to optionally pass in an id from the METAL call...
Should I be doing it differently? I've tried using PHP: isset(id) ? $id : NULL and variations thereof, but just end up with an id="0" in the resultant HTML.
Any ideas?
In case anyone else needs it, one working answer is:
<xml>
<tal:block metal:define-macro="text">
<label tal:condition="not: exists:hideLabel">${field/label}</label>
<input name="${name}" tal:attributes="id id | nothing" type="text" value="${field/value}" />
<p tal:condition="exists:field/error">${field/error}</p>
</tal:block>
</xml>
Where passed in variables are id, name, an array named field, and hideLabel .
Note, that I've also managed to simplify the label test to something which I believe is more idiomatically TAL.
Set VAR at a DIV containing the soon to be used element:
div class="" tal:define="VAR context.property"
div class="" tal:attributes="class python:'grid_8 omega' if VAR else 'grid_8 alpha'"
in PHP:
<div id="contentCenter" tal:attributes="id
php:isset(variable)&&isset(variable.property)?'IDVALUE':NULL">

Selecting items IN a row

I'm developing a website for Tenants to find properties. When they sign up, they can choose the property types that they are interested, for example: Apartment or House.
When a Tenant logs into their account, they can then do a search for properties. The search form is prepopulated with the values that they originally entered on sign up, for example: City, Postcode and so on.
The form also needs to display some checkboxes with the relevant boxes ticked for the Property Types that they selected on sign up. I'm having some problems getting this to work and wondered if there is anyone who could correct the code for me?
I believe I need to use an 'IN' statement so that the relevant checkboxes would be ticked, if the IDs for those properties are found in the CustomerReqPropertyType column. The CustomerReqPropertyType column is varchar(50) and as an example, if a user has selected Apartment and House, it is store in the row as 2, 4 (as there is a separate table with the Property Types.
This is the code I have on the page;
<%
While (NOT rspropertytype.EOF)
%>
<li>
<input type="checkbox" name="txtPropertyType" id="txtPropertyType" value="<%=(rspropertytype.Fields.Item("PropertyTypeID").Value)%>"<% If Not rstenantrequirements.EOF Or Not rstenantrequirements.BOF Then %><%If (Not isNull((rstenantrequirements.Fields.Item("CustomerReqPropertyType").Value))) Then If (CStr(rspropertytype.Fields.Item("PropertyTypeID").Value) = CStr((rstenantrequirements.Fields.Item("CustomerReqPropertyType").Value))) Then Response.Write("")%><% End If ' end Not rstenantrequirements.EOF Or NOT rstenantrequirements.BOF %> />
<label for="txtPropertyType"><%=(rspropertytype.Fields.Item("PropertyTypeTitle").Value)%></label>
</li>
<%
rspropertytype.MoveNext()
Wend
If (rspropertytype.CursorType > 0) Then
rspropertytype.MoveFirst
Else
rspropertytype.Requery
End If
%>
I would be very grateful for any help.
In order for a checkbox to be checked the checked property must equal "checked".
e.g.
<input type="checkbox" name="something" value="somethingElse" checked="checked" />
I suspect that in your code the rspropertytype and rstenantrequirements recordsets could be consolidated into one recordset generated from one SQL statement.
e.g.
SELECT pt.*
, CASE
WHEN ISNULL(tr.CustomerReqPropertyType,0) = 0 THEN 0
ELSE 1 END AS [checked]
FROM propertytype AS [pt]
LEFT JOIN tenantrequirements AS [tr]
ON pt.PropertyTypeID = tr.CustomerReqPropertyType
WHERE ...
Then your ASP code could be simplified as well.
e.g.
<%
While (NOT rs.EOF)
Dim pID : pID = rs("PropertyTypeID")
Dim pTitle : pTitle = rs("PropertyTypeTitle")
Dim checked : checked = "" : If (rs("checked") = 1) Then checked = "checked"
%>
<li>
<input type="checkbox" name="txtPropertyType" id="txtPropertyType<%=pID%>" value="<%=pID%>" checked="<%=checked%>" />
<label for="txtPropertyType<%=pID%>"><%=pTitle%></label>
</li>
<%
rs.MoveNext()
Wend
%>
This is really hard to follow. First I'd break up that line to where your while is you can just set a variable and print that to page. I assume you're trying to set the checkbox checked. What I would do is make sure the value returned isn't null assuming this is a query that just returns the property type and you left joined it with the table that has the descriptions in it when they are set for the property in question. I don't see you ever print checked to the checkbox so it's never going to be checked anyway.