Skip to content
blog.fossasia.org
  • Home
  • Projects
    • Contribute
  • Events
    • Eventyay Platform
    • Event Sponsorships
    • Event Calendar
    • FOSSASIA Summit
    • OpenTechSummit China
    • OpenTechSummit Thailand
    • OpenTechSummit Vietnam
    • Jugaad Fest India
    • Past Events
      • FOSSASIA Summit 2022
      • FOSSASIA Summit 2021
      • FOSSASIA Summit 2020
      • FOSSASIA Summit 2019
      • FOSSASIA Summit 2018
      • FOSSASIA Summit 2017
      • FOSSASIA Summit 2016
      • FOSSASIA Summit 2015
      • FOSSASIA Summit 2014
      • FOSSASIA Summit 2012
      • FOSSASIA Summit 2011
      • FOSSASIA Summit 2010
      • GNOME.Asia 2009
      • MiniDebConf Vietnam 2010
      • Sciencehack.Asia
      • Science Hack India
  • Programs
    • Programs and Opportunities
    • Jobs Opportunities
    • Program Guidelines
    • Codeheat Contest
    • University Internship Program
    • University Student Coding Programs
    • High School Student Program
    • Advanced Developer Program
    • Become a Mentor
      • Become A University Student Mentor
      • Become A High School Student Mentor
  • Shop
  • Blog
  • About
    • Jobs
    • Membership
    • Activities
    • Background & Mission
    • Best Practices
    • Licenses
    • Team
    • Code of Conduct
  • Donate
Menu Close
  • Home
  • Projects
    • Contribute
  • Events
    • Eventyay Platform
    • Event Sponsorships
    • Event Calendar
    • FOSSASIA Summit
    • OpenTechSummit China
    • OpenTechSummit Thailand
    • OpenTechSummit Vietnam
    • Jugaad Fest India
    • Past Events
      • FOSSASIA Summit 2022
      • FOSSASIA Summit 2021
      • FOSSASIA Summit 2020
      • FOSSASIA Summit 2019
      • FOSSASIA Summit 2018
      • FOSSASIA Summit 2017
      • FOSSASIA Summit 2016
      • FOSSASIA Summit 2015
      • FOSSASIA Summit 2014
      • FOSSASIA Summit 2012
      • FOSSASIA Summit 2011
      • FOSSASIA Summit 2010
      • GNOME.Asia 2009
      • MiniDebConf Vietnam 2010
      • Sciencehack.Asia
      • Science Hack India
  • Programs
    • Programs and Opportunities
    • Jobs Opportunities
    • Program Guidelines
    • Codeheat Contest
    • University Internship Program
    • University Student Coding Programs
    • High School Student Program
    • Advanced Developer Program
    • Become a Mentor
      • Become A University Student Mentor
      • Become A High School Student Mentor
  • Shop
  • Blog
  • About
    • Jobs
    • Membership
    • Activities
    • Background & Mission
    • Best Practices
    • Licenses
    • Team
    • Code of Conduct
  • Donate

skill feedback

Read more about the article Post feedback for SUSI Skills in SUSI.AI Android App

Post feedback for SUSI Skills in SUSI.AI Android App

  • Post author:Arundhati Gupta
  • Post published:August 19, 2018
  • Post category:Android/FOSSASIA/GSoC/SUSI.AI
  • Post comments:0 Comments

Feedback from users is one of the most important aspect of software development. This helps developers collect data about the bugs that need to be fixed and the improvements that need to be done in a software. This also provides them with an insight into what needs to be done for the long term sustainability of the app.

SUSI.AI Android, web and iOS clients allow user to rate the SUSI Skills allow the user to post feedback about a skill. Users can send their invaluable feedback about how helpful a skill is for them and how could it be improved. This blog focuses on the implementation of the feature to post feedback from the SUSI.AI Android client.

Steps to post feedback

  1. Log into the app. You will see the Chat Activity once you are logged into the app.
  2. Tap the FAB on the upper right corner of the Chat Activity.
  3. You will see the list of all skills.
  4. Tap on any skill of your choice.
  5. Write feedback about SUSI skill

Click on POST button to post the skill feedback. A toast, with the message “Skill feedback updated”, will appear at the bottom of the screen.

Note : An anonymous user cannot submit feedback for the skill. You must be logged-in in order to post feedback. If you are not logged-in, the post feedback section would not be visible. Instead you will see a text message saying “Please login to post feedback”.

Implementation of post skill feedback feature

Case 1 : The user is logged in i.e. the access token is not null.

