sakai-info 0.5.5 → 0.5.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4081d75a494513f659f2e400b39b19073941efd
4
- data.tar.gz: 0fec120b870358846426bf8e5f69480992e24d0a
3
+ metadata.gz: 9c1c362f4848aa264774fd24bd81df00291b3065
4
+ data.tar.gz: 9cf242a834d446eb1ed52762d75c9fa57239ad31
5
5
  SHA512:
6
- metadata.gz: b60724a90d944df64b7d89f7227ddaa21febb727b5e66bbddc9e2b088b46831bdccd9da8b8d7cbc91677606472f62bd4397126ddb944a30db669e48d785becde
7
- data.tar.gz: 63a192c81853a701021356aca37956625c2dd45879d1dffbc3241cbe04a37c5e52ddb8928598e1f714f548ddee5ee16290b6e50da1621494ebc540d818d5075e
6
+ metadata.gz: 2cf906ddf0b795735a9cb283666b101843427b89ecad5d7b0e4d3b1c4993e72a553627d85a8ce337fe9b30846cd3c41344fa2d65b37d9fcc7874c559c0118f20
7
+ data.tar.gz: 28a0fc85c2a4cc78483ed8c259663aab06e4b53ae48e439c5e3b43dd553bcecfa4b7dc55fd5675d7d638cc4c8fe916e4abba31dc5b2d58e763cd55ae9a04256e
@@ -1,8 +1,17 @@
1
1
  # sakai-info Change History #
2
2
 
3
+ ### 0.5.6 ###
4
+
5
+ *Released 2014-12-11*
6
+
7
+ * Added submitted date and elapsed time to quiz attempt serialization
8
+ * Added additional shortcut names for assignment and assignment-submission
9
+ * New object types: pending-quiz-metadata, published-quiz-metadata
10
+ * New object types: pending-quiz-authorization, published-quiz-authorization
11
+
3
12
  ### 0.5.5 ###
4
13
 
5
- *Released ????-??-??*
14
+ *Released 2014-07-08*
6
15
 
7
16
  * New object types: calendar and calendar-event
8
17
  * Added Site.find_all
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # sakai-info #
2
2
 
