Hi Matteo,
Sorry for the late reply. I was doing some further testing.
For URLs
This is what I got from Moodle:
?aicc_sid=zJLkaTWXpfOPN65BQy44&aicc_url=http://127.0.0.1:3010/mod/scorm/aicc.php&LEARNING_APP_TYPE=LEARNING&WINDOW_STYLE=OWN_WINDOW
This is what I sent to Moodle
%5BCore%5D%0D%0ALesson_Location%3D%0D%0ALesson_Status%3DC%0D%0AScore%3D100%0D%0ATime%3D0000%3A00%3A50%0D%0A%5BComments%5D%0D%0A%0D%0A%5BObjectives_Status%5D%0D%0A%0D%0A%5BStudent_Preferences%5D%0D%0AAudio%3D0%0D%0ALanguage%3D%0D%0ASpeed%3D100%0D%0AText%3D0%0D%0A%5BCore_Lesson%5D%0D%0A2p36607080on1001211f010110111101211w101%5En6cwRYys1ziX.6XR74bD0ClH1%5E1%5E0%7E2f2q039Cag34003400340034000000%7E2K1ed101002g12g1123u_0Q3400340034009490o0s1g09490o000e0f79030o0K0f0111%5E3400yw2Lhq340034003400340097w020111%5E000000002100
The following is my sample code:
public void Post(String req)
{
String message = req.ToString();
Int32 I_AICC_SID = message.IndexOf("aicc_sid");
Int32 I_AICC_URL = message.IndexOf("aicc_url");
Int32 N_AICC_SID_LEN = message.IndexOf('&', I_AICC_SID) - I_AICC_SID - 9;
Int32 N_AICC_URL_LEN = message.IndexOf('&', I_AICC_URL) - I_AICC_URL - 9;
String AICC_SID = message.Substring(I_AICC_SID + 9, N_AICC_SID_LEN);
String AICC_URL = message.Substring(I_AICC_URL + 9, N_AICC_URL_LEN);
// Setup GetParam
var client = new HttpClient();
var values = new Dictionary<string, string>
{
{ "command", "getparam" },
{ "version", "3.5" },
{ "session_id", AICC_SID }
};
var content = new FormUrlEncodedContent(values);
var response = client.PostAsync(AICC_URL, content).Result;
var responseString = response.Content.ReadAsStringAsync().Result;
// Setup PutParam
var PutParam_values = new Dictionary<string, string>
{
{ "command", "putparam" },
{ "version", "3.5" },
{ "session_id", AICC_SID },
{ "aicc_data", "%5BCore%5D%0D%0ALesson_Location%3D%0D%0ALesson_Status%3DC%0D%0AScore%3D100%0D%0ATime%3D0000%3A00%3A50%0D%0A%5BComments%5D%0D%0A%0D%0A%5BObjectives_Status%5D%0D%0A%0D%0A%5BStudent_Preferences%5D%0D%0AAudio%3D0%0D%0ALanguage%3D%0D%0ASpeed%3D100%0D%0AText%3D0%0D%0A%5BCore_Lesson%5D%0D%0A2p36607080on1001211f010110111101211w101%5En6cwRYys1ziX.6XR74bD0ClH1%5E1%5E0%7E2f2q039Cag34003400340034000000%7E2K1ed101002g12g1123u_0Q3400340034009490o0s1g09490o000e0f79030o0K0f0111%5E3400yw2Lhq340034003400340097w020111%5E000000002100"}
};
var PutParam_content = new FormUrlEncodedContent(PutParam_values);
var PutParam_response = client.PostAsync(AICC_URL, PutParam_content).Result;
var PutParam_responseString = PutParam_response.Content.ReadAsStringAsync().Result;
// Setup ExitAU
var ExitAU_values = new Dictionary<string, string>
{
{ "command", "exitau" },
{ "version", "3.5" },
{ "session_id", AICC_SID },
};
var ExitAU_content = new FormUrlEncodedContent(ExitAU_values);
var ExitAU_response = client.PostAsync(AICC_URL, ExitAU_content).Result;
var ExitAU_responseString = ExitAU_response.Content.ReadAsStringAsync().Result;
}
I agree that I should not add extra "decode" in the source code, but that was the only way I could make it work. Am I missing some steps?
Thanks!
Jack