This is how the post feedback UI looks like, when the user is logged in :

Now, add the following code inside a service to make a post request to feedbackSkill.json API.

/**
    * Post feedback given by the user for the skill to the server
    *
    * @param model    Model of the skill (e.g. general)
    * @param group    Group of skill (e.g. Knowledge)
    * @param language Language directory in which the skill resides (e.g. en)
    * @param skill    Skill Tag of object in which the skill data resides
    * @param feedback Feedback to be sent to the server
    * @return the call
    */
   @POST("/cms/feedbackSkill.json")
   Call<PostSkillFeedbackResponse> postFeedback(
                           @Query("model") String model,
                           @Query("group") String group,
                           @Query("language") String language,
                           @Query("skill") String skill,
                           @Query("feedback") String feedback);

 

Further, attach an OnClickListener with the POST button and call the postFeedback() present in the presenter layer, as can be seen in the following code :

/**
* Set up the feedback section
*
* If the user is logged in, show the post feedback section otherwise display an appropriate message
*/
private fun setFeedback() {
   if (PrefManager.getToken() != null) {
       tvPostFeedbackDesc.visibility = View.VISIBLE
       layoutPostFeedback.visibility = View.VISIBLE
       buttonPost.setOnClickListener {
           if (etFeedback.text.toString().isNotEmpty()) {
               skillDetailsPresenter.postFeedback(skillData.model, skillData.group, skillData.language,
                       skillTag, etFeedback.text.toString())
           } else {
               Toast.makeText(context, getString(R.string.toast_empty_feedback), Toast.LENGTH_SHORT).show()
           }
       }
   } else {
       tvAnonymousPostFeedback.visibility = View.VISIBLE
   }
}

 

The postFeedback() in the presenter will now invoke the postFeedback() method present in the model as follows :

skillDetailsModel.postFeedback(model, group, language, skill, feedback, this)

 

Here is how the postFeedback() method in the model looks like :

override fun postFeedback(model: String, group: String, language: String, skill: String, feedback: String, listener: ISkillDetailsModel.OnUpdateFeedbackFinishedListener) {

       updateFeedbackResponseCall = ClientBuilder().susiApi.postFeedback(model, group, language, skill, feedback)

       updateFeedbackResponseCall.enqueue(object : Callback<PostSkillFeedbackResponse> {
           override fun onResponse(call: Call<PostSkillFeedbackResponse>, response: Response<PostSkillFeedbackResponse>) {
               listener.onUpdateFeedbackModelSuccess(response)
           }

           override fun onFailure(call: Call<PostSkillFeedbackResponse>, t: Throwable) {
               t.printStackTrace()
               listener.onUpdateFeedbackError(t)
           }
       })

 

Once the call is made successfully to the server, the next step is to update the UI. This is achieved with the help of the onUpdateFeedbackModelSuccess() called above, if the response is received.

override fun onUpdateFeedbackModelSuccess(response: Response<PostSkillFeedbackResponse>) {
       if (response.isSuccessful && response.body() != null) {
           Timber.d(response.body().message)
           skillDetailsView?.updateFeedback()
       } else {
           Timber.d("Could not update feedback")
       }
   }

 

Clearly, if the response is successful and the response body is non-null, it implies that the feedback submitted by the user has been successfully updated on the server. Thus, we display a toast to notify the user of the successful submission of the feedback. This is achieved with the help of the updateFeedback() method in the view, as follows :

override fun updateFeedback() {
   Toast.makeText(context, getString(R.string.toast_feedback_updated), Toast.LENGTH_SHORT).show()
}

 

Note : The response from the server to the above post request would be similar to the one shown below :

{
  feedback: "Helpful",
  session: 
    {
      ...
    },
  accepted: true,
  message: "Skill feedback updated"
}

Case 2 : The user is not logged in.

In this case simply display a text message saying “Please login to post feedback”.

This is how the post feedback feature has been implemented in SUSI.AI Android App.

Resources

  • TextInputLayout | Android Developers
    https://developer.android.com/reference/android/support/design/widget/TextInputLayout
  • Styling Buttons | Android Developers
    https://developer.android.com/guide/topics/ui/controls/button#Style
Continue ReadingPost feedback for SUSI Skills in SUSI.AI Android App
  • FOSSASIA
  • Blog
  • GitHub
  • Projects
  • Code of Conduct
  • About
  • Contact
Copyright - OceanWP Theme by OceanWP
 

Loading Comments...
 

You must be logged in to post a comment.