Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@
<artifactId>poi-ooxml</artifactId>
<version>3.11</version>
</dependency>

<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
379 changes: 0 additions & 379 deletions sb-cb-ext.iml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ public ResponseEntity<?> readQuestionList(@Valid @RequestBody Map<String, Object
SBApiResponse response = assessmentServiceV2.readQuestionList(requestBody, authUserToken);
return new ResponseEntity<>(response, response.getResponseCode());
}
// QUML based Assessment APIs
// =======================

@GetMapping("/v1/quml/assessment/retake/{assessmentIdentifier}")
public ResponseEntity<SBApiResponse> retakeAssessment(
@PathVariable("assessmentIdentifier") String assessmentIdentifier,
@RequestHeader(Constants.X_AUTH_TOKEN) String token) throws Exception {
SBApiResponse readResponse = assessmentServiceV2.retakeAssessment(assessmentIdentifier, token);
return new ResponseEntity<>(readResponse, readResponse.getResponseCode());
}
}
196 changes: 196 additions & 0 deletions src/main/java/org/sunbird/assessment/model/Competency.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
package org.sunbird.assessment.model;

import javax.annotation.Generated;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"id",
"name",
"description",
"competencyType",
"competencyArea",
"source",
"selectedLevelId",
"selectedLevelLevel",
"selectedLevelName",
"selectedLevelDescription"
})
public class Competency {

@JsonProperty("id")
private String id;
@JsonProperty("name")
private String name;
@JsonProperty("description")
private String description;
@JsonProperty("competencyType")
private String competencyType;
@JsonProperty("competencyArea")
private String competencyArea;
@JsonProperty("source")
private String source;
@JsonProperty("selectedLevelId")
private String selectedLevelId;
@JsonProperty("selectedLevelLevel")
private String selectedLevelLevel;
@JsonProperty("selectedLevelName")
private String selectedLevelName;
@JsonProperty("selectedLevelDescription")
private String selectedLevelDescription;

@JsonProperty("id")
public String getId() {
return id;
}

@JsonProperty("id")
public void setId(String id) {
this.id = id;
}

@JsonProperty("name")
public String getName() {
return name;
}

@JsonProperty("name")
public void setName(String name) {
this.name = name;
}

@JsonProperty("description")
public String getDescription() {
return description;
}

@JsonProperty("description")
public void setDescription(String description) {
this.description = description;
}

@JsonProperty("competencyType")
public String getCompetencyType() {
return competencyType;
}

@JsonProperty("competencyType")
public void setCompetencyType(String competencyType) {
this.competencyType = competencyType;
}

@JsonProperty("competencyArea")
public String getCompetencyArea() {
return competencyArea;
}

@JsonProperty("competencyArea")
public void setCompetencyArea(String competencyArea) {
this.competencyArea = competencyArea;
}

@JsonProperty("source")
public String getSource() {
return source;
}

@JsonProperty("source")
public void setSource(String source) {
this.source = source;
}

@JsonProperty("selectedLevelId")
public String getSelectedLevelId() {
return selectedLevelId;
}

@JsonProperty("selectedLevelId")
public void setSelectedLevelId(String selectedLevelId) {
this.selectedLevelId = selectedLevelId;
}

@JsonProperty("selectedLevelLevel")
public String getSelectedLevelLevel() {
return selectedLevelLevel;
}

@JsonProperty("selectedLevelLevel")
public void setSelectedLevelLevel(String selectedLevelLevel) {
this.selectedLevelLevel = selectedLevelLevel;
}

@JsonProperty("selectedLevelName")
public String getSelectedLevelName() {
return selectedLevelName;
}

@JsonProperty("selectedLevelName")
public void setSelectedLevelName(String selectedLevelName) {
this.selectedLevelName = selectedLevelName;
}

@JsonProperty("selectedLevelDescription")
public String getSelectedLevelDescription() {
return selectedLevelDescription;
}

@JsonProperty("selectedLevelDescription")
public void setSelectedLevelDescription(String selectedLevelDescription) {
this.selectedLevelDescription = selectedLevelDescription;
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(Competency.class.getName()).append('@').append(Integer.toHexString(System.identityHashCode(this))).append('[');
sb.append("id");
sb.append('=');
sb.append(((this.id == null)?"<null>":this.id));
sb.append(',');
sb.append("name");
sb.append('=');
sb.append(((this.name == null)?"<null>":this.name));
sb.append(',');
sb.append("description");
sb.append('=');
sb.append(((this.description == null)?"<null>":this.description));
sb.append(',');
sb.append("competencyType");
sb.append('=');
sb.append(((this.competencyType == null)?"<null>":this.competencyType));
sb.append(',');
sb.append("competencyArea");
sb.append('=');
sb.append(((this.competencyArea == null)?"<null>":this.competencyArea));
sb.append(',');
sb.append("source");
sb.append('=');
sb.append(((this.source == null)?"<null>":this.source));
sb.append(',');
sb.append("selectedLevelId");
sb.append('=');
sb.append(((this.selectedLevelId == null)?"<null>":this.selectedLevelId));
sb.append(',');
sb.append("selectedLevelLevel");
sb.append('=');
sb.append(((this.selectedLevelLevel == null)?"<null>":this.selectedLevelLevel));
sb.append(',');
sb.append("selectedLevelName");
sb.append('=');
sb.append(((this.selectedLevelName == null)?"<null>":this.selectedLevelName));
sb.append(',');
sb.append("selectedLevelDescription");
sb.append('=');
sb.append(((this.selectedLevelDescription == null)?"<null>":this.selectedLevelDescription));
sb.append(',');
if (sb.charAt((sb.length()- 1)) == ',') {
sb.setCharAt((sb.length()- 1), ']');
} else {
sb.append(']');
}
return sb.toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public interface AssessmentRepository {

/**
* gets answer key for the assessment given the url
*
*
* @param artifactUrl
* @return
* @throws Exception
Expand All @@ -20,7 +20,7 @@ public interface AssessmentRepository {

/**
* gets answerkey for the quiz submission
*
*
* @param quizMap
* @return
* @throws Exception
Expand All @@ -29,7 +29,7 @@ public interface AssessmentRepository {

/**
* inserts quiz or assessments for a user
*
*
* @param persist
* @param isAssessment
* @return
Expand All @@ -40,7 +40,7 @@ public Map<String, Object> insertQuizOrAssessment(Map<String, Object> persist, B

/**
* gets assessment for a user given a content id
*
*
* @param courseId
* @param userId
* @return
Expand All @@ -49,7 +49,12 @@ public Map<String, Object> insertQuizOrAssessment(Map<String, Object> persist, B
public List<Map<String, Object>> getAssessmentbyContentUser(String rootOrg, String courseId, String userId)
throws Exception;

boolean addUserAssesmentStartTime(String userId, String assessmentIdentifier, Timestamp startTime);
List<Map<String, Object>> fetchUserAssessmentDataFromDB(String userId, String assessmentIdentifier);

Date fetchUserAssessmentStartTime(String userId, String s);
}
boolean addUserAssesmentDataToDB(String userId, String assessmentId, Timestamp startTime, Timestamp endTime,
Map<String, Object> questionSet, String status);

Boolean updateUserAssesmentDataToDB(String userId, String assessmentIdentifier,
Map<String, Object> submitAssessmentRequest, Map<String, Object> submitAssessmentResponse, String status,
Date startTime);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
package org.sunbird.assessment.repo;

import com.datastax.driver.core.utils.UUIDs;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.sunbird.assessment.dto.AssessmentSubmissionDTO;
Expand All @@ -9,10 +17,8 @@
import org.sunbird.common.util.Constants;
import org.sunbird.core.logger.CbExtLogger;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
import com.datastax.driver.core.utils.UUIDs;
import com.google.gson.Gson;

@Service
public class AssessmentRepositoryImpl implements AssessmentRepository {
Expand All @@ -22,7 +28,7 @@ public class AssessmentRepositoryImpl implements AssessmentRepository {
public static final String SOURCE_ID = "sourceId";
public static final String USER_ID = "userId";
private CbExtLogger logger = new CbExtLogger(getClass().getName());

@Autowired
UserAssessmentSummaryRepository userAssessmentSummaryRepo;

Expand Down Expand Up @@ -128,23 +134,50 @@ public List<Map<String, Object>> getAssessmentbyContentUser(String rootOrg, Stri
}

@Override
public boolean addUserAssesmentStartTime(String userId, String assessmentIdentifier, Timestamp startTime) {
public boolean addUserAssesmentDataToDB(String userId, String assessmentIdentifier, Timestamp startTime,
Timestamp endTime, Map<String, Object> questionSet, String status) {
Map<String, Object> request = new HashMap<>();
request.put(Constants.USER_ID, userId);
request.put(Constants.IDENTIFIER, assessmentIdentifier);
cassandraOperation.deleteRecord(Constants.KEYSPACE_SUNBIRD, Constants.TABLE_USER_ASSESSMENT_TIME, request);
request.put("starttime", startTime);
SBApiResponse resp = cassandraOperation.insertRecord(Constants.KEYSPACE_SUNBIRD, Constants.TABLE_USER_ASSESSMENT_TIME, request);
request.put(Constants.ASSESSMENT_ID_KEY, assessmentIdentifier);
request.put(Constants.START_TIME, startTime);
request.put(Constants.END_TIME, endTime);
request.put(Constants.ASSESSMENT_READ_RESPONSE, new Gson().toJson(questionSet));
request.put(Constants.STATUS, status);
SBApiResponse resp = cassandraOperation.insertRecord(Constants.KEYSPACE_SUNBIRD,
Constants.TABLE_USER_ASSESSMENT_DATA, request);
return resp.get(Constants.RESPONSE).equals(Constants.SUCCESS);
}

@Override
public Date fetchUserAssessmentStartTime(String userId, String assessmentIdentifier) {
@Override
public List<Map<String, Object>> fetchUserAssessmentDataFromDB(String userId, String assessmentIdentifier) {
Map<String, Object> request = new HashMap<>();
request.put(Constants.USER_ID, userId);
request.put(Constants.IDENTIFIER, assessmentIdentifier);
Map<String, Object> existingDataList = cassandraOperation.getRecordsByProperties(Constants.KEYSPACE_SUNBIRD,
Constants.TABLE_USER_ASSESSMENT_TIME, request, null).get(0);
return (Date) existingDataList.get("starttime");
request.put(Constants.ASSESSMENT_ID_KEY, assessmentIdentifier);
List<Map<String, Object>> existingDataList = cassandraOperation.getRecordsByProperties(
Constants.KEYSPACE_SUNBIRD, Constants.TABLE_USER_ASSESSMENT_DATA, request, null);
return existingDataList;
}

@Override
public Boolean updateUserAssesmentDataToDB(String userId, String assessmentIdentifier,
Map<String, Object> submitAssessmentRequest, Map<String, Object> submitAssessmentResponse, String status,
Date startTime) {
Map<String, Object> compositeKeys = new HashMap<>();
compositeKeys.put(Constants.USER_ID, userId);
compositeKeys.put(Constants.ASSESSMENT_ID_KEY, assessmentIdentifier);
compositeKeys.put(Constants.START_TIME, startTime);
Map<String, Object> fieldsToBeUpdated = new HashMap<>();
if (!submitAssessmentRequest.isEmpty()) {
fieldsToBeUpdated.put("submitassessmentrequest", new Gson().toJson(submitAssessmentRequest));
}
if (!submitAssessmentResponse.isEmpty()) {
fieldsToBeUpdated.put("submitassessmentresponse", new Gson().toJson(submitAssessmentResponse));
}
if (!status.isEmpty()) {
fieldsToBeUpdated.put(Constants.STATUS, status);
}
cassandraOperation.updateRecord(Constants.KEYSPACE_SUNBIRD, Constants.TABLE_USER_ASSESSMENT_DATA,
fieldsToBeUpdated, compositeKeys);
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ public interface AssessmentServiceV2 {
public SBApiResponse readAssessment(String assessmentIdentifier, String token) throws Exception;

public SBApiResponse readQuestionList(Map<String, Object> requestBody, String authUserToken) throws Exception;

public SBApiResponse retakeAssessment(String assessmentIdentifier, String token) throws Exception;
}
Loading