3
- last updated: 2013-06-28
3
+ last updated: 2014-12-11
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.5.5.gem`.
27
+ `sakai-info-0.5.6.gem`.
28
28
 
29
29
  Cleanup built gems using:
30
30
 
@@ -2,7 +2,7 @@
2
2
  # class for handling the default command line mode
3
3
  #
4
4
  # Created 2012-05-23 daveadams@gmail.com
5
- # Last updated 2012-10-31 daveadams@gmail.com
5
+ # Last updated 2014-09-16 daveadams@gmail.com
6
6
  #
7
7
  # https://github.com/daveadams/sakai-info
8
8
  #
@@ -99,6 +99,11 @@ module SakaiInfo
99
99
  "published-quiz-access-control" => PublishedQuizAccessControl,
100
100
  "nqac" => PendingQuizAccessControl,
101
101
  "pending-quiz-access-control" => PendingQuizAccessControl,
102
+ "pqm" => PublishedQuizMetadata,
103
+ "published-quiz-metadata" => PublishedQuizMetadata,
104
+ "nqm" => PendingQuizMetadata,
105
+ "pending-quiz-metadata" => PendingQuizMetadata,
106
+ "qauth" => QuizAuthorization,
102
107
  "qa" => QuizAttempt,
103
108
  "quiz-attempt" => QuizAttempt,
104
109
  "qai" => QuizAttemptItem,
@@ -109,9 +114,11 @@ module SakaiInfo
109
114
  "qpool" => QuestionPool,
110
115
  "question-pool" => QuestionPool,
111
116
  "a" => Assignment,
117
+ "asn" => Assignment,
112
118
  "assignment" => Assignment,
113
119
  "as" => AssignmentSubmission,
114
120
  "asub" => AssignmentSubmission,
121
+ "asnsub" => AssignmentSubmission,
115
122
  "assignment-submission" => AssignmentSubmission,
116
123
  "forum" => Forum,
117
124
  "ft" => ForumThread,
@@ -2,7 +2,7 @@
2
2
  # SakaiInfo::Quiz library
3
3
  #
4
4
  # Created 2012-02-17 daveadams@gmail.com
5
- # Last updated 2014-07-08 daveadams@gmail.com
5
+ # Last updated 2014-12-11 daveadams@gmail.com
6
6
  #
7
7
  # https://github.com/daveadams/sakai-info
8
8
  #
@@ -132,6 +132,14 @@ module SakaiInfo
132
132
  @access_control ||= self.access_control_class.find(self.id)
133
133
  end
134
134
 
135
+ def metadata
136
+ @metadata ||= self.metadata_class.find_by_quiz_id(self.id)
137
+ end
138
+
139
+ def authorizations
140
+ @authorizations ||= self.authorization_class.find_by_quiz_id(self.id)
141
+ end
142
+
135
143
  def default_serialization
136
144
  result = {
137
145
  "id" => self.id,
@@ -195,6 +203,22 @@ module SakaiInfo
195
203
  }
196
204
  end
197
205
 
206
+ def metadata_serialization
207
+ {
208
+ "metadata" => self.metadata.collect { |m| [m.key, m.value] }.to_h
209
+ }
210
+ end
211
+
212
+ def authorizations_serialization
213
+ {
214
+ "authorizations" => self.authorizations.collect { |a| a.serialize(:quiz_summary) }
215
+ }
216
+ end
217
+
218
+ def auths_serialization
219
+ self.authorizations_serialization
220
+ end
221
+
198
222
  def self.all_serializations
199
223
  [
200
224
  :default,
@@ -260,6 +284,14 @@ module SakaiInfo
260
284
  def access_control_class
261
285
  PendingQuizAccessControl
262
286
  end
287
+
288
+ def metadata_class
289
+ PendingQuizMetadata
290
+ end
291
+
292
+ def authorization_class
293
+ PendingQuizAuthorization
294
+ end
263
295
  end
264
296
 
265
297
  class PublishedQuiz < Quiz
@@ -324,6 +356,14 @@ module SakaiInfo
324
356
  PublishedQuizAccessControl
325
357
  end
326
358
 
359
+ def metadata_class
360
+ PublishedQuizMetadata
361
+ end
362
+
363
+ def authorization_class
364
+ PublishedQuizAuthorization
365
+ end
366
+
327
367
  def attempt_count
328
368
  @attempt_count ||= QuizAttempt.count_by_quiz_id(self.id)
329
369
  end
@@ -728,18 +768,8 @@ module SakaiInfo
728
768
  end
729
769
  end
730
770
 
731
- # class QuizItemAttachment < SakaiObject
732
- # end
733
-
734
- # class PendingQuizItemAttachment < QuizItemAttachment
735
- # end
736
-
737
- # class PublishedQuizItemAttachment < QuizItemAttachment
738
- # end
739
-
740
771
  class QuizAttempt < SakaiObject
741
- attr_reader :dbrow, :submitted_at, :total_auto_score, :status, :attempted_at
742
- attr_reader :time_elapsed, :comments, :user_id, :quiz_id
772
+ attr_reader :dbrow, :total_auto_score, :status, :time_elapsed, :comments, :user_id, :quiz_id
743
773
 
744
774
  def self.clear_cache
745
775
  @@cache = {}
@@ -755,7 +785,7 @@ module SakaiInfo
755
785
  @quiz_id = dbrow[:publishedassessmentid]
756
786
  @total_auto_score = dbrow[:totalautoscore]
757
787
  @status = dbrow[:status]
758
- @attempted_at = dbrow[:attempted_at]
788
+ @attempted_at = dbrow[:attemptdate]
759
789
  @time_elapsed = dbrow[:timeelapsed]
760
790
  @is_auto_submitted = dbrow[:is_auto_submitted]
761
791
  @is_late = dbrow[:islate]
@@ -821,6 +851,22 @@ module SakaiInfo
821
851
  @is_late == 1
822
852
  end
823
853
 
854
+ def attempted_at
855
+ if @attempted_at.nil?
856
+ nil
857
+ else
858
+ @attempted_at.strftime("%Y-%m-%d %H:%M:%S")
859
+ end
860
+ end
861
+
862
+ def submitted_at
863
+ if @submitted_at.nil?
864
+ nil
865
+ else
866
+ @submitted_at.strftime("%Y-%m-%d %H:%M:%S")
867
+ end
868
+ end
869
+
824
870
  # status definitions from samigo-api/src/java/org/sakaiproject/tool/assessment/data/ifc/grading/AssessmentGradingIfc.java
825
871
  ATTEMPT_STATUS = {
826
872
  "0" => "unsubmitted",
@@ -842,7 +888,9 @@ module SakaiInfo
842
888
  "user" => self.user.serialize(:summary),
843
889
  "quiz" => self.quiz.serialize(:summary),
844
890
  "item_count" => self.item_count,
891
+ "attempted_at" => self.attempted_at,
845
892
  "submitted_at" => self.submitted_at,
893
+ "time_elapsed" => self.time_elapsed,
846
894
  "is_auto_submitted" => self.auto_submitted?,
847
895
  "is_late" => self.late?,
848
896
  "status" => self.status,
@@ -1301,4 +1349,212 @@ module SakaiInfo
1301
1349
  @quiz ||= PublishedQuiz.find(self.id)
1302
1350
  end
1303
1351
  end
1352
+
1353
+ # metadata
1354
+ class QuizMetadata < SakaiObject
1355
+ attr_reader :id, :dbrow, :key, :value
1356
+
1357
+ def initialize(dbrow)
1358
+ @dbrow = dbrow
1359
+ @id = dbrow[:assessmentmetadataid]
1360
+ @quiz_id = dbrow[:assessmentid]
1361
+ @key = dbrow[:label]
1362
+ @value = dbrow[:entry]
1363
+ end
1364
+
1365
+ def default_serialization
1366
+ {
1367
+ "id" => self.id,
1368
+ "quiz" => self.quiz.serialize(:summary),
1369
+ "key" => self.key,
1370
+ "value" => self.value,
1371
+ }
1372
+ end
1373
+ end
1374
+
1375
+ class PendingQuizMetadata < QuizMetadata
1376
+ def self.clear_cache
1377
+ @@cache = {}
1378
+ end
1379
+ clear_cache
1380
+
1381
+ def self.find(id)
1382
+ id = id.to_s
1383
+ if @@cache[id].nil?
1384
+ row = DB.connect[:sam_assessmetadata_t].where(:assessmentmetadataid => id.to_i).first
1385
+ if row.nil?
1386
+ raise ObjectNotFoundException.new(PendingQuizMetadata, id)
1387
+ end
1388
+
1389
+ @@cache[id] = PendingQuizMetadata.new(row)
1390
+ end
1391
+ @@cache[id]
1392
+ end
1393
+
1394
+ def quiz
1395
+ @quiz ||= PendingQuiz.find(@quiz_id)
1396
+ end
1397
+
1398
+ def self.query_by_quiz_id(quiz_id)
1399
+ DB.connect[:sam_assessmetadata_t].where(:assessmentid => quiz_id)
1400
+ end
1401
+
1402
+ def self.count_by_quiz_id(quiz_id)
1403
+ PendingQuizMetadata.query_by_quiz_id(quiz_id).count
1404
+ end
1405
+
1406
+ def self.find_by_quiz_id(quiz_id)
1407
+ PendingQuizMetadata.query_by_quiz_id(quiz_id).
1408
+ all.collect { |row| PendingQuizMetadata.new(row) }
1409
+ end
1410
+ end
1411
+
1412
+ class PublishedQuizMetadata < QuizMetadata
1413
+ def self.clear_cache
1414
+ @@cache = {}
1415
+ end
1416
+ clear_cache
1417
+
1418
+ def self.find(id)
1419
+ id = id.to_s
1420
+ if @@cache[id].nil?
1421
+ row = DB.connect[:sam_publishedmetadata_t].where(:assessmentmetadataid => id.to_i).first
1422
+ if row.nil?
1423
+ raise ObjectNotFoundException.new(PublishedQuizMetadata, id)
1424
+ end
1425
+
1426
+ @@cache[id] = PublishedQuizMetadata.new(row)
1427
+ end
1428
+ @@cache[id]
1429
+ end
1430
+
1431
+ def quiz
1432
+ @quiz ||= PublishedQuiz.find(@quiz_id)
1433
+ end
1434
+
1435
+ def self.query_by_quiz_id(quiz_id)
1436
+ DB.connect[:sam_publishedmetadata_t].where(:assessmentid => quiz_id)
1437
+ end
1438
+
1439
+ def self.count_by_quiz_id(quiz_id)
1440
+ PublishedQuizMetadata.query_by_quiz_id(quiz_id).count
1441
+ end
1442
+
1443
+ def self.find_by_quiz_id(quiz_id)
1444
+ PublishedQuizMetadata.query_by_quiz_id(quiz_id).
1445
+ all.collect { |row| PublishedQuizMetadata.new(row) }
1446
+ end
1447
+ end
1448
+
1449
+ # authorization
1450
+ class QuizAuthorization < SakaiObject
1451
+ attr_reader :id, :dbrow, :name, :starts_at, :ends_at
1452
+
1453
+ include ModProps
1454
+ created_by_key :lastmodifiedby
1455
+ created_at_key :lastmodifieddate
1456
+ modified_by_key :lastmodifiedby
1457
+ modified_at_key :lastmodifieddate
1458
+
1459
+ def initialize(dbrow)
1460
+ @dbrow = dbrow
1461
+ @id = dbrow[:id]
1462
+ @agent_id = dbrow[:agentid]
1463
+ @name = dbrow[:functionid]
1464
+ @quiz_id = dbrow[:qualifierid]
1465
+ @starts_at = dbrow[:effectivedate]
1466
+ @ends_at = dbrow[:expirationdate]
1467
+ end
1468
+
1469
+ def default_serialization
1470
+ {
1471
+ "id" => self.id,
1472
+ "quiz" => self.quiz.serialize(:summary),
1473
+ "name" => self.name,
1474
+ "agent" => @agent_id,
1475
+ }
1476
+ end
1477
+
1478
+ def quiz_summary_serialization
1479
+ {
1480
+ "name" => self.name,
1481
+ "agent" => @agent_id,
1482
+ }
1483
+ end
1484
+ end
1485
+
1486
+ class PendingQuizAuthorization < QuizAuthorization
1487
+ def self.clear_cache
1488
+ @@cache = {}
1489
+ end
1490
+ clear_cache
1491
+
1492
+ def self.find(id)
1493
+ id = id.to_s
1494
+ if @@cache[id].nil?
1495
+ row = DB.connect[:sam_authzdata_t].where(:id => id.to_i).first
1496
+ if row.nil?
1497
+ raise ObjectNotFoundException.new(PendingQuizAuthorization, id)
1498
+ end
1499
+
1500
+ @@cache[id] = PendingQuizAuthorization.new(row)
1501
+ end
1502
+ @@cache[id]
1503
+ end
1504
+
1505
+ def quiz
1506
+ @quiz ||= PendingQuiz.find(@quiz_id)
1507
+ end
1508
+
1509
+ def self.query_by_quiz_id(quiz_id)
1510
+ DB.connect[:sam_authzdata_t].where(:qualifierid => quiz_id).exclude(Sequel.like(:functionid, "%_PUBLISHED_ASSESSMENT%"))
1511
+ end
1512
+
1513
+ def self.count_by_quiz_id(quiz_id)
1514
+ PendingQuizAuthorization.query_by_quiz_id(quiz_id).count
1515
+ end
1516
+
1517
+ def self.find_by_quiz_id(quiz_id)
1518
+ PendingQuizAuthorization.query_by_quiz_id(quiz_id).
1519
+ all.collect { |row| PendingQuizAuthorization.new(row) }
1520
+ end
1521
+ end
1522
+
1523
+ class PublishedQuizAuthorization < QuizAuthorization
1524
+ def self.clear_cache
1525
+ @@cache = {}
1526
+ end
1527
+ clear_cache
1528
+
1529
+ def self.find(id)
1530
+ id = id.to_s
1531
+ if @@cache[id].nil?
1532
+ row = DB.connect[:sam_authzdata_t].where(:id => id.to_i).first
1533
+ if row.nil?
1534
+ raise ObjectNotFoundException.new(PublishedQuizAuthorization, id)
1535
+ end
1536
+
1537
+ @@cache[id] = PublishedQuizAuthorization.new(row)
1538
+ end
1539
+ @@cache[id]
1540
+ end
1541
+
1542
+ def quiz
1543
+ @quiz ||= PublishedQuiz.find(@quiz_id)
1544
+ end
1545
+
1546
+ def self.query_by_quiz_id(quiz_id)
1547
+ DB.connect[:sam_authzdata_t].where(:qualifierid => quiz_id).where(Sequel.like(:functionid, "%_PUBLISHED_ASSESSMENT%"))
1548
+ end
1549
+
1550
+ def self.count_by_quiz_id(quiz_id)
1551
+ PublishedQuizAuthorization.query_by_quiz_id(quiz_id).count
1552
+ end
1553
+
1554
+ def self.find_by_quiz_id(quiz_id)
1555
+ PublishedQuizAuthorization.query_by_quiz_id(quiz_id).
1556
+ all.collect { |row| PublishedQuizAuthorization.new(row) }
1557
+ end
1558
+ end
1559
+
1304
1560
  end
@@ -1,3 +1,3 @@
1
1
  module SakaiInfo
2
- VERSION = "0.5.5"
2
+ VERSION = "0.5.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sakai-info
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Adams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-08 00:00:00.000000000 Z
11
+ date: 2014-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel