Skip to content

Commit

Permalink
Merge pull request #184 from TelefonicaED/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
jorgeted authored May 11, 2021
2 parents 3e17f18 + dd71e0f commit ce270fb
Show file tree
Hide file tree
Showing 24 changed files with 285 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.portlet.PortletClassLoaderUtil;
import com.liferay.portal.kernel.util.AutoResetThreadLocal;
import com.liferay.portal.kernel.util.ClassLoaderProxy;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.PortalClassLoaderUtil;
Expand Down Expand Up @@ -145,6 +144,11 @@ public static List<LearningActivityType> getLearningActivityTypesForCreating() {
return _learningActivityTypesForCreating;
}

public static void resetLearningActivityTypes(){

_learningActivityTypes = null;
}

private static List<LearningActivityType> _learningActivityTypes = null;


Expand Down
6 changes: 4 additions & 2 deletions docroot/WEB-INF/src/com/liferay/lms/LmsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import javax.portlet.ReadOnlyException;
import javax.portlet.ValidatorException;

import com.liferay.lms.learningactivity.LearningActivityTypeRegistry;
import com.liferay.lms.model.LmsPrefs;
import com.liferay.lms.service.LmsPrefsLocalServiceUtil;
import com.liferay.lms.util.LmsConstant;
Expand All @@ -25,7 +26,7 @@
*/
public class LmsConfig extends MVCPortlet {

public void changeSettings(ActionRequest request , ActionResponse response) throws Exception{
public void changeSettings(ActionRequest request , ActionResponse response) throws Exception{

String redirect = ParamUtil.get(request, "redirect", "");

Expand Down Expand Up @@ -79,10 +80,11 @@ public void changeSettings(ActionRequest request , ActionResponse response) thro
savePreference(LmsConstant.PREFS_SHOW_OPTION_TEST, String.valueOf(showOptionTest), themeDisplay.getCompanyId());
savePreference(LmsConstant.PREFS_ACCESS_COURSE_EXECUTION_DATES, String.valueOf(accessCoursesExecutionDate), themeDisplay.getCompanyId());

LearningActivityTypeRegistry.resetLearningActivityTypes();

if (Validator.isNotNull(redirect)) {
response.sendRedirect(redirect);
}

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,16 @@ public void render(RenderRequest renderRequest, RenderResponse renderResponse)
if(videoControl!=null){
videoControlDisabled = Boolean.parseBoolean(videoControl.getText());
}

renderRequest.setAttribute("controls", videoControlDisabled && !userPassed ? "": "controls");

boolean showScoreInfo = false;
Element showScoreInfoElement = root.element("show-score-info");
if(Validator.isNotNull(showScoreInfoElement)){
showScoreInfo = Boolean.parseBoolean(showScoreInfoElement.getText());
}
renderRequest.setAttribute("showScoreInfo", showScoreInfo);


int seekTo = 0;
if (videoPosition > 0 && oldScore<100){
DecimalFormat df = new DecimalFormat("#####");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.PropsUtil;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.kernel.xml.Document;
import com.liferay.portal.kernel.xml.DocumentException;
Expand Down Expand Up @@ -124,6 +125,7 @@ public String setExtraContent(UploadRequest uploadRequest, PortletResponse portl

String youtubecode=ParamUtil.getString(uploadRequest,"youtubecode");
boolean videoControlEnabled=ParamUtil.getBoolean(uploadRequest,"videoControl");
boolean showScoreInfo=ParamUtil.getBoolean(uploadRequest,"showScoreInfo");
String team = ParamUtil.getString(uploadRequest, "team","0");
long teamId = 0;
if(!team.equalsIgnoreCase("0")&&!team.isEmpty()){
Expand Down Expand Up @@ -193,7 +195,18 @@ public String setExtraContent(UploadRequest uploadRequest, PortletResponse portl

videoControl = SAXReaderUtil.createElement("video-control");
videoControl.setText(String.valueOf(videoControlEnabled));
rootElement.add(videoControl);
rootElement.add(videoControl);

Element showScoreInfoElement = rootElement.element("show-score-info");
if(Validator.isNotNull(showScoreInfoElement))
{
showScoreInfoElement.detach();
rootElement.remove(showScoreInfoElement);
}

showScoreInfoElement = SAXReaderUtil.createElement("show-score-info");
showScoreInfoElement.setText(String.valueOf(showScoreInfo));
rootElement.add(showScoreInfoElement);

if(files.size()>0){
boolean changes = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.PrefsPropsUtil;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.kernel.xml.Document;
import com.liferay.portal.kernel.xml.DocumentException;
Expand Down Expand Up @@ -107,6 +108,8 @@ public String setExtraContent(UploadRequest uploadRequest,
String assetId = ParamUtil.getString(uploadRequest,"assetEntryId","0");
String team = ParamUtil.getString(uploadRequest, "team","0");
long teamId = 0;
boolean showDoneInfo=ParamUtil.getBoolean(uploadRequest,"showDoneInfo");

ThemeDisplay themeDisplay = (ThemeDisplay) uploadRequest.getAttribute(WebKeys.THEME_DISPLAY);
if(!team.equalsIgnoreCase("0")){
teamId = Long.parseLong(team);
Expand Down Expand Up @@ -205,6 +208,16 @@ public String setExtraContent(UploadRequest uploadRequest,
}
}

Element doneInfoElement=rootElement.element("show-done-info");
if(Validator.isNotNull(doneInfoElement))
{
doneInfoElement.detach();
rootElement.remove(doneInfoElement);
}
doneInfoElement = SAXReaderUtil.createElement("show-done-info");
doneInfoElement.setText(String.valueOf(showDoneInfo));
rootElement.add(doneInfoElement);

learningActivity.setExtracontent(document.formattedString());

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import javax.portlet.PortletPreferences;

import com.liferay.lms.asset.LearningActivityBaseAssetRenderer;
import com.liferay.lms.auditing.AuditConstants;
import com.liferay.lms.auditing.AuditingLogFactory;
import com.liferay.lms.learningactivity.courseeval.CourseEval;
Expand Down Expand Up @@ -81,7 +80,6 @@
import com.liferay.portal.kernel.workflow.WorkflowConstants;
import com.liferay.portal.model.Group;
import com.liferay.portal.model.GroupConstants;
import com.liferay.portal.model.Layout;
import com.liferay.portal.model.LayoutSet;
import com.liferay.portal.model.LayoutSetPrototype;
import com.liferay.portal.model.MembershipRequestConstants;
Expand All @@ -98,7 +96,6 @@
import com.liferay.portal.service.ClassNameLocalServiceUtil;
import com.liferay.portal.service.CompanyLocalServiceUtil;
import com.liferay.portal.service.GroupLocalServiceUtil;
import com.liferay.portal.service.LayoutServiceUtil;
import com.liferay.portal.service.LayoutSetPrototypeLocalServiceUtil;
import com.liferay.portal.service.MembershipRequestLocalServiceUtil;
import com.liferay.portal.service.PortalPreferencesLocalServiceUtil;
Expand Down Expand Up @@ -267,19 +264,42 @@ public List<Course> getPublicCoursesByCompanyId(Long companyId, int start, int e
return null;
}



public Course addCourse (String title, String description,String summary,String friendlyURL, Locale locale,
public Course addCourse (Map<Locale,String> titleMap, Map<Locale,String> descriptionMap,Map<Locale,String> summaryMap,String friendlyURL, Locale locale,
Date createDate,Date startDate,Date endDate,long layoutSetPrototypeId,int typesite, long CourseEvalId, long calificationType, int maxUsers,ServiceContext serviceContext,boolean isfromClone)
throws SystemException, PortalException {

Course course = addCourse (title, description,summary,friendlyURL, locale,
Course course = addCourse (titleMap, descriptionMap,summaryMap,friendlyURL, locale,
createDate,startDate,endDate,null,null,layoutSetPrototypeId,typesite, CourseEvalId, calificationType, maxUsers,
serviceContext, isfromClone);

serviceContext, isfromClone, 0);

return course;
}

public Course addCourse (Map<Locale,String> titleMap, Map<Locale,String> descriptionMap,Map<Locale,String> summaryMap,String friendlyURL, Locale locale,
Date createDate,Date startDate,Date endDate,long layoutSetPrototypeId,int typesite, long CourseEvalId, long calificationType, int maxUsers,ServiceContext serviceContext,
boolean isfromClone, boolean assetVisible)
throws SystemException, PortalException {

Course course = addCourse (titleMap, descriptionMap,summaryMap,friendlyURL, locale,
createDate,startDate,endDate,null,null,layoutSetPrototypeId,typesite, CourseEvalId, calificationType, maxUsers,
serviceContext, isfromClone, 0, assetVisible);

return course;
}

public Course addCourse (String title, String description,String summary,String friendlyURL, Locale locale,
Date createDate,Date startDate,Date endDate,long layoutSetPrototypeId,int typesite, long CourseEvalId, long calificationType, int maxUsers,ServiceContext serviceContext,boolean isfromClone)
throws SystemException, PortalException {

Course course = addCourse (title, description,summary,friendlyURL, locale,
createDate,startDate,endDate,null,null,layoutSetPrototypeId,typesite, CourseEvalId, calificationType, maxUsers,
serviceContext, isfromClone);

return course;
}

public Course addCourse (String title, String description,String summary,String friendlyURL, Locale locale,
Date createDate,Date startDate,Date endDate, Date executionStartDate, Date executionEndDate, long layoutSetPrototypeId,int typesite, long CourseEvalId, long calificationType, int maxUsers,ServiceContext serviceContext,boolean isfromClone)
throws SystemException, PortalException {
Expand All @@ -292,7 +312,8 @@ public Course addCourse (String title, String description,String summary,String
public Course addCourse (Map<Locale,String> titleMap, String description,String summary,String friendlyURL, Locale locale,
Date createDate,Date startDate,Date endDate, Date executionStartDate, Date executionEndDate, long layoutSetPrototypeId,int typesite, long CourseEvalId, long calificationType, int maxUsers,ServiceContext serviceContext,boolean isfromClone)
throws SystemException, PortalException {
return addCourse(titleMap, description, summary, friendlyURL, locale, createDate, startDate, endDate, executionStartDate, executionEndDate, layoutSetPrototypeId, typesite, CourseEvalId, calificationType, maxUsers, serviceContext, isfromClone, 0);
return addCourse(titleMap, description, summary, friendlyURL, locale, createDate, startDate, endDate, executionStartDate, executionEndDate, layoutSetPrototypeId,
typesite, CourseEvalId, calificationType, maxUsers, serviceContext, isfromClone, 0);
}

public Course addCourse (Map<Locale,String> titleMap, String description,String summary,String friendlyURL, Locale locale,
Expand All @@ -301,6 +322,50 @@ public Course addCourse (Map<Locale,String> titleMap, String description,String
long courseTypeId)
throws SystemException, PortalException {

Map<Locale, String> descriptionMap = new HashMap<Locale, String>();
descriptionMap.put(locale, description);
Map<Locale, String> summaryMap = new HashMap<Locale, String>();
summaryMap.put(locale, summary);

return addCourse(titleMap, descriptionMap, summaryMap, friendlyURL, locale, createDate, startDate, endDate,
executionStartDate, executionEndDate, layoutSetPrototypeId, typesite, CourseEvalId, calificationType,
maxUsers, serviceContext, isfromClone, courseTypeId);
}

public Course addCourse (Map<Locale,String> titleMap, String description,String summary,String friendlyURL, Locale locale,
Date createDate,Date startDate,Date endDate, Date executionStartDate, Date executionEndDate, long layoutSetPrototypeId,int typesite,
long CourseEvalId, long calificationType, int maxUsers,ServiceContext serviceContext,boolean isfromClone,
long courseTypeId, boolean assetIsVisible)
throws SystemException, PortalException {

Map<Locale, String> descriptionMap = new HashMap<Locale, String>();
descriptionMap.put(locale, description);
Map<Locale, String> summaryMap = new HashMap<Locale, String>();
summaryMap.put(locale, summary);

return addCourse(titleMap, descriptionMap, summaryMap, friendlyURL, locale, createDate, startDate, endDate,
executionStartDate, executionEndDate, layoutSetPrototypeId, typesite, CourseEvalId, calificationType,
maxUsers, serviceContext, isfromClone, courseTypeId, assetIsVisible);
}

public Course addCourse (Map<Locale,String> titleMap, Map<Locale,String> descriptionMap, Map<Locale,String> summaryMap,String friendlyURL, Locale locale,
Date createDate,Date startDate,Date endDate, Date executionStartDate, Date executionEndDate, long layoutSetPrototypeId,int typesite,
long CourseEvalId, long calificationType, int maxUsers,ServiceContext serviceContext,boolean isfromClone,
long courseTypeId)
throws SystemException, PortalException {

return addCourse(titleMap, descriptionMap, summaryMap, friendlyURL, locale, createDate, startDate, endDate,
executionStartDate, executionEndDate, layoutSetPrototypeId, typesite, CourseEvalId, calificationType,
maxUsers, serviceContext, isfromClone, courseTypeId, true);

}

public Course addCourse (Map<Locale,String> titleMap, Map<Locale,String> descriptionMap, Map<Locale,String> summaryMap,String friendlyURL, Locale locale,
Date createDate,Date startDate,Date endDate, Date executionStartDate, Date executionEndDate, long layoutSetPrototypeId,int typesite,
long CourseEvalId, long calificationType, int maxUsers,ServiceContext serviceContext,boolean isfromClone,
long courseTypeId, boolean assetIsVisible)
throws SystemException, PortalException {

log.debug("courseTypeId:: " + courseTypeId);

LmsPrefs lmsPrefs=lmsPrefsLocalService.getLmsPrefsIni(serviceContext.getCompanyId());
Expand Down Expand Up @@ -353,14 +418,14 @@ public Course addCourse (Map<Locale,String> titleMap, String description,String
course.setUserId(userId);
course.setUserName(userLocalService.getUser(userId).getFullName());
course.setFriendlyURL(friendlyURL);
course.setDescription(description,locale, locale);
course.setDescriptionMap(descriptionMap);
course.setTitleMap(titleMap);
course.setCreateDate(createDate);
course.setModifiedDate(createDate);
course.setStartDate(startDate);
course.setEndDate(endDate);
course.setExecutionStartDate(executionStartDate);
course.setExecutionEndDate(executionEndDate);
course.setExecutionStartDate(Validator.isNotNull(executionStartDate)?executionStartDate:startDate);
course.setExecutionEndDate(Validator.isNotNull(executionEndDate)?executionEndDate:endDate);
course.setStatus(WorkflowConstants.STATUS_APPROVED);
course.setExpandoBridgeAttributes(serviceContext);
course.setCourseEvalId(CourseEvalId);
Expand Down Expand Up @@ -389,7 +454,7 @@ public Course addCourse (Map<Locale,String> titleMap, String description,String
log.debug("groupName: " + groupName);

Group group = groupLocalService.addGroup(userLocalService.getDefaultUser(serviceContext.getCompanyId()).getUserId(),
null, 0, groupName,summary,typesite,friendlyURL,true,true,serviceContext);
null, 0, groupName, summaryMap.get(locale),typesite,friendlyURL,true,true,serviceContext);
course.setGroupCreatedId(group.getGroupId());
course.setFriendlyURL(group.getFriendlyURL());
course.setIsLinked(false);
Expand All @@ -399,8 +464,12 @@ public Course addCourse (Map<Locale,String> titleMap, String description,String
resourceLocalService.addResources(serviceContext.getCompanyId(), serviceContext.getScopeGroupId(), userId,Course.class.getName(), course.getPrimaryKey(), false,true, true);
AssetEntry assetEntry=assetEntryLocalService.updateEntry(userId, course.getGroupId(), Course.class.getName(),
course.getCourseId(), course.getUuid(),courseTypeId, serviceContext.getAssetCategoryIds(),
serviceContext.getAssetTagNames(), true, executionStartDate, executionEndDate,new java.util.Date(System.currentTimeMillis()), null,
ContentTypes.TEXT_HTML, course.getTitle(), course.getDescription(locale), summary, null, null, 0, 0,null, false);
serviceContext.getAssetTagNames(), assetIsVisible, executionStartDate, executionEndDate,new java.util.Date(System.currentTimeMillis()), null,
ContentTypes.TEXT_HTML, course.getTitle(), course.getDescription(locale), summaryMap.get(locale), null, null, 0, 0,null, false);
assetEntry.setTitleMap(course.getTitleMap());
assetEntry.setDescriptionMap(course.getDescriptionMap());
assetEntry.setSummaryMap(summaryMap);
assetEntry = assetEntryLocalService.updateAssetEntry(assetEntry);

assetLinkLocalService.updateLinks(
userId, assetEntry.getEntryId(), serviceContext.getAssetLinkEntryIds(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@


import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import javax.portlet.ActionRequest;
import javax.portlet.PortletRequest;
Expand Down Expand Up @@ -406,9 +409,28 @@ public Module addModule(Long companyId, Long groupId, Long userId,
return addModule(companyId, groupId, userId, title, description, startDate, endDate, ordern, null);
}
@Indexable(type=IndexableType.REINDEX)
public Module addModule(Long companyId, Long groupId, Long userId,
Map<Locale, String> titleMap, Map<Locale, String> descriptionMap,
Date startDate, Date endDate, Long ordern) throws SystemException, PortalException{
return addModule(companyId, groupId, userId, titleMap, descriptionMap, startDate, endDate, ordern, null);
}
@Indexable(type=IndexableType.REINDEX)
public Module addModule(Long companyId, Long groupId, Long userId,
String title, String description,
Date startDate, Date endDate, Long ordern, ServiceContext serviceContext) throws SystemException, PortalException {

Map<Locale, String> titleMap = new HashMap<Locale, String>();
titleMap.put(serviceContext.getLocale(), title);

Map<Locale, String> descriptionMap = new HashMap<Locale, String>();
descriptionMap.put(serviceContext.getLocale(), description);

return addModule(companyId, groupId, userId, titleMap, descriptionMap, startDate, endDate, ordern, serviceContext);
}
@Indexable(type=IndexableType.REINDEX)
public Module addModule(Long companyId, Long groupId, Long userId,
Map<Locale,String> titleMap, Map<Locale,String> descriptionMap,
Date startDate, Date endDate, Long ordern, ServiceContext serviceContext) throws SystemException, PortalException {
Module fileobj = modulePersistence.create(CounterLocalServiceUtil.increment(Module.class.getName()));

fileobj.setCompanyId(companyId);
Expand All @@ -425,8 +447,8 @@ public Module addModule(Long companyId, Long groupId, Long userId,
fileobj.setModifiedDate(new java.util.Date(System.currentTimeMillis()));
fileobj.setStartDate(startDate);
fileobj.setEndDate(endDate);
fileobj.setTitle(title);
fileobj.setDescription(description);
fileobj.setTitleMap(titleMap);
fileobj.setDescriptionMap(descriptionMap);
fileobj.setOrdern(ordern != null ? ordern : fileobj.getModuleId());

try {
Expand Down
Loading

0 comments on commit ce270fb

Please sign in to comment.