Collect: Add 'rating' appearance for range type

Created on 9 Jul 2018  路  21Comments  路  Source: getodk/collect

As described in https://github.com/XLSForm/pyxform/issues/145.

The widget should validate that the step is 1 and that min is 1. There should be max stars displayed with equal spacing. If the stars don't fit in the device width, they should wrap onto additional lines.

When the user taps on an empty (white) star, the stars up to and including that star should be filled in yellow and the stored value should be updated accordingly. When the user taps on a yellow star, if there are stars to the right of it that are also yellow, those stars should become empty/white and the stored value should be updated accordingly. If there are no yellow stars to the right of the yellow star tapped, the state of the widget should remain unchanged.

If no default is specified, no stars should be selected initially and the question value should be blank. If a default is specified, that number of stars should be selected initially. Clearing the widget should clear all the stars.

Requirement and constraints should work as they do with other question types.

enhancement help wanted

All 21 comments

Hi @lognaturel . Is it an enhancement to an existing widget or totally new development ?

Is it an enhancement to an existing widget or totally new development?

@vikasdesale it's a new appearance for an existing widget so the first option.

Is it the org.odk.collect.android.widgets.RangeWidget ?
If not, could you please tell me which one it is ?

Yes, it's RangeWidget.

@vishnus1224 In terms of implementation you have a couple of options. If you look at WidgetFactory, you'll see that some appearances are handled at that level (e.g. SelectMultipleAutocompleteWidget and GridMultiWidget handle different appearances of the multiple select type) and others are like range where the appearances are all handled in RangeWidget by various conditionals.

I think that in this case the rating appearance is different enough in its requirements you'll likely want to introduce a RatingWidget class. In WidgetFactory I think it makes sense to first check to see if it's a rating, if so, use that widget and if not look at whether it's an int or decimal (this wouldn't change).

thank you @lognaturel for the explanation. I will give it a try :)
I think I will have to make a custom rating bar as the default doesn't display on multiple lines.
Also should default star icons be used ?

That's awesome, @vishnus1224! Don't hesitate to ask in the #collect-code Slack channel at http://slack.opendatakit.org/ if you have any general questions that could benefit from a quick conversation.

Hello @akshay-ap, you have been unassigned from this issue because you have not updated this issue or any referenced pull requests for over 15 days.

You can reclaim this issue or claim any other issue by commenting @opendatakit-bot claim on that issue.

Thanks for your contributions, and hope to see you again soon!

I'm sorry @lognaturel . I have been very busy past few days and haven't been able to work on this.
I am going on vacation in a couple of days for the next 15 days. So if this is urgent than someone can go ahead . Else I will do the implementation once I am back.
@opendatakit-bot unclaim

I would like to work on this issue.
@opendatakit-bot claim

Hello @akshay-ap, you have been unassigned from this issue because you have not updated this issue or any referenced pull requests for over 15 days.

You can reclaim this issue or claim any other issue by commenting @opendatakit-bot claim on that issue.

Thanks for your contributions, and hope to see you again soon!

Hie @lognaturel, I would like to work on this isuue

@opendatakit-bot claim

But @lognaturel, I have some doubts, we are talking about a whole new widget Rating Widget, that will function just same as Range Widget but will differ in appearance. Also, if we can have minimum number of selected stars to be 0, what is the maximum number of unselected stars to be displayed on the screen?

Hello @SaumiaSinghal, you claimed this issue to work on it, but this issue and any referenced pull requests haven't been updated for 10 days. Are you still working on this issue?

If so, please update this issue by leaving a comment on this issue to let me know that you're still working on it. Otherwise, I'll automatically remove you from this issue in 5 days.

If you've decided to work on something else, simply comment @opendatakit-bot unclaim so that someone else can claim it and continue from where you left off.

Thank you for your valuable contributions to Open Data Kit!

@opendatakit-bot unclaim

Apologies for missing your question, @SaumiaSinghal! I'll answer for anyone else who may want to take this on.

we are talking about a whole new widget Rating Widget, that will function just same as Range Widget but will differ in appearance.

That's correct.

Also, if we can have minimum number of selected stars to be 0, what is the maximum number of unselected stars to be displayed on the screen?

I don't think there should be a max. If the stars don't fit in the device width, they should wrap onto additional lines. That would look weird but it's something form designers can decide for themselves.

@opendatakit-bot claim

To keep this up to date -- @akshay-ap has a PR open at #2585 using Android's RatingBar but there appear to be bugs on some Android levels and no way to make the stars wrap if they don't fit horizontally. @shobhitagarwal1612, @akshay-ap and I discussed in Slack and agreed that the wrapping behavior is important because data collection projects are having enumerators use their own devices more and more and these may have very different screen widths. We think it's likely form designers will want to specify up to 10 stars.

Unless someone has suggestions to overcome the RatingBar limitations, the next step is probably to build something custom instead.

The plan is to use GridLayout with each cell containing Imagebutton.
I would suggest keeping max 5 stars each column(images would scale out depending to screen size).
The number of rows will differ.
Any other approach is also welcome.
(I shall push commits on next weekend).

I would suggest keeping max 5 stars each column

I think a fluid layout would be more expected. That is, if 7 or 10 stars fit horizontally, they should take up that space. There should only be wrapping if needed.

images would scale out depending to screen size

The images should remain a fixed size. Otherwise it will look very odd when changing orientation or using the same form on different devices.

Was this page helpful?
0 / 5 - 0 ratings