Commit 1105640e authored by Andreas Gärtner's avatar Andreas Gärtner

Added verification if a leaf node (tst) is flagged as online.

parent c6b2bad6
......@@ -203,6 +203,27 @@ public class IliasConnectorDaoImpl implements UniRepDao {
}
);
}
@Override
public boolean isTestOnline(final int refId) {
final JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
return jdbcTemplate.queryForObject(
"SELECT online_status FROM tree AS t1 "
+ "JOIN tree AS t2 ON t2.lft BETWEEN t1.lft AND t1.rgt AND t1.tree = t2.tree "
+ "JOIN object_reference AS r ON r.ref_id=t2.child "
+ "JOIN object_data as d ON d.obj_id=r.obj_id "
+ "JOIN tst_tests as tests ON tests.obj_fi=r.obj_id "
+ "WHERE t1.child = ?",
new String[] {String.valueOf(refId)},
new RowMapper<Boolean>() {
@Override
public Boolean mapRow(final ResultSet resultSet, final int row) throws SQLException {
return resultSet.getBoolean("online_status");
}
}
);
}
@Override
public boolean isRandomQuestionSet(final int refId) {
......
......@@ -38,6 +38,13 @@ public interface UniRepDao {
* @return A map with reference id - meta data value pairs
*/
Map<String, String> getReferenceIdsWithMetaDataFlag(String metaDataTitle);
/** Returns TRUE if referenced repository object is a test which is flagged as online
*
* @param refId The reference id of the test to be checked
* @return TRUE if this object is a test which is flagged as online
*/
boolean isTestOnline(int refId);
/** Returns TRUE if referenced repository object is a test with random question selection
*
......
......@@ -95,7 +95,7 @@ public class UniRepServiceImpl implements UniRepService {
}
if (node.getChildren() == null || node.getChildren().size() == 0) {
if (node.getQuestionCount() == 0) {
if (node.getQuestionCount() == 0 || !uniRepDao.isTestOnline(node.getId())) {
it.remove();
hasRemovedNodes = true;
continue;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment