-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Aggiunto scaricamento e passaggio domande a question tramite coda e s…
…eparata classe questionnairelist
- Loading branch information
1 parent
9105a1c
commit d94baa1
Showing
12 changed files
with
268 additions
and
160 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
app/src/main/java/com/example/raffaele/testapp/QueryList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package com.example.raffaele.testapp; | ||
|
||
import android.os.Parcel; | ||
import android.os.Parcelable; | ||
import android.util.Log; | ||
|
||
import org.json.JSONArray; | ||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
|
||
import java.util.LinkedList; | ||
|
||
/** | ||
* Created by K12-Dev-Team on 29/04/2015. | ||
*/ | ||
public class QueryList extends LinkedList<Query> implements Parcelable { | ||
private final String url = "https://k12-api.mybluemix.net/api/questionnaire/view"; //Url di connessione al backend | ||
public static final Parcelable.Creator<QueryList> CREATOR= new Parcelable.Creator<QueryList>(){ //creatore dell'argumentlist | ||
@Override | ||
public QueryList createFromParcel(Parcel in){ | ||
return new QueryList(in); | ||
} | ||
|
||
@Override | ||
public QueryList[] newArray(int size) {return new QueryList[0]; | ||
} | ||
}; | ||
private String idquiz; | ||
|
||
public QueryList(String idquiz){ | ||
this.idquiz=idquiz; | ||
} | ||
public void getHTTP(String token) throws NullPointerException { | ||
this.clear(); //pulisce la lista per sicurezza | ||
HTMLRequest htmlRequest =new HTMLRequest(url, "access_token=" + token+"&id="+idquiz); //richiesta con token | ||
String result=htmlRequest.getHTMLThread(); | ||
Log.d("QueryList", idquiz); //loggo per scopi di debug | ||
Log.d("TeacherQuestionresult", result); | ||
try{ | ||
JSONObject jo= new JSONObject(result); //elaboro l'array di json e aggiungo gli elementi alla lista | ||
if(jo.has("success")&&!jo.getBoolean("success")){ | ||
throw new NullPointerException("QuizNull"); | ||
} | ||
JSONArray ja=jo.getJSONArray("questions"); | ||
for(int i=0;i<ja.length();i++){ | ||
jo=ja.getJSONObject(i); | ||
this.add(new Query(jo.getString("id"), jo.getString("body"), jo.getString("answer"), jo.getString("fakeAnswer1"), jo.getString("fakeAnswer2"), jo.getString("fakeAnswer3"), jo.getString("topic"))); | ||
} | ||
} catch (JSONException e) { | ||
throw new NullPointerException("QuizNull"); | ||
} | ||
} | ||
/** | ||
* @param in Parcel di ingresso | ||
*/ | ||
private QueryList(Parcel in){ | ||
readFromParcel(in); | ||
} //Costruttore della parceable | ||
|
||
/** | ||
* @param in Parcel di ingresso | ||
*/ | ||
public void readFromParcel(Parcel in){ | ||
this.clear(); //pulisce la lista per sicurezza | ||
in.readList(this,QueryList.class.getClassLoader()); //riempie la lista con gli elementi dal parceable | ||
} | ||
|
||
@Override | ||
public int describeContents() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public void writeToParcel(Parcel dest, int flags) { | ||
dest.writeList(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 15 additions & 13 deletions
28
app/src/main/java/com/example/raffaele/testapp/Questionnaire.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,31 @@ | ||
package com.example.raffaele.testapp; | ||
|
||
/** | ||
* Created by Muscetti on 25/04/2015. | ||
* Created by K12-Dev-Team on 25/04/2015. | ||
*/ | ||
public class Questionnaire { | ||
private String Name; | ||
private String Description; | ||
|
||
public String getName() { | ||
return Name; | ||
private String id; | ||
private String name; | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setName(String name) { | ||
Name = name; | ||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
public String getDescription() { | ||
return Description; | ||
public String getname() { | ||
return name; | ||
} | ||
|
||
public void setDescription(String description) { | ||
Description = description; | ||
public void setname(String name) { | ||
this.name = name; | ||
} | ||
|
||
public Questionnaire(String name) { | ||
Name = name; | ||
public Questionnaire(String id,String name) { | ||
this.name = name; | ||
this.id=id; | ||
} | ||
} |
Oops, something went wrong.