How to add an 'image' property to questions in SurveyJS Creator? - surveyjs

In our application, the surveys that we create need to support an 'easy read' format whereby an image may be attached to any question, to be displayed alongside the question text.
I can't see a way to do this directly via the SurveyJS API properties, i.e. there doesn't seem to be any standard questionImage property. It therefore looks like this would need to be implemented as a custom property.
On that basis, I need to add a custom property to all question types, which the user can populate with an image in the same way as the 'image picker' question type allows you to select images. Specifically, the use-case we want to support is to open a file browser to the user's local machine and for the selected image to be encoded as a data: URI and stored in this property. (Supporting additional image-entry methods might be useful, but is not required.)
We are in a position to control the rendering of this property for respondents, so I am not concerned about how to make use of this property, just how to get it into the editor UI. Also, whilst it would be nice to see the image in the editing interface, this is also not essential behaviour at this stage.
From a Google search, I have seen similar questions, where the answer has been to insert an Image or HTML element into the survey just before the relevant question, however this is not an appropriate solution for our use-case. Firstly, it makes the survey hard to manage (both fiddly to use and also easy to break things when moving/deleting questions). Secondly, it means that the Image is rendered before the question, whereas we need it to be rendered as part of the question element (i.e. after the question number, before the question text).
Can anyone give an example for how I can add a new question property that behaves in the manner described above?

You need to add this property to surveyjs metadata:
Survey
.Serializer
.addProperty("question", {
name: "image:file",
category: "general"
});
Here is the working sample - https://plnkr.co/edit/5wpQMdMq1vxKhWaG

Related

web2py sqlform grid modify edit view

How do I modify the edit view in my SQLFORM.grid - size of input fields, drip down menus, etc. Documentation is poorly written so any examples would be a big help.
Thank you
The SQLFORM.grid uses the assigned widgets in your database model.
So to change the output of the grid on widget level, change the model. The fieldtype defines the auto selected widget. See the field-constructors part of the book.
If you want more fine-grained control over the result you could tweak the widgets, override widgets, create your own widgets, patch the generated code in the browser using jquery of choose to write the entire grid yourself. Also you could change some parameters to the grid based on some SQLFORM parameters it passed through to the generated SQLFORM. Try the viewargs argument to the grid to alter the parameters sent to the SQLFORM when viewing. You might want to offer it something like dict(formstyle='divs') or use the ui parameter to offer a dictionary with classnames you use to apply your own CSS. ref
About the choice for using the grid in the first place:
These are two high level objects that create complex CRUD controls.
They provide pagination, the ability to browse, search, sort, create,
update and delete records from a single object.
So for very fine grained control it might be best to write your own grid instead of using such high level objects.
I'm not saying it's impossible to finetune the grid using the model and some javascript, but because it uses so much of all the other elements of web2py diving into the grid without much further web2py knowledge is quite a steep learning curve.

Flag module - link's position change (Drupal)

I've just installed Flags module and it looks awful when on the bottom I see "Flag this item" link. The only thing I've found in configuration is enabling it to show as normal link. Still I haven't found how to change position of this link. Is it even possible to change link's place? I have installed CCK Blocks but it doesn't give me any option to get rid of it. If someone know or suspect what's possible - please help me.
Try the Display Suite module, this module is integrated with many modules like flag, title etc...
Display Suite allows you to take full control over how your content is displayed using a drag and drop interface. Arrange your
nodes, views, comments, user data etc. the way you want without having
to work your way through dozens of template files. A predefined list
of layouts (D7 only) is available for even more drag and drop fun!
https://drupal.org/project/ds
You can move and generate custom layouts for the fields/properties on the entity display formatter: teaser, full...

DNN get params in view are not available in edit

I am creating a dnn module. The content depends on the param in the url.
I want to be able to edit this content in the 'edit content' mode. However when i go to edit content the param in the url is no longer accessible because it is the parent document. How do i go about passing this value from the view.ascx to the edit.ascx?
Try storing the param in cookies or localstorage. Then you should be able to access it. Of course the user will be able to modify it but you can do a check that the user has not modified it by storing a server side encryption or somthing like that.
A workaround is to have a field where the user enters this parameter. But i know this isn't a very good solution. I am guessing that you will have to override the dotnetnuke core to do this (yes i know it sucks).
I hope I am understanding the question properly.
To pass parameters from your View to Edit controls, you should first make sure they are registered properly in the module definition. You default View should have an empty controlkey and your Edit should be registered with a control key, for example "addedit".
When creating a link between your view control and edit control, use the EditUrl() method of PortalModuleBase. When passing a parameter, for example an id of the item you want to load into your edit control, you can pass them as arguments in the EditUr method.
Example (in my view.ascx.cs):
lnkEdit.NavigateUrl = EditUrl("id", "16", "addedit");
This will assign a module view link to the edit.ascx (assuming the controlkey in the definition is addedit) passing in a url parameter "id" with value 16.
See my DNN Module Views tutorial for a complete lesson on how to do DNN module views and navigation.
http://www.dnnhero.com/Premium/Tutorial/tabid/259/ArticleID/204/Introduction-and-Module-Definition-basics-in-DNN-Part-1-6.aspx

