Challenge Overview

Challenge Overview

In this challenge you are building a Rails mountable engine using the provided UI prototype and outlined requirements below.

Winning submissions will be used by end users to donate energy to people in energy poverty.

You are expected to implement the following in this challenge :

  • Build the Ruby on Rails engine as outlined below.

  • Build a Ruby on Rails demo application that demonstrate how to host the engine.

  • Create a detailed readme deployment document.

Challenge Requirements

Send Energy Now Requirement

  • In this functionality a user can see energy production of solar energy, define a percentage of produced energy to send to people in energy poverty, see the impact of the specific amount of energy selected and click to send energy. The Send Energy button will include a URL to drive users to a Send Energy.

  • Step 1

    • User will provide a US zip code.

    • We have following flow/logic based on user’s answer for “Do you have rooftop solar panels?” :

      • Yes

        • This will display a form to authenticate user with enphase. But since enphase api requires user id (generated from an auth flow)  you need to change the first field a button with label “Login with EnPhase”. The second field will display the user id on successful authentication.

        • Clicking on “Login with EnPhase” will take user to enphase auth flow.

        • Refer to Enphase and PVWatts Gem demo for sample of how the authorization is done.

      • No

        • We will take the input value from “Installed Capacity” field as it is.

        • If user picked “Square feet of solar panels” then do the following calculation to convert the value from sqrft to Kw:

    • For both Yes/No options, the collected data will be passed to backend to be processed by “Enphase and PVWatts Gem”, refer to “Enphase and PVWatts Gem Gem” section below for more information.

    • The call to backend should be via AJAX, display ajax loading indicator to give user indication that is something is being calculated in the backend.

  • Step 2

    • The response of ‘calculate’ button will be an energy production value and cost, render these information as shown in the screenshot.

    • “Your Impact” section will allow user to select the amount of energy to send.

      • User can set the amount to send via two input UI :

        • Slider :

          • The steps should be dynamically calculated based on the amount of cost rendered above. Every step is 5$ always, so if we have $100 then we will have 20 steps .. etc.

          • The selected step should be updated when percentage button is changed.

        • Percentage buttons :

          • You will use same percentage as in the prototype.

          • The selected button should be updated when slider step is changed.

      • The three labels : day of energy, $$ amount, and energy amount will be recalculated based on selected amount to send.

        • You can assume the response from “calculate” represents a 30 days of produced energy, your calculation for updating these labels will be based on this assumption.

  • Last Step : Send Energy

    • Clicking this button will do the following :

      • Persist all data and information collected from all steps in cookie/session. So next time user visit the page will get the information pre-populated from cookie.

      • A backend controller method should handle the call :  
        protected def callback_to_host_app(dollars_to_send, kwh_to_send, last_month_production, zipcode)
            raise "Please override me in the host application!"
        end

      • The demo application should show how to override this method and displaying a success popup window with the information passed to the method.

Enphase and PVWatts Gem

  • You are provided with a Ruby gem built in a past challenge to handle “calculate” action in Send Energy flow.

  • The Gem is provided in challenge forums and contains a very detailed information about it’s usage.

  • If user selected Enphase then zip code and enphase user id will be passed to the Enphase get_enphase_last_month_stats function in the Gem.

  • If user selected “NO” then we will use PVWatts to calculate an estimate of last month produced energy and cost. We will pass zip code, and capacity (in kW) to PVWatts get_pvwatts_stats function in the gem.

  • The provided Gem also include a demo folder gm_stats_demo that demonstrates how to authorize a user with EnPhase and how to use the Gem to get produced energy and cost for both EnPhase and PVWatts.

  • All required configuration in this gem should be configured in the Rails engine.

Ruby on Rails Engine Requirements

The following points are very important as we are integrating the output of this challenge with an existing RoR application. You can find this link very helpful to get started with Engines.

  1. The engine to be built should be ready made application extension, such that it can be plugged in into an existing RubyOnRails application and once handed the execution path it runs completely autonomous.

  2. The views created in this challenge should not render any core HTML elements (html, head, body) nor provide any header/footer. The host application is responsible for them. CSS/JS assets will be loaded by the host/existing application per instructions.

    • The demo application should use the header/footer in the provided UI prototype.

    • Make sure the Rails engine is inheriting from host application's ApplicationController class and not the namespaced one, by removing the auto generated application_controller.rb in your engine. This way the engine is also inheriting the host application's layouts.

    • In your generated views use a construct the one like below to pass your header elements to the host application layout. There is JS in the real host application to automatically pick-up a link with class .scroll-link and smooth-scroll to the element ID in data-id. You also need to demonstrate this in the demo application app.

- content_for :topcoders_main_nav

    li= link_to "Send energy now", 'javascript:void(0)', class: "scroll-link", data: {id: "your-impact"}

    li= link_to "How it works", "javascript:void(0)", class: "scroll-link", data:{id: "how-it-works-for-you"}

  1. Provide Turbolinks compatible JS. Existing application is utilizing Turbolinks, which is de facto included in Rails 4 projects.

  2. Provide all needed integration scripts and instructions to integrate with existing application, that include the routes, database migration, and an initializer for the engine configuration.

  3. Provide a sample RoR application to verify the integration and mounting functionality.

Demo RoR Application

You are building a demo RoR to demonstrate the following :

  • Mounting the engine to existing RoR application.

  • Passing header/footer dynamic content to hosting RoR application.

  • Verify that the engine inherit the hosting view layout.

  • Demonstrate the “Send Energy” controller function override functionality.

Documentation

Because other programmers will be working with your code, and incorporating it into their projects, all functions must be documented in detail in the code.

Coding Standard

Follows coding standards listed here: https://github.com/copycopter/style-guide

Folder Structure

Please follow best practices for the folder structure as mentioned in this link http://edgeguides.rubyonrails.org/engines.html

Readme

Provide a detailed readme file using Markdown language with following information :

  • Overview

  • Setup Prerequisites

  • How to install

  • Usage Example

  • How to run the engine and verify results.

  • Any details about any limitations of your solution.

References

Documents

The UI prototype and Gem library are provided in challenge forums.



Final Submission Guidelines

Deliverable

  • All source code files and scripts that addresses the challenge requirement.

  • Detailed readme file as clarified above.

ELIGIBLE EVENTS:

2015 topcoder Open

REVIEW STYLE:

Final Review:

Community Review Board

Approval:

User Sign-Off

SHARE:

ID: 30049820