Explore the community Forums Lectora Lectora Questions & Answers Grocery store simulator

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #342241 Score: 0
    Profile photo of Alexis Scott
    Alexis Scott
    Member
    beginner
    intermediate
    contributor
    advanced
    friend finder
    profile
    Group Member
    entry
    entry
    curious george
    3 pts
    @ascott7223

    I am working on a challenge to create a grocery store simulator. I have attached what I have so far. I’m looking to have each of the purple buttons respond by adding the prices to a calculator to tell the shopper their total. In a perfect world, I’d have them drag and drop an image to the shopping cart icon, and have a way to subtract totals as well – if a customer decided to “put back” an item, for example – but I’m not sure how to build either of these out (partially because I don’t have individual images for each item, and I don’t know how to isolate the images from what I do have). But really my first goal is to get the purple buttons to work with a calculator function of some sort. I looked at the javascript options for calculators, but I’m just not technically savvy enough to have a clue what I’m doing. Am I overreaching here? Any advice?

     

    PS – I know that everyone on the planet has a calculator available if they’re doing e-learning, but part of the challenge is to have the module itself do the tallying, thus my needing help.

     

    Thanks in advance!

    #342260 Score: 0
    Profile photo of clammers
    clammers
    Member
    beginner
    intermediate
    contributor
    curious george
    wise owl
    picture perfect
    friend finder
    advanced
    entry
    entry
    20 pts
    @clammers

    Perhaps I’m oversimplifying this, but what about adding an action to each item/button to increase a variable (“Total”)  with each click. For example:

    Trigger: OnClick

    Action: Modify Variable

    Target: Total, Type: Add to Variable, Value: 0.50

    A secondary action could then change the contents of a text box to display the new total.

     

    Have you thought about adding plus (+) and minus (-) buttons below the price? You could then assign Add to Variable or Subtract from Variable actions to simulate the customer putting the item back.

    #342276 Score: 0
    Profile photo of Tim K
    Tim K
    Member
    contributor
    beginner
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    wise owl
    curious george
    Group Member
    271 pts
    @timk

    To upgrade Clammers approach, you could create variables for the amount of each product and make the buttons add 1 to the respective variable. Multiply the amounts with the prices, and sum up the individual product costs. Then you could display something like:

    You cart contains:

    2 Apples for  $1
    3 Croissants for $3

    Total = $4

    #342291 Score: 0
    Profile photo of Jason Dalrymple
    Jason Dalrymple
    Member
    beginner
    intermediate
    profile
    wise owl
    curious george
    contributor
    friend finder
    advanced
    picture perfect
    42 pts
    @JasonADal

    I’m using a similar method for the add to variable that’s outlined above in a module where the actions a learner takes tallies the score for the “test” instead of using a test itself.

    Since you want the action to subtract from the total if it’s removed from the cart, you could add a variable to indicate if the items is in or out of the cart and use if statements to modify the total.

    Variable: cart_state
    Initial value: out

    OnClick: Set variable cart_state = “in” IF cart_state = “out”, ELSE set variable cart_state = “in”

    OnClick: Add to variable “total” (amount) if cart_state = “in”, Else subtract from variable “total” (amount)

    OnClick Change content of the text box to the new total

    With drag and drop, thanks to Tim, it is possible to modify the total if the item is dragged to the drop area, but I’m not sure how you could subtract from variable if it’s dragged out of the drop area.

    #342695 Score: 0
    Profile photo of Math Notermans
    Math Notermans
    Member
    contributor
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    LUC16 Attendee
    LUC16
    wise owl
    curious george
    111 pts
    @mnotermans5114

    Maintenance deleted some of the responses..especially mine in which both issues were fixed. Only using javascript for the calculation of the total and to ensure 2 decimals are shown. If you want 1 or 3 or whatever amount of decimals, its just changing a variable.

    https://community.trivantis.com/shared-content/grocery-shopping-store/

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.