use of org.motechproject.mots.domain.ModuleProgress in project mots by motech-implementations.
the class ModuleProgressService method parseVotoModuleBlocks.
private boolean parseVotoModuleBlocks(VotoCallLogDto callLog, Iterator<VotoBlockDto> blockIterator, String moduleId, boolean callInterrupted) {
String chwIvrId = callLog.getChwIvrId();
ModuleProgress moduleProgress = moduleProgressRepository.findByCommunityHealthWorkerIvrIdAndCourseModuleIvrId(chwIvrId, moduleId).orElseThrow(() -> new CourseProgressException("No module progress found for" + " CHW with IVR Id: {0} and module with IVR Id: {1}", chwIvrId, moduleId));
if (ProgressStatus.COMPLETED.equals(moduleProgress.getStatus())) {
throw new CourseProgressException("Module already completed for CHW with IVR Id: {0} " + "and module with IVR Id: {1}", chwIvrId, moduleId);
}
if (!moduleProgress.getInterrupted()) {
VotoBlockDto blockDto = checkRunUnitBlock(blockIterator, moduleProgress);
moduleProgress.startModule(parseDate(blockDto.getEntryAt()));
}
while (!moduleProgress.isCompleted()) {
UnitProgress unitProgress = moduleProgress.getCurrentUnitProgress();
if (parseVotoUnitBlocks(unitProgress, blockIterator, callInterrupted) || !blockIterator.hasNext()) {
moduleProgress.setInterrupted(true);
moduleProgressRepository.save(moduleProgress);
return true;
}
moduleProgress.setInterrupted(false);
if (parseUnitContinuationQuestion(blockIterator, moduleProgress, unitProgress)) {
moduleProgressRepository.save(moduleProgress);
return true;
}
}
moduleProgressRepository.save(moduleProgress);
return false;
}
use of org.motechproject.mots.domain.ModuleProgress in project mots by motech-implementations.
the class ModuleProgressService method updateModuleProgressWithNewCourseModules.
/**
* Update ModuleProgresses with new Course Modules when Module is reused in newly released Course.
* @param courseModules list of new Course Modules with reused Modules
*/
public void updateModuleProgressWithNewCourseModules(List<CourseModule> courseModules) {
courseModules.forEach(courseModule -> {
UUID courseModuleId = courseModule.getPreviousVersion().getId();
List<ModuleProgress> moduleProgresses = moduleProgressRepository.findByCourseModuleId(courseModuleId);
if (moduleProgresses != null && !moduleProgresses.isEmpty()) {
moduleProgresses.forEach(moduleProgress -> moduleProgress.setCourseModule(courseModule));
moduleProgressRepository.save(moduleProgresses);
}
});
}
use of org.motechproject.mots.domain.ModuleProgress in project mots by motech-implementations.
the class ModuleProgressDataBuilder method buildAsNew.
/**
* Builds instance of {@link ModuleProgress} without id.
*/
public ModuleProgress buildAsNew() {
ModuleProgress moduleProgress = new ModuleProgress();
moduleProgress.setStatus(status);
moduleProgress.setCourseModule(courseModule);
moduleProgress.setCommunityHealthWorker(chw);
return moduleProgress;
}
use of org.motechproject.mots.domain.ModuleProgress in project mots by motech-implementations.
the class ModuleProgressDataBuilder method build.
/**
* Builds instance of {@link ModuleProgress}.
*/
public ModuleProgress build() {
ModuleProgress moduleProgress = buildAsNew();
moduleProgress.setId(id);
return moduleProgress;
}
use of org.motechproject.mots.domain.ModuleProgress in project mots by motech-implementations.
the class ModuleProgressService method createModuleProgress.
private void createModuleProgress(CommunityHealthWorker chw, Module module) {
Course course = moduleService.getReleasedCourse();
if (!moduleProgressRepository.findByCommunityHealthWorkerIdAndCourseModuleModuleIdAndCourseModuleCourseId(chw.getId(), module.getId(), course.getId()).isPresent()) {
CourseModule courseModule = moduleService.findReleasedCourseModuleByModuleId(module.getId());
ModuleProgress moduleProgress = new ModuleProgress(chw, courseModule);
moduleProgressRepository.save(moduleProgress);
}
}
Aggregations