Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ARSnova Backend
Manage
Activity
Members
Labels
Plan
Issues
27
Issue boards
Milestones
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Privacy
Imprint
Contact
Snippets
Groups
Projects
Show more breadcrumbs
ARSnova
ARSnova Backend
Commits
7a5d2f72
Commit
7a5d2f72
authored
11 years ago
by
Christoph Thelen
Browse files
Options
Downloads
Patches
Plain Diff
Fix for #7654: Count unanswered variant questions
parent
b4f02923
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/de/thm/arsnova/dao/CouchDBDao.java
+62
-30
62 additions, 30 deletions
src/main/java/de/thm/arsnova/dao/CouchDBDao.java
src/main/java/de/thm/arsnova/entities/Answer.java
+11
-2
11 additions, 2 deletions
src/main/java/de/thm/arsnova/entities/Answer.java
with
73 additions
and
32 deletions
src/main/java/de/thm/arsnova/dao/CouchDBDao.java
+
62
−
30
View file @
7a5d2f72
...
...
@@ -431,18 +431,8 @@ public class CouchDBDao implements IDatabaseDao {
}
else
{
view
=
new
NovaView
(
"skill_question/by_session_only_id_for_all"
);
}
view
.
setKey
(
session
.
get_id
());
ViewResults
results
=
this
.
getDatabase
().
view
(
view
);
if
(
results
.
getResults
().
size
()
==
0
)
{
return
new
ArrayList
<
String
>();
}
List
<
String
>
ids
=
new
ArrayList
<
String
>();
for
(
Document
d
:
results
.
getResults
())
{
ids
.
add
(
d
.
getId
());
}
return
ids
;
return
collectQuestionIds
(
view
);
}
@Override
...
...
@@ -497,21 +487,7 @@ public class CouchDBDao implements IDatabaseDao {
public
final
List
<
String
>
getUnAnsweredQuestionIds
(
final
Session
session
,
final
User
user
)
{
NovaView
view
=
new
NovaView
(
"answer/by_user"
);
view
.
setKey
(
user
.
getUsername
(),
session
.
get_id
());
ViewResults
anseweredQuestions
=
this
.
getDatabase
().
view
(
view
);
List
<
String
>
answered
=
new
ArrayList
<
String
>();
for
(
Document
d
:
anseweredQuestions
.
getResults
())
{
answered
.
add
(
d
.
getString
(
"value"
));
}
List
<
String
>
questions
=
this
.
getQuestionIds
(
session
,
user
);
List
<
String
>
unanswered
=
new
ArrayList
<
String
>();
for
(
String
questionId
:
questions
)
{
if
(!
answered
.
contains
(
questionId
))
{
unanswered
.
add
(
questionId
);
}
}
return
unanswered
;
return
collectUnansweredQuestionIds
(
session
,
user
,
this
.
getQuestionIds
(
session
,
user
),
view
);
}
@Override
...
...
@@ -943,6 +919,7 @@ public class CouchDBDao implements IDatabaseDao {
a
.
put
(
"sessionId"
,
answer
.
getSessionId
());
a
.
put
(
"questionId"
,
answer
.
getQuestionId
());
a
.
put
(
"answerSubject"
,
answer
.
getAnswerSubject
());
a
.
put
(
"questionVariant"
,
answer
.
getQuestionVariant
());
a
.
put
(
"answerText"
,
answer
.
getAnswerText
());
a
.
put
(
"timestamp"
,
answer
.
getTimestamp
());
a
.
put
(
"user"
,
user
.
getUsername
());
...
...
@@ -1243,13 +1220,68 @@ public class CouchDBDao implements IDatabaseDao {
@Override
public
List
<
String
>
getUnAnsweredLectureQuestionIds
(
Session
session
,
User
user
)
{
// TODO Auto-generated method stub
return
null
;
NovaView
view
=
new
NovaView
(
"answer/variant_by_user"
);
view
.
setKey
(
user
.
getUsername
(),
session
.
get_id
(),
"lecture"
);
return
collectUnansweredQuestionIds
(
session
,
user
,
this
.
getLectureQuestionIds
(
session
,
user
),
view
);
}
private
List
<
String
>
getLectureQuestionIds
(
Session
session
,
User
user
)
{
NovaView
view
;
if
(
user
.
getType
().
equals
(
"thm"
))
{
view
=
new
NovaView
(
"skill_question/lecture_question_by_session_for_thm"
);
}
else
{
view
=
new
NovaView
(
"skill_question/lecture_question_by_session_for_all"
);
}
view
.
setStartKeyArray
(
session
.
get_id
());
view
.
setEndKeyArray
(
session
.
get_id
(),
"{}"
);
return
collectQuestionIds
(
view
);
}
@Override
public
List
<
String
>
getUnAnsweredPreparationQuestionIds
(
Session
session
,
User
user
)
{
// TODO Auto-generated method stub
return
null
;
NovaView
view
=
new
NovaView
(
"answer/variant_by_user"
);
view
.
setKey
(
user
.
getUsername
(),
session
.
get_id
(),
"preparation"
);
return
collectUnansweredQuestionIds
(
session
,
user
,
this
.
getPreparationQuestionIds
(
session
,
user
),
view
);
}
private
List
<
String
>
getPreparationQuestionIds
(
Session
session
,
User
user
)
{
NovaView
view
;
if
(
user
.
getType
().
equals
(
"thm"
))
{
view
=
new
NovaView
(
"skill_question/preparation_question_by_session_for_thm"
);
}
else
{
view
=
new
NovaView
(
"skill_question/preparation_question_by_session_for_all"
);
}
view
.
setStartKeyArray
(
session
.
get_id
());
view
.
setEndKeyArray
(
session
.
get_id
(),
"{}"
);
return
collectQuestionIds
(
view
);
}
private
List
<
String
>
collectUnansweredQuestionIds
(
Session
session
,
User
user
,
List
<
String
>
questions
,
NovaView
view
)
{
ViewResults
answeredQuestions
=
this
.
getDatabase
().
view
(
view
);
List
<
String
>
answered
=
new
ArrayList
<
String
>();
for
(
Document
d
:
answeredQuestions
.
getResults
())
{
answered
.
add
(
d
.
getString
(
"value"
));
}
List
<
String
>
unanswered
=
new
ArrayList
<
String
>();
for
(
String
questionId
:
questions
)
{
if
(!
answered
.
contains
(
questionId
))
{
unanswered
.
add
(
questionId
);
}
}
return
unanswered
;
}
private
List
<
String
>
collectQuestionIds
(
NovaView
view
)
{
ViewResults
results
=
this
.
getDatabase
().
view
(
view
);
if
(
results
.
getResults
().
size
()
==
0
)
{
return
new
ArrayList
<
String
>();
}
List
<
String
>
ids
=
new
ArrayList
<
String
>();
for
(
Document
d
:
results
.
getResults
())
{
ids
.
add
(
d
.
getId
());
}
return
ids
;
}
}
This diff is collapsed.
Click to expand it.
src/main/java/de/thm/arsnova/entities/Answer.java
+
11
−
2
View file @
7a5d2f72
...
...
@@ -9,12 +9,13 @@ public class Answer {
private
String
questionId
;
private
String
answerText
;
private
String
answerSubject
;
private
String
questionVariant
;
private
int
piRound
;
private
String
user
;
private
long
timestamp
;
private
int
answerCount
=
1
;
private
boolean
abstention
;
// Currently available only for freetext and mc answers!
private
int
abstentionCount
;
// Currently available only for freetext and mc answers!
private
boolean
abstention
;
private
int
abstentionCount
;
public
Answer
()
{
this
.
type
=
"skill_question_answer"
;
...
...
@@ -124,6 +125,14 @@ public class Answer {
this
.
abstentionCount
=
abstentionCount
;
}
public
String
getQuestionVariant
()
{
return
questionVariant
;
}
public
void
setQuestionVariant
(
String
questionVariant
)
{
this
.
questionVariant
=
questionVariant
;
}
@Override
public
final
String
toString
()
{
return
"Answer type:'"
+
type
+
"'"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment