Register
Submit a solution
The challenge is finished.

Challenge Overview

This is the final challenge of the 5 Star Rating Asset Project! We have a UI built but now we need the magic of backend processing to turn this into a fully functioning feature for all our fantastic asset fans. =)

We want our community of Asset users to be able to see, at a glance, which Assets are most liked by the community. We also want users to be able to rank Assets themselves and highlight that ranking for the users when they come back to look at the Asset list.
To get you directly into coding, we've put together an unmanaged package that you can install directly into a new SalesForce developer sandbox. The URL to install the unmanaged package is: https://login.salesforce.com/packaging/installPackage.apexp?p0=04to000000070do

The package provides the Object Model that you'll need to get started with the fields that you'll need to read, insert, and update.
You'll also see two placeholder classes for where we need code implemented:
* Assets_5Star
* Test_Assets_5Star

We defined the interaction with the UI to only require a returned list of records prepared for rendering.

In this challenge we'll be extracting records and preparing the data for rendering, ending with simply the compiled list of records to display.

Later we'll combine the results from this challenge with the results of the other 5 Star Asset Challenges in order to tie the backend and frontend fully together.
In the Assets_5Star class you'll see the pattern that we need the data returned.

The code needs to return a list of the Assets_5Star Public Class Asset.
To begin, extract all records from the CMC_Asset__c custom object.

The public class defined within Assets_5Star contains getters and setters for all the fields that we’ll need to display on the UI.

public Class Asset{
   public String id {get;set;}
   public String title {get;set;}
   public String description {get; set;}
   public Boolean recommended {get; set;}
   public integer assetReuses {get; set;}
   public string previewURL {get; set;}
   public string assetType {get; set;}
   public string assetSubType {get; set;}
   public List<String> technologiesUsed {get; set;}
   public String primaryContributor {get; set;}
   public decimal averageRating {get; set;}
   public decimal myRating {get; set;}
   public String assetURL {get; set;}
 }

Most of the fields in the object model map fairly directly to the defined class. However, you’ll often find that the naming convention between the class and the Object will follow the pattern of:
(Class.property) Asset.assetType = (Object.field) CMC_Asset__c.Asset_Type__c
Notice that the difference is mostly in camel casing and underscores.
There are few properties that will require additional logic before the class’s field may be set.

1. With previewURL:
if (‘Preview Media Type (Preview_Media_Type__c)’ = ‘jpg’ or ‘png’)
then
 return the value of Preview_Media_URL__c
else
 return a null string

2. With the image to display for Practices :
Please create a custom setting that has a list of practice names and imageURLs
Include a record for value Workday (icon-workday.png)
And a record value for Other (icon-asset-blue-cloud.png)
If the Practice does not appear in the Custom Setting List of values, use the image for “Other”

3. With the User’s Rating:
For the value of the User’s Rating, select from the CMC_Asset_Rating__c object where CMC_Asset_Rating__c.User__c = the current logged in User
and
CMC_Asset_Rating__c.CMC_Asset__c = the current Asset that you are processing to display

4. Setting the User's Rating
Curently we have a method that will set the CMC Assert Rating for the current logged in user via Remote Action method see below:
@RemoteAction
public static Boolean setMyRating(String assetId, decimal myRating, string userid){
 if(math.mod(random(10,false),6) == 0)
 return false;
}else{
 return true;
}
}
This should be changed to be called from the front end with Salesforce Id of the Asset, Rating current user has entered, Id of current user. Method should upsert into salesforce object of CMC_Asset_Rating__c.

 



Final Submission Guidelines

1. Provide an SRC package (Ant or Eclipse) of your code.
2. Provide a detailed document of your solution including details for installation and setup. Provide any details about governor limits or any other limitations to your solution.
3. Provide a simple video of you solution in action. If English is not your first language feel free to annotate your video with text.
4. Not required: provide access to your dev org. If the package does not install due to missing dependencies or conflicts in the judges org, access to your org may be helpful.  

If you do provide this you should also install the ‘Enable All Trusted IP Ranges for a Salesforce Org’ by Ray Dehler. This will prevent the judge for asking you the activation code.
5. Provide 95% test coverage for your solution

Review style

Final Review

Community Review Board

Approval

User Sign-Off

Challenge links

ID: 30046896