Skip to content

Commit bd720ea

Browse files
committed
Merge pull request #2 from brianjmiller/master
Initial Implementation
2 parents 34da6b2 + 86dba13 commit bd720ea

54 files changed

Lines changed: 3750 additions & 3 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,10 @@ Generated_Code #added for RIA/Silverlight projects
106106
_UpgradeReport_Files/
107107
Backup*/
108108
UpgradeLog*.XML
109+
110+
#Ignore generated nupkg files
111+
*.nupkg
112+
113+
.DS_Store
114+
*.swp
115+
tmp/

README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
TinCanCSharp
2-
============
1+
A C#/.NET library for implementing Tin Can API.
32

4-
C#/.NET library for Tin Can API
3+
For hosted API documentation, basic usage instructions, supported version listing, etc. visit the main project website at:
4+
5+
http://rusticisoftware.github.io/TinCan.NET/
6+
7+
For more information about the Tin Can API visit:
8+
9+
http://tincanapi.com/
10+
11+
Requires .NET 3.5 or later.
12+
13+
### Installation
14+
15+
Available via NuGet.

RELEASE.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Make sure that the `TinCan/Properties/AssemblyInfo.cs` has been updated with new release version.
2+
3+
TinCan -> Properties -> Assembly Information
4+
5+
Then set the Build Configuration to "Release" and build the solution. (Verify `bin/Release/TinCan.dll` has correct version.)
6+
7+
With `nuget.exe` installed and in your path do:
8+
9+
cd TinCan
10+
nuget pack TinCan.csproj -sym -Prop Configuration=Release
11+
nuget push TinCan.(version).nupkg
12+
13+
Commit the updated assembly information file and push to master. Upload the generated `TinCan.(version).nupkg` as a GitHub tag release.

