RAPP Platform API
 All Classes Namespaces Files Functions Variables Typedefs
CognitiveExerciseSelect.py
Go to the documentation of this file.
1 from RappCloud.Objects import (
2  File,
3  Payload)
4 
5 from Cloud import (
6  CloudMsg,
7  CloudRequest,
8  CloudResponse)
9 
10 
11 class CognitiveExerciseSelect(CloudMsg):
12  """ Cognitive Exercise Select Cloud Message object
13 
14  For more information on available exercises have a look at:
15  https://github.com/rapp-project/rapp-platform/tree/master/rapp_cognitive_exercise
16  """
17 
18  class Request(CloudRequest):
19  """ Cognitive Exercise Select Cloud Request object.
20 
21  CognitiveExerciseSelect.Request
22  """
23  def __init__(self, **kwargs):
24  """!
25  Constructor
26 
27  @param **kwargs - Keyword arguments. Apply values to the request attributes.
28  - @ref test_type
29  - @ref test_subtype
30  - @ref test_diff
31  - @ref test_index
32  """
33 
34  ## Cognitive Exercise test type. Can be one of:
35  # - 'ArithmeticCts'
36  # - 'AwarenessCts'
37  # - 'ReasoningCts'
38  # - ''
39  #
40  # If left empty, selection will be performed based on user's past
41  # performance records.
42  self.test_type = ''
43  ## Force select from this subtype. Defaults to empty string ""
44  self.test_subtype = ''
45  ## Force select from this difficulty. Defaults to empty string ""
46  self.test_diff = ''
47  ## Force select this index. Defaults to empty string "".
48  self.test_index = ''
49  # { test_type: 'Arithmetic', test_subtype: 'BasicArithmetic', test_diff: '1', test_index: '1' }
50  super(CognitiveExerciseSelect.Request, self).__init__(**kwargs)
51 
52 
53  def make_payload(self):
54  """ Create and return the Payload of the Request. """
55  return Payload(
56  test_type=self.test_type,
57  test_subtype=self.test_subtype,
58  test_diff=self.test_diff,
59  test_index=self.test_index)
60 
61 
62  def make_files(self):
63  """ Create and return Array of File objects of the Request. """
64  return []
65 
66 
67  class Response(CloudResponse):
68  """ Cognitive Exercise Select Cloud Response object.
69 
70  CognitiveExerciseSelect.Response
71  """
72  def __init__(self, **kwargs):
73  """!
74  Constructor
75 
76  @param **kwargs - Keyword arguments. Apply values to the request attributes.
77  - @ref error
78  - @ref questions
79  - @ref possib_ans
80  - @ref correct_ans
81  - @ref test_instance
82  - @ref test_type
83  - @ref test_subtype
84  """
85 
86  ## Error message
87  self.error = ''
88  ## The set of questions for the exercise
89  self.questions = []
90  ## The set of possible answers for each question.
91  self.possib_ans = []
92  ## The set of correct answers for each question.
93  self.correct_ans = []
94  ## Returned test instance name.
95  # e.g. 'ArithmeticCts_askw0Snwk'
96  self.test_instance = ''
97  ## Cognitive exercise class/type.
98  self.test_type = ''
99  ## Cognitive exercise sub-type.
100  self.test_subtype = ''
101  super(CognitiveExerciseSelect.Response, self).__init__(**kwargs)
102 
103 
104  def __init__(self, **kwargs):
105  """!
106  Constructor
107 
108  @param **kwargs - Keyword argumen.ts. Apply values to the request attributes.
109  - @ref Request.test_type
110  - @ref Request.test_subtype
111  - @ref Request.test_diff
112  - @ref Request.test_index
113  """
114 
115  # Create and hold the Request object for this CloudMsg
117  # Create and hold the Response object for this CloudMsg
119  super(CognitiveExerciseSelect, self).__init__(
120  svcname='cognitive_test_chooser', **kwargs)
121 
122