Get ancestor object of un-saved object in Hobo

I'm working on a Hobo app trying to tie together a few models properly.
Activity objects have many Page children. They also have many DataSet children.
Page objects have several different kinds of children. We'll talk about Widget children, but there are several types with the same issue. An instance of a Widget belongs to a Page but also has a belongs_to relationship with a DataSet. Here's the important point: the DataSet must belong to the containing Activity. So for any given #widget:
#widget.page.activity === #widget.data_set.activity
It's easy enough to enforce this constraint in the model with a validation on save. The trick is presenting, within the Widget's form, a select menu of available DataSets which only contains DataSets for the current Activity
I was able to get this working for existing objects using a tag like this:
<data_set-tag: options="&DataSet.activity_is(&this.page.activity)" />
However, for a new Widget, this fails messily, because either &this or &this.page is not yet set. Even for a route which contains the page ID, like /pages/:page_id/widgets/new, I'm not really able to get an Activity to scope the list of DataSets with.
If this was proper Rails, I'd get in to the relevant controller method and make the Activity available to the view as #activity or something of the sort, but in Hobo the controllers seems to be 95% Magicâ„¢ and I don't know where to start. The knowledge of which Activity is current must be in there somewhere; how do I get it out?
This is Hobo 1.3.x on Rails 3.0.x.
ETA: The code producing the errors is in the form tag for Widget, like so:
<extend tag="form" for="Widget">
<old-form merge>
<field-list: fields="&this.field_order">
<data_set-tag: options="&DataSet.activity_is(&this.page.activity)" />
</field-list>
</old-form>
</extend>
As I said above, this works for editing existing Widgets, but not new Widgets; the error is undefined method 'page' for nil:NilClass. Bryan Larsen's answer seems to suggest that &this.page should not be null.
it looks like you tried to post this question to the Hobo Users mailing list -- I got a moderation message, but it doesn't appear that your post got posted, nor can I find it to let it through. Please try reposting it, there are several helpful people on the list that don't monitor the Hobo tag here.
In Hobo 1.3, the new action doesn't support part AJAX, so there really isn't much magic. You can just replace the action with your own:
def new_for_page
#activity = Activity.find(...)
#page = Page.find(params[:page_id])
#widget = #page.widgets.new
end
There is a little bit of magic referenced above: if you're in WidgetsController, assigning to #widget will also assign to this.
But as you said, the knowledge is obviously in there somewhere, and your custom controller action shouldn't be necessary.
This statement seems wrong: However, for a new Widget, this fails messily, because either &this or &this.page is not yet set.
It looks like you're properly using owner actions. /pages/:page_id/widgets/new is the route. In widgets_controller it's the new_for_page action. In a new or new_for action, this is set to an unsaved version of the object. In your action, it should have been created with the equivalent of Page.find(params[:page]).widgets.new. In other words, both this and this.page should be populated.
I'm sure you didn't make your statement up out of thin air, so there's probably something else going on.
In the end, it turned out to be syntax. Instead of
<data_set-tag: options="&DataSet.activity_is(&this.page.activity)" />
I needed
<data_set-tag: options="&DataSet.activity_is(#this.page.activity)" />
(note the #).
We actually made this into a helper method, so the final code is
<data_set-tag: options="&DataSet.activity_is(activity_for(#this))" />

Extend Page Property with custom controls in Sharepoint

Sharepoint is quite limited when it comes to multi-Lookups because it saves that information in strings. So I changed the Page-Property
"Elements (MultiLookup-> elementIds" on the propertyPage
to an inserted List "PageElements":
"
(SingleLookup)pageId , (singleLookup) elementId"
Because this is quite hard to maintain for my content admins I want that they can enter that information in the page properties like before instead of adding lines into "PageElements"
Therefore I want to add a control that handles that.
I do not need a solution for the task how to achieve that specific function, but a general hint how to add any custom control into a Page property.
I starting point link would be very nice. I just doen't seem to find the right words to feed google with my topic.
Solved this by using a custom field type with that logic. Basicly Described here: http://avinashkt.blogspot.de/2011/07/creating-custom-field-in-sharepoint.html