TinCan.sln

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2012
4+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TinCan", "TinCan\TinCan.csproj", "{27D0FCA1-E869-440C-9D16-F62D7A068C53}"
5+
EndProject
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TinCanTests", "TinCanTests\TinCanTests.csproj", "{854413C2-2F81-4A82-9949-DE2868A10078}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{27D0FCA1-E869-440C-9D16-F62D7A068C53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{27D0FCA1-E869-440C-9D16-F62D7A068C53}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{27D0FCA1-E869-440C-9D16-F62D7A068C53}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{27D0FCA1-E869-440C-9D16-F62D7A068C53}.Release|Any CPU.Build.0 = Release|Any CPU
18+
{854413C2-2F81-4A82-9949-DE2868A10078}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+
{854413C2-2F81-4A82-9949-DE2868A10078}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+
{854413C2-2F81-4A82-9949-DE2868A10078}.Release|Any CPU.ActiveCfg = Release|Any CPU
21+
{854413C2-2F81-4A82-9949-DE2868A10078}.Release|Any CPU.Build.0 = Release|Any CPU
22+
EndGlobalSection
23+
GlobalSection(SolutionProperties) = preSolution
24+
HideSolutionNode = FALSE
25+
EndGlobalSection
26+
EndGlobal

TinCan/About.cs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
Copyright 2014 Rustici Software
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
using System;
17+
using System.Collections.Generic;
18+
using Newtonsoft.Json.Linq;
19+
using TinCan.Json;
20+
21+
namespace TinCan
22+
{
23+
public class About : JsonModel
24+
{
25+
public List<TCAPIVersion> version { get; set; }
26+
public Extensions extensions { get; set; }
27+
28+
public About(String str) : this(new StringOfJSON(str)) {}
29+
public About(StringOfJSON json) : this(json.toJObject()) {}
30+
31+
public About(JObject jobj)
32+
{
33+
if (jobj["version"] != null)
34+
{
35+
version = new List<TCAPIVersion>();
36+
foreach (String item in jobj.Value<JArray>("version"))
37+
{
38+
version.Add((TCAPIVersion)item);
39+
}
40+
}
41+
if (jobj["extensions"] != null)
42+
{
43+
extensions = new Extensions(jobj.Value<JObject>("extensions"));
44+
}
45+
}
46+
47+
public override JObject ToJObject(TCAPIVersion version) {
48+
JObject result = new JObject();
49+
if (version != null)
50+
{
51+
var versions = new JArray();
52+
foreach (var v in this.version) {
53+
versions.Add(v.ToString());
54+
}
55+
result.Add("version", versions);
56+
}
57+
58+
if (extensions != null && ! extensions.isEmpty())
59+
{
60+
result.Add("extensions", extensions.ToJObject(version));
61+
}
62+
63+
return result;
64+
}
65+
}
66+
}

TinCan/Activity.cs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
Copyright 2014 Rustici Software
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
using System;
17+
using Newtonsoft.Json.Linq;
18+
using TinCan.Json;
19+
20+
namespace TinCan
21+
{
22+
public class Activity : JsonModel, StatementTarget
23+
{
24+
public static readonly String OBJECT_TYPE = "Activity";
25+
public String ObjectType { get { return OBJECT_TYPE; } }
26+
27+
public Uri id { get; set; }
28+
public ActivityDefinition definition { get; set; }
29+
30+
public Activity() { }
31+
32+
public Activity(StringOfJSON json) : this(json.toJObject()) { }
33+
34+
public Activity(JObject jobj)
35+
{
36+
if (jobj["id"] != null)
37+
{
38+
id = new Uri(jobj.Value<String>("id"));
39+
}
40+
if (jobj["definition"] != null)
41+
{
42+
definition = (ActivityDefinition)jobj.Value<JObject>("definition");
43+
}
44+
}
45+
46+
public override JObject ToJObject(TCAPIVersion version)
47+
{
48+
JObject result = new JObject();
49+
result.Add("objectType", ObjectType);
50+
51+
if (id != null)
52+
{
53+
result.Add("id", id.ToString());
54+
}
55+
if (definition != null)
56+
{
57+
result.Add("definition", definition.ToJObject(version));
58+
}
59+
60+
return result;
61+
}
62+
63+
public static explicit operator Activity(JObject jobj)
64+
{
65+
return new Activity(jobj);
66+
}
67+
}
68+
}

TinCan/ActivityDefinition.cs

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/*
2+
Copyright 2014 Rustici Software
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
using System;
17+
using Newtonsoft.Json.Linq;
18+
using TinCan.Json;
19+
20+
namespace TinCan
21+
{
22+
public class ActivityDefinition : JsonModel
23+
{
24+
public Uri type { get; set; }
25+
public Uri moreInfo { get; set; }
26+
public LanguageMap name { get; set; }
27+
public LanguageMap description { get; set; }
28+
public Extensions extensions { get; set; }
29+
//public InteractionType interactionType { get; set; }
30+
//public List<String> correctResponsesPattern { get; set; }
31+
//public List<InteractionComponent> choices { get; set; }
32+
//public List<InteractionComponent> scale { get; set; }
33+
//public List<InteractionComponent> source { get; set; }
34+
//public List<InteractionComponent> target { get; set; }
35+
//public List<InteractionComponent> steps { get; set; }
36+
37+
public ActivityDefinition() {}
38+
39+
public ActivityDefinition(StringOfJSON json): this(json.toJObject()) {}
40+
41+
public ActivityDefinition(JObject jobj)
42+
{
43+
if (jobj["type"] != null)
44+
{
45+
type = new Uri(jobj.Value<String>("type"));
46+
}
47+
if (jobj["moreInfo"] != null)
48+
{
49+
moreInfo = new Uri(jobj.Value<String>("moreInfo"));
50+
}
51+
if (jobj["name"] != null)
52+
{
53+
name = (LanguageMap)jobj.Value<JObject>("name");
54+
}
55+
if (jobj["description"] != null)
56+
{
57+
description = (LanguageMap)jobj.Value<JObject>("description");
58+
}
59+
if (jobj["extensions"] != null)
60+
{
61+
extensions = (Extensions)jobj.Value<JObject>("extensions");
62+
}
63+
}
64+
65+
public override JObject ToJObject(TCAPIVersion version) {
66+
JObject result = new JObject();
67+
68+
if (type != null)
69+
{
70+
result.Add("type", type.ToString());
71+
}
72+
if (moreInfo != null)
73+
{
74+
result.Add("moreInfo", moreInfo.ToString());
75+
}
76+
if (name != null && ! name.isEmpty())
77+
{
78+
result.Add("name", name.ToJObject(version));
79+
}
80+
if (description != null && ! description.isEmpty())
81+
{
82+
result.Add("description", description.ToJObject(version));
83+
}
84+
if (extensions != null && ! extensions.isEmpty())
85+
{
86+
result.Add("extensions", extensions.ToJObject(version));
87+
}
88+
89+
return result;
90+
}
91+
92+
public static explicit operator ActivityDefinition(JObject jobj)
93+
{
94+
return new ActivityDefinition(jobj);
95+
}
96+
}
97+
}

0 commit comments

Comments
 (0)