sakai-info 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +9 -0
- data/README.md +34 -3
- data/ROADMAP.md +4 -4
- data/lib/sakai-info/assignment.rb +2 -2
- data/lib/sakai-info/database.rb +52 -4
- data/lib/sakai-info/quiz.rb +20 -2
- data/lib/sakai-info/user.rb +23 -10
- data/lib/sakai-info/version.rb +1 -1
- metadata +50 -64
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# sakai-info Change History #
|
2
2
|
|
3
|
+
### 0.4.2 ###
|
4
|
+
|
5
|
+
*Released 2012-05-04*
|
6
|
+
|
7
|
+
* Fixed issue in assignment-submission for formatting entity dates
|
8
|
+
* Added status property to quizzes along with interpretation of the value
|
9
|
+
* Added support for provided users to User object (submitted by Will Humphries)
|
10
|
+
* Allowed .sakai-info file to point to another location for configuration
|
11
|
+
|
3
12
|
### 0.4.1 ###
|
4
13
|
|
5
14
|
*Released 2012-04-22*
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# sakai-info #
|
2
2
|
|
3
|
-
last updated: 2012-04
|
3
|
+
last updated: 2012-05-04
|
4
4
|
author: David Adams (daveadams@gmail.com)
|
5
5
|
github url: https://github.com/daveadams/sakai-info
|
6
6
|
|
@@ -24,7 +24,7 @@ Use `rake` to test and build the gem:
|
|
24
24
|
$ rake gem:build
|
25
25
|
|
26
26
|
The resulting gem will be saved to the working directory as
|
27
|
-
`sakai-info-0.4.
|
27
|
+
`sakai-info-0.4.2.gem`.
|
28
28
|
|
29
29
|
Cleanup built gems using:
|
30
30
|
|
@@ -53,6 +53,9 @@ Oracle support requires the `ruby-oci8` gem, and MySQL support requires the
|
|
53
53
|
MySQL support is now working. Your MySQL server must have the setting
|
54
54
|
`lower_case_table_names=1` or be running on a case-insensitive filesystem.
|
55
55
|
|
56
|
+
I recommend you use the `mysql2` gem, which is faster than the `mysql` or
|
57
|
+
`ruby-mysql` gems and is also much better tested.
|
58
|
+
|
56
59
|
## Configuration ##
|
57
60
|
|
58
61
|
To run, *sakai-info* needs to be able to connect to your Sakai database server.
|
@@ -63,7 +66,23 @@ In this release, *sakai-info* expects a to find the config in a file located at
|
|
63
66
|
more Sakai database connection nicknames and connection strings, for example:
|
64
67
|
|
65
68
|
prod: oracle://sakai:password@SAKAIPROD
|
66
|
-
test:
|
69
|
+
test: mysql2://test:password@mysql-host/db_name
|
70
|
+
local: mysql2://sakai:ironchef@localhost/db_name
|
71
|
+
|
72
|
+
For connections requiring options not well-supported by URI strings,
|
73
|
+
i.e. passwords with special characters, or non-default schemas,
|
74
|
+
all options can be specified one their own line, eg:
|
75
|
+
|
76
|
+
lmssbx:
|
77
|
+
adapter: oracle
|
78
|
+
user: user
|
79
|
+
password: pas^w#?d
|
80
|
+
host: db_name
|
81
|
+
after_connect: ALTER SESSION SET CURRENT_SCHEMA=sakai
|
82
|
+
|
83
|
+
Some connections may require a query be run immediately after connecting, i.e.
|
84
|
+
to select a default schema. Sequel supports this through the after_connect
|
85
|
+
option. To provide a query for after_connect, include it as shown above.
|
67
86
|
|
68
87
|
The first connection in the list is the default connection. Other connections
|
69
88
|
may be specified using the corresponding YAML key, which functions as a
|
@@ -71,6 +90,12 @@ nickname for the connection.
|
|
71
90
|
|
72
91
|
[More information on how to specify a Sequel connection string.](http://sequel.rubyforge.org/rdoc/files/doc/opening_databases_rdoc.html)
|
73
92
|
|
93
|
+
As an alternative, may specify an alternate file name by putting an `@` sign
|
94
|
+
followed by the filename to load the config from on the first line of
|
95
|
+
the config file specified, eg:
|
96
|
+
|
97
|
+
@/etc/sakai-info/shared.conf
|
98
|
+
|
74
99
|
## Command Line Usage ##
|
75
100
|
|
76
101
|
After installing the gem, the `sin` program should be found in your PATH. For
|
@@ -105,3 +130,9 @@ See ROADMAP.md
|
|
105
130
|
This work is dedicated to the public domain. No rights are reserved. See
|
106
131
|
LICENSE for more information.
|
107
132
|
|
133
|
+
## Contributors ##
|
134
|
+
|
135
|
+
The following individuals have contributed code to this project:
|
136
|
+
|
137
|
+
* David Adams <daveadams@gmail.com>
|
138
|
+
* Will Humphries <will.d.humphries@gmail.com>
|
data/ROADMAP.md
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
# sakai-info Roadmap #
|
2
2
|
|
3
|
-
*Last updated 2012-04
|
3
|
+
*Last updated 2012-05-04*
|
4
4
|
|
5
|
-
### 0.4.
|
5
|
+
### 0.4.3 ###
|
6
6
|
|
7
7
|
* CLI access to announcements
|
8
8
|
|
9
|
-
### 0.4.
|
9
|
+
### 0.4.4 ###
|
10
10
|
|
11
11
|
* CLI access to gradebook
|
12
12
|
|
13
|
-
### 0.4.
|
13
|
+
### 0.4.5 ###
|
14
14
|
|
15
15
|
* CLI access to authz (realms, roles, functions)
|
16
16
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# SakaiInfo::Assignment library
|
3
3
|
#
|
4
4
|
# Created 2012-02-17 daveadams@gmail.com
|
5
|
-
# Last updated 2012-02
|
5
|
+
# Last updated 2012-05-02 daveadams@gmail.com
|
6
6
|
#
|
7
7
|
# https://github.com/daveadams/sakai-info
|
8
8
|
#
|
@@ -137,7 +137,7 @@ module SakaiInfo
|
|
137
137
|
end
|
138
138
|
|
139
139
|
def submitted_at
|
140
|
-
@submitted_at ||= format_entity_date(@attributes["datesubmitted"])
|
140
|
+
@submitted_at ||= Util.format_entity_date(@attributes["datesubmitted"])
|
141
141
|
end
|
142
142
|
|
143
143
|
def self.query_by_assignment_id(assignment_id)
|
data/lib/sakai-info/database.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# SakaiInfo::Database library
|
3
3
|
#
|
4
4
|
# Created 2012-02-19 daveadams@gmail.com
|
5
|
-
# Last updated 2012-
|
5
|
+
# Last updated 2012-05-04 daveadams@gmail.com
|
6
6
|
#
|
7
7
|
# https://github.com/daveadams/sakai-info
|
8
8
|
#
|
@@ -17,10 +17,31 @@
|
|
17
17
|
# test: oracle://user:pass@sid/schema_name
|
18
18
|
# dev: mysql://user:pass@hostname/db_name
|
19
19
|
#
|
20
|
+
# For connections requiring options not well-supported by URI strings,
|
21
|
+
# i.e. passwords with special characters, or non-default schemas,
|
22
|
+
# all options can be specified one their own line, eg:
|
23
|
+
#
|
24
|
+
# lmssbx:
|
25
|
+
# adapter: oracle
|
26
|
+
# user: user
|
27
|
+
# password: pas^w#?d
|
28
|
+
# host: db_name
|
29
|
+
# after_connect: ALTER SESSION SET CURRENT_SCHEMA=sakai
|
30
|
+
#
|
31
|
+
# Some connections may require a query be run immediately after connecting, i.e.
|
32
|
+
# to select a default schema. Sequel supports this through the after_connect
|
33
|
+
# option. To provide a query for after_connect, include it as shown above.
|
34
|
+
#
|
20
35
|
# The default connection is the first one in the file.
|
21
36
|
# For more on Sequel connection strings, see:
|
22
37
|
# http://sequel.rubyforge.org/rdoc/files/doc/opening_databases_rdoc.html
|
23
38
|
#
|
39
|
+
# As an alternative, may specify an alternate file name by putting an @ sign
|
40
|
+
# followed by the filename to load the config from on the first line of
|
41
|
+
# the config file specified, eg:
|
42
|
+
#
|
43
|
+
# @/etc/sakai-info/shared.conf
|
44
|
+
#
|
24
45
|
|
25
46
|
# using the oci8 driver will complain if NLS_LANG is not set in the environment
|
26
47
|
ENV["NLS_LANG"] ||= "AMERICAN_AMERICA.UTF8"
|
@@ -40,8 +61,35 @@ module SakaiInfo
|
|
40
61
|
@@config = config
|
41
62
|
elsif config.is_a? String and File.exist?(config)
|
42
63
|
# try to parse as a filename first
|
64
|
+
# first check to see if it points to a different config file
|
65
|
+
File.open(config) do |f|
|
66
|
+
first_line = f.readlines[0].chomp
|
67
|
+
if first_line =~ /^@(.+)$/
|
68
|
+
# use the rest of the line as an alternate filename
|
69
|
+
config = $1
|
70
|
+
end
|
71
|
+
end
|
43
72
|
if File.exist?(config)
|
44
73
|
@@config = YAML::load_file(config)
|
74
|
+
# loop through each connection, symbolicize keys in options hashes
|
75
|
+
@@config.each do |name,connect_info|
|
76
|
+
if connect_info.is_a?(Hash)
|
77
|
+
conn = {}
|
78
|
+
connect_info.each do |option,value|
|
79
|
+
osym=option.to_sym
|
80
|
+
# If a query is needed after connection, store it in a procedure
|
81
|
+
# See: http://sequel.rubyforge.org/rdoc/files/doc/release_notes/3_11_0_txt.html
|
82
|
+
if option=="after_connect"
|
83
|
+
conn[osym]=proc{|c| c.exec(value)}
|
84
|
+
else
|
85
|
+
conn[osym]=value
|
86
|
+
end
|
87
|
+
end
|
88
|
+
@@config[name]=conn
|
89
|
+
end
|
90
|
+
end
|
91
|
+
else
|
92
|
+
raise "No such file '#{config}'"
|
45
93
|
end
|
46
94
|
else
|
47
95
|
# otherwise try to parse it generically
|
@@ -105,8 +153,8 @@ module SakaiInfo
|
|
105
153
|
end
|
106
154
|
|
107
155
|
class Database
|
108
|
-
def initialize(
|
109
|
-
@
|
156
|
+
def initialize(connect_info, logger = nil)
|
157
|
+
@connect_info=connect_info
|
110
158
|
@logger = logger
|
111
159
|
end
|
112
160
|
|
@@ -116,7 +164,7 @@ module SakaiInfo
|
|
116
164
|
end
|
117
165
|
|
118
166
|
begin
|
119
|
-
@connection = Sequel.connect(@
|
167
|
+
@connection = Sequel.connect(@connect_info)
|
120
168
|
rescue => e
|
121
169
|
@connection = nil
|
122
170
|
raise ConnectionFailureException.new("Could not connect: #{e}")
|
data/lib/sakai-info/quiz.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# SakaiInfo::Quiz library
|
3
3
|
#
|
4
4
|
# Created 2012-02-17 daveadams@gmail.com
|
5
|
-
# Last updated 2012-
|
5
|
+
# Last updated 2012-05-03 daveadams@gmail.com
|
6
6
|
#
|
7
7
|
# https://github.com/daveadams/sakai-info
|
8
8
|
#
|
@@ -93,6 +93,21 @@ module SakaiInfo
|
|
93
93
|
nil
|
94
94
|
end
|
95
95
|
|
96
|
+
# possible statuses
|
97
|
+
INACTIVE = 0
|
98
|
+
ACTIVE = 1
|
99
|
+
DELETED = 2 # aka 'DEAD' in the Scholar source
|
100
|
+
RETRACTED_FOR_EDITING = 3
|
101
|
+
def status
|
102
|
+
case @dbrow[:status].to_i
|
103
|
+
when INACTIVE then "inactive"
|
104
|
+
when ACTIVE then "active"
|
105
|
+
when DELETED then "deleted"
|
106
|
+
when RETRACTED_FOR_EDITING then "retracted for editing"
|
107
|
+
else "unknown status '#{@dbrow[:status].to_i}'"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
96
111
|
def section_count
|
97
112
|
@section_count ||= QuizSection.count_by_quiz_id(@id)
|
98
113
|
end
|
@@ -106,6 +121,7 @@ module SakaiInfo
|
|
106
121
|
"id" => self.id,
|
107
122
|
"title" => self.title,
|
108
123
|
"site" => nil,
|
124
|
+
"status" => self.status,
|
109
125
|
"type" => self.quiz_type,
|
110
126
|
"section_count" => self.section_count,
|
111
127
|
"attempt_count" => nil
|
@@ -126,6 +142,7 @@ module SakaiInfo
|
|
126
142
|
"id" => self.id,
|
127
143
|
"title" => self.title,
|
128
144
|
"site_id" => nil,
|
145
|
+
"status" => self.status,
|
129
146
|
"type" => self.quiz_type
|
130
147
|
}
|
131
148
|
if not self.site.nil?
|
@@ -137,7 +154,8 @@ module SakaiInfo
|
|
137
154
|
def site_summary_serialization
|
138
155
|
{
|
139
156
|
"id" => self.id,
|
140
|
-
"title" => self.title
|
157
|
+
"title" => self.title,
|
158
|
+
"status" => self.status,
|
141
159
|
}
|
142
160
|
end
|
143
161
|
|
data/lib/sakai-info/user.rb
CHANGED
@@ -30,9 +30,12 @@ module SakaiInfo
|
|
30
30
|
|
31
31
|
row = DB.connect[:sakai_user].where(:user_id => user_id).first
|
32
32
|
if row.nil?
|
33
|
-
|
33
|
+
#Has sakai_user_id_map record, but not sakai_user record. Provided account!
|
34
|
+
#raise ObjectNotFoundException.new(User, id)
|
35
|
+
@@cache[eid] = @@cache[user_id] = User.new(user_id,'Provided')
|
36
|
+
else
|
37
|
+
@@cache[eid] = @@cache[user_id] = User.new(row)
|
34
38
|
end
|
35
|
-
@@cache[eid] = @@cache[user_id] = User.new(row)
|
36
39
|
end
|
37
40
|
@@cache[id]
|
38
41
|
end
|
@@ -59,14 +62,24 @@ module SakaiInfo
|
|
59
62
|
end
|
60
63
|
end
|
61
64
|
|
62
|
-
def initialize(
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
65
|
+
def initialize(*args)
|
66
|
+
case args.size
|
67
|
+
when 1
|
68
|
+
dbrow = args[0]
|
69
|
+
@dbrow = dbrow
|
70
|
+
@id = dbrow[:user_id]
|
71
|
+
@eid = User.get_eid(@id)
|
72
|
+
@email = dbrow[:email]
|
73
|
+
@name = ((dbrow[:first_name] || "") + " " + (dbrow[:last_name] || "")).strip
|
74
|
+
@type = dbrow[:type]
|
75
|
+
when 2
|
76
|
+
user_id, placeholder_string = args
|
77
|
+
@id = user_id
|
78
|
+
@eid=User.get_eid(@id)
|
79
|
+
@email = @name = @type = placeholder_string
|
80
|
+
else
|
81
|
+
raise ArgumentError, "This method takes 1-2 arguments"
|
82
|
+
end
|
70
83
|
end
|
71
84
|
|
72
85
|
def properties
|
data/lib/sakai-info/version.rb
CHANGED
metadata
CHANGED
@@ -1,60 +1,56 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: sakai-info
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 4
|
9
|
-
- 1
|
10
|
-
version: 0.4.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.2
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- David Adams
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-05-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: sequel
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
33
22
|
type: :runtime
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: sqlite3
|
37
23
|
prerelease: false
|
38
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
25
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: sqlite3
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
47
38
|
type: :development
|
48
|
-
|
49
|
-
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: A command line tool and a suite of libraries for representing the objects
|
47
|
+
and relationships defined by a Sakai CLE database.
|
50
48
|
email: daveadams@gmail.com
|
51
|
-
executables:
|
49
|
+
executables:
|
52
50
|
- sin
|
53
51
|
extensions: []
|
54
|
-
|
55
52
|
extra_rdoc_files: []
|
56
|
-
|
57
|
-
files:
|
53
|
+
files:
|
58
54
|
- lib/sakai-info.rb
|
59
55
|
- lib/sakai-info/group.rb
|
60
56
|
- lib/sakai-info/tool.rb
|
@@ -83,39 +79,29 @@ files:
|
|
83
79
|
- LICENSE
|
84
80
|
- CHANGELOG.md
|
85
81
|
- ROADMAP.md
|
86
|
-
has_rdoc: true
|
87
82
|
homepage: https://github.com/daveadams/sakai-info
|
88
|
-
licenses:
|
83
|
+
licenses:
|
89
84
|
- Public Domain
|
90
85
|
post_install_message:
|
91
86
|
rdoc_options: []
|
92
|
-
|
93
|
-
require_paths:
|
87
|
+
require_paths:
|
94
88
|
- lib
|
95
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
90
|
none: false
|
97
|
-
requirements:
|
98
|
-
- -
|
99
|
-
- !ruby/object:Gem::Version
|
100
|
-
|
101
|
-
|
102
|
-
- 0
|
103
|
-
version: "0"
|
104
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
96
|
none: false
|
106
|
-
requirements:
|
107
|
-
- -
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
|
110
|
-
segments:
|
111
|
-
- 0
|
112
|
-
version: "0"
|
97
|
+
requirements:
|
98
|
+
- - ! '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
113
101
|
requirements: []
|
114
|
-
|
115
102
|
rubyforge_project:
|
116
|
-
rubygems_version: 1.
|
103
|
+
rubygems_version: 1.8.23
|
117
104
|
signing_key:
|
118
105
|
specification_version: 3
|
119
106
|
summary: Tools and library for exploring a Sakai database
|
120
107
|
test_files: []
|
121
|
-
|