Forum Discussion

joetesta's avatar
joetesta
Roku Guru
14 years ago

questions about handling starratings

Hi -

I have included the 'AddRatingButton' so the user can vote on titles and I'm trying to figure out the logistics. I didn't find anything about this in the docs or forum, does anyone have advice about implementing it?
Here are my questions:

1. Is there an easy way to save their vote so that once the user browses to a different title and then browses back to the title they voted on, their earlier vote will still be shown? Would the app need to connect to the server / db to get the user's previous rating for each title page they browse? (not liking that idea) Alternatively, each time they return to the page they'd see the default rating and would be able to recast their vote (replacing their earlier vote for the same title)

2. At what point should the average ratings be generated for inclusion in the XML?
a) each time the app is launched, re-calculate all average ratings?
b) each time a user votes, recalculate the average rating for just that title?
c) periodically (every 6 hours) recalculate all average ratings?
(I'm thinking a combination of b and c, where the average rating gets recalc'd on the fly but the XML is only regenerated a few times per day)

tyvmia,
Joe

10 Replies

  • The better option would to be put the value in a database that you can read from later. However, if you want to avoid the database option you could write the value to the registry and read back from the registry later. Several examples of registry functions in a utils file, just look for roRegistry.
  • thanks Skipfire - i was thinking it would be inefficient to make an additional web / db call on every single page. but maybe that is the way to go...? Will check out using the registry functions, thank you!
  • Just pass the user's star rating in place of the average if the user has submitted one, then it is included in the XML response that has all the data and doesn't result in extra calls to get the value. I don't know how much space the registry has and if you have a really big number of videos you could run into problems. Plus you would have to be sure the naming of the values can stay unique. DB is the better way to go if you can.
  • destruk's avatar
    destruk
    Streaming Star
    You wouldn't need to download the star rating on every page. If you are downloading the xml for an entire poster screen, then you download the star ratings with the meta data for all the content on the poster screen and pass the entire listing of items to the detail screen. That way the user can use the left and right buttons on the remote to scroll through on the detail screen without needing to interact with the server again unless they 'rate' something.
  • Hi guys, thanks for your replies. But I think you are missing the point of my question (1). I understand I can pass the user's rating within the XML but my question was when the user does not reload the XML; ie browsing to the next title then back to the title they rated. Their rating would appear to the user to be lost / not recorded, until the next time they load the XML. Or are you saying the XML should be reloaded on every page call? I used the videoplayer example and load the XML for many titles at once.

    And now I know there are (at least) 2 ways to address it - a web / db call on every page load or a registry call at the same point.
  • "joetesta" wrote:
    Hi guys, thanks for your replies. But I think you are missing the point of my question (1). I understand I can pass the user's rating within the XML but my question was when the user does not reload the XML; ie browsing to the next title then back to the title they rated. Their rating would appear to the user to be lost / not recorded, until the next time they load the XML. Or are you saying the XML should be reloaded on every page call? I used the videoplayer example and load the XML for many titles at once.

    And now I know there are (at least) 2 ways to address it - a web / db call on every page load or a registry call at the same point.


    Maybe I'm not understanding what you're trying to do, but if you're just talking about the user's rating, that is stored in the userStarRating attribute of the content-meta-data structure. Just modify the value there in memory during the session and don't worry about the XML at all.
  • You might wish to implement separate calls to your server to set and get the star ratings for a video, for example:

    set star ratings:
    http://myserver.com/api/SetStarRating?authtoken=FZXXY&videoUniqueID=AZ7YZ&DeviceSerialNumber=13A12X12345&rating=5

    get star rating:
    http://myserver.com/api/GetStarRating?videoUniqueID=AX7YZ&authtoken=FZXXY

    that would returns either the value as a text string or XML. That way, you wouldn't have to reparse your full XML each time as the user browses from one item to the next.

    - Joel
  • Thank you very much guys,
    Just modify the value there in memory during the session and don't worry about the XML at all.

    Is there an example somewhere showing the proper sytnax for doing this within the videoplayer example?

    here's what I'm trying, on appDetailScreen.brs I am seeing the ratings come in, but is it getting stored in memory?
                    if msg.GetIndex() = 4
    ' update userStarRating
    print "Rating received: "; msg.GetData()
    showList[showIndex].StarRating = msg.GetData()
    endif


    Then in showFeed.brs I tried this:
            item.StarRating = validstr(curShow.StarRating)

    and since that didn't work I also tried this:
            item.StarRating = validstr(curShow.StarRating.GetText())


    I don't know what I'm doing, it's not working.
    tyvmia for any help.
  • OK getting there, it is getting stored in memory, I just needed to convert the stored value to an integer when displaying in the button,
    screen.AddRatingButton(4, 0, strtoi(showList[showIndex].StarRating))


    and as far as retrieving the values from the XML, the second way I tried works:
    item.StarRating = validstr(curShow.StarRating.GetText())


    but now I'm getting a Type Mismatch when I try to strtoi the stored values... i'll figure it out