-
Notifications
You must be signed in to change notification settings - Fork 22
/
RegistrationData.cs
262 lines (212 loc) · 8.11 KB
/
RegistrationData.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
/* Software License Agreement (BSD License)
*
* Copyright (c) 2010-2011, Rustici Software, LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL Rustici Software, LLC BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Xml;
namespace RusticiSoftware.HostedEngine.Client
{
/// <summary>
/// Data class to hold high-level Registration Data
/// </summary>
public class RegistrationData
{
private string _registrationId;
private string _courseId;
private string _courseTitle;
private string _lastCourseVersionLaunched;
private string _learnerId;
private string _learnerFirstName;
private string _learnerLastName;
private string _email;
private DateTime _createDate;
private DateTime? _firstAccessDate;
private DateTime? _lastAccessDate;
private DateTime? _completedDate;
private List<InstanceData> _instances;
/// <summary>
/// Constructor which takes an XML node as returned by the web service.
/// </summary>
/// <param name="regDataEl"></param>
public RegistrationData(XmlElement registrationElem)
{
this.RegistrationId = registrationElem.Attributes["id"].Value;
this.CourseId = registrationElem.Attributes["courseid"].Value;
this.CourseTitle = ((XmlElement)registrationElem
.GetElementsByTagName("courseTitle")[0])
.InnerText;
this.LastCourseVersionLaunched = ((XmlElement)registrationElem
.GetElementsByTagName("lastCourseVersionLaunched")[0])
.InnerText;
this.LearnerId = ((XmlElement)registrationElem
.GetElementsByTagName("learnerId")[0])
.InnerText;
this.LearnerFirstName = ((XmlElement)registrationElem
.GetElementsByTagName("learnerFirstName")[0])
.InnerText;
this.LearnerLastName = ((XmlElement)registrationElem
.GetElementsByTagName("learnerLastName")[0])
.InnerText;
this.Email = ((XmlElement)registrationElem
.GetElementsByTagName("email")[0])
.InnerText;
this.CreateDate = DateTime.Parse(((XmlElement)registrationElem
.GetElementsByTagName("createDate")[0])
.InnerText);
this.FirstAccessDate = Utils.ParseNullableDate(((XmlElement)registrationElem
.GetElementsByTagName("firstAccessDate")[0])
.InnerText);
this.LastAccessDate = Utils.ParseNullableDate(((XmlElement)registrationElem
.GetElementsByTagName("lastAccessDate")[0])
.InnerText);
this.CompletedDate = Utils.ParseNullableDate(((XmlElement)registrationElem
.GetElementsByTagName("completedDate")[0])
.InnerText);
this.Instances = InstanceData.ConvertToInstanceDataList((XmlElement)registrationElem.GetElementsByTagName("instances")[0]);
}
/// <summary>
/// Helper method which takes the full XmlDocument as returned from the registration listing
/// web service and returns a List of RegistrationData objects.
/// </summary>
/// <param name="xmlDoc"></param>
/// <returns></returns>
public static List<RegistrationData> ConvertToRegistrationDataList(XmlDocument xmlDoc)
{
List<RegistrationData> allResults = new List<RegistrationData>();
XmlNodeList regDataList = xmlDoc.GetElementsByTagName("registration");
foreach (XmlElement regData in regDataList)
{
allResults.Add(new RegistrationData(regData));
}
return allResults;
}
/// <summary>
/// Unique Identifier for this registration
/// </summary>
public string RegistrationId
{
get { return _registrationId; }
private set { _registrationId = value; }
}
/// <summary>
/// Course Identifier as specified at import-time
/// </summary>
public string CourseId
{
get { return _courseId; }
private set { _courseId = value; }
}
/// <summary>
/// The title of this course
/// </summary>
public string CourseTitle
{
get { return _courseTitle; }
private set { _courseTitle = value; }
}
/// <summary>
/// The last version of the course that was launched
/// </summary>
public string LastCourseVersionLaunched
{
get { return _lastCourseVersionLaunched; }
private set { _lastCourseVersionLaunched = value; }
}
/// <summary>
/// Learner Identifier as specified at import-time
/// </summary>
public string LearnerId
{
get { return _learnerId; }
private set { _learnerId = value; }
}
/// <summary>
/// Learner First Name as specified at import-time
/// </summary>
public string LearnerFirstName
{
get { return _learnerFirstName; }
private set { _learnerFirstName = value; }
}
/// <summary>
/// Learner Last Name as specified at import-time
/// </summary>
public string LearnerLastName
{
get { return _learnerLastName; }
private set { _learnerLastName = value; }
}
/// <summary>
/// Learner Email as specified at import-time
/// </summary>
public string Email
{
get { return _email; }
private set { _email = value; }
}
/// <summary>
/// Date in which the registration was created
/// </summary>
public DateTime CreateDate
{
get { return _createDate; }
private set { _createDate = value; }
}
/// <summary>
/// Date in which the registration was first accessed
/// </summary>
public DateTime? FirstAccessDate
{
get { return _firstAccessDate; }
private set { _firstAccessDate = value; }
}
/// <summary>
/// Date in which the registration was last accessed
/// </summary>
public DateTime? LastAccessDate
{
get { return _lastAccessDate; }
private set { _lastAccessDate = value; }
}
/// <summary>
/// Date in which the registration was completed
/// </summary>
public DateTime? CompletedDate
{
get { return _completedDate; }
private set { _completedDate = value; }
}
/// <summary>
/// List of Verions/Instances available for this course
/// </summary>
public List<InstanceData> Instances
{
get { return _instances; }
private set { _instances = value; }
}
}
}